mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 02:47:02 +02:00
refactor renderer
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "graphics/host_gpu/pageManager.h"
|
||||
#include "graphics/host_gpu/rangeSet.h"
|
||||
#include "graphics/host_gpu/regionManager.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -10,6 +11,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace Libs::Graphics {
|
||||
@@ -38,6 +40,10 @@ public:
|
||||
PageFaultPhase phase) noexcept;
|
||||
[[nodiscard]] bool InvalidateVirtualGpuWrite(PageFaultAccess access, uint64_t vaddr,
|
||||
uint64_t size, PageFaultPhase phase) noexcept;
|
||||
void ValidateGpuDirtyPages(const RangeSet& dirty, uint64_t vaddr, uint64_t size,
|
||||
const char* operation) const noexcept;
|
||||
void ValidateGpuDirtyOwnership(const RangeSet& dirty, uint64_t vaddr, uint64_t size,
|
||||
const char* operation);
|
||||
|
||||
template <bool clear, typename Preflight, typename Func>
|
||||
void ForEachDownloadRange(uint64_t vaddr, uint64_t size, Preflight&& preflight, Func&& func) {
|
||||
@@ -99,7 +105,7 @@ public:
|
||||
std::unique_lock access(m_access_mutex);
|
||||
RequireMapped(vaddr, size);
|
||||
Iterate<true>(vaddr, size, [](RegionManager*, uint64_t, uint64_t) {});
|
||||
s_upload_owner = this;
|
||||
const auto* previous_upload_owner = std::exchange(s_upload_owner, this);
|
||||
Iterate<false>(vaddr, size, [&](RegionManager* manager, uint64_t offset, uint64_t bytes) {
|
||||
manager->lock.lock();
|
||||
manager->Track(manager->GetCpuAddr() + offset, bytes);
|
||||
@@ -119,15 +125,15 @@ public:
|
||||
manager->lock.unlock();
|
||||
});
|
||||
}
|
||||
s_upload_owner = nullptr;
|
||||
s_upload_owner = previous_upload_owner;
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr size_t REGION_COUNT = TRACKER_ADDRESS_SIZE / TRACKER_REGION_SIZE;
|
||||
inline static thread_local const MemoryTracker* s_upload_owner = nullptr;
|
||||
|
||||
static void CheckNotInUploadCallback() noexcept {
|
||||
if (s_upload_owner != nullptr) {
|
||||
void CheckNotInUploadCallback() const noexcept {
|
||||
if (s_upload_owner == this) {
|
||||
EXIT("memory tracker re-entered from upload callback\n");
|
||||
}
|
||||
}
|
||||
@@ -167,7 +173,9 @@ private:
|
||||
void RequireMapped(uint64_t vaddr, uint64_t size) const {
|
||||
ValidateRange(vaddr, size);
|
||||
if (!m_page_manager.IsMapped(vaddr, size)) {
|
||||
EXIT("memory tracker range is not mapped\n");
|
||||
EXIT("memory tracker range [0x%llx, 0x%llx) is not mapped\n",
|
||||
static_cast<unsigned long long>(vaddr),
|
||||
static_cast<unsigned long long>(vaddr + size));
|
||||
}
|
||||
}
|
||||
RegionManager* GetOrCreateRegion(uint64_t index);
|
||||
|
||||
Reference in New Issue
Block a user