yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
7dabfa76c
master
1//TEST(compute):COMPARE_COMPUTE: -shaderobj 2//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj 3 4// Testing that we can implicitly specialize a generic 5// that has a constrained type parameter. 6 7 8interface ISimple 9{ 10 int getVal(); 11} 12 13struct Simple : ISimple 14{ 15 int val; 16 17 int getVal() { return val; } 18}; 19 20int doIt<T : ISimple>(T obj) 21{ 22 return obj.getVal(); 23} 24 25int test(int val) 26{ 27 Simple simple; 28 simple.val = val; 29 return doIt(simple); 30} 31 32//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 33RWStructuredBuffer<int> outputBuffer; 34 35[numthreads(4, 1, 1)] 36void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 37{ 38 int tid = (int) dispatchThreadID.x; 39 int outVal = test(tid); 40 outputBuffer[tid] = outVal; 41}