From be6c16b20113c8e1c0a2f19b7b24283be30dd248 Mon Sep 17 00:00:00 2001 From: JMS55 <47158642+JMS55@users.noreply.github.com> Date: Fri, 10 Nov 2023 18:41:32 -0800 Subject: [PATCH] Shrink visbuffer triangle ID to 7 bits --- crates/bevy_pbr/src/meshlet/visibility_buffer.wgsl | 2 +- crates/bevy_pbr/src/meshlet/visibility_buffer_resolve.wgsl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_pbr/src/meshlet/visibility_buffer.wgsl b/crates/bevy_pbr/src/meshlet/visibility_buffer.wgsl index c5c605b56cff9..b6bb30c095141 100644 --- a/crates/bevy_pbr/src/meshlet/visibility_buffer.wgsl +++ b/crates/bevy_pbr/src/meshlet/visibility_buffer.wgsl @@ -35,7 +35,7 @@ fn vertex(@builtin(vertex_index) cull_output: u32) -> VertexOutput { clip_position.z = min(clip_position.z, 1.0); #endif - let visibility = (thread_id << 8u) | (index_id / 3u); + let visibility = (thread_id << 7u) | (index_id / 3u); return VertexOutput(clip_position, visibility, material_id); } diff --git a/crates/bevy_pbr/src/meshlet/visibility_buffer_resolve.wgsl b/crates/bevy_pbr/src/meshlet/visibility_buffer_resolve.wgsl index 444abf59e1351..b67bc277001e8 100644 --- a/crates/bevy_pbr/src/meshlet/visibility_buffer_resolve.wgsl +++ b/crates/bevy_pbr/src/meshlet/visibility_buffer_resolve.wgsl @@ -68,10 +68,10 @@ struct VertexOutput { fn resolve_vertex_output(frag_coord: vec4) -> VertexOutput { let vbuffer = textureLoad(meshlet_visibility_buffer, vec2(frag_coord.xy), 0).r; - let thread_id = vbuffer >> 8u; + let thread_id = vbuffer >> 7u; let meshlet_id = meshlet_thread_meshlet_ids[thread_id]; let meshlet = meshlets[meshlet_id]; - let triangle_id = extractBits(vbuffer, 0u, 8u); + let triangle_id = extractBits(vbuffer, 0u, 7u); let index_ids = meshlet.start_index_id + vec3(triangle_id * 3u) + vec3(0u, 1u, 2u); let indices = meshlet.start_vertex_id + vec3(get_meshlet_index(index_ids.x), get_meshlet_index(index_ids.y), get_meshlet_index(index_ids.z)); let vertex_ids = vec3(meshlet_vertex_ids[indices.x], meshlet_vertex_ids[indices.y], meshlet_vertex_ids[indices.z]);