From: Józef Kucia jkucia@codeweavers.com
Allows us to create the render pass while creating the pipeline state.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d/state.c | 13 ++++++++++--- tests/d3d12.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index b3348d601b9e..7bce6143c4a1 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -2228,8 +2228,17 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s graphics->rtv_formats[i] = VK_FORMAT_UNDEFINED; graphics->rt_count = rt_count;
+ ds_desc_from_d3d12(&graphics->ds_desc, &desc->DepthStencilState); + if (desc->DSVFormat == DXGI_FORMAT_UNKNOWN + && graphics->ds_desc.depthTestEnable && !graphics->ds_desc.depthWriteEnable + && graphics->ds_desc.depthCompareOp == VK_COMPARE_OP_ALWAYS && !graphics->ds_desc.stencilTestEnable) + { + TRACE("Disabling depth test.\n"); + graphics->ds_desc.depthTestEnable = VK_FALSE; + } + graphics->dsv_format = VK_FORMAT_UNDEFINED; - if (desc->DepthStencilState.DepthEnable || desc->DepthStencilState.StencilEnable) + if (graphics->ds_desc.depthTestEnable || graphics->ds_desc.stencilTestEnable) { if (desc->DSVFormat == DXGI_FORMAT_UNKNOWN) { @@ -2545,8 +2554,6 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s graphics->ms_desc.alphaToCoverageEnable = desc->BlendState.AlphaToCoverageEnable; graphics->ms_desc.alphaToOneEnable = VK_FALSE;
- ds_desc_from_d3d12(&graphics->ds_desc, &desc->DepthStencilState); - if (graphics->dsv_format == VK_FORMAT_UNDEFINED) graphics->render_pass = VK_NULL_HANDLE; else if (FAILED(hr = d3d12_graphics_pipeline_state_create_render_pass(graphics, diff --git a/tests/d3d12.c b/tests/d3d12.c index 36bc41cd23c2..c7dfd8a3ed1c 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -4963,6 +4963,39 @@ 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 D3D12_COMPARISON_FUNC_ALWAYS */ + ID3D12PipelineState_Release(context.pipeline_state); + pso_desc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_ALWAYS; + hr = ID3D12Device_CreateGraphicsPipelineState(context.device, &pso_desc, + &IID_ID3D12PipelineState, (void **)&context.pipeline_state); + ok(hr == S_OK, "Failed to create graphics pipeline state, hr %#x.\n", hr); + + reset_command_list(command_list, context.allocator); + 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.6f); + 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); }