Updated d3d11-Deferred_Context patchset.

Add basic test for drawing with deferred context.
This commit is contained in:
Paul Gofman 2019-09-27 16:36:10 +03:00
parent 0c815a486b
commit 670a9e20c0
2 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,183 @@
From 20bd2911327fd59dde921b7d16e084b8f671be2b Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Fri, 27 Sep 2019 16:26:04 +0300
Subject: [PATCH] d3d11/tests: Add a basic test for drawing with deferred
context.
---
dlls/d3d11/tests/d3d11.c | 101 +++++++++++++++++++++++++++++++--------
1 file changed, 81 insertions(+), 20 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index e653fb30b2..3d9766fda8 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -1692,10 +1692,11 @@ static void release_test_context_(unsigned int line, struct d3d11_test_context *
ok_(__FILE__, line)(!ref, "Device has %u references left.\n", ref);
}
-#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)
+#define draw_quad(context) draw_quad_vs_(__LINE__, context, NULL, 0, (context)->immediate_context)
+#define draw_quad_vs(a, b, c) draw_quad_vs_(__LINE__, a, b, c, (a)->immediate_context)
+#define draw_quad_ext(a, b, c, d) draw_quad_vs_(__LINE__, a, b, c, d)
static void draw_quad_vs_(unsigned int line, struct d3d11_test_context *context,
- const DWORD *vs_code, size_t vs_code_size)
+ const DWORD *vs_code, size_t vs_code_size, ID3D11DeviceContext *draw_context)
{
static const D3D11_INPUT_ELEMENT_DESC default_layout_desc[] =
{
@@ -1764,14 +1765,14 @@ static void draw_quad_vs_(unsigned int line, struct d3d11_test_context *context,
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);
+ ID3D11DeviceContext_IASetInputLayout(draw_context, context->input_layout);
+ ID3D11DeviceContext_IASetPrimitiveTopology(draw_context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
stride = sizeof(*quad);
offset = 0;
- ID3D11DeviceContext_IASetVertexBuffers(context->immediate_context, 0, 1, &context->vb, &stride, &offset);
- ID3D11DeviceContext_VSSetShader(context->immediate_context, context->vs, NULL, 0);
+ ID3D11DeviceContext_IASetVertexBuffers(draw_context, 0, 1, &context->vb, &stride, &offset);
+ ID3D11DeviceContext_VSSetShader(draw_context, context->vs, NULL, 0);
- ID3D11DeviceContext_Draw(context->immediate_context, 4, 0);
+ ID3D11DeviceContext_Draw(draw_context, 4, 0);
}
#define draw_quad_z(context, z) draw_quad_z_(__LINE__, context, z)
@@ -1807,19 +1808,27 @@ 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), context->immediate_context);
}
-static void set_quad_color(struct d3d11_test_context *context, const struct vec4 *color)
+static void set_quad_color_ext(struct d3d11_test_context *context, const struct vec4 *color,
+ ID3D11DeviceContext *draw_context)
{
- ID3D11DeviceContext_UpdateSubresource(context->immediate_context,
+ ID3D11DeviceContext_UpdateSubresource(draw_context,
(ID3D11Resource *)context->ps_cb, 0, NULL, color, 0, 0);
}
-#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 set_quad_color(struct d3d11_test_context *context, const struct vec4 *color)
+{
+ set_quad_color_ext(context, color, context->immediate_context);
+}
+
+#define draw_color_quad(a, b) draw_color_quad_(__LINE__, a, b, NULL, 0, (a)->immediate_context)
+#define draw_color_quad_vs(a, b, c, d) draw_color_quad_(__LINE__, a, b, c, d, (a)->immediate_context)
+#define draw_color_quad_ext(a, b, c, d, e) draw_color_quad_(__LINE__, a, b, c, d, e)
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)
+ const struct vec4 *color, const DWORD *vs_code, size_t vs_code_size,
+ ID3D11DeviceContext *draw_context)
{
static const DWORD ps_color_code[] =
{
@@ -1856,12 +1865,12 @@ static void draw_color_quad_(unsigned int line, struct d3d11_test_context *conte
if (!context->ps_cb)
context->ps_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(*color), NULL);
- ID3D11DeviceContext_PSSetShader(context->immediate_context, context->ps, NULL, 0);
- ID3D11DeviceContext_PSSetConstantBuffers(context->immediate_context, 0, 1, &context->ps_cb);
+ ID3D11DeviceContext_PSSetShader(draw_context, context->ps, NULL, 0);
+ ID3D11DeviceContext_PSSetConstantBuffers(draw_context, 0, 1, &context->ps_cb);
- set_quad_color(context, color);
+ set_quad_color_ext(context, color, draw_context);
- draw_quad_vs_(line, context, vs_code, vs_code_size);
+ draw_quad_vs_(line, context, vs_code, vs_code_size, draw_context);
}
static void test_create_device(void)
@@ -2088,6 +2097,59 @@ static void test_create_device(void)
DestroyWindow(window);
}
+static void test_draw_deferred_context(void)
+{
+ static const struct vec4 red = {1.0f, 0.0f, 0.0f, 1.0f};
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const float black[] = {0.0f, 0.0f, 0.0f, 0.0f};
+ ID3D11DeviceContext *context, *deferred_context;
+ struct d3d11_test_context test_context;
+ ID3D11CommandList *command_list;
+ ID3D11Device *device;
+ DWORD color;
+ HRESULT hr;
+
+ if (!init_test_context(&test_context, NULL))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ hr = ID3D11Device_CreateDeferredContext(device, 0, &deferred_context);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0xffffffff, "Got unexpected color 0x%08x.\n", color);
+
+ ID3D11DeviceContext_ClearRenderTargetView(deferred_context, test_context.backbuffer_rtv, black);
+
+ hr = ID3D11DeviceContext_FinishCommandList(deferred_context, FALSE, &command_list);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+
+ ID3D11DeviceContext_ExecuteCommandList(context, command_list, TRUE);
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+ ID3D11CommandList_Release(command_list);
+
+ ID3D11DeviceContext_OMSetRenderTargets(deferred_context, 1, &test_context.backbuffer_rtv, NULL);
+
+ draw_color_quad_ext(&test_context, &red, NULL, 0, deferred_context);
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+
+ hr = ID3D11DeviceContext_FinishCommandList(deferred_context, TRUE, &command_list);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ ID3D11DeviceContext_ExecuteCommandList(context, command_list, TRUE);
+
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
+ ID3D11CommandList_Release(command_list);
+
+ ID3D11DeviceContext_Release(deferred_context);
+ todo_wine release_test_context(&test_context);
+}
+
static void test_device_interfaces(const D3D_FEATURE_LEVEL feature_level)
{
struct device_desc device_desc;
@@ -29400,11 +29462,11 @@ START_TEST(d3d11)
}
print_adapter_info();
-
queue_test(test_create_device);
queue_for_each_feature_level(test_device_interfaces);
queue_test(test_get_immediate_context);
queue_test(test_create_deferred_context);
+ queue_test(test_draw_deferred_context);
queue_test(test_create_texture1d);
queue_test(test_texture1d_interfaces);
queue_test(test_create_texture2d);
@@ -29538,6 +29600,5 @@ START_TEST(d3d11)
queue_test(test_render_a8);
queue_test(test_standard_pattern);
queue_test(test_desktop_window);
-
run_queued_tests();
}
--
2.21.0

