Commit 75c703b4 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d11/tests: Add test for SV_ClipDistance.

parent 431aa327
......@@ -1267,12 +1267,13 @@ static void draw_quad_vs(unsigned int line, struct d3d11_test_context *context,
vs_code, vs_code_size, &context->input_layout);
ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
context->vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(quad), quad);
hr = ID3D11Device_CreateVertexShader(device, vs_code, vs_code_size, NULL, &context->vs);
ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
}
if (!context->vb)
context->vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(quad), quad);
ID3D11DeviceContext_IASetInputLayout(context->immediate_context, context->input_layout);
ID3D11DeviceContext_IASetPrimitiveTopology(context->immediate_context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
stride = sizeof(*quad);
......@@ -12116,13 +12117,6 @@ float4 main(const ps_in v) : SV_TARGET
0x0000000f, 0x0100086a, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
};
static const struct vec2 quad[] =
{
{-1.0f, -1.0f},
{-1.0f, 1.0f},
{ 1.0f, -1.0f},
{ 1.0f, 1.0f},
};
static const struct
{
float color[4];
......@@ -12172,7 +12166,6 @@ float4 main(const ps_in v) : SV_TARGET
vs_code, sizeof(vs_code), &test_context.input_layout);
ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
test_context.vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(quad), quad);
colors_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(colors), &colors);
index_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(index), NULL);
......@@ -22563,6 +22556,576 @@ static void test_format_compatibility(void)
ok(!refcount, "Device has %u references left.\n", refcount);
}
static void check_clip_distance(struct d3d11_test_context *test_context, ID3D11Buffer *vb)
{
static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
struct vertex
{
float clip_distance0;
float clip_distance1;
};
ID3D11DeviceContext *context = test_context->immediate_context;
struct resource_readback rb;
struct vertex vertices[4];
unsigned int i;
RECT rect;
for (i = 0; i < ARRAY_SIZE(vertices); ++i)
vertices[i].clip_distance0 = 1.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context->backbuffer_rtv, white);
ID3D11DeviceContext_Draw(context, 4, 0);
check_texture_color(test_context->backbuffer, 0xff00ff00, 1);
for (i = 0; i < ARRAY_SIZE(vertices); ++i)
vertices[i].clip_distance0 = 0.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context->backbuffer_rtv, white);
ID3D11DeviceContext_Draw(context, 4, 0);
check_texture_color(test_context->backbuffer, 0xff00ff00, 1);
for (i = 0; i < ARRAY_SIZE(vertices); ++i)
vertices[i].clip_distance0 = -1.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context->backbuffer_rtv, white);
ID3D11DeviceContext_Draw(context, 4, 0);
check_texture_color(test_context->backbuffer, 0xffffffff, 1);
for (i = 0; i < ARRAY_SIZE(vertices); ++i)
vertices[i].clip_distance0 = i < 2 ? 1.0f : -1.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context->backbuffer_rtv, white);
ID3D11DeviceContext_Draw(context, 4, 0);
get_texture_readback(test_context->backbuffer, 0, &rb);
SetRect(&rect, 0, 0, 320, 480);
check_readback_data_color(&rb, &rect, 0xff00ff00, 1);
SetRect(&rect, 320, 0, 320, 480);
check_readback_data_color(&rb, &rect, 0xffffffff, 1);
release_resource_readback(&rb);
for (i = 0; i < ARRAY_SIZE(vertices); ++i)
vertices[i].clip_distance0 = i % 2 ? 1.0f : -1.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context->backbuffer_rtv, white);
ID3D11DeviceContext_Draw(context, 4, 0);
get_texture_readback(test_context->backbuffer, 0, &rb);
SetRect(&rect, 0, 0, 640, 240);
check_readback_data_color(&rb, &rect, 0xff00ff00, 1);
SetRect(&rect, 0, 240, 640, 240);
check_readback_data_color(&rb, &rect, 0xffffffff, 1);
release_resource_readback(&rb);
}
static void test_clip_distance(void)
{
struct d3d11_test_context test_context;
ID3D11Buffer *vs_cb, *tess_cb, *gs_cb;
D3D_FEATURE_LEVEL feature_level;
ID3D11DomainShader *ds = NULL;
ID3D11DeviceContext *context;
struct resource_readback rb;
unsigned int offset, stride;
ID3D11HullShader *hs = NULL;
ID3D11GeometryShader *gs;
ID3D11Device *device;
ID3D11Buffer *vb;
unsigned int i;
HRESULT hr;
RECT rect;
static const DWORD vs_code[] =
{
#if 0
bool use_constant;
float clip_distance;
struct input
{
float4 position : POSITION;
float distance0 : CLIP_DISTANCE0;
float distance1 : CLIP_DISTANCE1;
};
struct vertex
{
float4 position : SV_POSITION;
float user_clip : CLIP_DISTANCE;
float clip : SV_ClipDistance;
};
void main(input vin, out vertex vertex)
{
vertex.position = vin.position;
vertex.user_clip = vin.distance0;
vertex.clip = vin.distance0;
if (use_constant)
vertex.clip = clip_distance;
}
#endif
0x43425844, 0x09dfef58, 0x88570f2e, 0x1ebcf953, 0x9f97e22a, 0x00000001, 0x000001dc, 0x00000003,
0x0000002c, 0x0000009c, 0x00000120, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
0x00000003, 0x00000001, 0x00000101, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
0x00000001, 0x49534f50, 0x4e4f4954, 0x494c4300, 0x49445f50, 0x4e415453, 0xab004543, 0x4e47534f,
0x0000007c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a,
0x00000000, 0x00000002, 0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49,
0x50494c43, 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065,
0x52444853, 0x000000b4, 0x00010040, 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001,
0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x04000067, 0x001020f2,
0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067, 0x00102012, 0x00000002,
0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102012,
0x00000001, 0x0010100a, 0x00000001, 0x0b000037, 0x00102012, 0x00000002, 0x0020800a, 0x00000000,
0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0010100a, 0x00000001, 0x0100003e,
};
static const DWORD vs_multiple_code[] =
{
#if 0
bool use_constant;
float clip_distance0;
float clip_distance1;
struct input
{
float4 position : POSITION;
float distance0 : CLIP_DISTANCE0;
float distance1 : CLIP_DISTANCE1;
};
struct vertex
{
float4 position : SV_POSITION;
float user_clip : CLIP_DISTANCE;
float2 clip : SV_ClipDistance;
};
void main(input vin, out vertex vertex)
{
vertex.position = vin.position;
vertex.user_clip = vin.distance0;
vertex.clip.x = vin.distance0;
if (use_constant)
vertex.clip.x = clip_distance0;
vertex.clip.y = vin.distance1;
if (use_constant)
vertex.clip.y = clip_distance1;
}
#endif
0x43425844, 0xef5cc236, 0xe2fbfa69, 0x560b6591, 0x23037999, 0x00000001, 0x00000214, 0x00000003,
0x0000002c, 0x0000009c, 0x00000120, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000,
0x00000003, 0x00000001, 0x00000101, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
0x00000101, 0x49534f50, 0x4e4f4954, 0x494c4300, 0x49445f50, 0x4e415453, 0xab004543, 0x4e47534f,
0x0000007c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a,
0x00000000, 0x00000002, 0x00000003, 0x00000002, 0x00000c03, 0x505f5653, 0x5449534f, 0x004e4f49,
0x50494c43, 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065,
0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059, 0x00208e46, 0x00000000, 0x00000001,
0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x0300005f, 0x00101012,
0x00000002, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001,
0x04000067, 0x00102032, 0x00000002, 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46,
0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010100a, 0x00000001, 0x0b000037, 0x00102012,
0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0010100a,
0x00000001, 0x0b000037, 0x00102022, 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020802a,
0x00000000, 0x00000000, 0x0010100a, 0x00000002, 0x0100003e,
};
#if 0
bool use_constant;
float clip_distance0;
float clip_distance1;
float tessellation_factor;
struct vertex
{
float4 position : SV_POSITION;
float user_clip : CLIP_DISTANCE;
float clip : SV_ClipDistance;
};
struct patch_constant_data
{
float edges[4] : SV_TessFactor;
float inside[2] : SV_InsideTessFactor;
};
patch_constant_data patch_constant()
{
patch_constant_data output;
output.edges[0] = tessellation_factor;
output.edges[1] = tessellation_factor;
output.edges[2] = tessellation_factor;
output.edges[3] = tessellation_factor;
output.inside[0] = tessellation_factor;
output.inside[1] = tessellation_factor;
return output;
}
[domain("quad")]
[outputcontrolpoints(4)]
[outputtopology("triangle_cw")]
[partitioning("pow2")]
[patchconstantfunc("patch_constant")]
vertex hs_main(InputPatch<vertex, 4> input,
uint i : SV_OutputControlPointID)
{
vertex o;
o.position = input[i].position;
o.user_clip = input[i].user_clip;
o.clip = input[i].user_clip;
return o;
}
float4 interpolate_vec(float4 a, float4 b, float4 c, float4 d, float2 tess_coord)
{
float4 e = lerp(a, b, tess_coord.x);
float4 f = lerp(c, d, tess_coord.x);
return lerp(e, f, tess_coord.y);
}
float interpolate(float a, float b, float c, float d, float2 tess_coord)
{
float e = lerp(a, b, tess_coord.x);
float f = lerp(c, d, tess_coord.x);
return lerp(e, f, tess_coord.y);
}
[domain("quad")]
vertex ds_main(patch_constant_data input,
float2 tess_coord : SV_DomainLocation,
const OutputPatch<vertex, 4> patch)
{
vertex output;
output.position = interpolate_vec(patch[0].position, patch[1].position,
patch[2].position, patch[3].position, tess_coord);
output.user_clip = interpolate(patch[0].user_clip, patch[1].user_clip,
patch[2].user_clip, patch[3].user_clip, tess_coord);
output.clip = interpolate(patch[0].clip, patch[1].clip,
patch[2].clip, patch[3].clip, tess_coord);
if (use_constant)
output.clip = clip_distance0;
return output;
}
#endif
static const DWORD hs_code[] =
{
0x43425844, 0x5a6d7564, 0x5f30a6c9, 0x2cf3b848, 0x5b4c6dca, 0x00000001, 0x00000414, 0x00000004,
0x00000030, 0x000000b4, 0x00000138, 0x000001fc, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008,
0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000,
0x00000000, 0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003,
0x00000002, 0x00000001, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154,
0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x4e47534f, 0x0000007c, 0x00000003,
0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c,
0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000, 0x00000002,
0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f,
0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x47534350, 0x000000bc,
0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000e01,
0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000e01, 0x00000098, 0x00000002,
0x0000000b, 0x00000003, 0x00000002, 0x00000e01, 0x00000098, 0x00000003, 0x0000000b, 0x00000003,
0x00000003, 0x00000e01, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000e01,
0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000e01, 0x545f5653, 0x46737365,
0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x58454853,
0x00000210, 0x00030050, 0x00000084, 0x01000071, 0x01002093, 0x01002094, 0x01001895, 0x01001096,
0x01001897, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x01000072, 0x0200005f,
0x00016000, 0x0400005f, 0x002010f2, 0x00000004, 0x00000000, 0x0400005f, 0x00201012, 0x00000004,
0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x00102012, 0x00000001, 0x03000065,
0x00102012, 0x00000002, 0x02000068, 0x00000001, 0x04000036, 0x00100012, 0x00000000, 0x00016001,
0x07000036, 0x001020f2, 0x00000000, 0x00a01e46, 0x0010000a, 0x00000000, 0x00000000, 0x07000036,
0x00102012, 0x00000001, 0x00a0100a, 0x0010000a, 0x00000000, 0x00000001, 0x07000036, 0x00102012,
0x00000002, 0x00a0100a, 0x0010000a, 0x00000000, 0x00000001, 0x0100003e, 0x01000073, 0x02000099,
0x00000004, 0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000000, 0x0000000b, 0x04000067,
0x00102012, 0x00000001, 0x0000000c, 0x04000067, 0x00102012, 0x00000002, 0x0000000d, 0x04000067,
0x00102012, 0x00000003, 0x0000000e, 0x02000068, 0x00000001, 0x0400005b, 0x00102012, 0x00000000,
0x00000004, 0x04000036, 0x00100012, 0x00000000, 0x0001700a, 0x07000036, 0x00902012, 0x0010000a,
0x00000000, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e, 0x01000073, 0x02000099, 0x00000002,
0x0200005f, 0x00017000, 0x04000067, 0x00102012, 0x00000004, 0x0000000f, 0x04000067, 0x00102012,
0x00000005, 0x00000010, 0x02000068, 0x00000001, 0x0400005b, 0x00102012, 0x00000004, 0x00000002,
0x04000036, 0x00100012, 0x00000000, 0x0001700a, 0x08000036, 0x00d02012, 0x00000004, 0x0010000a,
0x00000000, 0x0020803a, 0x00000000, 0x00000000, 0x0100003e,
};
static const DWORD ds_code[] =
{
0x43425844, 0xc54dc020, 0x063a9622, 0x6f649eb9, 0xceb1dd36, 0x00000001, 0x0000054c, 0x00000004,
0x00000030, 0x000000b4, 0x00000178, 0x000001fc, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008,
0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000,
0x00000000, 0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003,
0x00000002, 0x00000101, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154,
0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x47534350, 0x000000bc, 0x00000006,
0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000, 0x00000001, 0x00000098,
0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000001, 0x00000098, 0x00000002, 0x0000000b,
0x00000003, 0x00000002, 0x00000001, 0x00000098, 0x00000003, 0x0000000b, 0x00000003, 0x00000003,
0x00000001, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004, 0x00000001, 0x000000a6,
0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000001, 0x545f5653, 0x46737365, 0x6f746361,
0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072, 0x4e47534f, 0x0000007c,
0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000,
0x00000002, 0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43,
0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x58454853,
0x00000348, 0x00040050, 0x000000d2, 0x01002093, 0x01001895, 0x0100086a, 0x04000059, 0x00208e46,
0x00000000, 0x00000001, 0x0200005f, 0x0001c032, 0x0400005f, 0x002190f2, 0x00000004, 0x00000000,
0x0400005f, 0x00219012, 0x00000004, 0x00000001, 0x0400005f, 0x00219012, 0x00000004, 0x00000002,
0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067,
0x00102012, 0x00000002, 0x00000002, 0x02000068, 0x00000002, 0x0a000000, 0x001000f2, 0x00000000,
0x80219e46, 0x00000041, 0x00000002, 0x00000000, 0x00219e46, 0x00000003, 0x00000000, 0x09000032,
0x001000f2, 0x00000000, 0x0001c006, 0x00100e46, 0x00000000, 0x00219e46, 0x00000002, 0x00000000,
0x0a000000, 0x001000f2, 0x00000001, 0x80219e46, 0x00000041, 0x00000000, 0x00000000, 0x00219e46,
0x00000001, 0x00000000, 0x09000032, 0x001000f2, 0x00000001, 0x0001c006, 0x00100e46, 0x00000001,
0x00219e46, 0x00000000, 0x00000000, 0x08000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
0x80100e46, 0x00000041, 0x00000001, 0x08000032, 0x001020f2, 0x00000000, 0x0001c556, 0x00100e46,
0x00000000, 0x00100e46, 0x00000001, 0x0a000000, 0x00100012, 0x00000000, 0x8021900a, 0x00000041,
0x00000002, 0x00000001, 0x0021900a, 0x00000003, 0x00000001, 0x09000032, 0x00100012, 0x00000000,
0x0001c00a, 0x0010000a, 0x00000000, 0x0021900a, 0x00000002, 0x00000001, 0x0a000000, 0x00100022,
0x00000000, 0x8021900a, 0x00000041, 0x00000000, 0x00000001, 0x0021900a, 0x00000001, 0x00000001,
0x09000032, 0x00100022, 0x00000000, 0x0001c00a, 0x0010001a, 0x00000000, 0x0021900a, 0x00000000,
0x00000001, 0x08000000, 0x00100012, 0x00000000, 0x8010001a, 0x00000041, 0x00000000, 0x0010000a,
0x00000000, 0x08000032, 0x00102012, 0x00000001, 0x0001c01a, 0x0010000a, 0x00000000, 0x0010001a,
0x00000000, 0x0a000000, 0x00100012, 0x00000000, 0x8021900a, 0x00000041, 0x00000002, 0x00000002,
0x0021900a, 0x00000003, 0x00000002, 0x09000032, 0x00100012, 0x00000000, 0x0001c00a, 0x0010000a,
0x00000000, 0x0021900a, 0x00000002, 0x00000002, 0x0a000000, 0x00100022, 0x00000000, 0x8021900a,
0x00000041, 0x00000000, 0x00000002, 0x0021900a, 0x00000001, 0x00000002, 0x09000032, 0x00100022,
0x00000000, 0x0001c00a, 0x0010001a, 0x00000000, 0x0021900a, 0x00000000, 0x00000002, 0x08000000,
0x00100012, 0x00000000, 0x8010001a, 0x00000041, 0x00000000, 0x0010000a, 0x00000000, 0x08000032,
0x00100012, 0x00000000, 0x0001c01a, 0x0010000a, 0x00000000, 0x0010001a, 0x00000000, 0x0b000037,
0x00102012, 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
0x0010000a, 0x00000000, 0x0100003e,
};
static const DWORD gs_code[] =
{
#if 0
bool use_constant;
float clip_distance;
struct vertex
{
float4 position : SV_POSITION;
float user_clip : CLIP_DISTANCE;
float clip : SV_ClipDistance;
};
[maxvertexcount(3)]
void main(triangle vertex input[3], inout TriangleStream<vertex> output)
{
vertex o;
o = input[0];
o.clip = input[0].user_clip;
if (use_constant)
o.clip = clip_distance;
output.Append(o);
o = input[1];
o.clip = input[1].user_clip;
if (use_constant)
o.clip = clip_distance;
output.Append(o);
o = input[2];
o.clip = input[2].user_clip;
if (use_constant)
o.clip = clip_distance;
output.Append(o);
}
#endif
0x43425844, 0x9b0823e9, 0xab3ed100, 0xba0ff618, 0x1bbd1cb8, 0x00000001, 0x00000338, 0x00000003,
0x0000002c, 0x000000b0, 0x00000134, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008, 0x00000050,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000, 0x00000000,
0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003, 0x00000002,
0x00000001, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045,
0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x4e47534f, 0x0000007c, 0x00000003, 0x00000008,
0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000, 0x00000002, 0x00000003,
0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154,
0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x52444853, 0x000001fc, 0x00020040,
0x0000007f, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x05000061, 0x002010f2, 0x00000003,
0x00000000, 0x00000001, 0x0400005f, 0x00201012, 0x00000003, 0x00000001, 0x0400005f, 0x00201012,
0x00000003, 0x00000002, 0x02000068, 0x00000001, 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2,
0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067, 0x00102012, 0x00000002,
0x00000002, 0x0200005e, 0x00000003, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000000,
0x00000000, 0x06000036, 0x00102012, 0x00000001, 0x0020100a, 0x00000000, 0x00000001, 0x0c000037,
0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
0x0020100a, 0x00000000, 0x00000001, 0x05000036, 0x00102012, 0x00000002, 0x0010000a, 0x00000000,
0x01000013, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000001, 0x00000000, 0x06000036,
0x00102012, 0x00000001, 0x0020100a, 0x00000001, 0x00000001, 0x0c000037, 0x00100012, 0x00000000,
0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0020100a, 0x00000001,
0x00000001, 0x05000036, 0x00102012, 0x00000002, 0x0010000a, 0x00000000, 0x01000013, 0x06000036,
0x001020f2, 0x00000000, 0x00201e46, 0x00000002, 0x00000000, 0x06000036, 0x00102012, 0x00000001,
0x0020100a, 0x00000002, 0x00000001, 0x0c000037, 0x00100012, 0x00000000, 0x0020800a, 0x00000000,
0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0020100a, 0x00000002, 0x00000001, 0x05000036,
0x00102012, 0x00000002, 0x0010000a, 0x00000000, 0x01000013, 0x0100003e,
};
static const D3D11_INPUT_ELEMENT_DESC layout_desc[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"CLIP_DISTANCE", 0, DXGI_FORMAT_R32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"CLIP_DISTANCE", 1, DXGI_FORMAT_R32_FLOAT, 1, 4, D3D11_INPUT_PER_VERTEX_DATA, 0},
};
struct
{
float clip_distance0;
float clip_distance1;
}
vertices[] =
{
{1.0f, 1.0f},
{1.0f, 1.0f},
{1.0f, 1.0f},
{1.0f, 1.0f},
};
static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
static const struct vec4 green = {0.0f, 1.0f, 0.0f, 1.0f};
struct
{
BOOL use_constant;
float clip_distance0;
float clip_distance1;
float tessellation_factor;
} cb_data;
if (!init_test_context(&test_context, NULL))
return;
device = test_context.device;
context = test_context.immediate_context;
feature_level = ID3D11Device_GetFeatureLevel(device);
hr = ID3D11Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc),
vs_code, sizeof(vs_code), &test_context.input_layout);
ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(vertices), vertices);
stride = sizeof(*vertices);
offset = 0;
ID3D11DeviceContext_IASetVertexBuffers(context, 1, 1, &vb, &stride, &offset);
hr = ID3D11Device_CreateVertexShader(device, vs_code, sizeof(vs_code), NULL, &test_context.vs);
ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
memset(&cb_data, 0, sizeof(cb_data));
cb_data.tessellation_factor = 1.0f;
vs_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(cb_data), &cb_data);
ID3D11DeviceContext_VSSetConstantBuffers(context, 0, 1, &vs_cb);
tess_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(cb_data), &cb_data);
ID3D11DeviceContext_HSSetConstantBuffers(context, 0, 1, &tess_cb);
ID3D11DeviceContext_DSSetConstantBuffers(context, 0, 1, &tess_cb);
gs_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(cb_data), &cb_data);
ID3D11DeviceContext_GSSetConstantBuffers(context, 0, 1, &gs_cb);
/* vertex shader */
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
draw_color_quad(&test_context, &green);
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
check_clip_distance(&test_context, vb);
cb_data.use_constant = TRUE;
cb_data.clip_distance0 = -1.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vs_cb, 0, NULL, &cb_data, 0, 0);
/* tessellation shaders */
if (feature_level >= D3D_FEATURE_LEVEL_11_0)
{
ID3D11DeviceContext_IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST);
hr = ID3D11Device_CreateHullShader(device, hs_code, sizeof(hs_code), NULL, &hs);
ok(SUCCEEDED(hr), "Failed to create hull shader, hr %#x.\n", hr);
ID3D11DeviceContext_HSSetShader(context, hs, NULL, 0);
hr = ID3D11Device_CreateDomainShader(device, ds_code, sizeof(ds_code), NULL, &ds);
ok(SUCCEEDED(hr), "Failed to create domain shader, hr %#x.\n", hr);
ID3D11DeviceContext_DSSetShader(context, ds, NULL, 0);
check_clip_distance(&test_context, vb);
cb_data.use_constant = FALSE;
cb_data.tessellation_factor = 2.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)tess_cb, 0, NULL, &cb_data, 0, 0);
for (i = 0; i < ARRAY_SIZE(vertices); ++i)
vertices[i].clip_distance0 = 1.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
ID3D11DeviceContext_Draw(context, 4, 0);
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
cb_data.use_constant = TRUE;
cb_data.clip_distance0 = -1.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)tess_cb, 0, NULL, &cb_data, 0, 0);
}
else
{
skip("Tessellation shaders are not supported.\n");
}
/* geometry shader */
hr = ID3D11Device_CreateGeometryShader(device, gs_code, sizeof(gs_code), NULL, &gs);
ok(SUCCEEDED(hr), "Failed to create geometry shader, hr %#x.\n", hr);
ID3D11DeviceContext_GSSetShader(context, gs, NULL, 0);
check_clip_distance(&test_context, vb);
cb_data.use_constant = TRUE;
cb_data.clip_distance0 = 1.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)gs_cb, 0, NULL, &cb_data, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
ID3D11DeviceContext_Draw(context, 4, 0);
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
/* multiple clip distances */
ID3D11DeviceContext_HSSetShader(context, NULL, NULL, 0);
ID3D11DeviceContext_DSSetShader(context, NULL, NULL, 0);
ID3D11DeviceContext_GSSetShader(context, NULL, NULL, 0);
ID3D11VertexShader_Release(test_context.vs);
hr = ID3D11Device_CreateVertexShader(device, vs_multiple_code, sizeof(vs_multiple_code),
NULL, &test_context.vs);
ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
cb_data.use_constant = FALSE;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vs_cb, 0, NULL, &cb_data, 0, 0);
for (i = 0; i < ARRAY_SIZE(vertices); ++i)
vertices[i].clip_distance0 = 1.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
draw_color_quad(&test_context, &green);
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
for (i = 0; i < ARRAY_SIZE(vertices); ++i)
{
vertices[i].clip_distance0 = i < 2 ? 1.0f : -1.0f;
vertices[i].clip_distance1 = i % 2 ? 1.0f : -1.0f;
}
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
draw_color_quad(&test_context, &green);
get_texture_readback(test_context.backbuffer, 0, &rb);
SetRect(&rect, 0, 0, 320, 240);
check_readback_data_color(&rb, &rect, 0xff00ff00, 1);
SetRect(&rect, 0, 240, 320, 480);
check_readback_data_color(&rb, &rect, 0xffffffff, 1);
SetRect(&rect, 320, 0, 640, 480);
check_readback_data_color(&rb, &rect, 0xffffffff, 1);
release_resource_readback(&rb);
cb_data.use_constant = TRUE;
cb_data.clip_distance0 = 0.0f;
cb_data.clip_distance1 = 0.0f;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vs_cb, 0, NULL, &cb_data, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
draw_color_quad(&test_context, &green);
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
if (hs)
ID3D11HullShader_Release(hs);
if (ds)
ID3D11DomainShader_Release(ds);
ID3D11GeometryShader_Release(gs);
ID3D11Buffer_Release(vb);
ID3D11Buffer_Release(vs_cb);
ID3D11Buffer_Release(tess_cb);
ID3D11Buffer_Release(gs_cb);
release_test_context(&test_context);
}
START_TEST(d3d11)
{
test_create_device();
......@@ -22670,4 +23233,5 @@ START_TEST(d3d11)
test_early_depth_stencil();
test_conservative_depth_output();
test_format_compatibility();
test_clip_distance();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment