From c5a65111c49cde3dc7f570e290b18d58885df84d Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 14 Feb 2018 20:18:39 +0300 Subject: [PATCH] 0029508: Visualization, TKOpenGl - visual artifacts on Adreno 305/308 OpenGl_ShaderManager now: - prefers GLSL ES 100 over GLSL ES 300 on devices reporting OpenGL ES 3.0; - prefers GLSL ES 300 on devices reporting OpenGL ES 3.1+. to workaround known buggy implementations of OpenGL ES 3.0 drivers. --- src/OpenGl/OpenGl_ShaderManager.cxx | 39 ++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/OpenGl/OpenGl_ShaderManager.cxx b/src/OpenGl/OpenGl_ShaderManager.cxx index a664c0751b..1b6d056558 100644 --- a/src/OpenGl/OpenGl_ShaderManager.cxx +++ b/src/OpenGl/OpenGl_ShaderManager.cxx @@ -1197,8 +1197,10 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont() aProgramSrc->SetHeader ("#version 150"); } #else - if (myContext->IsGlGreaterEqual (3, 0)) + if (myContext->IsGlGreaterEqual (3, 1)) { + // prefer "100 es" on OpenGL ES 3.0 devices + // and "300 es" on newer devices (3.1+) aProgramSrc->SetHeader ("#version 300 es"); } #endif @@ -1532,6 +1534,12 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFlat (Handle(OpenGl_Shad { aProgramSrc->SetNbFragmentOutputs (2); aProgramSrc->SetWeightOitOutput (true); + #if defined(GL_ES_VERSION_2_0) + if (myContext->IsGlGreaterEqual (3, 0)) + { + aProgramSrc->SetHeader ("#version 300 es"); + } + #endif } TCollection_AsciiString aSrcVertEndMain; @@ -1541,6 +1549,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFlat (Handle(OpenGl_Shad #if defined(GL_ES_VERSION_2_0) if (myContext->IsGlGreaterEqual (3, 0)) { + aProgramSrc->SetHeader ("#version 300 es"); hasGlslBitOps = true; } #else @@ -1611,8 +1620,10 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFlat (Handle(OpenGl_Shad aProgramSrc->SetHeader ("#version 150"); } #else - if (myContext->IsGlGreaterEqual (3, 0)) + if (myContext->IsGlGreaterEqual (3, 1)) { + // prefer "100 es" on OpenGL ES 3.0 devices + // and "300 es" on newer devices (3.1+) aProgramSrc->SetHeader ("#version 300 es"); } #endif @@ -1885,6 +1896,12 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S { aProgramSrc->SetNbFragmentOutputs (2); aProgramSrc->SetWeightOitOutput (true); + #if defined(GL_ES_VERSION_2_0) + if (myContext->IsGlGreaterEqual (3, 0)) + { + aProgramSrc->SetHeader ("#version 300 es"); + } + #endif } Standard_Integer aNbLights = 0; @@ -1929,8 +1946,10 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S aProgramSrc->SetHeader ("#version 150"); } #else - if (myContext->IsGlGreaterEqual (3, 0)) + if (myContext->IsGlGreaterEqual (3, 1)) { + // prefer "100 es" on OpenGL ES 3.0 devices + // and "300 es" on newer devices (3.1+) aProgramSrc->SetHeader ("#version 300 es"); } #endif @@ -2089,13 +2108,19 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha aProgramSrc->SetHeader ("#version 150"); } #else - if (myContext->IsGlGreaterEqual (3, 0)) + if (myContext->IsGlGreaterEqual (3, 1)) { + // prefer "100 es" on OpenGL ES 3.0 devices + // and "300 es" on newer devices (3.1+) aProgramSrc->SetHeader ("#version 300 es"); } else if (isFlatNormal) { - if (myContext->oesStdDerivatives) + if (myContext->IsGlGreaterEqual (3, 0)) + { + aProgramSrc->SetHeader ("#version 300 es"); + } + else if (myContext->oesStdDerivatives) { aProgramSrc->SetHeader ("#extension GL_OES_standard_derivatives : enable"); } @@ -2325,8 +2350,10 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh aProgramSrc->SetHeader ("#version 150"); } #else - if (myContext->IsGlGreaterEqual (3, 0)) + if (myContext->IsGlGreaterEqual (3, 1)) { + // prefer "100 es" on OpenGL ES 3.0 devices + // and "300 es" on newer devices (3.1+) aProgramSrc->SetHeader ("#version 300 es"); } #endif