From 81c3daa3d068f6a1fd2e8960efa0a109a61ebe78 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 23 Jan 2020 22:19:59 +0100 Subject: [PATCH] [dxvk] Remove image renaming Broken by design, has to be implemented by client APIs instead. --- src/d3d9/d3d9_swapchain.cpp | 8 ---- src/dxvk/dxvk_context.cpp | 24 ---------- src/dxvk/dxvk_context.h | 15 ------- src/dxvk/dxvk_image.cpp | 88 +++---------------------------------- src/dxvk/dxvk_image.h | 46 ------------------- 5 files changed, 6 insertions(+), 175 deletions(-) diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 48737bd10..179aca38f 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -752,14 +752,6 @@ namespace dxvk { m_device->presentImage(m_presenter, cSync.present, &m_presentStatus); - - // Shift back buffers so that m_backBuffers[BackBufferCount] - // will contain the image that we just presented - for (uint32_t i = m_backBuffers.size(); i > 1; i--) { - ctx->swapImages( - m_backBuffers[i - 1]->GetCommonTexture()->GetImage(), - m_backBuffers[i - 2]->GetCommonTexture()->GetImage()); - } }); m_parent->FlushCsChunk(); diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 44ab31855..86829a4aa 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1800,30 +1800,6 @@ namespace dxvk { } - void DxvkContext::swapImages( - const Rc& image1, - const Rc& image2) { - Rc dump = new DxvkImageViewDump(m_device->vkd()); - image1->swap(image2, dump); - - // Usage flags are required to be identical - VkImageUsageFlags usage = image1->info().usage; - - if (usage & (VK_IMAGE_USAGE_SAMPLED_BIT - | VK_IMAGE_USAGE_STORAGE_BIT)) { - m_flags.set( - DxvkContextFlag::GpDirtyResources, - DxvkContextFlag::CpDirtyResources); - } - - if (usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT - | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) - this->spillRenderPass(); - - m_cmd->trackResource(dump); - } - - void DxvkContext::transformImage( const Rc& dstImage, const VkImageSubresourceRange& dstSubresources, diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 29b54a53c..2456b20af 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -708,21 +708,6 @@ namespace dxvk { VkResolveModeFlagBitsKHR depthMode, VkResolveModeFlagBitsKHR stencilMode); - /** - * \brief Swaps two images - * - * Exchanges the image handles and backing storage - * of the two images, and recreates all the views. - * Note that the two images must have been created - * with identical properties, including the memory - * properties. - * \param [in] image1 The first image - * \param [in] image2 The second image - */ - void swapImages( - const Rc& image1, - const Rc& image2); - /** * \brief Transforms image subresource layouts * diff --git a/src/dxvk/dxvk_image.cpp b/src/dxvk/dxvk_image.cpp index 7f86755a4..1ff763276 100644 --- a/src/dxvk/dxvk_image.cpp +++ b/src/dxvk/dxvk_image.cpp @@ -125,66 +125,11 @@ namespace dxvk { } - void DxvkImage::swap(const Rc& next, const Rc& dump) { - // Technically this could deadlock if two threads - // call this method, but that's undefined behaviour - // anyway so let's not care about it too much. - std::lock_guard lock1(this->m_viewLock); - std::lock_guard lock2(next->m_viewLock); - - std::swap(this->m_image, next->m_image); - - this->recreateViews(dump); - next->recreateViews(dump); - } - - - void DxvkImage::addView(DxvkImageView* view) { - m_viewList.push_back(view); - } - - - void DxvkImage::removeView(DxvkImageView* view) { - for (size_t i = 0; i < m_viewList.size(); i++) { - if (m_viewList[i] == view) { - m_viewList[i] = m_viewList.back(); - m_viewList.pop_back(); - return; - } - } - } - - - void DxvkImage::recreateViews(const Rc& dump) { - for (size_t i = 0; i < m_viewList.size(); i++) { - m_viewList[i]->discardViews(dump); - m_viewList[i]->createViews(); - } - } - - DxvkImageView::DxvkImageView( const Rc& vkd, const Rc& image, const DxvkImageViewCreateInfo& info) : m_vkd(vkd), m_image(image), m_info(info) { - std::lock_guard lock(m_image->m_viewLock); - m_image->addView(this); - - createViews(); - } - - - DxvkImageView::~DxvkImageView() { - for (uint32_t i = 0; i < ViewCount; i++) - m_vkd->vkDestroyImageView(m_vkd->device(), m_views[i], nullptr); - - std::lock_guard lock(m_image->m_viewLock); - m_image->removeView(this); - } - - - void DxvkImageView::createViews() { for (uint32_t i = 0; i < ViewCount; i++) m_views[i] = VK_NULL_HANDLE; @@ -227,18 +172,14 @@ namespace dxvk { throw DxvkError(str::format("DxvkImageView: Invalid view type: ", m_info.type)); } } - - - void DxvkImageView::discardViews(const Rc& dump) { - for (uint32_t i = 0; i < ViewCount; i++) { - if (m_views[i]) { - dump->addView(m_views[i]); - m_views[i] = VK_NULL_HANDLE; - } - } - } + DxvkImageView::~DxvkImageView() { + for (uint32_t i = 0; i < ViewCount; i++) + m_vkd->vkDestroyImageView(m_vkd->device(), m_views[i], nullptr); + } + + void DxvkImageView::createView(VkImageViewType type, uint32_t numLayers) { VkImageSubresourceRange subresourceRange; subresourceRange.aspectMask = m_info.aspect; @@ -293,22 +234,5 @@ namespace dxvk { "\n Tiling: ", m_image->info().tiling)); } } - - - DxvkImageViewDump::DxvkImageViewDump(const Rc& vkd) - : m_vkd(vkd) { - - } - - - DxvkImageViewDump::~DxvkImageViewDump() { - for (auto view : m_views) - m_vkd->vkDestroyImageView(m_vkd->device(), view, nullptr); - } - - - void DxvkImageViewDump::addView(VkImageView view) { - m_views.push_back(view); - } } \ No newline at end of file diff --git a/src/dxvk/dxvk_image.h b/src/dxvk/dxvk_image.h index 2f2c313d2..19b5d85f0 100644 --- a/src/dxvk/dxvk_image.h +++ b/src/dxvk/dxvk_image.h @@ -9,7 +9,6 @@ namespace dxvk { class DxvkImageView; - class DxvkImageViewDump; /** * \brief Image create info @@ -285,16 +284,6 @@ namespace dxvk { VkDeviceSize memSize() const { return m_image.memory.length(); } - - /** - * \brief Swaps the image with another - * - * \param [in] next The other image - * \param [in] dump Image view dump - */ - void swap( - const Rc& next, - const Rc& dump); private: @@ -305,14 +294,6 @@ namespace dxvk { small_vector m_viewFormats; - sync::Spinlock m_viewLock; - small_vector m_viewList; - - void addView(DxvkImageView* view); - void removeView(DxvkImageView* view); - - void recreateViews(const Rc& dump); - }; @@ -492,35 +473,8 @@ namespace dxvk { DxvkImageViewCreateInfo m_info; VkImageView m_views[ViewCount]; - void createViews(); - void createView(VkImageViewType type, uint32_t numLayers); - - void discardViews(const Rc& dump); }; - - - /** - * \brief Image view dump - * - * Takes orphaned image view objects and destroys - * them when they are no longer needed. - */ - class DxvkImageViewDump : public DxvkResource { - - public: - - DxvkImageViewDump(const Rc& vkd); - ~DxvkImageViewDump(); - - void addView(VkImageView view); - - private: - - Rc m_vkd; - std::vector m_views; - - }; } \ No newline at end of file