From 53aa27336bb6ee3b04f38a4e7d60016c7a4785fa Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 3 May 2019 14:38:21 +0200 Subject: [PATCH] [dxvk] Disable depthWriteEnable if depth attachment has read-only layout Fixes water rendering in SpellForce 3. --- src/dxvk/dxvk_graphics.cpp | 11 +++++++---- src/dxvk/dxvk_graphics.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 78dea7f1..4d60b1fe 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -121,7 +121,7 @@ namespace dxvk { // If no pipeline instance exists with the given state // vector, create a new one and add it to the list. - newPipelineHandle = this->compilePipeline(state, renderPassHandle, m_basePipeline); + newPipelineHandle = this->compilePipeline(state, renderPass, m_basePipeline); // Add new pipeline to the set m_pipelines.emplace_back(state, renderPassHandle, newPipelineHandle); @@ -152,12 +152,15 @@ namespace dxvk { VkPipeline DxvkGraphicsPipeline::compilePipeline( const DxvkGraphicsPipelineStateInfo& state, - VkRenderPass renderPass, + const DxvkRenderPass& renderPass, VkPipeline baseHandle) const { if (Logger::logLevel() <= LogLevel::Debug) { Logger::debug("Compiling graphics pipeline..."); this->logPipelineState(LogLevel::Debug, state); } + + // Render pass format and image layouts + DxvkRenderPassFormat passFormat = renderPass.format(); // Set up dynamic states as needed std::array dynamicStates; @@ -349,7 +352,7 @@ namespace dxvk { dsInfo.pNext = nullptr; dsInfo.flags = 0; dsInfo.depthTestEnable = state.dsEnableDepthTest; - dsInfo.depthWriteEnable = state.dsEnableDepthWrite; + dsInfo.depthWriteEnable = state.dsEnableDepthWrite && !util::isDepthReadOnlyLayout(passFormat.depth.layout); dsInfo.depthCompareOp = state.dsDepthCompareOp; dsInfo.depthBoundsTestEnable = VK_FALSE; dsInfo.stencilTestEnable = state.dsEnableStencilTest; @@ -393,7 +396,7 @@ namespace dxvk { info.pColorBlendState = &cbInfo; info.pDynamicState = &dyInfo; info.layout = m_layout->pipelineLayout(); - info.renderPass = renderPass; + info.renderPass = renderPass.getDefaultHandle(); info.subpass = 0; info.basePipelineHandle = baseHandle; info.basePipelineIndex = -1; diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index aaf64e43..a1f68cc6 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -274,7 +274,7 @@ namespace dxvk { VkPipeline compilePipeline( const DxvkGraphicsPipelineStateInfo& state, - VkRenderPass renderPass, + const DxvkRenderPass& renderPass, VkPipeline baseHandle) const; void destroyPipeline(