aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-12-22 15:05:56 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2017-01-04 15:21:19 +0000
commit0a88774a0f11bf96a87012ac4a83e31ced19460b (patch)
tree79c9930bc7ad640b35d5a87bef002a25827637ee /src/quick/scenegraph
parent4406667874b22803ef78650f4af28337eaf7952b (diff)
Fix stencil clips with core profile contexts
Client-side pointers are not supported. Start using a VBO instead. Task-number: QTBUG-57768 Change-Id: Ia7ac9b0838d837b02e8bf99fcd22f0373cb357c9 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 6db96f369c..4893c175a3 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -2022,6 +2022,8 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip)
}
ClipType clipType = NoClip;
+ GLuint vbo = 0;
+ int vboSize = 0;
glDisable(GL_SCISSOR_TEST);
@@ -2106,7 +2108,21 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip)
const QSGGeometry *g = clip->geometry();
Q_ASSERT(g->attributeCount() > 0);
const QSGGeometry::Attribute *a = g->attributes();
- glVertexAttribPointer(0, a->tupleSize, a->type, GL_FALSE, g->sizeOfVertex(), g->vertexData());
+
+ if (!vbo)
+ glGenBuffers(1, &vbo);
+
+ glBindBuffer(GL_ARRAY_BUFFER, vbo);
+
+ const int vertexByteSize = g->sizeOfVertex() * g->vertexCount();
+ if (vboSize < vertexByteSize) {
+ vboSize = vertexByteSize;
+ glBufferData(GL_ARRAY_BUFFER, vertexByteSize, g->vertexData(), GL_STATIC_DRAW);
+ } else {
+ glBufferSubData(GL_ARRAY_BUFFER, 0, vertexByteSize, g->vertexData());
+ }
+
+ glVertexAttribPointer(0, a->tupleSize, a->type, GL_FALSE, g->sizeOfVertex(), 0);
m_clipProgram.setUniformValue(m_clipMatrixId, m);
if (g->indexCount()) {
@@ -2115,12 +2131,17 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip)
glDrawArrays(g->drawingMode(), 0, g->vertexCount());
}
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
++m_currentStencilValue;
}
clip = clip->clipList();
}
+ if (vbo)
+ glDeleteBuffers(1, &vbo);
+
if (clipType & StencilClip) {
m_clipProgram.disableAttributeArray(0);
glStencilFunc(GL_EQUAL, m_currentStencilValue, 0xff); // stencil test, ref, test mask