OGL: Move primitive restart enable logic to GLUtil

This commit is contained in:
Stenzek 2018-03-10 14:54:44 +10:00
parent 51a586d11a
commit 93ab50c555
4 changed files with 26 additions and 38 deletions

View File

@ -102,4 +102,27 @@ GLuint CompileProgram(const std::string& vertexShader, const std::string& fragme
return programID; return programID;
} }
void EnablePrimitiveRestart()
{
constexpr GLuint PRIMITIVE_RESTART_INDEX = 65535;
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
{
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
}
else
{
if (GLExtensions::Version() >= 310)
{
glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(PRIMITIVE_RESTART_INDEX);
}
else
{
glEnableClientState(GL_PRIMITIVE_RESTART_NV);
glPrimitiveRestartIndexNV(PRIMITIVE_RESTART_INDEX);
}
}
}
} }

View File

@ -12,4 +12,5 @@ namespace GLUtil
{ {
void InitInterface(); void InitInterface();
GLuint CompileProgram(const std::string& vertexShader, const std::string& fragmentShader); GLuint CompileProgram(const std::string& vertexShader, const std::string& fragmentShader);
void EnablePrimitiveRestart();
} }

View File

@ -824,25 +824,7 @@ bool SharedContextAsyncShaderCompiler::WorkerThreadInitWorkerThread(void* param)
s_is_shared_context = true; s_is_shared_context = true;
if (g_ActiveConfig.backend_info.bSupportsPrimitiveRestart) if (g_ActiveConfig.backend_info.bSupportsPrimitiveRestart)
{ GLUtil::EnablePrimitiveRestart();
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
{
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
}
else
{
if (GLExtensions::Version() >= 310)
{
glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(65535);
}
else
{
glEnableClientState(GL_PRIMITIVE_RESTART_NV);
glPrimitiveRestartIndexNV(65535);
}
}
}
return true; return true;
} }

View File

@ -788,25 +788,7 @@ Renderer::Renderer()
glClearDepthf(1.0f); glClearDepthf(1.0f);
if (g_ActiveConfig.backend_info.bSupportsPrimitiveRestart) if (g_ActiveConfig.backend_info.bSupportsPrimitiveRestart)
{ GLUtil::EnablePrimitiveRestart();
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
{
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
}
else
{
if (GLExtensions::Version() >= 310)
{
glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(65535);
}
else
{
glEnableClientState(GL_PRIMITIVE_RESTART_NV);
glPrimitiveRestartIndexNV(65535);
}
}
}
IndexGenerator::Init(); IndexGenerator::Init();
UpdateActiveConfig(); UpdateActiveConfig();