summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/swizzles/matrix-swizzles.slang
blob: fb9f9238ffee809b9ac7c14eeca3eb5ebcb384e2 (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
34
// matrix-swizzle.slang

//TEST(compute):COMPARE_COMPUTE: -shaderobj

// Test that matrix swizzle works correctly
// Matrix swizzles can either be one or zero indexed
// Reference: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-per-component-math

int test(int val)
{
    float2x2 worldMatrix = float2x2(val + 0, val + 1, val + 2, val + 3);
    float2 tempVector1;
    float2 tempVector2;

    // TODO: make left-hand side matrix swizzles work
    tempVector1 = worldMatrix._m00_m11;
    tempVector2 = worldMatrix._12_21;

    // return tempMatrix[0][0] + tempMatrix[0][1] = val + 0 + val + 1
    return int(tempVector1.x + tempVector2.x);
}


//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;
    int inVal = tid;
    int outVal = test(inVal);
    outputBuffer[tid] = outVal;
}