#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct BDA;

struct BDA
{
    float v;
};

struct SSBO
{
    uint v;
};

struct Registers
{
    coherent device BDA* ssbo;
};

constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u);

struct spvDescriptorSetBuffer0
{
    coherent device SSBO* ssbos [[id(0)]][4];
    texture2d<float, access::write, memory_coherence_device> img [[id(4)]];
};

kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant Registers& _80 [[buffer(1)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]])
{
    spvDescriptorSet0.ssbos[gl_WorkGroupID.x]->v += 10u;
    spvDescriptorSet0.ssbos[gl_WorkGroupID.x]->v += 2u;
    spvDescriptorSet0.img.write(float4(8.0), uint2(int2(4)));
    spvDescriptorSet0.img.write(float4(1.0), uint2(int2(1)));
    spvDescriptorSet0.img.write(float4(4.0), uint2(int2(2)));
    _80.ssbo->v += 4.0;
    _80.ssbo->v += 6.0;
}

