Skip to content

Commit 193998b

Browse files
committed
add NO_STORAGE_BUFFERS_SUPPORT shaderdef when needed (#4949)
# Objective - fix #4946 - fix running 3d in wasm ## Solution - since #4867, the imports are splitter differently, and this shader def was not always set correctly depending on the shader used - add it when needed
1 parent 25219a4 commit 193998b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

crates/bevy_pbr/src/render/light.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ pub struct ShadowPipeline {
212212
pub skinned_mesh_layout: BindGroupLayout,
213213
pub point_light_sampler: Sampler,
214214
pub directional_light_sampler: Sampler,
215+
pub clustered_forward_buffer_binding_type: BufferBindingType,
215216
}
216217

217218
// TODO: this pattern for initializing the shaders / pipeline isn't ideal. this should be handled by the asset system
@@ -220,6 +221,9 @@ impl FromWorld for ShadowPipeline {
220221
let world = world.cell();
221222
let render_device = world.resource::<RenderDevice>();
222223

224+
let clustered_forward_buffer_binding_type = render_device
225+
.get_supported_read_only_binding_type(CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT);
226+
223227
let view_layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor {
224228
entries: &[
225229
// View
@@ -264,6 +268,7 @@ impl FromWorld for ShadowPipeline {
264268
compare: Some(CompareFunction::GreaterEqual),
265269
..Default::default()
266270
}),
271+
clustered_forward_buffer_binding_type,
267272
}
268273
}
269274
}
@@ -325,6 +330,13 @@ impl SpecializedMeshPipeline for ShadowPipeline {
325330
bind_group_layout.push(self.mesh_layout.clone());
326331
}
327332

333+
if !matches!(
334+
self.clustered_forward_buffer_binding_type,
335+
BufferBindingType::Storage { .. }
336+
) {
337+
shader_defs.push(String::from("NO_STORAGE_BUFFERS_SUPPORT"));
338+
}
339+
328340
let vertex_buffer_layout = layout.get_layout(&vertex_attributes)?;
329341

330342
Ok(RenderPipelineDescriptor {

0 commit comments

Comments
 (0)