wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

[glsl-in] explicitly sizing unsized arrays causes validation errors

Open Vipitis opened this issue 1 year ago • 1 comments

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

Vipitis avatar Feb 06 '24 00:02 Vipitis

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

teoxoy avatar Feb 08 '24 14:02 teoxoy