% Partial assigments are possible if the cast is to a smaller type that fits
% in the destination variable's type.
[pixel shader todo fail(sm>=6)]
float4 a;

float4 main() : sv_target
{
    float4 p = {-1, -2, -3, -4};

    (float2) p = a.yz; // partial assignment to p.xy.
    return p;
}

[test]
uniform 0 float4 1 2 3 4
todo draw quad
probe (0, 0) rgba(2, 3, -3, -4)


[pixel shader todo]
float4 main() : sv_target
{
    float4 p = {-1, -2, -3, -4};

    (float) p = 1; // partial assignment to p.x.
    return p;
}

[test]
uniform 0 float4 1 2 3 4
todo(sm<6) draw quad
probe (0, 0) rgba(1, -2, -3, -4)


[pixel shader todo]
float4 main() : sv_target
{
    float p[5] = {-1, -2, -3, -4, -5};
    float r[2] = {1, 2};

    (float[2]) p = r; // partial assignment to p[0] and p[1]
    return float4(p[0], p[1], p[2], p[4]);
}

[test]
todo(sm<6) draw quad
probe (0, 0) rgba(1, 2, -3, -5)


[pixel shader]
float4 a;

float4 main() : sv_target
{
    float4 p = {-1, -2, -3, -4};

    (float2) p.yz = a.yz; // partial assignment to p.yz
    return p;
}

[test]
uniform 0 float4 1 2 3 4
draw quad
probe (0, 0) rgba(-1, 2, 3, -4)


[pixel shader fail(sm>=4) todo]
float4 main() : sv_target
{
    float4 p = {-1, -2, -3, -4};

    (int2) p = int2(1, 2);
    return p;
}


% Matrix partial assignment.
[pixel shader fail(sm>=6) todo]
float3x4 a;

float4 main() : sv_target
{
    float4x4 g = 0;

    (float2x3) g = a;
    return 1000000*g[0] + 10000*g[1] + 100*g[2] + g[3];
}

[test]
uniform 0 float4 1 5 9 0
uniform 4 float4 2 6 10 0
uniform 8 float4 3 7 11 0
uniform 12 float4 4 8 12 0
todo draw quad
probe (0, 0) rgba(1050000, 2060000, 3070000, 0)


% Multiple cast partial assigment.
[pixel shader fail(sm>=6) todo]
float4 main() : sv_target
{
    float4x4 g = 0;

    (float2x2)(float2x3)g = float4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
    return g._11_12_21_22;
}

[test]
todo draw quad
probe (0, 0) rgba(1, 2, 5, 6)


[pixel shader fail(sm>=4) todo]
float4 main() : sv_target
{
    float4 p = 0;

    (float2)(int4) p = float4(-1.1, -2.8, 3.7, 4.3);
    return p;
}

[test]
todo draw quad
probe (0, 0) rgba(-1.1, -2.8, 0, 0)


[pixel shader fail(sm>=4) todo]
float4 main() : sv_target
{
    float4 p = 0;

    (float2)(int3) p = float4(1, 2, 3, 4);
    return 0;
}


[pixel shader todo]
float4 main() : sv_target
{
    float p[4][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
    float r[2][2] = {10, 20, 30, 40};

    (float[2][2]) p = r;
    return float4(p[0][0], p[1][1], p[1][0], p[2][2]);
}

[test]
todo(sm<6) draw quad
probe (0, 0) rgba(10, 5, 40, 9)


% For some reason this acts as .z swizzle on the rhs.
[pixel shader todo fail(sm>=4)]
float4 main() : sv_target
{
    float2 a = 0;

    (int3)(float)a = float3(1.1, 2.1, 3.1);
    return a.xyxy;
}

[test]
todo(sm<6) draw quad
probe (0, 0) rgba(3, 0, 3, 0)
