Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

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

Closed
@Wumpf

Description

@Wumpf

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: back-endOutputs of shader conversionkind: bugSomething isn't workinglang: GLSLOpenGL Shading Language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions