enforce discard only in fragment (#2262)

This commit is contained in:
Pâris DOUADY 2023-02-27 10:47:10 +01:00 committed by GitHub
parent 00be08e9f8
commit a7b52b8663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -595,6 +595,7 @@ impl super::Validator {
finished = true;
}
S::Kill => {
stages &= super::ShaderStages::FRAGMENT;
finished = true;
}
S::Barrier(_) => {

View File

@ -943,6 +943,35 @@ fn invalid_arrays() {
}
}
#[test]
fn discard_in_wrong_stage() {
check_validation! {
"@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
if global_id.x == 3u {
discard;
}
}":
Err(naga::valid::ValidationError::EntryPoint {
stage: naga::ShaderStage::Compute,
source: naga::valid::EntryPointError::ForbiddenStageOperations,
..
})
}
check_validation! {
"@vertex
fn main() {
discard;
}":
Err(naga::valid::ValidationError::EntryPoint {
stage: naga::ShaderStage::Vertex,
source: naga::valid::EntryPointError::ForbiddenStageOperations,
..
})
}
}
#[test]
fn invalid_structs() {
check_validation! {