yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
04e7327a2
master
1//TEST:SIMPLE(filecheck=CHECK_EXPERIMENTAL):-target spirv -entry main -stage compute -emit-spirv-directly -O0 -enable-experimental-passes 2//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry main -stage compute -emit-spirv-directly -O0 3 4// Test that we can pass arguments in different address space to an `inout` parameter, and have 5// the callee specialized to the address space of the argument. 6// If successful, we should generate SPIRV that passes validation. 7 8static int gArray0[2]; 9groupshared int gArray1[2]; 10 11// Note: static globals are inside a context variable 12// CHECK_EXPERIMENTAL: OpTypeArray %int %int_2 13// CHECK_EXPERIMENTAL: OpVariable %_ptr_Function__arr_int_int_2 Function 14// CHECK_EXPERIMENTAL: %array_0 = OpFunctionParameter %_ptr_Workgroup__arr_int_int_2 15 16 17// CHECK: %array = OpFunctionParameter %_ptr_Private__arr_int_int_2 18// CHECK: %array_0 = OpFunctionParameter %_ptr_Workgroup__arr_int_int_2 19 20void modify(inout int array[2]) 21{ 22 array[0] = 1; 23 array[1] = 2; 24} 25 26void atomicOp(inout int array[2]) 27{ 28 InterlockedAdd(array[0], 1); 29} 30 31RWStructuredBuffer<int> output; 32 33[numthreads(1,1,1)] 34void main() 35{ 36 modify(gArray0); 37 modify(gArray1); 38 atomicOp(gArray1); 39 output[0] = gArray0[0] + gArray1[1]; 40}