[require]
shader model >= 4.0
rt-vp-array-index

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

[vertex shader]
float4 main(in uint vertex_id : SV_VertexID, in uint instance_id : SV_InstanceID,
        out uint viewport : SV_ViewportArrayIndex) : SV_Position
{
    viewport = instance_id;
    switch (vertex_id)
    {
        case 0:
            return float4(-1, 1, 0, 1);
        case 1:
            return float4(3, 1, 0, 1);
        case 2:
            return float4(-1, -3, 0, 1);
        default:
            return float4(0, 0, 0, 0);
    }
}

[pixel shader]
float4 main(float4 p : SV_Position, uint viewport : SV_ViewportArrayIndex) : SV_Target
{
    return float4(viewport / 4.0, 0.0, 0.0, 1.0);
}

[test]
viewport 0 (  0.0,   0.0, 320.0, 240.0)
viewport 1 (320.0,   0.0, 320.0, 240.0)
viewport 2 (  0.0, 240.0, 320.0, 240.0)
viewport 3 (320.0, 240.0, 320.0, 240.0)
clear rtv 0 1.0 1.0 1.0 1.0
todo(glsl) draw triangle list 3 4
probe rtv 0 (160, 120) f32(0.0,  0.0, 0.0, 1.0)
probe rtv 0 (480, 120) f32(0.25, 0.0, 0.0, 1.0)
probe rtv 0 (160, 360) f32(0.5,  0.0, 0.0, 1.0)
probe rtv 0 (480, 360) f32(0.75, 0.0, 0.0, 1.0)
