-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathbuiltin_duplicates.rs
More file actions
58 lines (51 loc) · 1.55 KB
/
builtin_duplicates.rs
File metadata and controls
58 lines (51 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// build-pass
// compile-flags: -C llvm-args=--disassemble
// normalize-stderr-test "OpLine .*\n" -> ""
// normalize-stderr-test "OpSource .*\n" -> ""
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
// normalize-stderr-test "; .*\n" -> ""
// ignore-spv1.0
// ignore-spv1.1
// ignore-spv1.2
// ignore-vulkan1.0
// ignore-vulkan1.1
use core::arch::asm;
use spirv_std::{glam::*, spirv};
#[spirv(compute(threads(1)))]
pub fn entry_1(#[spirv(local_invocation_index)] _local_idx: u32) {
let _: u32 = local_invocation_index();
let _: u32 = local_invocation_index();
let _: u32 = sub_1();
let _: u32 = sub_2();
}
#[spirv(compute(threads(1)))]
pub fn entry_2(#[spirv(local_invocation_index)] _local_idx: u32) {
let _: u32 = local_invocation_index();
let _: u32 = sub_1();
let _: u32 = sub_2();
}
#[inline(never)]
fn sub_1() -> u32 {
local_invocation_index()
}
#[inline(never)]
fn sub_2() -> u32 {
local_invocation_index()
}
#[inline]
pub fn local_invocation_index() -> u32 {
unsafe {
let result = 0;
asm! {
"%builtin = OpVariable typeof{result} Input",
"OpDecorate %builtin BuiltIn LocalInvocationIndex",
"%result = OpLoad typeof*{result} %builtin",
"OpStore {result} %result",
result = in(reg) &result,
}
result
}
}