gfx-rs / naga

Universal shader translation in Rust

Home Page:https://github.com/gfx-rs/wgpu/tree/trunk/naga

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[glsl-out] Return type for returning arrays is incorrect

Wumpf opened this issue · comments

To my understanding wgsl supports having arrays as return types. However, the glsl backend doesn't handle this correctly right now, putting the element type as return value:

Minimal repro:

Wgsl in:

fn ret_array() -> array<f32, 2> {
    return array<f32, 2>(1.0, 2.0);
}

@fragment
fn main() -> @location(0) vec4<f32> {
    let a = ret_array();
    return vec4<f32>(a[0], a[1], 0.0, 1.0);
}

Glsl out (cargo run --all-features -- ./test.wgsl test.frag):

#version 310 es

precision highp float;
precision highp int;

layout(location = 0) out vec4 _fs2p_location0;

float ret_array() {
    return float[2](1.0, 2.0);
}

void main() {
    float _e0 = ret_array();
    _fs2p_location0 = vec4(_e0[0], _e0[1], 0.0, 1.0);
    return;
}

Linking a similar HLSL issue: gfx-rs/wgpu#4393