Module: vkd3d Branch: master Commit: 92d88e290390ab8c62656b67bb35813cb08e16f3 URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=92d88e290390ab8c62656b67...
Author: Józef Kucia jkucia@codeweavers.com Date: Fri May 17 10:39:10 2019 +0200
vkd3d: Fix draw calls without depth-stencil view.
Fixes a regression introduced by 9eba55403d9a3b9cd58f76a6f14ddf5f745df73a.
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
libs/vkd3d/command.c | 7 ++++++- libs/vkd3d/state.c | 20 +++++++++++--------- tests/d3d12.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index edf13d6..1c518f3 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -2340,6 +2340,7 @@ static bool d3d12_command_list_update_current_framebuffer(struct d3d12_command_l VkFramebuffer vk_framebuffer; unsigned int view_count; size_t start_idx = 0; + bool null_attachment; unsigned int i; VkResult vr;
@@ -2353,7 +2354,11 @@ static bool d3d12_command_list_update_current_framebuffer(struct d3d12_command_l
for (i = 0, view_count = 0; i < graphics->attachment_count; ++i) { - if (graphics->null_attachment_mask & (1u << i)) + null_attachment = graphics->null_attachment_mask & (1u << i); + if (graphics->rt_idx && i == 0) + null_attachment = list->dsv_format == VK_FORMAT_UNDEFINED; + + if (null_attachment) { if (list->views[start_idx + i]) WARN("Expected NULL view for attachment %u.\n", i); diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 457f3d9..5d2f490 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -2058,21 +2058,21 @@ static HRESULT d3d12_graphics_pipeline_state_create_render_pass( VkFormat dynamic_dsv_format, VkRenderPass *vk_render_pass) { struct vkd3d_render_pass_key key; - unsigned int i; + VkFormat dsv_format; + unsigned int i = 0; + + dsv_format = graphics->rt_idx ? + graphics->dsv_format ? graphics->dsv_format : dynamic_dsv_format + : VK_FORMAT_UNDEFINED;
- if (graphics->rt_idx) + if (dsv_format) { assert(graphics->ds_desc.front.writeMask == graphics->ds_desc.back.writeMask); key.depth_enable = graphics->ds_desc.depthTestEnable; key.stencil_enable = graphics->ds_desc.stencilTestEnable; key.depth_stencil_write = graphics->ds_desc.depthWriteEnable || graphics->ds_desc.front.writeMask; - - if (!(key.vk_formats[0] = graphics->dsv_format)) - key.vk_formats[0] = dynamic_dsv_format; - - if (!key.vk_formats[0]) - FIXME("Compiling with DXGI_FORMAT_UNKNOWN.\n"); + key.vk_formats[i++] = dsv_format; } else { @@ -2082,11 +2082,13 @@ static HRESULT d3d12_graphics_pipeline_state_create_render_pass( key.vk_formats[ARRAY_SIZE(key.vk_formats) - 1] = VK_FORMAT_UNDEFINED; }
- memcpy(&key.vk_formats[graphics->rt_idx], graphics->rtv_formats, sizeof(graphics->rtv_formats)); + memcpy(&key.vk_formats[i], graphics->rtv_formats, sizeof(graphics->rtv_formats)); for (i = graphics->attachment_count; i < ARRAY_SIZE(key.vk_formats); ++i) assert(key.vk_formats[i] == VK_FORMAT_UNDEFINED);
key.attachment_count = graphics->attachment_count; + if (!dsv_format && graphics->rt_idx) + --key.attachment_count; key.padding = 0; key.sample_count = graphics->ms_desc.rasterizationSamples;
diff --git a/tests/d3d12.c b/tests/d3d12.c index 305d087..36bc41c 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -4934,6 +4934,35 @@ static void test_unknown_dsv_format(void) D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); check_sub_resource_vec4(context.render_target, 0, queue, command_list, &green, 0);
+ /* DSVFormat = DXGI_FORMAT_UNKNOWN and no DSV */ + reset_command_list(command_list, context.allocator); + transition_resource_state(command_list, ds.texture, + D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_DEPTH_WRITE); + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); + + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL); + + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, FALSE, NULL); + ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); + ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state); + ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect); + + ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 0, 4, &red.x, 0); + set_viewport(&context.viewport, 0.0f, 0.0f, 32.0f, 32.0f, 0.0f, 0.0f); + ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); + ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0); + + ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 0, 4, &green.x, 0); + set_viewport(&context.viewport, 0.0f, 0.0f, 32.0f, 32.0f, 1.0f, 0.5f); + ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); + ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0); + + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + check_sub_resource_vec4(context.render_target, 0, queue, command_list, &green, 0); + destroy_depth_stencil(&ds); destroy_test_context(&context); }