From 8f818af6d251dfadc67a12e482ffdbfd035a6717 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 23 May 2026 12:41:00 +1000 Subject: [PATCH] GPU/HW: Remove unnecessary reference to backend in texture cache --- src/core/gpu_hw.cpp | 4 ++-- src/core/gpu_hw_texture_cache.cpp | 10 +++------- src/core/gpu_hw_texture_cache.h | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 21a79df9e..3ba568873 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -322,7 +322,7 @@ bool GPU_HW::Initialize(bool upload_vram, Error* error) if (m_use_texture_cache) { - if (!GPUTextureCache::Initialize(this, error)) + if (!GPUTextureCache::Initialize(error)) return false; } else @@ -681,7 +681,7 @@ bool GPU_HW::UpdateSettings(const GPUSettings& old_settings, Error* error) if (m_use_texture_cache && !old_settings.gpu_texture_cache) { - if (!GPUTextureCache::Initialize(this, error)) + if (!GPUTextureCache::Initialize(error)) { Error::AddPrefix(error, "Failed to initialize texture cache: "); return false; diff --git a/src/core/gpu_hw_texture_cache.cpp b/src/core/gpu_hw_texture_cache.cpp index a16476619..879323d87 100644 --- a/src/core/gpu_hw_texture_cache.cpp +++ b/src/core/gpu_hw_texture_cache.cpp @@ -540,7 +540,6 @@ struct GPUTextureCacheState GPUTextureFormat hash_cache_texture_format = GPUTextureFormat::Unknown; HashCache hash_cache; - GPU_HW* hw_backend = nullptr; // TODO:FIXME: remove me /// List of candidates for purging when the hash cache gets too large. std::vector> hash_cache_purge_list; @@ -597,10 +596,8 @@ bool GPUTextureCache::IsDumpingVRAMWriteTextures() return (g_gpu_settings.texture_replacements.dump_textures && !s_state.config.dump_texture_pages); } -bool GPUTextureCache::Initialize(GPU_HW* backend, Error* error) +bool GPUTextureCache::Initialize(Error* error) { - s_state.hw_backend = backend; - SetHashCacheTextureFormat(); // note: safe because the CPU thread is waiting for the GPU thread to finish initializing @@ -828,7 +825,6 @@ void GPUTextureCache::Shutdown() s_state.hash_cache_purge_list = {}; s_state.temp_vram_write_list = {}; s_state.track_vram_writes = false; - s_state.hw_backend = nullptr; for (auto it = s_state.gpu_replacement_image_cache.begin(); it != s_state.gpu_replacement_image_cache.end();) { @@ -3895,5 +3891,5 @@ void GPUTextureCache::ApplyTextureReplacements(SourceKey key, HashType tex_hash, g_gpu_device->RecycleTexture(std::move(entry->texture)); entry->texture = std::move(replacement_tex); - s_state.hw_backend->RestoreDeviceContext(); -} \ No newline at end of file + static_cast(VideoThread::GetGPUBackend())->RestoreDeviceContext(); +} diff --git a/src/core/gpu_hw_texture_cache.h b/src/core/gpu_hw_texture_cache.h index f7d103d2d..97fd9a6fa 100644 --- a/src/core/gpu_hw_texture_cache.h +++ b/src/core/gpu_hw_texture_cache.h @@ -106,7 +106,7 @@ struct Source TListNode hash_cache_ref; }; -bool Initialize(GPU_HW* backend, Error* error); +bool Initialize(Error* error); bool UpdateSettings(bool use_texture_cache, const GPUSettings& old_settings, Error* error); bool GetStateSize(StateWrapper& sw, u32* size);