Zebediah Figura : d3d11/tests: Add a test for rendering with deferred contexts.
Alexandre Julliard
julliard at winehq.org
Thu Oct 1 15:50:30 CDT 2020
Module: wine
Branch: master
Commit: 386e6799572296ac36d433b8fc37de5540a52f6b
URL: https://source.winehq.org/git/wine.git/?a=commit;h=386e6799572296ac36d433b8fc37de5540a52f6b
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Wed Sep 30 10:25:00 2020 -0500
d3d11/tests: Add a test for rendering with deferred contexts.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3d11/tests/d3d11.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 82a165c62d..e1a6dd6159 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -30237,6 +30237,108 @@ static void test_deferred_context_state(void)
release_test_context(&test_context);
}
+static void test_deferred_context_rendering(void)
+{
+ ID3D11DeviceContext *immediate, *deferred;
+ struct d3d11_test_context test_context;
+ D3D11_TEXTURE2D_DESC texture_desc;
+ ID3D11CommandList *list1, *list2;
+ ID3D11RenderTargetView *rtv;
+ ID3D11Texture2D *texture;
+ ID3D11Device *device;
+ DWORD color;
+ HRESULT hr;
+
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const float green[] = {0.0f, 1.0f, 0.0f, 1.0f};
+ static const float blue[] = {0.0f, 0.0f, 1.0f, 1.0f};
+
+ if (!init_test_context(&test_context, NULL))
+ return;
+
+ device = test_context.device;
+ immediate = test_context.immediate_context;
+
+ ID3D11DeviceContext_ClearRenderTargetView(immediate, test_context.backbuffer_rtv, white);
+
+ hr = ID3D11Device_CreateDeferredContext(device, 0, &deferred);
+ todo_wine ok(hr == S_OK, "Failed to create deferred context, hr %#x.\n", hr);
+ if (hr != S_OK)
+ {
+ release_test_context(&test_context);
+ return;
+ }
+
+ ID3D11DeviceContext_ClearRenderTargetView(deferred, test_context.backbuffer_rtv, green);
+
+ hr = ID3D11DeviceContext_FinishCommandList(deferred, TRUE, &list1);
+ ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
+
+ hr = ID3D11DeviceContext_FinishCommandList(deferred, TRUE, &list2);
+ ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
+
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0xffffffff, "Got unexpected color %#08x.\n", color);
+
+ ID3D11DeviceContext_ExecuteCommandList(immediate, list1, TRUE);
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0xff00ff00, "Got unexpected color %#08x.\n", color);
+
+ ID3D11DeviceContext_ClearRenderTargetView(immediate, test_context.backbuffer_rtv, white);
+ ID3D11DeviceContext_ExecuteCommandList(immediate, list1, TRUE);
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0xff00ff00, "Got unexpected color %#08x.\n", color);
+
+ ID3D11DeviceContext_ClearRenderTargetView(immediate, test_context.backbuffer_rtv, white);
+ ID3D11DeviceContext_ExecuteCommandList(immediate, list2, TRUE);
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0xffffffff, "Got unexpected color %#08x.\n", color);
+
+ ID3D11CommandList_Release(list2);
+
+ ID3D11DeviceContext_ExecuteCommandList(deferred, list1, TRUE);
+ hr = ID3D11DeviceContext_FinishCommandList(deferred, TRUE, &list2);
+ ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
+
+ ID3D11DeviceContext_ClearRenderTargetView(immediate, test_context.backbuffer_rtv, white);
+ ID3D11DeviceContext_ExecuteCommandList(immediate, list2, TRUE);
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0xff00ff00, "Got unexpected color %#08x.\n", color);
+
+ ID3D11CommandList_Release(list2);
+ ID3D11CommandList_Release(list1);
+ ID3D11DeviceContext_Release(deferred);
+
+ ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
+ hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
+ ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
+ hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)texture, NULL, &rtv);
+ ok(hr == S_OK, "Failed to create view, hr %#x.\n", hr);
+
+ ID3D11DeviceContext_ClearRenderTargetView(immediate, test_context.backbuffer_rtv, white);
+ ID3D11DeviceContext_ClearRenderTargetView(immediate, rtv, green);
+
+ hr = ID3D11Device_CreateDeferredContext(device, 0, &deferred);
+ ok(hr == S_OK, "Failed to create deferred context, hr %#x.\n", hr);
+
+ ID3D11DeviceContext_CopyResource(deferred, (ID3D11Resource *)test_context.backbuffer, (ID3D11Resource *)texture);
+
+ hr = ID3D11DeviceContext_FinishCommandList(deferred, TRUE, &list1);
+ ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
+
+ ID3D11DeviceContext_ClearRenderTargetView(immediate, rtv, blue);
+ ID3D11DeviceContext_ExecuteCommandList(immediate, list1, TRUE);
+ color = get_texture_color(test_context.backbuffer, 320, 240);
+ ok(color == 0xffff0000, "Got unexpected color %#08x.\n", color);
+
+ ID3D11CommandList_Release(list1);
+ ID3D11DeviceContext_Release(deferred);
+
+ ID3D11RenderTargetView_Release(rtv);
+ ID3D11Texture2D_Release(texture);
+ release_test_context(&test_context);
+}
+
START_TEST(d3d11)
{
unsigned int argc, i;
@@ -30401,6 +30503,7 @@ START_TEST(d3d11)
queue_test(test_independent_blend);
queue_test(test_dual_source_blend);
queue_test(test_deferred_context_state);
+ queue_test(test_deferred_context_rendering);
run_queued_tests();
}
More information about the wine-cvs
mailing list