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

[wgsl-in] Broken error message for invalid textureStore() on 2d_array #2431

Closed
JMS55 opened this issue Aug 10, 2023 · 0 comments · Fixed by #2432
Closed

[wgsl-in] Broken error message for invalid textureStore() on 2d_array #2431

JMS55 opened this issue Aug 10, 2023 · 0 comments · Fixed by #2432
Labels
area: front-end Input formats for conversion kind: bug Something isn't working lang: WGSL WebGPU shading language

Comments

@JMS55
Copy link
Contributor

JMS55 commented Aug 10, 2023

// 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
fornwall added a commit to fornwall/naga that referenced this issue Aug 10, 2023
fornwall added a commit to fornwall/naga that referenced this issue Aug 11, 2023
@teoxoy teoxoy added kind: bug Something isn't working lang: WGSL WebGPU shading language area: front-end Input formats for conversion labels Aug 11, 2023
@teoxoy teoxoy added this to the WGSL Specification V1 milestone Aug 11, 2023
fornwall added a commit to fornwall/naga that referenced this issue Aug 11, 2023
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 lang: WGSL WebGPU shading language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants