Browse Source

add WriteUnmanagedSpan

pull/3262/head
Maufeat 1 month ago
committed by crueter
parent
commit
7f1e82898c
  1. 4
      src/core/hle/service/nvnflinger/buffer_queue_producer.cpp
  2. 17
      src/core/hle/service/nvnflinger/parcel.h

4
src/core/hle/service/nvnflinger/buffer_queue_producer.cpp

@ -984,9 +984,7 @@ void BufferQueueProducer::Transact(u32 code, std::span<const u8> parcel_data,
parcel_out.Write(status); parcel_out.Write(status);
parcel_out.Write<s32>(static_cast<s32>(history.size())); parcel_out.Write<s32>(static_cast<s32>(history.size()));
for (const auto& rec : history) {
parcel_out.Write(rec);
}
parcel_out.WriteUnmanagedSpan<BufferHistoryInfo>(history);
break; break;
} }
default: default:

17
src/core/hle/service/nvnflinger/parcel.h

@ -129,6 +129,23 @@ public:
this->WriteImpl(val, m_data_buffer); this->WriteImpl(val, m_data_buffer);
} }
template <typename T>
void WriteUnmanagedSpan(std::span<const T> values) {
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable.");
if (values.empty()) {
return;
}
const size_t bytes = values.size_bytes();
const size_t old_size = m_data_buffer.size();
m_data_buffer.resize(old_size + bytes);
std::memcpy(m_data_buffer.data() + old_size, values.data(), bytes);
// Align the parcel stream once after the whole span.
const size_t aligned = Common::AlignUp(m_data_buffer.size(), 4);
m_data_buffer.resize(aligned);
}
template <typename T> template <typename T>
void WriteFlattenedObject(const T* ptr) { void WriteFlattenedObject(const T* ptr) {
if (!ptr) { if (!ptr) {

Loading…
Cancel
Save