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.

mesh_preprocess.wgsl

Bindings

current_input

#
@group(0)
@binding(3)
var<storage> current_input: array<MeshInput>

previous_input

#
@group(0)
@binding(4)
var<storage> previous_input: array<MeshInput>

work_items

#
@group(0)
@binding(5)
var<storage> work_items: array<PreprocessWorkItem>

output

#
@group(0)
@binding(6)
var<storage, read_write> output: array<Mesh>

indirect_parameters_cpu_metadata

#

Shader defs requirments:

🟢 INDIRECT

@group(0)
@binding(7)
var<storage> indirect_parameters_cpu_metadata: array<IndirectParametersCpuMetadata>

indirect_parameters_gpu_metadata

#

Shader defs requirments:

🟢 INDIRECT

@group(0)
@binding(8)
var<storage, read_write> indirect_parameters_gpu_metadata: array<IndirectParametersGpuMetadata>

mesh_culling_data

#

Shader defs requirments:

🟢 FRUSTUM_CULLING

@group(0)
@binding(9)
var<storage> mesh_culling_data: array<MeshCullingData>

depth_pyramid

#

Shader defs requirments:

🟢 OCCLUSION_CULLING

@group(0)
@binding(10)
var depth_pyramid: texture_2d<f32>

late_preprocess_work_items

#

Shader defs requirments:

🟢 OCCLUSION_CULLING, 🟢 EARLY_PHASE

@group(0)
@binding(11)
var<storage, read_write> late_preprocess_work_items: array<PreprocessWorkItem>

late_preprocess_work_item_indirect_parameters

#

Shader defs requirments:

🟢 OCCLUSION_CULLING

@group(0)
@binding(12)
var<storage, read_write> late_preprocess_work_item_indirect_parameters: array<LatePreprocessWorkItemIndirectParameters>

Structures

MeshCullingData

#

At the moment, this just consists of its axis-aligned bounding box (AABB).

struct MeshCullingData {
aabb_center: vec4<f32> ,
aabb_half_extents: vec4<f32> ,
}

PreprocessWorkItem

#

One invocation of this compute shader: i.e. one mesh instance in a view.

struct PreprocessWorkItem {
input_index: u32 ,
output_or_indirect_parameters_index: u32 ,
}

LatePreprocessWorkItemIndirectParameters

#

The parameters for the indirect compute dispatch for the late mesh preprocessing phase.

struct LatePreprocessWorkItemIndirectParameters {
dispatch_x: atomic<u32> ,
dispatch_y: u32 ,
dispatch_z: u32 ,
work_item_count: atomic<u32> ,
}

PushConstants

#

These have to be in a structure because of Naga limitations on DX12.

struct PushConstants {
late_preprocess_work_item_indirect_offset: u32 ,
}

Functions

view_frustum_intersects_obb

#

Shader defs requirments:

🟢 FRUSTUM_CULLING

aabb_center.w should be 1.0.

fn view_frustum_intersects_obb (
world_from_local: mat4x4<f32>
aabb_center: vec4<f32>
aabb_half_extents: vec3<f32>
) -> bool

main

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