[require]
shader model >= 4.0

[input layout]
0 r32g32-float SV_POSITION
0 r32g32-float TEXCOORD 0
0 r32-float TEXCOORD 1
1 r32-uint TEXCOORD 2
1 r32-uint TEXCOORD 3
0 r32-float TEXCOORD 4

[vb 0]
-1.0 -1.0   3.0 5.0   5.0   7.0
-1.0  1.0   3.0 5.0   5.0   7.0
 1.0 -1.0   3.0 5.0   5.0   7.0
 1.0  1.0   3.0 5.0   5.0   7.0

[vb 1]
format r32-uint
2   6
2   6
2   6
2   6

[vertex shader]

struct vertex
{
    float4 position : SV_Position;
    float2 t0 : TEXCOORD0;
    nointerpolation float t1 : TEXCOORD1;
    uint t2 : TEXCOORD2;
    uint t3 : TEXCOORD3;
    float t4 : TEXCOORD4;
};

void main(in vertex vin, out vertex vout)
{
    vout = vin;
}

[pixel shader]

void main(float4 position : SV_Position, float2 t0 : TEXCOORD0,
        nointerpolation float t1 : TEXCOORD1, uint t2 : TEXCOORD2,
        uint t3 : TEXCOORD3, float t4 : TEXCOORD4, out float4 o : SV_Target)
{
    o.x = t0.y + t1;
    o.y = t2 + t3;
    o.z = t4;
    o.w = t0.x;
}

[test]
todo(msl & sm>=6) draw triangle strip 4
probe (0, 0) rgba (10.0, 8.0, 7.0, 3.0)

[input layout]
0 r32g32-float SV_POSITION
0 r32g32b32a32-float COLOR 0
0 r32g32b32a32-float COLOR 1
0 r32g32b32a32-float COLOR 2

[vb 0]
-1.0 -1.0   0.0 1.0 1.0 1.0  0.0 1.0 0.0 0.0   0.0 1.0 0.0 1.0
-1.0  1.0   0.0 1.0 1.0 1.0  0.0 1.0 0.0 0.0   0.0 1.0 0.0 1.0
 1.0 -1.0   0.0 1.0 1.0 1.0  0.0 1.0 0.0 0.0   0.0 1.0 0.0 1.0
 1.0  1.0   0.0 1.0 1.0 1.0  0.0 1.0 0.0 0.0   0.0 1.0 0.0 1.0

[vertex shader]
uint3 index;

struct vs_data
{
    float4 pos : SV_Position;
    float4 color[3] : COLOR;
};

void main(in struct vs_data vs_input, out struct vs_data vs_output)
{
    vs_output.pos = vs_input.pos;
    vs_output.color[0] = vs_input.color[index.x];
    vs_output.color[1] = vs_input.color[index.y];
    vs_output.color[2] = vs_input.color[index.z];
}

[pixel shader]
uint4 index;

struct ps_data
{
    float4 pos : SV_Position;
    float4 color[3] : COLOR;
};

float4 main(struct ps_data ps_input) : SV_Target
{
    return ps_input.color[index.w];
}

[test]
uniform 0 uint4 1 2 0 1
clear rtv 0 1.0 1.0 1.0 1.0
todo(msl & sm>=6) draw triangle strip 4
probe (0, 0) rgba(0.0, 1.0, 0.0, 1.0)

[require]
shader model >= 4.0

[input layout]
0 r32g32-float SV_POSITION
0 r32g32-float TEXCOORD 0
1 r32g32-uint TEXCOORD 1

[vb 0]
-1.0 -1.0 700.0 5.0
-1.0  1.0 700.0 5.0
 1.0 -1.0 700.0 5.0
 1.0  1.0 700.0 5.0

[vb 1]
format r32-uint
0x7fff 2
0x7fff 2
0x7fff 2
0x7fff 2

[vertex shader]
struct vertex
{
    float4 position : SV_Position;
    min16float2 t0 : TEXCOORD0;
    min16uint2 t1 : TEXCOORD1;
};

void main(in vertex vin, out vertex vout)
{
    vout = vin;
}

[pixel shader]
uniform min16float h;

