1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-04-01 09:25:24 +02: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.aspectMask = clear.clearAspects;
entry.clearValue = clear.clearValue; 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); 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()) { if (!attachments.empty()) {
@ -2508,12 +2516,16 @@ namespace dxvk {
color.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT; color.resolveMode = VK_RESOLVE_MODE_AVERAGE_BIT;
color.resolveImageView = resolve.imageView->handle(); color.resolveImageView = resolve.imageView->handle();
color.resolveImageLayout = newLayout; color.resolveImageLayout = newLayout;
m_state.om.attachmentMask.trackColorRead(index);
} else { } else {
if (resolve.depthMode) { if (resolve.depthMode) {
auto& depth = m_state.om.renderingInfo.depth; auto& depth = m_state.om.renderingInfo.depth;
depth.resolveMode = resolve.depthMode; depth.resolveMode = resolve.depthMode;
depth.resolveImageView = resolve.imageView->handle(); depth.resolveImageView = resolve.imageView->handle();
depth.resolveImageLayout = newLayout; depth.resolveImageLayout = newLayout;
m_state.om.attachmentMask.trackDepthRead();
} }
if (resolve.stencilMode) { if (resolve.stencilMode) {
@ -2521,6 +2533,8 @@ namespace dxvk {
stencil.resolveMode = resolve.stencilMode; stencil.resolveMode = resolve.stencilMode;
stencil.resolveImageView = resolve.imageView->handle(); stencil.resolveImageView = resolve.imageView->handle();
stencil.resolveImageLayout = newLayout; stencil.resolveImageLayout = newLayout;
m_state.om.attachmentMask.trackStencilRead();
} }
} }
@ -5642,6 +5656,8 @@ namespace dxvk {
this->renderPassEmitInitBarriers(framebufferInfo, ops); this->renderPassEmitInitBarriers(framebufferInfo, ops);
this->renderPassEmitPostBarriers(framebufferInfo, ops); this->renderPassEmitPostBarriers(framebufferInfo, ops);
m_state.om.attachmentMask.clear();
VkCommandBufferInheritanceRenderingInfo renderingInheritance = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO }; VkCommandBufferInheritanceRenderingInfo renderingInheritance = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO };
VkCommandBufferInheritanceInfo inheritance = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, &renderingInheritance }; VkCommandBufferInheritanceInfo inheritance = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, &renderingInheritance };
@ -5679,6 +5695,8 @@ namespace dxvk {
clear.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; clear.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
clear.clearValue.color = ops.colorOps[i].clearValue; clear.clearValue.color = ops.colorOps[i].clearValue;
} }
m_state.om.attachmentMask.trackColorWrite(i);
} }
colorInfoCount = i + 1; colorInfoCount = i + 1;
@ -5711,6 +5729,9 @@ namespace dxvk {
if (ops.depthOps.loadOpD == VK_ATTACHMENT_LOAD_OP_CLEAR) { if (ops.depthOps.loadOpD == VK_ATTACHMENT_LOAD_OP_CLEAR) {
depthInfo.clearValue.depthStencil.depth = ops.depthOps.clearValue.depth; depthInfo.clearValue.depthStencil.depth = ops.depthOps.clearValue.depth;
depthInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE; 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; renderingInheritance.rasterizationSamples = depthTarget.view->image()->info().sampleCount;
@ -5727,6 +5748,9 @@ namespace dxvk {
if (ops.depthOps.loadOpS == VK_ATTACHMENT_LOAD_OP_CLEAR) { if (ops.depthOps.loadOpS == VK_ATTACHMENT_LOAD_OP_CLEAR) {
stencilInfo.clearValue.depthStencil.stencil = ops.depthOps.clearValue.stencil; stencilInfo.clearValue.depthStencil.stencil = ops.depthOps.clearValue.stencil;
stencilInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE; 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, m_cmd->cmdBindPipeline(DxvkCmdBuffer::ExecBuffer,
VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineInfo.handle); 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 // For pipelines created from graphics pipeline libraries, we need to
// apply a bunch of dynamic state that is otherwise static or unused // apply a bunch of dynamic state that is otherwise static or unused
if (pipelineInfo.type == DxvkGraphicsPipelineType::BasePipeline) { if (pipelineInfo.type == DxvkGraphicsPipelineType::BasePipeline) {

View File

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