Skip to content

Commit 142a066

Browse files
mockersfItsDoot
authored andcommitted
set AVAILABLE_STORAGE_BUFFER_BINDINGS to the actual number of buffers available (bevyengine#6787)
# Objective - Since bevyengine#5900 3d examples fail in wasm ``` ERROR crates/bevy_render/src/render_resource/pipeline_cache.rs:660 failed to process shader: Unknown shader def: 'AVAILABLE_STORAGE_BUFFER_BINDINGS' ``` ## Solution - Fix it by always adding the shaderdef `AVAILABLE_STORAGE_BUFFER_BINDINGS` with the actual value, instead of 3 when 3 or more were available
1 parent 17f96e1 commit 142a066

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

crates/bevy_render/src/render_resource/pipeline_cache.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use bevy_utils::{
1919
};
2020
use std::{hash::Hash, iter::FusedIterator, mem, ops::Deref};
2121
use thiserror::Error;
22-
use wgpu::{
23-
BufferBindingType, PipelineLayoutDescriptor, VertexBufferLayout as RawVertexBufferLayout,
24-
};
22+
use wgpu::{PipelineLayoutDescriptor, VertexBufferLayout as RawVertexBufferLayout};
2523

2624
use crate::render_resource::resource_macros::*;
2725

@@ -178,17 +176,10 @@ impl ShaderCache {
178176
shader_defs.push("SIXTEEN_BYTE_ALIGNMENT".into());
179177
}
180178

181-
// 3 is the value from CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT declared in bevy_pbr
182-
// Using the value directly here to avoid the cyclic dependency
183-
if matches!(
184-
render_device.get_supported_read_only_binding_type(3),
185-
BufferBindingType::Storage { .. }
186-
) {
187-
shader_defs.push(ShaderDefVal::Int(
188-
String::from("AVAILABLE_STORAGE_BUFFER_BINDINGS"),
189-
3,
190-
));
191-
}
179+
shader_defs.push(ShaderDefVal::Int(
180+
String::from("AVAILABLE_STORAGE_BUFFER_BINDINGS"),
181+
render_device.limits().max_storage_buffers_per_shader_stage as i32,
182+
));
192183

193184
debug!(
194185
"processing shader {:?}, with shader defs {:?}",

0 commit comments

Comments
 (0)