summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2016-05-10 13:54:06 +0200
committerPaul Lemire <paul.lemire@kdab.com>2016-05-12 13:45:57 +0000
commitf181206cc5f7371106ea131560a6c9cafae557b4 (patch)
treef5864d13c06b30d68ed608af961eb7557fd9cc30
parent544bc5594524b36b63feece874a4e8742cba9428 (diff)
Make sure baseInstance and baseVertex are passed
Change-Id: I2289ada6e9d17590c8e0891fde8dadcdb4d3e021 Task-number: QTBUG-53174 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/render/backend/renderer.cpp18
-rw-r--r--src/render/graphicshelpers/graphicscontext.cpp30
-rw-r--r--src/render/graphicshelpers/graphicscontext_p.h4
-rw-r--r--src/render/graphicshelpers/graphicshelperes2.cpp14
-rw-r--r--src/render/graphicshelpers/graphicshelperes2_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelpergl2.cpp14
-rw-r--r--src/render/graphicshelpers/graphicshelpergl2_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3.cpp14
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_3.cpp14
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_3_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelpergl4.cpp14
-rw-r--r--src/render/graphicshelpers/graphicshelpergl4_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelperinterface_p.h4
14 files changed, 69 insertions, 67 deletions
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index f7b176d10..0ca87b098 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -883,19 +883,21 @@ void Renderer::performDraw(GeometryRenderer *rGeometryRenderer, GLsizei primitiv
m_graphicsContext->enablePrimitiveRestart(rGeometryRenderer->restartIndexValue());
// TO DO: Add glMulti Draw variants
- if (drawIndexed)
- m_graphicsContext->drawElementsInstanced(primType,
- primitiveCount,
- indexType,
- reinterpret_cast<void*>(quintptr(indexAttribute->byteOffset())),
- rGeometryRenderer->instanceCount(),
- rGeometryRenderer->indexOffset());
- else
+ if (drawIndexed) {
+ m_graphicsContext->drawElementsInstancedBaseVertexBaseInstance(primType,
+ primitiveCount,
+ indexType,
+ reinterpret_cast<void*>(quintptr(indexAttribute->byteOffset())),
+ rGeometryRenderer->instanceCount(),
+ rGeometryRenderer->indexOffset(),
+ rGeometryRenderer->firstVertex());
+ } else {
m_graphicsContext->drawArraysInstancedBaseInstance(primType,
rGeometryRenderer->firstInstance(),
primitiveCount,
rGeometryRenderer->instanceCount(),
rGeometryRenderer->firstVertex());
+ }
#if defined(QT3D_RENDER_ASPECT_OPENGL_DEBUG)
int err = m_graphicsContext->openGLContext()->functions()->glGetError();
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp
index 5a099c371..1372d217e 100644
--- a/src/render/graphicshelpers/graphicscontext.cpp
+++ b/src/render/graphicshelpers/graphicscontext.cpp
@@ -701,21 +701,21 @@ bool GraphicsContext::supportsDrawBuffersBlend() const
* If the call is not supported by the system's OpenGL version,
* it is simulated with a loop.
*/
-void GraphicsContext::drawElementsInstanced(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
-{
- m_glHelper->drawElementsInstanced(primitiveType,
- primitiveCount,
- indexType,
- indices,
- instances,
- baseVertex,
- baseInstance);
+void GraphicsContext::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
+ GLsizei primitiveCount,
+ GLint indexType,
+ void *indices,
+ GLsizei instances,
+ GLint baseVertex,
+ GLint baseInstance)
+{
+ m_glHelper->drawElementsInstancedBaseVertexBaseInstance(primitiveType,
+ primitiveCount,
+ indexType,
+ indices,
+ instances,
+ baseVertex,
+ baseInstance);
}
/*!
diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h
index 0c9709dd1..4c41c0e4b 100644
--- a/src/render/graphicshelpers/graphicscontext_p.h
+++ b/src/render/graphicshelpers/graphicscontext_p.h
@@ -199,8 +199,8 @@ public:
void drawArrays(GLenum primitiveType, GLint first, GLsizei count);
void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances);
void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseinstance);
- void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex = 0);
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0);
+ void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex);
+ void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex, GLint baseInstance);
void enableClipPlane(int clipPlane);
void enablei(GLenum cap, GLuint index);
void enablePrimitiveRestart(int restartIndex);
diff --git a/src/render/graphicshelpers/graphicshelperes2.cpp b/src/render/graphicshelpers/graphicshelperes2.cpp
index 4b84bfbad..140fcf2af 100644
--- a/src/render/graphicshelpers/graphicshelperes2.cpp
+++ b/src/render/graphicshelpers/graphicshelperes2.cpp
@@ -83,13 +83,13 @@ void GraphicsHelperES2::initializeHelper(QOpenGLContext *context,
m_isES3 = context->format().majorVersion() >= 3;
}
-void GraphicsHelperES2::drawElementsInstanced(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
+void GraphicsHelperES2::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
+ GLsizei primitiveCount,
+ GLint indexType,
+ void *indices,
+ GLsizei instances,
+ GLint baseVertex,
+ GLint baseInstance)
{
if (baseInstance != 0)
qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2";
diff --git a/src/render/graphicshelpers/graphicshelperes2_p.h b/src/render/graphicshelpers/graphicshelperes2_p.h
index 22bd00307..896008dc8 100644
--- a/src/render/graphicshelpers/graphicshelperes2_p.h
+++ b/src/render/graphicshelpers/graphicshelperes2_p.h
@@ -94,7 +94,7 @@ public:
void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelpergl2.cpp b/src/render/graphicshelpers/graphicshelpergl2.cpp
index 3e283ca7e..f0e753f2d 100644
--- a/src/render/graphicshelpers/graphicshelpergl2.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl2.cpp
@@ -73,13 +73,13 @@ void GraphicsHelperGL2::initializeHelper(QOpenGLContext *context,
}
}
-void GraphicsHelperGL2::drawElementsInstanced(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
+void GraphicsHelperGL2::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
+ GLsizei primitiveCount,
+ GLint indexType,
+ void *indices,
+ GLsizei instances,
+ GLint baseVertex,
+ GLint baseInstance)
{
if (baseInstance != 0)
qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2";
diff --git a/src/render/graphicshelpers/graphicshelpergl2_p.h b/src/render/graphicshelpers/graphicshelpergl2_p.h
index 1256ebe25..719f9c92c 100644
--- a/src/render/graphicshelpers/graphicshelpergl2_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl2_p.h
@@ -96,7 +96,7 @@ public:
void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelpergl3.cpp b/src/render/graphicshelpers/graphicshelpergl3.cpp
index 791e7bf9a..549c665c3 100644
--- a/src/render/graphicshelpers/graphicshelpergl3.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl3.cpp
@@ -91,13 +91,13 @@ void GraphicsHelperGL3::initializeHelper(QOpenGLContext *context,
}
}
-void GraphicsHelperGL3::drawElementsInstanced(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
+void GraphicsHelperGL3::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
+ GLsizei primitiveCount,
+ GLint indexType,
+ void *indices,
+ GLsizei instances,
+ GLint baseVertex,
+ GLint baseInstance)
{
if (baseInstance != 0)
qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2";
diff --git a/src/render/graphicshelpers/graphicshelpergl3_3.cpp b/src/render/graphicshelpers/graphicshelpergl3_3.cpp
index 99f070ab7..fe257ce27 100644
--- a/src/render/graphicshelpers/graphicshelpergl3_3.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl3_3.cpp
@@ -90,13 +90,13 @@ void GraphicsHelperGL3_3::initializeHelper(QOpenGLContext *context,
}
}
-void GraphicsHelperGL3_3::drawElementsInstanced(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
+void GraphicsHelperGL3_3::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
+ GLsizei primitiveCount,
+ GLint indexType,
+ void *indices,
+ GLsizei instances,
+ GLint baseVertex,
+ GLint baseInstance)
{
if (baseInstance != 0)
qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL 3";
diff --git a/src/render/graphicshelpers/graphicshelpergl3_3_p.h b/src/render/graphicshelpers/graphicshelpergl3_3_p.h
index b9c074040..bb6946a20 100644
--- a/src/render/graphicshelpers/graphicshelpergl3_3_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl3_3_p.h
@@ -97,7 +97,7 @@ public:
void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelpergl3_p.h b/src/render/graphicshelpers/graphicshelpergl3_p.h
index 5379c24aa..721078130 100644
--- a/src/render/graphicshelpers/graphicshelpergl3_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl3_p.h
@@ -97,7 +97,7 @@ public:
void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelpergl4.cpp b/src/render/graphicshelpers/graphicshelpergl4.cpp
index 04e409263..6d7a3b5b1 100644
--- a/src/render/graphicshelpers/graphicshelpergl4.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl4.cpp
@@ -86,13 +86,13 @@ void GraphicsHelperGL4::initializeHelper(QOpenGLContext *context,
Q_UNUSED(ok);
}
-void GraphicsHelperGL4::drawElementsInstanced(GLenum primitiveType,
- GLsizei primitiveCount,
- GLint indexType,
- void *indices,
- GLsizei instances,
- GLint baseVertex,
- GLint baseInstance)
+void GraphicsHelperGL4::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
+ GLsizei primitiveCount,
+ GLint indexType,
+ void *indices,
+ GLsizei instances,
+ GLint baseVertex,
+ GLint baseInstance)
{
if (baseInstance != 0)
qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL ES 2";
diff --git a/src/render/graphicshelpers/graphicshelpergl4_p.h b/src/render/graphicshelpers/graphicshelpergl4_p.h
index f00e97fd5..38a01e271 100644
--- a/src/render/graphicshelpers/graphicshelpergl4_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl4_p.h
@@ -96,7 +96,7 @@ public:
void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance) Q_DECL_OVERRIDE;
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
- void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
+ void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelperinterface_p.h b/src/render/graphicshelpers/graphicshelperinterface_p.h
index 1eca84b90..6e7caee6a 100644
--- a/src/render/graphicshelpers/graphicshelperinterface_p.h
+++ b/src/render/graphicshelpers/graphicshelperinterface_p.h
@@ -106,8 +106,8 @@ public:
virtual void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) = 0;
virtual void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseinstance) = 0;
virtual void drawBuffers(GLsizei n, const int *bufs) = 0;
- virtual void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex = 0) = 0;
- virtual void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) = 0;
+ virtual void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex) = 0;
+ virtual void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex, GLint baseInstance) = 0;
virtual void enableClipPlane(int clipPlane) = 0;
virtual void enablei(GLenum cap, GLuint index) = 0;
virtual void enablePrimitiveRestart(int primitiveRestartIndex) = 0;