From 2b2c44aa998f6743ec07bdf3e81566ad24978012 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 7 Aug 2022 21:24:57 +0200 Subject: [PATCH] [dxvk] Move image view cookie to DxvkResource --- src/dxvk/dxvk_image.cpp | 5 +---- src/dxvk/dxvk_image.h | 16 ---------------- src/dxvk/dxvk_resource.cpp | 9 +++++++++ src/dxvk/dxvk_resource.h | 21 +++++++++++++++++++-- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/dxvk/dxvk_image.cpp b/src/dxvk/dxvk_image.cpp index f08ce410c..d48fc05ed 100644 --- a/src/dxvk/dxvk_image.cpp +++ b/src/dxvk/dxvk_image.cpp @@ -4,9 +4,6 @@ namespace dxvk { - std::atomic DxvkImageView::s_cookie = { 0ull }; - - DxvkImage::DxvkImage( const DxvkDevice* device, const DxvkImageCreateInfo& createInfo, @@ -220,7 +217,7 @@ namespace dxvk { const Rc& vkd, const Rc& image, const DxvkImageViewCreateInfo& info) - : m_vkd(vkd), m_image(image), m_info(info), m_cookie(++s_cookie) { + : m_vkd(vkd), m_image(image), m_info(info) { for (uint32_t i = 0; i < ViewCount; i++) m_views[i] = VK_NULL_HANDLE; diff --git a/src/dxvk/dxvk_image.h b/src/dxvk/dxvk_image.h index 42d95971a..285c5e9ee 100644 --- a/src/dxvk/dxvk_image.h +++ b/src/dxvk/dxvk_image.h @@ -438,18 +438,6 @@ namespace dxvk { return lookupFormatInfo(m_info.format); } - /** - * \brief Unique object identifier - * - * Can be used to identify an object even when - * the lifetime of the object is unknown, and - * without referencing the actual object. - * \returns Unique identifier - */ - uint64_t cookie() const { - return m_cookie; - } - /** * \brief Mip level size * @@ -567,10 +555,6 @@ namespace dxvk { DxvkImageViewCreateInfo m_info; VkImageView m_views[ViewCount]; - uint64_t m_cookie; - - static std::atomic s_cookie; - void createView(VkImageViewType type, uint32_t numLayers); }; diff --git a/src/dxvk/dxvk_resource.cpp b/src/dxvk/dxvk_resource.cpp index af7a2ea4e..4dff5d7c2 100644 --- a/src/dxvk/dxvk_resource.cpp +++ b/src/dxvk/dxvk_resource.cpp @@ -2,6 +2,15 @@ namespace dxvk { + std::atomic DxvkResource::s_cookie = { 0ull }; + + + DxvkResource::DxvkResource() + : m_useCount(0ull), m_cookie(++s_cookie) { + + } + + DxvkResource::~DxvkResource() { } diff --git a/src/dxvk/dxvk_resource.h b/src/dxvk/dxvk_resource.h index 80a935270..97e82cb72 100644 --- a/src/dxvk/dxvk_resource.h +++ b/src/dxvk/dxvk_resource.h @@ -31,9 +31,23 @@ namespace dxvk { static constexpr uint64_t RdAccessInc = 1ull << RdAccessShift; static constexpr uint64_t WrAccessInc = 1ull << WrAccessShift; public: - + + DxvkResource(); + virtual ~DxvkResource(); + /** + * \brief Unique object identifier + * + * Can be used to identify an object even when + * the lifetime of the object is unknown, and + * without referencing the actual object. + * \returns Unique identifier + */ + uint64_t cookie() const { + return m_cookie; + } + /** * \brief Increments reference count * \returns New reference count @@ -104,7 +118,8 @@ namespace dxvk { private: - std::atomic m_useCount = { 0ull }; + std::atomic m_useCount; + uint64_t m_cookie; static constexpr uint64_t getIncrement(DxvkAccess access) { uint64_t increment = RefcountInc; @@ -117,6 +132,8 @@ namespace dxvk { return increment; } + static std::atomic s_cookie; + }; } \ No newline at end of file