17#include <QtGui/qtguiglobal.h>
18#include <QtCore/qsize.h>
19#include <QtCore/qlist.h>
20#include <QtCore/qvarlengtharray.h>
21#include <QtCore/qthread.h>
22#include <QtGui/qmatrix4x4.h>
23#include <QtGui/qcolor.h>
24#include <QtGui/qimage.h>
28#include <rhi/qshader.h>
34class QRhiImplementation;
36class QRhiRenderBuffer;
39class QRhiCommandBuffer;
40class QRhiResourceUpdateBatch;
43class QRhiShadingRateMap;
48 QRhiDepthStencilClearValue() =
default;
49 QRhiDepthStencilClearValue(
float d, quint32 s);
51 float depthClearValue()
const {
return m_d; }
52 void setDepthClearValue(
float d) { m_d = d; }
54 quint32 stencilClearValue()
const {
return m_s; }
55 void setStencilClearValue(quint32 s) { m_s = s; }
61 friend bool operator==(
const QRhiDepthStencilClearValue &a,
const QRhiDepthStencilClearValue &b)
noexcept
63 return a.m_d == b.m_d && a.m_s == b.m_s;
66 friend bool operator!=(
const QRhiDepthStencilClearValue &a,
const QRhiDepthStencilClearValue &b)
noexcept
71 friend size_t qHash(
const QRhiDepthStencilClearValue &v, size_t seed = 0)
noexcept
73 QtPrivate::QHashCombine hash(seed);
74 seed = hash(seed, v.m_d);
75 seed = hash(seed, v.m_s);
82#ifndef QT_NO_DEBUG_STREAM
83Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiDepthStencilClearValue &);
89 QRhiViewport() =
default;
90 QRhiViewport(
float x,
float y,
float w,
float h,
float minDepth = 0.0f,
float maxDepth = 1.0f);
92 std::array<
float, 4> viewport()
const {
return m_rect; }
93 void setViewport(
float x,
float y,
float w,
float h) {
94 m_rect[0] = x; m_rect[1] = y; m_rect[2] = w; m_rect[3] = h;
97 float minDepth()
const {
return m_minDepth; }
98 void setMinDepth(
float minDepth) { m_minDepth = minDepth; }
100 float maxDepth()
const {
return m_maxDepth; }
101 void setMaxDepth(
float maxDepth) { m_maxDepth = maxDepth; }
104 std::array<
float, 4> m_rect { { 0.0f, 0.0f, 0.0f, 0.0f } };
105 float m_minDepth = 0.0f;
106 float m_maxDepth = 1.0f;
108 friend bool operator==(
const QRhiViewport &a,
const QRhiViewport &b)
noexcept
110 return a.m_rect == b.m_rect
111 && a.m_minDepth == b.m_minDepth
112 && a.m_maxDepth == b.m_maxDepth;
115 friend bool operator!=(
const QRhiViewport &a,
const QRhiViewport &b)
noexcept
120 friend size_t qHash(
const QRhiViewport &v, size_t seed = 0)
noexcept
122 QtPrivate::QHashCombine hash(seed);
123 seed = hash(seed, v.m_rect[0]);
124 seed = hash(seed, v.m_rect[1]);
125 seed = hash(seed, v.m_rect[2]);
126 seed = hash(seed, v.m_rect[3]);
127 seed = hash(seed, v.m_minDepth);
128 seed = hash(seed, v.m_maxDepth);
135#ifndef QT_NO_DEBUG_STREAM
136Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiViewport &);
142 QRhiScissor() =
default;
143 QRhiScissor(
int x,
int y,
int w,
int h);
145 std::array<
int, 4> scissor()
const {
return m_rect; }
146 void setScissor(
int x,
int y,
int w,
int h) {
147 m_rect[0] = x; m_rect[1] = y; m_rect[2] = w; m_rect[3] = h;
151 std::array<
int, 4> m_rect { { 0, 0, 0, 0 } };
153 friend bool operator==(
const QRhiScissor &a,
const QRhiScissor &b)
noexcept
155 return a.m_rect == b.m_rect;
158 friend bool operator!=(
const QRhiScissor &a,
const QRhiScissor &b)
noexcept
163 friend size_t qHash(
const QRhiScissor &v, size_t seed = 0)
noexcept
165 QtPrivate::QHashCombine hash(seed);
166 seed = hash(seed, v.m_rect[0]);
167 seed = hash(seed, v.m_rect[1]);
168 seed = hash(seed, v.m_rect[2]);
169 seed = hash(seed, v.m_rect[3]);
176#ifndef QT_NO_DEBUG_STREAM
177Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiScissor &);
183 enum Classification {
188 QRhiVertexInputBinding() =
default;
189 QRhiVertexInputBinding(quint32 stride, Classification cls = PerVertex, quint32 stepRate = 1);
191 quint32 stride()
const {
return m_stride; }
192 void setStride(quint32 s) { m_stride = s; }
194 Classification classification()
const {
return m_classification; }
195 void setClassification(Classification c) { m_classification = c; }
197 quint32 instanceStepRate()
const {
return m_instanceStepRate; }
198 void setInstanceStepRate(quint32 rate) { m_instanceStepRate = rate; }
201 quint32 m_stride = 0;
202 Classification m_classification = PerVertex;
203 quint32 m_instanceStepRate = 1;
205 friend bool operator==(
const QRhiVertexInputBinding &a,
const QRhiVertexInputBinding &b)
noexcept
207 return a.m_stride == b.m_stride
208 && a.m_classification == b.m_classification
209 && a.m_instanceStepRate == b.m_instanceStepRate;
212 friend bool operator!=(
const QRhiVertexInputBinding &a,
const QRhiVertexInputBinding &b)
noexcept
217 friend size_t qHash(
const QRhiVertexInputBinding &v, size_t seed = 0)
noexcept
219 QtPrivate::QHashCombine hash(seed);
220 seed = hash(seed, v.m_stride);
221 seed = hash(seed, v.m_classification);
222 seed = hash(seed, v.m_instanceStepRate);
229#ifndef QT_NO_DEBUG_STREAM
230Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiVertexInputBinding &);
266 QRhiVertexInputAttribute() =
default;
267 QRhiVertexInputAttribute(
int binding,
int location, Format format, quint32 offset,
int matrixSlice = -1);
269 int binding()
const {
return m_binding; }
270 void setBinding(
int b) { m_binding = b; }
272 int location()
const {
return m_location; }
273 void setLocation(
int loc) { m_location = loc; }
275 Format format()
const {
return m_format; }
276 void setFormat(Format f) { m_format = f; }
278 quint32 offset()
const {
return m_offset; }
279 void setOffset(quint32 ofs) { m_offset = ofs; }
281 int matrixSlice()
const {
return m_matrixSlice; }
282 void setMatrixSlice(
int slice) { m_matrixSlice = slice; }
287 Format m_format = Float4;
288 quint32 m_offset = 0;
289 int m_matrixSlice = -1;
291 friend bool operator==(
const QRhiVertexInputAttribute &a,
const QRhiVertexInputAttribute &b)
noexcept
293 return a.m_binding == b.m_binding
294 && a.m_location == b.m_location
295 && a.m_format == b.m_format
296 && a.m_offset == b.m_offset;
300 friend bool operator!=(
const QRhiVertexInputAttribute &a,
const QRhiVertexInputAttribute &b)
noexcept
305 friend size_t qHash(
const QRhiVertexInputAttribute &v, size_t seed = 0)
noexcept
307 QtPrivate::QHashCombine hash(seed);
308 seed = hash(seed, v.m_binding);
309 seed = hash(seed, v.m_location);
310 seed = hash(seed, v.m_format);
311 seed = hash(seed, v.m_offset);
318#ifndef QT_NO_DEBUG_STREAM
319Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiVertexInputAttribute &);
325 QRhiVertexInputLayout() =
default;
327 void setBindings(std::initializer_list<QRhiVertexInputBinding> list) { m_bindings = list; }
328 template<
typename InputIterator>
329 void setBindings(InputIterator first, InputIterator last)
332 std::copy(first, last, std::back_inserter(m_bindings));
334 const QRhiVertexInputBinding *cbeginBindings()
const {
return m_bindings.cbegin(); }
335 const QRhiVertexInputBinding *cendBindings()
const {
return m_bindings.cend(); }
336 const QRhiVertexInputBinding *bindingAt(qsizetype index)
const {
return &m_bindings.at(index); }
337 qsizetype bindingCount()
const {
return m_bindings.count(); }
339 void setAttributes(std::initializer_list<QRhiVertexInputAttribute> list) { m_attributes = list; }
340 template<
typename InputIterator>
341 void setAttributes(InputIterator first, InputIterator last)
343 m_attributes.clear();
344 std::copy(first, last, std::back_inserter(m_attributes));
346 const QRhiVertexInputAttribute *cbeginAttributes()
const {
return m_attributes.cbegin(); }
347 const QRhiVertexInputAttribute *cendAttributes()
const {
return m_attributes.cend(); }
348 const QRhiVertexInputAttribute *attributeAt(qsizetype index)
const {
return &m_attributes.at(index); }
349 qsizetype attributeCount()
const {
return m_attributes.count(); }
352 QVarLengthArray<QRhiVertexInputBinding, 8> m_bindings;
353 QVarLengthArray<QRhiVertexInputAttribute, 8> m_attributes;
355 friend bool operator==(
const QRhiVertexInputLayout &a,
const QRhiVertexInputLayout &b)
noexcept
357 return a.m_bindings == b.m_bindings && a.m_attributes == b.m_attributes;
360 friend bool operator!=(
const QRhiVertexInputLayout &a,
const QRhiVertexInputLayout &b)
noexcept
365 friend size_t qHash(
const QRhiVertexInputLayout &v, size_t seed = 0)
noexcept
367 QtPrivate::QHashCombine hash(seed);
368 seed = hash(seed, v.m_bindings);
369 seed = hash(seed, v.m_attributes);
373 friend Q_GUI_EXPORT QDebug operator<<(QDebug,
const QRhiVertexInputLayout &);
376#ifndef QT_NO_DEBUG_STREAM
377Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiVertexInputLayout &);
386 TessellationEvaluation,
392 QRhiShaderStage() =
default;
393 QRhiShaderStage(Type type,
const QShader &shader,
394 QShader::Variant v = QShader::StandardShader);
396 Type type()
const {
return m_type; }
397 void setType(Type t) { m_type = t; }
399 QShader shader()
const {
return m_shader; }
400 void setShader(
const QShader &s) { m_shader = s; }
402 QShader::Variant shaderVariant()
const {
return m_shaderVariant; }
403 void setShaderVariant(QShader::Variant v) { m_shaderVariant = v; }
406 Type m_type = Vertex;
408 QShader::Variant m_shaderVariant = QShader::StandardShader;
410 friend bool operator==(
const QRhiShaderStage &a,
const QRhiShaderStage &b)
noexcept
412 return a.m_type == b.m_type
413 && a.m_shader == b.m_shader
414 && a.m_shaderVariant == b.m_shaderVariant;
417 friend bool operator!=(
const QRhiShaderStage &a,
const QRhiShaderStage &b)
noexcept
422 friend size_t qHash(
const QRhiShaderStage &v, size_t seed = 0)
noexcept
424 QtPrivate::QHashCombine hash(seed);
425 seed = hash(seed, v.m_type);
426 seed = hash(seed, v.m_shader);
427 seed = hash(seed, v.m_shaderVariant);
434#ifndef QT_NO_DEBUG_STREAM
435Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiShaderStage &);
438using QRhiGraphicsShaderStage = QRhiShaderStage;
457 VertexStage = 1 << 0,
458 TessellationControlStage = 1 << 1,
459 TessellationEvaluationStage = 1 << 2,
460 GeometryStage = 1 << 3,
461 FragmentStage = 1 << 4,
462 ComputeStage = 1 << 5
464 Q_DECLARE_FLAGS(StageFlags, StageFlag)
466 QRhiShaderResourceBinding() =
default;
468 bool isLayoutCompatible(
const QRhiShaderResourceBinding &other)
const;
470 static QRhiShaderResourceBinding uniformBuffer(
int binding, StageFlags stage, QRhiBuffer *buf);
471 static QRhiShaderResourceBinding uniformBuffer(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
472 static QRhiShaderResourceBinding uniformBufferWithDynamicOffset(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 size);
474 static QRhiShaderResourceBinding sampledTexture(
int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler);
476 struct TextureAndSampler {
478 QRhiSampler *sampler;
480 static QRhiShaderResourceBinding sampledTextures(
int binding, StageFlags stage,
int count,
const TextureAndSampler *texSamplers);
482 static QRhiShaderResourceBinding texture(
int binding, StageFlags stage, QRhiTexture *tex);
483 static QRhiShaderResourceBinding textures(
int binding, StageFlags stage,
int count, QRhiTexture **tex);
484 static QRhiShaderResourceBinding sampler(
int binding, StageFlags stage, QRhiSampler *sampler);
486 static QRhiShaderResourceBinding imageLoad(
int binding, StageFlags stage, QRhiTexture *tex,
int level);
487 static QRhiShaderResourceBinding imageStore(
int binding, StageFlags stage, QRhiTexture *tex,
int level);
488 static QRhiShaderResourceBinding imageLoadStore(
int binding, StageFlags stage, QRhiTexture *tex,
int level);
490 static QRhiShaderResourceBinding bufferLoad(
int binding, StageFlags stage, QRhiBuffer *buf);
491 static QRhiShaderResourceBinding bufferLoad(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
492 static QRhiShaderResourceBinding bufferStore(
int binding, StageFlags stage, QRhiBuffer *buf);
493 static QRhiShaderResourceBinding bufferStore(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
494 static QRhiShaderResourceBinding bufferLoadStore(
int binding, StageFlags stage, QRhiBuffer *buf);
495 static QRhiShaderResourceBinding bufferLoadStore(
int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size);
500 QRhiShaderResourceBinding::StageFlags stage;
501 QRhiShaderResourceBinding::Type type;
502 struct UniformBufferData {
506 bool hasDynamicOffset;
508 static constexpr int MAX_TEX_SAMPLER_ARRAY_SIZE = 16;
509 struct TextureAndOrSamplerData {
511 TextureAndSampler texSamplers[MAX_TEX_SAMPLER_ARRAY_SIZE];
513 struct StorageImageData {
517 struct StorageBufferData {
523 UniformBufferData ubuf;
524 TextureAndOrSamplerData stex;
525 StorageImageData simage;
526 StorageBufferData sbuf;
529 int arraySize()
const
531 return type == QRhiShaderResourceBinding::SampledTexture || type == QRhiShaderResourceBinding::Texture
536 template<
typename Output>
537 Output serialize(Output dst)
const
540 *dst++ = quint32(binding);
541 *dst++ = quint32(stage);
542 *dst++ = quint32(type);
543 *dst++ = quint32(arraySize());
548 static constexpr int LAYOUT_DESC_ENTRIES_PER_BINDING = 4;
550 template<
typename Output>
551 static void serializeLayoutDescription(
const QRhiShaderResourceBinding *first,
552 const QRhiShaderResourceBinding *last,
555 while (first != last) {
556 dst = first->d.serialize(dst);
563 friend class QRhiImplementation;
566Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBinding::StageFlags)
568Q_DECLARE_TYPEINFO(QRhiShaderResourceBinding, Q_PRIMITIVE_TYPE);
570Q_GUI_EXPORT
bool operator==(
const QRhiShaderResourceBinding &a,
const QRhiShaderResourceBinding &b)
noexcept;
571Q_GUI_EXPORT
bool operator!=(
const QRhiShaderResourceBinding &a,
const QRhiShaderResourceBinding &b)
noexcept;
572Q_GUI_EXPORT size_t qHash(
const QRhiShaderResourceBinding &b, size_t seed = 0)
noexcept;
573#ifndef QT_NO_DEBUG_STREAM
574Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiShaderResourceBinding &);
580 QRhiColorAttachment() =
default;
581 QRhiColorAttachment(QRhiTexture *texture);
582 QRhiColorAttachment(QRhiRenderBuffer *renderBuffer);
584 QRhiTexture *texture()
const {
return m_texture; }
585 void setTexture(QRhiTexture *tex) { m_texture = tex; }
587 QRhiRenderBuffer *renderBuffer()
const {
return m_renderBuffer; }
588 void setRenderBuffer(QRhiRenderBuffer *rb) { m_renderBuffer = rb; }
590 int layer()
const {
return m_layer; }
591 void setLayer(
int layer) { m_layer = layer; }
593 int level()
const {
return m_level; }
594 void setLevel(
int level) { m_level = level; }
596 QRhiTexture *resolveTexture()
const {
return m_resolveTexture; }
597 void setResolveTexture(QRhiTexture *tex) { m_resolveTexture = tex; }
599 int resolveLayer()
const {
return m_resolveLayer; }
600 void setResolveLayer(
int layer) { m_resolveLayer = layer; }
602 int resolveLevel()
const {
return m_resolveLevel; }
603 void setResolveLevel(
int level) { m_resolveLevel = level; }
605 int multiViewCount()
const {
return m_multiViewCount; }
606 void setMultiViewCount(
int count) { m_multiViewCount = count; }
609 QRhiTexture *m_texture =
nullptr;
610 QRhiRenderBuffer *m_renderBuffer =
nullptr;
613 QRhiTexture *m_resolveTexture =
nullptr;
614 int m_resolveLayer = 0;
615 int m_resolveLevel = 0;
616 int m_multiViewCount = 0;
624 QRhiTextureRenderTargetDescription() =
default;
625 QRhiTextureRenderTargetDescription(
const QRhiColorAttachment &colorAttachment);
626 QRhiTextureRenderTargetDescription(
const QRhiColorAttachment &colorAttachment, QRhiRenderBuffer *depthStencilBuffer);
627 QRhiTextureRenderTargetDescription(
const QRhiColorAttachment &colorAttachment, QRhiTexture *depthTexture);
629 void setColorAttachments(std::initializer_list<QRhiColorAttachment> list) { m_colorAttachments = list; }
630 template<
typename InputIterator>
631 void setColorAttachments(InputIterator first, InputIterator last)
633 m_colorAttachments.clear();
634 std::copy(first, last, std::back_inserter(m_colorAttachments));
636 const QRhiColorAttachment *cbeginColorAttachments()
const {
return m_colorAttachments.cbegin(); }
637 const QRhiColorAttachment *cendColorAttachments()
const {
return m_colorAttachments.cend(); }
638 const QRhiColorAttachment *colorAttachmentAt(qsizetype index)
const {
return &m_colorAttachments.at(index); }
639 qsizetype colorAttachmentCount()
const {
return m_colorAttachments.count(); }
641 QRhiRenderBuffer *depthStencilBuffer()
const {
return m_depthStencilBuffer; }
642 void setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer) { m_depthStencilBuffer = renderBuffer; }
644 QRhiTexture *depthTexture()
const {
return m_depthTexture; }
645 void setDepthTexture(QRhiTexture *texture) { m_depthTexture = texture; }
647 QRhiTexture *depthResolveTexture()
const {
return m_depthResolveTexture; }
648 void setDepthResolveTexture(QRhiTexture *tex) { m_depthResolveTexture = tex; }
650 QRhiShadingRateMap *shadingRateMap()
const {
return m_shadingRateMap; }
651 void setShadingRateMap(QRhiShadingRateMap *map) { m_shadingRateMap = map; }
654 QVarLengthArray<QRhiColorAttachment, 8> m_colorAttachments;
655 QRhiRenderBuffer *m_depthStencilBuffer =
nullptr;
656 QRhiTexture *m_depthTexture =
nullptr;
657 QRhiTexture *m_depthResolveTexture =
nullptr;
658 QRhiShadingRateMap *m_shadingRateMap =
nullptr;
664 QRhiTextureSubresourceUploadDescription() =
default;
665 explicit QRhiTextureSubresourceUploadDescription(
const QImage &image);
666 QRhiTextureSubresourceUploadDescription(
const void *data, quint32 size);
667 explicit QRhiTextureSubresourceUploadDescription(
const QByteArray &data);
669 QImage image()
const {
return m_image; }
670 void setImage(
const QImage &image) { m_image = image; }
672 QByteArray data()
const {
return m_data; }
673 void setData(
const QByteArray &data) { m_data = data; }
675 quint32 dataStride()
const {
return m_dataStride; }
676 void setDataStride(quint32 stride) { m_dataStride = stride; }
678 QPoint destinationTopLeft()
const {
return m_destinationTopLeft; }
679 void setDestinationTopLeft(
const QPoint &p) { m_destinationTopLeft = p; }
681 QSize sourceSize()
const {
return m_sourceSize; }
682 void setSourceSize(
const QSize &size) { m_sourceSize = size; }
684 QPoint sourceTopLeft()
const {
return m_sourceTopLeft; }
685 void setSourceTopLeft(
const QPoint &p) { m_sourceTopLeft = p; }
690 quint32 m_dataStride = 0;
691 QPoint m_destinationTopLeft;
693 QPoint m_sourceTopLeft;
701 QRhiTextureUploadEntry() =
default;
702 QRhiTextureUploadEntry(
int layer,
int level,
const QRhiTextureSubresourceUploadDescription &desc);
704 int layer()
const {
return m_layer; }
705 void setLayer(
int layer) { m_layer = layer; }
707 int level()
const {
return m_level; }
708 void setLevel(
int level) { m_level = level; }
710 QRhiTextureSubresourceUploadDescription description()
const {
return m_desc; }
711 void setDescription(
const QRhiTextureSubresourceUploadDescription &desc) { m_desc = desc; }
716 QRhiTextureSubresourceUploadDescription m_desc;
724 QRhiTextureUploadDescription() =
default;
725 QRhiTextureUploadDescription(
const QRhiTextureUploadEntry &entry);
726 QRhiTextureUploadDescription(std::initializer_list<QRhiTextureUploadEntry> list);
728 void setEntries(std::initializer_list<QRhiTextureUploadEntry> list) { m_entries = list; }
729 template<
typename InputIterator>
730 void setEntries(InputIterator first, InputIterator last)
733 std::copy(first, last, std::back_inserter(m_entries));
735 const QRhiTextureUploadEntry *cbeginEntries()
const {
return m_entries.cbegin(); }
736 const QRhiTextureUploadEntry *cendEntries()
const {
return m_entries.cend(); }
737 const QRhiTextureUploadEntry *entryAt(qsizetype index)
const {
return &m_entries.at(index); }
738 qsizetype entryCount()
const {
return m_entries.count(); }
741 QVarLengthArray<QRhiTextureUploadEntry, 16> m_entries;
747 QRhiTextureCopyDescription() =
default;
749 QSize pixelSize()
const {
return m_pixelSize; }
750 void setPixelSize(
const QSize &sz) { m_pixelSize = sz; }
752 int sourceLayer()
const {
return m_sourceLayer; }
753 void setSourceLayer(
int layer) { m_sourceLayer = layer; }
755 int sourceLevel()
const {
return m_sourceLevel; }
756 void setSourceLevel(
int level) { m_sourceLevel = level; }
758 QPoint sourceTopLeft()
const {
return m_sourceTopLeft; }
759 void setSourceTopLeft(
const QPoint &p) { m_sourceTopLeft = p; }
761 int destinationLayer()
const {
return m_destinationLayer; }
762 void setDestinationLayer(
int layer) { m_destinationLayer = layer; }
764 int destinationLevel()
const {
return m_destinationLevel; }
765 void setDestinationLevel(
int level) { m_destinationLevel = level; }
767 QPoint destinationTopLeft()
const {
return m_destinationTopLeft; }
768 void setDestinationTopLeft(
const QPoint &p) { m_destinationTopLeft = p; }
772 int m_sourceLayer = 0;
773 int m_sourceLevel = 0;
774 QPoint m_sourceTopLeft;
775 int m_destinationLayer = 0;
776 int m_destinationLevel = 0;
777 QPoint m_destinationTopLeft;
785 QRhiReadbackDescription() =
default;
786 QRhiReadbackDescription(QRhiTexture *texture);
788 QRhiTexture *texture()
const {
return m_texture; }
789 void setTexture(QRhiTexture *tex) { m_texture = tex; }
791 int layer()
const {
return m_layer; }
792 void setLayer(
int layer) { m_layer = layer; }
794 int level()
const {
return m_level; }
795 void setLevel(
int level) { m_level = level; }
797 QRect rect()
const {
return m_rect; }
798 void setRect(
const QRect &rectangle) { m_rect = rectangle; }
801 QRhiTexture *m_texture =
nullptr;
821 RenderPassDescriptor,
822 SwapChainRenderTarget,
824 ShaderResourceBindings,
832 virtual ~QRhiResource();
834 virtual Type resourceType()
const = 0;
836 virtual void destroy() = 0;
840 QByteArray name()
const;
841 void setName(
const QByteArray &name);
843 quint64 globalResourceId()
const;
848 QRhiResource(QRhiImplementation *rhi);
849 Q_DISABLE_COPY(QRhiResource)
850 friend class QRhiImplementation;
851 QRhiImplementation *m_rhi =
nullptr;
853 QByteArray m_objectName;
866 VertexBuffer = 1 << 0,
867 IndexBuffer = 1 << 1,
868 UniformBuffer = 1 << 2,
869 StorageBuffer = 1 << 3,
870 IndirectBuffer = 1 << 4,
872 Q_DECLARE_FLAGS(UsageFlags, UsageFlag)
874 struct NativeBuffer {
875 const void *objects[3];
879 QRhiResource::Type resourceType()
const override;
881 Type type()
const {
return m_type; }
882 void setType(Type t) { m_type = t; }
884 UsageFlags usage()
const {
return m_usage; }
885 void setUsage(UsageFlags u) { m_usage = u; }
887 quint32 size()
const {
return m_size; }
888 void setSize(quint32 sz) { m_size = sz; }
890 virtual bool create() = 0;
892 virtual NativeBuffer nativeBuffer();
894 virtual char *beginFullDynamicBufferUpdateForCurrentFrame();
895 virtual void endFullDynamicBufferUpdateForCurrentFrame();
896 virtual void fullDynamicBufferUpdateForCurrentFrame(
const void *data, quint32 size = 0);
899 QRhiBuffer(QRhiImplementation *rhi, Type type_, UsageFlags usage_, quint32 size_);
905Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiBuffer::UsageFlags)
907class Q_GUI_EXPORT QRhiTexture :
public QRhiResource
911 RenderTarget = 1 << 0,
915 UsedAsTransferSource = 1 << 5,
916 UsedWithGenerateMips = 1 << 6,
917 UsedWithLoadStore = 1 << 7,
918 UsedAsCompressedAtlas = 1 << 8,
919 ExternalOES = 1 << 9,
920 ThreeDimensional = 1 << 10,
921 TextureRectangleGL = 1 << 11,
922 TextureArray = 1 << 12,
923 OneDimensional = 1 << 13,
924 UsedAsShadingRateMap = 1 << 14
926 Q_DECLARE_FLAGS(Flags, Flag)
990 struct NativeTexture {
995 QRhiResource::Type resourceType()
const override;
997 Format format()
const {
return m_format; }
998 void setFormat(Format fmt) { m_format = fmt; }
1000 QSize pixelSize()
const {
return m_pixelSize; }
1001 void setPixelSize(
const QSize &sz) { m_pixelSize = sz; }
1003 int depth()
const {
return m_depth; }
1004 void setDepth(
int depth) { m_depth = depth; }
1006 int arraySize()
const {
return m_arraySize; }
1007 void setArraySize(
int arraySize) { m_arraySize = arraySize; }
1009 int arrayRangeStart()
const {
return m_arrayRangeStart; }
1010 int arrayRangeLength()
const {
return m_arrayRangeLength; }
1011 void setArrayRange(
int startIndex,
int count)
1013 m_arrayRangeStart = startIndex;
1014 m_arrayRangeLength = count;
1017 Flags flags()
const {
return m_flags; }
1018 void setFlags(Flags f) { m_flags = f; }
1020 int sampleCount()
const {
return m_sampleCount; }
1021 void setSampleCount(
int s) { m_sampleCount = s; }
1024 QRhiTexture::Format format;
1027 ViewFormat readViewFormat()
const {
return m_readViewFormat; }
1028 void setReadViewFormat(
const ViewFormat &fmt) { m_readViewFormat = fmt; }
1029 ViewFormat writeViewFormat()
const {
return m_writeViewFormat; }
1030 void setWriteViewFormat(
const ViewFormat &fmt) { m_writeViewFormat = fmt; }
1032 virtual bool create() = 0;
1033 virtual NativeTexture nativeTexture();
1034 virtual bool createFrom(NativeTexture src);
1035 virtual void setNativeLayout(
int layout);
1038 QRhiTexture(QRhiImplementation *rhi, Format format_,
const QSize &pixelSize_,
int depth_,
1039 int arraySize_,
int sampleCount_, Flags flags_);
1046 int m_arrayRangeStart = -1;
1047 int m_arrayRangeLength = -1;
1048 ViewFormat m_readViewFormat = { UnknownFormat,
false };
1049 ViewFormat m_writeViewFormat = { UnknownFormat,
false };
1052Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiTexture::Flags)
1054class Q_GUI_EXPORT QRhiSampler :
public QRhiResource
1080 QRhiResource::Type resourceType()
const override;
1082 Filter magFilter()
const {
return m_magFilter; }
1083 void setMagFilter(Filter f) { m_magFilter = f; }
1085 Filter minFilter()
const {
return m_minFilter; }
1086 void setMinFilter(Filter f) { m_minFilter = f; }
1088 Filter mipmapMode()
const {
return m_mipmapMode; }
1089 void setMipmapMode(Filter f) { m_mipmapMode = f; }
1091 AddressMode addressU()
const {
return m_addressU; }
1092 void setAddressU(AddressMode mode) { m_addressU = mode; }
1094 AddressMode addressV()
const {
return m_addressV; }
1095 void setAddressV(AddressMode mode) { m_addressV = mode; }
1097 AddressMode addressW()
const {
return m_addressW; }
1098 void setAddressW(AddressMode mode) { m_addressW = mode; }
1100 CompareOp textureCompareOp()
const {
return m_compareOp; }
1101 void setTextureCompareOp(CompareOp op) { m_compareOp = op; }
1103 virtual bool create() = 0;
1106 QRhiSampler(QRhiImplementation *rhi,
1107 Filter magFilter_, Filter minFilter_, Filter mipmapMode_,
1108 AddressMode u_, AddressMode v_, AddressMode w_);
1111 Filter m_mipmapMode;
1112 AddressMode m_addressU;
1113 AddressMode m_addressV;
1114 AddressMode m_addressW;
1115 CompareOp m_compareOp;
1127 UsedWithSwapChainOnly = 1 << 0
1129 Q_DECLARE_FLAGS(Flags, Flag)
1131 struct NativeRenderBuffer {
1135 QRhiResource::Type resourceType()
const override;
1137 Type type()
const {
return m_type; }
1138 void setType(Type t) { m_type = t; }
1140 QSize pixelSize()
const {
return m_pixelSize; }
1141 void setPixelSize(
const QSize &sz) { m_pixelSize = sz; }
1143 int sampleCount()
const {
return m_sampleCount; }
1144 void setSampleCount(
int s) { m_sampleCount = s; }
1146 Flags flags()
const {
return m_flags; }
1147 void setFlags(Flags f) { m_flags = f; }
1149 virtual bool create() = 0;
1150 virtual bool createFrom(NativeRenderBuffer src);
1152 virtual QRhiTexture::Format backingFormat()
const = 0;
1155 QRhiRenderBuffer(QRhiImplementation *rhi, Type type_,
const QSize &pixelSize_,
1156 int sampleCount_, Flags flags_, QRhiTexture::Format backingFormatHint_);
1161 QRhiTexture::Format m_backingFormatHint;
1164Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiRenderBuffer::Flags)
1166class Q_GUI_EXPORT QRhiShadingRateMap :
public QRhiResource
1169 struct NativeShadingRateMap {
1173 QRhiResource::Type resourceType()
const override;
1175 virtual bool createFrom(NativeShadingRateMap src);
1176 virtual bool createFrom(QRhiTexture *src);
1179 QRhiShadingRateMap(QRhiImplementation *rhi);
1185 QRhiResource::Type resourceType()
const override;
1187 virtual bool isCompatible(
const QRhiRenderPassDescriptor *other)
const = 0;
1188 virtual const QRhiNativeHandles *nativeHandles();
1190 virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor()
const = 0;
1192 virtual QVector<quint32> serializedFormat()
const = 0;
1195 QRhiRenderPassDescriptor(QRhiImplementation *rhi);
1201 virtual QSize pixelSize()
const = 0;
1202 virtual float devicePixelRatio()
const = 0;
1203 virtual int sampleCount()
const = 0;
1205 QRhiRenderPassDescriptor *renderPassDescriptor()
const {
return m_renderPassDesc; }
1206 void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
1209 QRhiRenderTarget(QRhiImplementation *rhi);
1210 QRhiRenderPassDescriptor *m_renderPassDesc =
nullptr;
1216 QRhiResource::Type resourceType()
const override;
1217 QRhiSwapChain *swapChain()
const {
return m_swapchain; }
1220 QRhiSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain_);
1221 QRhiSwapChain *m_swapchain;
1228 PreserveColorContents = 1 << 0,
1229 PreserveDepthStencilContents = 1 << 1,
1230 DoNotStoreDepthStencilContents = 1 << 2
1232 Q_DECLARE_FLAGS(Flags, Flag)
1234 QRhiResource::Type resourceType()
const override;
1236 QRhiTextureRenderTargetDescription description()
const {
return m_desc; }
1237 void setDescription(
const QRhiTextureRenderTargetDescription &desc) { m_desc = desc; }
1239 Flags flags()
const {
return m_flags; }
1240 void setFlags(Flags f) { m_flags = f; }
1242 virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() = 0;
1244 virtual bool create() = 0;
1247 QRhiTextureRenderTarget(QRhiImplementation *rhi,
const QRhiTextureRenderTargetDescription &desc_, Flags flags_);
1248 QRhiTextureRenderTargetDescription m_desc;
1252Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiTextureRenderTarget::Flags)
1254class Q_GUI_EXPORT QRhiShaderResourceBindings :
public QRhiResource
1257 QRhiResource::Type resourceType()
const override;
1259 void setBindings(std::initializer_list<QRhiShaderResourceBinding> list) { m_bindings = list; }
1260 template<
typename InputIterator>
1261 void setBindings(InputIterator first, InputIterator last)
1264 std::copy(first, last, std::back_inserter(m_bindings));
1266 const QRhiShaderResourceBinding *cbeginBindings()
const {
return m_bindings.cbegin(); }
1267 const QRhiShaderResourceBinding *cendBindings()
const {
return m_bindings.cend(); }
1268 const QRhiShaderResourceBinding *bindingAt(qsizetype index)
const {
return &m_bindings.at(index); }
1269 qsizetype bindingCount()
const {
return m_bindings.count(); }
1271 bool isLayoutCompatible(
const QRhiShaderResourceBindings *other)
const;
1273 QVector<quint32> serializedLayoutDescription()
const {
return m_layoutDesc; }
1275 virtual bool create() = 0;
1278 BindingsAreSorted = 0x01
1280 Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag)
1282 virtual void updateResources(UpdateFlags flags = {}) = 0;
1285 static constexpr int BINDING_PREALLOC = 12;
1286 QRhiShaderResourceBindings(QRhiImplementation *rhi);
1287 QVarLengthArray<QRhiShaderResourceBinding, BINDING_PREALLOC> m_bindings;
1288 size_t m_layoutDescHash = 0;
1292 QVector<quint32> m_layoutDesc;
1293 friend class QRhiImplementation;
1294#ifndef QT_NO_DEBUG_STREAM
1295 friend Q_GUI_EXPORT QDebug operator<<(QDebug,
const QRhiShaderResourceBindings &);
1299Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBindings::UpdateFlags)
1301#ifndef QT_NO_DEBUG_STREAM
1302Q_GUI_EXPORT QDebug operator<<(QDebug,
const QRhiShaderResourceBindings &);
1308using QRhiShaderResourceBindingSet = QRhiShaderResourceBindings;
1314 UsesBlendConstants = 1 << 0,
1315 UsesStencilRef = 1 << 1,
1316 UsesScissor = 1 << 2,
1317 CompileShadersWithDebugInfo = 1 << 3,
1318 UsesShadingRate = 1 << 4,
1319 UsesIndirectDraws = 1 << 5
1321 Q_DECLARE_FLAGS(Flags, Flag)
1344 enum ColorMaskComponent {
1350 Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)
1364 OneMinusConstantColor,
1366 OneMinusConstantAlpha,
1382 struct TargetBlend {
1383 ColorMask colorWrite = ColorMask(0xF);
1384 bool enable =
false;
1385 BlendFactor srcColor = One;
1386 BlendFactor dstColor = OneMinusSrcAlpha;
1387 BlendOp opColor = Add;
1388 BlendFactor srcAlpha = One;
1389 BlendFactor dstAlpha = OneMinusSrcAlpha;
1390 BlendOp opAlpha = Add;
1415 struct StencilOpState {
1416 StencilOp failOp = Keep;
1417 StencilOp depthFailOp = Keep;
1418 StencilOp passOp = Keep;
1419 CompareOp compareOp = Always;
1427 QRhiResource::Type resourceType()
const override;
1429 Flags flags()
const {
return m_flags; }
1430 void setFlags(Flags f) { m_flags = f; }
1432 Topology topology()
const {
return m_topology; }
1433 void setTopology(Topology t) { m_topology = t; }
1435 CullMode cullMode()
const {
return m_cullMode; }
1436 void setCullMode(CullMode mode) { m_cullMode = mode; }
1438 FrontFace frontFace()
const {
return m_frontFace; }
1439 void setFrontFace(FrontFace f) { m_frontFace = f; }
1441 void setTargetBlends(std::initializer_list<TargetBlend> list) { m_targetBlends = list; }
1442 template<
typename InputIterator>
1443 void setTargetBlends(InputIterator first, InputIterator last)
1445 m_targetBlends.clear();
1446 std::copy(first, last, std::back_inserter(m_targetBlends));
1448 const TargetBlend *cbeginTargetBlends()
const {
return m_targetBlends.cbegin(); }
1449 const TargetBlend *cendTargetBlends()
const {
return m_targetBlends.cend(); }
1450 const TargetBlend *targetBlendAt(qsizetype index)
const {
return &m_targetBlends.at(index); }
1451 qsizetype targetBlendCount()
const {
return m_targetBlends.count(); }
1453 bool hasDepthTest()
const {
return m_depthTest; }
1454 void setDepthTest(
bool enable) { m_depthTest = enable; }
1456 bool hasDepthWrite()
const {
return m_depthWrite; }
1457 void setDepthWrite(
bool enable) { m_depthWrite = enable; }
1459 bool hasDepthClamp()
const {
return m_depthClamp; }
1460 void setDepthClamp(
bool enable) { m_depthClamp = enable; }
1462 CompareOp depthOp()
const {
return m_depthOp; }
1463 void setDepthOp(CompareOp op) { m_depthOp = op; }
1465 bool hasStencilTest()
const {
return m_stencilTest; }
1466 void setStencilTest(
bool enable) { m_stencilTest = enable; }
1468 StencilOpState stencilFront()
const {
return m_stencilFront; }
1469 void setStencilFront(
const StencilOpState &state) { m_stencilFront = state; }
1471 StencilOpState stencilBack()
const {
return m_stencilBack; }
1472 void setStencilBack(
const StencilOpState &state) { m_stencilBack = state; }
1474 quint32 stencilReadMask()
const {
return m_stencilReadMask; }
1475 void setStencilReadMask(quint32 mask) { m_stencilReadMask = mask; }
1477 quint32 stencilWriteMask()
const {
return m_stencilWriteMask; }
1478 void setStencilWriteMask(quint32 mask) { m_stencilWriteMask = mask; }
1480 int sampleCount()
const {
return m_sampleCount; }
1481 void setSampleCount(
int s) { m_sampleCount = s; }
1483 float lineWidth()
const {
return m_lineWidth; }
1484 void setLineWidth(
float width) { m_lineWidth = width; }
1486 int depthBias()
const {
return m_depthBias; }
1487 void setDepthBias(
int bias) { m_depthBias = bias; }
1489 float slopeScaledDepthBias()
const {
return m_slopeScaledDepthBias; }
1490 void setSlopeScaledDepthBias(
float bias) { m_slopeScaledDepthBias = bias; }
1492 void setShaderStages(std::initializer_list<QRhiShaderStage> list) { m_shaderStages = list; }
1493 template<
typename InputIterator>
1494 void setShaderStages(InputIterator first, InputIterator last)
1496 m_shaderStages.clear();
1497 std::copy(first, last, std::back_inserter(m_shaderStages));
1499 const QRhiShaderStage *cbeginShaderStages()
const {
return m_shaderStages.cbegin(); }
1500 const QRhiShaderStage *cendShaderStages()
const {
return m_shaderStages.cend(); }
1501 const QRhiShaderStage *shaderStageAt(qsizetype index)
const {
return &m_shaderStages.at(index); }
1502 qsizetype shaderStageCount()
const {
return m_shaderStages.count(); }
1504 QRhiVertexInputLayout vertexInputLayout()
const {
return m_vertexInputLayout; }
1505 void setVertexInputLayout(
const QRhiVertexInputLayout &layout) { m_vertexInputLayout = layout; }
1507 QRhiShaderResourceBindings *shaderResourceBindings()
const {
return m_shaderResourceBindings; }
1508 void setShaderResourceBindings(QRhiShaderResourceBindings *srb) { m_shaderResourceBindings = srb; }
1510 QRhiRenderPassDescriptor *renderPassDescriptor()
const {
return m_renderPassDesc; }
1511 void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
1513 int patchControlPointCount()
const {
return m_patchControlPointCount; }
1514 void setPatchControlPointCount(
int count) { m_patchControlPointCount = count; }
1516 PolygonMode polygonMode()
const {
return m_polygonMode; }
1517 void setPolygonMode(PolygonMode mode) {m_polygonMode = mode; }
1519 int multiViewCount()
const {
return m_multiViewCount; }
1520 void setMultiViewCount(
int count) { m_multiViewCount = count; }
1522 virtual bool create() = 0;
1525 QRhiGraphicsPipeline(QRhiImplementation *rhi);
1527 Topology m_topology = Triangles;
1528 CullMode m_cullMode = None;
1529 FrontFace m_frontFace = CCW;
1530 QVarLengthArray<TargetBlend, 8> m_targetBlends;
1531 bool m_depthTest =
false;
1532 bool m_depthWrite =
false;
1533 bool m_depthClamp =
false;
1534 CompareOp m_depthOp = Less;
1535 bool m_stencilTest =
false;
1536 StencilOpState m_stencilFront;
1537 StencilOpState m_stencilBack;
1538 quint32 m_stencilReadMask = 0xFF;
1539 quint32 m_stencilWriteMask = 0xFF;
1540 int m_sampleCount = 1;
1541 float m_lineWidth = 1.0f;
1542 int m_depthBias = 0;
1543 float m_slopeScaledDepthBias = 0.0f;
1544 int m_patchControlPointCount = 3;
1545 PolygonMode m_polygonMode = Fill;
1546 int m_multiViewCount = 0;
1547 QVarLengthArray<QRhiShaderStage, 4> m_shaderStages;
1548 QRhiVertexInputLayout m_vertexInputLayout;
1549 QRhiShaderResourceBindings *m_shaderResourceBindings =
nullptr;
1550 QRhiRenderPassDescriptor *m_renderPassDesc =
nullptr;
1553Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::Flags)
1554Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiGraphicsPipeline::ColorMask)
1555Q_DECLARE_TYPEINFO(QRhiGraphicsPipeline::TargetBlend, Q_RELOCATABLE_TYPE);
1578 } colorComponentValue;
1586#ifndef QT_NO_DEBUG_STREAM
1587Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiSwapChainHdrInfo &);
1599 SurfaceHasPreMulAlpha = 1 << 0,
1600 SurfaceHasNonPreMulAlpha = 1 << 1,
1602 UsedAsTransferSource = 1 << 3,
1604 MinimalBufferCount = 1 << 5
1606 Q_DECLARE_FLAGS(Flags, Flag)
1610 HDRExtendedSrgbLinear,
1612 HDRExtendedDisplayP3Linear
1615 enum StereoTargetBuffer {
1620 QRhiResource::Type resourceType()
const override;
1622 QWindow *window()
const {
return m_window; }
1623 void setWindow(QWindow *window) { m_window = window; }
1625 QRhiSwapChainProxyData proxyData()
const {
return m_proxyData; }
1626 void setProxyData(
const QRhiSwapChainProxyData &d) { m_proxyData = d; }
1628 Flags flags()
const {
return m_flags; }
1629 void setFlags(Flags f) { m_flags = f; }
1631 Format format()
const {
return m_format; }
1632 void setFormat(Format f) { m_format = f; }
1634 QRhiRenderBuffer *depthStencil()
const {
return m_depthStencil; }
1635 void setDepthStencil(QRhiRenderBuffer *ds) { m_depthStencil = ds; }
1637 int sampleCount()
const {
return m_sampleCount; }
1638 void setSampleCount(
int samples) { m_sampleCount = samples; }
1640 QRhiRenderPassDescriptor *renderPassDescriptor()
const {
return m_renderPassDesc; }
1641 void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc) { m_renderPassDesc = desc; }
1643 QRhiShadingRateMap *shadingRateMap()
const {
return m_shadingRateMap; }
1644 void setShadingRateMap(QRhiShadingRateMap *map) { m_shadingRateMap = map; }
1646 QSize currentPixelSize()
const {
return m_currentPixelSize; }
1648 virtual QRhiCommandBuffer *currentFrameCommandBuffer() = 0;
1649 virtual QRhiRenderTarget *currentFrameRenderTarget() = 0;
1650 virtual QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer);
1651 virtual QSize surfacePixelSize() = 0;
1652 virtual bool isFormatSupported(Format f) = 0;
1653 virtual QRhiRenderPassDescriptor *newCompatibleRenderPassDescriptor() = 0;
1654 virtual bool createOrResize() = 0;
1655 virtual QRhiSwapChainHdrInfo hdrInfo();
1658 QRhiSwapChain(QRhiImplementation *rhi);
1659 QWindow *m_window =
nullptr;
1661 Format m_format = SDR;
1662 QRhiRenderBuffer *m_depthStencil =
nullptr;
1663 int m_sampleCount = 1;
1664 QRhiRenderPassDescriptor *m_renderPassDesc =
nullptr;
1665 QSize m_currentPixelSize;
1666 QRhiSwapChainProxyData m_proxyData;
1667 QRhiShadingRateMap *m_shadingRateMap =
nullptr;
1670Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiSwapChain::Flags)
1672class Q_GUI_EXPORT QRhiComputePipeline :
public QRhiResource
1676 CompileShadersWithDebugInfo = 1 << 0
1678 Q_DECLARE_FLAGS(Flags, Flag)
1680 QRhiResource::Type resourceType()
const override;
1681 virtual bool create() = 0;
1683 Flags flags()
const {
return m_flags; }
1684 void setFlags(Flags f) { m_flags = f; }
1686 QRhiShaderStage shaderStage()
const {
return m_shaderStage; }
1687 void setShaderStage(
const QRhiShaderStage &stage) { m_shaderStage = stage; }
1689 QRhiShaderResourceBindings *shaderResourceBindings()
const {
return m_shaderResourceBindings; }
1690 void setShaderResourceBindings(QRhiShaderResourceBindings *srb) { m_shaderResourceBindings = srb; }
1693 QRhiComputePipeline(QRhiImplementation *rhi);
1695 QRhiShaderStage m_shaderStage;
1696 QRhiShaderResourceBindings *m_shaderResourceBindings =
nullptr;
1699Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiComputePipeline::Flags)
1701struct QRhiIndirectDrawCommand
1703 quint32 vertexCount;
1704 quint32 instanceCount = 1;
1705 quint32 firstVertex = 0;
1706 quint32 firstInstance = 0;
1719static_assert(
sizeof(QRhiIndirectDrawCommand) == 16);
1730 enum BeginPassFlag {
1731 ExternalContent = 0x01,
1732 DoNotTrackResourcesForCompute = 0x02
1734 Q_DECLARE_FLAGS(BeginPassFlags, BeginPassFlag)
1736 QRhiResource::Type resourceType()
const override;
1738 void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates);
1740 void beginPass(QRhiRenderTarget *rt,
1741 const QColor &colorClearValue,
1742 const QRhiDepthStencilClearValue &depthStencilClearValue,
1743 QRhiResourceUpdateBatch *resourceUpdates =
nullptr,
1744 BeginPassFlags flags = {});
1745 void endPass(QRhiResourceUpdateBatch *resourceUpdates =
nullptr);
1747 void setGraphicsPipeline(QRhiGraphicsPipeline *ps);
1748 using DynamicOffset = std::pair<
int, quint32>;
1749 void setShaderResources(QRhiShaderResourceBindings *srb =
nullptr,
1750 int dynamicOffsetCount = 0,
1751 const DynamicOffset *dynamicOffsets =
nullptr);
1752 using VertexInput = std::pair<QRhiBuffer *, quint32>;
1753 void setVertexInput(
int startBinding,
int bindingCount,
const VertexInput *bindings,
1754 QRhiBuffer *indexBuf =
nullptr, quint32 indexOffset = 0,
1755 IndexFormat indexFormat = IndexUInt16);
1757 void setViewport(
const QRhiViewport &viewport);
1758 void setScissor(
const QRhiScissor &scissor);
1759 void setBlendConstants(
const QColor &c);
1760 void setStencilRef(quint32 refValue);
1761 void setShadingRate(
const QSize &coarsePixelSize);
1763 void draw(quint32 vertexCount,
1764 quint32 instanceCount = 1,
1765 quint32 firstVertex = 0,
1766 quint32 firstInstance = 0);
1768 void drawIndexed(quint32 indexCount,
1769 quint32 instanceCount = 1,
1770 quint32 firstIndex = 0,
1771 qint32 vertexOffset = 0,
1772 quint32 firstInstance = 0);
1774 void drawIndirect(QRhiBuffer *indirectBuffer,
1775 quint32 indirectBufferOffset,
1777 quint32 stride =
sizeof(QRhiIndirectDrawCommand));
1779 void drawIndexedIndirect(QRhiBuffer *indirectBuffer,
1780 quint32 indirectBufferOffset,
1782 quint32 stride =
sizeof(QRhiIndexedIndirectDrawCommand));
1784 void debugMarkBegin(
const QByteArray &name);
1785 void debugMarkEnd();
1786 void debugMarkMsg(
const QByteArray &msg);
1788 void beginComputePass(QRhiResourceUpdateBatch *resourceUpdates =
nullptr, BeginPassFlags flags = {});
1789 void endComputePass(QRhiResourceUpdateBatch *resourceUpdates =
nullptr);
1790 void setComputePipeline(QRhiComputePipeline *ps);
1791 void dispatch(
int x,
int y,
int z);
1793 const QRhiNativeHandles *nativeHandles();
1794 void beginExternal();
1797 double lastCompletedGpuTime();
1800 QRhiCommandBuffer(QRhiImplementation *rhi);
1803Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiCommandBuffer::BeginPassFlags)
1805struct Q_GUI_EXPORT QRhiReadbackResult
1807 std::function<
void()> completed =
nullptr;
1808 QRhiTexture::Format format;
1816 ~QRhiResourceUpdateBatch();
1820 void merge(QRhiResourceUpdateBatch *other);
1821 bool hasOptimalCapacity()
const;
1823 void updateDynamicBuffer(QRhiBuffer *buf, quint32 offset, quint32 size,
const void *data);
1824 void updateDynamicBuffer(QRhiBuffer *buf, quint32 offset, QByteArray data);
1825 void uploadStaticBuffer(QRhiBuffer *buf, quint32 offset, quint32 size,
const void *data);
1826 void uploadStaticBuffer(QRhiBuffer *buf, quint32 offset, QByteArray data);
1827 void uploadStaticBuffer(QRhiBuffer *buf,
const void *data);
1828 void uploadStaticBuffer(QRhiBuffer *buf, QByteArray data);
1829 void readBackBuffer(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiReadbackResult *result);
1830 void uploadTexture(QRhiTexture *tex,
const QRhiTextureUploadDescription &desc);
1831 void uploadTexture(QRhiTexture *tex,
const QImage &image);
1832 void copyTexture(QRhiTexture *dst, QRhiTexture *src,
const QRhiTextureCopyDescription &desc = QRhiTextureCopyDescription());
1833 void readBackTexture(
const QRhiReadbackDescription &rb, QRhiReadbackResult *result);
1834 void generateMips(QRhiTexture *tex);
1837 QRhiResourceUpdateBatch(QRhiImplementation *rhi);
1838 Q_DISABLE_COPY(QRhiResourceUpdateBatch)
1839 QRhiResourceUpdateBatchPrivate *d;
1840 friend class QRhiResourceUpdateBatchPrivate;
1855 QByteArray deviceName;
1856 quint64 deviceId = 0;
1857 quint64 vendorId = 0;
1858 DeviceType deviceType = UnknownDevice;
1863#ifndef QT_NO_DEBUG_STREAM
1864Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiDriverInfo &);
1869 qint64 totalPipelineCreationTime = 0;
1871 quint32 blockCount = 0;
1872 quint32 allocCount = 0;
1873 quint64 usedBytes = 0;
1874 quint64 unusedBytes = 0;
1876 quint64 totalUsageBytes = 0;
1881#ifndef QT_NO_DEBUG_STREAM
1882Q_GUI_EXPORT
QDebug operator<<(QDebug,
const QRhiStats &);
1888 virtual ~QRhiAdapter();
1889 virtual QRhiDriverInfo info()
const = 0;
1899 enum Implementation {
1909 EnableDebugMarkers = 1 << 0,
1910 PreferSoftwareRenderer = 1 << 1,
1911 EnablePipelineCacheDataSave = 1 << 2,
1912 EnableTimestamps = 1 << 3,
1913 SuppressSmokeTestWarnings = 1 << 4
1915 Q_DECLARE_FLAGS(Flags, Flag)
1917 enum FrameOpResult {
1920 FrameOpSwapChainOutOfDate,
1925 MultisampleTexture = 1,
1926 MultisampleRenderBuffer,
1930 CustomInstanceStepRate,
1932 NonDynamicUniformBuffers,
1933 NonFourAlignedEffectiveIndexBufferOffset,
1939 VertexShaderPointSize,
1942 TriangleFanTopology,
1943 ReadBackNonUniformBuffer,
1944 ReadBackNonBaseMipLevel,
1946 RenderToNonBaseMipLevel,
1948 ScreenSpaceDerivatives,
1949 ReadBackAnyTextureFormat,
1950 PipelineCacheDataLoadSave,
1953 ThreeDimensionalTextures,
1954 RenderTo3DTextureSlice,
1960 OneDimensionalTextures,
1961 OneDimensionalTextureMipmaps,
1963 RenderToOneDimensionalTexture,
1964 ThreeDimensionalTextureMipmaps,
1967 ResolveDepthStencil,
1968 VariableRateShading,
1969 VariableRateShadingMap,
1970 VariableRateShadingMapWithTexture,
1971 PerRenderTargetBlending,
1973 InstanceIndexIncludesBaseInstance,
1979 enum BeginFrameFlag {
1981 Q_DECLARE_FLAGS(BeginFrameFlags, BeginFrameFlag)
1984 SkipPresent = 1 << 0
1986 Q_DECLARE_FLAGS(EndFrameFlags, EndFrameFlag)
1988 enum ResourceLimit {
1991 MaxColorAttachments,
1993 MaxAsyncReadbackFrames,
1994 MaxThreadGroupsPerDimension,
1995 MaxThreadsPerThreadGroup,
1999 TextureArraySizeMax,
2000 MaxUniformBufferRange,
2003 ShadingRateImageTileSize
2008 static QRhi *create(Implementation impl,
2009 QRhiInitParams *params,
2011 QRhiNativeHandles *importDevice =
nullptr);
2012 static QRhi *create(Implementation impl,
2013 QRhiInitParams *params,
2015 QRhiNativeHandles *importDevice,
2016 QRhiAdapter *adapter);
2017 static bool probe(Implementation impl, QRhiInitParams *params);
2018 using AdapterList = QVector<QRhiAdapter *>;
2019 static AdapterList enumerateAdapters(Implementation impl,
2020 QRhiInitParams *params,
2021 QRhiNativeHandles *nativeHandles =
nullptr);
2023 Implementation backend()
const;
2024 const char *backendName()
const;
2025 static const char *backendName(Implementation impl);
2026 QRhiDriverInfo driverInfo()
const;
2027 QThread *thread()
const;
2029 using CleanupCallback = std::function<
void(QRhi *)>;
2030 void addCleanupCallback(
const CleanupCallback &callback);
2031 void addCleanupCallback(
const void *key,
const CleanupCallback &callback);
2032 void removeCleanupCallback(
const void *key);
2034 QRhiGraphicsPipeline *newGraphicsPipeline();
2035 QRhiComputePipeline *newComputePipeline();
2036 QRhiShaderResourceBindings *newShaderResourceBindings();
2038 QRhiBuffer *newBuffer(QRhiBuffer::Type type,
2039 QRhiBuffer::UsageFlags usage,
2042 QRhiRenderBuffer *newRenderBuffer(QRhiRenderBuffer::Type type,
2043 const QSize &pixelSize,
2044 int sampleCount = 1,
2045 QRhiRenderBuffer::Flags flags = {},
2046 QRhiTexture::Format backingFormatHint = QRhiTexture::UnknownFormat);
2048 QRhiTexture *newTexture(QRhiTexture::Format format,
2049 const QSize &pixelSize,
2050 int sampleCount = 1,
2051 QRhiTexture::Flags flags = {});
2053 QRhiTexture *newTexture(QRhiTexture::Format format,
2054 int width,
int height,
int depth,
2055 int sampleCount = 1,
2056 QRhiTexture::Flags flags = {});
2058 QRhiTexture *newTextureArray(QRhiTexture::Format format,
2060 const QSize &pixelSize,
2061 int sampleCount = 1,
2062 QRhiTexture::Flags flags = {});
2064 QRhiSampler *newSampler(QRhiSampler::Filter magFilter,
2065 QRhiSampler::Filter minFilter,
2066 QRhiSampler::Filter mipmapMode,
2067 QRhiSampler::AddressMode addressU,
2068 QRhiSampler::AddressMode addressV,
2069 QRhiSampler::AddressMode addressW = QRhiSampler::Repeat);
2071 QRhiShadingRateMap *newShadingRateMap();
2073 QRhiTextureRenderTarget *newTextureRenderTarget(
const QRhiTextureRenderTargetDescription &desc,
2074 QRhiTextureRenderTarget::Flags flags = {});
2076 QRhiSwapChain *newSwapChain();
2077 FrameOpResult beginFrame(QRhiSwapChain *swapChain, BeginFrameFlags flags = {});
2078 FrameOpResult endFrame(QRhiSwapChain *swapChain, EndFrameFlags flags = {});
2079 bool isRecordingFrame()
const;
2080 int currentFrameSlot()
const;
2082 FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags = {});
2083 FrameOpResult endOffscreenFrame(EndFrameFlags flags = {});
2085 QRhi::FrameOpResult finish();
2087 QRhiResourceUpdateBatch *nextResourceUpdateBatch();
2089 QList<
int> supportedSampleCounts()
const;
2091 int ubufAlignment()
const;
2092 int ubufAligned(
int v)
const;
2094 static int mipLevelsForSize(
const QSize &size);
2095 static QSize sizeForMipLevel(
int mipLevel,
const QSize &baseLevelSize);
2097 bool isYUpInFramebuffer()
const;
2098 bool isYUpInNDC()
const;
2099 bool isClipDepthZeroToOne()
const;
2101 QMatrix4x4 clipSpaceCorrMatrix()
const;
2103 bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags = {})
const;
2104 bool isFeatureSupported(QRhi::Feature feature)
const;
2105 int resourceLimit(ResourceLimit limit)
const;
2107 const QRhiNativeHandles *nativeHandles();
2108 bool makeThreadLocalNativeContextCurrent();
2109 void setQueueSubmitParams(QRhiNativeHandles *params);
2111 static constexpr int MAX_MIP_LEVELS = 16;
2113 void releaseCachedResources();
2115 bool isDeviceLost()
const;
2117 QByteArray pipelineCacheData();
2118 void setPipelineCacheData(
const QByteArray &data);
2120 QRhiStats statistics()
const;
2122 static QRhiSwapChainProxyData updateSwapChainProxyData(Implementation impl, QWindow *window);
2124 QList<QSize> supportedShadingRates(
int sampleCount)
const;
2130 Q_DISABLE_COPY(QRhi)
2131 QRhiImplementation *d =
nullptr;
2134Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::Flags)
2135Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::BeginFrameFlags)
2136Q_DECLARE_OPERATORS_FOR_FLAGS(QRhi::EndFrameFlags)
2140#include <rhi/qrhi_platform.h>
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
\variable QRhiIndexedIndirectDrawCommand::indexCount
\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)
int main(int argc, char *argv[])
[ctor_close]
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
\variable QRhiIndirectDrawCommand::vertexCount
\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