1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-11 10:24:10 +01:00

[dxvk] Fix deferred clear logic for overlapping image views

If we clear the same image subresources twice with different views
and then start rendering to one view, we may end up clearing to
the wrong clear value.
This commit is contained in:
Philip Rebohle 2021-02-21 14:51:11 +01:00
parent 96e1079526
commit 5e55ced8b2
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 21 additions and 2 deletions

View File

@ -1868,7 +1868,8 @@ namespace dxvk {
entry.clearValue.depthStencil.stencil = clearValue.depthStencil.stencil; entry.clearValue.depthStencil.stencil = clearValue.depthStencil.stencil;
return; return;
} } else if (entry.imageView->checkSubresourceOverlap(imageView))
this->flushClears(false);
} }
m_deferredClears.push_back({ imageView, 0, clearAspects, clearValue }); m_deferredClears.push_back({ imageView, 0, clearAspects, clearValue });
@ -1883,7 +1884,8 @@ namespace dxvk {
entry.discardAspects |= discardAspects; entry.discardAspects |= discardAspects;
entry.clearAspects &= ~discardAspects; entry.clearAspects &= ~discardAspects;
return; return;
} } else if (entry.imageView->checkSubresourceOverlap(imageView))
this->flushClears(false);
} }
m_deferredClears.push_back({ imageView, discardAspects }); m_deferredClears.push_back({ imageView, discardAspects });

View File

@ -469,6 +469,23 @@ namespace dxvk {
return result; return result;
} }
/**
* \brief Checks whether this view overlaps with another one
*
* Two views overlap if they were created for the same
* image and have at least one subresource in common.
* \param [in] view The other view to check
* \returns \c true if the two views overlap
*/
bool checkSubresourceOverlap(const Rc<DxvkImageView>& view) const {
if (likely(m_image != view->m_image))
return false;
return vk::checkSubresourceRangeOverlap(
this->imageSubresources(),
view->imageSubresources());
}
private: private:
Rc<vk::DeviceFn> m_vkd; Rc<vk::DeviceFn> m_vkd;