summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/vulkan_common/vulkan_memory_allocator.cpp20
-rw-r--r--src/video_core/vulkan_common/vulkan_memory_allocator.h10
2 files changed, 15 insertions, 15 deletions
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp
index f15061d0c..d6eb3af31 100644
--- a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp
+++ b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp
@@ -71,7 +71,7 @@ public:
71 .end = *alloc + size, 71 .end = *alloc + size,
72 }; 72 };
73 commits.insert(std::ranges::upper_bound(commits, *alloc, {}, &Range::begin), range); 73 commits.insert(std::ranges::upper_bound(commits, *alloc, {}, &Range::begin), range);
74 return std::make_optional<MemoryCommit>(device, this, *memory, *alloc, *alloc + size); 74 return std::make_optional<MemoryCommit>(this, *memory, *alloc, *alloc + size);
75 } 75 }
76 76
77 void Free(u64 begin) { 77 void Free(u64 begin) {
@@ -127,9 +127,9 @@ private:
127 std::span<u8> memory_mapped_span; ///< Memory mapped span. Empty if not queried before. 127 std::span<u8> memory_mapped_span; ///< Memory mapped span. Empty if not queried before.
128}; 128};
129 129
130MemoryCommit::MemoryCommit(const Device& device_, MemoryAllocation* allocation_, 130MemoryCommit::MemoryCommit(MemoryAllocation* allocation_, VkDeviceMemory memory_, u64 begin_,
131 VkDeviceMemory memory_, u64 begin, u64 end) noexcept 131 u64 end_) noexcept
132 : device{&device_}, allocation{allocation_}, memory{memory_}, interval{begin, end} {} 132 : allocation{allocation_}, memory{memory_}, begin{begin_}, end{end_} {}
133 133
134MemoryCommit::~MemoryCommit() { 134MemoryCommit::~MemoryCommit() {
135 Release(); 135 Release();
@@ -137,28 +137,28 @@ MemoryCommit::~MemoryCommit() {
137 137
138MemoryCommit& MemoryCommit::operator=(MemoryCommit&& rhs) noexcept { 138MemoryCommit& MemoryCommit::operator=(MemoryCommit&& rhs) noexcept {
139 Release(); 139 Release();
140 device = rhs.device;
141 allocation = std::exchange(rhs.allocation, nullptr); 140 allocation = std::exchange(rhs.allocation, nullptr);
142 memory = rhs.memory; 141 memory = rhs.memory;
143 interval = rhs.interval; 142 begin = rhs.begin;
143 end = rhs.end;
144 span = std::exchange(rhs.span, std::span<u8>{}); 144 span = std::exchange(rhs.span, std::span<u8>{});
145 return *this; 145 return *this;
146} 146}
147 147
148MemoryCommit::MemoryCommit(MemoryCommit&& rhs) noexcept 148MemoryCommit::MemoryCommit(MemoryCommit&& rhs) noexcept
149 : device{rhs.device}, allocation{std::exchange(rhs.allocation, nullptr)}, memory{rhs.memory}, 149 : allocation{std::exchange(rhs.allocation, nullptr)}, memory{rhs.memory}, begin{rhs.begin},
150 interval{rhs.interval}, span{std::exchange(rhs.span, std::span<u8>{})} {} 150 end{rhs.end}, span{std::exchange(rhs.span, std::span<u8>{})} {}
151 151
152std::span<u8> MemoryCommit::Map() { 152std::span<u8> MemoryCommit::Map() {
153 if (span.empty()) { 153 if (span.empty()) {
154 span = allocation->Map().subspan(interval.first, interval.second - interval.first); 154 span = allocation->Map().subspan(begin, end - begin);
155 } 155 }
156 return span; 156 return span;
157} 157}
158 158
159void MemoryCommit::Release() { 159void MemoryCommit::Release() {
160 if (allocation) { 160 if (allocation) {
161 allocation->Free(interval.first); 161 allocation->Free(begin);
162 } 162 }
163} 163}
164 164
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.h b/src/video_core/vulkan_common/vulkan_memory_allocator.h
index d4e34c843..53b3b275a 100644
--- a/src/video_core/vulkan_common/vulkan_memory_allocator.h
+++ b/src/video_core/vulkan_common/vulkan_memory_allocator.h
@@ -29,8 +29,8 @@ enum class MemoryUsage {
29class MemoryCommit { 29class MemoryCommit {
30public: 30public:
31 explicit MemoryCommit() noexcept = default; 31 explicit MemoryCommit() noexcept = default;
32 explicit MemoryCommit(const Device& device_, MemoryAllocation* allocation_, 32 explicit MemoryCommit(MemoryAllocation* allocation_, VkDeviceMemory memory_, u64 begin_,
33 VkDeviceMemory memory_, u64 begin, u64 end) noexcept; 33 u64 end_) noexcept;
34 ~MemoryCommit(); 34 ~MemoryCommit();
35 35
36 MemoryCommit& operator=(MemoryCommit&&) noexcept; 36 MemoryCommit& operator=(MemoryCommit&&) noexcept;
@@ -50,16 +50,16 @@ public:
50 50
51 /// Returns the start position of the commit relative to the allocation. 51 /// Returns the start position of the commit relative to the allocation.
52 VkDeviceSize Offset() const { 52 VkDeviceSize Offset() const {
53 return static_cast<VkDeviceSize>(interval.first); 53 return static_cast<VkDeviceSize>(begin);
54 } 54 }
55 55
56private: 56private:
57 void Release(); 57 void Release();
58 58
59 const Device* device{}; ///< Vulkan device.
60 MemoryAllocation* allocation{}; ///< Pointer to the large memory allocation. 59 MemoryAllocation* allocation{}; ///< Pointer to the large memory allocation.
61 VkDeviceMemory memory{}; ///< Vulkan device memory handler. 60 VkDeviceMemory memory{}; ///< Vulkan device memory handler.
62 std::pair<u64, u64> interval{}; ///< Interval where the commit exists. 61 u64 begin{}; ///< Beginning offset in bytes to where the commit exists.
62 u64 end{}; ///< Offset in bytes where the commit ends.
63 std::span<u8> span; ///< Host visible memory span. Empty if not queried before. 63 std::span<u8> span; ///< Host visible memory span. Empty if not queried before.
64}; 64};
65 65