Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsgbatchrenderer_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
3// Copyright (C) 2016 Robin Burchell <robin.burchell@viroteck.net>
4// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
5// Qt-Security score:significant reason:default
6
7#ifndef QSGBATCHRENDERER_P_H
8#define QSGBATCHRENDERER_P_H
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include <private/qsgrenderer_p.h>
22#include <private/qsgdefaultrendercontext_p.h>
23#include <private/qsgnodeupdater_p.h>
24#include <private/qsgrendernode_p.h>
25#include <private/qdatabuffer_p.h>
26#include <private/qsgtexture_p.h>
27#include <private/qsgnode_p.h>
28
29#include <QtCore/QBitArray>
30#include <QtCore/QElapsedTimer>
31#include <QtCore/QStack>
32
33#include <rhi/qrhi.h>
34
36
37namespace QSGBatchRenderer
38{
39
40#define QSG_RENDERER_COORD_LIMIT 1000000.0f
41
42struct Vec;
43struct Rect;
44struct Buffer;
45struct Chunk;
46struct Batch;
47struct Node;
48class Updater;
49class Renderer;
50class ShaderManager;
51
52template <typename Type, int PageSize> class AllocatorPage
53{
54public:
55 // The memory used by this allocator
56 char data[sizeof(Type) * PageSize];
57
58 // 'blocks' contains a list of free indices which can be allocated.
59 // The first available index is found in PageSize - available.
60 int blocks[PageSize];
61
62 // 'available' is the number of available instances this page has left to allocate.
64
65 // This is not strictly needed, but useful for sanity checking and anyway
66 // pretty small..
68
70 : available(PageSize)
72 {
73 for (int i=0; i<PageSize; ++i)
74 blocks[i] = i;
75
76 // Zero out all new pages.
77 memset(data, 0, sizeof(data));
78 }
79
80 const Type *at(uint index) const
81 {
82 return (Type *) &data[index * sizeof(Type)];
83 }
84
85 Type *at(uint index)
86 {
87 return (Type *) &data[index * sizeof(Type)];
88 }
89};
90
91template <typename Type, int PageSize> class Allocator
92{
93public:
95 {
96 pages.push_back(new AllocatorPage<Type, PageSize>());
97 }
98
100 {
101 qDeleteAll(pages);
102 }
103
104 Type *allocate(bool allowNewPages = true)
105 {
106 AllocatorPage<Type, PageSize> *p = 0;
107 for (int i = m_freePage; i < pages.size(); i++) {
108 if (pages.at(i)->available > 0) {
109 p = pages.at(i);
110 m_freePage = i;
111 break;
112 }
113 }
114
115 // we couldn't find a free page from m_freePage to the last page.
116 // either there is no free pages, or there weren't any in the area we
117 // scanned: rescanning is expensive, so let's just assume there isn't
118 // one. when an item is released, we'll reset m_freePage anyway.
119 if (!p) {
120 m_freePage = pages.size();
121 if (!allowNewPages)
122 return nullptr;
123
124 p = new AllocatorPage<Type, PageSize>();
125 pages.push_back(p);
126 }
127 uint pos = p->blocks[PageSize - p->available];
128 void *mem = p->at(pos);
129 p->available--;
130 p->allocated.setBit(pos);
131 Type *t = (Type*)mem;
132 return t;
133 }
134
135 qsizetype capacity() const { return pages.size() * PageSize; }
136
137 void releaseExplicit(uint pageIndex, uint index)
138 {
139 AllocatorPage<Type, PageSize> *page = pages.at(pageIndex);
140 if (!page->allocated.testBit(index))
141 qFatal("Double delete in allocator: page=%d, index=%d", pageIndex , index);
142
143 // Zero this instance as we're done with it.
144 void *mem = page->at(index);
145 memset(mem, 0, sizeof(Type));
146
147 page->allocated[index] = false;
148 page->available++;
149 page->blocks[PageSize - page->available] = index;
150
151 // Remove the pages if they are empty and they are the last ones. We need to keep the
152 // order of pages since we have references to their index, so we can only remove
153 // from the end.
154 while (page->available == PageSize && pages.size() > 1 && pages.back() == page) {
155 pages.pop_back();
156 delete page;
157 page = pages.back();
158 }
159
160 // Reset the free page to force a scan for a new free point.
161 m_freePage = 0;
162 }
163
164 void release(Type *t)
165 {
166 int pageIndex = -1;
167 for (int i=0; i<pages.size(); ++i) {
168 AllocatorPage<Type, PageSize> *p = pages.at(i);
169 if ((Type *) (&p->data[0]) <= t && (Type *) (&p->data[PageSize * sizeof(Type)]) > t) {
170 pageIndex = i;
171 break;
172 }
173 }
174 Q_ASSERT(pageIndex >= 0);
175
176 AllocatorPage<Type, PageSize> *page = pages.at(pageIndex);
177 int index = (quint64(t) - quint64(&page->data[0])) / sizeof(Type);
178
179 releaseExplicit(pageIndex, index);
180 }
181
183 int m_freePage = 0;
184};
185
186
187inline bool hasMaterialWithBlending(QSGGeometryNode *n)
188{
189 return (n->opaqueMaterial() ? n->opaqueMaterial()->flags() & QSGMaterial::Blending
190 : n->material()->flags() & QSGMaterial::Blending);
191}
192
193struct Pt {
194 float x, y;
195
196 void map(const QMatrix4x4 &mat) {
197 Pt r;
198 const float *m = mat.constData();
199 r.x = x * m[0] + y * m[4] + m[12];
200 r.y = x * m[1] + y * m[5] + m[13];
201 x = r.x;
202 y = r.y;
203 }
204
205 void set(float nx, float ny) {
206 x = nx;
207 y = ny;
208 }
209};
210
211inline QDebug operator << (QDebug d, const Pt &p) {
212 d << "Pt(" << p.x << p.y << ")";
213 return d;
214}
215
216
217
218struct Rect {
219 Pt tl, br; // Top-Left (min) and Bottom-Right (max)
220
221 void operator |= (const Pt &pt) {
222 if (pt.x < tl.x)
223 tl.x = pt.x;
224 if (pt.x > br.x)
225 br.x = pt.x;
226 if (pt.y < tl.y)
227 tl.y = pt.y;
228 if (pt.y > br.y)
229 br.y = pt.y;
230 }
231
232 void operator |= (const Rect &r) {
233 if (r.tl.x < tl.x)
234 tl.x = r.tl.x;
235 if (r.tl.y < tl.y)
236 tl.y = r.tl.y;
237 if (r.br.x > br.x)
238 br.x = r.br.x;
239 if (r.br.y > br.y)
240 br.y = r.br.y;
241 }
242
243 void map(const QMatrix4x4 &m);
244
245 void set(float left, float top, float right, float bottom) {
246 tl.set(left, top);
247 br.set(right, bottom);
248 }
249
250 bool intersects(const Rect &r) {
251 bool xOverlap = r.tl.x < br.x && r.br.x > tl.x;
252 bool yOverlap = r.tl.y < br.y && r.br.y > tl.y;
253 return xOverlap && yOverlap;
254 }
255
262};
263
264inline QDebug operator << (QDebug d, const Rect &r) {
265 d << "Rect(" << r.tl.x << r.tl.y << r.br.x << r.br.y << ")";
266 return d;
267}
268
269struct Buffer {
271 // Data is only valid while preparing the upload. Exception is if we are using the
272 // broken IBO workaround or we are using a visualization mode.
273 char *data;
274 QRhiBuffer *buf;
276};
277
279
280struct Element {
282 : boundsComputed(false)
284 , translateOnlyToRoot(false)
285 , removed(false)
286 , orphaned(false)
287 , isRenderNode(false)
288 , isMaterialBlended(false)
289 , mutabilityGroup(0)
290 {
291 }
292
293 void setNode(QSGGeometryNode *n) {
294 node = n;
295 isMaterialBlended = hasMaterialWithBlending(n);
296 mutabilityGroup = QSGNodePrivate::mutabilityGroup(n);
297 }
298
299 inline void ensureBoundsValid() {
300 if (!boundsComputed)
302 }
303 void computeBounds();
304
306 Batch *batch = nullptr;
308 Node *root = nullptr;
309
310 Rect bounds; // in device coordinates
311
312 int order = 0;
318
327};
328
329struct RenderNodeElement : public Element {
330
331 RenderNodeElement(QSGRenderNode *rn)
332 : renderNode(rn)
333 {
334 isRenderNode = true;
335 }
336
338};
339
348
353
355{
356 DrawSet(int v, int z, int i)
357 : vertices(v)
358 , zorders(z)
359 , indices(i)
360 {
361 }
363 int vertices = 0;
364 int zorders = 0;
365 int indices = 0;
366 int indexCount = 0;
367};
368
374
376{
378 {
379 NoClip = 0x00,
382 };
383 Q_DECLARE_FLAGS(ClipType, ClipTypeBit)
384
389
390 inline void reset();
391};
392
416
417struct Batch
418{
419 Batch() : drawSets(1) {}
420 bool geometryWasChanged(QSGGeometryNode *gn);
422 void invalidate();
424
425 bool isTranslateOnlyToRoot() const;
426 bool isSafeToBatch() const;
427
428 // pseudo-constructor...
429 void init() {
430 // Only non-reusable members are reset here. See Renderer::newBatch().
431 first = nullptr;
432 root = nullptr;
433 vertexCount = 0;
434 indexCount = 0;
435 isOpaque = false;
436 needsUpload = false;
437 merged = false;
439 uploadedThisFrame = false;
440 isRenderNode = false;
441 needsPurge = false;
442 clipState.reset();
443 blendConstant = QColor();
444 }
445
448
450
453
455
461
462 mutable uint uploadedThisFrame : 1; // solely for debugging purposes
463
469
471};
472
473// NOTE: Node is zero-initialized by the Allocator.
474struct Node
475{
477 void *data;
478
483
484 Node *parent() const { return m_parent; }
485
486 void append(Node *child) {
487 Q_ASSERT(child);
488 Q_ASSERT(!hasChild(child));
489 Q_ASSERT(child->m_parent == nullptr);
490 Q_ASSERT(child->m_next == nullptr);
491 Q_ASSERT(child->m_prev == nullptr);
492
493 if (!m_child) {
494 child->m_next = child;
495 child->m_prev = child;
496 m_child = child;
497 } else {
500 m_child->m_prev = child;
501 child->m_next = m_child;
502 }
503 child->setParent(this);
504 }
505
506 void remove(Node *child) {
507 Q_ASSERT(child);
508 Q_ASSERT(hasChild(child));
509
510 // only child..
511 if (child->m_next == child) {
512 m_child = nullptr;
513 } else {
514 if (m_child == child)
515 m_child = child->m_next;
516 child->m_next->m_prev = child->m_prev;
517 child->m_prev->m_next = child->m_next;
518 }
519 child->m_next = nullptr;
520 child->m_prev = nullptr;
521 child->setParent(nullptr);
522 }
523
524 Node *firstChild() const { return m_child; }
525
526 Node *sibling() const {
527 Q_ASSERT(m_parent);
528 return m_next == m_parent->m_child ? nullptr : m_next;
529 }
530
531 void setParent(Node *p) {
532 Q_ASSERT(m_parent == nullptr || p == nullptr);
533 m_parent = p;
534 }
535
536 bool hasChild(Node *child) const {
537 Node *n = m_child;
538 while (n && n != child)
539 n = n->sibling();
540 return n;
541 }
542
543
544
546
550
551 inline QSGNode::NodeType type() const { return sgNode->type(); }
552
553 inline Element *element() const {
554 Q_ASSERT(sgNode->type() == QSGNode::GeometryNodeType);
555 return (Element *) data;
556 }
557
559 Q_ASSERT(sgNode->type() == QSGNode::RenderNodeType);
560 return (RenderNodeElement *) data;
561 }
562
563 inline ClipBatchRootInfo *clipInfo() const {
564 Q_ASSERT(sgNode->type() == QSGNode::ClipNodeType);
565 return (ClipBatchRootInfo *) data;
566 }
567
568 inline BatchRootInfo *rootInfo() const {
569 Q_ASSERT(sgNode->type() == QSGNode::ClipNodeType
570 || (sgNode->type() == QSGNode::TransformNodeType && isBatchRoot));
571 return (BatchRootInfo *) data;
572 }
573};
574
576{
577public:
578 Updater(Renderer *r);
579
580 void visitOpacityNode(Node *n);
581 void visitTransformNode(Node *n);
582 void visitGeometryNode(Node *n);
583 void visitClipNode(Node *n);
585 void updateRootTransforms(Node *n, Node *root, const QMatrix4x4 &combined);
586
587 void updateStates(QSGNode *n) override;
588 void visitNode(Node *n);
589 void registerWithParentRoot(QSGNode *subRoot, QSGNode *parentRoot);
590
591private:
592 Renderer *renderer;
593
594 QDataBuffer<Node *> m_roots;
595 QDataBuffer<QMatrix4x4> m_rootMatrices;
596
597 int m_added;
598 int m_transformChange;
599 int m_opacityChange;
600
601 QMatrix4x4 m_identityMatrix;
602};
603
626
627bool operator==(const GraphicsState &a, const GraphicsState &b) noexcept;
628bool operator!=(const GraphicsState &a, const GraphicsState &b) noexcept;
629size_t qHash(const GraphicsState &s, size_t seed = 0) noexcept;
630
632
634{
639 struct {
640 size_t renderTargetDescriptionHash;
641 size_t srbLayoutDescriptionHash;
642 } extra;
644 const ShaderManagerShader *sms,
645 const QRhiRenderPassDescriptor *rpDesc,
646 const QRhiShaderResourceBindings *srb)
647 {
648 const QList<quint32> rtDesc = rpDesc->serializedFormat();
649 const QList<quint32> srbDesc = srb->serializedLayoutDescription();
650 return { state, sms, rtDesc, srbDesc, { qHash(rtDesc), qHash(srbDesc) } };
651 }
652};
653
654bool operator==(const GraphicsPipelineStateKey &a, const GraphicsPipelineStateKey &b) noexcept;
655bool operator!=(const GraphicsPipelineStateKey &a, const GraphicsPipelineStateKey &b) noexcept;
656size_t qHash(const GraphicsPipelineStateKey &k, size_t seed = 0) noexcept;
657
664
665bool operator==(const ShaderKey &a, const ShaderKey &b) noexcept;
666bool operator!=(const ShaderKey &a, const ShaderKey &b) noexcept;
667size_t qHash(const ShaderKey &k, size_t seed = 0) noexcept;
668
679
681{
682 const QSGMaterialShader *srbShader = nullptr;
683 QRhiBuffer *ubuf = nullptr;
684 QRhiTexture *texture = nullptr;
685 QRhiSampler *sampler = nullptr;
687 bool srbValid = false;
688
689 const ShaderManagerShader *psSms = nullptr;
692};
693
694class ShaderManager : public QObject
695{
697public:
699
700 ShaderManager(QSGDefaultRenderContext *ctx) : context(ctx) { }
702 qDeleteAll(rewrittenShaders);
703 qDeleteAll(stockShaders);
704 }
705
707
709
712
714
715public Q_SLOTS:
716 void invalidated();
717
718public:
719 Shader *prepareMaterial(QSGMaterial *material,
720 const QSGGeometry *geometry = nullptr,
721 QSGRendererInterface::RenderMode renderMode = QSGRendererInterface::RenderMode2D,
722 int multiViewCount = 0);
723 Shader *prepareMaterialNoRewrite(QSGMaterial *material,
724 const QSGGeometry *geometry = nullptr,
725 QSGRendererInterface::RenderMode renderMode = QSGRendererInterface::RenderMode2D,
726 int multiViewCount = 0);
727
728private:
729 QHash<ShaderKey, Shader *> rewrittenShaders;
730 QHash<ShaderKey, Shader *> stockShaders;
731
732 QSGDefaultRenderContext *context;
733};
734
743
745{
746public:
754
755 Visualizer(Renderer *renderer);
756 virtual ~Visualizer();
757
759 void setMode(VisualizeMode mode) { m_visualizeMode = mode; }
760
761 virtual void visualizeChangesPrepare(Node *n, uint parentChanges = 0);
762 virtual void prepareVisualize() = 0;
763 virtual void visualize() = 0;
764
765 virtual void releaseResources() = 0;
766
767protected:
768 Renderer *m_renderer;
771};
772
773class Q_QUICK_EXPORT Renderer : public QSGRenderer
774{
775public:
777 ~Renderer();
778
779protected:
781 void render() override;
782 void prepareInline() override;
783 void renderInline() override;
785
790
803
804#ifdef QT_BUILD_INTERNAL
805 // For autotests.
807#endif
808
809 // update batches and queue and commit rhi resource updates
811 // records the beginPass()
813 // records the draw calls, must be preceded by a prepareRenderPass at minimum,
814 // and also surrounded by begin/endRenderPass unless we are recording inside an
815 // already started pass.
817 // does visualizing if enabled and records the endPass()
819
820private:
821 enum RebuildFlag {
823 BuildRenderLists = 0x0002,
824 BuildBatches = 0x0004,
825 FullRebuild = 0xffff
826 };
827
828 friend class Updater;
829 friend class RhiVisualizer;
830
832 void map(Buffer *buffer, quint32 byteSize, bool isIndexBuf = false);
833 void unmap(Buffer *buffer, bool isIndexBuf = false);
834
837 void tagSubRoots(Node *node);
839
844 bool checkOverlap(int first, int last, const Rect &bounds);
845 void prepareAlphaBatches();
847
848 void uploadBatch(Batch *b);
849 void uploadMergedElement(Element *e, int vaOffset, char **vertexData, char **zData, char **indexData, void *iBasePtr, int *indexCount);
850
851 bool ensurePipelineState(Element *e, const ShaderManager::Shader *sms, bool depthPostPass = false);
867 const ShaderManager::Shader *sms, bool depthPostPass = false);
869 void updateClip(const QSGClipNode *clipList, const Batch *batch);
873 void enqueueStencilDraw(const Batch *batch);
877 void renderRhiRenderNode(const Batch *batch);
880
887 void nodeWasRemoved(Node *node);
891
892 inline Batch *newBatch();
894 void releaseElement(Element *e, bool inDestructor = false);
895
898
905 bool m_partialRebuild;
908
913
918
923
926#if defined(QSGBATCHRENDERER_INVALIDATE_WEDGED_NODES)
929#endif
930
936
938
939 ShaderManager *m_shaderManager; // per rendercontext, shared
944
947 const QRhiRenderPassDescriptor *m_lastRpDesc = nullptr;
949
952
955
958 QRhiBuffer *m_uniformBuffer = nullptr;
963 bool m_uniformBufferFailed = false;
970 QRhiTexture *m_dummyTexture = nullptr;
971
972 struct StencilClipCommonData {
974 QRhiGraphicsPipeline *incrPs = nullptr;
975 QShader vs;
976 QShader fs;
979 inline void reset();
981
982 inline int mergedIndexElemSize() const;
983 inline bool useDepthBuffer() const;
984 inline void setStateForDepthPostPass();
985};
986
988{
989 Batch *b;
990 int size = m_batchPool.size();
991 if (size) {
992 b = m_batchPool.at(size - 1);
993 // vbo, ibo, stencil-related buffers are reused
995 } else {
996 b = new Batch();
997 Q_ASSERT(offsetof(Batch, ibo) == sizeof(Buffer) + offsetof(Batch, vbo));
998 memset(&b->vbo, 0, sizeof(Buffer) * 2); // Clear VBO & IBO
1000 }
1001 // initialize (when new batch) or reset (when reusing a batch) the non-reusable fields
1002 b->init();
1003 return b;
1004}
1005
1006int Renderer::mergedIndexElemSize() const
1007{
1008 return m_uint32IndexForRhi ? sizeof(quint32) : sizeof(quint16);
1009}
1010
1011// "use" here means that both depth test and write is wanted (the latter for
1012// opaque batches only). Therefore neither RenderMode2DNoDepthBuffer nor
1013// RenderMode3D must result in true. So while RenderMode3D requires a depth
1014// buffer, this here must say false. In addition, m_forceNoDepthBuffer is a
1015// dynamic override relevant with QSGRenderNode.
1016//
1017bool Renderer::useDepthBuffer() const
1018{
1020}
1021
1023{
1024 m_gstate.colorWrite = {};
1025 m_gstate.depthWrite = true;
1026 m_gstate.depthTest = true;
1028}
1029
1031{
1032 delete replacePs;
1033 replacePs = nullptr;
1034
1035 delete incrPs;
1036 incrPs = nullptr;
1037
1038 vs = QShader();
1039 fs = QShader();
1040}
1041
1043{
1044 clipList = nullptr;
1045 type = NoClip;
1046 stencilRef = 0;
1047}
1048
1050{
1051 updateStencilBuffer = false;
1052
1053 delete srb;
1054 srb = nullptr;
1055
1056 delete vbuf;
1057 vbuf = nullptr;
1058
1059 delete ibuf;
1060 ibuf = nullptr;
1061
1062 delete ubuf;
1063 ubuf = nullptr;
1064
1065 drawCalls.reset();
1066}
1067
1068}
1069
1074
1075QT_END_NAMESPACE
1076
1077#endif // QSGBATCHRENDERER_P_H
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:326
const Type * at(uint index) const
char data[sizeof(Type) *PageSize]
QList< AllocatorPage< Type, PageSize > * > pages
void releaseExplicit(uint pageIndex, uint index)
Type * allocate(bool allowNewPages=true)
QMultiHash< QList< quint32 >, QRhiShaderResourceBindings * > srbPool
Shader * prepareMaterial(QSGMaterial *material, const QSGGeometry *geometry=nullptr, QSGRendererInterface::RenderMode renderMode=QSGRendererInterface::RenderMode2D, int multiViewCount=0)
QList< quint32 > srbLayoutDescSerializeWorkspace
QHash< GraphicsPipelineStateKey, QRhiGraphicsPipeline * > pipelineCache
ShaderManager(QSGDefaultRenderContext *ctx)
Shader * prepareMaterialNoRewrite(QSGMaterial *material, const QSGGeometry *geometry=nullptr, QSGRendererInterface::RenderMode renderMode=QSGRendererInterface::RenderMode2D, int multiViewCount=0)
void updateRootTransforms(Node *n, Node *root, const QMatrix4x4 &combined)
void registerWithParentRoot(QSGNode *subRoot, QSGNode *parentRoot)
void updateStates(QSGNode *n) override
void updateRootTransforms(Node *n)
virtual void visualize()=0
void setMode(VisualizeMode mode)
virtual void visualizeChangesPrepare(Node *n, uint parentChanges=0)
virtual void prepareVisualize()=0
virtual void releaseResources()=0
QHash< Node *, uint > m_visualizeChangeSet
const int ZORDER_BUFFER_BINDING
static void qsg_wipeBuffer(Buffer *buffer)
static void rendererToMaterialGraphicsState(QSGMaterialShader::GraphicsPipelineState *dst, GraphicsState *src)
size_t qHash(const GraphicsState &s, size_t seed) noexcept
static QRhiVertexInputLayout calculateVertexInputLayout(const QSGMaterialShader *s, const QSGGeometry *geometry, bool batchable)
static void qsg_addBackOrphanedElements(QDataBuffer< Element * > &orphans, QDataBuffer< Element * > &renderList)
bool operator!=(const GraphicsPipelineStateKey &a, const GraphicsPipelineStateKey &b) noexcept
const float VIEWPORT_MIN_DEPTH
QSGMaterial::Flag QSGMaterial_FullMatrix
bool qsg_sort_batch_decreasing_order(Batch *a, Batch *b)
QDebug operator<<(QDebug d, const Pt &p)
QDebug operator<<(QDebug d, const Rect &r)
bool operator==(const ShaderKey &a, const ShaderKey &b) noexcept
bool operator==(const GraphicsPipelineStateKey &a, const GraphicsPipelineStateKey &b) noexcept
bool operator!=(const ShaderKey &a, const ShaderKey &b) noexcept
static void qsg_wipeBatch(Batch *batch)
static QRhiSampler * newSampler(QRhi *rhi, const QSGSamplerDescription &desc)
QRhiVertexInputAttribute::Format qsg_vertexInputFormat(const QSGGeometry::Attribute &a)
QRhiGraphicsPipeline::Topology qsg_topology(int geomDrawMode, QRhi *rhi)
QMatrix4x4 qsg_matrixForRoot(Node *node)
bool qsg_sort_batch_increasing_order(Batch *a, Batch *b)
static void qsg_addOrphanedElements(QDataBuffer< Element * > &orphans, const QDataBuffer< Element * > &renderList)
void qsg_setMultiViewFlagsOnMaterial(QSGMaterial *material, int multiViewCount)
const float VIEWPORT_MAX_DEPTH
int qsg_positionAttribute(QSGGeometry *g)
const quint32 MIN_UNIFORM_BUFFER_SIZE
static int size_of_type(int type)
static bool isTranslate(const QMatrix4x4 &m)
static int qsg_countNodesInBatches(const QDataBuffer< Batch * > &batches)
static float calculateElementZOrder(const Element *e, qreal zRange)
static int qsg_fixIndexCount(int iCount, int drawMode)
bool qsg_sort_element_increasing_order(Element *a, Element *b)
static void materialToRendererGraphicsState(GraphicsState *dst, QSGMaterialShader::GraphicsPipelineState *src)
static bool needsBlendConstant(QRhiGraphicsPipeline::BlendFactor f)
const int VERTEX_BUFFER_BINDING
const uint DYNAMIC_VERTEX_INDEX_BUFFER_THRESHOLD
bool hasMaterialWithBlending(QSGGeometryNode *n)
static int qsg_countNodesInBatch(const Batch *batch)
const int UNIFORM_BUFFER_SHRINK_FRAMES
bool operator==(const GraphicsState &a, const GraphicsState &b) noexcept
QRhiCommandBuffer::IndexFormat qsg_indexFormat(const QSGGeometry *geometry)
bool operator!=(const GraphicsState &a, const GraphicsState &b) noexcept
bool qsg_sort_element_decreasing_order(Element *a, Element *b)
size_t qHash(const ShaderKey &k, size_t seed) noexcept
void qsg_dumpShadowRoots(BatchRootInfo *i, int indent)
void qsg_dumpShadowRoots(Node *n)
static bool isScale(const QMatrix4x4 &m)
static bool is2DSafe(const QMatrix4x4 &m)
size_t qHash(const GraphicsPipelineStateKey &k, size_t seed) noexcept
Int aligned(Int v, Int byteAlign)
const quint32 DEFAULT_BUFFER_POOL_SIZE_LIMIT
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2620
#define DECLARE_DEBUG_VAR(variable)
#define QSGNODE_DIRTY_PARENT
QT_BEGIN_NAMESPACE int qt_sg_envInt(const char *name, int defaultValue)
#define SHADOWNODE_TRAVERSE(NODE)
#define QSGNODE_TRAVERSE(NODE)
Q_DECLARE_TYPEINFO(QSGBatchRenderer::DrawSet, Q_PRIMITIVE_TYPE)
Q_DECLARE_TYPEINFO(QSGBatchRenderer::GraphicsState, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(QSGBatchRenderer::GraphicsPipelineStateKey, Q_RELOCATABLE_TYPE)
#define QSG_RENDERER_COORD_LIMIT
Q_DECLARE_TYPEINFO(QSGBatchRenderer::RenderPassState, Q_RELOCATABLE_TYPE)
bool geometryWasChanged(QSGGeometryNode *gn)
BatchCompatibility isMaterialCompatible(Element *e) const
StencilClipState stencilClipState
QDataBuffer< DrawSet > drawSets
DrawSet(int v, int z, int i)
QRhiGraphicsPipeline * depthPostPassPs
QRhiShaderResourceBindings * srb
QRhiGraphicsPipeline * ps
ElementPreparedState * prepared
void setNode(QSGGeometryNode *n)
static GraphicsPipelineStateKey create(const GraphicsState &state, const ShaderManagerShader *sms, const QRhiRenderPassDescriptor *rpDesc, const QRhiShaderResourceBindings *srb)
QSGGeometry::DrawingMode drawMode
QSGNode::NodeType type() const
BatchRootInfo * rootInfo() const
QSGNode::DirtyState dirtyState
ClipBatchRootInfo * clipInfo() const
RenderNodeElement * renderNodeElement() const
bool hasChild(Node *child) const
void map(const QMatrix4x4 &mat)
void set(float nx, float ny)
void operator|=(const Pt &pt)
void set(float left, float top, float right, float bottom)
void map(const QMatrix4x4 &m)
bool intersects(const Rect &r)
void operator|=(const Rect &r)
const QMatrix4x4 * projectionMatrix() const override
const QRegion * clipRegion() const override
QRhiDepthStencilClearValue dsClear
QSGRendererInterface::RenderMode renderMode
QVarLengthArray< QRhiShaderStage, 2 > stages
QRhiShaderResourceBindings * srb
QDataBuffer< StencilDrawCall > drawCalls