From 3d078cc20f14af507bf5bb4c6a21d49a18981383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 28 Nov 2022 18:06:54 +0100 Subject: [PATCH] set AVAILABLE_STORAGE_BUFFER_BINDINGS to the actual number of buffers available --- .../src/render_resource/pipeline_cache.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index ce5faf9099700..b13c39e1fbecc 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -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::*; @@ -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 {:?}",