yum-mirror/slang

Making it easier to work with shaders

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

Yong He[Metal] Fix global constant array emit. (#4392)33e81a031

master
579 B23 linesraw
1// static-const-array.slang
2
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
5//TEST(compute):COMPARE_COMPUTE_EX:-cpu -slang -compute -shaderobj
6
7//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out, name outputBuffer
8RWStructuredBuffer<int> outputBuffer;
9
10static const int kArray[] = { 16, 1, 32, 2 };
11
12int test(int val)
13{
14	return kArray[val];
15}
16
17[numthreads(4, 1, 1)]
18void computeMain(int3 tid : SV_DispatchThreadID)
19{
20	int inVal = tid.x;
21	int outVal = test(inVal);
22	outputBuffer[inVal] = outVal;
23}