spirv_std/arch/
mesh_shading.rs

1#[cfg(target_arch = "spirv")]
2use core::arch::asm;
3
4/// Sets the actual output size of the primitives and vertices that the mesh shader
5/// workgroup will emit upon completion.
6///
7/// 'Vertex Count' must be a 32-bit unsigned integer value.
8/// It defines the array size of per-vertex outputs.
9///
10/// 'Primitive Count' must a 32-bit unsigned integer value.
11/// It defines the array size of per-primitive outputs.
12///
13/// The arguments are taken from the first invocation in each workgroup.
14/// Any invocation must execute this instruction no more than once and under
15/// uniform control flow.
16/// There must not be any control flow path to an output write that is not preceded
17/// by this instruction.
18///
19/// This instruction is only valid in the *`MeshEXT`* Execution Model.
20#[spirv_std_macros::gpu_only]
21#[doc(alias = "OpSetMeshOutputsEXT")]
22#[inline]
23pub unsafe fn set_mesh_outputs_ext(vertex_count: u32, primitive_count: u32) {
24    unsafe {
25        asm! {
26            "OpSetMeshOutputsEXT {vertex_count} {primitive_count}",
27            vertex_count = in(reg) vertex_count,
28            primitive_count = in(reg) primitive_count,
29        }
30    }
31}
32
33/// Defines the grid size of subsequent mesh shader workgroups to generate
34/// upon completion of the task shader workgroup.
35///
36/// 'Group Count X Y Z' must each be a 32-bit unsigned integer value.
37/// They configure the number of local workgroups in each respective dimensions
38/// for the launch of child mesh tasks. See Vulkan API specification for more detail.
39///
40/// 'Payload' is an optional pointer to the payload structure to pass to the generated mesh shader invocations.
41/// 'Payload' must be the result of an *`OpVariable`* with a storage class of *`TaskPayloadWorkgroupEXT`*.
42///
43/// The arguments are taken from the first invocation in each workgroup.
44/// Any invocation must execute this instruction exactly once and under uniform
45/// control flow.
46/// This instruction also serves as an *OpControlBarrier* instruction, and also
47/// performs and adheres to the description and semantics of an *OpControlBarrier*
48/// instruction with the 'Execution' and 'Memory' operands set to *Workgroup* and
49/// the 'Semantics' operand set to a combination of *`WorkgroupMemory`* and
50/// *`AcquireRelease`*.
51/// Ceases all further processing: Only instructions executed before
52/// *`OpEmitMeshTasksEXT`* have observable side effects.
53///
54/// This instruction must be the last instruction in a block.
55///
56/// This instruction is only valid in the *`TaskEXT`* Execution Model.
57#[spirv_std_macros::gpu_only]
58#[doc(alias = "OpEmitMeshTasksEXT")]
59#[inline]
60pub unsafe fn emit_mesh_tasks_ext(group_count_x: u32, group_count_y: u32, group_count_z: u32) -> ! {
61    unsafe {
62        asm! {
63            "OpEmitMeshTasksEXT {group_count_x} {group_count_y} {group_count_z}",
64            group_count_x = in(reg) group_count_x,
65            group_count_y = in(reg) group_count_y,
66            group_count_z = in(reg) group_count_z,
67            options(noreturn),
68        }
69    }
70}
71
72/// Defines the grid size of subsequent mesh shader workgroups to generate
73/// upon completion of the task shader workgroup.
74///
75/// 'Group Count X Y Z' must each be a 32-bit unsigned integer value.
76/// They configure the number of local workgroups in each respective dimensions
77/// for the launch of child mesh tasks. See Vulkan API specification for more detail.
78///
79/// 'Payload' is an optional pointer to the payload structure to pass to the generated mesh shader invocations.
80/// 'Payload' must be the result of an *`OpVariable`* with a storage class of *`TaskPayloadWorkgroupEXT`*.
81///
82/// The arguments are taken from the first invocation in each workgroup.
83/// Any invocation must execute this instruction exactly once and under uniform
84/// control flow.
85/// This instruction also serves as an *OpControlBarrier* instruction, and also
86/// performs and adheres to the description and semantics of an *OpControlBarrier*
87/// instruction with the 'Execution' and 'Memory' operands set to *Workgroup* and
88/// the 'Semantics' operand set to a combination of *`WorkgroupMemory`* and
89/// *`AcquireRelease`*.
90/// Ceases all further processing: Only instructions executed before
91/// *`OpEmitMeshTasksEXT`* have observable side effects.
92///
93/// This instruction must be the last instruction in a block.
94///
95/// This instruction is only valid in the *`TaskEXT`* Execution Model.
96#[spirv_std_macros::gpu_only]
97#[doc(alias = "OpEmitMeshTasksEXT")]
98#[inline]
99pub unsafe fn emit_mesh_tasks_ext_payload<T>(
100    group_count_x: u32,
101    group_count_y: u32,
102    group_count_z: u32,
103    payload: &mut T,
104) -> ! {
105    unsafe {
106        asm! {
107            "OpEmitMeshTasksEXT {group_count_x} {group_count_y} {group_count_z} {payload}",
108            group_count_x = in(reg) group_count_x,
109            group_count_y = in(reg) group_count_y,
110            group_count_z = in(reg) group_count_z,
111            payload = in(reg) payload,
112            options(noreturn),
113        }
114    }
115}