Vulkan: Use memory budget extension where available

This commit is contained in:
Connor McLaughlin 2022-01-07 18:51:30 +10:00 committed by refractionpcsx2
parent 4f735d0201
commit 1a3c20f0f7
3 changed files with 10 additions and 0 deletions

View File

@ -460,6 +460,8 @@ namespace Vulkan
m_optional_extensions.vk_ext_provoking_vertex =
SupportsExtension(VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME, false);
m_optional_extensions.vk_ext_memory_budget =
SupportsExtension(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME, false);
return true;
}
@ -676,6 +678,9 @@ namespace Vulkan
ci.device = m_device;
ci.instance = m_instance;
if (m_optional_extensions.vk_ext_memory_budget)
ci.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT;
VkResult res = vmaCreateAllocator(&ci, &m_allocator);
if (res != VK_SUCCESS)
{
@ -1137,6 +1142,9 @@ namespace Vulkan
m_current_command_buffer = resources.command_buffers[1];
resources.fence_counter = m_next_fence_counter++;
resources.init_buffer_used = false;
// using the lower 32 bits of the fence index should be sufficient here, I hope...
vmaSetCurrentFrameIndex(m_allocator, static_cast<u32>(m_next_fence_counter));
}
void Context::ExecuteCommandBuffer(bool wait_for_completion)

View File

@ -49,6 +49,7 @@ namespace Vulkan
struct OptionalExtensions
{
bool vk_ext_provoking_vertex : 1;
bool vk_ext_memory_budget : 1;
};
~Context();

View File

@ -88,6 +88,7 @@ namespace Vulkan
VmaAllocationCreateInfo aci = {};
aci.usage = VMA_MEMORY_USAGE_GPU_ONLY;
aci.flags = VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT;
VkImage image = VK_NULL_HANDLE;
VmaAllocation allocation = VK_NULL_HANDLE;