SPIRV-Cross/reference/shaders/comp/inout-struct.invalid.comp
Hans-Kristian Arntzen e67f6f85a4 Defer parenthesis generation until needed.
Previously, we would generate parentheses proactively when generating
binary ops, however, this leads to uglier code and hits warnings in
compilers when used as a conditional.
2016-12-05 10:56:54 +01: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) buffer SSBO2
{
vec4 data[];
} indata;
layout(binding = 0, std430) buffer SSBO
{
vec4 data[];
} outdata;
layout(binding = 2, std430) buffer SSBO3
{
Foo foos[];
} foobar;
void baz(out 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 = foo.a + vec4(10.0);
foo.b = foo.b + vec4(20.0);
foo.c = foo.c + vec4(30.0);
foo.d = 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);
}