diff options
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index f6654f56c..494151eef 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "common/common_funcs.h" | 11 | #include "common/common_funcs.h" |
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 14 | #include "common/scratch_buffer.h" | ||
| 14 | #include "core/hle/ipc_helpers.h" | 15 | #include "core/hle/ipc_helpers.h" |
| 15 | #include "core/hle/kernel/hle_ipc.h" | 16 | #include "core/hle/kernel/hle_ipc.h" |
| 16 | #include "core/hle/kernel/k_auto_object.h" | 17 | #include "core/hle/kernel/k_auto_object.h" |
| @@ -346,20 +347,29 @@ std::vector<u8> HLERequestContext::ReadBufferCopy(std::size_t buffer_index) cons | |||
| 346 | } | 347 | } |
| 347 | 348 | ||
| 348 | std::span<const u8> HLERequestContext::ReadBuffer(std::size_t buffer_index) const { | 349 | std::span<const u8> HLERequestContext::ReadBuffer(std::size_t buffer_index) const { |
| 350 | static thread_local std::array<Common::ScratchBuffer<u8>, 2> read_buffer_a; | ||
| 351 | static thread_local std::array<Common::ScratchBuffer<u8>, 2> read_buffer_x; | ||
| 352 | |||
| 349 | const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && | 353 | const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && |
| 350 | BufferDescriptorA()[buffer_index].Size()}; | 354 | BufferDescriptorA()[buffer_index].Size()}; |
| 351 | if (is_buffer_a) { | 355 | if (is_buffer_a) { |
| 352 | ASSERT_OR_EXECUTE_MSG( | 356 | ASSERT_OR_EXECUTE_MSG( |
| 353 | BufferDescriptorA().size() > buffer_index, { return {}; }, | 357 | BufferDescriptorA().size() > buffer_index, { return {}; }, |
| 354 | "BufferDescriptorA invalid buffer_index {}", buffer_index); | 358 | "BufferDescriptorA invalid buffer_index {}", buffer_index); |
| 355 | const u8* const mem_ptr = memory.GetPointer(BufferDescriptorA()[buffer_index].Address()); | 359 | auto& read_buffer = read_buffer_a[buffer_index]; |
| 356 | return std::span<const u8>(mem_ptr, BufferDescriptorA()[buffer_index].Size()); | 360 | read_buffer.resize_destructive(BufferDescriptorA()[buffer_index].Size()); |
| 361 | memory.ReadBlock(BufferDescriptorA()[buffer_index].Address(), read_buffer.data(), | ||
| 362 | read_buffer.size()); | ||
| 363 | return read_buffer; | ||
| 357 | } else { | 364 | } else { |
| 358 | ASSERT_OR_EXECUTE_MSG( | 365 | ASSERT_OR_EXECUTE_MSG( |
| 359 | BufferDescriptorX().size() > buffer_index, { return {}; }, | 366 | BufferDescriptorX().size() > buffer_index, { return {}; }, |
| 360 | "BufferDescriptorX invalid buffer_index {}", buffer_index); | 367 | "BufferDescriptorX invalid buffer_index {}", buffer_index); |
| 361 | const u8* const mem_ptr = memory.GetPointer(BufferDescriptorX()[buffer_index].Address()); | 368 | auto& read_buffer = read_buffer_x[buffer_index]; |
| 362 | return std::span<const u8>(mem_ptr, BufferDescriptorX()[buffer_index].Size()); | 369 | read_buffer.resize_destructive(BufferDescriptorX()[buffer_index].Size()); |
| 370 | memory.ReadBlock(BufferDescriptorX()[buffer_index].Address(), read_buffer.data(), | ||
| 371 | read_buffer.size()); | ||
| 372 | return read_buffer; | ||
| 363 | } | 373 | } |
| 364 | } | 374 | } |
| 365 | 375 | ||