Qt 6.x
The Qt SDK
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
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 bool sanityCheckGraphicsPipeline(QRhiGraphicsPipeline *ps);
183 bool sanityCheckShaderResourceBindings(QRhiShaderResourceBindings *srb);
184 void updateLayoutDesc(QRhiShaderResourceBindings *srb);
185
187 {
188 const quint32 ver = (QT_VERSION_MAJOR << 16) | (QT_VERSION_MINOR << 8) | (QT_VERSION_PATCH);
189 return (quint32(implType) << 24) | ver;
190 }
191
193 {
194 pipelineCreationTimer.start();
195 }
196
198 {
199 accumulatedPipelineCreationTime += pipelineCreationTimer.elapsed();
200 }
201
203 {
204 return accumulatedPipelineCreationTime;
205 }
206
207 QRhiVertexInputAttribute::Format shaderDescVariableFormatToVertexInputFormat(QShaderDescription::VariableType type) const;
208 quint32 byteSizePerVertexForVertexInputFormat(QRhiVertexInputAttribute::Format format) const;
209
211 {
212 return &binding.d;
213 }
214
216 {
217 return &binding.d;
218 }
219
221 {
222 return a.d.binding < b.d.binding;
223 }
224
226
227 static const int MAX_SHADER_CACHE_ENTRIES = 128;
228
229 bool debugMarkers = false;
230 int currentFrameSlot = 0; // for vk, mtl, and similar. unused by gl and d3d11.
231 bool inFrame = false;
232
233private:
234 QRhi::Implementation implType;
235 QThread *implThread;
237 quint64 resUpdPoolMap = 0;
238 int lastResUpdIdx = -1;
240 QSet<QRhiResource *> pendingDeleteResources;
242 QElapsedTimer pipelineCreationTimer;
243 qint64 accumulatedPipelineCreationTime = 0;
244
245 friend class QRhi;
247};
248
250{
252 Bounded
254
255template<QRhiTargetRectBoundMode boundingMode, typename T, size_t N>
256bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array<T, N> &r,
257 T *x, T *y, T *w, T *h)
258{
259 // x,y are bottom-left in QRhiScissor and QRhiViewport but top-left in
260 // Vulkan/Metal/D3D. Our input is an OpenGL-style scissor rect where both
261 // negative x or y, and partly or completely out of bounds rects are
262 // allowed. The only thing the input here cannot have is a negative width
263 // or height. We must handle all other input gracefully, clamping to a zero
264 // width or height rect in the worst case, and ensuring the resulting rect
265 // is inside the rendertarget's bounds because some APIs' validation/debug
266 // layers are allergic to out of bounds scissor rects.
267
268 const T outputWidth = outputSize.width();
269 const T outputHeight = outputSize.height();
270 const T inputWidth = r[2];
271 const T inputHeight = r[3];
272
273 if (inputWidth < 0 || inputHeight < 0)
274 return false;
275
276 *x = r[0];
277 *y = outputHeight - (r[1] + inputHeight);
278 *w = inputWidth;
279 *h = inputHeight;
280
281 if (boundingMode == Bounded) {
282 const T widthOffset = *x < 0 ? -*x : 0;
283 const T heightOffset = *y < 0 ? -*y : 0;
284 *w = *x < outputWidth ? qMax<T>(0, inputWidth - widthOffset) : 0;
285 *h = *y < outputHeight ? qMax<T>(0, inputHeight - heightOffset) : 0;
286
287 if (outputWidth > 0)
288 *x = qBound<T>(0, *x, outputWidth - 1);
289 if (outputHeight > 0)
290 *y = qBound<T>(0, *y, outputHeight - 1);
291
292 if (*x + *w > outputWidth)
293 *w = qMax<T>(0, outputWidth - *x);
294 if (*y + *h > outputHeight)
295 *h = qMax<T>(0, outputHeight - *y);
296 }
297 return true;
298}
299
301{
302 Q_DISABLE_COPY_MOVE(QRhiBufferDataPrivate)
305 int ref = 1;
308 char *largeData = nullptr;
309 static constexpr quint32 SMALL_DATA_SIZE = 1024;
311};
312
313// no detach-with-contents, no atomic refcount, no shrink
315{
316public:
317 QRhiBufferData() = default;
319 {
320 if (d && !--d->ref)
321 delete d;
322 }
324 : d(other.d)
325 {
326 if (d)
327 d->ref += 1;
328 }
330 {
331 if (d == other.d)
332 return *this;
333 if (other.d)
334 other.d->ref += 1;
335 if (d && !--d->ref)
336 delete d;
337 d = other.d;
338 return *this;
339 }
340 const char *constData() const
341 {
343 }
344 quint32 size() const
345 {
346 return d->size;
347 }
348 void assign(const char *s, quint32 size)
349 {
350 if (!d) {
351 d = new QRhiBufferDataPrivate;
352 } else if (d->ref != 1) {
353 d->ref -= 1;
354 d = new QRhiBufferDataPrivate;
355 }
356 d->size = size;
358 memcpy(d->data, s, size);
359 } else {
360 if (d->largeAlloc < size) {
361 delete[] d->largeData;
362 d->largeAlloc = size;
363 d->largeData = new char[size];
364 }
365 memcpy(d->largeData, s, size);
366 }
367 }
368private:
369 QRhiBufferDataPrivate *d = nullptr;
370};
371
373
375{
376public:
377 struct BufferOp {
378 enum Type {
381 Read
382 };
389
391 {
392 BufferOp op = {};
393 op.type = DynamicUpdate;
394 op.buf = buf;
395 op.offset = offset;
396 const int effectiveSize = size ? size : buf->size();
397 op.data.assign(reinterpret_cast<const char *>(data), effectiveSize);
398 return op;
399 }
400
402 {
403 op->type = DynamicUpdate;
404 op->buf = buf;
405 op->offset = offset;
406 const int effectiveSize = size ? size : buf->size();
407 op->data.assign(reinterpret_cast<const char *>(data), effectiveSize);
408 }
409
411 {
412 BufferOp op = {};
413 op.type = StaticUpload;
414 op.buf = buf;
415 op.offset = offset;
416 const int effectiveSize = size ? size : buf->size();
417 op.data.assign(reinterpret_cast<const char *>(data), effectiveSize);
418 return op;
419 }
420
422 {
423 op->type = StaticUpload;
424 op->buf = buf;
425 op->offset = offset;
426 const int effectiveSize = size ? size : buf->size();
427 op->data.assign(reinterpret_cast<const char *>(data), effectiveSize);
428 }
429
431 {
432 BufferOp op = {};
433 op.type = Read;
434 op.buf = buf;
435 op.offset = offset;
436 op.readSize = size;
437 op.result = result;
438 return op;
439 }
440 };
441
442 struct TextureOp {
443 enum Type {
447 GenMips
448 };
451 // Specifying multiple uploads for a subresource must be supported.
452 // In the backend this can then end up, where applicable, as a
453 // single, batched copy operation with only one set of barriers.
454 // This helps when doing for example glyph cache fills.
455 using MipLevelUploadList = std::array<QVector<QRhiTextureSubresourceUploadDescription>, QRhi::MAX_MIP_LEVELS>;
461
463 {
464 TextureOp op = {};
465 op.type = Upload;
466 op.dst = tex;
467 int maxLayer = -1;
468 for (auto it = desc.cbeginEntries(), itEnd = desc.cendEntries(); it != itEnd; ++it) {
469 if (it->layer() > maxLayer)
470 maxLayer = it->layer();
471 }
472 op.subresDesc.resize(maxLayer + 1);
473 for (auto it = desc.cbeginEntries(), itEnd = desc.cendEntries(); it != itEnd; ++it)
474 op.subresDesc[it->layer()][it->level()].append(it->description());
475 return op;
476 }
477
479 {
480 TextureOp op = {};
481 op.type = Copy;
482 op.dst = dst;
483 op.src = src;
484 op.desc = desc;
485 return op;
486 }
487
489 {
490 TextureOp op = {};
491 op.type = Read;
492 op.rb = rb;
493 op.result = result;
494 return op;
495 }
496
498 {
499 TextureOp op = {};
500 op.type = GenMips;
501 op.dst = tex;
502 return op;
503 }
504 };
505
506 int activeBufferOpCount = 0; // this is the real number of used elements in bufferOps, not bufferOps.count()
507 static const int BUFFER_OPS_STATIC_ALLOC = 1024;
509
510 int activeTextureOpCount = 0; // this is the real number of used elements in textureOps, not textureOps.count()
511 static const int TEXTURE_OPS_STATIC_ALLOC = 256;
513
516 int poolIndex = -1;
517
518 void free();
520 bool hasOptimalCapacity() const;
521 void trimOpLists();
522
524};
525
526template<typename T>
528{
529 void feed(int binding, T resource) { // binding must be strictly increasing
530 if (curBinding == -1 || binding > curBinding + 1) {
531 finish();
532 curBatch.startBinding = binding;
533 curBatch.resources.clear();
534 curBatch.resources.append(resource);
535 } else {
536 Q_ASSERT(binding == curBinding + 1);
537 curBatch.resources.append(resource);
538 }
539 curBinding = binding;
540 }
541
542 bool finish() {
543 if (!curBatch.resources.isEmpty())
544 batches.append(curBatch);
545 return !batches.isEmpty();
546 }
547
548 void clear() {
549 batches.clear();
550 curBatch.resources.clear();
551 curBinding = -1;
552 }
553
554 struct Batch {
557
558 bool operator==(const Batch &other) const
559 {
560 return startBinding == other.startBinding && resources == other.resources;
561 }
562
563 bool operator!=(const Batch &other) const
564 {
565 return !operator==(other);
566 }
567 };
568
569 QVarLengthArray<Batch, 4> batches; // sorted by startBinding
570
572 {
573 return batches == other.batches;
574 }
575
577 {
578 return !operator==(other);
579 }
580
581private:
582 Batch curBatch;
583 int curBinding = -1;
584};
585
587{
588public:
589#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
590 using Type = quint64;
591#else
592 using Type = quint32;
593#endif
594 static Type newId();
595};
596
598{
599public:
600 bool isEmpty() const;
601 void reset();
602
603 struct UsageState {
606 int stage;
607 };
608
617 };
618
626 };
627
629 const UsageState &state);
630
640 };
641
649 };
650
652 const UsageState &state);
653
654 struct Buffer {
655 int slot;
659 };
660
662 BufferIterator cbeginBuffers() const { return m_buffers.cbegin(); }
663 BufferIterator cendBuffers() const { return m_buffers.cend(); }
664
665 struct Texture {
669 };
670
672 TextureIterator cbeginTextures() const { return m_textures.cbegin(); }
673 TextureIterator cendTextures() const { return m_textures.cend(); }
674
675 static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages);
676 static TextureStage toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages);
677
678private:
681};
682
685
686template<typename T, int GROW = 1024>
688{
689public:
692 inline void reset() { p = 0; }
693 inline bool isEmpty() const { return p == 0; }
694 inline T &get() {
695 if (p == a) {
696 a += GROW;
697 T *nv = new T[a];
698 if (v) {
699 memcpy(nv, v, p * sizeof(T));
700 delete[] v;
701 }
702 v = nv;
703 }
704 return v[p++];
705 }
706 inline void unget() { --p; }
707 inline T *cbegin() const { return v; }
708 inline T *cend() const { return v + p; }
709 inline T *begin() { return v; }
710 inline T *end() { return v + p; }
711private:
712 Q_DISABLE_COPY(QRhiBackendCommandList)
713 T *v = nullptr;
714 int a = 0;
715 int p = 0;
716};
717
719{
721 using ResIdList = QVarLengthArray<ResId, 8 * 2 + 1>; // color, resolve, ds
722
723 template<typename TexType, typename RenderBufferType>
725
726 template<typename TexType, typename RenderBufferType>
727 static bool isUpToDate(const QRhiTextureRenderTargetDescription &desc, const ResIdList &currentResIdList);
728};
729
731{
732 return a.id == b.id && a.generation == b.generation;
733}
734
736{
737 return !(a == b);
738}
739
740template<typename TexType, typename RenderBufferType>
742{
743 const bool hasDepthStencil = desc.depthStencilBuffer() || desc.depthTexture();
744 dst->resize(desc.colorAttachmentCount() * 2 + (hasDepthStencil ? 1 : 0));
745 int n = 0;
746 for (auto it = desc.cbeginColorAttachments(), itEnd = desc.cendColorAttachments(); it != itEnd; ++it, ++n) {
747 const QRhiColorAttachment &colorAtt(*it);
748 if (colorAtt.texture()) {
749 TexType *texD = QRHI_RES(TexType, colorAtt.texture());
750 (*dst)[n] = { texD->globalResourceId(), texD->generation };
751 } else if (colorAtt.renderBuffer()) {
752 RenderBufferType *rbD = QRHI_RES(RenderBufferType, colorAtt.renderBuffer());
753 (*dst)[n] = { rbD->globalResourceId(), rbD->generation };
754 } else {
755 (*dst)[n] = { 0, 0 };
756 }
757 ++n;
758 if (colorAtt.resolveTexture()) {
759 TexType *texD = QRHI_RES(TexType, colorAtt.resolveTexture());
760 (*dst)[n] = { texD->globalResourceId(), texD->generation };
761 } else {
762 (*dst)[n] = { 0, 0 };
763 }
764 }
765 if (hasDepthStencil) {
766 if (desc.depthTexture()) {
767 TexType *depthTexD = QRHI_RES(TexType, desc.depthTexture());
768 (*dst)[n] = { depthTexD->globalResourceId(), depthTexD->generation };
769 } else if (desc.depthStencilBuffer()) {
770 RenderBufferType *depthRbD = QRHI_RES(RenderBufferType, desc.depthStencilBuffer());
771 (*dst)[n] = { depthRbD->globalResourceId(), depthRbD->generation };
772 } else {
773 (*dst)[n] = { 0, 0 };
774 }
775 }
776}
777
778template<typename TexType, typename RenderBufferType>
780{
781 // Just as setShaderResources() recognizes if an srb's referenced
782 // resources have been rebuilt (got a create() since the srb's
783 // create()), we should do the same for the textures and renderbuffers
784 // referenced from the rendertarget. It is not uncommon that a texture
785 // or ds buffer gets resized due to following a window size in some
786 // form, which involves a create() on them. It is then nice if the
787 // render target auto-rebuilds in beginPass().
788
789 ResIdList resIdList;
790 updateResIdList<TexType, RenderBufferType>(desc, &resIdList);
791 return resIdList == currentResIdList;
792}
793
794template<typename T>
796{
797 Q_ASSERT(objectIndex < std::size(pd->reserved));
798 if (!pd->reserved[objectIndex]) // // was not set, no other choice, do it here, whatever thread this is
800 return static_cast<T *>(pd->reserved[objectIndex]);
801}
802
804
805#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:1135
\inmodule QtCore
Definition qhash.h:818
Definition qlist.h:74
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
QRhiBackendCommandList()=default
T * cend() const
Definition qrhi_p.h:708
T * cbegin() const
Definition qrhi_p.h:707
bool isEmpty() const
Definition qrhi_p.h:693
QRhiBufferData()=default
void assign(const char *s, quint32 size)
Definition qrhi_p.h:348
quint32 size() const
Definition qrhi_p.h:344
QRhiBufferData(const QRhiBufferData &other)
Definition qrhi_p.h:323
QRhiBufferData & operator=(const QRhiBufferData &other)
Definition qrhi_p.h:329
const char * constData() const
Definition qrhi_p.h:340
\inmodule QtGui
Definition qrhi.h:834
Type
Specifies storage type of buffer resource.
Definition qrhi.h:836
\inmodule QtGui
Definition qrhi.h:568
QRhiRenderBuffer * renderBuffer() const
Definition qrhi.h:577
QRhiTexture * texture() const
Definition qrhi.h:574
QRhiTexture * resolveTexture() const
Definition qrhi.h:586
\inmodule QtGui
Definition qrhi.h:1614
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
Definition qrhi.h:1643
QPair< int, quint32 > DynamicOffset
Synonym for QPair<int, quint32>.
Definition qrhi.h:1639
IndexFormat
Specifies the index data type.
Definition qrhi.h:1616
\inmodule QtGui
Definition qrhi.h:1585
\inmodule QtGui
Definition qrhi.h:44
\inmodule QtGui
Definition qrhi.h:1241
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
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:210
quint32 pipelineCacheRhiId() const
Definition qrhi_p.h:186
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:220
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:192
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:215
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:202
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
virtual void destroy()=0
virtual QByteArray pipelineCacheData()=0
virtual QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags)=0
void pipelineCreationEnd()
Definition qrhi_p.h:197
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:10651
TextureIterator cendTextures() const
Definition qrhi_p.h:673
static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages)
Definition qrhi.cpp:10632
BufferIterator cbeginBuffers() const
Definition qrhi_p.h:662
BufferIterator cendBuffers() const
Definition qrhi_p.h:663
TextureIterator cbeginTextures() const
Definition qrhi_p.h:672
bool isEmpty() const
Definition qrhi.cpp:10543
void registerBuffer(QRhiBuffer *buf, int slot, BufferAccess *access, BufferStage *stage, const UsageState &state)
Definition qrhi.cpp:10560
void registerTexture(QRhiTexture *tex, TextureAccess *access, TextureStage *stage, const UsageState &state)
Definition qrhi.cpp:10599
\inmodule QtGui
Definition qrhi.h:765
\inmodule QtGui
Definition qrhi.h:1071
Type
Specifies the type of the renderbuffer.
Definition qrhi.h:1073
\inmodule QtGui
Definition qrhi.h:1135
QVarLengthArray< BufferOp, BUFFER_OPS_STATIC_ALLOC > bufferOps
Definition qrhi_p.h:508
bool hasOptimalCapacity() const
Definition qrhi.cpp:8953
QRhiImplementation * rhi
Definition qrhi_p.h:515
QVarLengthArray< TextureOp, TEXTURE_OPS_STATIC_ALLOC > textureOps
Definition qrhi_p.h:512
static const int BUFFER_OPS_STATIC_ALLOC
Definition qrhi_p.h:507
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
Definition qrhi_p.h:523
void merge(QRhiResourceUpdateBatchPrivate *other)
Definition qrhi.cpp:8936
static const int TEXTURE_OPS_STATIC_ALLOC
Definition qrhi_p.h:511
\inmodule QtGui
Definition qrhi.h:1694
\inmodule QtGui
Definition qrhi.h:792
\inmodule QtGui
Definition qrhi.h:1007
Filter
Specifies the minification, magnification, or mipmap filtering.
Definition qrhi.h:1009
AddressMode
Specifies the addressing mode.
Definition qrhi.h:1015
\inmodule QtGui
Definition qrhi.h:138
\inmodule QtGui
Definition qrhi.h:431
\inmodule QtGui
Definition qrhi.h:1190
\inmodule QtGui
Definition qrhi.h:1513
\inmodule QtGui
Definition qrhi.h:727
\inmodule QtGui
Definition qrhi.h:1161
\inmodule QtGui
Definition qrhi.h:704
\inmodule QtGui
Definition qrhi.h:883
Format
Specifies the texture format.
Definition qrhi.h:902
Format
Specifies the type of the element data.
Definition qrhi.h:234
\inmodule QtGui
Definition qrhi.h:85
\inmodule QtGui
Definition qrhi.h:1767
static QRhiSwapChainProxyData updateSwapChainProxyData(Implementation impl, QWindow *window)
Generates and returns a QRhiSwapChainProxyData struct containing opaque data specific to the backend ...
Definition qrhi.cpp:8274
Implementation
Describes which graphics API-specific backend gets used by a QRhi instance.
Definition qrhi.h:1769
ResourceLimit
Describes the resource limit to query.
Definition qrhi.h:1846
Feature
Flag values to indicate what features are supported by the backend currently in use.
Definition qrhi.h:1793
static const int MAX_MIP_LEVELS
Definition qrhi.h:1955
FrameOpResult
Describes the result of operations that can have a soft failure.
Definition qrhi.h:1786
std::function< void(QRhi *)> CleanupCallback
Definition qrhi.h:1877
Definition qset.h:18
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:132
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
bool isEmpty() const
void resize(qsizetype sz)
void append(const T &t)
\inmodule QtGui
Definition qwindow.h:63
Definition lalr.h:269
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
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLenum src
GLenum type
GLenum GLenum dst
GLenum access
GLenum GLuint GLenum GLsizei const GLchar * buf
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint ref
GLuint name
GLfloat n
GLint GLsizei GLsizei GLenum format
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLuint res
const GLubyte * c
GLint limit
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
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:250
@ UnBounded
Definition qrhi_p.h:251
@ Bounded
Definition qrhi_p.h:252
T * qrhi_objectFromProxyData(QRhiSwapChainProxyData *pd, QWindow *window, QRhi::Implementation impl, uint objectIndex)
Definition qrhi_p.h:795
bool operator!=(const QRhiRenderTargetAttachmentTracker::ResId &a, const QRhiRenderTargetAttachmentTracker::ResId &b)
Definition qrhi_p.h:735
#define QRHI_RES(t, x)
Definition qrhi_p.h:28
bool operator==(const QRhiRenderTargetAttachmentTracker::ResId &a, const QRhiRenderTargetAttachmentTracker::ResId &b)
Definition qrhi_p.h:730
bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array< T, N > &r, T *x, T *y, T *w, T *h)
Definition qrhi_p.h:256
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
@ desc
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:145
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:163
unsigned int quint32
Definition qtypes.h:45
int qint32
Definition qtypes.h:44
unsigned long long quint64
Definition qtypes.h:56
unsigned int uint
Definition qtypes.h:29
long long qint64
Definition qtypes.h:55
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:563
bool operator==(const Batch &other) const
Definition qrhi_p.h:558
QVarLengthArray< T, 4 > resources
Definition qrhi_p.h:556
void feed(int binding, T resource)
Definition qrhi_p.h:529
QVarLengthArray< Batch, 4 > batches
Definition qrhi_p.h:569
bool operator!=(const QRhiBatchedBindings< T > &other) const
Definition qrhi_p.h:576
bool operator==(const QRhiBatchedBindings< T > &other) const
Definition qrhi_p.h:571
char data[SMALL_DATA_SIZE]
Definition qrhi_p.h:310
static constexpr quint32 SMALL_DATA_SIZE
Definition qrhi_p.h:309
\inmodule QtGui
Definition qrhi.h:1722
\variable QRhiReadbackResult::completed
Definition qrhi.h:788
\inmodule QtGui
Definition qrhi.h:1686
static void updateResIdList(const QRhiTextureRenderTargetDescription &desc, ResIdList *dst)
Definition qrhi_p.h:741
static bool isUpToDate(const QRhiTextureRenderTargetDescription &desc, const ResIdList &currentResIdList)
Definition qrhi_p.h:779
static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:421
static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:410
static BufferOp read(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result)
Definition qrhi_p.h:430
static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:390
static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:401
QRhiTextureCopyDescription desc
Definition qrhi_p.h:458
static TextureOp copy(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc)
Definition qrhi_p.h:478
std::array< QVector< QRhiTextureSubresourceUploadDescription >, QRhi::MAX_MIP_LEVELS > MipLevelUploadList
Definition qrhi_p.h:455
QVarLengthArray< MipLevelUploadList, 6 > subresDesc
Definition qrhi_p.h:456
static TextureOp upload(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
Definition qrhi_p.h:462
static TextureOp genMips(QRhiTexture *tex)
Definition qrhi_p.h:497
static TextureOp read(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
Definition qrhi_p.h:488
\inmodule QtGui
Definition qrhi.h:1745
\inmodule QtGui
Definition qrhi.h:1508
void * reserved[2]
Definition qrhi.h:1509
Definition moc.h:24