void GSShaderOGL::UseProgram() { if (GLState::dirty_prog) { if (!GLLoader::found_GL_ARB_separate_shader_objects) { hash_map<uint64, GLuint >::iterator it; // Note: shader are integer lookup pointer. They start from 1 and incr // every time you create a new shader OR a new program. // Note2: vs & gs are precompiled at startup. FGLRX and radeon got value < 128. GS has only 2 programs // We migth be able to pack the value in a 32bits int // I would need to check the behavior on Nvidia (pause/resume). uint64 sel = (uint64)GLState::vs << 40 | (uint64)GLState::gs << 20 | GLState::ps; it = m_single_prog.find(sel); if (it == m_single_prog.end()) { GLState::program = LinkNewProgram(); m_single_prog[sel] = GLState::program; ValidateProgram(GLState::program); glUseProgram(GLState::program); } else { GLuint prog = it->second; if (prog != GLState::program) { GLState::program = prog; glUseProgram(GLState::program); } } } } GLState::dirty_prog = false; }
void GSShaderOGL::UseProgram() { if (GLState::dirty_prog) { if (!GLLoader::found_GL_ARB_separate_shader_objects) { GLState::dirty_subroutine_vs = true; GLState::dirty_subroutine_ps = true; GLState::dirty_ressources = true; hash_map<uint64, GLuint >::iterator it; // Note: shader are integer lookup pointer. They start from 1 and incr // every time you create a new shader OR a new program. // Note2: vs & gs are precompiled at startup. FGLRX and radeon got value < 128. // We migth be able to pack the value in a 32bits int // I would need to check the behavior on Nvidia (pause/resume). uint64 sel = (uint64)GLState::vs << 40 | (uint64)GLState::gs << 20 | GLState::ps; it = m_single_prog.find(sel); if (it == m_single_prog.end()) { GLState::program = LinkNewProgram(); m_single_prog[sel] = GLState::program; ValidateProgram(GLState::program); gl_UseProgram(GLState::program); // warning it must be done after the "setup" of the program SetupUniform(); } else { GLuint prog = it->second; if (prog != GLState::program) { GLState::program = prog; gl_UseProgram(GLState::program); } } } else { ValidatePipeline(m_pipeline); SetupUniform(); } } SetupRessources(); SetupSubroutineUniform(); GLState::dirty_prog = false; }