mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-21 13:54:18 +01:00
[dxvk] Implement sparse image creation in allocator
This commit is contained in:
parent
bcd12a5b56
commit
eec4f0fb35
@ -828,10 +828,11 @@ namespace dxvk {
|
||||
dedicatedRequirements.prefersDedicatedAllocation = VK_TRUE;
|
||||
}
|
||||
|
||||
// If a dedicated allocation is at least preferred for this resource, try this first
|
||||
Rc<DxvkResourceAllocation> allocation;
|
||||
|
||||
if (dedicatedRequirements.prefersDedicatedAllocation) {
|
||||
if (!(createInfo.flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
|
||||
// If a dedicated allocation is at least preferred for this resource, try this first
|
||||
if (!allocation && dedicatedRequirements.prefersDedicatedAllocation) {
|
||||
VkMemoryDedicatedAllocateInfo dedicatedInfo = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO, next };
|
||||
dedicatedInfo.image = image;
|
||||
|
||||
@ -862,6 +863,30 @@ namespace dxvk {
|
||||
properties & ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Create a sparse page table and determine whether we need to allocate
|
||||
// actual memory for the metadata aspect of the image or not.
|
||||
auto pageTable = std::make_unique<DxvkSparsePageTable>(m_device, createInfo, image);
|
||||
auto pageProperties = pageTable->getProperties();
|
||||
|
||||
if (pageProperties.metadataPageCount) {
|
||||
VkMemoryRequirements metadataRequirements = { };
|
||||
metadataRequirements.size = SparseMemoryPageSize * pageProperties.metadataPageCount;
|
||||
metadataRequirements.alignment = SparseMemoryPageSize;
|
||||
metadataRequirements.memoryTypeBits = requirements.memoryRequirements.memoryTypeBits;
|
||||
|
||||
allocation = allocateMemory(metadataRequirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
|
||||
if (!allocation)
|
||||
allocation = allocateMemory(metadataRequirements, 0u);
|
||||
|
||||
if (allocation)
|
||||
allocation->m_sparsePageTable = pageTable.release();
|
||||
} else {
|
||||
// Just need a page table, but no memory
|
||||
allocation = createAllocation(pageTable.release());
|
||||
}
|
||||
}
|
||||
|
||||
if (!allocation) {
|
||||
vk->vkDestroyImage(vk->device(), image, nullptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user