-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathbuiltin.rs
More file actions
27 lines (25 loc) · 780 Bytes
/
builtin.rs
File metadata and controls
27 lines (25 loc) · 780 Bytes
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
//! Symbols to query SPIR-V read-only global built-ins
/// compute shader built-ins
pub mod compute {
#[cfg(target_arch = "spirv")]
use core::arch::asm;
use glam::UVec3;
/// GLSL: `gl_LocalInvocationID()`
/// WGSL: `local_invocation_id`
#[doc(alias = "gl_LocalInvocationID")]
#[inline]
#[gpu_only]
pub fn local_invocation_id() -> UVec3 {
unsafe {
let result = UVec3::default();
asm! {
"%builtin = OpVariable typeof{result} Input",
"OpDecorate %builtin BuiltIn LocalInvocationId",
"%result = OpLoad typeof*{result} %builtin",
"OpStore {result} %result",
result = in(reg) &result,
}
result
}
}
}