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
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// Qt-Security score:significant reason:default
4
5#ifndef QRHI_P_H
6#define QRHI_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <rhi/qrhi.h>
20#include <QBitArray>
21#include <QAtomicInt>
22#include <QElapsedTimer>
23#include <QLoggingCategory>
24#include <QtCore/qhash.h>
25#include <QtCore/qset.h>
26#include <QtCore/qvarlengtharray.h>
27#include <algorithm>
28#include <utility>
29
30QT_BEGIN_NAMESPACE
31
32#define QRHI_RES(t, x) static_cast<t *>(x)
33#define QRHI_RES_RHI(t) t *rhiD = static_cast<t *>(m_rhi)
34
35Q_DECLARE_LOGGING_CATEGORY(QRHI_LOG_INFO)
36Q_DECLARE_LOGGING_CATEGORY(QRHI_LOG_RUB)
37
38class QRhiImplementation
39{
40public:
41 virtual ~QRhiImplementation();
42
43 virtual bool create(QRhi::Flags flags) = 0;
44 virtual void destroy() = 0;
45 virtual QRhi::AdapterList enumerateAdaptersBeforeCreate(QRhiNativeHandles *nativeHandles) const;
46
47 virtual QRhiGraphicsPipeline *createGraphicsPipeline() = 0;
48 virtual QRhiComputePipeline *createComputePipeline() = 0;
49 virtual QRhiShaderResourceBindings *createShaderResourceBindings() = 0;
50 virtual QRhiBuffer *createBuffer(QRhiBuffer::Type type,
51 QRhiBuffer::UsageFlags usage,
52 quint32 size) = 0;
53 virtual QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type,
54 const QSize &pixelSize,
55 int sampleCount,
56 QRhiRenderBuffer::Flags flags,
57 QRhiTexture::Format backingFormatHint) = 0;
58 virtual QRhiTexture *createTexture(QRhiTexture::Format format,
59 const QSize &pixelSize,
60 int depth,
61 int arraySize,
62 int sampleCount,
63 QRhiTexture::Flags flags) = 0;
64 virtual QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
65 QRhiSampler::Filter minFilter,
66 QRhiSampler::Filter mipmapMode,
67 QRhiSampler:: AddressMode u,
68 QRhiSampler::AddressMode v,
69 QRhiSampler::AddressMode w) = 0;
70
71 virtual QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
72 QRhiTextureRenderTarget::Flags flags) = 0;
73
74 virtual QRhiShadingRateMap *createShadingRateMap() = 0;
75
76 virtual QRhiIndirectCommandBuffer *createIndirectCommandBuffer(QRhiIndirectCommandBuffer::Type type,
77 quint32 maxCommandCount);
78 virtual void buildIndirect(QRhiCommandBuffer *cb, QRhiIndirectCommandBuffer *icb,
79 const QRhiIndirectCommandBufferBuildInfo &info);
80 virtual void executeIndirect(QRhiCommandBuffer *cb, QRhiIndirectCommandBuffer *icb,
81 quint32 firstCommand, quint32 commandCount);
82 virtual void commitIndirectCommandBuffer(QRhiResourceUpdateBatch *u,
83 QRhiIndirectCommandBuffer *icb);
84
85 virtual QRhiSwapChain *createSwapChain() = 0;
86 virtual QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) = 0;
87 virtual QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) = 0;
88 virtual QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) = 0;
89 virtual QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) = 0;
90 virtual QRhi::FrameOpResult finish() = 0;
91
92 virtual void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0;
93
94 virtual void beginPass(QRhiCommandBuffer *cb,
95 QRhiRenderTarget *rt,
96 const QColor &colorClearValue,
97 const QRhiDepthStencilClearValue &depthStencilClearValue,
98 QRhiResourceUpdateBatch *resourceUpdates,
99 QRhiCommandBuffer::BeginPassFlags flags) = 0;
100 virtual void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0;
101
102 virtual void setGraphicsPipeline(QRhiCommandBuffer *cb,
103 QRhiGraphicsPipeline *ps) = 0;
104
105 virtual void setShaderResources(QRhiCommandBuffer *cb,
106 QRhiShaderResourceBindings *srb,
107 int dynamicOffsetCount,
108 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) = 0;
109
110 virtual void setVertexInput(QRhiCommandBuffer *cb,
111 int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings,
112 QRhiBuffer *indexBuf, quint32 indexOffset,
113 QRhiCommandBuffer::IndexFormat indexFormat) = 0;
114
115 virtual void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) = 0;
116 virtual void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) = 0;
117 virtual void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) = 0;
118 virtual void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) = 0;
119 virtual void setPushConstants(QRhiCommandBuffer *cb, quint32 offset, quint32 size, const void *data) = 0;
120 virtual void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) = 0;
121
122 virtual void draw(QRhiCommandBuffer *cb, quint32 vertexCount,
123 quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) = 0;
124 virtual void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
125 quint32 instanceCount, quint32 firstIndex,
126 qint32 vertexOffset, quint32 firstInstance) = 0;
127 virtual void drawIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
128 quint32 offset, quint32 drawCount, quint32 stride) = 0;
129 virtual void drawIndexedIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
130 quint32 offset, quint32 drawCount, quint32 stride) = 0;
131 virtual void drawIndirectCount(QRhiCommandBuffer *cb,
132 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
133 QRhiBuffer *countBuffer, quint32 countBufferOffset,
134 quint32 maxDrawCount, quint32 stride) = 0;
135 virtual void drawIndexedIndirectCount(QRhiCommandBuffer *cb,
136 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
137 QRhiBuffer *countBuffer, quint32 countBufferOffset,
138 quint32 maxDrawCount, quint32 stride) = 0;
139
140 virtual void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) = 0;
141 virtual void debugMarkEnd(QRhiCommandBuffer *cb) = 0;
142 virtual void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) = 0;
143
144 virtual void beginComputePass(QRhiCommandBuffer *cb,
145 QRhiResourceUpdateBatch *resourceUpdates,
146 QRhiCommandBuffer::BeginPassFlags flags) = 0;
147 virtual void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) = 0;
148 virtual void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) = 0;
149 virtual void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) = 0;
150 virtual void dispatchIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
151 quint32 offset) = 0;
152
153 virtual const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) = 0;
154 virtual void beginExternal(QRhiCommandBuffer *cb) = 0;
155 virtual void endExternal(QRhiCommandBuffer *cb) = 0;
156 virtual double lastCompletedGpuTime(QRhiCommandBuffer *cb) = 0;
157
158 virtual QList<int> supportedSampleCounts() const = 0;
159 virtual int ubufAlignment() const = 0;
160 virtual QList<QSize> supportedShadingRates(int sampleCount) const = 0;
161 virtual bool isYUpInFramebuffer() const = 0;
162 virtual bool isYUpInNDC() const = 0;
163 virtual bool isClipDepthZeroToOne() const = 0;
164 virtual QMatrix4x4 clipSpaceCorrMatrix() const = 0;
165 virtual bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const = 0;
166 virtual bool isFeatureSupported(QRhi::Feature feature) const = 0;
167 virtual int resourceLimit(QRhi::ResourceLimit limit) const = 0;
168 virtual const QRhiNativeHandles *nativeHandles() = 0;
169 virtual QRhiDriverInfo driverInfo() const = 0;
170 virtual QRhiStats statistics() = 0;
171 virtual bool makeThreadLocalNativeContextCurrent() = 0;
172 virtual void setQueueSubmitParams(QRhiNativeHandles *params) = 0;
173 virtual void releaseCachedResources() = 0;
174 virtual bool isDeviceLost() const = 0;
175
176 virtual QByteArray pipelineCacheData() = 0;
177 virtual void setPipelineCacheData(const QByteArray &data) = 0;
178
179 static QRhiImplementation *newInstance(QRhi::Implementation impl, QRhiInitParams *params, QRhiNativeHandles *importDevice);
180 void prepareForCreate(QRhi *rhi, QRhi::Implementation impl, QRhi::Flags flags, QRhiAdapter *adapter);
181
182 bool isCompressedFormat(QRhiTexture::Format format) const;
183 bool compressedFormatInfo(QRhiTexture::Format format, const QSize &size,
184 quint32 *bpl, quint32 *byteSize,
185 QSize *blockDim) const;
186 bool textureFormatInfo(QRhiTexture::Format format, const QSize &size,
187 quint32 *bpl, quint32 *byteSize, quint32 *bytesPerPixel) const;
188 bool isStencilSupportingFormat(QRhiTexture::Format format) const;
189
190 void registerResource(QRhiResource *res, bool ownsNativeResources = true)
191 {
192 // The ownsNativeResources is relevant for the (graphics resource) leak
193 // check in ~QRhiImplementation; when false, the registration's sole
194 // purpose is to automatically null out the resource's m_rhi pointer in
195 // case the rhi goes away first. (which should not happen in
196 // well-written applications but we try to be graceful)
197 resources.insert(res, ownsNativeResources);
198 }
199
200 void unregisterResource(QRhiResource *res)
201 {
202 resources.remove(res);
203 }
204
205 void addDeleteLater(QRhiResource *res)
206 {
207 if (inFrame)
208 pendingDeleteResources.insert(res);
209 else
210 delete res;
211 }
212
213 void addCleanupCallback(const QRhi::CleanupCallback &callback)
214 {
215 cleanupCallbacks.append(callback);
216 }
217
218 void addCleanupCallback(const void *key, const QRhi::CleanupCallback &callback)
219 {
220 keyedCleanupCallbacks[key] = callback;
221 }
222
223 void removeCleanupCallback(const void *key)
224 {
225 keyedCleanupCallbacks.remove(key);
226 }
227
228 bool sanityCheckGraphicsPipeline(QRhiGraphicsPipeline *ps);
229 bool sanityCheckShaderResourceBindings(QRhiShaderResourceBindings *srb);
230 bool sanityCheckResourceOwnership(QRhiResource *maybeResource);
231 void updateLayoutDesc(QRhiShaderResourceBindings *srb);
232
233 quint32 pipelineCacheRhiId() const
234 {
235 const quint32 ver = (QT_VERSION_MAJOR << 16) | (QT_VERSION_MINOR << 8) | (QT_VERSION_PATCH);
236 return (quint32(implType) << 24) | ver;
237 }
238
239 void pipelineCreationStart()
240 {
241 pipelineCreationTimer.start();
242 }
243
244 void pipelineCreationEnd()
245 {
246 accumulatedPipelineCreationTime += pipelineCreationTimer.elapsed();
247 }
248
249 qint64 totalPipelineCreationTime() const
250 {
251 return accumulatedPipelineCreationTime;
252 }
253
254 QRhiVertexInputAttribute::Format shaderDescVariableFormatToVertexInputFormat(QShaderDescription::VariableType type) const;
255 quint32 byteSizePerVertexForVertexInputFormat(QRhiVertexInputAttribute::Format format) const;
256
257 static const QRhiShaderResourceBinding::Data *shaderResourceBindingData(const QRhiShaderResourceBinding &binding)
258 {
259 return &binding.d;
260 }
261
262 static QRhiShaderResourceBinding::Data *shaderResourceBindingData(QRhiShaderResourceBinding &binding)
263 {
264 return &binding.d;
265 }
266
267 static bool sortedBindingLessThan(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
268 {
269 return a.d.binding < b.d.binding;
270 }
271
272 int effectiveSampleCount(int sampleCount) const;
273 QSize clampedSubResourceUploadSize(QSize size, QPoint dstPos, int level, QSize textureSizeAtLevelZero, bool warn = true);
274 QSize clampedSubResourceUploadSizeForSourceData(QSize size, quint32 bpl, quint32 bytesPerPixel,
275 qsizetype dataSize, bool warn = true);
276 QSize clampedCompressedSubResourceUploadSizeForSourceData(QRhiTexture::Format format, QSize size,
277 qsizetype dataSize, bool warn = true);
278
279 void runCleanup();
280
281 QRhi *q;
282
283 static const int MAX_SHADER_CACHE_ENTRIES = 128;
284 static const quint32 MAX_BINARY_CACHE_BYTES = 16 * 1024 * 1024;
285
286 bool debugMarkers = false;
287 bool timestamps = false;
288 int currentFrameSlot = 0; // for vk, mtl, and similar. unused by gl and d3d11.
289 bool inFrame = false;
290 QRhiCommandBuffer *currentOffscreenCb = nullptr;
291 QRhiAdapter *requestedRhiAdapter = nullptr;
292 QHash<QRhiResource *, bool> resources;
293
294private:
295 QRhi::Implementation implType;
296 QThread *implThread;
297 QVarLengthArray<QRhiResourceUpdateBatch *, 4> resUpdPool;
298 quint64 resUpdPoolMap = 0;
299 int lastResUpdIdx = -1;
300 QSet<QRhiResource *> pendingDeleteResources;
301 QVarLengthArray<QRhi::CleanupCallback, 4> cleanupCallbacks;
302 QHash<const void *, QRhi::CleanupCallback> keyedCleanupCallbacks;
303 QElapsedTimer pipelineCreationTimer;
304 qint64 accumulatedPipelineCreationTime = 0;
305
306 friend class QRhi;
307 friend class QRhiResourceUpdateBatchPrivate;
308 friend class QRhiBufferData;
309};
310
311inline quint32 qrhiBinaryCacheEntryByteSize(const QByteArray &data)
312{
313 return quint32(data.size());
314}
315
316template <typename Key, typename Value,
317 quint32 MaxBytes = QRhiImplementation::MAX_BINARY_CACHE_BYTES>
319{
320 explicit QRhiBinaryCache(const char *name) : name(name) { }
321
324 const char *name;
325
326 void clear()
327 {
328 data.clear();
329 dataByteSize = 0;
330 }
331
332 void insertWithCapacityLimit(const Key &key, const Value &value)
333 {
334 const quint32 entrySize = qrhiBinaryCacheEntryByteSize(value);
335
336 // Replacing an entry must not make the running total drift. This does
337 // happen in practice: trySaveToPipelineCache() in the OpenGL backend
338 // replaces the existing entry when forced to.
339 auto it = data.find(key);
340 if (it != data.end()) {
341 dataByteSize -= qrhiBinaryCacheEntryByteSize(*it);
342 *it = value;
343 dataByteSize += entrySize;
344 return;
345 }
346
347 if (dataByteSize + entrySize > MaxBytes) {
348 // Use the simplest strategy: too much cached data -> drop it all.
349 // An entry larger than the entire budget is still inserted, so the
350 // cache can hold up to the budget plus one entry.
351 qCDebug(QRHI_LOG_INFO, "%s would exceed %u bytes, dropping all %d entries (%u bytes)",
352 name, MaxBytes, int(data.count()), dataByteSize);
353 clear();
354 }
355
356 data.insert(key, value);
357 dataByteSize += entrySize;
358 }
359};
360
362{
363 void (*frameEnd)(QRhiImplementation *d, QRhiSwapChain *swapChain, QRhiCommandBuffer *cb) = nullptr;
364 void (*rhiAboutToBeDestroyed)(QRhiImplementation *d) = nullptr;
365};
366
367Q_GUI_EXPORT extern QRhiDebugHooks qrhiDebugHooks;
368
370{
371public:
372 QRhiBufferBackedIndirectCommandBuffer(QRhiImplementation *rhi, Type type, quint32 maxCommandCount);
374
375 void destroy() override;
376 bool create() override;
377
378 // no-op if uploadedGeneration matches the current one, so safe to call regularly
379 void enqueueUpload(QRhiResourceUpdateBatch *u);
380
381 void execute(QRhiCommandBuffer *cb, quint32 firstCommand, quint32 commandCount);
382 void build(const QRhiIndirectCommandBufferBuildInfo &info);
383
384 bool valid = false;
385 QRhiBuffer *buffer = nullptr;
387 QRhiIndirectCommandBufferBuildInfo buildInfo;
388};
389
395
396template<QRhiTargetRectBoundMode boundingMode, typename T, size_t N>
397bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array<T, N> &r,
398 T *x, T *y, T *w, T *h)
399{
400 // x,y are bottom-left in QRhiScissor and QRhiViewport but top-left in
401 // Vulkan/Metal/D3D. Our input is an OpenGL-style scissor rect where both
402 // negative x or y, and partly or completely out of bounds rects are
403 // allowed. The only thing the input here cannot have is a negative width
404 // or height. We must handle all other input gracefully, clamping to a zero
405 // width or height rect in the worst case, and ensuring the resulting rect
406 // is inside the rendertarget's bounds because some APIs' validation/debug
407 // layers are allergic to out of bounds scissor rects.
408
409 const T outputWidth = outputSize.width();
410 const T outputHeight = outputSize.height();
411 const T inputWidth = r[2];
412 const T inputHeight = r[3];
413
414 if (inputWidth < 0 || inputHeight < 0)
415 return false;
416
417 *x = r[0];
418 *y = outputHeight - (r[1] + inputHeight);
419 *w = inputWidth;
420 *h = inputHeight;
421
422 if (boundingMode == Bounded) {
423 const T widthOffset = *x < 0 ? -*x : 0;
424 const T heightOffset = *y < 0 ? -*y : 0;
425 *w = *x < outputWidth ? qMax<T>(0, inputWidth - widthOffset) : 0;
426 *h = *y < outputHeight ? qMax<T>(0, inputHeight - heightOffset) : 0;
427
428 if (outputWidth > 0)
429 *x = qBound<T>(0, *x, outputWidth - 1);
430 if (outputHeight > 0)
431 *y = qBound<T>(0, *y, outputHeight - 1);
432
433 if (*x + *w > outputWidth)
434 *w = qMax<T>(0, outputWidth - *x);
435 if (*y + *h > outputHeight)
436 *h = qMax<T>(0, outputHeight - *y);
437 }
438 return true;
439}
440
442{
444 QRhiBufferDataPrivate() { } // don't value-initialize smallData
445 int ref = 1;
448 static constexpr quint32 SMALL_DATA_SIZE = 1024;
449 char smallData[SMALL_DATA_SIZE];
450};
451
452// no detach-with-contents, no atomic refcount, no shrink
454{
455public:
456 QRhiBufferData() = default;
458 {
459 if (d && !--d->ref)
460 delete d;
461 }
463 : d(other.d)
464 {
465 if (d)
466 d->ref += 1;
467 }
469 : d(std::exchange(other.d, nullptr))
470 {
471 }
474 {
475 if (d == other.d)
476 return *this;
477 if (other.d)
478 other.d->ref += 1;
479 if (d && !--d->ref)
480 delete d;
481 d = other.d;
482 return *this;
483 }
484 void swap(QRhiBufferData &other) noexcept
485 {
486 qt_ptr_swap(d, other.d);
487 }
488 const char *constData() const
489 {
490 return d ? (d->size <= QRhiBufferDataPrivate::SMALL_DATA_SIZE ? d->smallData : d->largeData.constData()) : nullptr;
491 }
492 quint32 size() const
493 {
494 return d ? d->size : 0;
495 }
497 {
498 return d ? d->largeData.size() : 0;
499 }
500 void assign(const char *s, quint32 size)
501 {
502 if (!d) {
503 d = new QRhiBufferDataPrivate;
504 } else if (d->ref != 1) {
505 if (QRHI_LOG_RUB().isDebugEnabled())
506 qDebug("[rub] QRhiBufferData %p/%p new backing due to no-copy detach, ref was %d", this, d, d->ref);
507 d->ref -= 1;
508 d = new QRhiBufferDataPrivate;
509 }
510 d->size = size;
511 if (size <= QRhiBufferDataPrivate::SMALL_DATA_SIZE) {
512 memcpy(d->smallData, s, size);
513 } else {
514 if (QRHI_LOG_RUB().isDebugEnabled() && largeAlloc() < size)
515 qDebug("[rub] QRhiBufferData %p/%p new large data allocation %u -> %u", this, d, largeAlloc(), size);
516 d->largeData.assign(QByteArrayView(s, size)); // keeps capacity
517 }
518 }
519 void assign(QByteArray data)
520 {
521 if (!d) {
522 d = new QRhiBufferDataPrivate;
523 } else if (d->ref != 1) {
524 if (QRHI_LOG_RUB().isDebugEnabled())
525 qDebug("[rub] QRhiBufferData %p/%p new backing due to no-copy detach, ref was %d", this, d, d->ref);
526 d->ref -= 1;
527 d = new QRhiBufferDataPrivate;
528 }
529 d->size = data.size();
530 if (d->size <= QRhiBufferDataPrivate::SMALL_DATA_SIZE) {
531 memcpy(d->smallData, data.constData(), data.size());
532 } else {
533 d->largeData = std::move(data);
534 }
535 }
536private:
537 QRhiBufferDataPrivate *d = nullptr;
538};
539
541
543{
544public:
545 struct BufferOp {
554 QRhiBuffer *buf;
557 quint32 readSize; // also the number of bytes to copy with Copy, or to fill with Clear
559 QRhiBuffer *src;
562
563 static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
564 {
565 BufferOp op = {};
566 changeToDynamicUpdate(&op, buf, offset, size, data);
567 return op;
568 }
569
570 static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
571 {
573 op->buf = buf;
574 op->offset = offset;
575 const int effectiveSize = size ? size : buf->size();
576 op->data.assign(reinterpret_cast<const char *>(data), effectiveSize);
577 }
578
579 static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, QByteArray data)
580 {
581 BufferOp op = {};
582 changeToDynamicUpdate(&op, buf, offset, std::move(data));
583 return op;
584 }
585
586 static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, QByteArray data)
587 {
589 op->buf = buf;
590 op->offset = offset;
591 op->data.assign(std::move(data));
592 }
593
594 static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
595 {
596 BufferOp op = {};
597 changeToStaticUpload(&op, buf, offset, size, data);
598 return op;
599 }
600
601 static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
602 {
604 op->buf = buf;
605 op->offset = offset;
606 const int effectiveSize = size ? size : buf->size();
607 op->data.assign(reinterpret_cast<const char *>(data), effectiveSize);
608 }
609
610 static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, QByteArray data)
611 {
612 BufferOp op = {};
613 changeToStaticUpload(&op, buf, offset, std::move(data));
614 return op;
615 }
616
617 static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, QByteArray data)
618 {
620 op->buf = buf;
621 op->offset = offset;
622 op->data.assign(std::move(data));
623 }
624
625 static BufferOp read(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result)
626 {
627 BufferOp op = {};
628 op.type = Read;
629 op.buf = buf;
630 op.offset = offset;
631 op.readSize = size;
632 op.result = result;
633 return op;
634 }
635
636 static BufferOp copy(QRhiBuffer *dst, QRhiBuffer *src, quint32 dstOffset,
637 quint32 srcOffset, quint32 size)
638 {
639 BufferOp op = {};
640 op.type = Copy;
641 op.buf = dst;
642 op.offset = dstOffset;
643 op.readSize = size;
644 op.src = src;
645 op.srcOffset = srcOffset;
646 return op;
647 }
648
649 static BufferOp clear(QRhiBuffer *buf, quint32 offset, quint32 size, quint8 value)
650 {
651 BufferOp op = {};
652 op.type = Clear;
653 op.buf = buf;
654 op.offset = offset;
655 op.readSize = size;
656 op.fillValue = value;
657 return op;
658 }
659
660 // For the APIs that clear in units of 32 bits: fillValue repeated in
661 // all four bytes of the word, e.g. 0xAB becomes 0xABABABAB.
663 {
664 return quint32(fillValue) * 0x01010101u;
665 }
666 };
667
668 struct TextureOp {
676 QRhiTexture *dst;
677 // Specifying multiple uploads for a subresource must be supported.
678 // In the backend this can then end up, where applicable, as a
679 // single, batched copy operation with only one set of barriers.
680 // This helps when doing for example glyph cache fills.
681 //
682 // Stored as a flat list sorted by layer, then level, preserving the
683 // submission order within a subresource. (a dense layer x level grid
684 // of containers costs kilobytes per op even when empty, and there
685 // are dozens of ops preallocated in each batch)
692 QRhiTexture *src;
696
697 static TextureOp upload(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
698 {
699 TextureOp op = {};
700 op.type = Upload;
701 op.dst = tex;
702 for (auto it = desc.cbeginEntries(), itEnd = desc.cendEntries(); it != itEnd; ++it)
703 op.subresDesc.append({ it->layer(), it->level(), it->description() });
704 std::stable_sort(op.subresDesc.begin(), op.subresDesc.end(),
705 [](const SubresourceUpload &a, const SubresourceUpload &b) {
706 return a.layer != b.layer ? a.layer < b.layer : a.level < b.level;
707 });
708 return op;
709 }
710
711 static TextureOp copy(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc)
712 {
713 TextureOp op = {};
714 op.type = Copy;
715 op.dst = dst;
716 op.src = src;
717 op.desc = desc;
718 return op;
719 }
720
721 static TextureOp read(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
722 {
723 TextureOp op = {};
724 op.type = Read;
725 op.rb = rb;
726 op.result = result;
727 return op;
728 }
729
730 static TextureOp genMips(QRhiTexture *tex)
731 {
732 TextureOp op = {};
733 op.type = GenMips;
734 op.dst = tex;
735 return op;
736 }
737 };
738
739 int activeBufferOpCount = 0; // this is the real number of used elements in bufferOps, not bufferOps.count()
740 static const int BUFFER_OPS_STATIC_ALLOC = 64;
742
743 int activeTextureOpCount = 0; // this is the real number of used elements in textureOps, not textureOps.count()
744 static const int TEXTURE_OPS_STATIC_ALLOC = 32;
746
747 QRhiResourceUpdateBatch *q = nullptr;
748 QRhiImplementation *rhi = nullptr;
749 int poolIndex = -1;
750
751 void free();
753 bool hasOptimalCapacity() const;
754 void trimOpLists();
755
756 static QRhiResourceUpdateBatchPrivate *get(QRhiResourceUpdateBatch *b) { return b->d; }
757};
758
759template<typename T>
761{
762 void feed(int binding, T resource) { // binding must be strictly increasing
763 if (curBinding == -1 || binding > curBinding + 1) {
764 finish();
765 curBatch.startBinding = binding;
766 curBatch.resources.clear();
767 curBatch.resources.append(resource);
768 } else {
769 Q_ASSERT(binding == curBinding + 1);
770 curBatch.resources.append(resource);
771 }
772 curBinding = binding;
773 }
774
775 bool finish() {
776 if (!curBatch.resources.isEmpty())
777 batches.append(curBatch);
778 return !batches.isEmpty();
779 }
780
781 void clear() {
782 batches.clear();
783 curBatch.resources.clear();
784 curBinding = -1;
785 }
786
787 struct Batch {
790
791 bool operator==(const Batch &other) const
792 {
793 return startBinding == other.startBinding && resources == other.resources;
794 }
795
796 bool operator!=(const Batch &other) const
797 {
798 return !operator==(other);
799 }
800 };
801
802 // some backends make copies of QRhiBatchedBindings -> implicit sharing and
803 // not having a (possibly wasted) prealloc are beneficial -> use QVector
804 // instead of QVLA
805 QVector<Batch> batches; // sorted by startBinding
806
807 bool operator==(const QRhiBatchedBindings<T> &other) const
808 {
809 return batches == other.batches;
810 }
811
812 bool operator!=(const QRhiBatchedBindings<T> &other) const
813 {
814 return !operator==(other);
815 }
816
817private:
818 Batch curBatch;
819 int curBinding = -1;
820};
821
823{
824public:
825#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
826 using Type = quint64;
827#else
828 using Type = quint32;
829#endif
830 static Type newId();
831};
832
833// The tracked resources of a pass, in the order the pass first used them.
834// Neither QHash nor QVarLengthFlatMap is suitable on its own. Most passes track
835// a handful of resources, which a QHash would allocate for. But a pass can also
836// track thousands, such as the vertex and index buffers of thousands of draw
837// calls, and a flat map keeps its keys sorted, so each insertion shifts half
838// the entries, which is quadratic in the number of resources. So the entries are
839// appended to a QVarLengthArray and searched linearly while there are few, and
840// indexed by a QHash once there are more.
841template <typename Key, typename T, qsizetype Prealloc>
843{
844public:
845 using value_type = std::pair<Key, T>;
847 using const_iterator = const value_type *;
848
849 iterator begin() { return m_entries.begin(); }
850 iterator end() { return m_entries.end(); }
851 const_iterator begin() const { return m_entries.cbegin(); }
852 const_iterator end() const { return m_entries.cend(); }
853 const_iterator cbegin() const { return m_entries.cbegin(); }
854 const_iterator cend() const { return m_entries.cend(); }
855
856 bool isEmpty() const { return m_entries.isEmpty(); }
857 qsizetype size() const { return m_entries.size(); }
858
859 void clear()
860 {
861 m_entries.clear();
862 m_index.clear();
863 }
864
865 const_iterator find(Key key) const
866 {
867 if (m_index.isEmpty()) {
868 return std::find_if(m_entries.cbegin(), m_entries.cend(),
869 [key](const value_type &entry) { return entry.first == key; });
870 }
871 const auto it = m_index.constFind(key);
872 return it == m_index.cend() ? m_entries.cend() : m_entries.cbegin() + it.value();
873 }
874
875 iterator find(Key key)
876 {
877 const const_iterator it = std::as_const(*this).find(key);
878 return m_entries.begin() + (it - m_entries.cbegin());
879 }
880
881 bool contains(Key key) const { return find(key) != cend(); }
882
883 // The key must not be in the map yet.
884 void append(Key key, const T &value)
885 {
886 m_entries.append({ key, value });
887 if (!m_index.isEmpty()) {
888 m_index.insert(key, m_entries.size() - 1);
889 } else if (m_entries.size() > LinearSearchLimit) {
890 m_index.reserve(m_entries.size() * 2);
891 for (qsizetype i = 0; i < m_entries.size(); ++i)
892 m_index.insert(m_entries[i].first, i);
893 }
894 }
895
896private:
897 static constexpr qsizetype LinearSearchLimit = 32;
898 QVarLengthArray<value_type, Prealloc> m_entries;
899 QHash<Key, qsizetype> m_index;
900};
901
903{
904public:
905 bool isEmpty() const;
906 void reset();
907
908 struct UsageState {
911 int stage;
912 };
913
924
934
935 void registerBuffer(QRhiBuffer *buf, int slot, BufferAccess *access, BufferStage *stage,
936 const UsageState &state);
937
948
959
960 void registerTexture(QRhiTexture *tex, TextureAccess *access, TextureStage *stage,
961 const UsageState &state);
962
969
970 const QRhiPassResourceMap<QRhiBuffer *, Buffer, 12> &buffers() const { return m_buffers; }
971
977
978 const QRhiPassResourceMap<QRhiTexture *, Texture, 12> &textures() const { return m_textures; }
979
980 static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages);
981 static TextureStage toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages);
982
983private:
984 QRhiPassResourceMap<QRhiBuffer *, Buffer, 12> m_buffers;
985 QRhiPassResourceMap<QRhiTexture *, Texture, 12> m_textures;
986};
987
990
991template<typename T, int GROW = 1024>
993{
994public:
996 ~QRhiBackendCommandList() { delete[] v; }
997 inline void reset() { p = 0; }
998 inline bool isEmpty() const { return p == 0; }
999 inline T &get() {
1000 if (p == a) {
1001 a += GROW;
1002 T *nv = new T[a];
1003 if (v) {
1004 memcpy(nv, v, p * sizeof(T));
1005 delete[] v;
1006 }
1007 v = nv;
1008 }
1009 return v[p++];
1010 }
1011 inline void unget() { --p; }
1012 inline T *cbegin() const { return v; }
1013 inline T *cend() const { return v + p; }
1014 inline T *begin() { return v; }
1015 inline T *end() { return v + p; }
1016private:
1018 T *v = nullptr;
1019 int a = 0;
1020 int p = 0;
1021};
1022
1024{
1025 struct ResId { quint64 id; uint generation; };
1026 using ResIdList = QVarLengthArray<ResId, 8 * 2 + 1>; // color, resolve, ds
1027
1028 template<typename TexType, typename RenderBufferType>
1029 static void updateResIdList(const QRhiTextureRenderTargetDescription &desc, ResIdList *dst);
1030
1031 template<typename TexType, typename RenderBufferType>
1032 static bool isUpToDate(const QRhiTextureRenderTargetDescription &desc, const ResIdList &currentResIdList);
1033};
1034
1036{
1037 return a.id == b.id && a.generation == b.generation;
1038}
1039
1041{
1042 return !(a == b);
1043}
1044
1045template<typename TexType, typename RenderBufferType>
1046void QRhiRenderTargetAttachmentTracker::updateResIdList(const QRhiTextureRenderTargetDescription &desc, ResIdList *dst)
1047{
1048 const bool hasDepthStencil = desc.depthStencilBuffer() || desc.depthTexture();
1049 dst->resize(desc.colorAttachmentCount() * 2 + (hasDepthStencil ? 1 : 0));
1050 int n = 0;
1051 for (auto it = desc.cbeginColorAttachments(), itEnd = desc.cendColorAttachments(); it != itEnd; ++it, ++n) {
1052 const QRhiColorAttachment &colorAtt(*it);
1053 if (colorAtt.texture()) {
1054 TexType *texD = QRHI_RES(TexType, colorAtt.texture());
1055 (*dst)[n] = { texD->globalResourceId(), texD->generation };
1056 } else if (colorAtt.renderBuffer()) {
1057 RenderBufferType *rbD = QRHI_RES(RenderBufferType, colorAtt.renderBuffer());
1058 (*dst)[n] = { rbD->globalResourceId(), rbD->generation };
1059 } else {
1060 (*dst)[n] = { 0, 0 };
1061 }
1062 ++n;
1063 if (colorAtt.resolveTexture()) {
1064 TexType *texD = QRHI_RES(TexType, colorAtt.resolveTexture());
1065 (*dst)[n] = { texD->globalResourceId(), texD->generation };
1066 } else {
1067 (*dst)[n] = { 0, 0 };
1068 }
1069 }
1070 if (hasDepthStencil) {
1071 if (desc.depthTexture()) {
1072 TexType *depthTexD = QRHI_RES(TexType, desc.depthTexture());
1073 (*dst)[n] = { depthTexD->globalResourceId(), depthTexD->generation };
1074 } else if (desc.depthStencilBuffer()) {
1075 RenderBufferType *depthRbD = QRHI_RES(RenderBufferType, desc.depthStencilBuffer());
1076 (*dst)[n] = { depthRbD->globalResourceId(), depthRbD->generation };
1077 } else {
1078 (*dst)[n] = { 0, 0 };
1079 }
1080 }
1081}
1082
1083template<typename TexType, typename RenderBufferType>
1084bool QRhiRenderTargetAttachmentTracker::isUpToDate(const QRhiTextureRenderTargetDescription &desc, const ResIdList &currentResIdList)
1085{
1086 // Just as setShaderResources() recognizes if an srb's referenced
1087 // resources have been rebuilt (got a create() since the srb's
1088 // create()), we should do the same for the textures and renderbuffers
1089 // referenced from the rendertarget. It is not uncommon that a texture
1090 // or ds buffer gets resized due to following a window size in some
1091 // form, which involves a create() on them. It is then nice if the
1092 // render target auto-rebuilds in beginPass().
1093
1094 ResIdList resIdList;
1095 updateResIdList<TexType, RenderBufferType>(desc, &resIdList);
1096 return resIdList == currentResIdList;
1097}
1098
1099template<typename T>
1100inline T *qrhi_objectFromProxyData(QRhiSwapChainProxyData *pd, QWindow *window, QRhi::Implementation impl, uint objectIndex)
1101{
1102 Q_ASSERT(objectIndex < std::size(pd->reserved));
1103 if (!pd->reserved[objectIndex]) // // was not set, no other choice, do it here, whatever thread this is
1104 *pd = QRhi::updateSwapChainProxyData(impl, window);
1105 return static_cast<T *>(pd->reserved[objectIndex]);
1106}
1107
1109{
1110public:
1111 QRhiPipelineCacheDataReader(const char *data, quint32 size)
1112 : m_p(data), m_end(data + size)
1113 {
1114 }
1115
1116 bool readUInt32(quint32 *dst)
1117 {
1118 if (m_end - m_p < qptrdiff(sizeof(quint32)))
1119 return false;
1120 memcpy(dst, m_p, sizeof(quint32));
1121 m_p += sizeof(quint32);
1122 return true;
1123 }
1124
1125 // Reads a 32-bit length, followed by that many bytes.
1126 bool readByteArray(QByteArray *dst)
1127 {
1128 quint32 len = 0;
1129 if (!readUInt32(&len))
1130 return false;
1131 if (quint64(m_end - m_p) < len)
1132 return false;
1133 *dst = QByteArray(m_p, qsizetype(len));
1134 m_p += len;
1135 return true;
1136 }
1137
1138private:
1139 const char *m_p;
1140 const char *m_end;
1141};
1142
1143QT_END_NAMESPACE
1144
1145#endif
friend bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are equal, otherwise returns false.
Definition qbytearray.h:834
friend bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are different, otherwise returns false.
Definition qbytearray.h:845
QRhiBackendCommandList()=default
T * cbegin() const
Definition qrhi_p.h:1012
bool isEmpty() const
Definition qrhi_p.h:998
void execute(QRhiCommandBuffer *cb, quint32 firstCommand, quint32 commandCount)
Definition qrhi.cpp:9449
QRhiBufferBackedIndirectCommandBuffer(QRhiImplementation *rhi, Type type, quint32 maxCommandCount)
\variable QRhiIndirectCommandBufferBuildInfo::topology
Definition qrhi.cpp:9359
void enqueueUpload(QRhiResourceUpdateBatch *u)
Definition qrhi.cpp:9413
QRhiIndirectCommandBufferBuildInfo buildInfo
Definition qrhi_p.h:387
void build(const QRhiIndirectCommandBufferBuildInfo &info)
Definition qrhi.cpp:9436
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
Definition qrhi.cpp:9371
bool create() override
Creates the corresponding native objects.
Definition qrhi.cpp:9394
void swap(QRhiBufferData &other) noexcept
Definition qrhi_p.h:484
void assign(QByteArray data)
Definition qrhi_p.h:519
QRhiBufferData()=default
void assign(const char *s, quint32 size)
Definition qrhi_p.h:500
quint32 size() const
Definition qrhi_p.h:492
QRhiBufferData(const QRhiBufferData &other)
Definition qrhi_p.h:462
quint32 largeAlloc() const
Definition qrhi_p.h:496
QRhiBufferData(QRhiBufferData &&other) noexcept
Definition qrhi_p.h:468
QRhiBufferData & operator=(const QRhiBufferData &other)
Definition qrhi_p.h:473
const char * constData() const
Definition qrhi_p.h:488
iterator end()
Definition qrhi_p.h:850
value_type * iterator
Definition qrhi_p.h:846
const value_type * const_iterator
Definition qrhi_p.h:847
bool isEmpty() const
Definition qrhi_p.h:856
iterator find(Key key)
Definition qrhi_p.h:875
const_iterator end() const
Definition qrhi_p.h:852
void append(Key key, const T &value)
Definition qrhi_p.h:884
const_iterator find(Key key) const
Definition qrhi_p.h:865
qsizetype size() const
Definition qrhi_p.h:857
std::pair< Key, T > value_type
Definition qrhi_p.h:845
const_iterator begin() const
Definition qrhi_p.h:851
bool contains(Key key) const
Definition qrhi_p.h:881
const_iterator cend() const
Definition qrhi_p.h:854
iterator begin()
Definition qrhi_p.h:849
const_iterator cbegin() const
Definition qrhi_p.h:853
static TextureStage toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages)
Definition qrhi.cpp:13930
static BufferStage toPassTrackerBufferStage(QRhiShaderResourceBinding::StageFlags stages)
Definition qrhi.cpp:13911
bool isEmpty() const
Definition qrhi.cpp:13820
const QRhiPassResourceMap< QRhiTexture *, Texture, 12 > & textures() const
Definition qrhi_p.h:978
void registerBuffer(QRhiBuffer *buf, int slot, BufferAccess *access, BufferStage *stage, const UsageState &state)
Definition qrhi.cpp:13837
void registerTexture(QRhiTexture *tex, TextureAccess *access, TextureStage *stage, const UsageState &state)
Definition qrhi.cpp:13877
const QRhiPassResourceMap< QRhiBuffer *, Buffer, 12 > & buffers() const
Definition qrhi_p.h:970
QRhiPipelineCacheDataReader(const char *data, quint32 size)
Definition qrhi_p.h:1111
bool readByteArray(QByteArray *dst)
Definition qrhi_p.h:1126
bool readUInt32(quint32 *dst)
Definition qrhi_p.h:1116
QVarLengthArray< BufferOp, BUFFER_OPS_STATIC_ALLOC > bufferOps
Definition qrhi_p.h:741
QRhiImplementation * rhi
Definition qrhi_p.h:748
QVarLengthArray< TextureOp, TEXTURE_OPS_STATIC_ALLOC > textureOps
Definition qrhi_p.h:745
static const int BUFFER_OPS_STATIC_ALLOC
Definition qrhi_p.h:740
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
Definition qrhi_p.h:756
void merge(QRhiResourceUpdateBatchPrivate *other)
Definition qrhi.cpp:11559
QRhiResourceUpdateBatch * q
Definition qrhi_p.h:747
static const int TEXTURE_OPS_STATIC_ALLOC
Definition qrhi_p.h:744
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
static const char * resourceTypeStr(const QRhiResource *res)
Definition qrhi.cpp:9610
static QRhiPassResourceTracker::BufferStage earlierStage(QRhiPassResourceTracker::BufferStage a, QRhiPassResourceTracker::BufferStage b)
Definition qrhi.cpp:13831
QDebug operator<<(QDebug dbg, const QRhiSwapChainHdrInfo &info)
Definition qrhi.cpp:8656
static bool isImageLoadStore(QRhiPassResourceTracker::TextureAccess access)
Definition qrhi.cpp:13870
static const char * deviceTypeStr(QRhiDriverInfo::DeviceType type)
\variable QRhiDriverInfo::deviceName
Definition qrhi.cpp:10613
static auto & emplaceData(QRhiShaderResourceBinding::Data &d)
Definition qrhi.cpp:6321
static QRhiPassResourceTracker::TextureStage earlierStage(QRhiPassResourceTracker::TextureStage a, QRhiPassResourceTracker::TextureStage b)
Definition qrhi.cpp:13864
QRhiTargetRectBoundMode
Definition qrhi_p.h:391
@ UnBounded
Definition qrhi_p.h:392
@ Bounded
Definition qrhi_p.h:393
Q_DECLARE_TYPEINFO(QRhiPassResourceTracker::Texture, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(QRhiBufferData, Q_RELOCATABLE_TYPE)
T * qrhi_objectFromProxyData(QRhiSwapChainProxyData *pd, QWindow *window, QRhi::Implementation impl, uint objectIndex)
Definition qrhi_p.h:1100
bool operator!=(const QRhiRenderTargetAttachmentTracker::ResId &a, const QRhiRenderTargetAttachmentTracker::ResId &b)
Definition qrhi_p.h:1040
Q_DECLARE_TYPEINFO(QRhiPassResourceTracker::Buffer, Q_RELOCATABLE_TYPE)
#define QRHI_RES(t, x)
Definition qrhi_p.h:32
bool operator==(const QRhiRenderTargetAttachmentTracker::ResId &a, const QRhiRenderTargetAttachmentTracker::ResId &b)
Definition qrhi_p.h:1035
quint32 qrhiBinaryCacheEntryByteSize(const QByteArray &data)
Definition qrhi_p.h:311
bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array< T, N > &r, T *x, T *y, T *w, T *h)
Definition qrhi_p.h:397
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
Definition qsize.h:192
bool operator!=(const Batch &other) const
Definition qrhi_p.h:796
QVector< T > resources
Definition qrhi_p.h:789
bool operator==(const Batch &other) const
Definition qrhi_p.h:791
void feed(int binding, T resource)
Definition qrhi_p.h:762
QVector< Batch > batches
Definition qrhi_p.h:805
bool operator!=(const QRhiBatchedBindings< T > &other) const
Definition qrhi_p.h:812
bool operator==(const QRhiBatchedBindings< T > &other) const
Definition qrhi_p.h:807
void insertWithCapacityLimit(const Key &key, const Value &value)
Definition qrhi_p.h:332
quint32 dataByteSize
Definition qrhi_p.h:323
void clear()
Definition qrhi_p.h:326
const char * name
Definition qrhi_p.h:324
QHash< Key, Value > data
Definition qrhi_p.h:322
QRhiBinaryCache(const char *name)
Definition qrhi_p.h:320
char smallData[SMALL_DATA_SIZE]
Definition qrhi_p.h:449
QByteArray largeData
Definition qrhi_p.h:447
static constexpr quint32 SMALL_DATA_SIZE
Definition qrhi_p.h:448
void(*) frameEnd(QRhiImplementation *d, QRhiSwapChain *swapChain, QRhiCommandBuffer *cb)
Definition qrhi_p.h:363
void(*) rhiAboutToBeDestroyed(QRhiImplementation *d)
Definition qrhi_p.h:364
static void updateResIdList(const QRhiTextureRenderTargetDescription &desc, ResIdList *dst)
Definition qrhi_p.h:1046
static bool isUpToDate(const QRhiTextureRenderTargetDescription &desc, const ResIdList &currentResIdList)
Definition qrhi_p.h:1084
static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, QByteArray data)
Definition qrhi_p.h:586
static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, QByteArray data)
Definition qrhi_p.h:617
static BufferOp clear(QRhiBuffer *buf, quint32 offset, quint32 size, quint8 value)
Definition qrhi_p.h:649
static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:601
static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, QByteArray data)
Definition qrhi_p.h:579
static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, QByteArray data)
Definition qrhi_p.h:610
static BufferOp copy(QRhiBuffer *dst, QRhiBuffer *src, quint32 dstOffset, quint32 srcOffset, quint32 size)
Definition qrhi_p.h:636
static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:594
static BufferOp read(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result)
Definition qrhi_p.h:625
static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:563
static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
Definition qrhi_p.h:570
QRhiTextureSubresourceUploadDescription desc
Definition qrhi_p.h:689
QRhiTextureCopyDescription desc
Definition qrhi_p.h:693
static TextureOp copy(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc)
Definition qrhi_p.h:711
QVarLengthArray< SubresourceUpload, 4 > subresDesc
Definition qrhi_p.h:691
static TextureOp upload(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
Definition qrhi_p.h:697
static TextureOp genMips(QRhiTexture *tex)
Definition qrhi_p.h:730
static TextureOp read(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
Definition qrhi_p.h:721
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1616
LimitsType limitsType
Definition qrhi.h:1627
LuminanceBehavior luminanceBehavior
Definition qrhi.h:1638
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1649
void * reserved[2]
Definition qrhi.h:1650