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.2 KiB38 linesraw
1//TEST:SIMPLE(filecheck=SPIRV):-stage compute -entry computeMain -target spirv
2
3// coherent CoopVec operations crash the Nvidia driver.
4//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -render-feature cooperative-vector -emit-spirv-directly
5
6// Ensure SPIRV emits coherent operations here
7// SPIRV: MakePointerVisible
8// SPIRV: MakePointerAvailable
9
10//TEST_INPUT: set inputBuffer = ubuffer(data=[1 2 3 4 5 6 7 8 9 10 11 12], stride=4);
11uniform int32_t* inputBuffer;
12
13//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0 0 0 0 0], stride=4);
14uniform int32_t* outputBuffer;
15
16// CHECK: 9
17// CHECK-NEXT: A
18// CHECK-NEXT: B
19// CHECK-NEXT: C
20// CHECK-NEXT: 1
21// CHECK-NEXT: 2
22// CHECK-NEXT: 3
23// CHECK-NEXT: 4
24
25[shader("compute")]
26[numthreads(1, 1, 1)]
27void computeMain()
28{
29    //// First half of input.
30    let a = coopVecLoadCoherent<4, int32_t>(inputBuffer, 0, MemoryScope::Device);
31    //// Second half of input.
32    let b = coopVecLoadCoherent<4, int32_t>(inputBuffer + 4, 4 * 4, MemoryScope::Device);
33    //// Store second half of input to first half of output buffer.
34    b.storeCoherent(outputBuffer, 0, MemoryScope::Device);
35    //// Store first half of input to second half of output buffer.
36    a.storeCoherent(outputBuffer, 4 * 4, MemoryScope::Device);
37}
38