yum-mirror/slang

Making it easier to work with shaders

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

16-Bit-DogAddition of `Load`/`Store` coherent operations (#8395)1e0908bd7

master
1.1 KiB26 linesraw
1//TEST:SIMPLE(filecheck=SPIRV):-stage compute -entry computeMain -target spirv -capability vk_mem_model
2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -emit-spirv-directly -capability vk_mem_model
3
4// Tests if we pass-through and handle groupshared address space pointers correctly.
5// Ensure SPIRV emits coherent operations here
6// SPIRV: MakePointerAvailable|NonPrivatePointer
7// SPIRV: MakePointerVisible|NonPrivatePointer
8
9// CHECK: 2
10// CHECK-NEXT: 1
11// CHECK-NEXT: 0
12
13//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=outputBuffer
14RWStructuredBuffer<int> outputBuffer;
15
16groupshared int[32] shared;
17
18#define THREAD_GROUP_SIZE 3
19[numthreads(THREAD_GROUP_SIZE, 1, 1)]
20void computeMain(uint3 group_thread_id: SV_GroupThreadID)
21{
22    Ptr<int, Access::ReadWrite, AddressSpace::GroupShared> ptr = __getAddress(shared[0]);
23    storeCoherent<4, MemoryScope::Workgroup>(ptr + group_thread_id.x, (int)group_thread_id.x);
24    AllMemoryBarrierWithGroupSync();
25    outputBuffer[group_thread_id.x] = loadCoherent<4, MemoryScope::Workgroup>(ptr + THREAD_GROUP_SIZE - group_thread_id.x - 1);
26}