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 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:
io_buffer() = default;
@ -34,7 +35,7 @@ namespace rsx
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);
m_allocator = allocator;
@ -50,6 +51,11 @@ namespace rsx
: m_ptr(const_cast<void*>(ptr)), m_size(size)
{}
void reserve(usz size) const
{
m_allocation_size = size;
}
std::pair<void*, usz> raw() const
{
return { m_ptr, m_size };
@ -60,7 +66,7 @@ namespace rsx
{
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);

View file

@ -1014,7 +1014,7 @@ namespace vk
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)
{