QOpenGLShader: report geom. and tess. on GLES 3.2+
Also fix up the docs. To make everything more complicated, OpenGL ES 3.2 does not support default tessellation levels. Therefore the related functions remain OpenGL 4.0+ only. [ChangeLog][QtGui] QOpenGLShader has been fixed to expose geometry and tessellation evaluation/control shaders with OpenGL ES 3.2. Task-number: QTBUG-66074 Change-Id: I2e4277912800d8302824e3fb74f61ec16f4b341d Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
1fa5d83ad2
commit
76c4a70499
@ -39,7 +39,7 @@
|
||||
|
||||
#include "qopenglshaderprogram.h"
|
||||
#include "qopenglprogrambinarycache_p.h"
|
||||
#include "qopenglfunctions.h"
|
||||
#include "qopenglextrafunctions.h"
|
||||
#include "private/qopenglcontext_p.h"
|
||||
#include <QtCore/private/qobject_p.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
@ -170,13 +170,13 @@ QT_BEGIN_NAMESPACE
|
||||
\value Vertex Vertex shader written in the OpenGL Shading Language (GLSL).
|
||||
\value Fragment Fragment shader written in the OpenGL Shading Language (GLSL).
|
||||
\value Geometry Geometry shaders written in the OpenGL Shading Language (GLSL)
|
||||
based on the OpenGL core feature (requires OpenGL >= 3.2).
|
||||
(requires OpenGL >= 3.2 or OpenGL ES >= 3.2).
|
||||
\value TessellationControl Tessellation control shaders written in the OpenGL
|
||||
shading language (GLSL), based on the core feature (requires OpenGL >= 4.0).
|
||||
shading language (GLSL) (requires OpenGL >= 4.0 or OpenGL ES >= 3.2).
|
||||
\value TessellationEvaluation Tessellation evaluation shaders written in the OpenGL
|
||||
shading language (GLSL), based on the core feature (requires OpenGL >= 4.0).
|
||||
\value Compute Compute shaders written in the OpenGL shading language (GLSL),
|
||||
based on the core feature (requires OpenGL >= 4.3).
|
||||
shading language (GLSL) (requires OpenGL >= 4.0 or OpenGL ES >= 3.2).
|
||||
\value Compute Compute shaders written in the OpenGL shading language (GLSL)
|
||||
(requires OpenGL >= 4.3 or OpenGL ES >= 3.1).
|
||||
*/
|
||||
|
||||
Q_LOGGING_CATEGORY(DBG_SHADER_CACHE, "qt.opengl.diskcache")
|
||||
@ -223,26 +223,18 @@ static inline bool isFormatGLES(const QSurfaceFormat &f)
|
||||
|
||||
static inline bool supportsGeometry(const QSurfaceFormat &f)
|
||||
{
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!isFormatGLES(f))
|
||||
return (f.version() >= qMakePair<int, int>(3, 2));
|
||||
else
|
||||
return false;
|
||||
#else
|
||||
Q_UNUSED(f);
|
||||
return false;
|
||||
#endif
|
||||
return f.version() >= qMakePair(3, 2);
|
||||
}
|
||||
|
||||
static inline bool supportsCompute(const QSurfaceFormat &f)
|
||||
{
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!isFormatGLES(f))
|
||||
return (f.version() >= qMakePair<int, int>(4, 3));
|
||||
return f.version() >= qMakePair(4, 3);
|
||||
else
|
||||
return (f.version() >= qMakePair<int, int>(3, 1));
|
||||
return f.version() >= qMakePair(3, 1);
|
||||
#else
|
||||
return (f.version() >= qMakePair<int, int>(3, 1));
|
||||
return f.version() >= qMakePair(3, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -250,12 +242,11 @@ static inline bool supportsTessellation(const QSurfaceFormat &f)
|
||||
{
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!isFormatGLES(f))
|
||||
return (f.version() >= qMakePair<int, int>(4, 0));
|
||||
return f.version() >= qMakePair(4, 0);
|
||||
else
|
||||
return false;
|
||||
return f.version() >= qMakePair(3, 2);
|
||||
#else
|
||||
Q_UNUSED(f);
|
||||
return false;
|
||||
return f.version() >= qMakePair(3, 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -267,7 +258,7 @@ public:
|
||||
: shaderGuard(0)
|
||||
, shaderType(type)
|
||||
, compiled(false)
|
||||
, glfuncs(new QOpenGLFunctions(ctx))
|
||||
, glfuncs(new QOpenGLExtraFunctions(ctx))
|
||||
, supportsGeometryShaders(false)
|
||||
, supportsTessellationShaders(false)
|
||||
, supportsComputeShaders(false)
|
||||
@ -286,7 +277,7 @@ public:
|
||||
bool compiled;
|
||||
QString log;
|
||||
|
||||
QOpenGLFunctions *glfuncs;
|
||||
QOpenGLExtraFunctions *glfuncs;
|
||||
|
||||
// Support for geometry shaders
|
||||
bool supportsGeometryShaders;
|
||||
@ -802,7 +793,7 @@ public:
|
||||
, linked(false)
|
||||
, inited(false)
|
||||
, removingShaders(false)
|
||||
, glfuncs(new QOpenGLFunctions)
|
||||
, glfuncs(new QOpenGLExtraFunctions)
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
, tessellationFuncs(0)
|
||||
#endif
|
||||
@ -820,10 +811,9 @@ public:
|
||||
QList<QOpenGLShader *> shaders;
|
||||
QList<QOpenGLShader *> anonShaders;
|
||||
|
||||
QOpenGLFunctions *glfuncs;
|
||||
|
||||
QOpenGLExtraFunctions *glfuncs;
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
// Tessellation shader support
|
||||
// for tessellation features not in GLES 3.2
|
||||
QOpenGLFunctions_4_0_Core *tessellationFuncs;
|
||||
#endif
|
||||
|
||||
@ -913,10 +903,7 @@ bool QOpenGLShaderProgram::init()
|
||||
d->glfuncs->initializeOpenGLFunctions();
|
||||
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
// Resolve OpenGL 4 functions for tessellation shader support
|
||||
QSurfaceFormat format = context->format();
|
||||
if (!context->isOpenGLES()
|
||||
&& format.version() >= qMakePair<int, int>(4, 0)) {
|
||||
if (!context->isOpenGLES() && context->format().version() >= qMakePair(4, 0)) {
|
||||
d->tessellationFuncs = context->versionFunctions<QOpenGLFunctions_4_0_Core>();
|
||||
d->tessellationFuncs->initializeOpenGLFunctions();
|
||||
}
|
||||
@ -3508,13 +3495,8 @@ int QOpenGLShaderProgram::maxGeometryOutputVertices() const
|
||||
*/
|
||||
void QOpenGLShaderProgram::setPatchVertexCount(int count)
|
||||
{
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
Q_D(QOpenGLShaderProgram);
|
||||
if (d->tessellationFuncs)
|
||||
d->tessellationFuncs->glPatchParameteri(GL_PATCH_VERTICES, count);
|
||||
#else
|
||||
Q_UNUSED(count);
|
||||
#endif
|
||||
d->glfuncs->glPatchParameteri(GL_PATCH_VERTICES, count);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3527,15 +3509,10 @@ void QOpenGLShaderProgram::setPatchVertexCount(int count)
|
||||
*/
|
||||
int QOpenGLShaderProgram::patchVertexCount() const
|
||||
{
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
int patchVertices = 0;
|
||||
Q_D(const QOpenGLShaderProgram);
|
||||
if (d->tessellationFuncs)
|
||||
d->tessellationFuncs->glGetIntegerv(GL_PATCH_VERTICES, &patchVertices);
|
||||
d->glfuncs->glGetIntegerv(GL_PATCH_VERTICES, &patchVertices);
|
||||
return patchVertices;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3553,6 +3530,9 @@ int QOpenGLShaderProgram::patchVertexCount() const
|
||||
function when needed, as QOpenGLShaderProgram will not apply this for
|
||||
you. This is purely a convenience function.
|
||||
|
||||
\note This function is only available with OpenGL >= 4.0 and is not supported
|
||||
with OpenGL ES 3.2.
|
||||
|
||||
\sa defaultOuterTessellationLevels(), setDefaultInnerTessellationLevels()
|
||||
*/
|
||||
void QOpenGLShaderProgram::setDefaultOuterTessellationLevels(const QVector<float> &levels)
|
||||
@ -3590,6 +3570,9 @@ void QOpenGLShaderProgram::setDefaultOuterTessellationLevels(const QVector<float
|
||||
\note This returns the global OpenGL state value. It is not specific to
|
||||
this QOpenGLShaderProgram instance.
|
||||
|
||||
\note This function is only supported with OpenGL >= 4.0 and will not
|
||||
return valid results with OpenGL ES 3.2.
|
||||
|
||||
\sa setDefaultOuterTessellationLevels(), defaultInnerTessellationLevels()
|
||||
*/
|
||||
QVector<float> QOpenGLShaderProgram::defaultOuterTessellationLevels() const
|
||||
@ -3620,6 +3603,9 @@ QVector<float> QOpenGLShaderProgram::defaultOuterTessellationLevels() const
|
||||
function when needed, as QOpenGLShaderProgram will not apply this for
|
||||
you. This is purely a convenience function.
|
||||
|
||||
\note This function is only available with OpenGL >= 4.0 and is not supported
|
||||
with OpenGL ES 3.2.
|
||||
|
||||
\sa defaultInnerTessellationLevels(), setDefaultOuterTessellationLevels()
|
||||
*/
|
||||
void QOpenGLShaderProgram::setDefaultInnerTessellationLevels(const QVector<float> &levels)
|
||||
@ -3657,6 +3643,9 @@ void QOpenGLShaderProgram::setDefaultInnerTessellationLevels(const QVector<float
|
||||
\note This returns the global OpenGL state value. It is not specific to
|
||||
this QOpenGLShaderProgram instance.
|
||||
|
||||
\note This function is only supported with OpenGL >= 4.0 and will not
|
||||
return valid results with OpenGL ES 3.2.
|
||||
|
||||
\sa setDefaultInnerTessellationLevels(), defaultOuterTessellationLevels()
|
||||
*/
|
||||
QVector<float> QOpenGLShaderProgram::defaultInnerTessellationLevels() const
|
||||
|
Loading…
Reference in New Issue
Block a user