From 96793193b5addb6c630773327b69b9ad4ce94c37 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Fri, 19 Apr 2024 04:16:13 +0300 Subject: [PATCH] rsx: Implement deferred request size io buffer where we do not know the size beforehand. --- rpcs3/Emu/RSX/Common/io_buffer.h | 12 +++++++++--- rpcs3/Emu/RSX/VK/VKTexture.cpp | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/io_buffer.h b/rpcs3/Emu/RSX/Common/io_buffer.h index 7029608f6e..612777f463 100644 --- a/rpcs3/Emu/RSX/Common/io_buffer.h +++ b/rpcs3/Emu/RSX/Common/io_buffer.h @@ -22,7 +22,8 @@ namespace rsx mutable void* m_ptr = nullptr; mutable usz m_size = 0; - std::function()> m_allocator{}; + std::function(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 ()> allocator) + io_buffer(std::function(usz)> allocator) { ensure(allocator); m_allocator = allocator; @@ -50,6 +51,11 @@ namespace rsx : m_ptr(const_cast(ptr)), m_size(size) {} + void reserve(usz size) const + { + m_allocation_size = size; + } + std::pair 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(m_ptr); diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index 5262fabf79..3353dcf341 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -1014,7 +1014,7 @@ namespace vk check_caps = false; } - auto buf_allocator = [&]() -> std::tuple + auto buf_allocator = [&](usz) -> std::tuple { if (image_setup_flags & source_is_gpu_resident) {