Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qrhi_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QRHI_P_H
5#define QRHI_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <rhi/qrhi.h>
19#include <QBitArray>
20#include <QAtomicInt>
21#include <QElapsedTimer>
22#include <QLoggingCategory>
23#include <QtCore/qset.h>
24#include <QtCore/qvarlengtharray.h>
25
27
28#define QRHI_RES(t, x) static_cast<t *>(x)
29#define QRHI_RES_RHI(t) t *rhiD = static_cast<t *>(m_rhi)
30
31Q_DECLARE_LOGGING_CATEGORY(QRHI_LOG_INFO)
32
34{
35public:
36 virtual ~QRhiImplementation();
37
38 virtual bool create(QRhi::Flags flags) = 0;
39 virtual void destroy() = 0;
40
45 QRhiBuffer::UsageFlags usage,
46 quint32 size) = 0;
48 const QSize &pixelSize,
49 int sampleCount,
50 QRhiRenderBuffer::Flags flags,
51 QRhiTexture::Format backingFormatHint) = 0;
53 const QSize &pixelSize,
54 int depth,
55 int arraySize,
56 int sampleCount,
57 QRhiTexture::Flags flags) = 0;
59 QRhiSampler::Filter minFilter,
60 QRhiSampler::Filter mipmapMode,
64
66 QRhiTextureRenderTarget::Flags flags) = 0;
67
69 virtual QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) = 0;
70 virtual QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) = 0;
71 virtual QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) = 0;
72 virtual QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) = 0;
74
75 virtual void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0;
76
79 const QColor &colorClearValue,
80 const QRhiDepthStencilClearValue &depthStencilClearValue,
81 QRhiResourceUpdateBatch *resourceUpdates,
82 QRhiCommandBuffer::BeginPassFlags flags) = 0;
83 virtual void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0;
84
86 QRhiGraphicsPipeline *ps) = 0;
87
90 int dynamicOffsetCount,
91 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) = 0;
92
94 int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings,
95 QRhiBuffer *indexBuf, quint32 indexOffset,
96 QRhiCommandBuffer::IndexFormat indexFormat) = 0;
97
99 virtual void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) = 0;
100 virtual void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) = 0;
101 virtual void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) = 0;
102
103 virtual void draw(QRhiCommandBuffer *cb, quint32 vertexCount,
104 quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) = 0;
105 virtual void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
106 quint32 instanceCount, quint32 firstIndex,
107 qint32 vertexOffset, quint32 firstInstance) = 0;
108
111 virtual void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) = 0;
112
114 QRhiResourceUpdateBatch *resourceUpdates,
115 QRhiCommandBuffer::BeginPassFlags flags) = 0;
116 virtual void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0;
118 virtual void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) = 0;
119
122 virtual void endExternal(QRhiCommandBuffer *cb) = 0;
124
125 virtual QList<int> supportedSampleCounts() const = 0;
126 virtual int ubufAlignment() const = 0;
127 virtual bool isYUpInFramebuffer() const = 0;
128 virtual bool isYUpInNDC() const = 0;
129 virtual bool isClipDepthZeroToOne() const = 0;
130 virtual QMatrix4x4 clipSpaceCorrMatrix() const = 0;
131 virtual bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const = 0;
132 virtual bool isFeatureSupported(QRhi::Feature feature) const = 0;
134 virtual const QRhiNativeHandles *nativeHandles() = 0;
135 virtual QRhiDriverInfo driverInfo() const = 0;
136 virtual QRhiStats statistics() = 0;
138 virtual void releaseCachedResources() = 0;
139 virtual bool isDeviceLost() const = 0;
140
142 virtual void setPipelineCacheData(const QByteArray &data) = 0;
143
144 void prepareForCreate(QRhi *rhi, QRhi::Implementation impl, QRhi::Flags flags);
145
147 void compressedFormatInfo(QRhiTexture::Format format, const QSize &size,
148 quint32 *bpl, quint32 *byteSize,
149 QSize *blockDim) const;
150 void textureFormatInfo(QRhiTexture::Format format, const QSize &size,
151 quint32 *bpl, quint32 *byteSize, quint32 *bytesPerPixel) const;
152 bool isStencilSupportingFormat(QRhiTexture::Format format) const;
153
154 void registerResource(QRhiResource *res, bool ownsNativeResources = true)
155 {
156 // The ownsNativeResources is relevant for the (graphics resource) leak
157 // check in ~QRhiImplementation; when false, the registration's sole
158 // purpose is to automatically null out the resource's m_rhi pointer in
159 // case the rhi goes away first. (which should not happen in
160 // well-written applications but we try to be graceful)
161 resources.insert(res, ownsNativeResources);
162 }
163
165 {
166 resources.remove(res);
167 }
168
170 {
171 if (inFrame)
172 pendingDeleteResources.insert(res);
173 else
174 delete res;
175 }
176
178 {
179 cleanupCallbacks.append(callback);
180 }
181
182 void addCleanupCallback(const void *key, const QRhi::CleanupCallback &callback)
183 {
184 keyedCleanupCallbacks[key] = callback;
185 }
186
187 void removeCleanupCallback(const void *key)
188 {
189 keyedCleanupCallbacks.remove(key);
190 }
191
192 bool sanityCheckGraphicsPipeline(QRhiGraphicsPipeline *ps);
193 bool sanityCheckShaderResourceBindings(QRhiShaderResourceBindings *srb);
194 void updateLayoutDesc(QRhiShaderResourceBindings *srb);
195
197 {
198 const quint32 ver = (QT_VERSION_MAJOR << 16) | (QT_VERSION_MINOR << 8) | (QT_VERSION_PATCH);
199 return (quint32(implType) << 24) | ver;
200 }
201
203 {
204 pipelineCreationTimer.start();
205 }
206
208 {
209 accumulatedPipelineCreationTime += pipelineCreationTimer.elapsed();
210 }
211
213 {
214 return accumulatedPipelineCreationTime;
215 }
216
217 QRhiVertexInputAttribute::Format shaderDescVariableFormatToVertexInputFormat(QShaderDescription::VariableType type) const;
218 quint32 byteSizePerVertexForVertexInputFormat(QRhiVertexInputAttribute::Format format) const;
219
221 {
222 return &binding.d;
223 }
224
226 {
227 return &binding.d;
228 }
229
231 {
232 return a.d.binding < b.d.binding;
233 }
234
235 int effectiveSampleCount(int sampleCount) const;
236
238
239 static const int MAX_SHADER_CACHE_ENTRIES = 128;
240
241 bool debugMarkers = false;
242 int currentFrameSlot = 0; // for vk, mtl, and similar. unused by gl and d3d11.
243 bool inFrame = false;
244
245private:
246 QRhi::Implementation implType;
247 QThread *implThread;
248 QVarLengthArray<QRhiResourceUpdateBatch *, 4> resUpdPool;
249 quint64 resUpdPoolMap = 0;
250 int lastResUpdIdx = -1;
251 QHash<QRhiResource *, bool> resources;
252 QSet<QRhiResource *> pendingDeleteResources;
253 QVarLengthArray<QRhi::CleanupCallback, 4> cleanupCallbacks;
254 QHash<const void *, QRhi::CleanupCallback> keyedCleanupCallbacks;
255 QElapsedTimer pipelineCreationTimer;
256 qint64 accumulatedPipelineCreationTime = 0;
257
258 friend class QRhi;
260};
261
267
268template<QRhiTargetRectBoundMode boundingMode, typename T, size_t N>
269bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array<T, N> &r,
270 T *x, T *y, T *w, T *h)
271{
272 // x,y are bottom-left in QRhiScissor and QRhiViewport but top-left in
273 // Vulkan/Metal/D3D. Our input is an OpenGL-style scissor rect where both
274 // negative x or y, and partly or completely out of bounds rects are
275 // allowed. The only thing the input here cannot have is a negative width
276 // or height. We must handle all other input gracefully, clamping to a zero
277 // width or height rect in the worst case, and ensuring the resulting rect
278 // is inside the rendertarget's bounds because some APIs' validation/debug
279 // layers are allergic to out of bounds scissor rects.
280
281 const T outputWidth = outputSize.width();
282 const T outputHeight = outputSize.height();
283 const T inputWidth = r[2];
284 const T inputHeight = r[3];
285
286 if (inputWidth < 0 || inputHeight < 0)
287 return false;
288
289 *x = r[0];
290 *y = outputHeight - (r[1] + inputHeight);
291 *w = inputWidth;
292 *h = inputHeight;
293
294 if (boundingMode == Bounded) {
295 const T widthOffset = *x < 0 ? -*x : 0;
296 const T heightOffset = *y < 0 ? -*y : 0;
297 *w = *x < outputWidth ? qMax<T>(0, inputWidth - widthOffset) : 0;
298 *h = *y < outputHeight ? qMax<T>(0, inputHeight - heightOffset) : 0;
299
300 if (outputWidth > 0)
301 *x = qBound<T>(0, *x, outputWidth - 1);
302 if (outputHeight > 0)
303 *y = qBound<T>(0, *y, outputHeight - 1);
304
305 if (*x + *w > outputWidth)
306 *w = qMax<T>(0, outputWidth - *x);
307 if (*y + *h > outputHeight)
308 *h = qMax<T>(0, outputHeight - *y);
309 }
310 return true;
311}
312
314{
315 Q_DISABLE_COPY_MOVE(QRhiBufferDataPrivate)
318 int ref = 1;
321 char *largeData = nullptr;
322 static constexpr quint32 SMALL_DATA_SIZE = 1024;
324};
325
326// no detach-with-contents, no atomic refcount, no shrink
328{
329public:
330 QRhiBufferData() = default;
332 {
333 if (d && !--d->ref)
334 delete d;
335 }
337 : d(other.d)
338 {
339 if (d)
340 d->ref += 1;
341 }
343 {
344 if (d == other.d)
345 return *this;
346 if (other.d)
347 other.d->ref += 1;
348 if (d && !--d->ref)
349 delete d;
350 d = other.d;
351 return *this;
352 }
353 const char *constData() const
354 {
356 }
357 quint32 size() const
358 {
359 return d->size;
360 }
361 void assign(const char *s, quint32 size)
362 {
363 if (!d) {
364 d = new QRhiBufferDataPrivate;
365 } else if (d->ref != 1) {
366 d->ref -= 1;
367 d = new QRhiBufferDataPrivate;
368 }
369 d->size = size;
371 memcpy(d->data, s, size);
372 } else {
373 if (d->largeAlloc < size) {
374 delete[] d->largeData;
375 d->largeAlloc = size;
376 d->largeData = new char[size];
377 }
378 memcpy(d->largeData, s, size);
379 }
380 }
381private:
382 QRhiBufferDataPrivate *d = nullptr;
383};
384
386
388{
389public:
390 struct BufferOp {
402
404 {
405 BufferOp op = {};
406 op.type = DynamicUpdate;
407 op.buf = buf;
408 op.offset = offset;
409 const int effectiveSize = size ? size : buf->size();
410 op.data.assign(reinterpret_cast<const char *>(data), effectiveSize);
411 return op;
412 }
413
415 {
416 op->type = DynamicUpdate;
417 op->buf = buf;
418 op->offset = offset;
419 const int effectiveSize = size ? size : buf->size();
420 op->data.assign(reinterpret_cast<const char *>(data), effectiveSize);
421 }
422
424 {
425 BufferOp op = {};
426 op.type = StaticUpload;
427 op.buf = buf;
428 op.offset = offset;
429 const int effectiveSize = size ? size : buf->size();
430 op.data.assign(reinterpret_cast<const char *>(data), effectiveSize);
431 return op;
432 }
433
435 {
436 op->type = StaticUpload;
437 op->buf = buf;
438 op->offset = offset;
439 const int effectiveSize = size ? size : buf->size();
440 op->data.assign(reinterpret_cast<const char *>(data), effectiveSize);
441 }
442
444 {
445 BufferOp op = {};
446 op.type = Read;
447 op.buf = buf;
448 op.offset = offset;
449 op.readSize = size;
450 op.result = result;
451 return op;
452 }
453 };
454
455 struct TextureOp {
464 // Specifying multiple uploads for a subresource must be supported.
465 // In the backend this can then end up, where applicable, as a
466 // single, batched copy operation with only one set of barriers.
467 // This helps when doing for example glyph cache fills.
468 using MipLevelUploadList = std::array<QVector<QRhiTextureSubresourceUploadDescription>, QRhi::MAX_MIP_LEVELS>;
469 QVarLengthArray<MipLevelUploadList, 6> subresDesc;
474
476 {
477 TextureOp op = {};
478 op.type = Upload;
479 op.dst = tex;
480 int maxLayer = -1;
481 for (auto it = desc.cbeginEntries(), itEnd = desc.cendEntries(); it != itEnd; ++it) {
482 if (it->layer() > maxLayer)
483 maxLayer = it->layer();
484 }
485 op.subresDesc.resize(maxLayer + 1);
486 for (auto it = desc.cbeginEntries(), itEnd = desc.cendEntries(); it != itEnd; ++it)
487 op.subresDesc[it->layer()][it->level()].append(it->description());
488 return op;
489 }
490
492 {
493 TextureOp op = {};
494 op.type = Copy;
495 op.dst = dst;
496 op.src = src;
497 op.desc = desc;
498 return op;
499 }
500
502 {
503 TextureOp op = {};
504 op.type = Read;
505 op.rb = rb;
506 op.result = result;
507 return op;
508 }
509
511 {
512 TextureOp op = {};
513 op.type = GenMips;
514 op.dst = tex;
515 return op;
516 }
517 };
518
519 int activeBufferOpCount = 0; // this is the real number of used elements in bufferOps, not bufferOps.count()
520 static const int BUFFER_OPS_STATIC_ALLOC = 1024;
521 QVarLengthArray<BufferOp, BUFFER_OPS_STATIC_ALLOC> bufferOps;
522
523 int activeTextureOpCount = 0; // this is the real number of used elements in textureOps, not textureOps.count()
524 static const int TEXTURE_OPS_STATIC_ALLOC = 256;
525 QVarLengthArray<TextureOp, TEXTURE_OPS_STATIC_ALLOC> textureOps;
526
529 int poolIndex = -1;
530
531 void free();
533 bool hasOptimalCapacity() const;
534 void trimOpLists();
535
537};
538
539template<typename T>
541{
542 void feed(int binding, T resource) { // binding must be strictly increasing
543 if (curBinding == -1 || binding > curBinding + 1) {
544 finish();
545 curBatch.startBinding = binding;
546 curBatch.resources.clear();
547 curBatch.resources.append(resource);
548 } else {
549 Q_ASSERT(binding == curBinding + 1);
550 curBatch.resources.append(resource);
551 }
552 curBinding = binding;
553 }
554
555 bool finish() {
556 if (!curBatch.resources.isEmpty())
557 batches.append(curBatch);
558 return !batches.isEmpty();
559 }
560
561 void clear() {
562 batches.clear();
563 curBatch.resources.clear();
564 curBinding = -1;
565 }
566
567 struct Batch {
569 QVarLengthArray<T, 4> resources;
570
571 bool operator==(const Batch &other) const
572 {
573 return startBinding == other.startBinding && resources == other.resources;
574 }
575
576 bool operator!=(const Batch &other) const
577 {
578 return !operator==(other);
579 }
580 };
581
582 QVarLengthArray<Batch, 4> batches; // sorted by startBinding
583
584 bool operator==(const QRhiBatchedBindings<T> &other) const
585 {
586 return batches == other.batches;
587 }
588
589 bool operator!=(const QRhiBatchedBindings<T> &other) const
590 {
591 return !operator==(other);
592 }
593
594private:
595 Batch curBatch;
596 int curBinding = -1;
597};
598
600{
601public:
602#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
603 using Type = quint64;
604#else
605 using Type = quint32;
606#endif
607 static Type newId();
608};
609
611{
612public:
613 bool isEmpty() const;
614 void reset();
615
616 struct UsageState {
619 int stage;
620 };
621
631
640
642 const UsageState &state);
643
654
663
665 const UsageState &state);
666
673
675 BufferIterator cbeginBuffers() const { return m_buffers.cbegin(); }
676 BufferIterator cendBuffers() const { return m_buffers.cend(); }
677
683
685 TextureIterator cbeginTextures() const { return m_textures.cbegin(); }
686 TextureIterator cendTextures() const { return m_textures.cend(); }
687
688 static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages);
689 static TextureStage toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages);
690
691private:
692 QHash<QRhiBuffer *, Buffer> m_buffers;
693 QHash<QRhiTexture *, Texture> m_textures;
694};
695
698
699template<typename T, int GROW = 1024>
701{
702public:
705 inline void reset() { p = 0; }
706 inline bool isEmpty() const { return p == 0; }
707 inline T &get() {
708 if (p == a) {
709 a += GROW;
710 T *nv = new T[a];
711 if (v) {
712 memcpy(nv, v, p * sizeof(T));
713 delete[] v;
714 }
715 v = nv;
716 }
717 return v[p++];
718 }
719 inline void unget() { --p; }
720 inline T *cbegin() const { return v; }
721 inline T *cend() const { return v + p; }
722 inline T *begin() { return v; }
723 inline T *end() { return v + p; }
724private:
725 Q_DISABLE_COPY(QRhiBackendCommandList)
726 T *v = nullptr;
727 int a = 0;
728 int p = 0;
729};
730
732{
734 using ResIdList = QVarLengthArray<ResId, 8 * 2 + 1>; // color, resolve, ds
735
736 template<typename TexType, typename RenderBufferType>
738
739 template<typename TexType, typename RenderBufferType>
740 static bool isUpToDate(const QRhiTextureRenderTargetDescription &desc, const ResIdList &currentResIdList);
741};
742
744{
745 return a.id == b.id && a.generation == b.generation;
746}
747
752
753template<typename TexType, typename RenderBufferType>
755{
756 const bool hasDepthStencil = desc.depthStencilBuffer() || desc.depthTexture();
757 dst->resize(desc.colorAttachmentCount() * 2 + (hasDepthStencil ? 1 : 0));
758 int n = 0;
759 for (auto it = desc.cbeginColorAttachments(), itEnd = desc.cendColorAttachments(); it != itEnd; ++it, ++n) {
760 const QRhiColorAttachment &colorAtt(*it);
761 if (colorAtt.texture()) {
762 TexType *texD = QRHI_RES(TexType, colorAtt.texture());
763 (*dst)[n] = { texD->globalResourceId(), texD->generation };
764 } else if (colorAtt.renderBuffer()) {
765 RenderBufferType *rbD = QRHI_RES(RenderBufferType, colorAtt.renderBuffer());
766 (*dst)[n] = { rbD->globalResourceId(), rbD->generation };
767 } else {
768 (*dst)[n] = { 0, 0 };
769 }
770 ++n;
771 if (colorAtt.resolveTexture()) {
772 TexType *texD = QRHI_RES(TexType, colorAtt.resolveTexture());
773 (*dst)[n] = { texD->globalResourceId(), texD->generation };
774 } else {
775 (*dst)[n] = { 0, 0 };
776 }
777 }
778 if (hasDepthStencil) {
779 if (desc.depthTexture()) {
780 TexType *depthTexD = QRHI_RES(TexType, desc.depthTexture());
781 (*dst)[n] = { depthTexD->globalResourceId(), depthTexD->generation };
782 } else if (desc.depthStencilBuffer()) {
783 RenderBufferType *depthRbD = QRHI_RES(RenderBufferType, desc.depthStencilBuffer());
784 (*dst)[n] = { depthRbD->globalResourceId(), depthRbD->generation };
785 } else {
786 (*dst)[n] = { 0, 0 };
787 }
788 }
789}
790
791template<typename TexType, typename RenderBufferType>
793{
794 // Just as setShaderResources() recognizes if an srb's referenced
795 // resources have been rebuilt (got a create() since the srb's
796 // create()), we should do the same for the textures and renderbuffers
797 // referenced from the rendertarget. It is not uncommon that a texture
798 // or ds buffer gets resized due to following a window size in some
799 // form, which involves a create() on them. It is then nice if the
800 // render target auto-rebuilds in beginPass().
801
802 ResIdList resIdList;
803 updateResIdList<TexType, RenderBufferType>(desc, &resIdList);
804 return resIdList == currentResIdList;
805}
806
807template<typename T>
809{
810 Q_ASSERT(objectIndex < std::size(pd->reserved));
811 if (!pd->reserved[objectIndex]) // // was not set, no other choice, do it here, whatever thread this is
813 return static_cast<T *>(pd->reserved[objectIndex]);
814}
815
817
818#endif
\inmodule QtCore
Definition qbytearray.h:57
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
\inmodule QtCore
Definition qhash.h:1145
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
QRhiBackendCommandList()=default
T * cend() const
Definition qrhi_p.h:721
T * cbegin() const
Definition qrhi_p.h:720
bool isEmpty() const
Definition qrhi_p.h:706
QRhiBufferData()=default
void assign(const char *s, quint32 size)
Definition qrhi_p.h:361
quint32 size() const
Definition qrhi_p.h:357
QRhiBufferData(const QRhiBufferData &other)
Definition qrhi_p.h:336
QRhiBufferData & operator=(const QRhiBufferData &other)
Definition qrhi_p.h:342
const char * constData() const
Definition qrhi_p.h:353
\inmodule QtGui
Definition qrhi.h:846
Type
Specifies storage type of buffer resource.
Definition qrhi.h:848
\inmodule QtGui
Definition qrhi.h:576
QRhiRenderBuffer * renderBuffer() const
Definition qrhi.h:585
QRhiTexture * texture() const
Definition qrhi.h:582
QRhiTexture * resolveTexture() const
Definition qrhi.h:594
\inmodule QtGui
Definition qrhi.h:1651
QPair< int, quint32 > DynamicOffset
Synonym for QPair<int, quint32>.
Definition qrhi.h:1676
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
Definition qrhi.h:1680
IndexFormat
Specifies the index data type.
Definition qrhi.h:1653
\inmodule QtGui
Definition qrhi.h:1622
\inmodule QtGui
Definition qrhi.h:44
\inmodule QtGui
Definition qrhi.h:1270
virtual bool isClipDepthZeroToOne() const =0
virtual void endExternal(QRhiCommandBuffer *cb)=0
virtual QRhiTextureRenderTarget * createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags)=0
virtual QRhiComputePipeline * createComputePipeline()=0
virtual QRhiGraphicsPipeline * createGraphicsPipeline()=0
virtual void beginPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags)=0
virtual void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps)=0
void removeCleanupCallback(const void *key)
Definition qrhi_p.h:187
virtual void releaseCachedResources()=0
virtual bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const =0
void unregisterResource(QRhiResource *res)
Definition qrhi_p.h:164
virtual QRhiDriverInfo driverInfo() const =0
static const QRhiShaderResourceBinding::Data * shaderResourceBindingData(const QRhiShaderResourceBinding &binding)
Definition qrhi_p.h:220
quint32 pipelineCacheRhiId() const
Definition qrhi_p.h:196
virtual QRhiSampler * createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w)=0
virtual QRhiTexture * createTexture(QRhiTexture::Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, QRhiTexture::Flags flags)=0
virtual bool isYUpInFramebuffer() const =0
virtual QList< int > supportedSampleCounts() const =0
virtual void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
virtual void debugMarkEnd(QRhiCommandBuffer *cb)=0
virtual QRhi::FrameOpResult finish()=0
virtual QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags)=0
virtual void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
virtual int ubufAlignment() const =0
virtual QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags)=0
virtual void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
virtual void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags)=0
virtual void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c)=0
virtual void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name)=0
virtual int resourceLimit(QRhi::ResourceLimit limit) const =0
virtual void setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBindings *srb, int dynamicOffsetCount, const QRhiCommandBuffer::DynamicOffset *dynamicOffsets)=0
virtual void setPipelineCacheData(const QByteArray &data)=0
virtual QRhiBuffer * createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size)=0
static bool sortedBindingLessThan(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
Definition qrhi_p.h:230
virtual bool isDeviceLost() const =0
virtual const QRhiNativeHandles * nativeHandles(QRhiCommandBuffer *cb)=0
virtual void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)=0
virtual void beginExternal(QRhiCommandBuffer *cb)=0
virtual QMatrix4x4 clipSpaceCorrMatrix() const =0
virtual void dispatch(QRhiCommandBuffer *cb, int x, int y, int z)=0
virtual bool makeThreadLocalNativeContextCurrent()=0
void addDeleteLater(QRhiResource *res)
Definition qrhi_p.h:169
virtual void setVertexInput(QRhiCommandBuffer *cb, int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat)=0
void pipelineCreationStart()
Definition qrhi_p.h:202
virtual QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags)=0
void registerResource(QRhiResource *res, bool ownsNativeResources=true)
Definition qrhi_p.h:154
virtual void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue)=0
static QRhiShaderResourceBinding::Data * shaderResourceBindingData(QRhiShaderResourceBinding &binding)
Definition qrhi_p.h:225
virtual void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg)=0
virtual double lastCompletedGpuTime(QRhiCommandBuffer *cb)=0
virtual QRhiRenderBuffer * createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint)=0
void addCleanupCallback(const QRhi::CleanupCallback &callback)
Definition qrhi_p.h:177
qint64 totalPipelineCreationTime() const
Definition qrhi_p.h:212
virtual bool isYUpInNDC() const =0
virtual void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance)=0
virtual QRhiShaderResourceBindings * createShaderResourceBindings()=0
virtual bool isFeatureSupported(QRhi::Feature feature) const =0
virtual void setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline *ps)=0
virtual bool create(QRhi::Flags flags)=0
virtual void draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance)=0
void addCleanupCallback(const void *key, const QRhi::CleanupCallback &callback)
Definition qrhi_p.h:182
virtual void destroy()=0
virtual QByteArray pipelineCacheData()=0
virtual QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags)=0
void pipelineCreationEnd()
Definition qrhi_p.h:207
virtual QRhiStats statistics()=0
virtual void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)=0
virtual QRhiSwapChain * createSwapChain()=0
virtual const QRhiNativeHandles * nativeHandles()=0
static TextureStage toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages)
Definition qrhi.cpp:11088
TextureIterator cendTextures() const
Definition qrhi_p.h:686
static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages)
Definition qrhi.cpp:11069
BufferIterator cbeginBuffers() const
Definition qrhi_p.h:675
BufferIterator cendBuffers() const
Definition qrhi_p.h:676
TextureIterator cbeginTextures() const
Definition qrhi_p.h:685
bool isEmpty() const
Definition qrhi.cpp:10980
void registerBuffer(QRhiBuffer *buf, int slot, BufferAccess *access, BufferStage *stage, const UsageState &state)
Definition qrhi.cpp:10997
void registerTexture(QRhiTexture *tex, TextureAccess *access, TextureStage *stage, const UsageState &state)
Definition qrhi.cpp:11036
\inmodule QtGui
Definition qrhi.h:777
\inmodule QtGui
Definition qrhi.h:1094
Type
Specifies the type of the renderbuffer.
Definition qrhi.h:1096
\inmodule QtGui
Definition qrhi.h:1158
QVarLengthArray< BufferOp, BUFFER_OPS_STATIC_ALLOC > bufferOps
Definition qrhi_p.h:521
bool hasOptimalCapacity() const
Definition qrhi.cpp:9351
QRhiImplementation * rhi
Definition qrhi_p.h:528
QVarLengthArray< TextureOp, TEXTURE_OPS_STATIC_ALLOC > textureOps
Definition qrhi_p.h:525
static const int BUFFER_OPS_STATIC_ALLOC
Definition qrhi_p.h:520
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
Definition qrhi_p.h:536
void merge(QRhiResourceUpdateBatchPrivate *other)
Definition qrhi.cpp:9334
static const int TEXTURE_OPS_STATIC_ALLOC
Definition qrhi_p.h:524
\inmodule QtGui
Definition qrhi.h:1731
\inmodule QtGui
Definition qrhi.h:804
\inmodule QtGui
Definition qrhi.h:1030
Filter
Specifies the minification, magnification, or mipmap filtering.
Definition qrhi.h:1032
AddressMode
Specifies the addressing mode.
Definition qrhi.h:1038
\inmodule QtGui
Definition qrhi.h:138
\inmodule QtGui
Definition qrhi.h:439
\inmodule QtGui
Definition qrhi.h:1214
\inmodule QtGui
Definition qrhi.h:1549
\inmodule QtGui
Definition qrhi.h:739
\inmodule QtGui
Definition qrhi.h:1184
\inmodule QtGui
Definition qrhi.h:716
\inmodule QtGui
Definition qrhi.h:895
Format
Specifies the texture format.
Definition qrhi.h:914
Format
Specifies the type of the element data.
Definition qrhi.h:234
\inmodule QtGui
Definition qrhi.h:85
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
static constexpr int MAX_MIP_LEVELS
Definition qrhi.h:1997
static QRhiSwapChainProxyData updateSwapChainProxyData(Implementation impl, QWindow *window)
Generates and returns a QRhiSwapChainProxyData struct containing opaque data specific to the backend ...
Definition qrhi.cpp:8636
Implementation
Describes which graphics API-specific backend gets used by a QRhi instance.
Definition qrhi.h:1806
ResourceLimit
Describes the resource limit to query.
Definition qrhi.h:1886
Feature
Flag values to indicate what features are supported by the backend currently in use.
Definition qrhi.h:1831
FrameOpResult
Describes the result of operations that can have a soft failure.
Definition qrhi.h:1824
std::function< void(QRhi *)> CleanupCallback
Definition qrhi.h:1917
VariableType
Represents the type of a variable or block member.
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
bool isEmpty() const
void resize(qsizetype sz)
void append(const T &t)
\inmodule QtGui
Definition qwindow.h:63
Definition lalr.h:268
QSet< QString >::iterator it
else opt state
[0]
Combined button and popup list for selecting options.
static int instanceCount
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLboolean GLboolean GLboolean b
GLbitfield stages
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum src
GLenum type
GLenum GLenum dst
GLenum access
GLenum GLuint GLenum GLsizei const GLchar * buf
GLbitfield flags
GLenum GLuint GLintptr offset
GLint ref
GLuint name
GLfloat n
GLint GLsizei GLsizei GLenum format
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLdouble s
[6]
Definition qopenglext.h:235
GLuint res
const GLubyte * c
GLint limit
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
GLsizeiptr const void GLenum usage
Definition qopenglext.h:543
static bool isCompressedFormat(QOpenGLTexture::TextureFormat internalFormat)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QRhiTargetRectBoundMode
Definition qrhi_p.h:263
@ UnBounded
Definition qrhi_p.h:264
@ Bounded
Definition qrhi_p.h:265
T * qrhi_objectFromProxyData(QRhiSwapChainProxyData *pd, QWindow *window, QRhi::Implementation impl, uint objectIndex)
Definition qrhi_p.h:808
bool operator!=(const QRhiRenderTargetAttachmentTracker::ResId &a, const QRhiRenderTargetAttachmentTracker::ResId &b)
Definition qrhi_p.h:748
#define QRHI_RES(t, x)
Definition qrhi_p.h:28
bool operator==(const QRhiRenderTargetAttachmentTracker::ResId &a, const QRhiRenderTargetAttachmentTracker::ResId &b)
Definition qrhi_p.h:743
bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array< T, N > &r, T *x, T *y, T *w, T *h)
Definition qrhi_p.h:269
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:158
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
unsigned int quint32
Definition qtypes.h:50
int qint32
Definition qtypes.h:49
unsigned long long quint64
Definition qtypes.h:61
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
QSharedPointer< T > other(t)
[5]
view viewport() -> scroll(dx, dy, deviceRect)
aWidget window() -> setWindowTitle("New Window Title")
[2]
bool operator!=(const Batch &other) const
Definition qrhi_p.h:576
bool operator==(const Batch &other) const
Definition qrhi_p.h:571
QVarLengthArray< T, 4 > resources
Definition qrhi_p.h:569
void feed(int binding, T resource)
Definition qrhi_p.h:542
QVarLengthArray< Batch, 4 > batches
Definition qrhi_p.h:582
bool operator!=(const QRhiBatchedBindings< T > &other) const
Definition qrhi_p.h:589
bool operator==(const QRhiBatchedBindings< T > &other) const
Definition qrhi_p.h:584
char data[SMALL_DATA_SIZE]
Definition qrhi_p.h:323
static constexpr quint32 SMALL_DATA_SIZE
Definition qrhi_p.h:322
\inmodule QtGui
Definition qrhi.h:1759
\variable QRhiReadbackResult::completed
Definition qrhi.h:800
\inmodule QtGui
Definition qrhi.h:1723
static void updateResIdList(const QRhiTextureRenderTargetDescription &desc, ResIdList *dst)
Definition qrhi_p.h:754
static bool isUpToDate(const QRhiTextureRenderTargetDescription &desc, const ResIdList &currentResIdList)
Definition qrhi_p.h:792
static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:434
static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:423
static BufferOp read(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result)
Definition qrhi_p.h:443
static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:403
static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:414
QRhiTextureCopyDescription desc
Definition qrhi_p.h:471
static TextureOp copy(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc)
Definition qrhi_p.h:491
std::array< QVector< QRhiTextureSubresourceUploadDescription >, QRhi::MAX_MIP_LEVELS > MipLevelUploadList
Definition qrhi_p.h:468
QVarLengthArray< MipLevelUploadList, 6 > subresDesc
Definition qrhi_p.h:469
static TextureOp upload(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
Definition qrhi_p.h:475
static TextureOp genMips(QRhiTexture *tex)
Definition qrhi_p.h:510
static TextureOp read(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
Definition qrhi_p.h:501
\inmodule QtGui
Definition qrhi.h:1782
\inmodule QtGui
Definition qrhi.h:1544
void * reserved[2]
Definition qrhi.h:1545
Definition moc.h:23