yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
aa28f26e1
master
1// frem.slang 2 3//TEST(compute):COMPARE_COMPUTE: -shaderobj -output-using-type 4//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj -output-using-type 5//TEST(compute):COMPARE_COMPUTE:-vk -shaderobj -emit-spirv-directly -output-using-type 6 7// Test uses of floating-point `%` operator. 8 9RWStructuredBuffer<float> gInput; 10//TEST_INPUT:ubuffer(data=[2.0 1.0 5.0 2.0 1.0 -4.0 -5.0 4.0], stride=4):name=gInput 11 12int test(int inVal) 13{ 14 float a = gInput[inVal*2]; 15 float b = gInput[inVal*2 + 1]; 16 return int(a % b); 17} 18 19//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 20RWStructuredBuffer<float> outputBuffer; 21 22[Shader("compute")] 23[NumThreads(4, 1, 1)] 24void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 25{ 26 int tid = dispatchThreadID.x; 27 int inVal = tid; 28 int outVal = test(inVal); 29 outputBuffer[tid] = outVal; 30}