Skip to content

Commit 0ac78d2

Browse files
committed
shared: compiletest for unused shared memory, failing
1 parent 2232fcb commit 0ac78d2

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble-globals
3+
// normalize-stderr-test "OpSource .*\n" -> ""
4+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
5+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
6+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
7+
// ignore-spv1.0
8+
// ignore-spv1.1
9+
// ignore-spv1.2
10+
// ignore-spv1.3
11+
// ignore-vulkan1.0
12+
// ignore-vulkan1.1
13+
14+
use spirv_std::arch::workgroup_memory_barrier_with_group_sync;
15+
use spirv_std::glam::*;
16+
use spirv_std::spirv;
17+
18+
#[spirv(compute(threads(2)))]
19+
pub fn main(
20+
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] input: &f32,
21+
#[spirv(descriptor_set = 0, binding = 1, storage_buffer)] output: &mut f32,
22+
#[spirv(workgroup)] used_shared: &mut f32,
23+
#[spirv(workgroup)] dce_shared: &mut [i32; 2],
24+
#[spirv(local_invocation_index)] inv_id: UVec3,
25+
) {
26+
unsafe {
27+
let inv_id = inv_id.x as usize;
28+
if inv_id == 0 {
29+
*used_shared = *input;
30+
}
31+
workgroup_memory_barrier_with_group_sync();
32+
if inv_id == 1 {
33+
*output = *used_shared;
34+
}
35+
}
36+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
OpCapability Shader
2+
OpMemoryModel Logical Simple
3+
OpEntryPoint GLCompute %1 "main" %2 %3 %4 %5 %6
4+
OpExecutionMode %1 LocalSize 2 1 1
5+
OpName %2 "input"
6+
OpName %3 "output"
7+
OpName %6 "inv_id"
8+
OpName %4 "used_shared"
9+
OpName %5 "dce_shared"
10+
OpDecorate %9 Block
11+
OpMemberDecorate %9 0 Offset 0
12+
OpDecorate %10 ArrayStride 4
13+
OpDecorate %2 NonWritable
14+
OpDecorate %2 Binding 0
15+
OpDecorate %2 DescriptorSet 0
16+
OpDecorate %3 Binding 1
17+
OpDecorate %3 DescriptorSet 0
18+
OpDecorate %6 BuiltIn LocalInvocationIndex
19+
%11 = OpTypeFloat 32
20+
%9 = OpTypeStruct %11
21+
%12 = OpTypePointer StorageBuffer %9
22+
%13 = OpTypePointer Workgroup %11
23+
%14 = OpTypeInt 32 1
24+
%15 = OpTypeInt 32 0
25+
%16 = OpConstant %15 2
26+
%10 = OpTypeArray %14 %16
27+
%17 = OpTypePointer Workgroup %10
28+
%18 = OpTypeVector %15 3
29+
%19 = OpTypePointer Input %18
30+
%20 = OpTypeVoid
31+
%21 = OpTypeFunction %20
32+
%22 = OpTypePointer StorageBuffer %11
33+
%2 = OpVariable %12 StorageBuffer
34+
%23 = OpConstant %15 0
35+
%3 = OpVariable %12 StorageBuffer
36+
%6 = OpVariable %19 Input
37+
%24 = OpTypeBool
38+
%4 = OpVariable %13 Workgroup
39+
%25 = OpConstant %15 264
40+
%26 = OpConstant %15 1
41+
%5 = OpVariable %17 Workgroup
42+
error: error:0:0 - [VUID-StandaloneSpirv-None-10684] Invalid explicit layout decorations on type for operand '17[%_ptr_Workgroup__arr_int_uint_2]'
43+
%dce_shared = OpVariable %_ptr_Workgroup__arr_int_uint_2 Workgroup
44+
|
45+
= note: spirv-val failed
46+
= note: module `$TEST_BUILD_DIR/arch/shared/dce_shared.vulkan1.2`
47+
48+
error: aborting due to 1 previous error
49+

0 commit comments

Comments
 (0)