Skip to content

Commit df22992

Browse files
committed
move mod: split up mod arch::mesh_shading into mesh and task
1 parent c8e517c commit df22992

13 files changed

Lines changed: 51 additions & 45 deletions

File tree

crates/spirv-std/src/arch.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ mod atomics;
1414
mod barrier;
1515
mod demote_to_helper_invocation_ext;
1616
mod derivative;
17-
mod mesh_shading;
1817
mod ray_tracing;
1918
mod subgroup;
2019

2120
pub use atomics::*;
2221
pub use barrier::*;
2322
pub use demote_to_helper_invocation_ext::*;
2423
pub use derivative::*;
25-
pub use mesh_shading::*;
2624
pub use ray_tracing::*;
2725
pub use subgroup::*;
2826

crates/spirv-std/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ pub mod image;
9999
pub mod indirect_command;
100100
pub mod matrix;
101101
pub mod memory;
102+
pub mod mesh;
102103
pub mod ray_tracing;
103104
mod runtime_array;
104105
mod sampler;
105106
mod scalar;
106107
mod scalar_or_vector;
108+
pub mod task;
107109
mod typed_buffer;
108110
mod vector;
109111

crates/spirv-std/src/mesh.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//! Intrinsics for mesh shaders
2+
3+
#[cfg(target_arch = "spirv")]
4+
use core::arch::asm;
5+
6+
/// Sets the actual output size of the primitives and vertices that the mesh shader
7+
/// workgroup will emit upon completion.
8+
///
9+
/// 'Vertex Count' must be a 32-bit unsigned integer value.
10+
/// It defines the array size of per-vertex outputs.
11+
///
12+
/// 'Primitive Count' must a 32-bit unsigned integer value.
13+
/// It defines the array size of per-primitive outputs.
14+
///
15+
/// The arguments are taken from the first invocation in each workgroup.
16+
/// Any invocation must execute this instruction no more than once and under
17+
/// uniform control flow.
18+
/// There must not be any control flow path to an output write that is not preceded
19+
/// by this instruction.
20+
///
21+
/// This instruction is only valid in the *`MeshEXT`* Execution Model.
22+
///
23+
/// # Safety
24+
/// * Must be called **exactly once** in mesh shaders
25+
/// * Must be called in uniform control flow
26+
/// * Must not write any output before this instruction in invoked
27+
#[spirv_std_macros::gpu_only]
28+
#[doc(alias = "OpSetMeshOutputsEXT")]
29+
#[inline]
30+
pub unsafe fn set_mesh_outputs_ext(vertex_count: u32, primitive_count: u32) {
31+
unsafe {
32+
asm! {
33+
"OpSetMeshOutputsEXT {vertex_count} {primitive_count}",
34+
vertex_count = in(reg) vertex_count,
35+
primitive_count = in(reg) primitive_count,
36+
}
37+
}
38+
}
Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,8 @@
1+
//! Intrinsics for task shaders
2+
13
#[cfg(target_arch = "spirv")]
24
use core::arch::asm;
35

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-
///
21-
/// # Safety
22-
/// * Must be called **exactly once** in mesh shaders
23-
/// * Must be called in uniform control flow
24-
/// * Must not write any output before this instruction in invoked
25-
#[spirv_std_macros::gpu_only]
26-
#[doc(alias = "OpSetMeshOutputsEXT")]
27-
#[inline]
28-
pub unsafe fn set_mesh_outputs_ext(vertex_count: u32, primitive_count: u32) {
29-
unsafe {
30-
asm! {
31-
"OpSetMeshOutputsEXT {vertex_count} {primitive_count}",
32-
vertex_count = in(reg) vertex_count,
33-
primitive_count = in(reg) primitive_count,
34-
}
35-
}
36-
}
37-
386
/// Defines the grid size of subsequent mesh shader workgroups to generate
397
/// upon completion of the task shader workgroup.
408
///

tests/compiletests/ui/arch/mesh_shader_output_lines.rs renamed to tests/compiletests/ui/entry/mesh/mesh_shader_output_lines.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// only-vulkan1.2
33
// compile-flags: -Ctarget-feature=+MeshShadingEXT,+ext:SPV_EXT_mesh_shader
44

5-
use spirv_std::arch::set_mesh_outputs_ext;
65
use spirv_std::glam::{UVec2, Vec4};
6+
use spirv_std::mesh::set_mesh_outputs_ext;
77
use spirv_std::spirv;
88

99
#[spirv(mesh_ext(

tests/compiletests/ui/arch/mesh_shader_output_points.rs renamed to tests/compiletests/ui/entry/mesh/mesh_shader_output_points.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// only-vulkan1.2
33
// compile-flags: -Ctarget-feature=+MeshShadingEXT,+ext:SPV_EXT_mesh_shader
44

5-
use spirv_std::arch::set_mesh_outputs_ext;
65
use spirv_std::glam::{UVec2, Vec4};
6+
use spirv_std::mesh::set_mesh_outputs_ext;
77
use spirv_std::spirv;
88

99
#[spirv(mesh_ext(

tests/compiletests/ui/arch/mesh_shader_output_triangles.rs renamed to tests/compiletests/ui/entry/mesh/mesh_shader_output_triangles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// only-vulkan1.2
33
// compile-flags: -Ctarget-feature=+MeshShadingEXT,+ext:SPV_EXT_mesh_shader
44

5-
use spirv_std::arch::set_mesh_outputs_ext;
65
use spirv_std::glam::{UVec3, Vec4};
6+
use spirv_std::mesh::set_mesh_outputs_ext;
77
use spirv_std::spirv;
88

99
#[spirv(mesh_ext(

tests/compiletests/ui/arch/mesh_shader_payload.rs renamed to tests/compiletests/ui/entry/mesh/mesh_shader_payload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// only-vulkan1.2
33
// compile-flags: -Ctarget-feature=+MeshShadingEXT,+ext:SPV_EXT_mesh_shader
44

5-
use spirv_std::arch::set_mesh_outputs_ext;
65
use spirv_std::glam::{UVec3, Vec4};
6+
use spirv_std::mesh::set_mesh_outputs_ext;
77
use spirv_std::spirv;
88

99
pub struct Payload {

tests/compiletests/ui/arch/mesh_shader_per_primitive.rs renamed to tests/compiletests/ui/entry/mesh/mesh_shader_per_primitive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// only-vulkan1.2
33
// compile-flags: -Ctarget-feature=+MeshShadingEXT,+ext:SPV_EXT_mesh_shader
44

5-
use spirv_std::arch::set_mesh_outputs_ext;
65
use spirv_std::glam::{UVec3, Vec4};
6+
use spirv_std::mesh::set_mesh_outputs_ext;
77
use spirv_std::spirv;
88

99
#[spirv(mesh_ext(

tests/compiletests/ui/arch/task_shader.rs renamed to tests/compiletests/ui/entry/task/task_shader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
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;
65
use spirv_std::spirv;
6+
use spirv_std::task::emit_mesh_tasks_ext;
77

88
#[spirv(task_ext(threads(1)))]
99
pub fn main() {

0 commit comments

Comments
 (0)