float4 main(float4 position : SV_Position, min16float2 t0 : TEXCOORD0, min16uint2 t1 : TEXCOORD1) : SV_Target
{
    // Prevent float -> half -> float being optimised out by doing a half-precision operation.
    return float4(t0 - min16float2(h, h), t1);
}

[test]
uniform 0 uint 0
todo(glsl | msl) draw triangle strip 4
probe (0, 0) rgba(700.0, 5.0, 32767.0, 2.0)

[input layout]
0 r32g32-float SV_POSITION
1 r32g32-sint TEXCOORD 0

[vb 0]
-1.0 -1.0
-1.0  1.0
 1.0 -1.0
 1.0  1.0

[vb 1]
format r32-sint
-7000 -2
-7000 -2
-7000 -2
-7000 -2

[vertex shader]
struct vertex
{
    float4 position : SV_Position;
    min16int2 t0 : TEXCOORD0;
};

void main(in vertex vin, out vertex vout)
{
    vout = vin;
}

[pixel shader]
int4 main(float4 position : SV_Position, min16int2 t0 : TEXCOORD0) : SV_Target
{
    return int4(t0, 0, 0);
}

[rtv 0]
format r32g32b32a32-sint
size (2d, 640, 480)

[test]
todo(msl & sm>=6) draw triangle strip 4
todo(opengl) probe (0, 0) i32(-7000, -2, 0, 0)

[pixel shader]
uint4 main(float4 position : SV_Position, min16int2 t0 : TEXCOORD0) : SV_Target
{
    return uint4(t0, 0, 0);
}

[rtv 0]
format r32g32b32a32-uint
size (2d, 640, 480)

[test]
todo(msl & sm>=6) draw triangle strip 4
probe (0, 0) i32(-7000, -2, 0, 0)

[require]
shader model >= 6.2
native-16-bit

[input layout]
0 r32g32-float SV_POSITION
0 r32g32-float TEXCOORD 0
1 r32g32-uint TEXCOORD 1

[vb 0]
-1.0 -1.0 700.0 5.0
-1.0  1.0 700.0 5.0
 1.0 -1.0 700.0 5.0
 1.0  1.0 700.0 5.0

[vb 1]
format r32-uint
0x7fff 2
0x7fff 2
0x7fff 2
0x7fff 2

[vertex shader]
struct vertex
{
    float4 position : SV_Position;
    half2 t0 : TEXCOORD0;
    uint16_t2 t1 : TEXCOORD1;
};

void main(in vertex vin, out vertex vout)
{
    vout = vin;
}

[pixel shader]
uniform half h;

float4 main(float4 position : SV_Position, half2 t0 : TEXCOORD0, uint16_t2 t1 : TEXCOORD1) : SV_Target
{
    // Prevent float -> half -> float being optimised out by doing a half-precision operation.
    return float4(t0 - half2(h, h), t1);
}

[rtv 0]
format r32g32b32a32-float
size (2d, 640, 480)

[test]
uniform 0 uint 0
draw triangle strip 4
probe (0, 0) rgba(700.0, 5.0, 32767.0, 2.0)

[input layout]
0 r32g32-float SV_POSITION
1 r32g32-sint TEXCOORD 0

[vb 0]
-1.0 -1.0
-1.0  1.0
 1.0 -1.0
 1.0  1.0

[vb 1]
format r32-sint
-7000 -2
-7000 -2
-7000 -2
-7000 -2

[vertex shader]
struct vertex
{
    float4 position : SV_Position;
    int16_t2 t0 : TEXCOORD0;
};

void main(in vertex vin, out vertex vout)
{
    vout = vin;
}

[pixel shader]
int4 main(float4 position : SV_Position, int16_t2 t0 : TEXCOORD0) : SV_Target
{
    return int4(t0, 0, 0);
}

[rtv 0]
format r32g32b32a32-sint
size (2d, 640, 480)

[test]
draw triangle strip 4
probe (0, 0) i32(-7000, -2, 0, 0)

[pixel shader]
uint4 main(float4 position : SV_Position, int16_t2 t0 : TEXCOORD0) : SV_Target
{
    return uint4(t0, 0, 0);
}

[rtv 0]
format r32g32b32a32-uint
size (2d, 640, 480)

[test]
draw triangle strip 4
probe (0, 0) i32(-7000, -2, 0, 0)
