yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyConvert more tests to use shader objects (#1659)2a5d5b323

master
966 B41 linesraw
1// groupshared.slang
2
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
5//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
6//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
7
8//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out, name=gBuffer
9RWStructuredBuffer<int> gBuffer;
10
11static const int A = 4;
12static const int B = 1;
13static const int THREAD_COUNT = A * B;
14
15groupshared int gA[THREAD_COUNT];
16int test(int val)
17{
18	gA[val] = val;
19	GroupMemoryBarrierWithGroupSync();
20	val = gA[val ^ 1];
21
22/* TODO: once function-scope `static` works
23	static groupshared int gB[THREAD_COUNT];
24
25	gB[val] = val;
26	GroupMemoryBarrierWithGroupSync();
27	val = gB[val ^ 2];
28*/
29
30	return val;
31}
32
33[numthreads(THREAD_COUNT, 1, 1)]
34void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
35{
36	uint tid = dispatchThreadID.x;
37
38	int val = int(tid);
39	val = test(val);
40	gBuffer[tid] = val;
41}