diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 16:00:07 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 16:00:07 +0200 |
commit | 19ed7973a311a8d42d3a558bb551230e902ce9b9 (patch) | |
tree | 9832c0cc796722f85579e25fd50cc38b65e6ef6c /src/quick/scenegraph | |
parent | f5701f0def37fcc0c2b38ae9552eb3a896a34687 (diff) | |
parent | a5635345175e667601c8b6a344508c4d4ebb0f9d (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into tqtc/lts-5.15-opensourcev5.15.9-lts-lgpl
Change-Id: I91d2b178e7111d0802ea973bccf230b264c30c96
Diffstat (limited to 'src/quick/scenegraph')
14 files changed, 22 insertions, 7 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 77bac7c8a5..ea1a1a9b93 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -2215,6 +2215,15 @@ void Renderer::uploadBatch(Batch *b) */ int bufferSize = b->vertexCount * g->sizeOfVertex(); int ibufferSize = 0; + // At this point, we need to check if the vertices byte size is 4 byte aligned or not. + // If an unaligned value is used in a shared buffer with indices, it causes problems with + // glDrawElements. We need to do a 4 byte alignment so that it can work with both + // QSGGeometry::UnsignedShortType and QSGGeometry::UnsignedIntType + int paddingBytes = 0; + if (!m_context->separateIndexBuffer()) { + paddingBytes = aligned(bufferSize, 4) - bufferSize; + bufferSize += paddingBytes; + } if (b->merged) { ibufferSize = b->indexCount * mergedIndexElemSize(); if (m_useDepthBuffer) @@ -2239,7 +2248,7 @@ void Renderer::uploadBatch(Batch *b) char *zData = vertexData + b->vertexCount * g->sizeOfVertex(); char *indexData = separateIndexBuffer ? b->ibo.data - : zData + (int(m_useDepthBuffer) * b->vertexCount * sizeof(float)); + : zData + (int(m_useDepthBuffer) * b->vertexCount * sizeof(float)) + paddingBytes; quint16 iOffset16 = 0; quint32 iOffset32 = 0; @@ -2287,7 +2296,7 @@ void Renderer::uploadBatch(Batch *b) } else { char *vboData = b->vbo.data; char *iboData = separateIndexBuffer ? b->ibo.data - : vboData + b->vertexCount * g->sizeOfVertex(); + : vboData + b->vertexCount * g->sizeOfVertex() + paddingBytes; Element *e = b->first; while (e) { QSGGeometry *g = e->node->geometry(); @@ -3176,8 +3185,14 @@ void Renderer::renderUnmergedBatch(const Batch *batch) // legacy (GL-only) int vOffset = 0; char *iOffset = indexBase; + // If a shared buffer is used, 4 byte alignment was done to avoid issues + // while using glDrawElements with both QSGGeometry::UnsignedShortType and + // QSGGeometry::UnsignedIntType. Here, we need to take this into account + // while calculating iOffset value to end up with the correct offset for drawing. + int vertexDataByteSize = batch->vertexCount * gn->geometry()->sizeOfVertex(); + vertexDataByteSize = aligned(vertexDataByteSize, 4); if (!separateIndexBuffer) - iOffset += batch->vertexCount * gn->geometry()->sizeOfVertex(); + iOffset += vertexDataByteSize; QMatrix4x4 rootMatrix = batch->root ? qsg_matrixForRoot(batch->root) : QMatrix4x4(); diff --git a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp index eb4db0f85e..2325a2665b 100644 --- a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp @@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font) const char *textureRecord = allocatorData; for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) { - if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) { + if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) { qWarning("qtdf table too small in font '%s'.", qPrintable(font.familyName())); return false; @@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font) const char *glyphRecord = textureRecord; for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) { - if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) { + if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) { qWarning("qtdf table too small in font '%s'.", qPrintable(font.familyName())); return false; @@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font) int width = texInfo->allocatedArea.width(); int height = texInfo->allocatedArea.height(); - qint64 size = width * height; - if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) { + qint64 size = qint64(width) * height; + if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) { qWarning("qtdf table too small in font '%s'.", qPrintable(font.familyName())); return false; diff --git a/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb b/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb Binary files differindex c493996375..6eee3f01d6 100644 --- a/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb b/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb Binary files differindex 3f8489bfe6..d81bb2f26d 100644 --- a/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb b/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb Binary files differindex f721207325..6ebb3342ac 100644 --- a/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb b/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb Binary files differindex 93ac0124be..e29f734c33 100644 --- a/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb Binary files differindex 1756ee9d4b..071abd2f88 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb Binary files differindex b8d38bdff4..dd159d008d 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb Binary files differindex f44b92dc28..393b1608e9 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb b/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb Binary files differindex b0461a686c..5b45142201 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb b/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb Binary files differindex 18e4685d21..e2a5859bfc 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb diff --git a/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb Binary files differindex 3d9b5a0bdd..c3aa6c068a 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/textmask.frag.qsb b/src/quick/scenegraph/shaders_ng/textmask.frag.qsb Binary files differindex cfae9575da..a4341d8915 100644 --- a/src/quick/scenegraph/shaders_ng/textmask.frag.qsb +++ b/src/quick/scenegraph/shaders_ng/textmask.frag.qsb diff --git a/src/quick/scenegraph/shaders_ng/textmask.vert.qsb b/src/quick/scenegraph/shaders_ng/textmask.vert.qsb Binary files differindex 2ea425e1c0..4ca3b874d0 100644 --- a/src/quick/scenegraph/shaders_ng/textmask.vert.qsb +++ b/src/quick/scenegraph/shaders_ng/textmask.vert.qsb |