aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@crimson.no>2017-04-23 02:39:56 +0200
committerRobin Burchell <robin.burchell@crimson.no>2017-04-24 14:04:15 +0000
commite6a8a5c229f802125baa33834b4ec4b19747a29b (patch)
tree3da892f68110491c02d65c765b1bb453ee27d7c1
parent1e257c441a4b456c1b6a4304467d773771f9e770 (diff)
QSGBatchRenderer: Fix a performance regression noted by qmlbench
0a88774a0f11bf96a87012ac4a83e31ced19460b switched from using client side pointers to VBOs, ostensibly for core profile support. Unfortunately, some GPUs/drivers seem to suffer quite a bit with these, so only use them if we must. Results for changing_over_isolated_with_clip_rotated.qml: eskil_linux_tx1: Before: Average: 65.6 frames; using samples; MedianAll=65; StdDev=0.894427, CoV=0.0136346 After: Average: 120 frames; using samples; MedianAll=120; StdDev=0, CoV=0 eskil_linux_focault (nvidia) has a similar regression in all branches where the original commit is present, too: 5.6 & v5.8.0 tag: 600 5.8, 5.9 & dev branches: 399 Assuming this is the sole regression in that case and we end up at the original 600 again, that would be a 50% gain there, and an 81% increase on TX1. Change-Id: I44af9e67698356200f9587e77c9409fdb756519d Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Gunnar Sletta <gunnar@crimson.no>
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 14f8514289..bf54319db6 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -2029,6 +2029,15 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip)
GLuint vbo = 0;
int vboSize = 0;
+ bool useVBO = false;
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ QSurfaceFormat::OpenGLContextProfile profile = ctx->format().profile();
+
+ if (!ctx->isOpenGLES() && profile == QSurfaceFormat::CoreProfile) {
+ // VBO are more expensive, so only use them if we must.
+ useVBO = true;
+ }
+
glDisable(GL_SCISSOR_TEST);
m_currentStencilValue = 0;
@@ -2113,20 +2122,27 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip)
Q_ASSERT(g->attributeCount() > 0);
const QSGGeometry::Attribute *a = g->attributes();
- if (!vbo)
- glGenBuffers(1, &vbo);
+ const GLvoid *pointer;
+ if (!useVBO) {
+ pointer = g->vertexData();
+ } else {
+ if (!vbo)
+ glGenBuffers(1, &vbo);
- glBindBuffer(GL_ARRAY_BUFFER, 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());
+ 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());
+ }
+
+ pointer = 0;
}
- glVertexAttribPointer(0, a->tupleSize, a->type, GL_FALSE, g->sizeOfVertex(), 0);
+ glVertexAttribPointer(0, a->tupleSize, a->type, GL_FALSE, g->sizeOfVertex(), pointer);
m_clipProgram.setUniformValue(m_clipMatrixId, m);
if (g->indexCount()) {
@@ -2135,7 +2151,8 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip)
glDrawArrays(g->drawingMode(), 0, g->vertexCount());
}
- glBindBuffer(GL_ARRAY_BUFFER, 0);
+ if (useVBO)
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
++m_currentStencilValue;
}