[PATCH 6/7] d3d11/tests: Introduce draw_color_quad_vs() helper function.
Józef Kucia
jkucia at codeweavers.com
Wed Apr 25 04:23:52 CDT 2018
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d11/tests/d3d11.c | 120 +++++++++++++++++++++++------------------------
1 file changed, 58 insertions(+), 62 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 4f6664d918ca..8279e7b105cf 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -1273,6 +1273,7 @@ struct d3d11_test_context
ID3D11InputLayout *input_layout;
ID3D11VertexShader *vs;
+ const DWORD *vs_code;
ID3D11Buffer *vs_cb;
ID3D11Buffer *vb;
@@ -1351,13 +1352,39 @@ static void release_test_context_(unsigned int line, struct d3d11_test_context *
ok_(__FILE__, line)(!ref, "Device has %u references left.\n", ref);
}
-static void draw_quad_vs(unsigned int line, struct d3d11_test_context *context,
+#define draw_quad(context) draw_quad_vs_(__LINE__, context, NULL, 0)
+#define draw_quad_vs(a, b, c) draw_quad_vs_(__LINE__, a, b, c)
+static void draw_quad_vs_(unsigned int line, struct d3d11_test_context *context,
const DWORD *vs_code, size_t vs_code_size)
{
static const D3D11_INPUT_ELEMENT_DESC default_layout_desc[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
};
+ static const DWORD default_vs_code[] =
+ {
+#if 0
+ float4 main(float4 position : POSITION) : SV_POSITION
+ {
+ return position;
+ }
+#endif
+ 0x43425844, 0x4fb19b86, 0x955fa240, 0x1a630688, 0x24eb9db4, 0x00000001, 0x000001e0, 0x00000006,
+ 0x00000038, 0x00000084, 0x000000d0, 0x00000134, 0x00000178, 0x000001ac, 0x53414e58, 0x00000044,
+ 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
+ 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x02000001, 0xc00f0000, 0x80e40000,
+ 0x0000ffff, 0x50414e58, 0x00000044, 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000,
+ 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000,
+ 0x02000001, 0xc00f0000, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x0000005c, 0x0000005c, 0xfffe0200,
+ 0x00000034, 0x00000028, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240001, 0x00000000,
+ 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x04000004, 0xc0030000, 0x90ff0000, 0xa0e40000,
+ 0x90e40000, 0x02000001, 0xc00c0000, 0x90e40000, 0x0000ffff, 0x52444853, 0x0000003c, 0x00010040,
+ 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
+ 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x0000002c,
+ 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
+ 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
+ };
static const struct vec3 quad[] =
{
{-1.0f, -1.0f, 0.0f},
@@ -1370,14 +1397,28 @@ static void draw_quad_vs(unsigned int line, struct d3d11_test_context *context,
unsigned int stride, offset;
HRESULT hr;
+ if (!vs_code)
+ {
+ vs_code = default_vs_code;
+ vs_code_size = sizeof(default_vs_code);
+ }
+
if (!context->input_layout)
{
hr = ID3D11Device_CreateInputLayout(device, default_layout_desc, ARRAY_SIZE(default_layout_desc),
vs_code, vs_code_size, &context->input_layout);
ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
+ }
+
+ if (context->vs_code != vs_code)
+ {
+ if (context->vs)
+ ID3D11VertexShader_Release(context->vs);
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);
+ ok_(__FILE__, line)(hr == S_OK, "Failed to create vertex shader, hr %#x.\n", hr);
+
+ context->vs_code = vs_code;
}
if (!context->vb)
@@ -1393,37 +1434,6 @@ static void draw_quad_vs(unsigned int line, struct d3d11_test_context *context,
ID3D11DeviceContext_Draw(context->immediate_context, 4, 0);
}
-#define draw_quad(context) draw_quad_(__LINE__, context)
-static void draw_quad_(unsigned int line, struct d3d11_test_context *context)
-{
- static const DWORD vs_code[] =
- {
-#if 0
- float4 main(float4 position : POSITION) : SV_POSITION
- {
- return position;
- }
-#endif
- 0x43425844, 0x4fb19b86, 0x955fa240, 0x1a630688, 0x24eb9db4, 0x00000001, 0x000001e0, 0x00000006,
- 0x00000038, 0x00000084, 0x000000d0, 0x00000134, 0x00000178, 0x000001ac, 0x53414e58, 0x00000044,
- 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
- 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x02000001, 0xc00f0000, 0x80e40000,
- 0x0000ffff, 0x50414e58, 0x00000044, 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000,
- 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000,
- 0x02000001, 0xc00f0000, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x0000005c, 0x0000005c, 0xfffe0200,
- 0x00000034, 0x00000028, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240001, 0x00000000,
- 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x04000004, 0xc0030000, 0x90ff0000, 0xa0e40000,
- 0x90e40000, 0x02000001, 0xc00c0000, 0x90e40000, 0x0000ffff, 0x52444853, 0x0000003c, 0x00010040,
- 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
- 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x0000002c,
- 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
- 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
- 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
- };
-
- draw_quad_vs(__LINE__, context, vs_code, sizeof(vs_code));
-}
-
#define draw_quad_z(context, z) draw_quad_z_(__LINE__, context, z)
static void draw_quad_z_(unsigned int line, struct d3d11_test_context *context, float z)
{
@@ -1457,7 +1467,7 @@ static void draw_quad_z_(unsigned int line, struct d3d11_test_context *context,
(ID3D11Resource *)context->vs_cb, 0, NULL, &data, 0, 0);
ID3D11DeviceContext_VSSetConstantBuffers(context->immediate_context, 0, 1, &context->vs_cb);
- draw_quad_vs(__LINE__, context, vs_code, sizeof(vs_code));
+ draw_quad_vs_(__LINE__, context, vs_code, sizeof(vs_code));
}
static void set_quad_color(struct d3d11_test_context *context, const struct vec4 *color)
@@ -1466,8 +1476,10 @@ static void set_quad_color(struct d3d11_test_context *context, const struct vec4
(ID3D11Resource *)context->ps_cb, 0, NULL, color, 0, 0);
}
-#define draw_color_quad(context, color) draw_color_quad_(__LINE__, context, color)
-static void draw_color_quad_(unsigned int line, struct d3d11_test_context *context, const struct vec4 *color)
+#define draw_color_quad(a, b) draw_color_quad_(__LINE__, a, b, NULL, 0)
+#define draw_color_quad_vs(a, b, c, d) draw_color_quad_(__LINE__, a, b, c, d)
+static void draw_color_quad_(unsigned int line, struct d3d11_test_context *context,
+ const struct vec4 *color, const DWORD *vs_code, size_t vs_code_size)
{
static const DWORD ps_color_code[] =
{
@@ -1509,7 +1521,7 @@ static void draw_color_quad_(unsigned int line, struct d3d11_test_context *conte
set_quad_color(context, color);
- draw_quad_(line, context);
+ draw_quad_vs_(line, context, vs_code, vs_code_size);
}
static void test_create_device(void)
@@ -13495,8 +13507,6 @@ float4 main(const ps_in v) : SV_TARGET
colors_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(colors), &colors);
index_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(index), NULL);
- 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);
hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps);
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
@@ -13511,7 +13521,7 @@ float4 main(const ps_in v) : SV_TARGET
index[0] = test_data[i].index;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)index_cb, 0, NULL, &index, 0, 0);
- draw_quad(&test_context);
+ draw_quad_vs(&test_context, vs_code, sizeof(vs_code));
check_texture_color(test_context.backbuffer, test_data[i].expected, 1);
}
@@ -13620,9 +13630,6 @@ static void test_vs_input_relative_addressing(void)
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);
-
hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps);
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0);
@@ -13632,7 +13639,7 @@ static void test_vs_input_relative_addressing(void)
*index = i;
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, index, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
- draw_quad(&test_context);
+ draw_quad_vs(&test_context, vs_code, sizeof(vs_code));
check_texture_color(test_context.backbuffer, colors[i], 1);
}
@@ -24943,9 +24950,6 @@ static void test_clip_distance(void)
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);
@@ -24958,7 +24962,7 @@ static void test_clip_distance(void)
/* vertex shader */
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
- draw_color_quad(&test_context, &green);
+ draw_color_quad_vs(&test_context, &green, vs_code, sizeof(vs_code));
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
check_clip_distance(&test_context, vb);
@@ -25020,11 +25024,6 @@ static void test_clip_distance(void)
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);
@@ -25032,7 +25031,7 @@ static void test_clip_distance(void)
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);
+ draw_color_quad_vs(&test_context, &green, vs_multiple_code, sizeof(vs_multiple_code));
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
for (i = 0; i < ARRAY_SIZE(vertices); ++i)
@@ -25042,7 +25041,7 @@ static void test_clip_distance(void)
}
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
- draw_color_quad(&test_context, &green);
+ draw_color_quad_vs(&test_context, &green, vs_multiple_code, sizeof(vs_multiple_code));
get_texture_readback(test_context.backbuffer, 0, &rb);
SetRect(&rect, 0, 0, 320, 240);
check_readback_data_color(&rb, &rect, 0xff00ff00, 1);
@@ -25057,7 +25056,7 @@ static void test_clip_distance(void)
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);
+ draw_color_quad_vs(&test_context, &green, vs_multiple_code, sizeof(vs_multiple_code));
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
if (hs)
@@ -25212,9 +25211,6 @@ static void test_combined_clip_and_cull_distances(void)
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);
-
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
draw_color_quad(&test_context, &green);
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
@@ -25232,7 +25228,7 @@ static void test_combined_clip_and_cull_distances(void)
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
- draw_color_quad(&test_context, &green);
+ draw_color_quad_vs(&test_context, &green, vs_code, sizeof(vs_code));
for (k = 0; k < ARRAY_SIZE(expected_color); ++k)
expected_color[k] = test->triangle_visible[k] ? 0xff00ff00 : 0xffffffff;
@@ -25263,7 +25259,7 @@ static void test_combined_clip_and_cull_distances(void)
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
- draw_color_quad(&test_context, &green);
+ draw_color_quad_vs(&test_context, &green, vs_code, sizeof(vs_code));
check_texture_color(test_context.backbuffer, 0xffffffff, 1);
for (j = 0; j < ARRAY_SIZE(vertices); ++j)
@@ -25273,7 +25269,7 @@ static void test_combined_clip_and_cull_distances(void)
memset(vertices, 0, sizeof(vertices));
ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
- draw_color_quad(&test_context, &green);
+ draw_color_quad_vs(&test_context, &green, vs_code, sizeof(vs_code));
check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
ID3D11Buffer_Release(vb);
--
2.16.1
More information about the wine-devel
mailing list