Advanced search tips: use spaces to require multiple terms (AND), | for alternatives (OR), wrap phrases in quotes (="a b"), =term for exact match, 'term to include, !term to exclude, ^term to match prefix, !^term to exclude prefix, .ext$ to match suffix, and !.ext$ to exclude suffix.

cluster_allocate.wgsl

Bindings

offsets_and_counts

#
@group(0)
@binding(0)
var<storage, read_write> offsets_and_counts: ClusterOffsetsAndCounts

lights

#
@group(0)
@binding(1)
var<uniform> lights: Lights

clustering_metadata

#
@group(0)
@binding(2)
var<storage, read_write> clustering_metadata: ClusterMetadata

scratchpad_offsets_and_counts

#
@group(0)
@binding(3)
var<storage, read_write> scratchpad_offsets_and_counts: ClusterOffsetsAndCounts

Functions

allocate_local_main

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(256, 1, 1)
Defines the size of a thread group. One to three numbers: width (x), height (y), and depth (z). Missing values default to 1

The local allocation pass that, for each chunk of 256 clusters, calculates the offset for each cluster in the chunk.

fn allocate_local_main (
@builtin(local_invocation_id)
local_id: vec3<u32>
@builtin(workgroup_id)
group_id: vec3<u32>
@builtin(global_invocation_id)
global_id: vec3<u32>
)

allocate_global_main

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(256, 1, 1)
Defines the size of a thread group. One to three numbers: width (x), height (y), and depth (z). Missing values default to 1

The global allocation pass that propagates the offsets from each chunk of 256 clusters to later chunks sequentially.

fn allocate_global_main (
@builtin(local_invocation_id)
local_id: vec3<u32>
)

cluster_object_count

#

Returns the total number of objects in the given cluster.

fn cluster_object_count (
cluster_index: u32
) -> u32