Skip to content

Commit 505b9e5

Browse files
committed
rm cap checks: add compiletests for non_uniform post-link removal
1 parent ddb039b commit 505b9e5

File tree

12 files changed

+486
-0
lines changed

12 files changed

+486
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble
3+
// compile-flags: -C target-feature=+RuntimeDescriptorArray,+StorageBufferArrayDynamicIndexing
4+
// compile-flags: -C target-feature=+ShaderNonUniform,+StorageBufferArrayNonUniformIndexing
5+
// normalize-stderr-test "OpSource .*\n" -> ""
6+
// normalize-stderr-test "OpLine .*\n" -> ""
7+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
8+
// normalize-stderr-test "; .*\n" -> ""
9+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
10+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
11+
// ignore-spv1.0
12+
// ignore-spv1.1
13+
// ignore-spv1.2
14+
// ignore-spv1.3
15+
// ignore-spv1.4
16+
// ignore-vulkan1.0
17+
// ignore-vulkan1.1
18+
19+
use spirv_std::glam::*;
20+
use spirv_std::image::*;
21+
use spirv_std::*;
22+
23+
#[spirv(vertex)]
24+
pub fn main(
25+
index: u32,
26+
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffers: &RuntimeArray<
27+
TypedBuffer<Vec4>,
28+
>,
29+
out: &mut Vec4,
30+
) {
31+
unsafe {
32+
*out = **buffers.index(index as usize);
33+
}
34+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
OpCapability Shader
2+
OpCapability StorageBufferArrayDynamicIndexing
3+
OpCapability ShaderNonUniform
4+
OpCapability RuntimeDescriptorArray
5+
OpCapability StorageBufferArrayNonUniformIndexing
6+
OpMemoryModel Logical Simple
7+
OpEntryPoint Vertex %1 "main" %2 %3 %4
8+
OpName %2 "index"
9+
OpName %3 "buffers"
10+
OpName %4 "out"
11+
OpDecorate %8 Block
12+
OpMemberDecorate %8 0 Offset 0
13+
OpDecorate %2 Location 0
14+
OpDecorate %3 NonWritable
15+
OpDecorate %3 Binding 0
16+
OpDecorate %3 DescriptorSet 0
17+
OpDecorate %4 Location 0
18+
OpDecorate %9 NonUniform
19+
%10 = OpTypeInt 32 0
20+
%11 = OpTypePointer Input %10
21+
%12 = OpTypeFloat 32
22+
%13 = OpTypeVector %12 4
23+
%8 = OpTypeStruct %13
24+
%14 = OpTypeRuntimeArray %8
25+
%15 = OpTypePointer StorageBuffer %14
26+
%16 = OpTypePointer Output %13
27+
%17 = OpTypeVoid
28+
%18 = OpTypeFunction %17
29+
%2 = OpVariable %11 Input
30+
%19 = OpTypePointer StorageBuffer %8
31+
%3 = OpVariable %15 StorageBuffer
32+
%20 = OpTypePointer StorageBuffer %13
33+
%21 = OpConstant %10 0
34+
%4 = OpVariable %16 Output
35+
%1 = OpFunction %17 None %18
36+
%22 = OpLabel
37+
%23 = OpLoad %10 %2
38+
%9 = OpAccessChain %19 %3 %23
39+
%24 = OpAccessChain %20 %9 %21
40+
%25 = OpLoad %13 %24
41+
OpStore %4 %25
42+
OpNoLine
43+
OpReturn
44+
OpFunctionEnd
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble
3+
// compile-flags: -C target-feature=+RuntimeDescriptorArray,+StorageBufferArrayDynamicIndexing
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-spv1.4
15+
// ignore-vulkan1.0
16+
// ignore-vulkan1.1
17+
18+
use spirv_std::glam::*;
19+
use spirv_std::image::*;
20+
use spirv_std::*;
21+
22+
#[spirv(vertex)]
23+
pub fn main(
24+
index: u32,
25+
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buffers: &RuntimeArray<
26+
TypedBuffer<Vec4>,
27+
>,
28+
out: &mut Vec4,
29+
) {
30+
unsafe {
31+
*out = **buffers.index(index as usize);
32+
}
33+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
OpCapability Shader
2+
OpCapability StorageBufferArrayDynamicIndexing
3+
OpCapability RuntimeDescriptorArray
4+
OpMemoryModel Logical Simple
5+
OpEntryPoint Vertex %1 "main" %2 %3 %4
6+
OpName %2 "index"
7+
OpName %3 "buffers"
8+
OpName %4 "out"
9+
OpDecorate %8 Block
10+
OpMemberDecorate %8 0 Offset 0
11+
OpDecorate %2 Location 0
12+
OpDecorate %3 NonWritable
13+
OpDecorate %3 Binding 0
14+
OpDecorate %3 DescriptorSet 0
15+
OpDecorate %4 Location 0
16+
%9 = OpTypeInt 32 0
17+
%10 = OpTypePointer Input %9
18+
%11 = OpTypeFloat 32
19+
%12 = OpTypeVector %11 4
20+
%8 = OpTypeStruct %12
21+
%13 = OpTypeRuntimeArray %8
22+
%14 = OpTypePointer StorageBuffer %13
23+
%15 = OpTypePointer Output %12
24+
%16 = OpTypeVoid
25+
%17 = OpTypeFunction %16
26+
%2 = OpVariable %10 Input
27+
%18 = OpTypePointer StorageBuffer %8
28+
%3 = OpVariable %14 StorageBuffer
29+
%19 = OpTypePointer StorageBuffer %12
30+
%20 = OpConstant %9 0
31+
%4 = OpVariable %15 Output
32+
%1 = OpFunction %16 None %17
33+
%21 = OpLabel
34+
%22 = OpLoad %9 %2
35+
%23 = OpAccessChain %18 %3 %22
36+
%24 = OpAccessChain %19 %23 %20
37+
%25 = OpLoad %12 %24
38+
OpStore %4 %25
39+
OpNoLine
40+
OpReturn
41+
OpFunctionEnd
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble
3+
// compile-flags: -C target-feature=+RuntimeDescriptorArray,+SampledImageArrayDynamicIndexing
4+
// compile-flags: -C target-feature=+ShaderNonUniform,+SampledImageArrayNonUniformIndexing
5+
// normalize-stderr-test "OpSource .*\n" -> ""
6+
// normalize-stderr-test "OpLine .*\n" -> ""
7+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
8+
// normalize-stderr-test "; .*\n" -> ""
9+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
10+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
11+
// ignore-spv1.0
12+
// ignore-spv1.1
13+
// ignore-spv1.2
14+
// ignore-spv1.3
15+
// ignore-spv1.4
16+
// ignore-vulkan1.0
17+
// ignore-vulkan1.1
18+
19+
use spirv_std::glam::*;
20+
use spirv_std::image::*;
21+
use spirv_std::*;
22+
23+
#[spirv(vertex)]
24+
pub fn main(
25+
index: u32,
26+
#[spirv(descriptor_set = 0, binding = 0)] images: &RuntimeArray<Image2d>,
27+
out: &mut Vec4,
28+
) {
29+
unsafe {
30+
*out = images.index(index as usize).fetch(UVec2::new(1, 2));
31+
}
32+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
OpCapability Shader
2+
OpCapability SampledImageArrayDynamicIndexing
3+
OpCapability ShaderNonUniform
4+
OpCapability RuntimeDescriptorArray
5+
OpCapability SampledImageArrayNonUniformIndexing
6+
OpMemoryModel Logical Simple
7+
OpEntryPoint Vertex %1 "main" %2 %3 %4
8+
OpName %2 "index"
9+
OpName %3 "images"
10+
OpName %4 "out"
11+
OpName %8 "<glam::f32::scalar::vec4::Vec4 as spirv_std::vector::VectorTruncateInto<glam::f32::scalar::vec4::Vec4>>::truncate_into"
12+
OpDecorate %2 Location 0
13+
OpDecorate %3 Binding 0
14+
OpDecorate %3 DescriptorSet 0
15+
OpDecorate %4 Location 0
16+
OpDecorate %9 NonUniform
17+
OpDecorate %10 NonUniform
18+
OpDecorate %11 NonUniform
19+
%12 = OpTypeInt 32 0
20+
%13 = OpTypePointer Input %12
21+
%14 = OpTypeFloat 32
22+
%15 = OpTypeImage %14 2D 2 0 0 1 Unknown
23+
%16 = OpTypeRuntimeArray %15
24+
%17 = OpTypePointer UniformConstant %16
25+
%18 = OpTypeVector %14 4
26+
%19 = OpTypePointer Output %18
27+
%20 = OpTypeVoid
28+
%21 = OpTypeFunction %20
29+
%2 = OpVariable %13 Input
30+
%22 = OpTypePointer UniformConstant %15
31+
%3 = OpVariable %17 UniformConstant
32+
%23 = OpTypeVector %12 2
33+
%24 = OpConstant %12 1
34+
%25 = OpConstant %12 2
35+
%26 = OpTypeFunction %18 %18
36+
%4 = OpVariable %19 Output
37+
%1 = OpFunction %20 None %21
38+
%27 = OpLabel
39+
%28 = OpLoad %12 %2
40+
%9 = OpAccessChain %22 %3 %28
41+
%29 = OpCompositeConstruct %23 %24 %25
42+
%10 = OpLoad %15 %9
43+
%11 = OpImageFetch %18 %10 %29
44+
%30 = OpFunctionCall %18 %8 %11
45+
OpStore %4 %30
46+
OpNoLine
47+
OpReturn
48+
OpFunctionEnd
49+
%8 = OpFunction %18 None %26
50+
%31 = OpFunctionParameter %18
51+
%32 = OpLabel
52+
OpReturnValue %31
53+
OpFunctionEnd
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble
3+
// compile-flags: -C target-feature=+RuntimeDescriptorArray,+SampledImageArrayDynamicIndexing
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-spv1.4
15+
// ignore-vulkan1.0
16+
// ignore-vulkan1.1
17+
18+
use spirv_std::glam::*;
19+
use spirv_std::image::*;
20+
use spirv_std::*;
21+
22+
#[spirv(vertex)]
23+
pub fn main(
24+
index: u32,
25+
#[spirv(descriptor_set = 0, binding = 0)] images: &RuntimeArray<Image2d>,
26+
out: &mut Vec4,
27+
) {
28+
unsafe {
29+
*out = images.index(index as usize).fetch(UVec2::new(1, 2));
30+
}
31+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
OpCapability Shader
2+
OpCapability SampledImageArrayDynamicIndexing
3+
OpCapability RuntimeDescriptorArray
4+
OpMemoryModel Logical Simple
5+
OpEntryPoint Vertex %1 "main" %2 %3 %4
6+
OpName %2 "index"
7+
OpName %3 "images"
8+
OpName %4 "out"
9+
OpName %8 "<glam::f32::scalar::vec4::Vec4 as spirv_std::vector::VectorTruncateInto<glam::f32::scalar::vec4::Vec4>>::truncate_into"
10+
OpDecorate %2 Location 0
11+
OpDecorate %3 Binding 0
12+
OpDecorate %3 DescriptorSet 0
13+
OpDecorate %4 Location 0
14+
%9 = OpTypeInt 32 0
15+
%10 = OpTypePointer Input %9
16+
%11 = OpTypeFloat 32
17+
%12 = OpTypeImage %11 2D 2 0 0 1 Unknown
18+
%13 = OpTypeRuntimeArray %12
19+
%14 = OpTypePointer UniformConstant %13
20+
%15 = OpTypeVector %11 4
21+
%16 = OpTypePointer Output %15
22+
%17 = OpTypeVoid
23+
%18 = OpTypeFunction %17
24+
%2 = OpVariable %10 Input
25+
%19 = OpTypePointer UniformConstant %12
26+
%3 = OpVariable %14 UniformConstant
27+
%20 = OpTypeVector %9 2
28+
%21 = OpConstant %9 1
29+
%22 = OpConstant %9 2
30+
%23 = OpTypeFunction %15 %15
31+
%4 = OpVariable %16 Output
32+
%1 = OpFunction %17 None %18
33+
%24 = OpLabel
34+
%25 = OpLoad %9 %2
35+
%26 = OpAccessChain %19 %3 %25
36+
%27 = OpCompositeConstruct %20 %21 %22
37+
%28 = OpLoad %12 %26
38+
%29 = OpImageFetch %15 %28 %27
39+
%30 = OpFunctionCall %15 %8 %29
40+
OpStore %4 %30
41+
OpNoLine
42+
OpReturn
43+
OpFunctionEnd
44+
%8 = OpFunction %15 None %23
45+
%31 = OpFunctionParameter %15
46+
%32 = OpLabel
47+
OpReturnValue %31
48+
OpFunctionEnd
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble
3+
// compile-flags: -C target-feature=+StorageImageExtendedFormats,+StorageImageReadWithoutFormat
4+
// compile-flags: -C target-feature=+RuntimeDescriptorArray,+StorageImageArrayDynamicIndexing
5+
// compile-flags: -C target-feature=+ShaderNonUniform,+StorageImageArrayNonUniformIndexing
6+
// normalize-stderr-test "OpSource .*\n" -> ""
7+
// normalize-stderr-test "OpLine .*\n" -> ""
8+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
9+
// normalize-stderr-test "; .*\n" -> ""
10+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
11+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
12+
// ignore-spv1.0
13+
// ignore-spv1.1
14+
// ignore-spv1.2
15+
// ignore-spv1.3
16+
// ignore-spv1.4
17+
// ignore-vulkan1.0
18+
// ignore-vulkan1.1
19+
20+
use spirv_std::glam::*;
21+
use spirv_std::image::*;
22+
use spirv_std::*;
23+
24+
#[spirv(vertex)]
25+
pub fn main(
26+
index: u32,
27+
#[spirv(descriptor_set = 0, binding = 0)] images: &RuntimeArray<StorageImage2d>,
28+
out: &mut Vec4,
29+
) {
30+
unsafe {
31+
*out = images.index(index as usize).read(UVec2::new(1, 2));
32+
}
33+
}

0 commit comments

Comments
 (0)