summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvnflinger/parcel.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/core/hle/service/nvnflinger/parcel.h b/src/core/hle/service/nvnflinger/parcel.h
index 23ba315a0..e2c9bbd50 100644
--- a/src/core/hle/service/nvnflinger/parcel.h
+++ b/src/core/hle/service/nvnflinger/parcel.h
@@ -6,6 +6,7 @@
6#include <memory> 6#include <memory>
7#include <span> 7#include <span>
8#include <vector> 8#include <vector>
9
9#include <boost/container/small_vector.hpp> 10#include <boost/container/small_vector.hpp>
10 11
11#include "common/alignment.h" 12#include "common/alignment.h"
@@ -148,9 +149,9 @@ public:
148 this->WriteImpl(0U, m_object_buffer); 149 this->WriteImpl(0U, m_object_buffer);
149 } 150 }
150 151
151 std::vector<u8> Serialize() const { 152 std::span<u8> Serialize() {
152 std::vector<u8> output_buffer(sizeof(ParcelHeader) + m_data_buffer.size() + 153 m_output_buffer.resize(sizeof(ParcelHeader) + m_data_buffer.size() +
153 m_object_buffer.size()); 154 m_object_buffer.size());
154 155
155 ParcelHeader header{}; 156 ParcelHeader header{};
156 header.data_size = static_cast<u32>(m_data_buffer.size()); 157 header.data_size = static_cast<u32>(m_data_buffer.size());
@@ -158,17 +159,17 @@ public:
158 header.objects_size = static_cast<u32>(m_object_buffer.size()); 159 header.objects_size = static_cast<u32>(m_object_buffer.size());
159 header.objects_offset = header.data_offset + header.data_size; 160 header.objects_offset = header.data_offset + header.data_size;
160 161
161 std::memcpy(output_buffer.data(), &header, sizeof(header)); 162 std::memcpy(m_output_buffer.data(), &header, sizeof(ParcelHeader));
162 std::ranges::copy(m_data_buffer, output_buffer.data() + header.data_offset); 163 std::ranges::copy(m_data_buffer, m_output_buffer.data() + header.data_offset);
163 std::ranges::copy(m_object_buffer, output_buffer.data() + header.objects_offset); 164 std::ranges::copy(m_object_buffer, m_output_buffer.data() + header.objects_offset);
164 165
165 return output_buffer; 166 return m_output_buffer;
166 } 167 }
167 168
168private: 169private:
169 template <typename T> 170 template <typename T, size_t BufferSize>
170 requires(std::is_trivially_copyable_v<T>) 171 requires(std::is_trivially_copyable_v<T>)
171 void WriteImpl(const T& val, boost::container::small_vector<u8, 0x200>& buffer) { 172 void WriteImpl(const T& val, boost::container::small_vector<u8, BufferSize>& buffer) {
172 const size_t aligned_size = Common::AlignUp(sizeof(T), 4); 173 const size_t aligned_size = Common::AlignUp(sizeof(T), 4);
173 const size_t old_size = buffer.size(); 174 const size_t old_size = buffer.size();
174 buffer.resize(old_size + aligned_size); 175 buffer.resize(old_size + aligned_size);
@@ -177,8 +178,9 @@ private:
177 } 178 }
178 179
179private: 180private:
180 boost::container::small_vector<u8, 0x200> m_data_buffer; 181 boost::container::small_vector<u8, 0x1B0> m_data_buffer;
181 boost::container::small_vector<u8, 0x200> m_object_buffer; 182 boost::container::small_vector<u8, 0x40> m_object_buffer;
183 boost::container::small_vector<u8, 0x200> m_output_buffer;
182}; 184};
183 185
184} // namespace Service::android 186} // namespace Service::android