View File

@ -2556,6 +2556,7 @@ if test "$enable_d3d11_Deferred_Context" -eq 1; then
patch_apply d3d11-Deferred_Context/0040-d3d11-Implement-restoring-of-state-after-executing-a.patch
patch_apply d3d11-Deferred_Context/0041-d3d11-Allow-NULL-pointer-for-initial-count-in-d3d11_.patch
patch_apply d3d11-Deferred_Context/0042-d3d11-Correctly-align-map-info-buffer.patch
patch_apply d3d11-Deferred_Context/0043-d3d11-tests-Add-a-basic-test-for-drawing-with-deferr.patch
(
printf '%s\n' '+ { "Kimmo Myllyvirta", "d3d11: Add stub deferred rendering context.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Add wined3d_resource_map_info function.", 1 },';
@ -2599,6 +2600,7 @@ if test "$enable_d3d11_Deferred_Context" -eq 1; then
printf '%s\n' '+ { "Michael Müller", "d3d11: Implement restoring of state after executing a command list.", 1 },';
printf '%s\n' '+ { "Steve Melenchuk", "d3d11: Allow NULL pointer for initial count in d3d11_deferred_context_CSSetUnorderedAccessViews.", 1 },';
printf '%s\n' '+ { "Kimmo Myllyvirta", "d3d11: Correctly align map info buffer.", 1 },';
printf '%s\n' '+ { "Paul Gofman", "d3d11/tests: Add a basic test for drawing with deferred context.", 1 },';
) >> "$patchlist"
fi