Skip to content

Commit 043a887

Browse files
committed
location assignment2: compiletest showing wrong locations with mesh and geometry shaders
1 parent bc32a2a commit 043a887

File tree

4 files changed

+235
-0
lines changed

4 files changed

+235
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// build-pass
2+
// compile-flags: -Ctarget-feature=+Geometry
3+
// compile-flags: -C llvm-args=--disassemble-globals
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::arch::{emit_vertex, end_primitive};
18+
use spirv_std::glam::*;
19+
use spirv_std::spirv;
20+
21+
pub struct Attr1 {
22+
pub a: Vec4,
23+
pub b: Vec2,
24+
pub c: f32,
25+
}
26+
27+
pub struct Attr2 {
28+
pub d: f32,
29+
}
30+
31+
#[spirv(geometry(input_points = 2, output_line_strip = 2))]
32+
pub fn main(
33+
// #[spirv(descriptor_set = 0, binding = 0, storage_buffer)]
34+
#[spirv(position)] position_in: Vec4,
35+
#[spirv(position)] position_out: &mut Vec4,
36+
// location 0
37+
attr1_in: [f32; 2],
38+
// location 0
39+
attr1_out: &mut f32,
40+
// location 1
41+
attr2_in: [u32; 2],
42+
// location 1
43+
attr2_out: &mut u32,
44+
) {
45+
unsafe {
46+
*attr1_out = attr1_in[0];
47+
*attr2_out = attr2_in[0];
48+
*position_out = position_in + vec4(-0.1, 0.0, 0.0, 0.0);
49+
emit_vertex();
50+
51+
*attr1_out = attr1_in[1];
52+
*attr2_out = attr2_in[1];
53+
*position_out = position_in + vec4(0.1, 0.0, 0.0, 0.0);
54+
emit_vertex();
55+
56+
end_primitive();
57+
};
58+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
OpCapability Shader
2+
OpCapability Geometry
3+
OpMemoryModel Logical Simple
4+
OpEntryPoint Geometry %1 "main" %2 %3 %4 %5 %6 %7
5+
OpExecutionMode %1 InputPoints
6+
OpExecutionMode %1 OutputLineStrip
7+
OpName %2 "position_in"
8+
OpName %3 "attr1_in"
9+
OpName %4 "attr2_in"
10+
OpName %5 "attr1_out"
11+
OpName %6 "attr2_out"
12+
OpName %7 "position_out"
13+
OpDecorate %2 BuiltIn Position
14+
OpDecorate %3 Location 0
15+
OpDecorate %12 ArrayStride 4
16+
OpDecorate %4 Location 2
17+
OpDecorate %13 ArrayStride 4
18+
OpDecorate %5 Location 0
19+
OpDecorate %6 Location 1
20+
OpDecorate %7 BuiltIn Position
21+
%14 = OpTypeFloat 32
22+
%15 = OpTypeVector %14 4
23+
%16 = OpTypePointer Input %15
24+
%17 = OpTypePointer Output %15
25+
%18 = OpTypeInt 32 0
26+
%19 = OpConstant %18 2
27+
%20 = OpTypeArray %14 %19
28+
%21 = OpTypePointer Input %20
29+
%22 = OpTypePointer Output %14
30+
%23 = OpTypeArray %18 %19
31+
%24 = OpTypePointer Input %23
32+
%25 = OpTypePointer Output %18
33+
%26 = OpTypeVoid
34+
%27 = OpTypeFunction %26
35+
%2 = OpVariable %16 Input
36+
%3 = OpVariable %21 Input
37+
%12 = OpTypeArray %14 %19
38+
%4 = OpVariable %24 Input
39+
%13 = OpTypeArray %18 %19
40+
%5 = OpVariable %22 Output
41+
%6 = OpVariable %25 Output
42+
%28 = OpConstant %14 3184315597
43+
%29 = OpConstant %14 0
44+
%7 = OpVariable %17 Output
45+
%30 = OpConstant %14 1036831949
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// build-pass
2+
// compile-flags: -Ctarget-feature=+MeshShadingEXT,+ext:SPV_EXT_mesh_shader
3+
// compile-flags: -C llvm-args=--disassemble-globals
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::arch::set_mesh_outputs_ext;
18+
use spirv_std::glam::{UVec3, Vec4};
19+
use spirv_std::spirv;
20+
21+
#[spirv(mesh_ext(
22+
threads(1),
23+
output_vertices = 9,
24+
output_primitives_ext = 3,
25+
output_triangles_ext
26+
))]
27+
pub fn main(
28+
#[spirv(position)] positions: &mut [Vec4; 9],
29+
#[spirv(primitive_triangle_indices_ext)] indices: &mut [UVec3; 3],
30+
// location 0
31+
out_per_vertex: &mut [u32; 9],
32+
// location 1
33+
out_per_vertex2: &mut [f32; 9],
34+
// location 2
35+
#[spirv(per_primitive_ext)] out_per_primitive: &mut [u32; 3],
36+
// location 3
37+
#[spirv(per_primitive_ext)] out_per_primitive2: &mut [f32; 3],
38+
) {
39+
unsafe {
40+
set_mesh_outputs_ext(9, 3);
41+
}
42+
43+
for i in 0..3 {
44+
positions[i * 3 + 0] = Vec4::new(-0.5, 0.5, 0.0, 1.0);
45+
positions[i * 3 + 1] = Vec4::new(0.5, 0.5, 0.0, 1.0);
46+
positions[i * 3 + 2] = Vec4::new(0.0, -0.5, 0.0, 1.0);
47+
}
48+
49+
for i in 0..9 {
50+
out_per_vertex[i] = i as u32;
51+
out_per_vertex2[i] = i as f32;
52+
}
53+
54+
for i in 0..3 {
55+
indices[i] = UVec3::new(0, 1, 2) + UVec3::splat(i as u32);
56+
out_per_primitive[i] = 42;
57+
out_per_primitive2[i] = 69.;
58+
}
59+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
OpCapability Shader
2+
OpCapability MeshShadingEXT
3+
OpExtension "SPV_EXT_mesh_shader"
4+
OpMemoryModel Logical Simple
5+
OpEntryPoint MeshEXT %1 "main" %2 %3 %4 %5 %6 %7
6+
OpExecutionMode %1 LocalSize 1 1 1
7+
OpExecutionMode %1 OutputVertices 9
8+
OpExecutionMode %1 OutputPrimitivesNV 3
9+
OpExecutionMode %1 OutputTrianglesNV
10+
OpName %16 "core::ops::Range<usize>"
11+
OpMemberName %16 0 "start"
12+
OpMemberName %16 1 "end"
13+
OpName %2 "positions"
14+
OpName %3 "out_per_vertex"
15+
OpName %4 "out_per_vertex2"
16+
OpName %5 "indices"
17+
OpName %6 "out_per_primitive"
18+
OpName %7 "out_per_primitive2"
19+
OpMemberDecorate %16 0 Offset 0
20+
OpMemberDecorate %16 1 Offset 4
21+
OpDecorate %2 BuiltIn Position
22+
OpDecorate %3 Location 0
23+
OpDecorate %4 Location 9
24+
OpDecorate %5 BuiltIn PrimitiveTriangleIndicesEXT
25+
OpDecorate %6 Location 18
26+
OpDecorate %6 PerPrimitiveNV
27+
OpDecorate %7 Location 21
28+
OpDecorate %7 PerPrimitiveNV
29+
%17 = OpTypeFloat 32
30+
%18 = OpTypeVector %17 4
31+
%19 = OpTypeInt 32 0
32+
%20 = OpConstant %19 9
33+
%21 = OpTypeArray %18 %20
34+
%22 = OpTypePointer Output %21
35+
%23 = OpTypeVector %19 3
36+
%24 = OpConstant %19 3
37+
%25 = OpTypeArray %23 %24
38+
%26 = OpTypePointer Output %25
39+
%27 = OpTypeArray %19 %20
40+
%28 = OpTypePointer Output %27
41+
%29 = OpTypeArray %17 %20
42+
%30 = OpTypePointer Output %29
43+
%31 = OpTypeArray %19 %24
44+
%32 = OpTypePointer Output %31
45+
%33 = OpTypeArray %17 %24
46+
%34 = OpTypePointer Output %33
47+
%35 = OpTypeVoid
48+
%36 = OpTypeFunction %35
49+
%16 = OpTypeStruct %19 %19
50+
%37 = OpConstant %19 0
51+
%38 = OpUndef %16
52+
%39 = OpTypeBool
53+
%40 = OpConstantFalse %39
54+
%41 = OpConstant %19 1
55+
%42 = OpTypeInt 32 1
56+
%43 = OpConstant %42 0
57+
%44 = OpConstant %17 3204448256
58+
%45 = OpConstant %17 1056964608
59+
%46 = OpConstant %17 0
60+
%47 = OpConstant %17 1065353216
61+
%48 = OpTypePointer Output %18
62+
%2 = OpVariable %22 Output
63+
%49 = OpConstant %19 2
64+
%50 = OpTypePointer Output %19
65+
%3 = OpVariable %28 Output
66+
%51 = OpTypePointer Output %17
67+
%4 = OpVariable %30 Output
68+
%52 = OpTypePointer Output %23
69+
%5 = OpVariable %26 Output
70+
%6 = OpVariable %32 Output
71+
%53 = OpConstant %19 42
72+
%7 = OpVariable %34 Output
73+
%54 = OpConstant %17 1116340224

0 commit comments

Comments
 (0)