Skip to content

Commit 6155050

Browse files
author
Rhys Weatherley
committed
Don't define highp/mediump/lowp if desktop GL has them
OpenGL 4.0 systems now have compatibility with ES2, including support for the precision qualifiers. If the GL_ARB_ES2_compatibility extension is present, then we don't define highp/mediump/lowp to the empty string. Task-number: QTBUG-12862 Reviewed-by: Sarah Smith
1 parent b0d2a43 commit 6155050

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

dist/changes-4.6.4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ QtNetwork
6363
QtOpenGL
6464
--------
6565

66-
- foo
67-
* bar
66+
- QGLShaderProgram
67+
* [QTBUG-12862] Don't #define highp/mediump/lowp if the desktop OpenGL
68+
implementation has the GL_ARB_ES2_compatibility extension.
6869

6970
QtScript
7071
--------

src/opengl/qgl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4923,6 +4923,8 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions()
49234923
glExtensions |= FragmentProgram;
49244924
if (extensions.match("GL_ARB_fragment_shader"))
49254925
glExtensions |= FragmentShader;
4926+
if (extensions.match("GL_ARB_ES2_compatibility"))
4927+
glExtensions |= ES2Compatibility;
49264928
if (extensions.match("GL_ARB_texture_mirrored_repeat"))
49274929
glExtensions |= MirroredRepeat;
49284930
if (extensions.match("GL_EXT_framebuffer_object"))
@@ -4941,6 +4943,7 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions()
49414943
glExtensions |= FramebufferObject;
49424944
glExtensions |= GenerateMipmap;
49434945
glExtensions |= FragmentShader;
4946+
glExtensions |= ES2Compatibility;
49444947
#endif
49454948
#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
49464949
if (extensions.match("GL_OES_framebuffer_object"))

src/opengl/qgl_p.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ class QGLExtensions {
291291
DDSTextureCompression = 0x00008000,
292292
ETC1TextureCompression = 0x00010000,
293293
PVRTCTextureCompression = 0x00020000,
294-
FragmentShader = 0x00040000
294+
FragmentShader = 0x00040000,
295+
ES2Compatibility = 0x00080000
295296
};
296297
Q_DECLARE_FLAGS(Extensions, Extension)
297298

src/opengl/qglshaderprogram.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ QT_BEGIN_NAMESPACE
9797
to just features that are present in GLSL/ES, and avoid
9898
standard variable names that only work on the desktop.
9999
100+
If the \c{GL_ARB_ES2_compatibility} extension is present,
101+
then the above prefix is not added because the desktop OpenGL
102+
implementation supports precision qualifiers.
103+
100104
\section1 Simple shader example
101105
102106
\snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 1
@@ -390,8 +394,10 @@ bool QGLShader::compileSourceCode(const char *source)
390394
srclen.append(GLint(headerLen));
391395
}
392396
#ifdef QGL_DEFINE_QUALIFIERS
393-
src.append(qualifierDefines);
394-
srclen.append(GLint(sizeof(qualifierDefines) - 1));
397+
if (!(QGLExtensions::glExtensions() & QGLExtensions::ES2Compatibility)) {
398+
src.append(qualifierDefines);
399+
srclen.append(GLint(sizeof(qualifierDefines) - 1));
400+
}
395401
#endif
396402
#ifdef QGL_REDEFINE_HIGHP
397403
if (d->shaderType == Fragment) {

0 commit comments

Comments
 (0)