yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
dfdf243f0
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj -output-using-type 2 3interface IOperation 4{ 5 [mutating] 6 void Store(float v); 7 8 float Load(); 9}; 10 11struct TOperationMax : IOperation 12{ 13 float result; 14 15 [mutating] 16 void Store(float v) 17 { 18 result = v; 19 } 20 21 float Load() 22 { 23 return result; 24 } 25}; 26 27float Run(inout IOperation op, float val) 28{ 29 op.Store(val); 30 return op.Load(); 31} 32 33//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 34RWStructuredBuffer<float> outputBuffer; 35 36[numthreads(4, 1, 1)] 37[shader("compute")] 38void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 39{ 40 TOperationMax opMax; 41 opMax.result = 0.f; 42 float val = 2.f; 43 IOperation op = opMax; 44 float result = Run(op, val); 45 // CHECK: 2.0 46 outputBuffer[0] = result; 47}