rsx: Implement deferred request size io buffer where we do not know the size beforehand.

This commit is contained in:
kd-11 2024-04-19 04:16:13 +03:00 committed by kd-11
parent 406a519400
commit 96793193b5
2 changed files with 10 additions and 4 deletions

View File

@ -22,7 +22,8 @@ namespace rsx
mutable void* m_ptr = nullptr; mutable void* m_ptr = nullptr;
mutable usz m_size = 0; mutable usz m_size = 0;
std::function<std::tuple<void*, usz>()> m_allocator{}; std::function<std::tuple<void*, usz>(usz)> m_allocator{};
mutable usz m_allocation_size = 0u;
public: public:
io_buffer() = default; io_buffer() = default;
@ -34,7 +35,7 @@ namespace rsx
m_size = container.size_bytes(); m_size = container.size_bytes();
} }
io_buffer(std::function<std::tuple<void*, usz> ()> allocator) io_buffer(std::function<std::tuple<void*, usz>(usz)> allocator)
{ {
ensure(allocator); ensure(allocator);
m_allocator = allocator; m_allocator = allocator;
@ -50,6 +51,11 @@ namespace rsx
: m_ptr(const_cast<void*>(ptr)), m_size(size) : m_ptr(const_cast<void*>(ptr)), m_size(size)
{} {}
void reserve(usz size) const
{
m_allocation_size = size;
}
std::pair<void*, usz> raw() const std::pair<void*, usz> raw() const
{ {
return { m_ptr, m_size }; return { m_ptr, m_size };
@ -60,7 +66,7 @@ namespace rsx
{ {
if (!m_ptr && m_allocator) if (!m_ptr && m_allocator)
{ {
std::tie(m_ptr, m_size) = m_allocator(); std::tie(m_ptr, m_size) = m_allocator(m_allocation_size);
} }
return static_cast<T*>(m_ptr); return static_cast<T*>(m_ptr);

View File

@ -1014,7 +1014,7 @@ namespace vk
check_caps = false; check_caps = false;
} }
auto buf_allocator = [&]() -> std::tuple<void*, usz> auto buf_allocator = [&](usz) -> std::tuple<void*, usz>
{ {
if (image_setup_flags & source_is_gpu_resident) if (image_setup_flags & source_is_gpu_resident)
{ {