yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
712ce653d
master
1// interface-conjunction.slang 2 3// Test that we can compose interfaces with `&` 4 5//TEST(compute):COMPARE_COMPUTE: -shaderobj 6 7interface IFirst 8{ 9 int getFirst(); 10} 11 12interface ISecond 13{ 14 int getSecond(); 15} 16 17struct Pair : IFirst, ISecond 18{ 19 int first; 20 int second; 21 22 int getFirst() { return first; } 23 int getSecond() { return second; } 24} 25 26typealias IBoth = IFirst & ISecond; 27 28int add<T : IBoth>(T input) 29{ 30 return 2*input.getFirst() + input.getSecond(); 31} 32 33int test(int value) 34{ 35 Pair p = { value, (value+1) * 256 }; 36 return add(p); 37} 38 39//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 40RWStructuredBuffer<int> outputBuffer; 41 42[numthreads(4, 1, 1)] 43void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 44{ 45 int tid = dispatchThreadID.x; 46 int inVal = tid; 47 int outVal = test(inVal); 48 outputBuffer[tid] = outVal; 49}