summaryrefslogtreecommitdiffstats
path: root/tests/hlsl-intrinsic/vector-int.slang
blob: e165847a8858839cf9c6a0daba6d37345df82251 (plain)
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
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
//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;
       
    outputBuffer[idx] = t.x + t.y + t.z;
}