Write all shaders to disk on emulator stop instead of constantly. Also change pair from u64 to u32.

This commit is contained in:
Ryan Houdek 2011-12-24 02:19:30 -06:00
parent b90fa37c60
commit aa2032af2c
2 changed files with 10 additions and 8 deletions

View File

@ -29,7 +29,7 @@ namespace OGL
LinearDiskCache<PROGRAMUID, u8> g_program_disk_cache;
GLenum ProgramFormat;
std::pair<u64, u64> ProgramShaderCache::CurrentShaderProgram;
std::pair<u32, u32> 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<u64, u64> ShaderPair = std::make_pair(uid.uid.psid, uid.uid.vsid);
std::pair<u32, u32> 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();
}

View File

@ -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<std::pair<u64, u64>, PCacheEntry> PCache;
typedef std::map<std::pair<u32, u32>, PCacheEntry> PCache;
static PCache pshaders;
static GLuint CurrentFShader, CurrentVShader, CurrentProgram;
static std::pair<u64, u64> CurrentShaderProgram;
static std::pair<u32, u32> CurrentShaderProgram;
static GLuint s_ps_vs_ubo;
static GLintptr s_vs_data_offset;