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 specializing a generic with 7// an existential value. 8 9[anyValueSize(16)] 10interface IInterface 11{ 12 int Compute(int inVal); 13}; 14 15int GenericCompute0(IInterface obj, int inVal) 16{ 17 return GenericCompute1(obj, obj, inVal); 18} 19 20int GenericCompute1<T:IInterface>(T obj, IInterface obj2, int inVal) 21{ 22 return obj.Compute(inVal) + obj2.Compute(inVal); 23} 24 25 26struct Impl : IInterface 27{ 28 int base; 29 int Compute(int inVal) { return base + inVal * inVal; } 30}; 31 32int test(int inVal) 33{ 34 Impl obj; 35 obj.base = 1; 36 return GenericCompute0(obj, inVal); 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}