From de05728c8c3ebfb2426928c6ff6129a2db232d1a Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 14 Jun 2021 16:40:34 +0200 Subject: [PATCH] [dxvk] Check view format as well when deferring clears Otherwise, we may accidentally clear to an incorrect value. Fixes #2100. --- src/dxvk/dxvk_context.cpp | 4 ++-- src/dxvk/dxvk_framebuffer.cpp | 2 +- src/dxvk/dxvk_image.h | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index bb041cf5..c1fc8ab5 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1881,7 +1881,7 @@ namespace dxvk { VkImageAspectFlags clearAspects, VkClearValue clearValue) { for (auto& entry : m_deferredClears) { - if (entry.imageView->checkSubresourceMatch(imageView)) { + if (entry.imageView->matchesView(imageView)) { entry.imageView = imageView; entry.discardAspects &= ~clearAspects; entry.clearAspects |= clearAspects; @@ -1908,7 +1908,7 @@ namespace dxvk { const Rc& imageView, VkImageAspectFlags discardAspects) { for (auto& entry : m_deferredClears) { - if (entry.imageView->checkSubresourceMatch(imageView)) { + if (entry.imageView->matchesView(imageView)) { entry.imageView = imageView; entry.discardAspects |= discardAspects; entry.clearAspects &= ~discardAspects; diff --git a/src/dxvk/dxvk_framebuffer.cpp b/src/dxvk/dxvk_framebuffer.cpp index a801f76c..2184f3f6 100644 --- a/src/dxvk/dxvk_framebuffer.cpp +++ b/src/dxvk/dxvk_framebuffer.cpp @@ -50,7 +50,7 @@ namespace dxvk { int32_t DxvkFramebuffer::findAttachment(const Rc& view) const { for (uint32_t i = 0; i < m_attachmentCount; i++) { - if (getAttachment(i).view->checkSubresourceMatch(view)) + if (getAttachment(i).view->matchesView(view)) return int32_t(i); } diff --git a/src/dxvk/dxvk_image.h b/src/dxvk/dxvk_image.h index 37c462b6..43f5552e 100644 --- a/src/dxvk/dxvk_image.h +++ b/src/dxvk/dxvk_image.h @@ -485,13 +485,14 @@ namespace dxvk { * \param [in] view The other view to check * \returns \c true if the two views have the same subresources */ - bool checkSubresourceMatch(const Rc& view) const { + bool matchesView(const Rc& view) const { if (this == view.ptr()) return true; return this->image() == view->image() && this->subresources() == view->subresources() - && this->info().type == view->info().type; + && this->info().type == view->info().type + && this->info().format == view->info().format; } /**