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 general `This` type. 7[anyValueSize(8)] 8interface IInterface 9{ 10 int Compute(int inVal, This other); 11}; 12 13int GenericCompute<T:IInterface>(int inVal, T obj, T other) 14{ 15 return obj.Compute(inVal, other); 16} 17 18struct Impl : IInterface 19{ 20 int base; 21 int Compute(int inVal, This other) { return other.base + base + inVal; } 22}; 23int test(int inVal) 24{ 25 Impl obj1, obj2; 26 obj1.base = 1; 27 obj2.base = 2; 28 return GenericCompute<Impl>(inVal, obj1, obj2); 29} 30 31//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer 32RWStructuredBuffer<int> outputBuffer; 33 34[numthreads(4, 1, 1)] 35void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 36{ 37 uint tid = dispatchThreadID.x; 38 int inVal = outputBuffer[tid]; 39 int outVal = test(inVal); 40 outputBuffer[tid] = outVal; 41}