1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-15 07:29:17 +01:00

[dxvk] Move image view cookie to DxvkResource

This commit is contained in:
Philip Rebohle 2022-08-07 21:24:57 +02:00
parent 4831909656
commit 2b2c44aa99
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 29 additions and 22 deletions

View File

@ -4,9 +4,6 @@
namespace dxvk { namespace dxvk {
std::atomic<uint64_t> DxvkImageView::s_cookie = { 0ull };
DxvkImage::DxvkImage( DxvkImage::DxvkImage(
const DxvkDevice* device, const DxvkDevice* device,
const DxvkImageCreateInfo& createInfo, const DxvkImageCreateInfo& createInfo,
@ -220,7 +217,7 @@ namespace dxvk {
const Rc<vk::DeviceFn>& vkd, const Rc<vk::DeviceFn>& vkd,
const Rc<DxvkImage>& image, const Rc<DxvkImage>& image,
const DxvkImageViewCreateInfo& info) 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++) for (uint32_t i = 0; i < ViewCount; i++)
m_views[i] = VK_NULL_HANDLE; m_views[i] = VK_NULL_HANDLE;

View File

@ -438,18 +438,6 @@ namespace dxvk {
return lookupFormatInfo(m_info.format); 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 * \brief Mip level size
* *
@ -567,10 +555,6 @@ namespace dxvk {
DxvkImageViewCreateInfo m_info; DxvkImageViewCreateInfo m_info;
VkImageView m_views[ViewCount]; VkImageView m_views[ViewCount];
uint64_t m_cookie;
static std::atomic<uint64_t> s_cookie;
void createView(VkImageViewType type, uint32_t numLayers); void createView(VkImageViewType type, uint32_t numLayers);
}; };

View File

@ -2,6 +2,15 @@
namespace dxvk { namespace dxvk {
std::atomic<uint64_t> DxvkResource::s_cookie = { 0ull };
DxvkResource::DxvkResource()
: m_useCount(0ull), m_cookie(++s_cookie) {
}
DxvkResource::~DxvkResource() { DxvkResource::~DxvkResource() {
} }

View File

@ -32,8 +32,22 @@ namespace dxvk {
static constexpr uint64_t WrAccessInc = 1ull << WrAccessShift; static constexpr uint64_t WrAccessInc = 1ull << WrAccessShift;
public: public:
DxvkResource();
virtual ~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 * \brief Increments reference count
* \returns New reference count * \returns New reference count
@ -104,7 +118,8 @@ namespace dxvk {
private: private:
std::atomic<uint64_t> m_useCount = { 0ull }; std::atomic<uint64_t> m_useCount;
uint64_t m_cookie;
static constexpr uint64_t getIncrement(DxvkAccess access) { static constexpr uint64_t getIncrement(DxvkAccess access) {
uint64_t increment = RefcountInc; uint64_t increment = RefcountInc;
@ -117,6 +132,8 @@ namespace dxvk {
return increment; return increment;
} }
static std::atomic<uint64_t> s_cookie;
}; };
} }