yum-mirror/slang

Making it easier to work with shaders

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

Yong HeFix global value inlining for spirv_asm blocks. (#4339)5da06d43b

master
819 B22 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target spirv
2
3// Test that we can use intrinsics in global scope constant array, which causes
4// the spirv_asm to be inlined in global module scope.
5// Our global value inlining pass should be able to clean up the global scope spirv_asm
6// blocks and inlining them to use sites.
7
8// CHECK: %main = OpFunction
9// CHECK: OpStore
10
11static const uint staticArr[] = {
12    uint((((uint)round(saturate(1) * 255) << 24) | ((uint)round(saturate(0) * 255) << 16) | ((uint)round(saturate(0) * 255) << 8) | 0xff)),
13    uint((((uint)round(saturate(1) * 255) << 24) | ((uint)round(saturate(0) * 255) << 16) | ((uint)round(saturate(1) * 255) << 8) | 0xff))
14};
15
16RWStructuredBuffer<int> buffer;
17
18[numthreads(1,1,1)]
19void main(int i : SV_DispatchThreadID)
20{
21    buffer[0] = staticArr[i] + staticArr[1];
22}