Browse Source

make virtual buffer become an optional

eden-orbis-ps4
lizzie 3 weeks ago
parent
commit
71e4119768
  1. 2
      src/common/host_memory.cpp
  2. 3
      src/common/host_memory.h
  3. 7
      src/common/virtual_buffer.h

2
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<Common::VirtualBuffer<u8>>(backing_size);
fallback_buffer.emplace(backing_size);
backing_base = fallback_buffer->data();
virtual_base = nullptr;
#else

3
src/common/host_memory.h

@ -4,6 +4,7 @@
#pragma once
#include <memory>
#include <optional>
#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<Common::VirtualBuffer<u8>> fallback_buffer;
std::optional<Common::VirtualBuffer<u8>> fallback_buffer;
};
} // namespace Common

7
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);

Loading…
Cancel
Save