yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
2a5d5b323
master
1//TEST(compute):COMPARE_COMPUTE:-dx11 -shaderobj 2//TEST(compute):COMPARE_COMPUTE:-vk -shaderobj 3//TEST(compute):COMPARE_COMPUTE:-cpu -xslang -disable-specialization -shaderobj 4//TEST(compute):COMPARE_COMPUTE:-cuda -xslang -disable-specialization -shaderobj 5 6// Test dynamic dispatch code gen for generic-typed local variables. 7 8[anyValueSize(8)] 9interface IInterface 10{ 11 [mutating] 12 int Compute(int inVal); 13}; 14 15int GenericCompute<T:IInterface>(int inVal) 16{ 17 T obj; 18 obj.Compute(3); 19 return obj.Compute(inVal); // 3 + inVal 20} 21 22struct Impl : IInterface 23{ 24 int base; 25 [mutating] 26 int Compute(int inVal) 27 { 28 int result = base + inVal; 29 base = inVal; 30 return result; 31 } 32}; 33 34int test(int inVal) 35{ 36 return GenericCompute<Impl>(1); 37} 38 39//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer 40RWStructuredBuffer<int> outputBuffer; 41 42[numthreads(4, 1, 1)] 43void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 44{ 45 uint tid = dispatchThreadID.x; 46 int inVal = outputBuffer[tid]; 47 int outVal = test(inVal); 48 outputBuffer[tid] = outVal; 49}