yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
7dabfa76c
master
1//TEST(compute):COMPARE_COMPUTE: -shaderobj 2//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj 3 4 5// Access fields of a `struct` type from within a "method" by 6// using an explicit `this` expression. 7 8struct A 9{ 10 float x; 11 12 float addWith(float y) 13 { 14 return this.x + y; 15 } 16}; 17 18//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 19RWStructuredBuffer<float> outputBuffer; 20 21 22float test(float inVal) 23{ 24 A a; 25 a.x = inVal; 26 return a.addWith(inVal*inVal); 27} 28 29[numthreads(4, 1, 1)] 30void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 31{ 32 uint tid = dispatchThreadID.x; 33 float inVal = float(tid); 34 float outVal = test(inVal); 35 outputBuffer[tid] = outVal; 36}