mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-16 04:00:04 +00:00
hle_ipc: Use thread_local ReadBuffer
This commit is contained in:
parent
a1490d77ac
commit
b0722591c9
@ -11,6 +11,7 @@
|
|||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
#include "core/hle/kernel/hle_ipc.h"
|
#include "core/hle/kernel/hle_ipc.h"
|
||||||
#include "core/hle/kernel/k_auto_object.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 {
|
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 &&
|
const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
|
||||||
BufferDescriptorA()[buffer_index].Size()};
|
BufferDescriptorA()[buffer_index].Size()};
|
||||||
if (is_buffer_a) {
|
if (is_buffer_a) {
|
||||||
ASSERT_OR_EXECUTE_MSG(
|
ASSERT_OR_EXECUTE_MSG(
|
||||||
BufferDescriptorA().size() > buffer_index, { return {}; },
|
BufferDescriptorA().size() > buffer_index, { return {}; },
|
||||||
"BufferDescriptorA invalid buffer_index {}", buffer_index);
|
"BufferDescriptorA invalid buffer_index {}", buffer_index);
|
||||||
const u8* const mem_ptr = memory.GetPointer(BufferDescriptorA()[buffer_index].Address());
|
auto& read_buffer = read_buffer_a[buffer_index];
|
||||||
return std::span<const u8>(mem_ptr, BufferDescriptorA()[buffer_index].Size());
|
read_buffer.resize_destructive(BufferDescriptorA()[buffer_index].Size());
|
||||||
|
memory.ReadBlock(BufferDescriptorA()[buffer_index].Address(), read_buffer.data(),
|
||||||
|
read_buffer.size());
|
||||||
|
return read_buffer;
|
||||||
} else {
|
} else {
|
||||||
ASSERT_OR_EXECUTE_MSG(
|
ASSERT_OR_EXECUTE_MSG(
|
||||||
BufferDescriptorX().size() > buffer_index, { return {}; },
|
BufferDescriptorX().size() > buffer_index, { return {}; },
|
||||||
"BufferDescriptorX invalid buffer_index {}", buffer_index);
|
"BufferDescriptorX invalid buffer_index {}", buffer_index);
|
||||||
const u8* const mem_ptr = memory.GetPointer(BufferDescriptorX()[buffer_index].Address());
|
auto& read_buffer = read_buffer_x[buffer_index];
|
||||||
return std::span<const u8>(mem_ptr, BufferDescriptorX()[buffer_index].Size());
|
read_buffer.resize_destructive(BufferDescriptorX()[buffer_index].Size());
|
||||||
|
memory.ReadBlock(BufferDescriptorX()[buffer_index].Address(), read_buffer.data(),
|
||||||
|
read_buffer.size());
|
||||||
|
return read_buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user