yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
712ce653d
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type 2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type 3 4interface IEqlTestable<T> 5{ 6 bool testEql(T v1); 7} 8 9bool test<T>(IEqlTestable<T> v0, T v1) 10{ 11 return v0.testEql(v1); 12} 13 14struct MyType : IEqlTestable<MyType> 15{ 16 int val; 17 bool testEql(MyType v1) 18 { 19 return val == v1.val; 20 } 21} 22 23//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 24RWStructuredBuffer<int> outputBuffer; 25 26[numthreads(2, 1, 1)] 27void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 28{ 29 int tid = dispatchThreadID.x; 30 MyType obj1, obj2; 31 obj1.val = tid; 32 obj2.val = 1; 33 let result = test(obj1, obj2); 34 outputBuffer[tid] = result ? 1 : 0; 35 // CHECK: 0 36 // CHECK: 1 37}