1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-04-12 03:02:33 +02:00

[dxvk] Use STORE_OP_NONE for read-only depth or stencil aspects

This commit is contained in:
Philip Rebohle 2025-03-21 04:27:49 +01:00
parent 90ee5fe180
commit b341b95d10

View File

@ -5598,34 +5598,47 @@ namespace dxvk {
VkFormat depthStencilFormat = VK_FORMAT_UNDEFINED; VkFormat depthStencilFormat = VK_FORMAT_UNDEFINED;
VkImageAspectFlags depthStencilAspects = 0; VkImageAspectFlags depthStencilAspects = 0;
VkImageAspectFlags depthStencilWritable = 0;
auto& depthInfo = m_state.om.renderingInfo.depth; auto& depthInfo = m_state.om.renderingInfo.depth;
depthInfo = { VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO }; depthInfo = { VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO };
if (framebufferInfo.getDepthTarget().view != nullptr) { const auto& depthTarget = framebufferInfo.getDepthTarget();
const auto& depthTarget = framebufferInfo.getDepthTarget();
if (depthTarget.view) {
depthStencilFormat = depthTarget.view->info().format; depthStencilFormat = depthTarget.view->info().format;
depthStencilAspects = depthTarget.view->info().aspects; depthStencilAspects = depthTarget.view->info().aspects;
depthStencilWritable = vk::getWritableAspectsForLayout(depthTarget.layout);
if (!m_device->properties().khrMaintenance7.separateDepthStencilAttachmentAccess && depthStencilWritable)
depthStencilWritable = depthStencilAspects;
depthInfo.imageView = depthTarget.view->handle(); depthInfo.imageView = depthTarget.view->handle();
depthInfo.imageLayout = depthTarget.layout; depthInfo.imageLayout = depthTarget.layout;
depthInfo.loadOp = ops.depthOps.loadOpD; depthInfo.loadOp = ops.depthOps.loadOpD;
depthInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE; depthInfo.storeOp = (depthStencilWritable & VK_IMAGE_ASPECT_DEPTH_BIT)
? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_NONE;
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;
}
renderingInheritance.rasterizationSamples = depthTarget.view->image()->info().sampleCount; renderingInheritance.rasterizationSamples = depthTarget.view->image()->info().sampleCount;
} }
auto& stencilInfo = m_state.om.renderingInfo.stencil; auto& stencilInfo = m_state.om.renderingInfo.stencil;
stencilInfo = depthInfo; stencilInfo = depthInfo;
if (framebufferInfo.getDepthTarget().view != nullptr) { if (depthTarget.view) {
stencilInfo.loadOp = ops.depthOps.loadOpS; stencilInfo.loadOp = ops.depthOps.loadOpS;
stencilInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE; stencilInfo.storeOp = (depthStencilWritable & VK_IMAGE_ASPECT_STENCIL_BIT)
? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_NONE;
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;
}
} }
auto& renderingInfo = m_state.om.renderingInfo.rendering; auto& renderingInfo = m_state.om.renderingInfo.rendering;