16#include <QtGui/qtguiglobal.h>
17#include <QtCore/qsize.h>
18#include <QtCore/qlist.h>
19#include <QtCore/qvarlengtharray.h>
20#include <QtCore/qthread.h>
21#include <QtGui/qmatrix4x4.h>
22#include <QtGui/qcolor.h>
23#include <QtGui/qimage.h>
27#include <rhi/qshader.h>
33class QRhiImplementation;
35class QRhiRenderBuffer;
38class QRhiCommandBuffer;
39class QRhiResourceUpdateBatch;
42class QRhiShadingRateMap;
47 QRhiDepthStencilClearValue() =
default;
48 QRhiDepthStencilClearValue(
float d, quint32 s);
50 float depthClearValue()
const {
return m_d; }
51 void setDepthClearValue(
float d) { m_d = d; }
53 quint32 stencilClearValue()
const {
return m_s; }
54 void setStencilClearValue(quint32 s) { m_s = s; }
60 friend bool operator==(
const QRhiDepthStencilClearValue &a,
const QRhiDepthStencilClearValue &b)
noexcept
62 return a.m_d == b.m_d && a.m_s == b.m_s;
65 friend bool operator!=(
const QRhiDepthStencilClearValue &a,
const QRhiDepthStencilClearValue &b)
noexcept
70 friend size_t qHash(
const QRhiDepthStencilClearValue &v, size_t seed = 0)
noexcept
72 QtPrivate::QHashCombine hash;
73 seed = hash(seed, v.m_d);
74 seed = hash(seed, v.m_s);
81#ifndef QT_NO_DEBUG_STREAM
82Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiDepthStencilClearValue &);
88 QRhiViewport() =
default;
89 QRhiViewport(
float x,
float y,
float w,
float h,
float minDepth = 0.0f,
float maxDepth = 1.0f);
91 std::array<
float, 4> viewport()
const {
return m_rect; }
92 void setViewport(
float x,
float y,
float w,
float h) {
93 m_rect[0] = x; m_rect[1] = y; m_rect[2] = w; m_rect[3] = h;
96 float minDepth()
const {
return m_minDepth; }
97 void setMinDepth(
float minDepth) { m_minDepth = minDepth; }
99 float maxDepth()
const {
return m_maxDepth; }
100 void setMaxDepth(
float maxDepth) { m_maxDepth = maxDepth; }
103 std::array<
float, 4> m_rect { { 0.0f, 0.0f, 0.0f, 0.0f } };
104 float m_minDepth = 0.0f;
105 float m_maxDepth = 1.0f;
107 friend bool operator==(
const QRhiViewport &a,
const QRhiViewport &b)
noexcept
109 return a.m_rect == b.m_rect
110 && a.m_minDepth == b.m_minDepth
111 && a.m_maxDepth == b.m_maxDepth;
114 friend bool operator!=(
const QRhiViewport &a,
const QRhiViewport &b)
noexcept
119 friend size_t qHash(
const QRhiViewport &v, size_t seed = 0)
noexcept
121 QtPrivate::QHashCombine hash;
122 seed = hash(seed, v.m_rect[0]);
123 seed = hash(seed, v.m_rect[1]);
124 seed = hash(seed, v.m_rect[2]);
125 seed = hash(seed, v.m_rect[3]);
126 seed = hash(seed, v.m_minDepth);
127 seed = hash(seed, v.m_maxDepth);
134#ifndef QT_NO_DEBUG_STREAM
135Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiViewport &);
141 QRhiScissor() =
default;
142 QRhiScissor(
int x,
int y,
int w,
int h);
144 std::array<
int, 4> scissor()
const {
return m_rect; }
145 void setScissor(
int x,
int y,
int w,
int h) {
146 m_rect[0] = x; m_rect[1] = y; m_rect[2] = w; m_rect[3] = h;
150 std::array<
int, 4> m_rect { { 0, 0, 0, 0 } };
152 friend bool operator==(
const QRhiScissor &a,
const QRhiScissor &b)
noexcept
154 return a.m_rect == b.m_rect;
157 friend bool operator!=(
const QRhiScissor &a,
const QRhiScissor &b)
noexcept
162 friend size_t qHash(
const QRhiScissor &v, size_t seed = 0)
noexcept
164 QtPrivate::QHashCombine hash;
165 seed = hash(seed, v.m_rect[0]);
166 seed = hash(seed, v.m_rect[1]);
167 seed = hash(seed, v.m_rect[2]);
168 seed = hash(seed, v.m_rect[3]);
175#ifndef QT_NO_DEBUG_STREAM
176Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiScissor &);
182 enum Classification {
187 QRhiVertexInputBinding() =
default;
188 QRhiVertexInputBinding(quint32 stride, Classification cls = PerVertex, quint32 stepRate = 1);
190 quint32 stride()
const {
return m_stride; }
191 void setStride(quint32 s) { m_stride = s; }
193 Classification classification()
const {
return m_classification; }
194 void setClassification(Classification c) { m_classification = c; }
196 quint32 instanceStepRate()
const {
return m_instanceStepRate; }
197 void setInstanceStepRate(quint32 rate) { m_instanceStepRate = rate; }
200 quint32 m_stride = 0;
201 Classification m_classification = PerVertex;
202 quint32 m_instanceStepRate = 1;
204 friend bool operator==(
const QRhiVertexInputBinding &a,
const QRhiVertexInputBinding &b)
noexcept
206 return a.m_stride == b.m_stride
207 && a.m_classification == b.m_classification
208 && a.m_instanceStepRate == b.m_instanceStepRate;
211 friend bool operator!=(
const QRhiVertexInputBinding &a,
const QRhiVertexInputBinding &b)
noexcept
216 friend size_t qHash(
const QRhiVertexInputBinding &v, size_t seed = 0)
noexcept
218 QtPrivate::QHashCombine hash;
219 seed = hash(seed, v.m_stride);
220 seed = hash(seed, v.m_classification);
221 seed = hash(seed, v.m_instanceStepRate);
228#ifndef QT_NO_DEBUG_STREAM
229Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiVertexInputBinding &);
265 QRhiVertexInputAttribute() =
default;
266 QRhiVertexInputAttribute(
int binding,
int location, Format format, quint32 offset,
int matrixSlice = -1);
268 int binding()
const {
return m_binding; }
269 void setBinding(
int b) { m_binding = b; }
271 int location()
const {
return m_location; }
272 void setLocation(
int loc) { m_location = loc; }
274 Format format()
const {
return m_format; }
275 void setFormat(Format f) { m_format = f; }
277 quint32 offset()
const {
return m_offset; }
278 void setOffset(quint32 ofs) { m_offset = ofs; }
280 int matrixSlice()
const {
return m_matrixSlice; }
281 void setMatrixSlice(
int slice) { m_matrixSlice = slice; }
286 Format m_format = Float4;
287 quint32 m_offset = 0;
288 int m_matrixSlice = -1;
290 friend bool operator==(
const QRhiVertexInputAttribute &a,
const QRhiVertexInputAttribute &b)
noexcept
292 return a.m_binding == b.m_binding
293 && a.m_location == b.m_location
294 && a.m_format == b.m_format
295 && a.m_offset == b.m_offset;
299 friend bool operator!=(
const QRhiVertexInputAttribute &a,
const QRhiVertexInputAttribute &b)
noexcept
304 friend size_t qHash(
const QRhiVertexInputAttribute &v, size_t seed = 0)
noexcept
306 QtPrivate::QHashCombine hash;
307 seed = hash(seed, v.m_binding);
308 seed = hash(seed, v.m_location);
309 seed = hash(seed, v.m_format);
310 seed = hash(seed, v.m_offset);
317#ifndef QT_NO_DEBUG_STREAM
318Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiVertexInputAttribute &);
324 QRhiVertexInputLayout() =
default;
326 void setBindings(std::initializer_list<QRhiVertexInputBinding> list) { m_bindings = list; }
327 template<
typename InputIterator>
328 void setBindings(InputIterator first, InputIterator last)
331 std::copy(first, last, std::back_inserter(m_bindings));
333 const QRhiVertexInputBinding *cbeginBindings()
const {
return m_bindings.cbegin(); }
334 const QRhiVertexInputBinding *cendBindings()
const {
return m_bindings.cend(); }
335 const QRhiVertexInputBinding *bindingAt(qsizetype index)
const {
return &m_bindings.at(index); }
336 qsizetype bindingCount()
const {
return m_bindings.count(); }
338 void setAttributes(std::initializer_list<QRhiVertexInputAttribute> list) { m_attributes = list; }
339 template<
typename InputIterator>
340 void setAttributes(InputIterator first, InputIterator last)
342 m_attributes.clear();
343 std::copy(first, last, std::back_inserter(m_attributes));
345 const QRhiVertexInputAttribute *cbeginAttributes()
const {
return m_attributes.cbegin(); }
346 const QRhiVertexInputAttribute *cendAttributes()
const {
return m_attributes.cend(); }
347 const QRhiVertexInputAttribute *attributeAt(qsizetype index)
const {
return &m_attributes.at(index); }
348 qsizetype attributeCount()
const {
return m_attributes.count(); }
351 QVarLengthArray<QRhiVertexInputBinding, 8> m_bindings;
352 QVarLengthArray<QRhiVertexInputAttribute, 8> m_attributes;
354 friend bool operator==(
const QRhiVertexInputLayout &a,
const QRhiVertexInputLayout &b)
noexcept
356 return a.m_bindings == b.m_bindings && a.m_attributes == b.m_attributes;
359 friend bool operator!=(
const QRhiVertexInputLayout &a,
const QRhiVertexInputLayout &b)
noexcept
364 friend size_t qHash(
const QRhiVertexInputLayout &v, size_t seed = 0)
noexcept
366 QtPrivate::QHashCombine hash;
367 seed = hash(seed, v.m_bindings);
368 seed = hash(seed, v.m_attributes);
372 friend Q_GUI_EXPORT QDebug operator<<(QDebug,
const QRhiVertexInputLayout &);
375#ifndef QT_NO_DEBUG_STREAM
376Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiVertexInputLayout &);
385 TessellationEvaluation,
391 QRhiShaderStage() =
default;
392 QRhiShaderStage(Type type,
const QShader &shader,
393 QShader::Variant v = QShader::StandardShader);
395 Type type()
const {
return m_type; }
396 void setType(Type t) { m_type = t; }
398 QShader shader()
const {
return m_shader; }
399 void setShader(
const QShader &s) { m_shader = s; }
401 QShader::Variant shaderVariant()
const {
return m_shaderVariant; }
402 void setShaderVariant(QShader::Variant v) { m_shaderVariant = v; }
405 Type m_type = Vertex;
407 QShader::Variant m_shaderVariant = QShader::StandardShader;
409 friend bool operator==(
const QRhiShaderStage &a,
const QRhiShaderStage &b)
noexcept
411 return a.m_type == b.m_type
412 && a.m_shader == b.m_shader
413 && a.m_shaderVariant == b.m_shaderVariant;
416 friend bool operator!=(
const QRhiShaderStage &a,
const QRhiShaderStage &b)
noexcept
421 friend size_t qHash(
const QRhiShaderStage &v, size_t seed = 0)
noexcept
423 QtPrivate::QHashCombine hash;
424 seed = hash(seed, v.m_type);
425 seed = hash(seed, v.m_shader);
426 seed = hash(seed, v.m_shaderVariant);
433#ifndef QT_NO_DEBUG_STREAM
434Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiShaderStage &);
437using QRhiGraphicsShaderStage = QRhiShaderStage;
456 VertexStage = 1 << 0,
457 TessellationControlStage = 1 << 1,
458 TessellationEvaluationStage = 1 << 2,
459 GeometryStage = 1 << 3,
460 FragmentStage = 1 << 4,
461 ComputeStage = 1 << 5
463 Q_DECLARE_FLAGS(StageFlags, StageFlag)
465 QRhiShaderResourceBinding() =
default;
467 bool isLayoutCompatible(
const QRhiShaderResourceBinding &other)
const;
469 static QRhiShaderResourceBinding uniformBuffer(
int binding, StageFlags stage, QRhiBuffer *buf);
470 static QRhiShaderResourceBinding uniformBuffer(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
471 static QRhiShaderResourceBinding uniformBufferWithDynamicOffset(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 size);
473 static QRhiShaderResourceBinding sampledTexture(
int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler);
475 struct TextureAndSampler {
477 QRhiSampler *sampler;
479 static QRhiShaderResourceBinding sampledTextures(
int binding, StageFlags stage,
int count,
const TextureAndSampler *texSamplers);
481 static QRhiShaderResourceBinding texture(
int binding, StageFlags stage, QRhiTexture *tex);
482 static QRhiShaderResourceBinding textures(
int binding, StageFlags stage,
int count, QRhiTexture **tex);
483 static QRhiShaderResourceBinding sampler(
int binding, StageFlags stage, QRhiSampler *sampler);
485 static QRhiShaderResourceBinding imageLoad(
int binding, StageFlags stage, QRhiTexture *tex,
int level);
486 static QRhiShaderResourceBinding imageStore(
int binding, StageFlags stage, QRhiTexture *tex,
int level);
487 static QRhiShaderResourceBinding imageLoadStore(
int binding, StageFlags stage, QRhiTexture *tex,
int level);
489 static QRhiShaderResourceBinding bufferLoad(
int binding, StageFlags stage, QRhiBuffer *buf);
490 static QRhiShaderResourceBinding bufferLoad(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
491 static QRhiShaderResourceBinding bufferStore(
int binding, StageFlags stage, QRhiBuffer *buf);
492 static QRhiShaderResourceBinding bufferStore(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
493 static QRhiShaderResourceBinding bufferLoadStore(
int binding, StageFlags stage, QRhiBuffer *buf);
494 static QRhiShaderResourceBinding bufferLoadStore(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
499 QRhiShaderResourceBinding::StageFlags stage;
500 QRhiShaderResourceBinding::Type type;
501 struct UniformBufferData {
505 bool hasDynamicOffset;
507 static constexpr int MAX_TEX_SAMPLER_ARRAY_SIZE = 16;
508 struct TextureAndOrSamplerData {
510 TextureAndSampler texSamplers[MAX_TEX_SAMPLER_ARRAY_SIZE];
512 struct StorageImageData {
516 struct StorageBufferData {
522 UniformBufferData ubuf;
523 TextureAndOrSamplerData stex;
524 StorageImageData simage;
525 StorageBufferData sbuf;
528 int arraySize()
const
530 return type == QRhiShaderResourceBinding::SampledTexture || type == QRhiShaderResourceBinding::Texture
535 template<
typename Output>
536 Output serialize(Output dst)
const
539 *dst++ = quint32(binding);
540 *dst++ = quint32(stage);
541 *dst++ = quint32(type);
542 *dst++ = quint32(arraySize());
547 static constexpr int LAYOUT_DESC_ENTRIES_PER_BINDING = 4;
549 template<
typename Output>
550 static void serializeLayoutDescription(
const QRhiShaderResourceBinding *first,
551 const QRhiShaderResourceBinding *last,
554 while (first != last) {
555 dst = first->d.serialize(dst);
562 friend class QRhiImplementation;
565Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBinding::StageFlags)
567Q_DECLARE_TYPEINFO(QRhiShaderResourceBinding, Q_PRIMITIVE_TYPE);
569Q_GUI_EXPORT
bool operator==(
const QRhiShaderResourceBinding &a,
const QRhiShaderResourceBinding &b)
noexcept;
570Q_GUI_EXPORT
bool operator!=(
const QRhiShaderResourceBinding &a,
const QRhiShaderResourceBinding &b)
noexcept;
571Q_GUI_EXPORT size_t qHash(
const QRhiShaderResourceBinding &b, size_t seed = 0)
noexcept;
572#ifndef QT_NO_DEBUG_STREAM
573Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiShaderResourceBinding &);
579 QRhiColorAttachment() =
default;
580 QRhiColorAttachment(QRhiTexture *texture);
581 QRhiColorAttachment(QRhiRenderBuffer *renderBuffer);
583 QRhiTexture *texture()
const {
return m_texture; }
584 void setTexture(QRhiTexture *tex) { m_texture = tex; }
586 QRhiRenderBuffer *renderBuffer()
const {
return m_renderBuffer; }
587 void setRenderBuffer(QRhiRenderBuffer *rb) { m_renderBuffer = rb; }
589 int layer()
const {
return m_layer; }
590 void setLayer(
int layer) { m_layer = layer; }
592 int level()
const {
return m_level; }
593 void setLevel(
int level) { m_level = level; }
595 QRhiTexture *resolveTexture()
const {
return m_resolveTexture; }
596 void setResolveTexture(QRhiTexture *tex) { m_resolveTexture = tex; }
598 int resolveLayer()
const {
return m_resolveLayer; }
599 void setResolveLayer(
int layer) { m_resolveLayer = layer; }
601 int resolveLevel()
const {
return m_resolveLevel; }
602 void setResolveLevel(
int level) { m_resolveLevel = level; }
604 int multiViewCount()
const {
return m_multiViewCount; }
605 void setMultiViewCount(
int count) { m_multiViewCount = count; }
608 QRhiTexture *m_texture =
nullptr;
609 QRhiRenderBuffer *m_renderBuffer =
nullptr;
612 QRhiTexture *m_resolveTexture =
nullptr;
613 int m_resolveLayer = 0;
614 int m_resolveLevel = 0;
615 int m_multiViewCount = 0;
623 QRhiTextureRenderTargetDescription() =
default;
624 QRhiTextureRenderTargetDescription(
const QRhiColorAttachment &colorAttachment);
625 QRhiTextureRenderTargetDescription(
const QRhiColorAttachment &colorAttachment, QRhiRenderBuffer *depthStencilBuffer);
626 QRhiTextureRenderTargetDescription(
const QRhiColorAttachment &colorAttachment, QRhiTexture *depthTexture);
628 void setColorAttachments(std::initializer_list<QRhiColorAttachment> list) { m_colorAttachments = list; }
629 template<
typename InputIterator>
630 void setColorAttachments(InputIterator first, InputIterator last)
632 m_colorAttachments.clear();
633 std::copy(first, last, std::back_inserter(m_colorAttachments));
635 const QRhiColorAttachment *cbeginColorAttachments()
const {
return m_colorAttachments.cbegin(); }
636 const QRhiColorAttachment *cendColorAttachments()
const {
return m_colorAttachments.cend(); }
637 const QRhiColorAttachment *colorAttachmentAt(qsizetype index)
const {
return &m_colorAttachments.at(index); }
638 qsizetype colorAttachmentCount()
const {
return m_colorAttachments.count(); }
640 QRhiRenderBuffer *depthStencilBuffer()
const {
return m_depthStencilBuffer; }
641 void setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer) { m_depthStencilBuffer = renderBuffer; }
643 QRhiTexture *depthTexture()
const {
return m_depthTexture; }
644 void setDepthTexture(QRhiTexture *texture) { m_depthTexture = texture; }
646 QRhiTexture *depthResolveTexture()
const {
return m_depthResolveTexture; }
647 void setDepthResolveTexture(QRhiTexture *tex) { m_depthResolveTexture = tex; }
649 QRhiShadingRateMap *shadingRateMap()
const {
return m_shadingRateMap; }
650 void setShadingRateMap(QRhiShadingRateMap *map) { m_shadingRateMap = map; }
653 QVarLengthArray<QRhiColorAttachment, 8> m_colorAttachments;
654 QRhiRenderBuffer *m_depthStencilBuffer =
nullptr;
655 QRhiTexture *m_depthTexture =
nullptr;
656 QRhiTexture *m_depthResolveTexture =
nullptr;
657 QRhiShadingRateMap *m_shadingRateMap =
nullptr;
663 QRhiTextureSubresourceUploadDescription() =
default;
664 explicit QRhiTextureSubresourceUploadDescription(
const QImage &image);
665 QRhiTextureSubresourceUploadDescription(
const void *data, quint32 size);
666 explicit QRhiTextureSubresourceUploadDescription(
const QByteArray &data);
668 QImage image()
const {
return m_image; }
669 void setImage(
const QImage &image) { m_image = image; }
671 QByteArray data()
const {
return m_data; }
672 void setData(
const QByteArray &data) { m_data = data; }
674 quint32 dataStride()
const {
return m_dataStride; }
675 void setDataStride(quint32 stride) { m_dataStride = stride; }
677 QPoint destinationTopLeft()
const {
return m_destinationTopLeft; }
678 void setDestinationTopLeft(
const QPoint &p) { m_destinationTopLeft = p; }
680 QSize sourceSize()
const {
return m_sourceSize; }
681 void setSourceSize(
const QSize &size) { m_sourceSize = size; }
683 QPoint sourceTopLeft()
const {
return m_sourceTopLeft; }
684 void setSourceTopLeft(
const QPoint &p) { m_sourceTopLeft = p; }
689 quint32 m_dataStride = 0;
690 QPoint m_destinationTopLeft;
692 QPoint m_sourceTopLeft;
700 QRhiTextureUploadEntry() =
default;
701 QRhiTextureUploadEntry(
int layer,
int level,
const QRhiTextureSubresourceUploadDescription &desc);
703 int layer()
const {
return m_layer; }
704 void setLayer(
int layer) { m_layer = layer; }
706 int level()
const {
return m_level; }
707 void setLevel(
int level) { m_level = level; }
709 QRhiTextureSubresourceUploadDescription description()
const {
return m_desc; }
710 void setDescription(
const QRhiTextureSubresourceUploadDescription &desc) { m_desc = desc; }
715 QRhiTextureSubresourceUploadDescription m_desc;
723 QRhiTextureUploadDescription() =
default;
724 QRhiTextureUploadDescription(
const QRhiTextureUploadEntry &entry);
725 QRhiTextureUploadDescription(std::initializer_list<QRhiTextureUploadEntry> list);
727 void setEntries(std::initializer_list<QRhiTextureUploadEntry> list) { m_entries = list; }
728 template<
typename InputIterator>
729 void setEntries(InputIterator first, InputIterator last)
732 std::copy(first, last, std::back_inserter(m_entries));
734 const QRhiTextureUploadEntry *cbeginEntries()
const {
return m_entries.cbegin(); }
735 const QRhiTextureUploadEntry *cendEntries()
const {
return m_entries.cend(); }
736 const QRhiTextureUploadEntry *entryAt(qsizetype index)
const {
return &m_entries.at(index); }
737 qsizetype entryCount()
const {
return m_entries.count(); }
740 QVarLengthArray<QRhiTextureUploadEntry, 16> m_entries;
746 QRhiTextureCopyDescription() =
default;
748 QSize pixelSize()
const {
return m_pixelSize; }
749 void setPixelSize(
const QSize &sz) { m_pixelSize = sz; }
751 int sourceLayer()
const {
return m_sourceLayer; }
752 void setSourceLayer(
int layer) { m_sourceLayer = layer; }
754 int sourceLevel()
const {
return m_sourceLevel; }
755 void setSourceLevel(
int level) { m_sourceLevel = level; }
757 QPoint sourceTopLeft()
const {
return m_sourceTopLeft; }
758 void setSourceTopLeft(
const QPoint &p) { m_sourceTopLeft = p; }
760 int destinationLayer()
const {
return m_destinationLayer; }
761 void setDestinationLayer(
int layer) { m_destinationLayer = layer; }
763 int destinationLevel()
const {
return m_destinationLevel; }
764 void setDestinationLevel(
int level) { m_destinationLevel = level; }
766 QPoint destinationTopLeft()
const {
return m_destinationTopLeft; }
767 void setDestinationTopLeft(
const QPoint &p) { m_destinationTopLeft = p; }
771 int m_sourceLayer = 0;
772 int m_sourceLevel = 0;
773 QPoint m_sourceTopLeft;
774 int m_destinationLayer = 0;
775 int m_destinationLevel = 0;
776 QPoint m_destinationTopLeft;
784 QRhiReadbackDescription() =
default;
785 QRhiReadbackDescription(QRhiTexture *texture);
787 QRhiTexture *texture()
const {
return m_texture; }
788 void setTexture(QRhiTexture *tex) { m_texture = tex; }
790 int layer()
const {
return m_layer; }
791 void setLayer(
int layer) { m_layer = layer; }
793 int level()
const {
return m_level; }
794 void setLevel(
int level) { m_level = level; }
797 QRhiTexture *m_texture =
nullptr;
816 RenderPassDescriptor,
817 SwapChainRenderTarget,
819 ShaderResourceBindings,
827 virtual ~QRhiResource();
829 virtual Type resourceType()
const = 0;
831 virtual void destroy() = 0;
835 QByteArray name()
const;
836 void setName(
const QByteArray &name);
838 quint64 globalResourceId()
const;
843 QRhiResource(QRhiImplementation *rhi);
844 Q_DISABLE_COPY(QRhiResource)
845 friend class QRhiImplementation;
846 QRhiImplementation *m_rhi =
nullptr;
848 QByteArray m_objectName;
861 VertexBuffer = 1 << 0,
862 IndexBuffer = 1 << 1,
863 UniformBuffer = 1 << 2,
864 StorageBuffer = 1 << 3
866 Q_DECLARE_FLAGS(UsageFlags, UsageFlag)
868 struct NativeBuffer {
869 const void *objects[3];
873 QRhiResource::Type resourceType()
const override;
875 Type type()
const {
return m_type; }
876 void setType(Type t) { m_type = t; }
878 UsageFlags usage()
const {
return m_usage; }
879 void setUsage(UsageFlags u) { m_usage = u; }
881 quint32 size()
const {
return m_size; }
882 void setSize(quint32 sz) { m_size = sz; }
884 virtual bool create() = 0;
886 virtual NativeBuffer nativeBuffer();
888 virtual char *beginFullDynamicBufferUpdateForCurrentFrame();
889 virtual void endFullDynamicBufferUpdateForCurrentFrame();
890 virtual void fullDynamicBufferUpdateForCurrentFrame(
const void *data, quint32 size = 0);
893 QRhiBuffer(QRhiImplementation *rhi, Type type_, UsageFlags usage_, quint32 size_);
899Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiBuffer::UsageFlags)
901class Q_GUI_EXPORT QRhiTexture :
public QRhiResource
905 RenderTarget = 1 << 0,
909 UsedAsTransferSource = 1 << 5,
910 UsedWithGenerateMips = 1 << 6,
911 UsedWithLoadStore = 1 << 7,
912 UsedAsCompressedAtlas = 1 << 8,
913 ExternalOES = 1 << 9,
914 ThreeDimensional = 1 << 10,
915 TextureRectangleGL = 1 << 11,
916 TextureArray = 1 << 12,
917 OneDimensional = 1 << 13,
918 UsedAsShadingRateMap = 1 << 14
920 Q_DECLARE_FLAGS(Flags, Flag)
984 struct NativeTexture {
989 QRhiResource::Type resourceType()
const override;
991 Format format()
const {
return m_format; }
992 void setFormat(Format fmt) { m_format = fmt; }
994 QSize pixelSize()
const {
return m_pixelSize; }
995 void setPixelSize(
const QSize &sz) { m_pixelSize = sz; }
997 int depth()
const {
return m_depth; }
998 void setDepth(
int depth) { m_depth = depth; }
1000 int arraySize()
const {
return m_arraySize; }
1001 void setArraySize(
int arraySize) { m_arraySize = arraySize; }
1003 int arrayRangeStart()
const {
return m_arrayRangeStart; }
1004 int arrayRangeLength()
const {
return m_arrayRangeLength; }
1005 void setArrayRange(
int startIndex,
int count)
1007 m_arrayRangeStart = startIndex;
1008 m_arrayRangeLength = count;
1011 Flags flags()
const {
return m_flags; }
1012 void setFlags(Flags f) { m_flags = f; }
1014 int sampleCount()
const {
return m_sampleCount; }
1015 void setSampleCount(
int s) { m_sampleCount = s; }
1018 QRhiTexture::Format format;
1021 ViewFormat readViewFormat()
const {
return m_readViewFormat; }
1022 void setReadViewFormat(
const ViewFormat &fmt) { m_readViewFormat = fmt; }
1023 ViewFormat writeViewFormat()
const {
return m_writeViewFormat; }
1024 void setWriteViewFormat(
const ViewFormat &fmt) { m_writeViewFormat = fmt; }
1026 virtual bool create() = 0;
1027 virtual NativeTexture nativeTexture();
1028 virtual bool createFrom(NativeTexture src);
1029 virtual void setNativeLayout(
int layout);
1032 QRhiTexture(QRhiImplementation *rhi, Format format_,
const QSize &pixelSize_,
int depth_,
1033 int arraySize_,
int sampleCount_, Flags flags_);
1040 int m_arrayRangeStart = -1;
1041 int m_arrayRangeLength = -1;
1042 ViewFormat m_readViewFormat = { UnknownFormat,
false };
1043 ViewFormat m_writeViewFormat = { UnknownFormat,
false };
1046Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiTexture::Flags)
1048class Q_GUI_EXPORT QRhiSampler :
public QRhiResource
1074 QRhiResource::Type resourceType()
const override;
1076 Filter magFilter()
const {
return m_magFilter; }
1077 void setMagFilter(Filter f) { m_magFilter = f; }
1079 Filter minFilter()
const {
return m_minFilter; }
1080 void setMinFilter(Filter f) { m_minFilter = f; }
1082 Filter mipmapMode()
const {
return m_mipmapMode; }
1083 void setMipmapMode(Filter f) { m_mipmapMode = f; }
1085 AddressMode addressU()
const {
return m_addressU; }
1086 void setAddressU(AddressMode mode) { m_addressU = mode; }
1088 AddressMode addressV()
const {
return m_addressV; }
1089 void setAddressV(AddressMode mode) { m_addressV = mode; }
1091 AddressMode addressW()
const {
return m_addressW; }
1092 void setAddressW(AddressMode mode) { m_addressW = mode; }
1094 CompareOp textureCompareOp()
const {
return m_compareOp; }
1095 void setTextureCompareOp(CompareOp op) { m_compareOp = op; }
1097 virtual bool create() = 0;
1100 QRhiSampler(QRhiImplementation *rhi,
1101 Filter magFilter_, Filter minFilter_, Filter mipmapMode_,
1102 AddressMode u_, AddressMode v_, AddressMode w_);
1105 Filter m_mipmapMode;
1106 AddressMode m_addressU;
1107 AddressMode m_addressV;
1108 AddressMode m_addressW;
1109 CompareOp m_compareOp;
1121 UsedWithSwapChainOnly = 1 << 0
1123 Q_DECLARE_FLAGS(Flags, Flag)
1125 struct NativeRenderBuffer {
1129 QRhiResource::Type resourceType()
const override;
1131 Type type()
const {
return m_type; }
1132 void setType(Type t) { m_type = t; }
1134 QSize pixelSize()
const {
return m_pixelSize; }
1135 void setPixelSize(
const QSize &sz) { m_pixelSize = sz; }
1137 int sampleCount()
const {
return m_sampleCount; }
1138 void setSampleCount(
int s) { m_sampleCount = s; }
1140 Flags flags()
const {
return m_flags; }
1141 void setFlags(Flags f) { m_flags = f; }
1143 virtual bool create() = 0;
1144 virtual bool createFrom(NativeRenderBuffer src);
1146 virtual QRhiTexture::Format backingFormat()
const = 0;
1149 QRhiRenderBuffer(QRhiImplementation *rhi, Type type_,
const QSize &pixelSize_,
1150 int sampleCount_, Flags flags_, QRhiTexture::Format backingFormatHint_);
1155 QRhiTexture::Format m_backingFormatHint;
1158Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiRenderBuffer::Flags)
1160class Q_GUI_EXPORT QRhiShadingRateMap :
public QRhiResource
1163 struct NativeShadingRateMap {
1167 QRhiResource::Type resourceType()
const override;
1169 virtual bool createFrom(NativeShadingRateMap src);
1170 virtual bool createFrom(QRhiTexture *src);
1173 QRhiShadingRateMap(QRhiImplementation *rhi);
1179 QRhiResource::Type resourceType()
const override;
1181 virtual bool isCompatible(
const QRhiRenderPassDescriptor *other)
const = 0;
1182 virtual const QRhiNativeHandles *nativeHandles();
1184 virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor()
const = 0;
1186 virtual QVector<quint32> serializedFormat()
const = 0;
1189 QRhiRenderPassDescriptor(QRhiImplementation *rhi);
1195 virtual QSize pixelSize()
const = 0;
1196 virtual float devicePixelRatio()
const = 0;
1197 virtual int sampleCount()
const = 0;
1199 QRhiRenderPassDescriptor *renderPassDescriptor()
const {
return m_renderPassDesc; }
1200 void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
1203 QRhiRenderTarget(QRhiImplementation *rhi);
1204 QRhiRenderPassDescriptor *m_renderPassDesc =
nullptr;
1210 QRhiResource::Type resourceType()
const override;
1211 QRhiSwapChain *swapChain()
const {
return m_swapchain; }
1214 QRhiSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain_);
1215 QRhiSwapChain *m_swapchain;
1222 PreserveColorContents = 1 << 0,
1223 PreserveDepthStencilContents = 1 << 1,
1224 DoNotStoreDepthStencilContents = 1 << 2
1226 Q_DECLARE_FLAGS(Flags, Flag)
1228 QRhiResource::Type resourceType()
const override;
1230 QRhiTextureRenderTargetDescription description()
const {
return m_desc; }
1231 void setDescription(
const QRhiTextureRenderTargetDescription &desc) { m_desc = desc; }
1233 Flags flags()
const {
return m_flags; }
1234 void setFlags(Flags f) { m_flags = f; }
1236 virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() = 0;
1238 virtual bool create() = 0;
1241 QRhiTextureRenderTarget(QRhiImplementation *rhi,
const QRhiTextureRenderTargetDescription &desc_, Flags flags_);
1242 QRhiTextureRenderTargetDescription m_desc;
1246Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiTextureRenderTarget::Flags)
1248class Q_GUI_EXPORT QRhiShaderResourceBindings :
public QRhiResource
1251 QRhiResource::Type resourceType()
const override;
1253 void setBindings(std::initializer_list<QRhiShaderResourceBinding> list) { m_bindings = list; }
1254 template<
typename InputIterator>
1255 void setBindings(InputIterator first, InputIterator last)
1258 std::copy(first, last, std::back_inserter(m_bindings));
1260 const QRhiShaderResourceBinding *cbeginBindings()
const {
return m_bindings.cbegin(); }
1261 const QRhiShaderResourceBinding *cendBindings()
const {
return m_bindings.cend(); }
1262 const QRhiShaderResourceBinding *bindingAt(qsizetype index)
const {
return &m_bindings.at(index); }
1263 qsizetype bindingCount()
const {
return m_bindings.count(); }
1265 bool isLayoutCompatible(
const QRhiShaderResourceBindings *other)
const;
1267 QVector<quint32> serializedLayoutDescription()
const {
return m_layoutDesc; }
1269 virtual bool create() = 0;
1272 BindingsAreSorted = 0x01
1274 Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag)
1276 virtual void updateResources(UpdateFlags flags = {}) = 0;
1279 static constexpr int BINDING_PREALLOC = 12;
1280 QRhiShaderResourceBindings(QRhiImplementation *rhi);
1281 QVarLengthArray<QRhiShaderResourceBinding, BINDING_PREALLOC> m_bindings;
1282 size_t m_layoutDescHash = 0;
1286 QVector<quint32> m_layoutDesc;
1287 friend class QRhiImplementation;
1288#ifndef QT_NO_DEBUG_STREAM
1289 friend Q_GUI_EXPORT QDebug operator<<(QDebug,
const QRhiShaderResourceBindings &);
1293Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBindings::UpdateFlags)
1295#ifndef QT_NO_DEBUG_STREAM
1296Q_GUI_EXPORT QDebug operator<<(QDebug,
const QRhiShaderResourceBindings &);
1302using QRhiShaderResourceBindingSet = QRhiShaderResourceBindings;
1308 UsesBlendConstants = 1 << 0,
1309 UsesStencilRef = 1 << 1,
1310 UsesScissor = 1 << 2,
1311 CompileShadersWithDebugInfo = 1 << 3,
1312 UsesShadingRate = 1 << 4
1314 Q_DECLARE_FLAGS(Flags, Flag)
1337 enum ColorMaskComponent {
1343 Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)
1357 OneMinusConstantColor,
1359 OneMinusConstantAlpha,
1375 struct TargetBlend {
1376 ColorMask colorWrite = ColorMask(0xF);
1377 bool enable =
false;
1378 BlendFactor srcColor = One;
1379 BlendFactor dstColor = OneMinusSrcAlpha;
1380 BlendOp opColor = Add;
1381 BlendFactor srcAlpha = One;
1382 BlendFactor dstAlpha = OneMinusSrcAlpha;
1383 BlendOp opAlpha = Add;
1408 struct StencilOpState {
1409 StencilOp failOp = Keep;
1410 StencilOp depthFailOp = Keep;
1411 StencilOp passOp = Keep;
1412 CompareOp compareOp = Always;
1420 QRhiResource::Type resourceType()
const override;
1422 Flags flags()
const {
return m_flags; }
1423 void setFlags(Flags f) { m_flags = f; }
1425 Topology topology()
const {
return m_topology; }
1426 void setTopology(Topology t) { m_topology = t; }
1428 CullMode cullMode()
const {
return m_cullMode; }
1429 void setCullMode(CullMode mode) { m_cullMode = mode; }
1431 FrontFace frontFace()
const {
return m_frontFace; }
1432 void setFrontFace(FrontFace f) { m_frontFace = f; }
1434 void setTargetBlends(std::initializer_list<TargetBlend> list) { m_targetBlends = list; }
1435 template<
typename InputIterator>
1436 void setTargetBlends(InputIterator first, InputIterator last)
1438 m_targetBlends.clear();
1439 std::copy(first, last, std::back_inserter(m_targetBlends));
1441 const TargetBlend *cbeginTargetBlends()
const {
return m_targetBlends.cbegin(); }
1442 const TargetBlend *cendTargetBlends()
const {
return m_targetBlends.cend(); }
1443 const TargetBlend *targetBlendAt(qsizetype index)
const {
return &m_targetBlends.at(index); }
1444 qsizetype targetBlendCount()
const {
return m_targetBlends.count(); }
1446 bool hasDepthTest()
const {
return m_depthTest; }
1447 void setDepthTest(
bool enable) { m_depthTest = enable; }
1449 bool hasDepthWrite()
const {
return m_depthWrite; }
1450 void setDepthWrite(
bool enable) { m_depthWrite = enable; }
1452 CompareOp depthOp()
const {
return m_depthOp; }
1453 void setDepthOp(CompareOp op) { m_depthOp = op; }
1455 bool hasStencilTest()
const {
return m_stencilTest; }
1456 void setStencilTest(
bool enable) { m_stencilTest = enable; }
1458 StencilOpState stencilFront()
const {
return m_stencilFront; }
1459 void setStencilFront(
const StencilOpState &state) { m_stencilFront = state; }
1461 StencilOpState stencilBack()
const {
return m_stencilBack; }
1462 void setStencilBack(
const StencilOpState &state) { m_stencilBack = state; }
1464 quint32 stencilReadMask()
const {
return m_stencilReadMask; }
1465 void setStencilReadMask(quint32 mask) { m_stencilReadMask = mask; }
1467 quint32 stencilWriteMask()
const {
return m_stencilWriteMask; }
1468 void setStencilWriteMask(quint32 mask) { m_stencilWriteMask = mask; }
1470 int sampleCount()
const {
return m_sampleCount; }
1471 void setSampleCount(
int s) { m_sampleCount = s; }
1473 float lineWidth()
const {
return m_lineWidth; }
1474 void setLineWidth(
float width) { m_lineWidth = width; }
1476 int depthBias()
const {
return m_depthBias; }
1477 void setDepthBias(
int bias) { m_depthBias = bias; }
1479 float slopeScaledDepthBias()
const {
return m_slopeScaledDepthBias; }
1480 void setSlopeScaledDepthBias(
float bias) { m_slopeScaledDepthBias = bias; }
1482 void setShaderStages(std::initializer_list<QRhiShaderStage> list) { m_shaderStages = list; }
1483 template<
typename InputIterator>
1484 void setShaderStages(InputIterator first, InputIterator last)
1486 m_shaderStages.clear();
1487 std::copy(first, last, std::back_inserter(m_shaderStages));
1489 const QRhiShaderStage *cbeginShaderStages()
const {
return m_shaderStages.cbegin(); }
1490 const QRhiShaderStage *cendShaderStages()
const {
return m_shaderStages.cend(); }
1491 const QRhiShaderStage *shaderStageAt(qsizetype index)
const {
return &m_shaderStages.at(index); }
1492 qsizetype shaderStageCount()
const {
return m_shaderStages.count(); }
1494 QRhiVertexInputLayout vertexInputLayout()
const {
return m_vertexInputLayout; }
1495 void setVertexInputLayout(
const QRhiVertexInputLayout &layout) { m_vertexInputLayout = layout; }
1497 QRhiShaderResourceBindings *shaderResourceBindings()
const {
return m_shaderResourceBindings; }
1498 void setShaderResourceBindings(QRhiShaderResourceBindings *srb) { m_shaderResourceBindings = srb; }
1500 QRhiRenderPassDescriptor *renderPassDescriptor()
const {
return m_renderPassDesc; }
1501 void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
1503 int patchControlPointCount()
const {
return m_patchControlPointCount; }
1504 void setPatchControlPointCount(
int count) { m_patchControlPointCount = count; }
1506 PolygonMode polygonMode()
const {
return m_polygonMode; }
1507 void setPolygonMode(PolygonMode mode) {m_polygonMode = mode; }
1509 int multiViewCount()
const {
return m_multiViewCount; }
1510 void setMultiViewCount(
int count) { m_multiViewCount = count; }
1512 virtual bool create() = 0;
1515 QRhiGraphicsPipeline(QRhiImplementation *rhi);
1517 Topology m_topology = Triangles;
1518 CullMode m_cullMode = None;
1519 FrontFace m_frontFace = CCW;
1520 QVarLengthArray<TargetBlend, 8> m_targetBlends;
1521 bool m_depthTest =
false;
1522 bool m_depthWrite =
false;
1523 CompareOp m_depthOp = Less;
1524 bool m_stencilTest =
false;
1525 StencilOpState m_stencilFront;
1526 StencilOpState m_stencilBack;
1527 quint32 m_stencilReadMask = 0xFF;
1528 quint32 m_stencilWriteMask = 0xFF;
1529 int m_sampleCount = 1;
1530 float m_lineWidth = 1.0f;
1531 int m_depthBias = 0;
1532 float m_slopeScaledDepthBias = 0.0f;
1533 int m_patchControlPointCount = 3;
1534 PolygonMode m_polygonMode = Fill;
1535 int m_multiViewCount = 0;
1536 QVarLengthArray<QRhiShaderStage, 4> m_shaderStages;
1537 QRhiVertexInputLayout m_vertexInputLayout;
1538 QRhiShaderResourceBindings *m_shaderResourceBindings =
nullptr;
1539 QRhiRenderPassDescriptor *m_renderPassDesc =
nullptr;
1542Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::Flags)
1543Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::ColorMask)
1544Q_DECLARE_TYPEINFO(QRhiGraphicsPipeline::TargetBlend, Q_RELOCATABLE_TYPE);
1567 } colorComponentValue;
1575#ifndef QT_NO_DEBUG_STREAM
1576Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiSwapChainHdrInfo &);
1588 SurfaceHasPreMulAlpha = 1 << 0,
1589 SurfaceHasNonPreMulAlpha = 1 << 1,
1591 UsedAsTransferSource = 1 << 3,
1593 MinimalBufferCount = 1 << 5
1595 Q_DECLARE_FLAGS(Flags, Flag)
1599 HDRExtendedSrgbLinear,
1601 HDRExtendedDisplayP3Linear
1604 enum StereoTargetBuffer {
1609 QRhiResource::Type resourceType()
const override;
1611 QWindow *window()
const {
return m_window; }
1612 void setWindow(QWindow *window) { m_window = window; }
1614 QRhiSwapChainProxyData proxyData()
const {
return m_proxyData; }
1615 void setProxyData(
const QRhiSwapChainProxyData &d) { m_proxyData = d; }
1617 Flags flags()
const {
return m_flags; }
1618 void setFlags(Flags f) { m_flags = f; }
1620 Format format()
const {
return m_format; }
1621 void setFormat(Format f) { m_format = f; }
1623 QRhiRenderBuffer *depthStencil()
const {
return m_depthStencil; }
1624 void setDepthStencil(QRhiRenderBuffer *ds) { m_depthStencil = ds; }
1626 int sampleCount()
const {
return m_sampleCount; }
1627 void setSampleCount(
int samples) { m_sampleCount = samples; }
1629 QRhiRenderPassDescriptor *renderPassDescriptor()
const {
return m_renderPassDesc; }
1630 void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
1632 QRhiShadingRateMap *shadingRateMap()
const {
return m_shadingRateMap; }
1633 void setShadingRateMap(QRhiShadingRateMap *map) { m_shadingRateMap = map; }
1635 QSize currentPixelSize()
const {
return m_currentPixelSize; }
1637 virtual QRhiCommandBuffer *currentFrameCommandBuffer() = 0;
1638 virtual QRhiRenderTarget *currentFrameRenderTarget() = 0;
1639 virtual QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer);
1640 virtual QSize surfacePixelSize() = 0;
1641 virtual bool isFormatSupported(Format f) = 0;
1642 virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() = 0;
1643 virtual bool createOrResize() = 0;
1644 virtual QRhiSwapChainHdrInfo hdrInfo();
1647 QRhiSwapChain(QRhiImplementation *rhi);
1648 QWindow *m_window =
nullptr;
1650 Format m_format = SDR;
1651 QRhiRenderBuffer *m_depthStencil =
nullptr;
1652 int m_sampleCount = 1;
1653 QRhiRenderPassDescriptor *m_renderPassDesc =
nullptr;
1654 QSize m_currentPixelSize;
1655 QRhiSwapChainProxyData m_proxyData;
1656 QRhiShadingRateMap *m_shadingRateMap =
nullptr;
1659Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiSwapChain::Flags)
1661class Q_GUI_EXPORT QRhiComputePipeline :
public QRhiResource
1665 CompileShadersWithDebugInfo = 1 << 0
1667 Q_DECLARE_FLAGS(Flags, Flag)
1669 QRhiResource::Type resourceType()
const override;
1670 virtual bool create() = 0;
1672 Flags flags()
const {
return m_flags; }
1673 void setFlags(Flags f) { m_flags = f; }
1675 QRhiShaderStage shaderStage()
const {
return m_shaderStage; }
1676 void setShaderStage(
const QRhiShaderStage &stage) { m_shaderStage = stage; }
1678 QRhiShaderResourceBindings *shaderResourceBindings()
const {
return m_shaderResourceBindings; }
1679 void setShaderResourceBindings(QRhiShaderResourceBindings *srb) { m_shaderResourceBindings = srb; }
1682 QRhiComputePipeline(QRhiImplementation *rhi);
1684 QRhiShaderStage m_shaderStage;
1685 QRhiShaderResourceBindings *m_shaderResourceBindings =
nullptr;
1688Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiComputePipeline::Flags)
1690class Q_GUI_EXPORT QRhiCommandBuffer :
public QRhiResource
1698 enum BeginPassFlag {
1699 ExternalContent = 0x01,
1700 DoNotTrackResourcesForCompute = 0x02
1702 Q_DECLARE_FLAGS(BeginPassFlags, BeginPassFlag)
1704 QRhiResource::Type resourceType()
const override;
1706 void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates);
1708 void beginPass(QRhiRenderTarget *rt,
1709 const QColor &colorClearValue,
1710 const QRhiDepthStencilClearValue &depthStencilClearValue,
1711 QRhiResourceUpdateBatch *resourceUpdates =
nullptr,
1712 BeginPassFlags flags = {});
1713 void endPass(QRhiResourceUpdateBatch *resourceUpdates =
nullptr);
1715 void setGraphicsPipeline(QRhiGraphicsPipeline *ps);
1716 using DynamicOffset = std::pair<
int, quint32>;
1717 void setShaderResources(QRhiShaderResourceBindings *srb =
nullptr,
1718 int dynamicOffsetCount = 0,
1719 const DynamicOffset *dynamicOffsets =
nullptr);
1720 using VertexInput = std::pair<QRhiBuffer *, quint32>;
1721 void setVertexInput(
int startBinding,
int bindingCount,
const VertexInput *bindings,
1722 QRhiBuffer *indexBuf =
nullptr, quint32 indexOffset = 0,
1723 IndexFormat indexFormat = IndexUInt16);
1725 void setViewport(
const QRhiViewport &viewport);
1726 void setScissor(
const QRhiScissor &scissor);
1727 void setBlendConstants(
const QColor &c);
1728 void setStencilRef(quint32 refValue);
1729 void setShadingRate(
const QSize &coarsePixelSize);
1731 void draw(quint32 vertexCount,
1732 quint32 instanceCount = 1,
1733 quint32 firstVertex = 0,
1734 quint32 firstInstance = 0);
1736 void drawIndexed(quint32 indexCount,
1737 quint32 instanceCount = 1,
1738 quint32 firstIndex = 0,
1739 qint32 vertexOffset = 0,
1740 quint32 firstInstance = 0);
1742 void debugMarkBegin(
const QByteArray &name);
1743 void debugMarkEnd();
1744 void debugMarkMsg(
const QByteArray &msg);
1746 void beginComputePass(QRhiResourceUpdateBatch *resourceUpdates =
nullptr, BeginPassFlags flags = {});
1747 void endComputePass(QRhiResourceUpdateBatch *resourceUpdates =
nullptr);
1748 void setComputePipeline(QRhiComputePipeline *ps);
1749 void dispatch(
int x,
int y,
int z);
1751 const QRhiNativeHandles *nativeHandles();
1752 void beginExternal();
1755 double lastCompletedGpuTime();
1758 QRhiCommandBuffer(QRhiImplementation *rhi);
1761Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiCommandBuffer::BeginPassFlags)
1763struct Q_GUI_EXPORT QRhiReadbackResult
1765 std::function<
void()> completed =
nullptr;
1766 QRhiTexture::Format format;
1774 ~QRhiResourceUpdateBatch();
1778 void merge(QRhiResourceUpdateBatch *other);
1779 bool hasOptimalCapacity()
const;
1781 void updateDynamicBuffer(QRhiBuffer *buf, quint32 offset, quint32 size,
const void *data);
1782 void updateDynamicBuffer(QRhiBuffer *buf, quint32 offset, QByteArray data);
1783 void uploadStaticBuffer(QRhiBuffer *buf, quint32 offset, quint32 size,
const void *data);
1784 void uploadStaticBuffer(QRhiBuffer *buf, quint32 offset, QByteArray data);
1785 void uploadStaticBuffer(QRhiBuffer *buf,
const void *data);
1786 void uploadStaticBuffer(QRhiBuffer *buf, QByteArray data);
1787 void readBackBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result);
1788 void uploadTexture(QRhiTexture *tex,
const QRhiTextureUploadDescription &desc);
1789 void uploadTexture(QRhiTexture *tex,
const QImage &image);
1790 void copyTexture(QRhiTexture *dst, QRhiTexture *src,
const QRhiTextureCopyDescription &desc = QRhiTextureCopyDescription());
1791 void readBackTexture(
const QRhiReadbackDescription &rb, QRhiReadbackResult *result);
1792 void generateMips(QRhiTexture *tex);
1795 QRhiResourceUpdateBatch(QRhiImplementation *rhi);
1796 Q_DISABLE_COPY(QRhiResourceUpdateBatch)
1797 QRhiResourceUpdateBatchPrivate *d;
1798 friend class QRhiResourceUpdateBatchPrivate;
1813 QByteArray deviceName;
1814 quint64 deviceId = 0;
1815 quint64 vendorId = 0;
1816 DeviceType deviceType = UnknownDevice;
1821#ifndef QT_NO_DEBUG_STREAM
1822Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiDriverInfo &);
1827 qint64 totalPipelineCreationTime = 0;
1829 quint32 blockCount = 0;
1830 quint32 allocCount = 0;
1831 quint64 usedBytes = 0;
1832 quint64 unusedBytes = 0;
1834 quint64 totalUsageBytes = 0;
1839#ifndef QT_NO_DEBUG_STREAM
1840Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiStats &);
1846 virtual ~QRhiAdapter();
1847 virtual QRhiDriverInfo info()
const = 0;
1857 enum Implementation {
1867 EnableDebugMarkers = 1 << 0,
1868 PreferSoftwareRenderer = 1 << 1,
1869 EnablePipelineCacheDataSave = 1 << 2,
1870 EnableTimestamps = 1 << 3,
1871 SuppressSmokeTestWarnings = 1 << 4
1873 Q_DECLARE_FLAGS(Flags, Flag)
1875 enum FrameOpResult {
1878 FrameOpSwapChainOutOfDate,
1883 MultisampleTexture = 1,
1884 MultisampleRenderBuffer,
1888 CustomInstanceStepRate,
1890 NonDynamicUniformBuffers,
1891 NonFourAlignedEffectiveIndexBufferOffset,
1897 VertexShaderPointSize,
1900 TriangleFanTopology,
1901 ReadBackNonUniformBuffer,
1902 ReadBackNonBaseMipLevel,
1904 RenderToNonBaseMipLevel,
1906 ScreenSpaceDerivatives,
1907 ReadBackAnyTextureFormat,
1908 PipelineCacheDataLoadSave,
1911 ThreeDimensionalTextures,
1912 RenderTo3DTextureSlice,
1918 OneDimensionalTextures,
1919 OneDimensionalTextureMipmaps,
1921 RenderToOneDimensionalTexture,
1922 ThreeDimensionalTextureMipmaps,
1925 ResolveDepthStencil,
1926 VariableRateShading,
1927 VariableRateShadingMap,
1928 VariableRateShadingMapWithTexture,
1929 PerRenderTargetBlending,
1932 enum BeginFrameFlag {
1934 Q_DECLARE_FLAGS(BeginFrameFlags, BeginFrameFlag)
1937 SkipPresent = 1 << 0
1939 Q_DECLARE_FLAGS(EndFrameFlags, EndFrameFlag)
1941 enum ResourceLimit {
1944 MaxColorAttachments,
1946 MaxAsyncReadbackFrames,
1947 MaxThreadGroupsPerDimension,
1948 MaxThreadsPerThreadGroup,
1952 TextureArraySizeMax,
1953 MaxUniformBufferRange,
1956 ShadingRateImageTileSize
1961 static QRhi *create(Implementation impl,
1962 QRhiInitParams *params,
1964 QRhiNativeHandles *importDevice =
nullptr,
1965 QRhiAdapter *adapter =
nullptr);
1966 static bool probe(Implementation impl, QRhiInitParams *params);
1967 using AdapterList = QVector<QRhiAdapter *>;
1968 static AdapterList enumerateAdapters(Implementation impl,
1969 QRhiInitParams *params,
1970 QRhiNativeHandles *nativeHandles =
nullptr);
1972 Implementation backend()
const;
1973 const char *backendName()
const;
1974 static const char *backendName(Implementation impl);
1975 QRhiDriverInfo driverInfo()
const;
1976 QThread *thread()
const;
1978 using CleanupCallback = std::function<
void(QRhi *)>;
1979 void addCleanupCallback(
const CleanupCallback &callback);
1980 void addCleanupCallback(
const void *key,
const CleanupCallback &callback);
1981 void removeCleanupCallback(
const void *key);
1984 QRhiGraphicsPipeline *newGraphicsPipeline();
1985 QRhiComputePipeline *newComputePipeline();
1986 QRhiShaderResourceBindings *newShaderResourceBindings();
1988 QRhiBuffer *newBuffer(QRhiBuffer::Type type,
1989 QRhiBuffer::UsageFlags usage,
1992 QRhiRenderBuffer *newRenderBuffer(QRhiRenderBuffer::Type type,
1993 const QSize &pixelSize,
1994 int sampleCount = 1,
1995 QRhiRenderBuffer::Flags flags = {},
1996 QRhiTexture::Format backingFormatHint = QRhiTexture::UnknownFormat);
1998 QRhiTexture *newTexture(QRhiTexture::Format format,
1999 const QSize &pixelSize,
2000 int sampleCount = 1,
2001 QRhiTexture::Flags flags = {});
2003 QRhiTexture *newTexture(QRhiTexture::Format format,
2004 int width,
int height,
int depth,
2005 int sampleCount = 1,
2006 QRhiTexture::Flags flags = {});
2008 QRhiTexture *newTextureArray(QRhiTexture::Format format,
2010 const QSize &pixelSize,
2011 int sampleCount = 1,
2012 QRhiTexture::Flags flags = {});
2014 QRhiSampler *newSampler(QRhiSampler::Filter magFilter,
2015 QRhiSampler::Filter minFilter,
2016 QRhiSampler::Filter mipmapMode,
2017 QRhiSampler::AddressMode addressU,
2018 QRhiSampler::AddressMode addressV,
2019 QRhiSampler::AddressMode addressW = QRhiSampler::Repeat);
2021 QRhiShadingRateMap *newShadingRateMap();
2023 QRhiTextureRenderTarget *newTextureRenderTarget(
const QRhiTextureRenderTargetDescription &desc,
2024 QRhiTextureRenderTarget::Flags flags = {});
2026 QRhiSwapChain *newSwapChain();
2027 FrameOpResult beginFrame(QRhiSwapChain *swapChain, BeginFrameFlags flags = {});
2028 FrameOpResult endFrame(QRhiSwapChain *swapChain, EndFrameFlags flags = {});
2029 bool isRecordingFrame()
const;
2030 int currentFrameSlot()
const;
2032 FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags = {});
2033 FrameOpResult endOffscreenFrame(EndFrameFlags flags = {});
2035 QRhi::FrameOpResult finish();
2037 QRhiResourceUpdateBatch *nextResourceUpdateBatch();
2039 QList<
int> supportedSampleCounts()
const;
2041 int ubufAlignment()
const;
2042 int ubufAligned(
int v)
const;
2044 static int mipLevelsForSize(
const QSize &size);
2045 static QSize sizeForMipLevel(
int mipLevel,
const QSize &baseLevelSize);
2047 bool isYUpInFramebuffer()
const;
2048 bool isYUpInNDC()
const;
2049 bool isClipDepthZeroToOne()
const;
2051 QMatrix4x4 clipSpaceCorrMatrix()
const;
2053 bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags = {})
const;
2054 bool isFeatureSupported(QRhi::Feature feature)
const;
2055 int resourceLimit(ResourceLimit limit)
const;
2057 const QRhiNativeHandles *nativeHandles();
2058 bool makeThreadLocalNativeContextCurrent();
2059 void setQueueSubmitParams(QRhiNativeHandles *params);
2061 static constexpr int MAX_MIP_LEVELS = 16;
2063 void releaseCachedResources();
2065 bool isDeviceLost()
const;
2067 QByteArray pipelineCacheData();
2068 void setPipelineCacheData(
const QByteArray &data);
2070 QRhiStats statistics()
const;
2072 static QRhiSwapChainProxyData updateSwapChainProxyData(Implementation impl, QWindow *window);
2074 QList<QSize> supportedShadingRates(
int sampleCount)
const;
2080 Q_DISABLE_COPY(QRhi)
2081 QRhiImplementation *d =
nullptr;
2084Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::Flags)
2085Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::BeginFrameFlags)
2086Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::EndFrameFlags)
2090#include <rhi/qrhi_platform.h>
int main(int argc, char *argv[])
[2]
friend bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are equal, otherwise returns false.
friend bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are different, otherwise returns false.
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Combined button and popup list for selecting options.
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Q_DECLARE_TYPEINFO(QRhiSwapChainHdrInfo, Q_RELOCATABLE_TYPE)
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\variable QRhiReadbackResult::completed
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
LuminanceBehavior
\value SceneReferred Indicates that the color value of 1.0 is interpreted as 80 nits.
float maxPotentialColorComponentValue
LimitsType
\value LuminanceInNits Indicates that the \l limits union has its luminanceInNits struct set
LuminanceBehavior luminanceBehavior
float maxColorComponentValue
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h