Expand description
DSL marker functions for WGSL code generation.
These functions are compile-time markers that the transpiler recognizes and converts to WGSL intrinsics. They do nothing at Rust compile time.
§Thread/Workgroup Indices
| Function | WGSL Equivalent |
|---|---|
thread_idx_x() | local_invocation_id.x |
thread_idx_y() | local_invocation_id.y |
thread_idx_z() | local_invocation_id.z |
block_idx_x() | workgroup_id.x |
block_idx_y() | workgroup_id.y |
block_idx_z() | workgroup_id.z |
block_dim_x() | WORKGROUP_SIZE_X (constant) |
global_thread_id() | global_invocation_id.x |
Functions§
- abs
- Absolute value. Maps to
abs(x)in WGSL. - atomic_
add - Atomic add. Maps to
atomicAdd(&var, value)in WGSL. - atomic_
cas - Atomic compare-and-swap. Maps to
atomicCompareExchangeWeak(&var, compare, value)in WGSL. Returns the old value. - atomic_
exchange - Atomic exchange. Maps to
atomicExchange(&var, value)in WGSL. - atomic_
load - Atomic load. Maps to
atomicLoad(&var)in WGSL. - atomic_
max - Atomic maximum. Maps to
atomicMax(&var, value)in WGSL. - atomic_
min - Atomic minimum. Maps to
atomicMin(&var, value)in WGSL. - atomic_
store - Atomic store. Maps to
atomicStore(&var, value)in WGSL. - atomic_
sub - Atomic subtract. Maps to
atomicSub(&var, value)in WGSL. - block_
dim_ x - Get the x-dimension of the workgroup size.
Maps to a compile-time constant
WORKGROUP_SIZE_Xin WGSL. - block_
dim_ y - Get the y-dimension of the workgroup size.
Maps to a compile-time constant
WORKGROUP_SIZE_Yin WGSL. - block_
dim_ z - Get the z-dimension of the workgroup size.
Maps to a compile-time constant
WORKGROUP_SIZE_Zin WGSL. - block_
idx_ x - Get the x-component of the workgroup index.
Maps to
workgroup_id.xin WGSL. - block_
idx_ y - Get the y-component of the workgroup index.
Maps to
workgroup_id.yin WGSL. - block_
idx_ z - Get the z-component of the workgroup index.
Maps to
workgroup_id.zin WGSL. - ceil
- Ceiling. Maps to
ceil(x)in WGSL. - clamp
- Clamp. Maps to
clamp(x, lo, hi)in WGSL. - cos
- Cosine. Maps to
cos(x)in WGSL. - exp
- Exponential. Maps to
exp(x)in WGSL. - floor
- Floor. Maps to
floor(x)in WGSL. - fma
- Fused multiply-add. Maps to
fma(a, b, c)in WGSL. - global_
thread_ id - Get the global thread ID (x-component).
Maps to
global_invocation_id.xin WGSL. - global_
thread_ id_ y - Get the global thread ID in the y-dimension.
Maps to
global_invocation_id.yin WGSL. - global_
thread_ id_ z - Get the global thread ID in the z-dimension.
Maps to
global_invocation_id.zin WGSL. - grid_
dim_ x - Get the x-component of the number of workgroups in the dispatch.
Maps to
num_workgroups.xin WGSL. - grid_
dim_ y - Get the y-component of the number of workgroups in the dispatch.
Maps to
num_workgroups.yin WGSL. - grid_
dim_ z - Get the z-component of the number of workgroups in the dispatch.
Maps to
num_workgroups.zin WGSL. - lane_id
- Get the lane ID within the subgroup.
Maps to
subgroup_invocation_idbuiltin in WGSL. - log
- Natural logarithm. Maps to
log(x)in WGSL. - max
- Maximum. Maps to
max(a, b)in WGSL. - min
- Minimum. Maps to
min(a, b)in WGSL. - mix
- Linear interpolation. Maps to
mix(a, b, t)in WGSL. - powf
- Power. Maps to
pow(x, y)in WGSL. - round
- Round to nearest. Maps to
round(x)in WGSL. - rsqrt
- Reciprocal square root. Maps to
inverseSqrt(x)in WGSL. - sin
- Sine. Maps to
sin(x)in WGSL. - sqrt
- Square root. Maps to
sqrt(x)in WGSL. - sync_
threads - Synchronize all threads in the workgroup.
Maps to
workgroupBarrier()in WGSL. - tan
- Tangent. Maps to
tan(x)in WGSL. - thread_
fence - Memory fence for storage buffers.
Maps to
storageBarrier()in WGSL. - thread_
fence_ block - Memory fence within the workgroup.
Maps to
workgroupBarrier()in WGSL. - thread_
idx_ x - Get the x-component of the local thread index within the workgroup.
Maps to
local_invocation_id.xin WGSL. - thread_
idx_ y - Get the y-component of the local thread index within the workgroup.
Maps to
local_invocation_id.yin WGSL. - thread_
idx_ z - Get the z-component of the local thread index within the workgroup.
Maps to
local_invocation_id.zin WGSL. - warp_
all - Check if all lanes in subgroup satisfy predicate. Maps to
subgroupAll(predicate)in WGSL. - warp_
any - Check if any lane in subgroup satisfies predicate. Maps to
subgroupAny(predicate)in WGSL. - warp_
ballot - Ballot within subgroup. Maps to
subgroupBallot(predicate)in WGSL. Returns a vec4where each bit represents a lane’s predicate. - warp_
shuffle - Shuffle within subgroup. Maps to
subgroupShuffle(value, lane)in WGSL. Requires:enable chromium_experimental_subgroups; - warp_
shuffle_ down - Shuffle down within subgroup. Maps to
subgroupShuffleDown(value, delta)in WGSL. - warp_
shuffle_ up - Shuffle up within subgroup. Maps to
subgroupShuffleUp(value, delta)in WGSL. - warp_
shuffle_ xor - Shuffle XOR within subgroup. Maps to
subgroupShuffleXor(value, mask)in WGSL. - warp_
size - Get the subgroup size.
Maps to
subgroup_sizebuiltin in WGSL.