vk: Refactor memory allocators to easily inspect device properties
This commit is contained in:
@@ -679,11 +679,11 @@ namespace vk
|
|||||||
|
|
||||||
if (g_cfg.video.disable_vulkan_mem_allocator)
|
if (g_cfg.video.disable_vulkan_mem_allocator)
|
||||||
{
|
{
|
||||||
m_allocator = std::make_unique<vk::mem_allocator_vk>(dev, pdev);
|
m_allocator = std::make_unique<vk::mem_allocator_vk>(*this, pdev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_allocator = std::make_unique<vk::mem_allocator_vma>(dev, pdev);
|
m_allocator = std::make_unique<vk::mem_allocator_vma>(*this, pdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Useful for debugging different VRAM configurations
|
// Useful for debugging different VRAM configurations
|
||||||
|
|||||||
@@ -153,7 +153,12 @@ namespace vk
|
|||||||
rsx_log.warning("Rebalanced memory types successfully");
|
rsx_log.warning("Rebalanced memory types successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_allocator_vma::mem_allocator_vma(VkDevice dev, VkPhysicalDevice pdev) : mem_allocator_base(dev, pdev)
|
mem_allocator_base::mem_allocator_base(const vk::render_device& dev, VkPhysicalDevice)
|
||||||
|
: m_device(dev), m_allocation_flags(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
mem_allocator_vma::mem_allocator_vma(const vk::render_device& dev, VkPhysicalDevice pdev)
|
||||||
|
: mem_allocator_base(dev, pdev)
|
||||||
{
|
{
|
||||||
// Initialize stats pool
|
// Initialize stats pool
|
||||||
std::fill(stats.begin(), stats.end(), VmaBudget{});
|
std::fill(stats.begin(), stats.end(), VmaBudget{});
|
||||||
@@ -164,11 +169,11 @@ namespace vk
|
|||||||
|
|
||||||
std::vector<VkDeviceSize> heap_limits;
|
std::vector<VkDeviceSize> heap_limits;
|
||||||
const auto vram_allocation_limit = g_cfg.video.vk.vram_allocation_limit * 0x100000ull;
|
const auto vram_allocation_limit = g_cfg.video.vk.vram_allocation_limit * 0x100000ull;
|
||||||
if (vram_allocation_limit < g_render_device->get_memory_mapping().device_local_total_bytes)
|
if (vram_allocation_limit < dev.get_memory_mapping().device_local_total_bytes)
|
||||||
{
|
{
|
||||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||||
vkGetPhysicalDeviceMemoryProperties(pdev, &memory_properties);
|
vkGetPhysicalDeviceMemoryProperties(pdev, &memory_properties);
|
||||||
for (int i = 0; i < memory_properties.memoryHeapCount; ++i)
|
for (u32 i = 0; i < memory_properties.memoryHeapCount; ++i)
|
||||||
{
|
{
|
||||||
const u64 max_sz = (memory_properties.memoryHeaps[i].flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
|
const u64 max_sz = (memory_properties.memoryHeaps[i].flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
|
||||||
? vram_allocation_limit
|
? vram_allocation_limit
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace vk
|
|||||||
public:
|
public:
|
||||||
using mem_handle_t = void*;
|
using mem_handle_t = void*;
|
||||||
|
|
||||||
mem_allocator_base(VkDevice dev, VkPhysicalDevice /*pdev*/) : m_device(dev), m_allocation_flags(0) {}
|
mem_allocator_base(const vk::render_device& dev, VkPhysicalDevice /*pdev*/);
|
||||||
virtual ~mem_allocator_base() = default;
|
virtual ~mem_allocator_base() = default;
|
||||||
|
|
||||||
virtual void destroy() = 0;
|
virtual void destroy() = 0;
|
||||||
@@ -83,7 +83,7 @@ namespace vk
|
|||||||
class mem_allocator_vma : public mem_allocator_base
|
class mem_allocator_vma : public mem_allocator_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mem_allocator_vma(VkDevice dev, VkPhysicalDevice pdev);
|
mem_allocator_vma(const vk::render_device& dev, VkPhysicalDevice pdev);
|
||||||
~mem_allocator_vma() override = default;
|
~mem_allocator_vma() override = default;
|
||||||
|
|
||||||
void destroy() override;
|
void destroy() override;
|
||||||
@@ -112,7 +112,7 @@ namespace vk
|
|||||||
class mem_allocator_vk : public mem_allocator_base
|
class mem_allocator_vk : public mem_allocator_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mem_allocator_vk(VkDevice dev, VkPhysicalDevice pdev) : mem_allocator_base(dev, pdev) {}
|
mem_allocator_vk(const vk::render_device& dev, VkPhysicalDevice pdev) : mem_allocator_base(dev, pdev) {}
|
||||||
~mem_allocator_vk() override = default;
|
~mem_allocator_vk() override = default;
|
||||||
|
|
||||||
void destroy() override {}
|
void destroy() override {}
|
||||||
|
|||||||
Reference in New Issue
Block a user