texture_cache: Query MemoryManager from the system
This commit is contained in:
parent
7565389700
commit
58c8a44e7a
5 changed files with 7 additions and 20 deletions
|
@ -32,7 +32,6 @@ u32 FramebufferConfig::BytesPerPixel(PixelFormat format) {
|
||||||
GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer) : renderer{renderer} {
|
GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer) : renderer{renderer} {
|
||||||
auto& rasterizer{renderer.Rasterizer()};
|
auto& rasterizer{renderer.Rasterizer()};
|
||||||
memory_manager = std::make_unique<Tegra::MemoryManager>(rasterizer);
|
memory_manager = std::make_unique<Tegra::MemoryManager>(rasterizer);
|
||||||
rasterizer.InitMemoryMananger(*memory_manager);
|
|
||||||
dma_pusher = std::make_unique<Tegra::DmaPusher>(*this);
|
dma_pusher = std::make_unique<Tegra::DmaPusher>(*this);
|
||||||
maxwell_3d = std::make_unique<Engines::Maxwell3D>(system, rasterizer, *memory_manager);
|
maxwell_3d = std::make_unique<Engines::Maxwell3D>(system, rasterizer, *memory_manager);
|
||||||
fermi_2d = std::make_unique<Engines::Fermi2D>(rasterizer, *memory_manager);
|
fermi_2d = std::make_unique<Engines::Fermi2D>(rasterizer, *memory_manager);
|
||||||
|
|
|
@ -28,8 +28,6 @@ class RasterizerInterface {
|
||||||
public:
|
public:
|
||||||
virtual ~RasterizerInterface() {}
|
virtual ~RasterizerInterface() {}
|
||||||
|
|
||||||
virtual void InitMemoryMananger(Tegra::MemoryManager& memory_manager) = 0;
|
|
||||||
|
|
||||||
/// Draw the current batch of vertex arrays
|
/// Draw the current batch of vertex arrays
|
||||||
virtual void DrawArrays() = 0;
|
virtual void DrawArrays() = 0;
|
||||||
|
|
||||||
|
|
|
@ -97,10 +97,6 @@ RasterizerOpenGL::RasterizerOpenGL(Core::System& system, Core::Frontend::EmuWind
|
||||||
|
|
||||||
RasterizerOpenGL::~RasterizerOpenGL() {}
|
RasterizerOpenGL::~RasterizerOpenGL() {}
|
||||||
|
|
||||||
void RasterizerOpenGL::InitMemoryMananger(Tegra::MemoryManager& memory_manager) {
|
|
||||||
texture_cache.InitMemoryMananger(memory_manager);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RasterizerOpenGL::CheckExtensions() {
|
void RasterizerOpenGL::CheckExtensions() {
|
||||||
if (!GLAD_GL_ARB_texture_filter_anisotropic && !GLAD_GL_EXT_texture_filter_anisotropic) {
|
if (!GLAD_GL_ARB_texture_filter_anisotropic && !GLAD_GL_EXT_texture_filter_anisotropic) {
|
||||||
LOG_WARNING(
|
LOG_WARNING(
|
||||||
|
|
|
@ -57,8 +57,6 @@ public:
|
||||||
ScreenInfo& info);
|
ScreenInfo& info);
|
||||||
~RasterizerOpenGL() override;
|
~RasterizerOpenGL() override;
|
||||||
|
|
||||||
void InitMemoryMananger(Tegra::MemoryManager& memory_manager) override;
|
|
||||||
|
|
||||||
void DrawArrays() override;
|
void DrawArrays() override;
|
||||||
void Clear() override;
|
void Clear() override;
|
||||||
void FlushAll() override;
|
void FlushAll() override;
|
||||||
|
|
|
@ -52,10 +52,6 @@ class TextureCache {
|
||||||
using IntervalType = typename IntervalMap::interval_type;
|
using IntervalType = typename IntervalMap::interval_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void InitMemoryMananger(Tegra::MemoryManager& memory_manager) {
|
|
||||||
this->memory_manager = &memory_manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InvalidateRegion(CacheAddr addr, std::size_t size) {
|
void InvalidateRegion(CacheAddr addr, std::size_t size) {
|
||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
|
|
||||||
|
@ -278,15 +274,16 @@ protected:
|
||||||
|
|
||||||
void Register(TSurface surface) {
|
void Register(TSurface surface) {
|
||||||
const GPUVAddr gpu_addr = surface->GetGpuAddr();
|
const GPUVAddr gpu_addr = surface->GetGpuAddr();
|
||||||
const CacheAddr cache_ptr = ToCacheAddr(memory_manager->GetPointer(gpu_addr));
|
const CacheAddr cache_ptr = ToCacheAddr(system.GPU().MemoryManager().GetPointer(gpu_addr));
|
||||||
const std::size_t size = surface->GetSizeInBytes();
|
const std::size_t size = surface->GetSizeInBytes();
|
||||||
const std::optional<VAddr> cpu_addr = memory_manager->GpuToCpuAddress(gpu_addr);
|
const std::optional<VAddr> cpu_addr =
|
||||||
|
system.GPU().MemoryManager().GpuToCpuAddress(gpu_addr);
|
||||||
if (!cache_ptr || !cpu_addr) {
|
if (!cache_ptr || !cpu_addr) {
|
||||||
LOG_CRITICAL(HW_GPU, "Failed to register surface with unmapped gpu_address 0x{:016x}",
|
LOG_CRITICAL(HW_GPU, "Failed to register surface with unmapped gpu_address 0x{:016x}",
|
||||||
gpu_addr);
|
gpu_addr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool continuouty = memory_manager->IsBlockContinuous(gpu_addr, size);
|
bool continuouty = system.GPU().MemoryManager().IsBlockContinuous(gpu_addr, size);
|
||||||
surface->MarkAsContinuous(continuouty);
|
surface->MarkAsContinuous(continuouty);
|
||||||
surface->SetCacheAddr(cache_ptr);
|
surface->SetCacheAddr(cache_ptr);
|
||||||
surface->SetCpuAddr(*cpu_addr);
|
surface->SetCpuAddr(*cpu_addr);
|
||||||
|
@ -552,7 +549,7 @@ private:
|
||||||
std::pair<TSurface, TView> GetSurface(const GPUVAddr gpu_addr, const SurfaceParams& params,
|
std::pair<TSurface, TView> GetSurface(const GPUVAddr gpu_addr, const SurfaceParams& params,
|
||||||
bool preserve_contents, bool is_render) {
|
bool preserve_contents, bool is_render) {
|
||||||
|
|
||||||
const auto host_ptr{memory_manager->GetPointer(gpu_addr)};
|
const auto host_ptr{system.GPU().MemoryManager().GetPointer(gpu_addr)};
|
||||||
const auto cache_addr{ToCacheAddr(host_ptr)};
|
const auto cache_addr{ToCacheAddr(host_ptr)};
|
||||||
|
|
||||||
// Step 0: guarantee a valid surface
|
// Step 0: guarantee a valid surface
|
||||||
|
@ -693,7 +690,7 @@ private:
|
||||||
|
|
||||||
void LoadSurface(const TSurface& surface) {
|
void LoadSurface(const TSurface& surface) {
|
||||||
staging_cache.GetBuffer(0).resize(surface->GetHostSizeInBytes());
|
staging_cache.GetBuffer(0).resize(surface->GetHostSizeInBytes());
|
||||||
surface->LoadBuffer(*memory_manager, staging_cache);
|
surface->LoadBuffer(system.GPU().MemoryManager(), staging_cache);
|
||||||
surface->UploadTexture(staging_cache.GetBuffer(0));
|
surface->UploadTexture(staging_cache.GetBuffer(0));
|
||||||
surface->MarkAsModified(false, Tick());
|
surface->MarkAsModified(false, Tick());
|
||||||
}
|
}
|
||||||
|
@ -704,7 +701,7 @@ private:
|
||||||
}
|
}
|
||||||
staging_cache.GetBuffer(0).resize(surface->GetHostSizeInBytes());
|
staging_cache.GetBuffer(0).resize(surface->GetHostSizeInBytes());
|
||||||
surface->DownloadTexture(staging_cache.GetBuffer(0));
|
surface->DownloadTexture(staging_cache.GetBuffer(0));
|
||||||
surface->FlushBuffer(*memory_manager, staging_cache);
|
surface->FlushBuffer(system.GPU().MemoryManager(), staging_cache);
|
||||||
surface->MarkAsModified(false, Tick());
|
surface->MarkAsModified(false, Tick());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,7 +775,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
VideoCore::RasterizerInterface& rasterizer;
|
VideoCore::RasterizerInterface& rasterizer;
|
||||||
Tegra::MemoryManager* memory_manager;
|
|
||||||
|
|
||||||
u64 ticks{};
|
u64 ticks{};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue