Skip to content

Commit

Permalink
add NO_STORAGE_BUFFERS_SUPPORT shaderdef when needed (bevyengine#4949)
Browse files Browse the repository at this point in the history
# Objective

- fix bevyengine#4946 
- fix running 3d in wasm

## Solution

- since bevyengine#4867, the imports are splitter differently, and this shader def was not always set correctly depending on the shader used
- add it when needed
  • Loading branch information
mockersf authored and james7132 committed Jun 7, 2022
1 parent b5fcf38 commit ebdf26c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -220,6 +221,9 @@ impl FromWorld for ShadowPipeline {
let world = world.cell();
let render_device = world.resource::<RenderDevice>();

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
Expand Down Expand Up @@ -264,6 +268,7 @@ impl FromWorld for ShadowPipeline {
compare: Some(CompareFunction::GreaterEqual),
..Default::default()
}),
clustered_forward_buffer_binding_type,
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ebdf26c

Please sign in to comment.