Skip to content

Commit 6656fef

Browse files
committed
shared: compiletest for unused shared memory, failing
1 parent e116d8b commit 6656fef

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-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-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+
12+
use spirv_std::arch::workgroup_memory_barrier_with_group_sync;
13+
use spirv_std::glam::*;
14+
use spirv_std::spirv;
15+
16+
#[spirv(compute(threads(2)))]
17+
pub fn main(
18+
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] input: &f32,
19+
#[spirv(descriptor_set = 0, binding = 1, storage_buffer)] output: &mut f32,
20+
#[spirv(workgroup)] used_shared: &mut f32,
21+
#[spirv(workgroup)] dce_shared: &mut [i32; 2],
22+
#[spirv(local_invocation_index)] inv_id: UVec3,
23+
) {
24+
unsafe {
25+
let inv_id = inv_id.x as usize;
26+
if inv_id == 0 {
27+
*used_shared = *input;
28+
}
29+
workgroup_memory_barrier_with_group_sync();
30+
if inv_id == 1 {
31+
*output = *used_shared;
32+
}
33+
}
34+
}
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)