Skip to content

Commit c8e517c

Browse files
committed
move mod: move mod arch::primitive to geometry
1 parent 3089687 commit c8e517c

10 files changed

Lines changed: 91 additions & 7 deletions

File tree

crates/spirv-std/src/arch.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ mod barrier;
1515
mod demote_to_helper_invocation_ext;
1616
mod derivative;
1717
mod mesh_shading;
18-
mod primitive;
1918
mod ray_tracing;
2019
mod subgroup;
2120

@@ -24,7 +23,6 @@ pub use barrier::*;
2423
pub use demote_to_helper_invocation_ext::*;
2524
pub use derivative::*;
2625
pub use mesh_shading::*;
27-
pub use primitive::*;
2826
pub use ray_tracing::*;
2927
pub use subgroup::*;
3028

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Intrinsics for geometry shaders
2+
13
#[cfg(target_arch = "spirv")]
24
use core::arch::asm;
35

crates/spirv-std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub mod arch;
9494
pub mod byte_addressable_buffer;
9595
pub mod debug_printf;
9696
pub mod float;
97+
pub mod geometry;
9798
pub mod image;
9899
pub mod indirect_command;
99100
pub mod matrix;

tests/compiletests/ui/arch/emit_stream_vertex.rs renamed to tests/compiletests/ui/entry/geometry/emit_stream_vertex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ use spirv_std::spirv;
66
#[spirv(geometry(input_lines = 2, output_points = 2))]
77
pub fn main() {
88
unsafe {
9-
spirv_std::arch::emit_stream_vertex::<2>();
9+
spirv_std::geometry::emit_stream_vertex::<2>();
1010
};
1111
}

tests/compiletests/ui/arch/emit_vertex.rs renamed to tests/compiletests/ui/entry/geometry/emit_vertex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ use spirv_std::spirv;
66
#[spirv(geometry(input_lines = 2, output_points = 2))]
77
pub fn main() {
88
unsafe {
9-
spirv_std::arch::emit_vertex();
9+
spirv_std::geometry::emit_vertex();
1010
};
1111
}

tests/compiletests/ui/arch/end_primitive.rs renamed to tests/compiletests/ui/entry/geometry/end_primitive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ use spirv_std::spirv;
66
#[spirv(geometry(input_lines = 2, output_points = 2))]
77
pub fn main() {
88
unsafe {
9-
spirv_std::arch::end_primitive();
9+
spirv_std::geometry::end_primitive();
1010
};
1111
}

tests/compiletests/ui/arch/end_stream_primitive.rs renamed to tests/compiletests/ui/entry/geometry/end_stream_primitive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ use spirv_std::spirv;
66
#[spirv(geometry(input_lines = 2, output_points = 2))]
77
pub fn main() {
88
unsafe {
9-
spirv_std::arch::end_stream_primitive::<2>();
9+
spirv_std::geometry::end_stream_primitive::<2>();
1010
};
1111
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// build-pass
2+
// compile-flags: -Ctarget-feature=+Geometry
3+
// compile-flags: -C llvm-args=--disassemble
4+
// normalize-stderr-test "OpSource .*\n" -> ""
5+
// normalize-stderr-test "OpLine .*\n" -> ""
6+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
7+
// normalize-stderr-test "; .*\n" -> ""
8+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
9+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
10+
// ignore-spv1.0
11+
// ignore-spv1.1
12+
// ignore-spv1.2
13+
// ignore-spv1.3
14+
// ignore-vulkan1.0
15+
// ignore-vulkan1.1
16+
17+
use spirv_std::geometry::{emit_vertex, end_primitive};
18+
use spirv_std::glam::*;
19+
use spirv_std::spirv;
20+
21+
#[spirv(geometry(input_points = 2, output_triangle_strip = 1))]
22+
pub fn main(#[spirv(position)] position_in: [Vec4; 2], #[spirv(position)] position_out: &mut Vec4) {
23+
unsafe {
24+
*position_out = position_in[0] + vec4(-0.1, 0.0, 0.0, 0.0);
25+
emit_vertex();
26+
*position_out = position_in[1] + vec4(0.1, 0.0, 0.0, 0.0);
27+
emit_vertex();
28+
*position_out = position_in[1] + vec4(0.0, 0.1, 0.0, 0.0);
29+
emit_vertex();
30+
end_primitive();
31+
};
32+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
OpCapability Shader
2+
OpCapability Geometry
3+
OpMemoryModel Logical Simple
4+
OpEntryPoint Geometry %1 "main" %2 %3
5+
OpExecutionMode %1 InputPoints
6+
OpExecutionMode %1 OutputTriangleStrip
7+
OpName %2 "position_in"
8+
OpName %3 "position_out"
9+
OpDecorate %2 BuiltIn Position
10+
OpDecorate %8 ArrayStride 16
11+
OpDecorate %3 BuiltIn Position
12+
%9 = OpTypeFloat 32
13+
%10 = OpTypeVector %9 4
14+
%11 = OpTypeInt 32 0
15+
%12 = OpConstant %11 2
16+
%13 = OpTypeArray %10 %12
17+
%14 = OpTypePointer Input %13
18+
%15 = OpTypePointer Output %10
19+
%16 = OpTypeVoid
20+
%17 = OpTypeFunction %16
21+
%2 = OpVariable %14 Input
22+
%8 = OpTypeArray %10 %12
23+
%18 = OpConstant %9 -0.1
24+
%19 = OpConstant %9 0
25+
%3 = OpVariable %15 Output
26+
%20 = OpConstant %9 0.1
27+
%1 = OpFunction %16 None %17
28+
%21 = OpLabel
29+
%22 = OpLoad %13 %2
30+
%23 = OpCompositeExtract %10 %22 0
31+
%24 = OpCompositeExtract %10 %22 1
32+
%25 = OpCompositeConstruct %8 %23 %24
33+
%26 = OpCompositeExtract %10 %25 0
34+
%27 = OpCompositeConstruct %10 %18 %19 %19 %19
35+
%28 = OpFAdd %10 %26 %27
36+
OpStore %3 %28
37+
OpEmitVertex
38+
%29 = OpCompositeExtract %10 %25 1
39+
%30 = OpCompositeConstruct %10 %20 %19 %19 %19
40+
%31 = OpFAdd %10 %29 %30
41+
OpStore %3 %31
42+
OpEmitVertex
43+
%32 = OpCompositeExtract %10 %25 1
44+
%33 = OpCompositeConstruct %10 %19 %20 %19 %19
45+
%34 = OpFAdd %10 %32 %33
46+
OpStore %3 %34
47+
OpEmitVertex
48+
OpEndPrimitive
49+
OpNoLine
50+
OpReturn
51+
OpFunctionEnd

tests/compiletests/ui/spirv-attr/location_assignment/geometry_shader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// ignore-vulkan1.0
1515
// ignore-vulkan1.1
1616

17-
use spirv_std::arch::{emit_vertex, end_primitive};
17+
use spirv_std::geometry::{emit_vertex, end_primitive};
1818
use spirv_std::glam::*;
1919
use spirv_std::spirv;
2020

0 commit comments

Comments
 (0)