How to use GLSL uniform struct with WebGPU

Hello everyone,

I am working on porting some code to WebGPU, and I have a shader written in GLSL with a uniform struct like this:

struct Test {
    float field;
};

uniform Test test;

But then when I hit run I get this cryptic error message:

image

I made a small PG:

Does anyone know what I must change to make the parser happy?

I do not think it is supported. cc @Evgeni_Popov for confirmation.

1 Like

No, it is not supported. What we support is to declare it like this:

    uniform Test {
        float field;
    };

Here’s a fixed PG:

However, you will need this PR for the PG to work, as we currently don’t support uniform buffers in post processes:

3 Likes

Thank you for the PR! That works for me

Is there any way to keep scoping, so that it can be used like this?

uniform Test {
	float field;
} test;

// later on
test.field

No, this syntax is only supported if you write your shader directly in WGSL.

I see, thank you.