From c9ca4a5d88f1f1f454fdc98e8bae34838da8b584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 6 Jun 2022 20:00:30 +0000 Subject: [PATCH] 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 --- crates/bevy_pbr/src/render/light.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 63cf180e0e810d..1862ebda3e2658 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -212,6 +212,7 @@ pub struct ShadowPipeline { pub skinned_mesh_layout: BindGroupLayout, pub point_light_sampler: Sampler, pub directional_light_sampler: Sampler, + pub clustered_forward_buffer_binding_type: BufferBindingType, } // 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 { let world = world.cell(); let render_device = world.resource::(); + let clustered_forward_buffer_binding_type = render_device + .get_supported_read_only_binding_type(CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT); + let view_layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[ // View @@ -264,6 +268,7 @@ impl FromWorld for ShadowPipeline { compare: Some(CompareFunction::GreaterEqual), ..Default::default() }), + clustered_forward_buffer_binding_type, } } } @@ -325,6 +330,13 @@ impl SpecializedMeshPipeline for ShadowPipeline { bind_group_layout.push(self.mesh_layout.clone()); } + if !matches!( + self.clustered_forward_buffer_binding_type, + BufferBindingType::Storage { .. } + ) { + shader_defs.push(String::from("NO_STORAGE_BUFFERS_SUPPORT")); + } + let vertex_buffer_layout = layout.get_layout(&vertex_attributes)?; Ok(RenderPipelineDescriptor {