Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/bevy_pbr/src/cluster/cluster_allocate.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ fn allocate_global_main(@builtin(local_invocation_id) local_id: vec3<u32>) {
// March along the chunks sequentially, accumulating as we go.
var current_offset = 0u;
for (var i = 0u; i < cluster_count; i += 256u) {
offsets_and_counts.data[i + local_id.x][0].x += current_offset;
if (i + local_id.x < cluster_count) {
offsets_and_counts.data[i + local_id.x][0].x += current_offset;
}
storageBarrier();

if (i + 255u < cluster_count) {
Expand Down
7 changes: 5 additions & 2 deletions crates/bevy_pbr/src/render/allocate_uniforms.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ fn allocate_local_scan(
// instances (plus the first output mesh uniform index if we're the first
// workgroup) in the fan buffer in preparation for the next phase.
if (local_id.x == WORKGROUP_SIZE - 1u) {
fan_buffer[group_id.x] = output_offsets[WORKGROUP_SIZE - 1u] +
bin_metadata[global_id.x].instance_count;
var chunk_total = output_offsets[WORKGROUP_SIZE - 1u];
if (global_id.x < block_end) {
chunk_total += bin_metadata[global_id.x].instance_count;
}
fan_buffer[group_id.x] = chunk_total;
}
}

Expand Down