Skip to content

Commit

Permalink
[dxvk] Disable depthWriteEnable if depth attachment has read-only layout
Browse files Browse the repository at this point in the history
Fixes water rendering in SpellForce 3.
  • Loading branch information
doitsujin committed May 3, 2019
1 parent 6eeb3b6 commit 53aa273
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/dxvk/dxvk_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<VkDynamicState, 5> dynamicStates;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/dxvk/dxvk_graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ namespace dxvk {

VkPipeline compilePipeline(
const DxvkGraphicsPipelineStateInfo& state,
VkRenderPass renderPass,
const DxvkRenderPass& renderPass,
VkPipeline baseHandle) const;

void destroyPipeline(
Expand Down

0 comments on commit 53aa273

Please sign in to comment.