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-in] explicitly sizing unsized arrays causes validation errors #5206

Open
Vipitis opened this issue Feb 6, 2024 · 1 comment
Open
Labels
area: naga front-end lang: GLSL OpenGL Shading Language naga Shader Translator

Comments

@Vipitis
Copy link

Vipitis commented Feb 6, 2024

Description
I run into some array construction issues when running Shadertoys with wgpu. According to the OpenGL spec Chapter 4.1.9 allows you to declare arrays with explicit size even implicitly when using an array constructor.

Repro steps
These versions give you validation error: The type is not constructible

const float[] a = float[](0.0, 1.0, 2.0, 3.0);
const float[] b = float[4](0.1, 1.1, 2.1, 3.1);

error is different when not constant: Type flags TypeFlags(DATA | COPY | HOST_SHAREABLE) do not meet the required TypeFlags(CONSTRUCTIBLE) But I am not too sure if this is super relevant...

float[] e = float[](0.4, 1.4, 2.4, 3.4);
float[] f = float[4](0.5, 1.5, 2.5, 3.5);

equivalent versions that work:

const float[4] c = float[](0.2, 1.2, 2.2, 3.2);
const float[4] d = float[4](0.3, 1.3, 2.3, 3.3);
float[4] g = float[](0.6, 1.6, 2.6, 3.6);
float[4] h = float[4](0.7, 1.7, 2.7, 3.7);

Expected behavior
Shadertoy with all variants working (older GLSL spec I believe)

Platform
wgpu 0.19.1 via wgpu-native 0.19.1.1 via wgpu-py#65044aa via wgpu-shadertoy

@teoxoy
Copy link
Member

teoxoy commented Feb 8, 2024

It seems like we are missing array size inference in the GLSL front-end.

@teoxoy teoxoy added naga Shader Translator area: naga front-end lang: GLSL OpenGL Shading Language labels Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga front-end lang: GLSL OpenGL Shading Language naga Shader Translator
Projects
None yet
Development

No branches or pull requests

2 participants