Wrong number of arguments error is wrong/misleading
Norlock opened this issue · comments
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
This should have been fixed by #2432. You are probably missing the array layer.
@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
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.
@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
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));
}
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) {
...
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.
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.
Commit with fix: Norlock/sparticles@8bebe48 see: blend.wgsl. The commit you can go to and reproduce the bug by reverting line 15.