// Generated by LLMenuEXT from the proven Miyabi palette assembly topology.
// All component VSTs are bound together; one dispatch writes float4 matrix rows.

Buffer<float4> t0 : register(t0); // Body: 105 bones
Buffer<float4> t1 : register(t1); // Legs: 51 bones
Buffer<float4> t2 : register(t2); // ShieldMount: 1 bones
Buffer<float4> t3 : register(t3); // Tail: 14 bones
RWBuffer<float4> u0 : register(u0);

float3x3 Inverse3x3(float3x3 m)
{
    float a=m[0][0], b=m[0][1], c=m[0][2];
    float d=m[1][0], e=m[1][1], f=m[1][2];
    float g=m[2][0], h=m[2][1], i=m[2][2];
    float det=a*(e*i-f*h)-b*(d*i-f*g)+c*(d*h-e*g);
    if (abs(det) < 1e-8) return float3x3(1,0,0, 0,1,0, 0,0,1);
    float inv=rcp(det);
    return float3x3((e*i-f*h)*inv,(c*h-b*i)*inv,(b*f-c*e)*inv,
                    (f*g-d*i)*inv,(a*i-c*g)*inv,(c*d-a*f)*inv,
                    (d*h-e*g)*inv,(b*g-a*h)*inv,(a*e-b*d)*inv);
}

[numthreads(64, 1, 1)]
void main(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    uint id = dispatchThreadID.x;
    // Body: merged rows 0..314
    if (id < 315)
    {
        u0[id] = t0[id - 0];
        return;
    }
    // Legs: merged rows 315..467
    if (id < 468)
    {
        u0[id] = t1[id - 315];
        return;
    }
    // ShieldMount: merged rows 468..470
    if (id < 471)
    {
        u0[id] = t2[id - 468];
        return;
    }
    // Tail: merged rows 471..512
    if (id < 513)
    {
        u0[id] = t3[id - 471];
        return;
    }
}
