1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-28 02:19:26 +01:00

[dxvk] Track attachment usage throughout a render pass

This commit is contained in:
Philip Rebohle 2025-03-21 22:57:47 +01:00
parent bd27980ae8
commit 8dbe6af8a3
2 changed files with 29 additions and 1 deletions

View File

@ -2325,8 +2325,16 @@ namespace dxvk {
entry.aspectMask = clear.clearAspects;
entry.clearValue = clear.clearValue;
if (clear.clearAspects & VK_IMAGE_ASPECT_COLOR_BIT)
if (clear.clearAspects & VK_IMAGE_ASPECT_COLOR_BIT) {
entry.colorAttachment = m_state.om.framebufferInfo.getColorAttachmentIndex(attachmentIndex);
m_state.om.attachmentMask.trackColorWrite(entry.colorAttachment);
}
if (clear.clearAspects & VK_IMAGE_ASPECT_DEPTH_BIT)
m_state.om.attachmentMask.trackDepthWrite();
if (clear.clearAspects & VK_IMAGE_ASPECT_STENCIL_BIT)
m_state.om.attachmentMask.trackStencilWrite();
}
if (!attachments.empty()) {
@ -2508,12 +2516,16 @@ namespace dxvk {
color.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
color.resolveImageView = resolve.imageView->handle();
color.resolveImageLayout = newLayout;
m_state.om.attachmentMask.trackColorRead(index);
} else {
if (resolve.depthMode) {
auto& depth = m_state.om.renderingInfo.depth;
depth.resolveMode = resolve.depthMode;
depth.resolveImageView = resolve.imageView->handle();
depth.resolveImageLayout = newLayout;
m_state.om.attachmentMask.trackDepthRead();
}
if (resolve.stencilMode) {
@ -2521,6 +2533,8 @@ namespace dxvk {
stencil.resolveMode = resolve.stencilMode;
stencil.resolveImageView = resolve.imageView->handle();
stencil.resolveImageLayout = newLayout;
m_state.om.attachmentMask.trackStencilRead();
}
}
@ -5642,6 +5656,8 @@ namespace dxvk {
this->renderPassEmitInitBarriers(framebufferInfo, ops);
this->renderPassEmitPostBarriers(framebufferInfo, ops);
m_state.om.attachmentMask.clear();
VkCommandBufferInheritanceRenderingInfo renderingInheritance = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO };
VkCommandBufferInheritanceInfo inheritance = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, &renderingInheritance };
@ -5679,6 +5695,8 @@ namespace dxvk {
clear.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
clear.clearValue.color = ops.colorOps[i].clearValue;
}
m_state.om.attachmentMask.trackColorWrite(i);
}
colorInfoCount = i + 1;
@ -5711,6 +5729,9 @@ namespace dxvk {
if (ops.depthOps.loadOpD == VK_ATTACHMENT_LOAD_OP_CLEAR) {
depthInfo.clearValue.depthStencil.depth = ops.depthOps.clearValue.depth;
depthInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
if (depthStencilAspects & VK_IMAGE_ASPECT_DEPTH_BIT)
m_state.om.attachmentMask.trackDepthWrite();
}
renderingInheritance.rasterizationSamples = depthTarget.view->image()->info().sampleCount;
@ -5727,6 +5748,9 @@ namespace dxvk {
if (ops.depthOps.loadOpS == VK_ATTACHMENT_LOAD_OP_CLEAR) {
stencilInfo.clearValue.depthStencil.stencil = ops.depthOps.clearValue.stencil;
stencilInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
if (depthStencilAspects & VK_IMAGE_ASPECT_STENCIL_BIT)
m_state.om.attachmentMask.trackStencilWrite();
}
}
@ -6054,6 +6078,9 @@ namespace dxvk {
m_cmd->cmdBindPipeline(DxvkCmdBuffer::ExecBuffer,
VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineInfo.handle);
// Update attachment usage info based on the pipeline state
m_state.om.attachmentMask.merge(pipelineInfo.attachments);
// For pipelines created from graphics pipeline libraries, we need to
// apply a bunch of dynamic state that is otherwise static or unused
if (pipelineInfo.type == DxvkGraphicsPipelineType::BasePipeline) {

View File

@ -134,6 +134,7 @@ namespace dxvk {
DxvkRenderTargets renderTargets;
DxvkRenderPassOps renderPassOps;
DxvkFramebufferInfo framebufferInfo;
DxvkAttachmentMask attachmentMask;
};