Skip to content

Commit c7a72a3

Browse files
committed
mesh shader ext: fix task shader payload passing
1 parent c6adc14 commit c7a72a3

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

crates/spirv-std/src/arch/mesh_shading.rs

+43
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,46 @@ pub unsafe fn emit_mesh_tasks_ext(group_count_x: u32, group_count_y: u32, group_
6464
options(noreturn),
6565
}
6666
}
67+
68+
/// Defines the grid size of subsequent mesh shader workgroups to generate
69+
/// upon completion of the task shader workgroup.
70+
///
71+
/// 'Group Count X Y Z' must each be a 32-bit unsigned integer value.
72+
/// They configure the number of local workgroups in each respective dimensions
73+
/// for the launch of child mesh tasks. See Vulkan API specification for more detail.
74+
///
75+
/// 'Payload' is an optional pointer to the payload structure to pass to the generated mesh shader invocations.
76+
/// 'Payload' must be the result of an *OpVariable* with a storage class of *TaskPayloadWorkgroupEXT*.
77+
///
78+
/// The arguments are taken from the first invocation in each workgroup.
79+
/// Any invocation must execute this instruction exactly once and under uniform
80+
/// control flow.
81+
/// This instruction also serves as an *OpControlBarrier* instruction, and also
82+
/// performs and adheres to the description and semantics of an *OpControlBarrier*
83+
/// instruction with the 'Execution' and 'Memory' operands set to *Workgroup* and
84+
/// the 'Semantics' operand set to a combination of *WorkgroupMemory* and
85+
/// *AcquireRelease*.
86+
/// Ceases all further processing: Only instructions executed before
87+
/// *OpEmitMeshTasksEXT* have observable side effects.
88+
///
89+
/// This instruction must be the last instruction in a block.
90+
///
91+
/// This instruction is only valid in the *TaskEXT* Execution Model.
92+
#[spirv_std_macros::gpu_only]
93+
#[doc(alias = "OpEmitMeshTasksEXT")]
94+
#[inline]
95+
pub unsafe fn emit_mesh_tasks_ext_payload<T>(
96+
group_count_x: u32,
97+
group_count_y: u32,
98+
group_count_z: u32,
99+
payload: &mut T,
100+
) -> ! {
101+
asm! {
102+
"OpEmitMeshTasksEXT {group_count_x} {group_count_y} {group_count_z} {payload}",
103+
group_count_x = in(reg) group_count_x,
104+
group_count_y = in(reg) group_count_y,
105+
group_count_z = in(reg) group_count_z,
106+
payload = in(reg) payload,
107+
options(noreturn),
108+
}
109+
}

tests/ui/arch/task_shader_payload.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// only-vulkan1.2
33
// compile-flags: -Ctarget-feature=+MeshShadingEXT,+ext:SPV_EXT_mesh_shader
44

5-
use spirv_std::arch::emit_mesh_tasks_ext;
5+
use spirv_std::arch::emit_mesh_tasks_ext_payload;
66
use spirv_std::spirv;
77

88
pub struct Payload {
@@ -16,6 +16,6 @@ pub fn main(#[spirv(task_payload_workgroup_ext)] payload: &mut Payload) {
1616
payload.second = 2;
1717

1818
unsafe {
19-
emit_mesh_tasks_ext(3, 4, 5);
19+
emit_mesh_tasks_ext_payload(3, 4, 5, payload);
2020
}
2121
}

0 commit comments

Comments
 (0)