vk: Enable auto-growing of the data heaps for the performance case

This commit is contained in:
kd-11 2019-11-10 10:34:53 +03:00 committed by kd-11
parent 357e0d2097
commit 0a32d478df
2 changed files with 17 additions and 1 deletions

View File

@ -116,7 +116,7 @@ public:
return (m_put_pos > 0) ? m_put_pos - 1 : m_size - 1; return (m_put_pos > 0) ? m_put_pos - 1 : m_size - 1;
} }
bool is_critical() const virtual bool is_critical() const
{ {
const size_t guard_length = std::max(m_min_guard_size, m_largest_allocated_pool); const size_t guard_length = std::max(m_min_guard_size, m_largest_allocated_pool);
return (m_current_allocated_size + guard_length) >= m_size; return (m_current_allocated_size + guard_length) >= m_size;

View File

@ -3394,6 +3394,7 @@ public:
class data_heap : public ::data_heap class data_heap : public ::data_heap
{ {
private: private:
size_t initial_size = 0;
bool mapped = false; bool mapped = false;
void *_ptr = nullptr; void *_ptr = nullptr;
@ -3431,6 +3432,7 @@ public:
} }
heap = std::make_unique<buffer>(*device, size, memory_index, memory_flags, usage, 0); heap = std::make_unique<buffer>(*device, size, memory_index, memory_flags, usage, 0);
initial_size = size;
} }
void destroy() void destroy()
@ -3497,6 +3499,20 @@ public:
VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT); VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT);
} }
} }
bool is_critical() const override
{
if (!::data_heap::is_critical())
return false;
// By default, allow the size to grow upto 8x larger
// This value is arbitrary, theoretically it is possible to allow infinite stretching to improve performance
const size_t soft_limit = initial_size * 8;
if ((m_size + m_min_guard_size) < soft_limit)
return false;
return true;
}
}; };
struct blitter struct blitter