SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp
2017-08-09 17:06:41 +02:00

66 lines
1.3 KiB
Plaintext

#version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
struct Foo
{
vec4 a;
vec4 b;
vec4 c;
vec4 d;
};
layout(binding = 1, std430) readonly buffer SSBO2
{
vec4 data[];
} indata;
layout(binding = 0, std430) writeonly buffer SSBO
{
vec4 data[];
} outdata;
layout(binding = 2, std430) readonly buffer SSBO3
{
Foo foos[];
} foobar;
void baz(inout Foo foo)
{
uint ident = gl_GlobalInvocationID.x;
foo.a = indata.data[(4u * ident) + 0u];
foo.b = indata.data[(4u * ident) + 1u];
foo.c = indata.data[(4u * ident) + 2u];
foo.d = indata.data[(4u * ident) + 3u];
}
void meow(inout Foo foo)
{
foo.a += vec4(10.0);
foo.b += vec4(20.0);
foo.c += vec4(30.0);
foo.d += vec4(40.0);
}
vec4 bar(Foo foo)
{
return ((foo.a + foo.b) + foo.c) + foo.d;
}
void main()
{
Foo param;
baz(param);
Foo foo = param;
Foo param_1 = foo;
meow(param_1);
foo = param_1;
Foo param_2 = foo;
Foo param_3;
param_3.a = foobar.foos[gl_GlobalInvocationID.x].a;
param_3.b = foobar.foos[gl_GlobalInvocationID.x].b;
param_3.c = foobar.foos[gl_GlobalInvocationID.x].c;
param_3.d = foobar.foos[gl_GlobalInvocationID.x].d;
outdata.data[gl_GlobalInvocationID.x] = bar(param_2) + bar(param_3);
}