Skip to content

Commit

Permalink
enforce discard only in compute
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Feb 26, 2023
1 parent 00be08e commit 15dc8c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/valid/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ impl super::Validator {
finished = true;
}
S::Kill => {
stages &= super::ShaderStages::FRAGMENT;
finished = true;
}
S::Barrier(_) => {
Expand Down
29 changes: 29 additions & 0 deletions tests/wgsl-errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down

0 comments on commit 15dc8c9

Please sign in to comment.