Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
[wgsl-in] Fix error message for invalid textureStore() on 2d_array
Browse files Browse the repository at this point in the history
Fixes #2431
  • Loading branch information
fornwall committed Aug 10, 2023
1 parent 061d499 commit 51214d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/front/wgsl/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,10 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {

let (_, arrayed) = ctx.image_data(image, image_span)?;
let array_index = arrayed
.then(|| self.expression(args.next()?, ctx.reborrow()))
.then(|| {
args.min_args += 1;
self.expression(args.next()?, ctx.reborrow())
})
.transpose()?;

let value = self.expression(args.next()?, ctx.reborrow())?;
Expand Down
19 changes: 19 additions & 0 deletions src/front/wgsl/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,22 @@ fn parse_alias() {
)
.unwrap();
}

#[test]
fn parse_texture_store_expecting_four_args() {
let error = parse_str(
"
@group(0) @binding(0) var tex_los_res: texture_storage_2d_array<rg11b10float, write>;
@compute
@workgroup_size(1)
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
var color = vec4(1, 1, 1, 1);
textureStore(tex_los_res, id, color);
}",
)
.unwrap_err();
assert_eq!(
error.message(),
"wrong number of arguments: expected 4, found 3"
);
}

0 comments on commit 51214d4

Please sign in to comment.