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

[dxvk] Only flush clears if image to use has any pending clears

We can reorder the clear after any operation that does not access
the image.
This commit is contained in:
Philip Rebohle 2025-03-22 00:23:26 +01:00
parent 86cf0a3e51
commit f355b1c30c
2 changed files with 22 additions and 3 deletions

View File

@ -6534,8 +6534,9 @@ namespace dxvk {
if (!(image->info().usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))) if (!(image->info().usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)))
return; return;
// Flush clears if there are any since they may affect the image // Flush clears if there are any that affect the image. We need
if (!m_deferredClears.empty() && flushClears) // to check all subresources here, not just the ones to be used.
if (flushClears && findOverlappingDeferredClear(image, image->getAvailableSubresources()))
this->spillRenderPass(false); this->spillRenderPass(false);
// All images are in their default layout for suspended passes // All images are in their default layout for suspended passes
@ -6573,7 +6574,7 @@ namespace dxvk {
const Rc<DxvkImage>& image, const Rc<DxvkImage>& image,
const VkImageSubresourceRange& subresources) { const VkImageSubresourceRange& subresources) {
for (auto& entry : m_deferredClears) { for (auto& entry : m_deferredClears) {
if ((entry.imageView->image() == image) && ((subresources.aspectMask & entry.clearAspects) == subresources.aspectMask) if ((entry.imageView->image() == image.ptr()) && ((subresources.aspectMask & entry.clearAspects) == subresources.aspectMask)
&& (vk::checkSubresourceRangeSuperset(entry.imageView->imageSubresources(), subresources))) && (vk::checkSubresourceRangeSuperset(entry.imageView->imageSubresources(), subresources)))
return &entry; return &entry;
} }
@ -6582,6 +6583,20 @@ namespace dxvk {
} }
DxvkDeferredClear* DxvkContext::findOverlappingDeferredClear(
const Rc<DxvkImage>& image,
const VkImageSubresourceRange& subresources) {
for (auto& entry : m_deferredClears) {
if ((entry.imageView->image() == image.ptr())
&& (entry.clearAspects & entry.discardAspects & subresources.aspectMask)
&& (vk::checkSubresourceRangeOverlap(entry.imageView->imageSubresources(), subresources)))
return &entry;
}
return nullptr;
}
bool DxvkContext::updateIndexBufferBinding() { bool DxvkContext::updateIndexBufferBinding() {
if (unlikely(!m_state.vi.indexBuffer.length())) if (unlikely(!m_state.vi.indexBuffer.length()))
return false; return false;

View File

@ -1754,6 +1754,10 @@ namespace dxvk {
const Rc<DxvkImage>& image, const Rc<DxvkImage>& image,
const VkImageSubresourceRange& subresources); const VkImageSubresourceRange& subresources);
DxvkDeferredClear* findOverlappingDeferredClear(
const Rc<DxvkImage>& image,
const VkImageSubresourceRange& subresources);
bool updateIndexBufferBinding(); bool updateIndexBufferBinding();
void updateVertexBufferBindings(); void updateVertexBufferBindings();