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 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,