From aa2032af2cc444fc0387d5aebcdd4b34b39d5277 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 24 Dec 2011 02:19:30 -0600 Subject: [PATCH] Write all shaders to disk on emulator stop instead of constantly. Also change pair from u64 to u32. --- .../Plugin_VideoOGL/Src/ProgramShaderCache.cpp | 13 +++++++------ .../Plugin_VideoOGL/Src/ProgramShaderCache.h | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index 628cbae865..6514e1e775 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -29,7 +29,7 @@ namespace OGL LinearDiskCache g_program_disk_cache; GLenum ProgramFormat; - std::pair ProgramShaderCache::CurrentShaderProgram; + std::pair ProgramShaderCache::CurrentShaderProgram; const char *UniformNames[NUM_UNIFORMS] = { // SAMPLERS "samp0","samp1","samp2","samp3","samp4","samp5","samp6","samp7", @@ -116,7 +116,7 @@ namespace OGL // Fragment shaders can survive without Vertex Shaders // We have a valid fragment shader, let's create our program - std::pair ShaderPair = std::make_pair(uid.uid.psid, uid.uid.vsid); + std::pair ShaderPair = std::make_pair(uid.uid.psid, uid.uid.vsid); PCache::iterator iter = pshaders.find(ShaderPair); if (iter != pshaders.end()) { @@ -129,6 +129,7 @@ namespace OGL PCacheEntry entry; entry.program.vsid = CurrentVShader; entry.program.psid = CurrentFShader; + entry.program.uid = uid; entry.program.glprogid = glCreateProgram(); // Right, the program is created now @@ -148,10 +149,6 @@ namespace OGL SetProgramVariables(entry, uid); - // Add it to our cache - if (g_ActiveConfig.backend_info.bSupportsGLSLCache) - g_program_disk_cache.Append(uid, entry.Data(), entry.Size()); - pshaders[ShaderPair] = entry; CurrentShaderProgram = ShaderPair; CurrentProgram = entry.program.glprogid; @@ -226,6 +223,10 @@ namespace OGL { if (g_ActiveConfig.backend_info.bSupportsGLSLCache) { + PCache::iterator iter = pshaders.begin(); + for (; iter != pshaders.end(); ++iter) + g_program_disk_cache.Append(iter->second.program.uid, iter->second.program.Data(), iter->second.program.Size()); + g_program_disk_cache.Sync(); g_program_disk_cache.Close(); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h index 51638cc1e4..59bcc8e295 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h @@ -75,6 +75,7 @@ struct PROGRAMSHADER PROGRAMSHADER() : glprogid(0), vsid(0), psid(0), binaryLength(0){} GLuint glprogid; // opengl program id GLuint vsid, psid; + PROGRAMUID uid; GLint UniformLocations[NUM_UNIFORMS]; GLint binaryLength; u8 *Data() @@ -152,11 +153,11 @@ class ProgramShaderCache } }; - typedef std::map, PCacheEntry> PCache; + typedef std::map, PCacheEntry> PCache; static PCache pshaders; static GLuint CurrentFShader, CurrentVShader, CurrentProgram; - static std::pair CurrentShaderProgram; + static std::pair CurrentShaderProgram; static GLuint s_ps_vs_ubo; static GLintptr s_vs_data_offset;