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_z_slice.wgsl

Bindings

cluster_metadata

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

z_slices

#
@group(0)
@binding(1)
var<storage, read_write> z_slices: array<ClusterableObjectZSlice>

clustered_lights

#
@group(0)
@binding(2)
var<storage> clustered_lights: ClusteredLights

light_probes

#
@group(0)
@binding(3)
var<uniform> light_probes: LightProbes

clustered_decals

#
@group(0)
@binding(4)
var<storage> clustered_decals: ClusteredDecals

lights

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

view

#
@group(0)
@binding(6)
var<uniform> view: View

Functions

z_slice_main

#
@compute
Runs custom parallel code on the GPU, not limited to graphics
@workgroup_size(64, 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

We have one invocation per clusterable object.

fn z_slice_main (
@builtin(global_invocation_id)
global_invocation_id: vec3<u32>
@builtin(local_invocation_id)
local_invocation_id: vec3<u32>
)

try_write_z_slice

#

This silently fails if the list is too small, but it still updates the instance count, which the CPU reads back. So, if the list is too small, the CPU will end up being notified and can resize the buffer.

fn try_write_z_slice (
object_index: u32
object_type: u32
z_slice: u32
)

accumulate_farthest_z_value

#

Records the farthest Z value for clusterable objects in this workgroup for the CPU to read back.

fn accumulate_farthest_z_value (
local_id: u32
position: vec3<f32>
radius: f32
view_from_world_scale: vec3<f32>
is_orthographic: bool
)

f32_bits_to_sortable_u32

#

The CPU decodes with sortable_u32_to_f32_bits in gpu.rs.

fn f32_bits_to_sortable_u32 (
bits: u32
) -> u32