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