From b35396bcd18ccbf1edb3d79c509c6cc5f5c9a784 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 22 Mar 2023 14:24:25 +0100 Subject: [PATCH 1/2] Validate shader location clashes --- wgpu-core/src/device/mod.rs | 8 +++++++- wgpu-core/src/pipeline.rs | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index f4413d1d3d..1b35d862e9 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -2806,10 +2806,16 @@ impl Device { self.require_features(wgt::Features::VERTEX_ATTRIBUTE_64BIT)?; } - io.insert( + let previous = io.insert( attribute.shader_location, validation::InterfaceVar::vertex_attribute(attribute.format), ); + + if previous.is_some() { + return Err(pipeline::CreateRenderPipelineError::ShaderLocationClash( + attribute.shader_location, + )); + } } total_attributes += vb_state.attributes.len(); } diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index cefeb97ba7..b46bd9fc25 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -352,6 +352,8 @@ pub enum CreateRenderPipelineError { location: wgt::ShaderLocation, offset: wgt::BufferAddress, }, + #[error("Two or more attributes were assigned to the same shader lcoation {0}")] + ShaderLocationClash(u32), #[error("Strip index format was not set to None but to {strip_index_format:?} while using the non-strip topology {topology:?}")] StripIndexFormatForNonStripTopology { strip_index_format: Option, From 6ec6030f224dcc6140a004e3c2193b10c1690b63 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 22 Mar 2023 14:27:43 +0100 Subject: [PATCH 2/2] Add line to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3f09f7c45..e9cbb50e87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -150,6 +150,7 @@ By @cwfitzgerald in [#3610](https://github.com/gfx-rs/wgpu/pull/3610). - `copyTextureToTexture` src/dst aspects must both refer to all aspects of src/dst format. By @teoxoy in [#3431](https://github.com/gfx-rs/wgpu/pull/3431) - Validate before extracting texture selectors. By @teoxoy in [#3487](https://github.com/gfx-rs/wgpu/pull/3487) - Fix fatal errors (those which panic even if an error handler is set) not including all of the details. By @kpreid in [#3563](https://github.com/gfx-rs/wgpu/pull/3563) +- Validate shader location clashes. By @emilk in [#3613](https://github.com/gfx-rs/wgpu/pull/3613) #### Vulkan