yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
7758625d3
master
1//TEST:SIMPLE(filecheck=CHECK):-stage compute -entry computeMain -target spirv 2 3// Tests for invalid/valid use of `__getAddress` 4 5struct DeviceStruct 6{ 7 int data1; 8 int data2; 9} 10 11struct StructPtrInStruct 12{ 13 DeviceStruct* ptr; 14} 15 16uniform int* bufferUserPointer; 17RWStructuredBuffer<int> bufferStorage; 18groupshared int bufferGroupShared[100]; 19uniform DeviceStruct* bufferUserPointerStruct; 20uniform int2* bufferUserPointerVector; 21 22int* output; 23 24typealias GroupSharedPtr<T> = Ptr<T, Access::ReadWrite, AddressSpace::GroupShared>; 25 26GroupSharedPtr<T> paramGroupShared<T : __BuiltinIntegerType>(out groupshared T[100] ptr) 27{ 28 // CHECK: ([[# @LINE+1]]): error 30019 29 T* ptr1 = __getAddress(ptr[5]); 30 31 // CHECK-NOT: ([[# @LINE+1]]): error 32 GroupSharedPtr<T> ptr2 = __getAddress(ptr[5]); 33 34 return ptr2; 35} 36 37[numthreads(1, 1, 1)] 38void computeMain(int id : SV_DispatchThreadID) 39{ 40 // CHECK: ([[# @LINE+1]]): error 31160 41 int* ptr1 = __getAddress(bufferStorage[id.x]); 42 43 // CHECK ([[# @LINE+1]]): error 44 int[100]* ptr2 = __getAddress(bufferGroupShared); 45 46 // CHECK: ([[# @LINE+1]]): error 47 int* ptr3 = __getAddress(bufferGroupShared[id.x]); 48 49 // CHECK-NOT: ([[# @LINE+1]]): error 50 int* ptr4 = __getAddress(bufferUserPointer[id.x]); 51 52 // CHECK-NOT: ([[# @LINE+1]]): error 53 GroupSharedPtr<int[100]> ptr5 = __getAddress(bufferGroupShared); 54 55 // CHECK-NOT: ([[# @LINE+1]]): error 56 GroupSharedPtr<int> ptr6 = __getAddress(bufferGroupShared[id.x]); 57 58 // CHECK-NOT: ([[# @LINE+1]]): error 59 GroupSharedPtr<int> ptr7 = paramGroupShared(bufferGroupShared); 60 61 // CHECK-NOT: ([[# @LINE+1]]): error 62 int* ptr8 = __getAddress(bufferUserPointerStruct.data1); 63 64 StructPtrInStruct structPtrInStruct; 65 structPtrInStruct.ptr = bufferUserPointerStruct; 66 // CHECK-NOT: ([[# @LINE+1]]): error 67 int* ptr9 = __getAddress(structPtrInStruct.ptr[id.x].data1); 68 69 // CHECK-NOT: ([[# @LINE+1]]): error 70 int* ptr10 = __getAddress(bufferUserPointerVector[0].x); 71 72 output[id] = ptr1[id]; 73 output[id] = ptr2[id][0]; 74 output[id] = ptr3[id]; 75 output[id] = ptr4[id]; 76 output[id] = ptr5[id]; 77 output[id] = ptr6[id]; 78 output[id] = ptr7[id]; 79 output[id] = ptr8[id]; 80 output[id] = ptr9[id]; 81 output[id] = ptr10[id]; 82}