mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxvk] Reimplement sparse buffer support
This commit is contained in:
parent
1ba6b81901
commit
bbd2461c8f
@ -64,4 +64,9 @@ namespace dxvk {
|
|||||||
return &entry.first->second;
|
return &entry.first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DxvkSparsePageTable* DxvkBuffer::getSparsePageTable() {
|
||||||
|
return m_storage->getSparsePageTable();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -384,6 +384,12 @@ namespace dxvk {
|
|||||||
Rc<DxvkBufferView> createView(
|
Rc<DxvkBufferView> createView(
|
||||||
const DxvkBufferViewCreateInfo& info);
|
const DxvkBufferViewCreateInfo& info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Retrieves sparse binding table
|
||||||
|
* \returns Sparse binding table
|
||||||
|
*/
|
||||||
|
DxvkSparsePageTable* getSparsePageTable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Rc<vk::DeviceFn> m_vkd;
|
Rc<vk::DeviceFn> m_vkd;
|
||||||
|
@ -215,6 +215,11 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DxvkSparsePageTable* DxvkImage::getSparsePageTable() {
|
||||||
|
return &m_sparsePageTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkImageView::DxvkImageView(
|
DxvkImageView::DxvkImageView(
|
||||||
const Rc<vk::DeviceFn>& vkd,
|
const Rc<vk::DeviceFn>& vkd,
|
||||||
const Rc<DxvkImage>& image,
|
const Rc<DxvkImage>& image,
|
||||||
|
@ -330,7 +330,13 @@ namespace dxvk {
|
|||||||
* \returns The shared handle with the type given by DxvkSharedHandleInfo::type
|
* \returns The shared handle with the type given by DxvkSharedHandleInfo::type
|
||||||
*/
|
*/
|
||||||
HANDLE sharedHandle() const;
|
HANDLE sharedHandle() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Retrives sparse page table
|
||||||
|
* \returns Page table
|
||||||
|
*/
|
||||||
|
DxvkSparsePageTable* getSparsePageTable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Rc<vk::DeviceFn> m_vkd;
|
Rc<vk::DeviceFn> m_vkd;
|
||||||
@ -339,6 +345,8 @@ namespace dxvk {
|
|||||||
VkMemoryPropertyFlags m_memFlags;
|
VkMemoryPropertyFlags m_memFlags;
|
||||||
DxvkPhysicalImage m_image;
|
DxvkPhysicalImage m_image;
|
||||||
|
|
||||||
|
DxvkSparsePageTable m_sparsePageTable;
|
||||||
|
|
||||||
bool m_shared = false;
|
bool m_shared = false;
|
||||||
|
|
||||||
small_vector<VkFormat, 4> m_viewFormats;
|
small_vector<VkFormat, 4> m_viewFormats;
|
||||||
|
@ -758,7 +758,7 @@ namespace dxvk {
|
|||||||
logMemoryStats();
|
logMemoryStats();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO implement sparse
|
allocation = createAllocation(new DxvkSparsePageTable(m_device, createInfo, buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allocation) {
|
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(
|
DxvkResourceAllocation* DxvkMemoryAllocator::createAllocation(
|
||||||
DxvkMemoryType& type,
|
DxvkMemoryType& type,
|
||||||
const DxvkDeviceMemory& memory) {
|
const DxvkDeviceMemory& memory) {
|
||||||
|
@ -1279,6 +1279,9 @@ namespace dxvk {
|
|||||||
DxvkMemoryType& type,
|
DxvkMemoryType& type,
|
||||||
const DxvkDeviceMemory& memory);
|
const DxvkDeviceMemory& memory);
|
||||||
|
|
||||||
|
DxvkResourceAllocation* createAllocation(
|
||||||
|
DxvkSparsePageTable* sparsePageTable);
|
||||||
|
|
||||||
bool refillAllocationCache(
|
bool refillAllocationCache(
|
||||||
DxvkLocalAllocationCache* cache,
|
DxvkLocalAllocationCache* cache,
|
||||||
const VkMemoryRequirements& requirements,
|
const VkMemoryRequirements& requirements,
|
||||||
|
@ -182,9 +182,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkSparsePageTable::DxvkSparsePageTable(
|
DxvkSparsePageTable::DxvkSparsePageTable(
|
||||||
DxvkDevice* device,
|
DxvkDevice* device,
|
||||||
const DxvkBuffer* buffer)
|
const VkBufferCreateInfo& bufferInfo,
|
||||||
: m_buffer(buffer) {
|
VkBuffer bufferHandle)
|
||||||
VkDeviceSize bufferSize = buffer->info().size;
|
: m_buffer(bufferHandle) {
|
||||||
|
VkDeviceSize bufferSize = bufferInfo.size;
|
||||||
|
|
||||||
// For linear buffers, the mapping is very simple
|
// For linear buffers, the mapping is very simple
|
||||||
// and consists of consecutive 64k pages
|
// and consists of consecutive 64k pages
|
||||||
@ -357,7 +358,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
VkBuffer DxvkSparsePageTable::getBufferHandle() const {
|
VkBuffer DxvkSparsePageTable::getBufferHandle() const {
|
||||||
return m_buffer ? m_buffer->getSliceHandle().handle : VK_NULL_HANDLE;
|
return m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -331,7 +331,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkSparsePageTable(
|
DxvkSparsePageTable(
|
||||||
DxvkDevice* device,
|
DxvkDevice* device,
|
||||||
const DxvkBuffer* buffer);
|
const VkBufferCreateInfo& bufferInfo,
|
||||||
|
VkBuffer bufferHandle);
|
||||||
|
|
||||||
DxvkSparsePageTable(
|
DxvkSparsePageTable(
|
||||||
DxvkDevice* device,
|
DxvkDevice* device,
|
||||||
@ -455,8 +456,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const DxvkBuffer* m_buffer = nullptr;
|
VkBuffer m_buffer = VK_NULL_HANDLE;
|
||||||
const DxvkImage* m_image = nullptr;
|
|
||||||
|
const DxvkImage* m_image = nullptr;
|
||||||
|
|
||||||
DxvkSparseImageProperties m_properties = { };
|
DxvkSparseImageProperties m_properties = { };
|
||||||
std::vector<DxvkSparseImageSubresourceProperties> m_subresources;
|
std::vector<DxvkSparseImageSubresourceProperties> m_subresources;
|
||||||
@ -478,17 +480,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Queries sparse page table
|
* \brief Queries sparse page table
|
||||||
|
*
|
||||||
|
* Should be removed once storage objects can
|
||||||
|
* be retrieved from resources diectly.
|
||||||
* \returns Sparse page table, if defined
|
* \returns Sparse page table, if defined
|
||||||
*/
|
*/
|
||||||
DxvkSparsePageTable* getSparsePageTable() {
|
virtual DxvkSparsePageTable* getSparsePageTable() = 0;
|
||||||
return m_sparsePageTable
|
|
||||||
? &m_sparsePageTable
|
|
||||||
: nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
DxvkSparsePageTable m_sparsePageTable;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user