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(0)
var<storage> current_input: array<MeshInput>

previous_input

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

work_items

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

output

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

indirect_parameters

#

Shader defs requirments:

🟢 INDIRECT

@group(0)
@binding(4)
var<storage, read_write> indirect_parameters: array<IndirectParameters>

mesh_culling_data

#

Shader defs requirments:

🟢 FRUSTUM_CULLING

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

view

#

Shader defs requirments:

🟢 FRUSTUM_CULLING

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

Structures

MeshInput

#

Per-frame data that the CPU supplies to the GPU.

struct MeshInput {
world_from_local: mat3x4<f32> ,
lightmap_uv_rect: vec2<u32> ,
flags: u32 ,
previous_input_index: u32 ,
first_vertex_index: u32 ,
pad_a: u32 ,
pad_b: u32 ,
pad_c: u32 ,
}

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_index: u32 ,
}

IndirectParameters

#

The wgpu indirect parameters structure. This is a union of two structures. For more information, see the corresponding comment in gpu_preprocessing.rs.

struct IndirectParameters {
data0: u32 ,
instance_count: atomic<u32> ,
first_vertex: u32 ,
data1: u32 ,
instance_index: 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>
)