fb5ee4cb5c
This command allows the caller to set the base value of `BuiltInWorkgroupId`, and thus of `BuiltInGlobalInvocationId`. Metal provides no direct support for this... but it does provide a builtin, `[[grid_origin]]`, normally used to pass the base values for the stage input region, which we will now abuse to pass the dispatch base and avoid burning a buffer binding. `[[grid_origin]]`, as part of Metal's support for compute stage input, requires MSL 1.2. For 1.0 and 1.1, we're forced to provide a buffer. (Curiously, this builtin was undocumented until the MSL 2.2 release. Go figure.)
30 lines
513 B
Plaintext
30 lines
513 B
Plaintext
#version 310 es
|
|
layout(local_size_x_id = 10) in;
|
|
|
|
layout(std430, binding = 0) readonly buffer SSBO
|
|
{
|
|
vec4 in_data[];
|
|
};
|
|
|
|
layout(std430, binding = 1) writeonly buffer SSBO2
|
|
{
|
|
vec4 out_data[];
|
|
};
|
|
|
|
layout(std430, binding = 2) buffer SSBO3
|
|
{
|
|
uint counter;
|
|
};
|
|
|
|
void main()
|
|
{
|
|
uint ident = gl_GlobalInvocationID.x;
|
|
uint workgroup = gl_WorkGroupID.x;
|
|
vec4 idata = in_data[ident];
|
|
if (dot(idata, vec4(1.0, 5.0, 6.0, 2.0)) > 8.2)
|
|
{
|
|
out_data[atomicAdd(counter, 1u)] = idata;
|
|
}
|
|
}
|
|
|