fedbc35315
Here, the inline uniform block is explicit: we instantiate the buffer block itself in the argument buffer, instead of a pointer to the buffer. I just hope this will work with the `MTLArgumentDescriptor` API... Note that Metal recursively assigns individual members of embedded structs IDs. This means for automatic assignment that we have to calculate the binding stride for a given buffer block. For MoltenVK, we'll simply increment the ID by the size of the inline uniform block. Then the later IDs will never conflict with the inline uniform block. We can get away with this because Metal doesn't require that IDs be contiguous, only monotonically increasing.
38 lines
496 B
Plaintext
38 lines
496 B
Plaintext
#version 450
|
|
#extension GL_EXT_scalar_block_layout : require
|
|
layout(local_size_x = 3, local_size_y = 3, local_size_z = 2) in;
|
|
|
|
struct X
|
|
{
|
|
int x;
|
|
int y;
|
|
float z;
|
|
};
|
|
|
|
layout(set = 0, binding = 0, scalar) uniform Foo
|
|
{
|
|
int a;
|
|
int b;
|
|
mat4 c;
|
|
X x[2];
|
|
};
|
|
|
|
layout(set = 0, binding = 1) uniform Bar
|
|
{
|
|
int d;
|
|
int e;
|
|
};
|
|
|
|
layout(set = 1, binding = 2) buffer Baz
|
|
{
|
|
int f;
|
|
int g;
|
|
} baz[3];
|
|
|
|
void main()
|
|
{
|
|
uvec3 coords = gl_GlobalInvocationID;
|
|
baz[coords.x].f = a + d;
|
|
baz[coords.x].g = b * e;
|
|
}
|