[require]
shader model >= 4.0


[srv 0]
size (buffer, 4)
0.0 1.0 2.0 3.0
4.0 5.0 6.0 7.0
8.0 9.0 10.0 11.0
12.0 13.0 14.0 15.0


[pixel shader]
float4 a;
Buffer<float4> buffer;
float4 b;

float4 main() : sv_target
{
    return float4(a.y, b.z, buffer[1].xw);
}

[test]
uniform 0 float4 100 200 300 400
uniform 4 float4 1000 2000 3000 4000
draw quad
probe (0, 0) rgba (200, 3000, 4, 7)


[pixel shader]
float4 a;
Buffer<float3> buffer;
float4 b;

float4 main() : sv_target
{
    return float4(b.w, buffer[2]);
}

[test]
uniform 0 float4 100 200 300 400
uniform 4 float4 1000 2000 3000 4000
draw quad
probe (0, 0) rgba (4000.0, 8.0, 9.0, 10.0)


[srv 0]
size (2d, 1, 1)
-1.0 -1.0 -1.0 -1.0

[sampler 0]
filter linear linear linear
address clamp clamp clamp

[srv 1]
size (buffer, 1)
1.0 2.0 3.0 4.0

[pixel shader]
Texture2D tex;
sampler sam;
Buffer<float4> buffer;

float4 main() : sv_target
{
    return float4(buffer[0].zw, tex.Sample(sam, float2(0, 0)).zw);
}

[test]
draw quad
probe (0, 0) rgba (3.0, 4.0, -1.0, -1.0)


[srv 0]
size (buffer, 4)
0.0 1.0 2.0 3.0
4.0 5.0 6.0 7.0
8.0 9.0 10.0 11.0
12.0 13.0 14.0 15.0


[pixel shader]
Buffer buffer;

float4 main() : sv_target
{
    return buffer.Load(1);
}

[test]
draw quad
probe (0, 0) rgba (4.0, 5.0, 6.0, 7.0)


[pixel shader]
Buffer buffer;

float4 main() : sv_target
{
    return buffer.Load(float2(2, 9999));
}

[test]
draw quad
probe (0, 0) rgba (8.0, 9.0, 10.0, 11.0)


[pixel shader fail]
Buffer buffer;
sampler sam;

float4 main() : sv_target
{
    return buffer.Sample(sam, 0);
}


[pixel shader fail]
Buffer buffer;

float4 main() : sv_target
{
    uint u1, u2;

    buffer.GetDimensions(u1, u2);
    return 0;
}


[pixel shader]
Buffer buf;
uniform int u;

float4 main() : sv_target
{
    return buf[u];
}

[test]
uniform 0 int 2
draw quad
probe (0, 0) rgba (8.0, 9.0, 10.0, 11.0)
uniform 0 int 0
draw quad
probe (0, 0) rgba (0.0, 1.0, 2.0, 3.0)


% Buffer doesn't have offset_dim or sample_index arguments allowed.
[pixel shader fail todo]
Buffer buffer;

float4 main() : sv_target
{
    // This test fails because the output status must be an l-value.
    buffer.Load(0, 0);
    return 0;
}

[pixel shader fail]
Buffer buffer;

float4 main() : sv_target
{
    uint u;

    // This test fails because there is no overload for an argument in-between the load index and
    // the output status.
    buffer.Load(0, 0, u);
    return 0;
}


[require]
shader model >= 5.0


[pixel shader todo]
Buffer buffer;

float4 main() : sv_target
{
    uint width;

    buffer.GetDimensions(width);
    return width;
}
[test]
todo(sm<6 | msl) draw quad
probe (0, 0) rgba (4.0, 4.0, 4.0, 4.0)

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

[srv 0]
format r32g32b32a32-float
size (buffer, 1)
-100.0 -1.0 1.0 100.0

[pixel shader]
Buffer<half4> t : register(t0);

float4 main() : sv_target
{
    return t[0];
}

[test]
draw quad
probe (0, 0) rgba(-100.0, -1.0, 1.0, 100.0)

[srv 0]
format r32g32b32a32-sint
size (buffer, 1)
-100 -1 1 100

[pixel shader]
Buffer<int16_t4> t : register(t0);

int4 main() : sv_target
{
    return t[0];
}

[test]
draw quad
probe (0, 0) i32(-100, -1, 1, 100)

[srv 0]
format r32g32b32a32-uint
size (buffer, 1)
0 1 10 100

[pixel shader]
Buffer<uint16_t4> t : register(t0);

uint4 main() : sv_target
{
    return t[0];
}

[test]
draw quad
probe (0, 0) u32(0, 1, 10, 100)
