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 initializing an extential value 7// from a generic value. 8 9[anyValueSize(16)] 10interface IInterface 11{ 12 int Compute(int inVal); 13}; 14 15int GenericCompute0(IInterface obj, int inVal) 16{ 17 return obj.Compute(inVal); 18} 19 20int GenericCompute1<T:IInterface>(T obj, int inVal) 21{ 22 IInterface iobj = obj; 23 return iobj.Compute(inVal) + 24 GenericCompute0(obj, inVal) - 25 GenericCompute0(iobj, inVal); 26} 27 28 29struct Impl : IInterface 30{ 31 int base; 32 int Compute(int inVal) { return base + inVal * inVal; } 33}; 34 35int test(int inVal) 36{ 37 Impl obj; 38 obj.base = 1; 39 return GenericCompute1(obj, inVal); 40} 41 42//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer 43RWStructuredBuffer<int> outputBuffer; 44 45[numthreads(4, 1, 1)] 46void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 47{ 48 uint tid = dispatchThreadID.x; 49 int inVal = outputBuffer[tid]; 50 int outVal = test(inVal); 51 outputBuffer[tid] = outVal; 52}