Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong number of arguments error is wrong/misleading #2583

Closed
Norlock opened this issue Oct 18, 2023 · 9 comments · Fixed by #2584
Closed

Wrong number of arguments error is wrong/misleading #2583

Norlock opened this issue Oct 18, 2023 · 9 comments · Fixed by #2584
Labels
area: front-end Input formats for conversion kind: bug Something isn't working kind: diagnostics Error message should be better lang: WGSL WebGPU shading language

Comments

@Norlock
Copy link

Norlock commented Oct 18, 2023

Repro steps

@group(0) @binding(2) var fx_blend: texture_storage_2d<rgba8unorm, read_write>;

@fragment
fn fs_main(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
    return textureLoad(fx_blend, vec2<i32>(pos.xy), 0);
}

Expected vs observed behavior

Expect behavior:

error: wrong number of arguments: expected 2, found 3
  ┌─ test.wgsl:5:12
  │
5 │     return textureLoad(fx_blend, vec2<i32>(pos.xy), 0);
  │            ^^^^^^^^^^^ wrong number of arguments

Observed behavior:

error: wrong number of arguments: expected 3, found 3
  ┌─ test.wgsl:5:12
  │
5 │     return textureLoad(fx_blend, vec2<i32>(pos.xy), 0);
  │            ^^^^^^^^^^^ wrong number of arguments
@teoxoy
Copy link
Member

teoxoy commented Oct 18, 2023

This should have been fixed by #2432. You are probably missing the array layer.

@teoxoy teoxoy closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2023
@Norlock
Copy link
Author

Norlock commented Oct 18, 2023

@teoxoy can you maybe reopen this issue? I updated wgpu to the lastest version and naga is 0.13.0 and it still produces this error? See: https://github.com/Norlock/sparticles-egui/tree/post_fx_overhaul

@teoxoy
Copy link
Member

teoxoy commented Oct 18, 2023

The fix is not yet part of a release. Could you try wgpu trunk? Also, we are planning to do a release (which will include the fix) next week.

@Norlock
Copy link
Author

Norlock commented Oct 19, 2023

@teoxoy I did update it with trunk by changing egui manually. If you fetch my branch and put this forked repo (https://github.com/Norlock/egui.git) next to this one. You can see it still produces the same error. Cargo tree shows it uses trunk

@Norlock
Copy link
Author

Norlock commented Oct 19, 2023

I already fixed the issue, but the error message is wrong. For read_write textures you have to pass 2 arguments instead of 3 as the error message suggested. This was the fix:

@group(0) @binding(2) var fx_blend: texture_storage_2d<rgba8unorm, read_write>;

@fragment
fn fs_main(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
    return textureLoad(fx_blend, vec2<i32>(pos.xy));
}

@Norlock
Copy link
Author

Norlock commented Oct 19, 2023

One more question I found with the new naga crate. Is it true I have to use same vec size in all/any comparison now?

 if all(abs(distance) < vec3<f32>(force.dead_zone)) {
    ...

before I could use:

 if all(abs(distance) < force.dead_zone) {
    ...

@teoxoy
Copy link
Member

teoxoy commented Oct 23, 2023

That is most likely due to us updating the validation according to the spec. Double-checked and this is correct, the binary operation < requires both operands to be either scalars or vectors.

@teoxoy
Copy link
Member

teoxoy commented Oct 23, 2023

I did update it with trunk by changing egui manually. If you fetch my branch and put this forked repo (https://github.com/Norlock/egui.git) next to this one. You can see it still produces the same error. Cargo tree shows it uses trunk

Will reopen the issue and transfer it to naga.

@teoxoy teoxoy reopened this Oct 23, 2023
@teoxoy teoxoy transferred this issue from gfx-rs/wgpu Oct 23, 2023
@teoxoy teoxoy added kind: bug Something isn't working lang: WGSL WebGPU shading language area: front-end Input formats for conversion kind: diagnostics Error message should be better labels Oct 23, 2023
@teoxoy teoxoy added this to the WGSL Specification V1 milestone Oct 23, 2023
@teoxoy teoxoy changed the title Storage read_write texture not working in fragment shader Wrong number of arguments error is wrong/misleading Oct 23, 2023
@Norlock
Copy link
Author

Norlock commented Oct 23, 2023

Commit with fix: Norlock/sparticles@8bebe48 see: blend.wgsl. The commit you can go to and reproduce the bug by reverting line 15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: front-end Input formats for conversion kind: bug Something isn't working kind: diagnostics Error message should be better lang: WGSL WebGPU shading language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants