[wgsl-in] Broken error message for invalid textureStore() on 2d_array
JMS55 opened this issue · comments
// Original source: https://www.activision.com/cdn/research/downsample_cubemap.txt
@group(0) @binding(0) var tex_hi_re: texture_cube<f32>;
@group(0) @binding(1) var tex_los_res: texture_storage_2d_array<rg11b10float, write>;
@group(0) @binding(2) var bilinear: sampler;
fn get_dir(u: f32, v: f32, face: u32) -> vec3<f32> {
switch face {
case 0u: { return vec3(1.0, v, -u); }
case 1u: { return vec3(-1.0, v, u); }
case 2u: { return vec3(u, 1.0, -v); }
case 3u: { return vec3(u, -1.0, v); }
case 4u: { return vec3(u, v, 1.0); }
default { return vec3(-u, v, -1.0); }
}
}
fn calc_weight(u: f32, v: f32) -> f32 {
let val = u * u + v * v + 1.0;
return val * sqrt(val);
}
@compute
@workgroup_size(8, 8, 1)
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
let res_lo = textureDimensions(tex_los_res).x;
if all(vec2u(id.xy) < vec2u(res_lo)) {
let inv_res_lo = 1.0 / f32(res_lo);
let u0 = (f32(id.x) * 2.0 + 1.0 - 0.75) * inv_res_lo - 1.0;
let u1 = (f32(id.x) * 2.0 + 1.0 + 0.75) * inv_res_lo - 1.0;
let v0 = (f32(id.y) * 2.0 + 1.0 - 0.75) * -inv_res_lo + 1.0;
let v1 = (f32(id.y) * 2.0 + 1.0 + 0.75) * -inv_res_lo + 1.0;
var weights = array(calc_weight(u0, v0), calc_weight(u1, v0), calc_weight(u0, v1), calc_weight(u1, v1));
let wsum = 0.5 / (weights[0] + weights[1] + weights[2] + weights[3]);
for (var i = 0u; i < 4u; i++) {
weights[i] = weights[i] * wsum + 0.125;
}
var color = textureSampleLevel(tex_hi_re, bilinear, get_dir(u0, v0, id.z), 0.0) * weights[0];
color += textureSampleLevel(tex_hi_re, bilinear, get_dir(u1, v0, id.z), 0.0) * weights[1];
color += textureSampleLevel(tex_hi_re, bilinear, get_dir(u0, v1, id.z), 0.0) * weights[2];
color += textureSampleLevel(tex_hi_re, bilinear, get_dir(u1, v1, id.z), 0.0) * weights[3];
textureStore(tex_los_res, id, color);
}
}
error: wrong number of arguments: expected 3, found 3
┌─ crates/bevy_pbr/src/environment_map/downsample.wgsl:68:9
│
68 │ textureStore(tex_los_res, id, color);
│ ^^^^^^^^^^^^ wrong number of arguments
│
= wrong number of arguments: expected 3, found 3