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_EX:-slang -compute -shaderobj 2 3// Tests operator overloading works in user space. 4 5//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 6RWStructuredBuffer<int> outputBuffer; 7 8struct Vec2d 9{ 10 float x, y; 11}; 12 13Vec2d operator+(Vec2d a, Vec2d b) 14{ 15 return {a.x + b.x, a.y + b.y}; 16} 17 18[numthreads(4, 1, 1)] 19void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 20{ 21 int index = dispatchThreadID.x; 22 23 Vec2d a = { 1, -index + 3 }; 24 Vec2d b = { index - 4, index * index }; 25 26 Vec2d c = a + b; 27 28 int r = int(c.x + c.y); 29 30 outputBuffer[dispatchThreadID.x] = int(r); 31}