mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
Check that all vertex outputs are consumed by the fragment shader (#2704)
This commit is contained in:
parent
16c796578c
commit
c12ae0880f
@ -263,6 +263,8 @@ pub enum StageError {
|
||||
#[source]
|
||||
error: InputError,
|
||||
},
|
||||
#[error("location[{location}] is provided by the previous stage output but is not consumed as input by this stage.")]
|
||||
InputNotConsumed { location: wgt::ShaderLocation },
|
||||
}
|
||||
|
||||
fn map_storage_format_to_naga(format: wgt::TextureFormat) -> Option<naga::StorageFormat> {
|
||||
@ -1158,6 +1160,21 @@ impl Interface {
|
||||
}
|
||||
}
|
||||
|
||||
// Check all vertex outputs and make sure the fragment shader consumes them.
|
||||
if shader_stage == naga::ShaderStage::Fragment {
|
||||
for &index in inputs.keys() {
|
||||
// This is a linear scan, but the count should be low enough that this should be fine.
|
||||
let found = entry_point.inputs.iter().any(|v| match *v {
|
||||
Varying::Local { location, .. } => location == index,
|
||||
Varying::BuiltIn(_) => false,
|
||||
});
|
||||
|
||||
if !found {
|
||||
return Err(StageError::InputNotConsumed { location: index });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if shader_stage == naga::ShaderStage::Vertex {
|
||||
for output in entry_point.outputs.iter() {
|
||||
//TODO: count builtins towards the limit?
|
||||
|
@ -30,6 +30,6 @@ fn fs_main(vertex: VertexOutput) -> @location(0) vec4<f32> {
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_wire() -> @location(0) vec4<f32> {
|
||||
fn fs_wire(vertex: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.5, 0.0, 0.5);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user