From 88c358e8c5970afdf15483ac982b481c895aaa7c Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Sun, 13 Dec 2015 14:39:11 +0100 Subject: GraphicsHelper: add dispatch compute function Change-Id: I3c2614f0fc484d6f492d9302a3ec9335e827f741 Reviewed-by: Paul Lemire --- src/render/graphicshelpers/graphicscontext.cpp | 6 ++++++ src/render/graphicshelpers/graphicscontext_p.h | 1 + src/render/graphicshelpers/graphicshelperes2.cpp | 8 ++++++++ src/render/graphicshelpers/graphicshelperes2_p.h | 3 +-- src/render/graphicshelpers/graphicshelpergl2.cpp | 8 ++++++++ src/render/graphicshelpers/graphicshelpergl2_p.h | 1 + src/render/graphicshelpers/graphicshelpergl3.cpp | 8 ++++++++ src/render/graphicshelpers/graphicshelpergl3_3.cpp | 8 ++++++++ src/render/graphicshelpers/graphicshelpergl3_3_p.h | 1 + src/render/graphicshelpers/graphicshelpergl3_p.h | 1 + src/render/graphicshelpers/graphicshelpergl4.cpp | 6 ++++++ src/render/graphicshelpers/graphicshelpergl4_p.h | 1 + src/render/graphicshelpers/graphicshelperinterface_p.h | 4 +++- 13 files changed, 53 insertions(+), 3 deletions(-) (limited to 'src/render') diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp index 5279fb191..85edbfa5b 100644 --- a/src/render/graphicshelpers/graphicscontext.cpp +++ b/src/render/graphicshelpers/graphicscontext.cpp @@ -792,6 +792,12 @@ void GraphicsContext::pointSize(bool programmable, GLfloat value) m_glHelper->pointSize(programmable, value); } +void GraphicsContext::dispatchCompute(int x, int y, int z) +{ + if (m_glHelper->supportsFeature(GraphicsHelperInterface::Compute)) + m_glHelper->dispatchCompute(x, y, z); +} + /*! \internal Returns a texture unit for a texture, -1 if all texture units are assigned. diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h index bbc93c43d..12145c090 100644 --- a/src/render/graphicshelpers/graphicscontext_p.h +++ b/src/render/graphicshelpers/graphicscontext_p.h @@ -186,6 +186,7 @@ public: void disableAlphaCoverage(); void disableClipPlane(int clipPlane); void disablePrimitiveRestart(); + void dispatchCompute(int x, int y, int z); void drawArrays(GLenum primitiveType, GLint first, GLsizei count); void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances); void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex = 0); diff --git a/src/render/graphicshelpers/graphicshelperes2.cpp b/src/render/graphicshelpers/graphicshelperes2.cpp index 29fe849d7..dcbc3b764 100644 --- a/src/render/graphicshelpers/graphicshelperes2.cpp +++ b/src/render/graphicshelpers/graphicshelperes2.cpp @@ -601,6 +601,14 @@ QSize GraphicsHelperES2::getTextureDimensions(GLuint textureId, GLenum target, u return QSize(0, 0); } +void GraphicsHelperES2::dispatchCompute(GLuint wx, GLuint wy, GLuint wz) +{ + Q_UNUSED(wx); + Q_UNUSED(wy); + Q_UNUSED(wz); + qWarning() << "Compute Shaders are not supported by ES 2.0 (since ES 3.1)"; +} + } // namespace Render } // namespace Qt3DRender diff --git a/src/render/graphicshelpers/graphicshelperes2_p.h b/src/render/graphicshelpers/graphicshelperes2_p.h index 01d4f59c4..b1f992f02 100644 --- a/src/render/graphicshelpers/graphicshelperes2_p.h +++ b/src/render/graphicshelpers/graphicshelperes2_p.h @@ -84,6 +84,7 @@ public: void disableAlphaCoverage() Q_DECL_OVERRIDE; void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) Q_DECL_OVERRIDE; void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE; void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE; void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE; @@ -108,8 +109,6 @@ public: uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE; void useProgram(GLuint programId) Q_DECL_OVERRIDE; void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE; - - private: QOpenGLFunctions *m_funcs; bool m_isES3; diff --git a/src/render/graphicshelpers/graphicshelpergl2.cpp b/src/render/graphicshelpers/graphicshelpergl2.cpp index 55676a6bf..035083446 100644 --- a/src/render/graphicshelpers/graphicshelpergl2.cpp +++ b/src/render/graphicshelpers/graphicshelpergl2.cpp @@ -597,6 +597,14 @@ QSize GraphicsHelperGL2::getTextureDimensions(GLuint textureId, GLenum target, u return QSize(width, height); } +void GraphicsHelperGL2::dispatchCompute(GLuint wx, GLuint wy, GLuint wz) +{ + Q_UNUSED(wx); + Q_UNUSED(wy); + Q_UNUSED(wz); + qWarning() << "Compute Shaders are not supported by OpenGL 2.0 (since OpenGL 4.3)"; +} + } // namespace Render } // namespace Qt3DRender diff --git a/src/render/graphicshelpers/graphicshelpergl2_p.h b/src/render/graphicshelpers/graphicshelpergl2_p.h index cb7596f4a..6603d34b8 100644 --- a/src/render/graphicshelpers/graphicshelpergl2_p.h +++ b/src/render/graphicshelpers/graphicshelpergl2_p.h @@ -86,6 +86,7 @@ public: void disableAlphaCoverage() Q_DECL_OVERRIDE; void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) Q_DECL_OVERRIDE; void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE; void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE; void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl3.cpp b/src/render/graphicshelpers/graphicshelpergl3.cpp index 64c0c1b03..d79431131 100644 --- a/src/render/graphicshelpers/graphicshelpergl3.cpp +++ b/src/render/graphicshelpers/graphicshelpergl3.cpp @@ -976,6 +976,14 @@ QSize GraphicsHelperGL3::getTextureDimensions(GLuint textureId, GLenum target, u return QSize(width, height); } +void GraphicsHelperGL3::dispatchCompute(GLuint wx, GLuint wy, GLuint wz) +{ + Q_UNUSED(wx); + Q_UNUSED(wy); + Q_UNUSED(wz); + qWarning() << "Compute Shaders are not supported by OpenGL 3.0 (since OpenGL 4.3)"; +} + } // namespace Render } // namespace Qt3DRender diff --git a/src/render/graphicshelpers/graphicshelpergl3_3.cpp b/src/render/graphicshelpers/graphicshelpergl3_3.cpp index e74968db9..61f7d9c25 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_3.cpp +++ b/src/render/graphicshelpers/graphicshelpergl3_3.cpp @@ -973,6 +973,14 @@ QSize GraphicsHelperGL3_3::getTextureDimensions(GLuint textureId, GLenum target, return QSize(width, height); } +void GraphicsHelperGL3_3::dispatchCompute(GLuint wx, GLuint wy, GLuint wz) +{ + Q_UNUSED(wx); + Q_UNUSED(wy); + Q_UNUSED(wz); + qWarning() << "Compute Shaders are not supported by OpenGL 3.3 (since OpenGL 4.3)"; +} + } // namespace Render } // namespace Qt3DRender diff --git a/src/render/graphicshelpers/graphicshelpergl3_3_p.h b/src/render/graphicshelpers/graphicshelpergl3_3_p.h index 837a61673..e8a5da0ae 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_3_p.h +++ b/src/render/graphicshelpers/graphicshelpergl3_3_p.h @@ -87,6 +87,7 @@ public: void disableAlphaCoverage() Q_DECL_OVERRIDE; void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) Q_DECL_OVERRIDE; void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE; void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE; void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl3_p.h b/src/render/graphicshelpers/graphicshelpergl3_p.h index 11d5c567c..ddd2b9ed9 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_p.h +++ b/src/render/graphicshelpers/graphicshelpergl3_p.h @@ -87,6 +87,7 @@ public: void disableAlphaCoverage() Q_DECL_OVERRIDE; void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) Q_DECL_OVERRIDE; void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE; void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE; void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl4.cpp b/src/render/graphicshelpers/graphicshelpergl4.cpp index 86b17e7f3..d97557bdc 100644 --- a/src/render/graphicshelpers/graphicshelpergl4.cpp +++ b/src/render/graphicshelpers/graphicshelpergl4.cpp @@ -363,6 +363,7 @@ bool GraphicsHelperGL4::supportsFeature(GraphicsHelperInterface::Feature feature case RenderBufferDimensionRetrieval: case TextureDimensionRetrieval: case ShaderStorageObject: + case Compute: return true; default: return false; @@ -968,6 +969,11 @@ QSize GraphicsHelperGL4::getTextureDimensions(GLuint textureId, GLenum target, u return QSize(width, height); } +void GraphicsHelperGL4::dispatchCompute(GLuint wx, GLuint wy, GLuint wz) +{ + m_funcs->glDispatchCompute(wx, wy, wz); +} + } // namespace Render } // namespace Qt3DRender diff --git a/src/render/graphicshelpers/graphicshelpergl4_p.h b/src/render/graphicshelpers/graphicshelpergl4_p.h index 4077a7828..05f9876cd 100644 --- a/src/render/graphicshelpers/graphicshelpergl4_p.h +++ b/src/render/graphicshelpers/graphicshelpergl4_p.h @@ -86,6 +86,7 @@ public: void disableAlphaCoverage() Q_DECL_OVERRIDE; void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) Q_DECL_OVERRIDE; void drawArrays(GLenum primitiveType, GLint first, GLsizei count) Q_DECL_OVERRIDE; void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) Q_DECL_OVERRIDE; void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelperinterface_p.h b/src/render/graphicshelpers/graphicshelperinterface_p.h index caeb8f0c0..91785d21f 100644 --- a/src/render/graphicshelpers/graphicshelperinterface_p.h +++ b/src/render/graphicshelpers/graphicshelperinterface_p.h @@ -71,7 +71,8 @@ public: PrimitiveRestart, RenderBufferDimensionRetrieval, TextureDimensionRetrieval, - ShaderStorageObject + ShaderStorageObject, + Compute }; virtual ~GraphicsHelperInterface() {} @@ -95,6 +96,7 @@ public: virtual void disableAlphaCoverage() = 0; virtual void disableClipPlane(int clipPlane) = 0; virtual void disablePrimitiveRestart() = 0; + virtual void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) = 0; virtual void drawArrays(GLenum primitiveType, GLint first, GLsizei count) = 0; virtual void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) = 0; virtual void drawBuffers(GLsizei n, const int *bufs) = 0; -- cgit v1.2.3