https://github.com/shader-slang/slang
Raw File
Tip revision: 7a1b6deff067b393041e90eb6b1ac6a62dedd5dd authored by jsmall-nvidia on 31 July 2020, 16:25:58 UTC
Fix for bug where memory that has been allocated with new T[] (within a list) is freed with free in the RiffContainer. (#1473)
Tip revision: 7a1b6de
generics-syntax-2.slang
//TEST(compute):COMPARE_COMPUTE:
//TEST(compute):COMPARE_COMPUTE:-cpu

// Confirm that generics syntax can be used in user
// code and generates valid output.

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<float> outputBuffer;

struct GenStruct<T>
{
    T x;
};

GenStruct<T> test<T>(T val)
{
    GenStruct<T> rs;
    rs.x = val;
    return rs;
}


[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    uint tid = dispatchThreadID.x;
    float inVal = float(tid);
    GenStruct<float> outVal = test(inVal);
    outputBuffer[tid] = outVal.x;
}
back to top