yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

ArielG-NV[CBP] Pointer frontend changes + groupshared pointer support (#7848)7758625d3

master
954 B41 linesraw
1//TEST:SIMPLE(filecheck=CHECK):-stage compute -entry computeMain -target spirv
2
3// Writing with a read-only pointer should be an error
4
5int* processMemory;
6RWStructuredBuffer<int> output;
7
8typealias ReadPtr = Ptr<int, Access::Read, AddressSpace::Device>;
9
10void writeToReadOnlyPointer(ReadPtr ptr)
11{
12    // CHECK: ([[# @LINE+1]]): error 30011
13    ptr[0] = 1;
14}
15
16void writeToReadOnlyPointerOut(out int ptrVal)
17{
18    ptrVal = 1;
19}
20
21[numthreads(1, 1, 1)]
22void computeMain(int id : SV_DispatchThreadID)
23{
24    // CHECK-NOT: ([[# @LINE+1]]): error
25    ReadPtr ptr1 = ReadPtr(processMemory + id.x);
26
27    // CHECK: ([[# @LINE+1]]): error 30011
28    ptr1[id + 1] = 1;
29    // CHECK: ([[# @LINE+1]]): error 30011
30    *ptr1 = 1;
31
32    writeToReadOnlyPointer(ptr1);
33
34    // CHECK: ([[# @LINE+1]]): error 30047
35    writeToReadOnlyPointerOut(ptr1[1]);
36
37    // CHECK: ([[# @LINE+1]]): error 30047
38    writeToReadOnlyPointerOut(*(ptr1+2));
39    
40    output[id] = ptr1[id];
41}