1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<int> outputBuffer;
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int idx = int(dispatchThreadID.x);
int3 a = { idx + 10, idx - 9, idx + 3};
int3 b = { idx * 2, idx * 3, idx * 10};
int3 t = { 0, 0, 0};
t += max(a, b);
t += min(a, b);
t += abs(a);
t += b % 5;
t += clamp(a, int3(10), int3(23));
// Swizzle
t += a.zyx;
// Swizzle from scalar
t += idx.xxx;
{
t += int3(a[idx % 3], a[0], b[2]);
}
// Writes
{
int3 v = int3(b[(idx + 1) % 3], b[(idx + 2) % 3], b[(idx + 3) % 3]);
v[1] += v[0];
v[idx & 1] += v[2];
t += v;
}
outputBuffer[idx] = t.x + t.y + t.z;
}
|