only change shader if needed
This commit is contained in:
parent
85200db6a2
commit
687d74e6c2
|
@ -131,26 +131,25 @@ void ProgramShaderCache::SetProgramBindings ( ProgramShaderCache::PCacheEntry& e
|
|||
|
||||
void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
|
||||
{
|
||||
CurrentFShader = PS;
|
||||
CurrentVShader = VS;
|
||||
|
||||
if (CurrentFShader == 0 && CurrentVShader == 0)
|
||||
{
|
||||
CurrentProgram = 0;
|
||||
glUseProgram(0);
|
||||
if(!PS || !VS) {
|
||||
ERROR_LOG(VIDEO, "tried to bind a zero shader");
|
||||
return;
|
||||
}
|
||||
|
||||
// Fragment shaders can survive without Vertex Shaders
|
||||
// We have a valid fragment shader, let's create our program
|
||||
CurrentFShader = PS;
|
||||
CurrentVShader = VS;
|
||||
|
||||
// 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);
|
||||
if (iter != pshaders.end())
|
||||
{
|
||||
PCacheEntry &entry = iter->second;
|
||||
if(CurrentProgram != entry.prog_id) {
|
||||
glUseProgram(entry.prog_id);
|
||||
CurrentShaderProgram = ShaderPair;
|
||||
CurrentProgram = entry.prog_id;
|
||||
CurrentShaderProgram = ShaderPair;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -159,9 +158,7 @@ void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
|
|||
|
||||
// Right, the program is created now
|
||||
// Let's attach everything
|
||||
if (entry.vsid != 0) // attaching zero vertex shader makes it freak out
|
||||
glAttachShader(entry.prog_id, entry.vsid);
|
||||
|
||||
glAttachShader(entry.prog_id, entry.psid);
|
||||
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLCache)
|
||||
|
@ -254,6 +251,8 @@ void ProgramShaderCache::Init(void)
|
|||
ProgramShaderCacheInserter inserter;
|
||||
g_program_disk_cache.OpenAndRead(cache_filename, inserter);
|
||||
}
|
||||
|
||||
CurrentProgram = 0;
|
||||
}
|
||||
|
||||
void ProgramShaderCache::Shutdown(void)
|
||||
|
|
|
@ -283,8 +283,6 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta
|
|||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glDrawArrays(GL_TRIANGLES, 0, usage/4);
|
||||
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1412,8 +1412,6 @@ void Renderer::ResetAPIState()
|
|||
{
|
||||
// Gets us to a reasonably sane state where it's possible to do things like
|
||||
// image copies with textured quads, etc.
|
||||
ProgramShaderCache::SetBothShaders(0, 0);
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
@ -1435,8 +1433,6 @@ void Renderer::RestoreAPIState()
|
|||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, g_ActiveConfig.bWireFrame ? GL_LINE : GL_FILL);
|
||||
|
||||
ProgramShaderCache::SetBothShaders(0, 0);
|
||||
|
||||
VertexManager *vm = (OGL::VertexManager*)g_vertex_manager;
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vm->m_vertex_buffers);
|
||||
vm->m_last_vao = 0;
|
||||
|
|
Loading…
Reference in New Issue