GL: use unique_ptr for prgramBinaryCache

This commit is contained in:
goeiecool9999 2025-07-24 09:02:33 +02:00
parent 08609591ae
commit f6610b5b0c
2 changed files with 6 additions and 9 deletions

View file

@ -266,8 +266,8 @@ void RendererShaderGL::ShaderCacheLoading_begin(uint64 cacheTitleId)
{
const uint32 cacheMagic = GeneratePrecompiledCacheId();
const std::string cacheFilename = fmt::format("{:016x}_gl.bin", cacheTitleId);
s_programBinaryCache = FileCache::Open(ActiveSettings::GetCachePath("shaderCache/precompiled/{}", cacheFilename), true, cacheMagic);
if (s_programBinaryCache == nullptr)
s_programBinaryCache.reset(FileCache::Open(ActiveSettings::GetCachePath("shaderCache/precompiled/{}", cacheFilename), true, cacheMagic));
if (!s_programBinaryCache)
cemuLog_log(LogType::Force, "Unable to open OpenGL precompiled cache {}", cacheFilename);
}
s_isLoadingShaders = true;
@ -280,13 +280,10 @@ void RendererShaderGL::ShaderCacheLoading_end()
void RendererShaderGL::ShaderCacheLoading_Close()
{
if(s_programBinaryCache)
{
delete s_programBinaryCache;
s_programBinaryCache = nullptr;
}
s_programBinaryCache.reset();
g_compiled_shaders_total = 0;
g_compiled_shaders_async = 0;
}
FileCache* RendererShaderGL::s_programBinaryCache{};
std::unique_ptr<class FileCache> RendererShaderGL::s_programBinaryCache{};

View file

@ -37,6 +37,6 @@ private:
bool m_shader_attached{ false };
bool m_isCompiled{ false };
static class FileCache* s_programBinaryCache;
static std::unique_ptr<class FileCache> s_programBinaryCache;
};