% Unrolling edge cases.

[pixel shader]
float a : register(c0);

float4 main() : sv_target
{
    int i;
    if (a > 0)
    {
        [unroll]
        for (i = 0; i < 10; ++i);

        return float4(i, a, 2.0, 3.0);
    }

    return float4(0.0, a, 3.0, 4.0);
}

[test]
uniform 0 float 1
draw quad
probe (0,0) f32(10.0, 1.0, 2.0, 3.0)

[pixel shader]
float4 main() : sv_target
{
    int i;
    [unroll(4)]
    for (i = 0; i < 8; ++i);

    return float4(i, 0, 0, 0);
}

[test]
draw quad
probe (0,0) rgba(4.0, 0.0, 0.0, 0.0)

[pixel shader fail(sm<6)]
float4 main() : sv_target
{
    int i;
    [unroll]
    for (i = 0; i < 1024; ++i);

    return float4(i, 0, 0, 0);
}

[test]
draw quad
probe (0,0) rgba(1024.0, 0, 0, 0)

[pixel shader]
float4 main() : sv_target
{
    int i;
    [unroll(1337)]
    for (i = 0; i < 1337; ++i);

    return float4(i, 0, 0, 0);
}

[test]
draw quad
probe (0,0) rgba(1337.0, 0, 0, 0)

[pixel shader]
float4 main() : sv_target
{
    float i = 0;

    [unroll]
    for (;;)
    {
        if (((float4)1).w == 1) break;
        ++i;
    }
    return i;
}

[test]
draw quad
probe (0,0) rgba(0, 0, 0, 0)
