Skip to content

Commit c6a3112

Browse files
committed
dedup OpVariable: add compiletests showing failure when both attr and getter are used
1 parent eb94b19 commit c6a3112

12 files changed

+336
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble
3+
// normalize-stderr-test "OpLine .*\n" -> ""
4+
// normalize-stderr-test "OpSource .*\n" -> ""
5+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
6+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
7+
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
8+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
9+
// normalize-stderr-test "; .*\n" -> ""
10+
11+
// ignore-spv1.0
12+
// ignore-spv1.1
13+
// ignore-spv1.2
14+
// ignore-vulkan1.0
15+
// ignore-vulkan1.1
16+
17+
use core::arch::asm;
18+
use spirv_std::{glam::*, spirv};
19+
20+
#[spirv(compute(threads(1)))]
21+
pub fn entry_1(
22+
#[spirv(local_invocation_index)] _local_id1: u32,
23+
#[spirv(local_invocation_index)] _local_id2: u32,
24+
) {
25+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
OpCapability Shader
2+
OpMemoryModel Logical Simple
3+
OpEntryPoint GLCompute %1 "entry_1" %2 %3
4+
OpExecutionMode %1 LocalSize 1 1 1
5+
OpName %3 "_local_id2"
6+
OpName %5 "attr_duplicate::entry_1"
7+
OpDecorate %2 BuiltIn LocalInvocationIndex
8+
OpDecorate %3 BuiltIn LocalInvocationIndex
9+
%6 = OpTypeInt 32 0
10+
%7 = OpTypePointer Input %6
11+
%8 = OpTypeVoid
12+
%9 = OpTypeFunction %8
13+
%2 = OpVariable %7 Input
14+
%3 = OpVariable %7 Input
15+
%10 = OpTypeFunction %8 %6 %6
16+
%1 = OpFunction %8 None %9
17+
%11 = OpLabel
18+
%12 = OpLoad %6 %2
19+
%13 = OpLoad %6 %3
20+
%14 = OpFunctionCall %8 %5 %12 %13
21+
OpNoLine
22+
OpReturn
23+
OpFunctionEnd
24+
%5 = OpFunction %8 None %10
25+
%15 = OpFunctionParameter %6
26+
%16 = OpFunctionParameter %6
27+
%17 = OpLabel
28+
OpReturn
29+
OpFunctionEnd
30+
error: error:0:0 - [VUID-StandaloneSpirv-OpEntryPoint-09658] OpEntryPoint contains duplicate input variables with LocalInvocationIndex builtin
31+
%_local_id2 = OpVariable %_ptr_Input_uint Input
32+
|
33+
= note: spirv-val failed
34+
= note: module `$TEST_BUILD_DIR/entry/duplicate/attr_duplicate.vulkan1.2`
35+
36+
error: aborting due to 1 previous error
37+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble
3+
// normalize-stderr-test "OpLine .*\n" -> ""
4+
// normalize-stderr-test "OpSource .*\n" -> ""
5+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
6+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
7+
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
8+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
9+
// normalize-stderr-test "; .*\n" -> ""
10+
11+
// ignore-spv1.0
12+
// ignore-spv1.1
13+
// ignore-spv1.2
14+
// ignore-vulkan1.0
15+
// ignore-vulkan1.1
16+
17+
use core::arch::asm;
18+
use spirv_std::compute::local_invocation_index;
19+
use spirv_std::{glam::*, spirv};
20+
21+
#[spirv(compute(threads(1)))]
22+
pub fn entry_1() {
23+
let _: u32 = local_invocation_index();
24+
let _: u32 = local_invocation_index();
25+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
OpCapability Shader
2+
OpMemoryModel Logical Simple
3+
OpEntryPoint GLCompute %1 "entry_1" %2
4+
OpExecutionMode %1 LocalSize 1 1 1
5+
OpName %5 "builtin_duplicate::entry_1"
6+
OpDecorate %2 BuiltIn LocalInvocationIndex
7+
%6 = OpTypeVoid
8+
%7 = OpTypeFunction %6
9+
%8 = OpTypeInt 32 0
10+
%9 = OpTypePointer Input %8
11+
%2 = OpVariable %9 Input
12+
%1 = OpFunction %6 None %7
13+
%10 = OpLabel
14+
%11 = OpFunctionCall %6 %5
15+
OpNoLine
16+
OpReturn
17+
OpFunctionEnd
18+
%5 = OpFunction %6 None %7
19+
%12 = OpLabel
20+
%13 = OpLoad %8 %2
21+
%14 = OpLoad %8 %2
22+
OpNoLine
23+
OpReturn
24+
OpFunctionEnd
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble
3+
// normalize-stderr-test "OpLine .*\n" -> ""
4+
// normalize-stderr-test "OpSource .*\n" -> ""
5+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
6+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
7+
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
8+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
9+
// normalize-stderr-test "; .*\n" -> ""
10+
11+
// ignore-spv1.0
12+
// ignore-spv1.1
13+
// ignore-spv1.2
14+
// ignore-vulkan1.0
15+
// ignore-vulkan1.1
16+
17+
use core::arch::asm;
18+
use spirv_std::compute::*;
19+
use spirv_std::{glam::*, spirv};
20+
21+
#[spirv(compute(threads(1)))]
22+
pub fn entry_1(#[spirv(local_invocation_index)] _local_idx: u32) {
23+
let _: u32 = local_invocation_index();
24+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
OpCapability Shader
2+
OpMemoryModel Logical Simple
3+
OpEntryPoint GLCompute %1 "entry_1" %2 %3
4+
OpExecutionMode %1 LocalSize 1 1 1
5+
OpName %2 "_local_idx"
6+
OpName %6 "builtin_duplicate_std_attr::entry_1"
7+
OpDecorate %2 BuiltIn LocalInvocationIndex
8+
OpDecorate %3 BuiltIn LocalInvocationIndex
9+
%7 = OpTypeInt 32 0
10+
%8 = OpTypePointer Input %7
11+
%9 = OpTypeVoid
12+
%10 = OpTypeFunction %9
13+
%2 = OpVariable %8 Input
14+
%11 = OpTypeFunction %9 %7
15+
%3 = OpVariable %8 Input
16+
%1 = OpFunction %9 None %10
17+
%12 = OpLabel
18+
%13 = OpLoad %7 %2
19+
%14 = OpFunctionCall %9 %6 %13
20+
OpNoLine
21+
OpReturn
22+
OpFunctionEnd
23+
%6 = OpFunction %9 None %11
24+
%15 = OpFunctionParameter %7
25+
%16 = OpLabel
26+
%17 = OpLoad %7 %3
27+
OpNoLine
28+
OpReturn
29+
OpFunctionEnd
30+
error: error:0:0 - [VUID-StandaloneSpirv-OpEntryPoint-09658] OpEntryPoint contains duplicate input variables with LocalInvocationIndex builtin
31+
%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input
32+
|
33+
= note: spirv-val failed
34+
= note: module `$TEST_BUILD_DIR/entry/duplicate/builtin_duplicate_std_attr.vulkan1.2`
35+
36+
error: aborting due to 1 previous error
37+
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
3+
// normalize-stderr-test "OpLine .*\n" -> ""
4+
// normalize-stderr-test "OpSource .*\n" -> ""
5+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
6+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
7+
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
8+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
9+
// normalize-stderr-test "; .*\n" -> ""
10+
11+
// ignore-spv1.0
12+
// ignore-spv1.1
13+
// ignore-spv1.2
14+
// ignore-vulkan1.0
15+
// ignore-vulkan1.1
16+
17+
use core::arch::asm;
18+
use spirv_std::compute::local_invocation_index;
19+
use spirv_std::{glam::*, spirv};
20+
21+
#[spirv(compute(threads(1)))]
22+
pub fn entry_1() {
23+
let _: u32 = local_invocation_index();
24+
let _: u32 = local2();
25+
let _: u32 = local3();
26+
}
27+
28+
#[inline]
29+
pub fn local2() -> u32 {
30+
spirv_std::load_builtin!(LocalInvocationIndex)
31+
}
32+
33+
#[inline(never)]
34+
pub fn local3() -> u32 {
35+
spirv_std::load_builtin!(LocalInvocationIndex)
36+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
OpCapability Shader
2+
OpMemoryModel Logical Simple
3+
OpEntryPoint GLCompute %1 "entry_1" %2
4+
OpExecutionMode %1 LocalSize 1 1 1
5+
OpName %5 "builtin_duplicate_std_local_def::entry_1"
6+
OpName %6 "builtin_duplicate_std_local_def::local3"
7+
OpDecorate %2 BuiltIn LocalInvocationIndex
8+
%7 = OpTypeVoid
9+
%8 = OpTypeFunction %7
10+
%9 = OpTypeInt 32 0
11+
%10 = OpTypePointer Input %9
12+
%2 = OpVariable %10 Input
13+
%11 = OpTypeFunction %9
14+
%1 = OpFunction %7 None %8
15+
%12 = OpLabel
16+
%13 = OpFunctionCall %7 %5
17+
OpNoLine
18+
OpReturn
19+
OpFunctionEnd
20+
%5 = OpFunction %7 None %8
21+
%14 = OpLabel
22+
%15 = OpLoad %9 %2
23+
%16 = OpLoad %9 %2
24+
%17 = OpFunctionCall %9 %6
25+
OpNoLine
26+
OpReturn
27+
OpFunctionEnd
28+
%6 = OpFunction %9 DontInline %11
29+
%18 = OpLabel
30+
%19 = OpLoad %9 %2
31+
OpNoLine
32+
OpReturnValue %19
33+
OpFunctionEnd
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// build-pass
2+
// compile-flags: -C llvm-args=--disassemble
3+
// normalize-stderr-test "OpLine .*\n" -> ""
4+
// normalize-stderr-test "OpSource .*\n" -> ""
5+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
6+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
7+
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
8+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
9+
// normalize-stderr-test "; .*\n" -> ""
10+
11+
// ignore-spv1.0
12+
// ignore-spv1.1
13+
// ignore-spv1.2
14+
// ignore-vulkan1.0
15+
// ignore-vulkan1.1
16+
17+
use core::arch::asm;
18+
use spirv_std::{glam::*, spirv};
19+
20+
#[spirv(fragment)]
21+
pub fn main(input1: f32, input2: f32, output: &mut f32) {
22+
*output = input1 + input2;
23+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
OpCapability Shader
2+
OpMemoryModel Logical Simple
3+
OpEntryPoint Fragment %1 "main" %2 %3 %4
4+
OpExecutionMode %1 OriginUpperLeft
5+
OpName %3 "input2"
6+
OpName %4 "output"
7+
OpDecorate %2 Location 0
8+
OpDecorate %3 Location 1
9+
OpDecorate %4 Location 0
10+
%6 = OpTypeFloat 32
11+
%7 = OpTypePointer Input %6
12+
%8 = OpTypePointer Output %6
13+
%9 = OpTypeVoid
14+
%10 = OpTypeFunction %9
15+
%2 = OpVariable %7 Input
16+
%3 = OpVariable %7 Input
17+
%4 = OpVariable %8 Output
18+
%1 = OpFunction %9 None %10
19+
%11 = OpLabel
20+
%12 = OpLoad %6 %2
21+
%13 = OpLoad %6 %3
22+
%14 = OpFAdd %6 %12 %13
23+
OpStore %4 %14
24+
OpNoLine
25+
OpReturn
26+
OpFunctionEnd

0 commit comments

Comments
 (0)