1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[dxvk] Reimplement sparse buffer support

This commit is contained in:
Philip Rebohle 2024-09-25 20:34:21 +02:00 committed by Philip Rebohle
parent 1ba6b81901
commit bbd2461c8f
8 changed files with 52 additions and 18 deletions

View File

@ -64,4 +64,9 @@ namespace dxvk {
return &entry.first->second;
}
DxvkSparsePageTable* DxvkBuffer::getSparsePageTable() {
return m_storage->getSparsePageTable();
}
}

View File

@ -384,6 +384,12 @@ namespace dxvk {
Rc<DxvkBufferView> createView(
const DxvkBufferViewCreateInfo& info);
/**
* \brief Retrieves sparse binding table
* \returns Sparse binding table
*/
DxvkSparsePageTable* getSparsePageTable();
private:
Rc<vk::DeviceFn> m_vkd;

View File

@ -215,6 +215,11 @@ namespace dxvk {
}
DxvkSparsePageTable* DxvkImage::getSparsePageTable() {
return &m_sparsePageTable;
}
DxvkImageView::DxvkImageView(
const Rc<vk::DeviceFn>& vkd,
const Rc<DxvkImage>& image,

View File

@ -330,7 +330,13 @@ namespace dxvk {
* \returns The shared handle with the type given by DxvkSharedHandleInfo::type
*/
HANDLE sharedHandle() const;
/**
* \brief Retrives sparse page table
* \returns Page table
*/
DxvkSparsePageTable* getSparsePageTable();
private:
Rc<vk::DeviceFn> m_vkd;
@ -339,6 +345,8 @@ namespace dxvk {
VkMemoryPropertyFlags m_memFlags;
DxvkPhysicalImage m_image;
DxvkSparsePageTable m_sparsePageTable;
bool m_shared = false;
small_vector<VkFormat, 4> m_viewFormats;

View File

@ -758,7 +758,7 @@ namespace dxvk {
logMemoryStats();
}
} else {
// TODO implement sparse
allocation = createAllocation(new DxvkSparsePageTable(m_device, createInfo, buffer));
}
if (!allocation) {
@ -1102,6 +1102,15 @@ namespace dxvk {
}
DxvkResourceAllocation* DxvkMemoryAllocator::createAllocation(
DxvkSparsePageTable* sparsePageTable) {
auto allocation = m_allocationPool.create(this, nullptr);
allocation->m_sparsePageTable = sparsePageTable;
return allocation;
}
DxvkResourceAllocation* DxvkMemoryAllocator::createAllocation(
DxvkMemoryType& type,
const DxvkDeviceMemory& memory) {

View File

@ -1279,6 +1279,9 @@ namespace dxvk {
DxvkMemoryType& type,
const DxvkDeviceMemory& memory);
DxvkResourceAllocation* createAllocation(
DxvkSparsePageTable* sparsePageTable);
bool refillAllocationCache(
DxvkLocalAllocationCache* cache,
const VkMemoryRequirements& requirements,

View File

@ -182,9 +182,10 @@ namespace dxvk {
DxvkSparsePageTable::DxvkSparsePageTable(
DxvkDevice* device,
const DxvkBuffer* buffer)
: m_buffer(buffer) {
VkDeviceSize bufferSize = buffer->info().size;
const VkBufferCreateInfo& bufferInfo,
VkBuffer bufferHandle)
: m_buffer(bufferHandle) {
VkDeviceSize bufferSize = bufferInfo.size;
// For linear buffers, the mapping is very simple
// and consists of consecutive 64k pages
@ -357,7 +358,7 @@ namespace dxvk {
VkBuffer DxvkSparsePageTable::getBufferHandle() const {
return m_buffer ? m_buffer->getSliceHandle().handle : VK_NULL_HANDLE;
return m_buffer;
}

View File

@ -331,7 +331,8 @@ namespace dxvk {
DxvkSparsePageTable(
DxvkDevice* device,
const DxvkBuffer* buffer);
const VkBufferCreateInfo& bufferInfo,
VkBuffer bufferHandle);
DxvkSparsePageTable(
DxvkDevice* device,
@ -455,8 +456,9 @@ namespace dxvk {
private:
const DxvkBuffer* m_buffer = nullptr;
const DxvkImage* m_image = nullptr;
VkBuffer m_buffer = VK_NULL_HANDLE;
const DxvkImage* m_image = nullptr;
DxvkSparseImageProperties m_properties = { };
std::vector<DxvkSparseImageSubresourceProperties> m_subresources;
@ -478,17 +480,12 @@ namespace dxvk {
/**
* \brief Queries sparse page table
*
* Should be removed once storage objects can
* be retrieved from resources diectly.
* \returns Sparse page table, if defined
*/
DxvkSparsePageTable* getSparsePageTable() {
return m_sparsePageTable
? &m_sparsePageTable
: nullptr;
}
protected:
DxvkSparsePageTable m_sparsePageTable;
virtual DxvkSparsePageTable* getSparsePageTable() = 0;
};