https://github.com/shader-slang/slang
Raw File
Tip revision: 926009a58315845b3a3a95e2724486a6c9e987ea authored by Tomáš Pazdiora on 10 May 2024, 01:17:38 UTC
fix typo (#4144)
Tip revision: 926009a
gh-566.slang
// legalize-struct-init.slang

//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
//TEST_INPUT:ubuffer(data=[4 3 2 1], stride=4):name inputBuffer


RWStructuredBuffer<uint> outputBuffer;
RWStructuredBuffer<uint> inputBuffer;

struct Helper
{
    RWStructuredBuffer<uint> o;
    RWStructuredBuffer<uint> i;
    uint                    t;  
};

void test(Helper h)
{
    h.o[h.t] = h.i[h.t] * 16 + h.t;    
}

void test(uint t)
{
    Helper h = { outputBuffer, inputBuffer, t };
    test(h);
}

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    uint tid = dispatchThreadID.x;
    test(tid);
}
back to top