Commit 386e6799 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3d11/tests: Add a test for rendering with deferred contexts.

parent da8e4d9c
...@@ -30237,6 +30237,108 @@ static void test_deferred_context_state(void) ...@@ -30237,6 +30237,108 @@ static void test_deferred_context_state(void)
release_test_context(&test_context); 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) START_TEST(d3d11)
{ {
unsigned int argc, i; unsigned int argc, i;
...@@ -30401,6 +30503,7 @@ START_TEST(d3d11) ...@@ -30401,6 +30503,7 @@ START_TEST(d3d11)
queue_test(test_independent_blend); queue_test(test_independent_blend);
queue_test(test_dual_source_blend); queue_test(test_dual_source_blend);
queue_test(test_deferred_context_state); queue_test(test_deferred_context_state);
queue_test(test_deferred_context_rendering);
run_queued_tests(); run_queued_tests();
} }
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