From 9bc8d6e02bf6349c70b68d884bdc666e8bfa6069 Mon Sep 17 00:00:00 2001 From: degasus Date: Tue, 26 Feb 2013 18:30:13 +0100 Subject: [PATCH] make samplercache global and call constructor/destructor --- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 6 +----- Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp | 2 ++ Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.h | 2 ++ Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 6 +++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 9670cc67d0..3196ad0886 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -129,8 +129,6 @@ static const u32 EFB_CACHE_HEIGHT = (EFB_HEIGHT + EFB_CACHE_RECT_SIZE - 1) / EFB static bool s_efbCacheValid[2][EFB_CACHE_WIDTH * EFB_CACHE_HEIGHT]; static std::vector s_efbCache[2][EFB_CACHE_WIDTH * EFB_CACHE_HEIGHT]; // 2 for PEEK_Z and PEEK_COLOR -static SamplerCache s_sampler_cache; - int GetNumMSAASamples(int MSAAMode) { switch (MSAAMode) @@ -374,8 +372,6 @@ void Renderer::Shutdown() delete s_pfont; s_pfont = 0; s_ShowEFBCopyRegions.Destroy(); - - s_sampler_cache.Clear(); } void Renderer::Init() @@ -1478,7 +1474,7 @@ void Renderer::SetSamplerState(int stage, int texindex) auto const& tm0 = tex.texMode0[stage]; auto const& tm1 = tex.texMode1[stage]; - s_sampler_cache.SetSamplerState((texindex * 4) + stage, tm0, tm1); + g_sampler_cache->SetSamplerState((texindex * 4) + stage, tm0, tm1); } void Renderer::SetInterlacingMode() diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp index d883d7e981..b007f89796 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp @@ -20,6 +20,8 @@ namespace OGL { +SamplerCache *g_sampler_cache; + SamplerCache::SamplerCache() : m_last_max_anisotropy() {} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.h b/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.h index 4666e5bf19..81180d2a7a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.h @@ -73,6 +73,8 @@ private: int m_last_max_anisotropy; }; +extern SamplerCache *g_sampler_cache; + } #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index c100721e6e..09482f00a9 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -91,6 +91,7 @@ Make AA apply instantly during gameplay if possible #include "FramebufferManager.h" #include "Core.h" #include "Host.h" +#include "SamplerCache.h" #include "VideoState.h" #include "VideoBackend.h" @@ -195,7 +196,8 @@ void VideoBackend::Video_Prepare() VertexShaderManager::Init(); PixelShaderManager::Init(); ProgramShaderCache::Init(); - g_texture_cache = new TextureCache; + g_texture_cache = new TextureCache(); + g_sampler_cache = new SamplerCache(); PostProcessing::Init(); Renderer::Init(); GL_REPORT_ERRORD(); @@ -229,6 +231,8 @@ void VideoBackend::Video_Cleanup() { Renderer::Shutdown(); TextureConverter::Shutdown(); VertexLoaderManager::Shutdown(); + delete g_sampler_cache; + g_sampler_cache = NULL; delete g_texture_cache; g_texture_cache = NULL; ProgramShaderCache::Shutdown();