yum-mirror/slang

Making it easier to work with shaders

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

aidanfnvRemove readonly keyword from buffer pointer definitions (#7068)8c98714df

master
1.3 KiB44 linesraw
1//TEST:SIMPLE(filecheck=CHECK):-target glsl -profile glsl_450 -entry main -stage compute
2//TEST:SIMPLE(filecheck=SPV):-target spirv -profile glsl_450 -entry main -stage compute -emit-spirv-via-glsl
3//TEST:SIMPLE(filecheck=SPV):-target spirv -profile glsl_450 -entry main -stage compute -emit-spirv-directly
4// SPV: OpMemoryModel PhysicalStorageBuffer64
5// SPV: OpEntryPoint GLCompute {{.*}} "main" {{.*}}
6// SPV: OpTypePointer PhysicalStorageBuffer
7// SPV: OpConvertPtrToU
8// SPV: OpINotEqual
9struct MyStruct
10{
11    float4 position;
12    float4x4 transform;
13}
14
15// CHECK: layout(buffer_reference, std430, buffer_reference_align = 4) buffer BufferPointer_MyStruct
16// CHECK-NEXT: {
17// CHECK-NEXT: MyStruct{{.*}} _data;
18// CHECK-NEXT: }
19
20// CHECK: struct ConstBufferPointer
21// CHECK-NEXT: {
22// CHECK-NEXT: BufferPointer_MyStruct{{.*}} _ptr
23// CHECK-NEXT: }
24
25struct Globals
26{
27    ConstBufferPointer<MyStruct> pStruct;
28}
29
30ConstantBuffer<Globals> gGlobals;
31
32RWStructuredBuffer<uint> outputBuffer;
33
34[numthreads(1,1,1)]
35void main(int3 tid: SV_DispatchThreadID)
36{
37    if (gGlobals.pStruct.isValid())
38    {
39        MyStruct s = gGlobals.pStruct.get();
40        outputBuffer[tid.x] = uint(s.position.x);
41        MyStruct s1 = gGlobals.pStruct[3];
42        outputBuffer[tid.x + 1] = uint(s1.position.x);
43    }
44}