From 71e4119768a2b7cbba87d8313aca2da154aeffda Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 20:21:16 +0000 Subject: [PATCH] make virtual buffer become an optional --- src/common/host_memory.cpp | 2 +- src/common/host_memory.h | 3 ++- src/common/virtual_buffer.h | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 99070f02b2..3c66e4309f 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -713,7 +713,7 @@ private: HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_) : backing_size(backing_size_), virtual_size(virtual_size_) { #ifdef __OPENORBIS__ LOG_WARNING(HW_Memory, "Platform doesn't support fastmem"); - fallback_buffer = std::make_unique>(backing_size); + fallback_buffer.emplace(backing_size); backing_base = fallback_buffer->data(); virtual_base = nullptr; #else diff --git a/src/common/host_memory.h b/src/common/host_memory.h index 72fbb05af7..8788e32f01 100644 --- a/src/common/host_memory.h +++ b/src/common/host_memory.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include "common/common_funcs.h" #include "common/common_types.h" #include "common/virtual_buffer.h" @@ -81,7 +82,7 @@ private: size_t virtual_base_offset{}; // Fallback if fastmem is not supported on this platform - std::unique_ptr> fallback_buffer; + std::optional> fallback_buffer; }; } // namespace Common diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index 4f6e3e6e5c..74cc3a66f9 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -32,9 +32,10 @@ public: VirtualBuffer(const VirtualBuffer&) = delete; VirtualBuffer& operator=(const VirtualBuffer&) = delete; - VirtualBuffer(VirtualBuffer&& other) noexcept - : alloc_size{std::exchange(other.alloc_size, 0)}, base_ptr{std::exchange(other.base_ptr), - nullptr} {} + VirtualBuffer(VirtualBuffer&& other) noexcept { + alloc_size = std::exchange(other.alloc_size, 0); + base_ptr = std::exchange(other.base_ptr, nullptr); + } VirtualBuffer& operator=(VirtualBuffer&& other) noexcept { alloc_size = std::exchange(other.alloc_size, 0);