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
989 B29 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target spirv
2
3RWStructuredBuffer<float> mutable_float_buffer;
4RWStructuredBuffer<uint> mutable_uint_buffer;
5
6StructuredBuffer<float> constant_float_buffer;
7StructuredBuffer<uint> constant_uint_buffer;
8
9// We do not allow taking a pointer from a StructuredBuffer/RWStructuredBuffer.
10[shader("compute")]
11[numthreads(1,1,1)]
12void computeMain(uint3 threadId : SV_DispatchThreadID)
13{
14    float* mutablePtr1 = &mutable_float_buffer[threadId.x];
15
16    // CHECK: ([[# @LINE+1]]): error 31160
17    float* mutablePtr2 = __getAddress(mutable_float_buffer[threadId.x]);
18
19    InterlockedAdd(mutable_uint_buffer[threadId.x], 1);
20
21    // Constant pointers arent a thing in slang
22    // CHECK: ([[# @LINE+1]]): error 30079:
23    float* ptr1 = &constant_float_buffer[threadId.x];
24
25    // CHECK: ([[# @LINE+1]]): error 31160
26    float* ptr2 = __getAddress(constant_float_buffer[threadId.x]);
27
28    InterlockedAdd(constant_uint_buffer[0], 1);
29}