diff --git a/src/dxvk/dxvk_buffer.h b/src/dxvk/dxvk_buffer.h index 3c383c2e1..5ea4ca91c 100644 --- a/src/dxvk/dxvk_buffer.h +++ b/src/dxvk/dxvk_buffer.h @@ -103,7 +103,7 @@ namespace dxvk { * unformatted data. Can be accessed by the host * if allocated on an appropriate memory type. */ - class DxvkBuffer : public DxvkResource { + class DxvkBuffer : public DxvkPagedResource { friend class DxvkBufferView; public: @@ -294,16 +294,6 @@ namespace dxvk { m_nextSlices.push_back(slice); } - /** - * \brief Queries sparse page table - * \returns Page table, or \c nullptr for a non-sparse resource - */ - DxvkSparsePageTable* getSparsePageTable() { - return m_info.flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT - ? &m_sparsePageTable - : nullptr; - } - private: DxvkDevice* m_device; @@ -316,8 +306,6 @@ namespace dxvk { DxvkBufferSliceHandle m_physSlice; uint32_t m_vertexStride = 0; - DxvkSparsePageTable m_sparsePageTable; - alignas(CACHE_LINE_SIZE) sync::Spinlock m_freeMutex; diff --git a/src/dxvk/dxvk_image.h b/src/dxvk/dxvk_image.h index 7cda6f5a1..a29d916cf 100644 --- a/src/dxvk/dxvk_image.h +++ b/src/dxvk/dxvk_image.h @@ -122,7 +122,7 @@ namespace dxvk { * Can be accessed by the host if allocated on a suitable * memory type and if created with the linear tiling option. */ - class DxvkImage : public DxvkResource { + class DxvkImage : public DxvkPagedResource { friend class DxvkContext; friend class DxvkImageView; public: @@ -324,16 +324,6 @@ namespace dxvk { return result; } - /** - * \brief Queries sparse page table - * \returns Page table, or \c nullptr for a non-sparse resource - */ - DxvkSparsePageTable* getSparsePageTable() { - return m_info.flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT - ? &m_sparsePageTable - : nullptr; - } - /** * \brief Create a new shared handle to dedicated memory backing the image * \returns The shared handle with the type given by DxvkSharedHandleInfo::type @@ -347,7 +337,6 @@ namespace dxvk { DxvkImageCreateInfo m_info; VkMemoryPropertyFlags m_memFlags; DxvkPhysicalImage m_image; - DxvkSparsePageTable m_sparsePageTable; bool m_shared = false; diff --git a/src/dxvk/dxvk_sparse.h b/src/dxvk/dxvk_sparse.h index 46c373ba3..1563e90e4 100644 --- a/src/dxvk/dxvk_sparse.h +++ b/src/dxvk/dxvk_sparse.h @@ -132,6 +132,14 @@ namespace dxvk { DxvkDevice* device, const DxvkImage* image); + /** + * \brief Checks whether page table is defined + * \returns \c true if the page table is defined + */ + operator bool () const { + return m_buffer || m_image; + } + /** * \brief Counts total number of pages in the resources * @@ -197,4 +205,31 @@ namespace dxvk { }; + + /** + * \brief Paged resource + * + * Base class for any resource that can + * hold a sparse page table. + */ + class DxvkPagedResource : public DxvkResource { + + public: + + /** + * \brief Queries sparse page table + * \returns Sparse page table, if defined + */ + DxvkSparsePageTable* getSparsePageTable() { + return m_sparsePageTable + ? &m_sparsePageTable + : nullptr; + } + + protected: + + DxvkSparsePageTable m_sparsePageTable; + + }; + } \ No newline at end of file