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

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

Closed
Wumpf opened this issue Jun 13, 2023 · 1 comment · Fixed by #2382
Closed

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

Wumpf opened this issue Jun 13, 2023 · 1 comment · Fixed by #2382
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: GLSL OpenGL Shading Language

Comments

@Wumpf
Copy link
Member

Wumpf commented Jun 13, 2023

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;
}
@Wumpf Wumpf changed the title [glsl-out] Return type for returning arrays is incorrect. [glsl-out] Return type for returning arrays is incorrect Jun 13, 2023
Wumpf added a commit to rerun-io/rerun that referenced this issue Jun 13, 2023
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

### What

Works around  gfx-rs/naga#2380

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)


<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2413

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/26e3636/docs
Examples preview: https://rerun.io/preview/26e3636/examples
<!-- pr-link-docs:end -->
@teoxoy
Copy link
Member

teoxoy commented Jun 13, 2023

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

@teoxoy teoxoy added kind: bug Something isn't working area: back-end Outputs of shader conversion lang: GLSL OpenGL Shading Language labels Jun 13, 2023
emilk pushed a commit to rerun-io/rerun that referenced this issue Jun 15, 2023
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

### What

Works around  gfx-rs/naga#2380

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)


<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2413

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/26e3636/docs
Examples preview: https://rerun.io/preview/26e3636/examples
<!-- pr-link-docs:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: GLSL OpenGL Shading Language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants