also don't search in the shader cache if the shader isn't changed
This commit is contained in:
parent
9165ac5a67
commit
bb200acdd8
|
@ -21,7 +21,7 @@
|
||||||
namespace OGL
|
namespace OGL
|
||||||
{
|
{
|
||||||
|
|
||||||
GLuint ProgramShaderCache::CurrentFShader = 0, ProgramShaderCache::CurrentVShader = 0, ProgramShaderCache::CurrentProgram = 0;
|
GLuint ProgramShaderCache::CurrentProgram = 0;
|
||||||
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
|
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
|
||||||
GLuint ProgramShaderCache::s_ps_vs_ubo;
|
GLuint ProgramShaderCache::s_ps_vs_ubo;
|
||||||
GLintptr ProgramShaderCache::s_vs_data_offset;
|
GLintptr ProgramShaderCache::s_vs_data_offset;
|
||||||
|
@ -136,25 +136,23 @@ void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentFShader = PS;
|
std::pair<u32, u32> ShaderPair = std::make_pair(PS, VS);
|
||||||
CurrentVShader = VS;
|
|
||||||
|
// program is already bound
|
||||||
|
if(ShaderPair == CurrentShaderProgram) return;
|
||||||
|
|
||||||
// We have a valid shaders, let's create our program
|
|
||||||
std::pair<u32, u32> ShaderPair = std::make_pair(CurrentFShader, CurrentVShader);
|
|
||||||
PCache::iterator iter = pshaders.find(ShaderPair);
|
PCache::iterator iter = pshaders.find(ShaderPair);
|
||||||
if (iter != pshaders.end())
|
if (iter != pshaders.end())
|
||||||
{
|
{
|
||||||
PCacheEntry &entry = iter->second;
|
PCacheEntry &entry = iter->second;
|
||||||
if(CurrentProgram != entry.prog_id) {
|
glUseProgram(entry.prog_id);
|
||||||
glUseProgram(entry.prog_id);
|
CurrentProgram = entry.prog_id;
|
||||||
CurrentProgram = entry.prog_id;
|
CurrentShaderProgram = ShaderPair;
|
||||||
CurrentShaderProgram = ShaderPair;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PCacheEntry entry;
|
PCacheEntry entry;
|
||||||
entry.Create(CurrentFShader, CurrentVShader);
|
entry.Create(PS, VS);
|
||||||
|
|
||||||
// Right, the program is created now
|
// Right, the program is created now
|
||||||
// Let's attach everything
|
// Let's attach everything
|
||||||
|
@ -253,6 +251,7 @@ void ProgramShaderCache::Init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentProgram = 0;
|
CurrentProgram = 0;
|
||||||
|
CurrentShaderProgram = std::pair<u32,u32>(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramShaderCache::Shutdown(void)
|
void ProgramShaderCache::Shutdown(void)
|
||||||
|
@ -270,6 +269,8 @@ void ProgramShaderCache::Shutdown(void)
|
||||||
g_program_disk_cache.Close();
|
g_program_disk_cache.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glUseProgram(0);
|
||||||
|
|
||||||
PCache::iterator iter = pshaders.begin();
|
PCache::iterator iter = pshaders.begin();
|
||||||
for (; iter != pshaders.end(); ++iter)
|
for (; iter != pshaders.end(); ++iter)
|
||||||
iter->second.Destroy();
|
iter->second.Destroy();
|
||||||
|
|
|
@ -150,7 +150,7 @@ private:
|
||||||
typedef std::map<ShaderUID, PCacheEntry> PCache;
|
typedef std::map<ShaderUID, PCacheEntry> PCache;
|
||||||
|
|
||||||
static PCache pshaders;
|
static PCache pshaders;
|
||||||
static GLuint CurrentFShader, CurrentVShader, CurrentProgram;
|
static GLuint CurrentProgram;
|
||||||
static ShaderUID CurrentShaderProgram;
|
static ShaderUID CurrentShaderProgram;
|
||||||
|
|
||||||
static GLuint s_ps_vs_ubo;
|
static GLuint s_ps_vs_ubo;
|
||||||
|
|
Loading…
Reference in New Issue