diff --git a/CHANGELOG.md b/CHANGELOG.md index 83246344a..13e394391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,7 @@ Bottom level categories: - Device lost callbacks are invoked when replaced and when global is dropped. By @bradwerth in [#5168](https://github.com/gfx-rs/wgpu/pull/5168) - Fix performance regression when allocating a large amount of resources of the same type. By @nical in [#5229](https://github.com/gfx-rs/wgpu/pull/5229) - Fix docs.rs wasm32 builds. By @cwfitzgerald in [#5310](https://github.com/gfx-rs/wgpu/pull/5310) +- Improve error message when binding count limit hit. By @hackaugusto in [#5298](https://github.com/gfx-rs/wgpu/pull/5298) #### DX12 - Fix `panic!` when dropping `Instance` without `InstanceFlags::VALIDATION`. By @hakolao in [#5134](https://github.com/gfx-rs/wgpu/pull/5134) diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index 39a21f7a1..bf74207db 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -222,7 +222,7 @@ pub enum BindingZone { } #[derive(Clone, Debug, Error)] -#[error("Too many bindings of type {kind:?} in {zone}, limit is {limit}, count was {count}")] +#[error("Too many bindings of type {kind:?} in {zone}, limit is {limit}, count was {count}. Check the limit `{}` passed to `Adapter::request_device`", .kind.to_config_str())] pub struct BindingTypeMaxCountError { pub kind: BindingTypeMaxCountErrorKind, pub zone: BindingZone, @@ -241,6 +241,28 @@ pub enum BindingTypeMaxCountErrorKind { UniformBuffers, } +impl BindingTypeMaxCountErrorKind { + fn to_config_str(&self) -> &'static str { + match self { + BindingTypeMaxCountErrorKind::DynamicUniformBuffers => { + "max_dynamic_uniform_buffers_per_pipeline_layout" + } + BindingTypeMaxCountErrorKind::DynamicStorageBuffers => { + "max_dynamic_storage_buffers_per_pipeline_layout" + } + BindingTypeMaxCountErrorKind::SampledTextures => { + "max_sampled_textures_per_shader_stage" + } + BindingTypeMaxCountErrorKind::Samplers => "max_samplers_per_shader_stage", + BindingTypeMaxCountErrorKind::StorageBuffers => "max_storage_buffers_per_shader_stage", + BindingTypeMaxCountErrorKind::StorageTextures => { + "max_storage_textures_per_shader_stage" + } + BindingTypeMaxCountErrorKind::UniformBuffers => "max_uniform_buffers_per_shader_stage", + } + } +} + #[derive(Debug, Default)] pub(crate) struct PerStageBindingTypeCounter { vertex: u32,