yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
ef4c9f1f1
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -shaderobj -emit-spirv-directly -output-using-type 2 3//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):out,name=outputBuffer 4RWStructuredBuffer<int> outputBuffer; 5 6// CHECK: 4 7// CHECK-NEXT: 8 8// CHECK-NEXT: 12 9// CHECK-NEXT: 16 10 11// 12// This test tests that addresses of variables and inout parameters can be 13// passed into a spirv_asm block 14// 15[numthreads(4, 1, 1)] 16void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 17{ 18 int i = dispatchThreadID.x; 19 int n = outputBuffer[i]; 20 int r; 21 spirv_asm 22 { 23 OpLoad $$int %n &n; 24 OpConstant $$int %two 2; 25 OpIMul $$int %r $n %two; 26 OpStore &r %r; 27 }; 28 foo(r); 29 outputBuffer[i] = r; 30} 31 32func foo(inout int x) 33{ 34 spirv_asm 35 { 36 OpLoad $$int %x &x; 37 OpIAdd $$int %added %x %x; 38 OpStore &x %added; 39 }; 40} 41