From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d/command.c | 5 +++-- tests/d3d12.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 49c3830030ee..fa5f8fb2ef4d 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -3749,7 +3749,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets(ID3D12Graphi rtv_desc = d3d12_rtv_desc_from_cpu_handle(render_target_descriptors[i]); }
- if (!rtv_desc) + if (!rtv_desc || !rtv_desc->resource) { WARN("RTV descriptor %u is not initialized.\n", i); list->views[i + 1] = VK_NULL_HANDLE; @@ -3773,7 +3773,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets(ID3D12Graphi
if (depth_stencil_descriptor) { - if ((dsv_desc = d3d12_dsv_desc_from_cpu_handle(*depth_stencil_descriptor))) + if ((dsv_desc = d3d12_dsv_desc_from_cpu_handle(*depth_stencil_descriptor)) + && dsv_desc->resource) { d3d12_command_list_track_resource_usage(list, dsv_desc->resource);
diff --git a/tests/d3d12.c b/tests/d3d12.c index 97af4c1a9f67..41704b3c076a 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -4219,6 +4219,42 @@ static void test_clear_unordered_access_view(void) #undef BUFFER_SIZE }
+static void test_set_render_targets(void) +{ + ID3D12DescriptorHeap *dsv_heap, *rtv_heap; + ID3D12GraphicsCommandList *command_list; + D3D12_CPU_DESCRIPTOR_HANDLE dsv, rtv; + struct test_context context; + ID3D12Device *device; + HRESULT hr; + + if (!init_test_context(&context, NULL)) + return; + device = context.device; + command_list = context.list; + + rtv_heap = create_cpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 4); + dsv_heap = create_cpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_DSV, 4); + + dsv = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(dsv_heap); + rtv = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rtv_heap); + + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &rtv, FALSE, NULL); + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &rtv, TRUE, NULL); + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &rtv, TRUE, &dsv); + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 0, &rtv, TRUE, &dsv); + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 0, &rtv, FALSE, &dsv); + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 0, NULL, TRUE, &dsv); + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 0, NULL, FALSE, &dsv); + + hr = ID3D12GraphicsCommandList_Close(command_list); + ok(hr == S_OK, "Failed to close command list, hr %#x.\n", hr); + + ID3D12DescriptorHeap_Release(rtv_heap); + ID3D12DescriptorHeap_Release(dsv_heap); + destroy_test_context(&context); +} + static void test_draw_instanced(void) { static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; @@ -22893,6 +22929,7 @@ START_TEST(d3d12) run_test(test_clear_depth_stencil_view); run_test(test_clear_render_target_view); run_test(test_clear_unordered_access_view); + run_test(test_set_render_targets); run_test(test_draw_instanced); run_test(test_draw_indexed_instanced); run_test(test_draw_no_descriptor_bindings);