Skip to content

Commit d734e7f

Browse files
authored
Fix occlusion culling (#22699)
# Objective - fix #22655 ## Solution - separate readonly storage binding for late phase to make wgpu happy ## Testing - occlusion_culling example no longer crashes finding this was very difficult lol
1 parent 00eb21c commit d734e7f

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

crates/bevy_pbr/src/render/gpu_preprocess.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,12 +1302,25 @@ impl FromWorld for PreprocessPipelines {
13021302
let direct_bind_group_layout_entries = preprocess_direct_bind_group_layout_entries();
13031303
let gpu_frustum_culling_bind_group_layout_entries = gpu_culling_bind_group_layout_entries();
13041304
let gpu_early_occlusion_culling_bind_group_layout_entries =
1305+
gpu_occlusion_culling_bind_group_layout_entries().extend_with_indices((
1306+
(
1307+
11,
1308+
storage_buffer::<PreprocessWorkItem>(/*has_dynamic_offset=*/ false),
1309+
),
1310+
(
1311+
12,
1312+
storage_buffer::<LatePreprocessWorkItemIndirectParameters>(
1313+
/*has_dynamic_offset=*/ false,
1314+
),
1315+
),
1316+
));
1317+
let gpu_late_occlusion_culling_bind_group_layout_entries =
13051318
gpu_occlusion_culling_bind_group_layout_entries().extend_with_indices(((
1306-
11,
1307-
storage_buffer::<PreprocessWorkItem>(/*has_dynamic_offset=*/ false),
1319+
12,
1320+
storage_buffer_read_only::<LatePreprocessWorkItemIndirectParameters>(
1321+
/*has_dynamic_offset=*/ false,
1322+
),
13081323
),));
1309-
let gpu_late_occlusion_culling_bind_group_layout_entries =
1310-
gpu_occlusion_culling_bind_group_layout_entries();
13111324

13121325
let reset_indirect_batch_sets_bind_group_layout_entries =
13131326
DynamicBindGroupLayoutEntries::sequential(
@@ -1495,12 +1508,6 @@ fn gpu_occlusion_culling_bind_group_layout_entries() -> DynamicBindGroupLayoutEn
14951508
10,
14961509
texture_2d(TextureSampleType::Float { filterable: true }),
14971510
),
1498-
(
1499-
12,
1500-
storage_buffer::<LatePreprocessWorkItemIndirectParameters>(
1501-
/*has_dynamic_offset=*/ false,
1502-
),
1503-
),
15041511
))
15051512
}
15061513

crates/bevy_pbr/src/render/mesh_preprocess.wgsl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,15 @@ struct Immediates {
112112
#ifdef EARLY_PHASE
113113
@group(0) @binding(11) var<storage, read_write> late_preprocess_work_items:
114114
array<PreprocessWorkItem>;
115-
#endif // EARLY_PHASE
116115

117116
@group(0) @binding(12) var<storage, read_write> late_preprocess_work_item_indirect_parameters:
118117
array<LatePreprocessWorkItemIndirectParameters>;
118+
#endif // EARLY_PHASE
119+
120+
#ifdef LATE_PHASE
121+
@group(0) @binding(12) var<storage, read> late_preprocess_work_item_indirect_parameters:
122+
array<LatePreprocessWorkItemIndirectParameters>;
123+
#endif // LATE_PHASE
119124

120125
var<immediate> immediates: Immediates;
121126
#endif // OCCLUSION_CULLING

0 commit comments

Comments
 (0)