mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-12 04:35:56 +00:00
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* Readbacks proof of concept * liverpool: Use span for acb too * config: Add readbacks config option * config: Log readbacks
59 lines
1.7 KiB
C++
59 lines
1.7 KiB
C++
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include "common/alignment.h"
|
|
#include "common/types.h"
|
|
#include "video_core/buffer_cache//region_definitions.h"
|
|
|
|
namespace Vulkan {
|
|
class Rasterizer;
|
|
}
|
|
|
|
namespace VideoCore {
|
|
|
|
class PageManager {
|
|
// Use the same page size as the tracker.
|
|
static constexpr size_t PAGE_BITS = TRACKER_PAGE_BITS;
|
|
static constexpr size_t PAGE_SIZE = TRACKER_BYTES_PER_PAGE;
|
|
|
|
// Keep the lock granularity the same as region granularity. (since each regions has
|
|
// itself a lock)
|
|
static constexpr size_t PAGES_PER_LOCK = NUM_PAGES_PER_REGION;
|
|
|
|
public:
|
|
explicit PageManager(Vulkan::Rasterizer* rasterizer);
|
|
~PageManager();
|
|
|
|
/// Register a range of mapped gpu memory.
|
|
void OnGpuMap(VAddr address, size_t size);
|
|
|
|
/// Unregister a range of gpu memory that was unmapped.
|
|
void OnGpuUnmap(VAddr address, size_t size);
|
|
|
|
/// Updates watches in the pages touching the specified region.
|
|
template <bool track>
|
|
void UpdatePageWatchers(VAddr addr, u64 size) const;
|
|
|
|
/// Updates watches in the pages touching the specified region using a mask.
|
|
template <bool track, bool is_read = false>
|
|
void UpdatePageWatchersForRegion(VAddr base_addr, RegionBits& mask) const;
|
|
|
|
/// Returns page aligned address.
|
|
static constexpr VAddr GetPageAddr(VAddr addr) {
|
|
return Common::AlignDown(addr, PAGE_SIZE);
|
|
}
|
|
|
|
/// Returns address of the next page.
|
|
static constexpr VAddr GetNextPageAddr(VAddr addr) {
|
|
return Common::AlignUp(addr + 1, PAGE_SIZE);
|
|
}
|
|
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl;
|
|
};
|
|
|
|
} // namespace VideoCore
|