summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2022-12-29 00:24:57 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2022-12-29 00:46:54 +0100
commitb0722591c9b8c1aed5b8bfc5e67e7e957b08f209 (patch)
treedcab04b2e978ae9eb198264700fee2d817d2d6c0 /src/core
parenthle_ipc: Rename ReadBufferSpan to ReadBuffer (diff)
downloadyuzu-b0722591c9b8c1aed5b8bfc5e67e7e957b08f209.tar
yuzu-b0722591c9b8c1aed5b8bfc5e67e7e957b08f209.tar.gz
yuzu-b0722591c9b8c1aed5b8bfc5e67e7e957b08f209.tar.bz2
yuzu-b0722591c9b8c1aed5b8bfc5e67e7e957b08f209.tar.lz
yuzu-b0722591c9b8c1aed5b8bfc5e67e7e957b08f209.tar.xz
yuzu-b0722591c9b8c1aed5b8bfc5e67e7e957b08f209.tar.zst
yuzu-b0722591c9b8c1aed5b8bfc5e67e7e957b08f209.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp18
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 @@
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/logging/log.h"
+#include "common/scratch_buffer.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/hle_ipc.h"
#include "core/hle/kernel/k_auto_object.h"
@@ -346,20 +347,29 @@ std::vector<u8> HLERequestContext::ReadBufferCopy(std::size_t buffer_index) cons
}
std::span<const u8> HLERequestContext::ReadBuffer(std::size_t buffer_index) const {
+ static thread_local std::array<Common::ScratchBuffer<u8>, 2> read_buffer_a;
+ static thread_local std::array<Common::ScratchBuffer<u8>, 2> read_buffer_x;
+
const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
BufferDescriptorA()[buffer_index].Size()};
if (is_buffer_a) {
ASSERT_OR_EXECUTE_MSG(
BufferDescriptorA().size() > buffer_index, { return {}; },
"BufferDescriptorA invalid buffer_index {}", buffer_index);
- const u8* const mem_ptr = memory.GetPointer(BufferDescriptorA()[buffer_index].Address());
- return std::span<const u8>(mem_ptr, BufferDescriptorA()[buffer_index].Size());
+ auto& read_buffer = read_buffer_a[buffer_index];
+ read_buffer.resize_destructive(BufferDescriptorA()[buffer_index].Size());
+ memory.ReadBlock(BufferDescriptorA()[buffer_index].Address(), read_buffer.data(),
+ read_buffer.size());
+ return read_buffer;
} else {
ASSERT_OR_EXECUTE_MSG(
BufferDescriptorX().size() > buffer_index, { return {}; },
"BufferDescriptorX invalid buffer_index {}", buffer_index);
- const u8* const mem_ptr = memory.GetPointer(BufferDescriptorX()[buffer_index].Address());
- return std::span<const u8>(mem_ptr, BufferDescriptorX()[buffer_index].Size());
+ auto& read_buffer = read_buffer_x[buffer_index];
+ read_buffer.resize_destructive(BufferDescriptorX()[buffer_index].Size());
+ memory.ReadBlock(BufferDescriptorX()[buffer_index].Address(), read_buffer.data(),
+ read_buffer.size());
+ return read_buffer;
}
}