mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 14:52:10 +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;
|
||||
}
|
||||
|
||||
|
||||
DxvkSparsePageTable* DxvkBuffer::getSparsePageTable() {
|
||||
return m_storage->getSparsePageTable();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -215,6 +215,11 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
DxvkSparsePageTable* DxvkImage::getSparsePageTable() {
|
||||
return &m_sparsePageTable;
|
||||
}
|
||||
|
||||
|
||||
DxvkImageView::DxvkImageView(
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const Rc<DxvkImage>& image,
|
||||
|
@ -331,6 +331,12 @@ namespace dxvk {
|
||||
*/
|
||||
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;
|
||||
|
@ -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) {
|
||||
|
@ -1279,6 +1279,9 @@ namespace dxvk {
|
||||
DxvkMemoryType& type,
|
||||
const DxvkDeviceMemory& memory);
|
||||
|
||||
DxvkResourceAllocation* createAllocation(
|
||||
DxvkSparsePageTable* sparsePageTable);
|
||||
|
||||
bool refillAllocationCache(
|
||||
DxvkLocalAllocationCache* cache,
|
||||
const VkMemoryRequirements& requirements,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -331,7 +331,8 @@ namespace dxvk {
|
||||
|
||||
DxvkSparsePageTable(
|
||||
DxvkDevice* device,
|
||||
const DxvkBuffer* buffer);
|
||||
const VkBufferCreateInfo& bufferInfo,
|
||||
VkBuffer bufferHandle);
|
||||
|
||||
DxvkSparsePageTable(
|
||||
DxvkDevice* device,
|
||||
@ -455,7 +456,8 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
const DxvkBuffer* m_buffer = nullptr;
|
||||
VkBuffer m_buffer = VK_NULL_HANDLE;
|
||||
|
||||
const DxvkImage* m_image = nullptr;
|
||||
|
||||
DxvkSparseImageProperties m_properties = { };
|
||||
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user