summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopenglshaderprogram.cpp
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2013-03-01 16:32:04 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-02 12:58:18 +0100
commit8c4d02ef875518be21f63bd115a0bec813da5a91 (patch)
treec00bf5811c64e054657d0c321ceb0c3048e32f9e /src/gui/opengl/qopenglshaderprogram.cpp
parent7e5d1c1c2fc764d4cacc3e367542e1f42e6b772e (diff)
OpenGL: Add support for the Compute shader stage
Change-Id: Ibb1b79358758c2adf818af8c6fcd5c379efad8c3 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/gui/opengl/qopenglshaderprogram.cpp')
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index e48b922dac..1cde0cb92d 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -156,6 +156,8 @@ QT_BEGIN_NAMESPACE
shading language (GLSL), based on the core feature (requires OpenGL >= 4.0).
\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).
*/
class QOpenGLShaderPrivate : public QObjectPrivate
@@ -236,6 +238,10 @@ bool QOpenGLShaderPrivate::create()
} else if (shaderType == QOpenGLShader::TessellationEvaluation && supportsTessellationShaders) {
shader = glfuncs->glCreateShader(GL_TESS_EVALUATION_SHADER);
#endif
+#if defined(QT_OPENGL_4_3)
+ } else if (shaderType == QOpenGLShader::Compute) {
+ shader = glfuncs->glCreateShader(GL_COMPUTE_SHADER);
+#endif
} else {
shader = glfuncs->glCreateShader(GL_FRAGMENT_SHADER);
}
@@ -3230,7 +3236,7 @@ bool QOpenGLShader::hasOpenGLShaders(ShaderType type, QOpenGLContext *context)
if (!context)
return false;
- if ((type & ~(Geometry | Vertex | Fragment | TessellationControl | TessellationEvaluation)) || type == 0)
+ if ((type & ~(Geometry | Vertex | Fragment | TessellationControl | TessellationEvaluation | Compute)) || type == 0)
return false;
QSurfaceFormat format = context->format();
@@ -3250,6 +3256,13 @@ bool QOpenGLShader::hasOpenGLShaders(ShaderType type, QOpenGLContext *context)
// No tessellation shader support in OpenGL ES2
return false;
#endif
+ } else if (type == Compute) {
+#if defined(QT_OPENGL_4_3)
+ return (format.version() >= qMakePair<int, int>(4, 3));
+#else
+ // No compute shader support without OpenGL 4.3 or newer
+ return false;
+#endif
}
// Unconditional support of vertex and fragment shaders implicitly assumes