Skip to content

Commit

Permalink
set AVAILABLE_STORAGE_BUFFER_BINDINGS to the actual number of buffers…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
mockersf authored and alradish committed Jan 22, 2023
1 parent 91d8cdc commit 2acd49f
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions crates/bevy_render/src/render_resource/pipeline_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ use bevy_utils::{
};
use std::{hash::Hash, iter::FusedIterator, mem, ops::Deref};
use thiserror::Error;
use wgpu::{
BufferBindingType, PipelineLayoutDescriptor, VertexBufferLayout as RawVertexBufferLayout,
};
use wgpu::{PipelineLayoutDescriptor, VertexBufferLayout as RawVertexBufferLayout};

use crate::render_resource::resource_macros::*;

Expand Down Expand Up @@ -178,17 +176,10 @@ impl ShaderCache {
shader_defs.push("SIXTEEN_BYTE_ALIGNMENT".into());
}

// 3 is the value from CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT declared in bevy_pbr
// Using the value directly here to avoid the cyclic dependency
if matches!(
render_device.get_supported_read_only_binding_type(3),
BufferBindingType::Storage { .. }
) {
shader_defs.push(ShaderDefVal::Int(
String::from("AVAILABLE_STORAGE_BUFFER_BINDINGS"),
3,
));
}
shader_defs.push(ShaderDefVal::Int(
String::from("AVAILABLE_STORAGE_BUFFER_BINDINGS"),
render_device.limits().max_storage_buffers_per_shader_stage as i32,
));

debug!(
"processing shader {:?}, with shader defs {:?}",
Expand Down

0 comments on commit 2acd49f

Please sign in to comment.