mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 08:13:27 +00:00
Fixes crash when there's a missing texture argument (#6486)
This commit is contained in:
parent
9b47b06a4f
commit
47d20d913d
@ -64,6 +64,10 @@ Bottom level categories:
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
#### Naga
|
||||||
|
|
||||||
|
- Fix crash when a texture argument is missing. By @aedm in [#6486](https://github.com/gfx-rs/wgpu/pull/6486)
|
||||||
|
|
||||||
#### General
|
#### General
|
||||||
|
|
||||||
- Ensure that `Features::TIMESTAMP_QUERY` is set when using timestamp writes in render and compute passes. By @ErichDonGubler in [#6497](https://github.com/gfx-rs/wgpu/pull/6497).
|
- Ensure that `Features::TIMESTAMP_QUERY` is set when using timestamp writes in render and compute passes. By @ErichDonGubler in [#6497](https://github.com/gfx-rs/wgpu/pull/6497).
|
||||||
|
@ -421,7 +421,10 @@ impl FunctionInfo {
|
|||||||
let image_storage = match sampling.image {
|
let image_storage = match sampling.image {
|
||||||
GlobalOrArgument::Global(var) => GlobalOrArgument::Global(var),
|
GlobalOrArgument::Global(var) => GlobalOrArgument::Global(var),
|
||||||
GlobalOrArgument::Argument(i) => {
|
GlobalOrArgument::Argument(i) => {
|
||||||
let handle = arguments[i as usize];
|
let Some(handle) = arguments.get(i as usize).cloned() else {
|
||||||
|
// Argument count mismatch, will be reported later by validate_call
|
||||||
|
break;
|
||||||
|
};
|
||||||
GlobalOrArgument::from_expression(expression_arena, handle).map_err(
|
GlobalOrArgument::from_expression(expression_arena, handle).map_err(
|
||||||
|source| {
|
|source| {
|
||||||
FunctionError::Expression { handle, source }
|
FunctionError::Expression { handle, source }
|
||||||
@ -434,7 +437,10 @@ impl FunctionInfo {
|
|||||||
let sampler_storage = match sampling.sampler {
|
let sampler_storage = match sampling.sampler {
|
||||||
GlobalOrArgument::Global(var) => GlobalOrArgument::Global(var),
|
GlobalOrArgument::Global(var) => GlobalOrArgument::Global(var),
|
||||||
GlobalOrArgument::Argument(i) => {
|
GlobalOrArgument::Argument(i) => {
|
||||||
let handle = arguments[i as usize];
|
let Some(handle) = arguments.get(i as usize).cloned() else {
|
||||||
|
// Argument count mismatch, will be reported later by validate_call
|
||||||
|
break;
|
||||||
|
};
|
||||||
GlobalOrArgument::from_expression(expression_arena, handle).map_err(
|
GlobalOrArgument::from_expression(expression_arena, handle).map_err(
|
||||||
|source| {
|
|source| {
|
||||||
FunctionError::Expression { handle, source }
|
FunctionError::Expression { handle, source }
|
||||||
|
@ -606,3 +606,40 @@ fn binding_arrays_cannot_hold_scalars() {
|
|||||||
|
|
||||||
assert!(t.validator.validate(&t.module).is_err());
|
assert!(t.validator.validate(&t.module).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "wgsl-in")]
|
||||||
|
#[test]
|
||||||
|
fn validation_error_messages() {
|
||||||
|
let cases = [(
|
||||||
|
r#"@group(0) @binding(0) var my_sampler: sampler;
|
||||||
|
|
||||||
|
fn foo(tex: texture_2d<f32>) -> vec4<f32> {
|
||||||
|
return textureSampleLevel(tex, my_sampler, vec2f(0, 0), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
"\
|
||||||
|
error: Function [1] 'main' is invalid
|
||||||
|
┌─ wgsl:7:17
|
||||||
|
│ \n7 │ ╭ fn main() {
|
||||||
|
8 │ │ foo();
|
||||||
|
│ │ ^^^^ invalid function call
|
||||||
|
│ ╰──────────────────────────^ naga::Function [1]
|
||||||
|
│ \n = Call to [0] is invalid
|
||||||
|
= Requires 1 arguments, but 0 are provided
|
||||||
|
|
||||||
|
",
|
||||||
|
)];
|
||||||
|
|
||||||
|
for (source, expected_err) in cases {
|
||||||
|
let module = naga::front::wgsl::parse_str(source).unwrap();
|
||||||
|
let err = valid::Validator::new(Default::default(), valid::Capabilities::all())
|
||||||
|
.validate_no_overrides(&module)
|
||||||
|
.expect_err("module should be invalid");
|
||||||
|
println!("{}", err.emit_to_string(source));
|
||||||
|
assert_eq!(err.emit_to_string(source), expected_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user