diff --git a/CHANGELOG.md b/CHANGELOG.md index a50e96da4..233e781de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ Bottom level categories: - BREAKING: Migrated from the `maxInterStageShaderComponents` limit to `maxInterStageShaderVariables`, which changes validation in a way that should not affect most programs. This follows the latest changes of the WebGPU spec. By @ErichDonGubler in [#8652](https://github.com/gfx-rs/wgpu/pull/8652), [#8792](https://github.com/gfx-rs/wgpu/pull/8792). - Fixed validation of the texture format in GPUDepthStencilState when neither depth nor stencil is actually enabled. By @andyleiserson in [#8766](https://github.com/gfx-rs/wgpu/pull/8766). - Tracing support has been restored. By @andyleiserson in [#8429](https://github.com/gfx-rs/wgpu/pull/8429). +- Pipelines using passthrough shaders now correctly require explicit pipeline layout. By @inner-daemons in #8881. #### naga diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index 73fc63d5f..a0f61ca96 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -1392,6 +1392,7 @@ impl Global { Ok(cache) => cache, Err(e) => break 'error e.into(), }; + let mut passthrough_stages = wgt::ShaderStages::empty(); let vertex = match desc.vertex { RenderPipelineVertexProcessor::Vertex(ref vertex) => { @@ -1407,6 +1408,9 @@ impl Global { Ok(module) => module, Err(e) => break 'error e, }; + if module.interface.is_none() { + passthrough_stages |= wgt::ShaderStages::VERTEX; + } let stage = ResolvedProgrammableStageDescriptor { module, entry_point: vertex.stage.entry_point.clone(), @@ -1434,6 +1438,9 @@ impl Global { Ok(module) => module, Err(e) => break 'error e, }; + if module.interface.is_none() { + passthrough_stages |= wgt::ShaderStages::TASK; + } let state = ResolvedProgrammableStageDescriptor { module, entry_point: task.stage.entry_point.clone(), @@ -1458,6 +1465,9 @@ impl Global { Ok(module) => module, Err(e) => break 'error e, }; + if mesh_module.interface.is_none() { + passthrough_stages |= wgt::ShaderStages::VERTEX; + } let mesh_stage = ResolvedProgrammableStageDescriptor { module: mesh_module, entry_point: mesh.stage.entry_point.clone(), @@ -1486,6 +1496,9 @@ impl Global { Ok(module) => module, Err(e) => break 'error e, }; + if module.interface.is_none() { + passthrough_stages |= wgt::ShaderStages::FRAGMENT; + } let stage = ResolvedProgrammableStageDescriptor { module, entry_point: state.stage.entry_point.clone(), @@ -1500,6 +1513,12 @@ impl Global { None }; + if !passthrough_stages.is_empty() && layout.is_none() { + break 'error pipeline::CreateRenderPipelineError::Implicit( + pipeline::ImplicitLayoutError::Passthrough(passthrough_stages), + ); + } + let desc = ResolvedGeneralRenderPipelineDescriptor { label: desc.label.clone(), layout, @@ -1642,6 +1661,11 @@ impl Global { Ok(module) => module, Err(e) => break 'error e.into(), }; + if module.interface.is_none() && layout.is_none() { + break 'error pipeline::CreateComputePipelineError::Implicit( + pipeline::ImplicitLayoutError::Passthrough(wgt::ShaderStages::COMPUTE), + ); + } let stage = ResolvedProgrammableStageDescriptor { module, entry_point: desc.stage.entry_point.clone(), diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index 7e8c48260..bb44b1771 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -202,6 +202,8 @@ pub enum ImplicitLayoutError { BindGroup(#[from] CreateBindGroupLayoutError), #[error(transparent)] Pipeline(#[from] CreatePipelineLayoutError), + #[error("Unable to create implicit pipeline layout from passthrough shader stage: {0:?}")] + Passthrough(wgt::ShaderStages), } impl WebGpuError for ImplicitLayoutError { @@ -210,6 +212,7 @@ impl WebGpuError for ImplicitLayoutError { Self::ReflectionError(_) => return ErrorType::Validation, Self::BindGroup(e) => e, Self::Pipeline(e) => e, + Self::Passthrough(_) => return ErrorType::Validation, }; e.webgpu_error_type() }