Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qssgrhicontext_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QSSGRHICONTEXT_P_H
7#define QSSGRHICONTEXT_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtGui/rhi/qrhi.h>
21
22#include <QtQuick3DRuntimeRender/qtquick3druntimerenderexports.h>
23#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
24#include <QtQuick3DUtils/private/qssgutils_p.h>
25#include <ssg/qssgrhicontext.h>
26
28
29struct QSSGRenderLayer;
30struct QSSGRenderSkyMaterial;
31struct QSSGRenderInstanceTable;
32struct QSSGRenderModel;
33struct QSSGRenderMesh;
34class QSSGRenderGraphObject;
35class QSSGBufferManager;
36class QSSGUserRenderPassManager;
37
39{
41 static const InputAssemblerState &get(const QSSGRhiGraphicsPipelineState &ps) { return ps.ia; }
42 static InputAssemblerState &get(QSSGRhiGraphicsPipelineState &ps) { return ps.ia; }
43};
44
45using QSSGRhiInputAssemblerState = QSSGRhiInputAssemblerStatePrivate::InputAssemblerState;
46
48{
49 static void setShaderPipeline(QSSGRhiGraphicsPipelineState &ps, const QSSGRhiShaderPipeline *pipeline)
50 {
51 ps.shaderPipeline = pipeline;
52 }
53
54 static constexpr const QSSGRhiShaderPipeline *getShaderPipeline(const QSSGRhiGraphicsPipelineState &ps)
55 {
56 return ps.shaderPipeline;
57 }
58};
59
60namespace QSSGRhiHelpers
61{
62
63inline QRhiSampler::Filter toRhi(QSSGRenderTextureFilterOp op)
64{
65 switch (op) {
66 case QSSGRenderTextureFilterOp::Nearest:
67 return QRhiSampler::Nearest;
68 case QSSGRenderTextureFilterOp::Linear:
69 return QRhiSampler::Linear;
70 case QSSGRenderTextureFilterOp::None:
71 return QRhiSampler::Linear;
72 }
73
74 Q_UNREACHABLE_RETURN(QRhiSampler::Linear);
75}
76
77inline QRhiSampler::AddressMode toRhi(QSSGRenderTextureCoordOp tiling)
78{
79 switch (tiling) {
80 case QSSGRenderTextureCoordOp::Repeat:
81 return QRhiSampler::Repeat;
82 case QSSGRenderTextureCoordOp::MirroredRepeat:
83 return QRhiSampler::Mirror;
84 case QSSGRenderTextureCoordOp::ClampToEdge:
85 return QRhiSampler::ClampToEdge;
86 case QSSGRenderTextureCoordOp::Unknown:
87 return QRhiSampler::ClampToEdge;
88 }
89
90 Q_UNREACHABLE_RETURN(QRhiSampler::ClampToEdge);
91}
92
93inline QRhiGraphicsPipeline::CullMode toCullMode(QSSGCullFaceMode cullFaceMode)
94{
95 switch (cullFaceMode) {
96 case QSSGCullFaceMode::Back:
97 return QRhiGraphicsPipeline::Back;
98 case QSSGCullFaceMode::Front:
99 return QRhiGraphicsPipeline::Front;
100 case QSSGCullFaceMode::Disabled:
101 return QRhiGraphicsPipeline::None;
102 case QSSGCullFaceMode::FrontAndBack:
103 qWarning("FrontAndBack cull mode not supported");
104 return QRhiGraphicsPipeline::None;
105 case QSSGCullFaceMode::Unknown:
106 return QRhiGraphicsPipeline::None;
107 }
108
109 Q_UNREACHABLE_RETURN(QRhiGraphicsPipeline::None);
110}
111
112QRhiVertexInputAttribute::Format toVertexInputFormat(QSSGRenderComponentType compType, quint32 numComps);
113QRhiGraphicsPipeline::Topology toTopology(QSSGRenderDrawMode drawMode);
114// Fills out inputLayout.attributes[].location based on
115// inputLayoutInputNames and the provided shader reflection info.
116void bakeVertexInputLocations(QSSGRhiInputAssemblerState *ia, const QSSGRhiShaderPipeline &shaders, int instanceBufferBinding = 0);
117
118} // namespace QSSGRhiHelpers
119
120inline bool operator==(const QSSGRhiGraphicsPipelineState &a, const QSSGRhiGraphicsPipelineState &b) Q_DECL_NOTHROW
121{
122 const auto &ia_a = QSSGRhiInputAssemblerStatePrivate::get(a);
123 const auto &ia_b = QSSGRhiInputAssemblerStatePrivate::get(b);
124 const auto compareTargetBlend = [](const std::array<QRhiGraphicsPipeline::TargetBlend, 8> &a,
125 const std::array<QRhiGraphicsPipeline::TargetBlend, 8> &b,
126 const int count) -> bool {
127 for (int i = 0; i < count; i++) {
128 if (a[i].colorWrite != b[i].colorWrite
129 || a[i].srcColor != b[i].srcColor
130 || a[i].dstColor != b[i].dstColor
131 || a[i].opColor != b[i].opColor
132 || a[i].srcAlpha != b[i].srcAlpha
133 || a[i].dstAlpha != b[i].dstAlpha
134 || a[i].opAlpha != b[i].opAlpha) {
135 return false;
136 }
137 }
138 return true;
139 };
140 // The viewport and scissor rects are intentionally not compared: they are
141 // dynamic state, never baked into a QRhiGraphicsPipeline, and comparing
142 // them made the pipeline cache key size-dependent, growing the cache with
143 // a new set of pipelines for every window size!
144 return QSSGRhiGraphicsPipelineStatePrivate::getShaderPipeline(a) == QSSGRhiGraphicsPipelineStatePrivate::getShaderPipeline(b)
145 && a.samples == b.samples
146 && a.flags == b.flags
147 && a.stencilRef == b.stencilRef
148 && (std::memcmp(&a.stencilOpFrontState, &b.stencilOpFrontState, sizeof(QRhiGraphicsPipeline::StencilOpState)) == 0)
149 && a.stencilWriteMask == b.stencilWriteMask
150 && a.depthFunc == b.depthFunc
151 && a.cullMode == b.cullMode
152 && a.depthBias == b.depthBias
153 && a.slopeScaledDepthBias == b.slopeScaledDepthBias
154 && ia_a.topology == ia_b.topology
155 && ia_a.inputLayout == ia_b.inputLayout
156 && a.colorAttachmentCount == b.colorAttachmentCount
157 && compareTargetBlend(a.targetBlend, b.targetBlend, a.colorAttachmentCount)
158 && a.lineWidth == b.lineWidth
159 && a.polygonMode == b.polygonMode
160 && a.viewCount == b.viewCount;
161}
162
163inline bool operator!=(const QSSGRhiGraphicsPipelineState &a, const QSSGRhiGraphicsPipelineState &b) Q_DECL_NOTHROW
164{
165 return !(a == b);
166}
167
168inline size_t qHash(const QSSGRhiGraphicsPipelineState &s, size_t seed) Q_DECL_NOTHROW
169{
170 // do not bother with all fields
171 return qHash(QSSGRhiGraphicsPipelineStatePrivate::getShaderPipeline(s), seed)
172 ^ qHash(s.samples)
173 ^ qHash(s.viewCount)
174 ^ qHash(s.targetBlend[0].dstColor)
175 ^ qHash(s.depthFunc)
176 ^ qHash(s.cullMode)
177 ^ qHash(s.colorAttachmentCount)
178 ^ qHash(s.lineWidth)
179 ^ qHash(s.polygonMode)
180 ^ qHashBits(&s.stencilOpFrontState, sizeof(QRhiGraphicsPipeline::StencilOpState))
181 ^ (s.flags)
182 ^ (s.stencilRef << 6)
183 ^ (s.stencilWriteMask << 7);
184}
185
186// The lookup keys can be somewhat complicated due to having to handle cases
187// like "render a model in a shared scene between multiple View3Ds" (here both
188// the View3D ('layer/cid') and the model ('model') act as the lookup key since
189// while the model is the same, we still want different uniform buffers per
190// View3D). 'resource' is the resource the model is drawn with, typically a
191// material; many resources can map to one model. When 'resource' refers to a
192// material it must be the material pointer and nothing else, since
193// cleanupDrawCallDataForResource() finds the entries to release for a
194// to-be-destroyed material by matching on 'resource'. 'mapEntry' is the
195// per-light shadow map entry or per-probe reflection map entry being rendered
196// into, when the draw is part of a shadow or reflection pass, otherwise null.
197// 'resourceIdx' disambiguates multiple entries for the same resource and map
198// entry, e.g. the cube map face and the subset offset.
199//
200struct QSSGRhiDrawCallDataKey
201{
202 const void *cid = nullptr; // Usually the sub-pass (see usage of QSSGPassKey)
203 const void *model = nullptr;
204 const void *resource = nullptr;
205 const void *mapEntry = nullptr;
206 quintptr resourceIdx = 0;
207};
208
209class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiBuffer
210{
211 Q_DISABLE_COPY(QSSGRhiBuffer)
212public:
213 QSSGRhiBuffer(QSSGRhiContext &context,
214 QRhiBuffer::Type type,
215 QRhiBuffer::UsageFlags usageMask,
216 quint32 stride,
217 qsizetype size,
218 QRhiCommandBuffer::IndexFormat indexFormat = QRhiCommandBuffer::IndexUInt16);
219
220 virtual ~QSSGRhiBuffer();
221
222 QRhiBuffer *buffer() const { return m_buffer; }
223 quint32 stride() const { return m_stride; }
225 const quint32 sz = quint32(m_buffer->size());
226 Q_ASSERT((sz % m_stride) == 0);
227 return sz / m_stride;
228 }
229 QRhiCommandBuffer::IndexFormat indexFormat() const { return m_indexFormat; }
230
231private:
232 QSSGRhiContext &m_context;
233 QRhiBuffer *m_buffer = nullptr;
234 quint32 m_stride;
235 QRhiCommandBuffer::IndexFormat m_indexFormat;
236};
237
239{
240 char name[64];
242
243private:
244 size_t offset = SIZE_MAX;
245 bool maybeExists = true;
246 friend class QSSGRhiShaderPipeline;
247};
248
250{
251 char name[64];
254
255private:
256 size_t offset = SIZE_MAX;
257 size_t size = 0;
258 bool maybeExists = true;
259 friend class QSSGRhiShaderPipeline;
260};
261
262using QSSGRhiBufferPtr = std::shared_ptr<QSSGRhiBuffer>;
263
264inline bool operator==(const QSSGRhiSamplerDescription &a, const QSSGRhiSamplerDescription &b) Q_DECL_NOTHROW
265{
266 return a.hTiling == b.hTiling && a.vTiling == b.vTiling && a.zTiling == b.zTiling
267 && a.minFilter == b.minFilter && a.magFilter == b.magFilter
268 && a.mipmap == b.mipmap;
269}
270
271inline bool operator!=(const QSSGRhiSamplerDescription &a, const QSSGRhiSamplerDescription &b) Q_DECL_NOTHROW
272{
273 return !(a == b);
274}
275
276struct QSSGRhiTexture
277{
278 QByteArray name;
279 QRhiTexture *texture = nullptr;
280 QSSGRhiSamplerDescription samplerDesc;
281};
282
298
299// these are our current shader limits
300#define QSSG_MAX_NUM_LIGHTS 16
301#define QSSG_MAX_NUM_DIRECTIONAL_LIGHTS 4
302#define QSSG_REDUCED_MAX_NUM_LIGHTS 4
303#define QSSG_REDUCED_MAX_NUM_DIRECTIONAL_LIGHTS 1
304
338
364
368
372
373class QSSGRhiShaderResourceBindingList;
374class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiShaderPipeline
375{
376 Q_DISABLE_COPY(QSSGRhiShaderPipeline)
377public:
378 explicit QSSGRhiShaderPipeline(QSSGRhiContext &context) : m_context(context) { }
379
380 QSSGRhiContext &context() const { return m_context; }
381 bool isNull() const { return m_stages.isEmpty(); }
382
383 enum StageFlag {
384 // Indicates that this shaderpipeline object is not going to be used with
385 // a QSSGRhiInputAssemblerState, i.e. bakeVertexInputLocations() will
386 // not be called.
387 UsedWithoutIa = 0x01
388 };
390
391 void addStage(const QRhiShaderStage &stage, StageFlags flags = {});
392 const QRhiShaderStage *cbeginStages() const { return m_stages.cbegin(); }
393 const QRhiShaderStage *cendStages() const { return m_stages.cend(); }
394
396 for (const QRhiShaderStage &s : m_stages) {
397 if (s.type() == QRhiShaderStage::Vertex)
398 return &s;
399 }
400 return nullptr;
401 }
403 for (const QRhiShaderStage &s : m_stages) {
404 if (s.type() == QRhiShaderStage::Fragment)
405 return &s;
406 }
407 return nullptr;
408 }
409
410 int ub0Size() const { return m_ub0Size; }
411 int ub0LightDataOffset() const { return m_ub0NextUBufOffset; }
413
415
416 // This struct is used purely for performance. It is used to quickly store
417 // and index common uniform names using the storeIndex argument in the
418 // setUniform method.
420 {
456 int pointSizeIdx = -1;
463 int fogColorIdx = -1;
471 int viewSize = -1;
472 int samples = -1;
473
480 } commonUniformIndices;
481
483 int transform0 = -1;
484 int transform1 = -1;
485 int transform2 = -1;
486 int color = -1;
487 int data = -1;
488 } instanceLocations;
489
490 enum class UniformFlag {
491 Mat3 = 0x01
492 };
493 Q_DECLARE_FLAGS(UniformFlags, UniformFlag)
494
495 void setUniformValue(char *ubufData, const char *name, const QVariant &value, QSSGRenderShaderValue::Type type);
496 void setUniform(char *ubufData, const char *name, const void *data, size_t size, int *storeIndex = nullptr, UniformFlags flags = {});
497 void setUniformArray(char *ubufData, const char *name, const void *data, size_t itemCount, QSSGRenderShaderValue::Type type, int *storeIndex = nullptr);
498 int bindingForTexture(const char *name, int hint = -1);
499 int bindingForStorageImage(QByteArrayView name);
500 int bindingForStorageBuffer(QByteArrayView name);
501
502 void setShaderResources(char *ubufData,
503 QSSGBufferManager &theBufferManager,
504 const QByteArray &inPropertyName,
505 const QVariant &propertyValue,
506 QSSGRenderShaderValue::Type inPropertyType);
507
508 void setLightsEnabled(bool enable) { m_lightsEnabled = enable; }
509 bool isLightingEnabled() const { return m_lightsEnabled; }
510
511 void ensureCombinedUniformBuffer(QRhiBuffer **ubuf);
512 void ensureUniformBuffer(QRhiBuffer **ubuf);
513
514 void setLightProbeTexture(QRhiTexture *texture,
515 QSSGRenderTextureCoordOp hTile = QSSGRenderTextureCoordOp::ClampToEdge,
516 QSSGRenderTextureCoordOp vTile = QSSGRenderTextureCoordOp::ClampToEdge)
517 {
518 m_lightProbeTexture = texture; m_lightProbeHorzTile = hTile; m_lightProbeVertTile = vTile;
519 }
520 QRhiTexture *lightProbeTexture() const { return m_lightProbeTexture; }
522 {
523 return {m_lightProbeHorzTile, m_lightProbeVertTile};
524 }
525
526 void setScreenTexture(QRhiTexture *texture) { m_screenTexture = texture; }
527 QRhiTexture *screenTexture() const { return m_screenTexture; }
528
529 void setDepthTexture(QRhiTexture *texture) { m_depthTexture = texture; }
530 QRhiTexture *depthTexture() const { return m_depthTexture; }
531
532 void setNormalTexture(QRhiTexture *texture) { m_normalTexture = texture; }
533 QRhiTexture *normalTexture() const { return m_normalTexture; }
534
535 void setSsaoTexture(QRhiTexture *texture) { m_ssaoTexture = texture; }
536 QRhiTexture *ssaoTexture() const { return m_ssaoTexture; }
537
538 void setLightmapTexture(QRhiTexture *texture) { m_lightmapTexture = texture; }
539 QRhiTexture *lightmapTexture() const { return m_lightmapTexture; }
540
541 void setMotionVectorTexture(QRhiTexture *texture) { m_motionVectorTexture = texture; }
542 QRhiTexture *MotionVectorTexture() const { return m_motionVectorTexture; }
543 void setShadowMapAtlasTexture(QRhiTexture *texture) { m_shadowMapAtlasTexture = texture; }
544 QRhiTexture *shadowMapAtlasTexture() const { return m_shadowMapAtlasTexture; }
545
546 void setShadowMapBlueNoiseTexture(QRhiTexture *texture) { m_shadowMapBlueNoiseTexture = texture; }
547 QRhiTexture *shadowMapBlueNoiseTexture() const { return m_shadowMapBlueNoiseTexture; }
548
549 void setOITImages(QRhiTexture *accumulator, QRhiTexture *auxiliary, QRhiTexture *counter)
550 {
551 m_oitImages[0] = accumulator;
552 m_oitImages[1] = auxiliary;
553 m_oitImages[2] = counter;
554 }
555 QRhiTexture **oitImages() { return m_oitImages; }
556
557 void resetExtraTextures() { m_extraTextures.clear(); }
558 void addExtraTexture(const QSSGRhiTexture &t) { m_extraTextures.append(t); }
559 int extraTextureCount() const { return m_extraTextures.size(); }
560 const QSSGRhiTexture &extraTextureAt(int index) const { return m_extraTextures[index]; }
561 QSSGRhiTexture &extraTextureAt(int index) { return m_extraTextures[index]; }
562
564 {
565 int binding = 0;
568 QRhiBuffer *buffer = nullptr;
571 StorageResourceBinding(int binding, const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiBuffer *buffer)
572 : binding(binding), name(name), type(type), buffer(buffer), texture(nullptr) {}
573 StorageResourceBinding(int binding, const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiTexture *texture)
574 : binding(binding), name(name), type(type), buffer(nullptr), texture(texture) {}
575 };
576 using StorageBindingMap = QMap<int, StorageResourceBinding>;
577
578 void addStorageBufferBinding(const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiBuffer *buffer, int binding);
579 void addStorageImageBinding(const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiTexture *texture, int binding);
580 void applyAndClearStorageBindings(QRhiShaderResourceBinding::StageFlags stage, QSSGRhiShaderResourceBindingList &bindings);
581 const StorageBindingMap &storageBufferBindings() const { return m_storageBufferBindings; }
582 const StorageBindingMap &storageImageBindings() const { return m_storageImageBindings; }
583
584 QSSGShaderLightsUniformData &lightsUniformData() { return m_lightsUniformData; }
585 QSSGShaderDirectionalLightsUniformData &directionalLightsUniformData() { return m_directionalLightsUniformData; }
586 InstanceLocations instanceBufferLocations() const { return instanceLocations; }
587
588 int offsetOfUniform(const QByteArray &name);
589
590private:
591 QSSGRhiContext &m_context;
592 QVarLengthArray<QRhiShaderStage, 2> m_stages;
593 int m_ub0Size = 0;
594 int m_ub0NextUBufOffset = 0;
595 QHash<QByteArray, QShaderDescription::BlockVariable> m_ub0;
596 QHash<QSSGRhiInputAssemblerState::InputSemantic, QShaderDescription::InOutVariable> m_vertexInputs;
597 QHash<QByteArray, QShaderDescription::InOutVariable> m_combinedImageSamplers;
598 QHash<QByteArray, QShaderDescription::InOutVariable> m_storageImages;
599 QHash<QByteArray, QShaderDescription::StorageBlock> m_storageBuffers;
600 int m_materialImageSamplerBindings[size_t(QSSGRhiSamplerBindingHints::BindingMapSize)];
601
602 QVarLengthArray<QSSGRhiShaderUniform, 32> m_uniforms; // members of the main (binding 0) uniform buffer
603 QVarLengthArray<QSSGRhiShaderUniformArray, 8> m_uniformArrays;
604 QHash<QByteArray, size_t> m_uniformIndex; // Maps uniform name to index in m_uniforms and m_uniformArrays
605
606 // transient (per-object) data; pointers are all non-owning
607 bool m_lightsEnabled = false;
608 QSSGShaderLightsUniformData m_lightsUniformData;
609 QSSGShaderDirectionalLightsUniformData m_directionalLightsUniformData;
610 QRhiTexture *m_shadowMapAtlasTexture = nullptr;
611 QRhiTexture *m_shadowMapBlueNoiseTexture = nullptr;
612 QRhiTexture *m_lightProbeTexture = nullptr;
613 QSSGRenderTextureCoordOp m_lightProbeHorzTile = QSSGRenderTextureCoordOp::ClampToEdge;
614 QSSGRenderTextureCoordOp m_lightProbeVertTile = QSSGRenderTextureCoordOp::ClampToEdge;
615 QRhiTexture *m_screenTexture = nullptr;
616 QRhiTexture *m_depthTexture = nullptr;
617 QRhiTexture *m_normalTexture = nullptr;
618 QRhiTexture *m_ssaoTexture = nullptr;
619 QRhiTexture *m_lightmapTexture = nullptr;
620 QRhiTexture *m_oitImages[3] = {nullptr};
621 QRhiTexture *m_motionVectorTexture = nullptr;
622 QVarLengthArray<QSSGRhiTexture, 8> m_extraTextures;
623
624 QMap<int, StorageResourceBinding> m_storageImageBindings;
625 QMap<int, StorageResourceBinding> m_storageBufferBindings;
626};
627
628Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRhiShaderPipeline::StageFlags)
629Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRhiShaderPipeline::UniformFlags)
630
631using QSSGRhiShaderPipelinePtr = std::shared_ptr<QSSGRhiShaderPipeline>;
632
633class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiShaderResourceBindingList
634{
635public:
636 static const int MAX_SIZE = 32;
637
638 int p = 0;
639 size_t h = 0;
640 QRhiShaderResourceBinding v[MAX_SIZE];
641
642 void clear() { p = 0; h = 0; }
643
644 QSSGRhiShaderResourceBindingList() { }
645
646 QSSGRhiShaderResourceBindingList(const QSSGRhiShaderResourceBindingList &other)
647 : p(other.p),
648 h(other.h)
649 {
650 for (int i = 0; i < p; ++i)
651 v[i] = other.v[i];
652 }
653
654 QSSGRhiShaderResourceBindingList &operator=(const QSSGRhiShaderResourceBindingList &other) Q_DECL_NOTHROW
655 {
656 if (this != &other) {
657 p = other.p;
658 h = other.h;
659 for (int i = 0; i < p; ++i)
660 v[i] = other.v[i];
661 }
662 return *this;
663 }
664
665 void addUniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset = 0 , int size = 0, bool hasDynamicOffset = false);
666 void addTexture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler);
667 void addImageLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level);
668 void addImageStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level);
669 void addImageLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level);
670 void addStorageBufferLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset = 0 , int size = 0);
671 void addStorageBufferStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset = 0 , int size = 0);
672 void addStorageBufferLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset = 0 , int size = 0);
673private:
674 void fillImage(QRhiShaderResourceBinding::Data *d, QRhiShaderResourceBinding::Type t, int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level);
675 void fillStorageBuffer(QRhiShaderResourceBinding::Data *d, QRhiShaderResourceBinding::Type t, int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int size);
676 QRhiShaderResourceBinding::Data *newBinding();
677};
678
679inline bool operator==(const QSSGRhiShaderResourceBindingList &a, const QSSGRhiShaderResourceBindingList &b) Q_DECL_NOTHROW
680{
681 if (a.h != b.h)
682 return false;
683 if (a.p != b.p)
684 return false;
685 for (int i = 0; i < a.p; ++i) {
686 if (a.v[i] != b.v[i])
687 return false;
688 }
689 return true;
690}
691
692inline bool operator!=(const QSSGRhiShaderResourceBindingList &a, const QSSGRhiShaderResourceBindingList &b) Q_DECL_NOTHROW
693{
694 return !(a == b);
695}
696
697inline size_t qHash(const QSSGRhiShaderResourceBindingList &bl, size_t seed) Q_DECL_NOTHROW
698{
699 return bl.h ^ seed;
700}
701
702struct QSSGRhiDrawCallData
703{
704 QRhiBuffer *ubuf = nullptr; // owned
705 QRhiShaderResourceBindings *srb = nullptr; // not owned
706 QSSGRhiShaderResourceBindingList bindings;
707 QRhiGraphicsPipeline *pipeline = nullptr; // not owned
708 size_t renderTargetDescriptionHash = 0;
709 QVector<quint32> renderTargetDescription;
710 QSSGRhiGraphicsPipelineState ps;
711
712 void reset()
713 {
714 delete ubuf;
715 ubuf = nullptr;
716 srb = nullptr;
717 pipeline = nullptr;
718 }
719};
720
721class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGManagedRhiTexture
722{
723 enum class Private { Initialize };
724 Q_DISABLE_COPY(QSSGManagedRhiTexture)
725public:
726 using Ptr = std::unique_ptr<QSSGManagedRhiTexture>;
727
728 const std::unique_ptr<QRhiTexture> &texture() const { return m_texture; }
729
730 [[nodiscard]] bool isValid() const { return m_texture != nullptr; }
731
732 QSSGManagedRhiTexture() = default;
733 QSSGManagedRhiTexture(const std::shared_ptr<QSSGUserRenderPassManager> &manager, QRhiTexture *texture, Private);
734 QSSGManagedRhiTexture(const std::shared_ptr<QSSGUserRenderPassManager> &manager, std::unique_ptr<QRhiTexture> texture);
735 ~QSSGManagedRhiTexture();
736
737 [[nodiscard]] static Ptr make_copy(const Ptr &other)
738 {
739 return std::make_unique<QSSGManagedRhiTexture>(other->m_manager, other->m_texture.get(), Private::Initialize);
740 }
741
742private:
743 friend class QSSGRhiRenderableTextureV2;
744 friend class QSSGUserRenderPassManager;
745
746 void invalidate();
747
748 std::shared_ptr<QSSGUserRenderPassManager> m_manager;
749 std::unique_ptr<QRhiTexture> m_texture;
750};
751
752using QSSGManagedRhiTexturePtr = QSSGManagedRhiTexture::Ptr;
753
755{
756 enum class Private { Initialize };
757public:
758 QSSGRhiRenderableTextureV2(const std::shared_ptr<QSSGUserRenderPassManager> &manager, Private)
759 : m_manager(manager)
760 {
761 }
763
764 void setDescription(QRhi *rhi, QRhiTextureRenderTargetDescription rtDesc, QRhiTextureRenderTarget::Flags = {});
765
766 void setName(const QByteArray &name) { rtName = name; }
767 const QByteArray &getName() const { return rtName; }
768
769 const QSSGManagedRhiTexturePtr &getDepthTexture() const { return depthTexture; }
770 const std::unique_ptr<QRhiRenderBuffer> &getDepthStencil() const { return depthStencil; }
773
774 size_t colorAttachmentCount() const { return textures.size(); }
775 const QSSGManagedRhiTexturePtr &getColorTexture(int index) const { return textures[index]; }
776
777 bool isValid() const { return (textures.size() > 0) && rt && rpDesc; }
778
779 void finialize(QRhi *rhi);
780
781 void resetRenderTarget();
782 void reset();
783
784private:
785 friend class QSSGUserRenderPassManager;
786
787 enum Dirty : quint32
788 {
789 ColorTextureDirty = 0x1,
790 DepthStencilDirty = 0x2,
791 DepthTextureDirty = 0x4,
792 };
793
794 void invalidate();
795
797
798 std::shared_ptr<QSSGUserRenderPassManager> m_manager;
799
800 QVarLengthArray<QSSGManagedRhiTexturePtr, 4> textures {};
801 std::unique_ptr<QRhiRenderBuffer> depthStencil;
802 QSSGManagedRhiTexturePtr depthTexture; // either depthStencil or depthTexture are valid, never both
803
804 std::unique_ptr<QRhiRenderPassDescriptor> rpDesc;
805 std::unique_ptr<QRhiTextureRenderTarget> rt;
806 QByteArray rtName;
807 DirtyT dirty = 0;
808};
809
810using QSSGRhiRenderableTextureV2Ptr = std::shared_ptr<QSSGRhiRenderableTextureV2>;
811
813{
816 QRhiTexture *depthTexture = nullptr; // either depthStencil or depthTexture are valid, never both
819 bool isValid() const { return texture && rpDesc && rt; }
821 delete rt;
822 rt = nullptr;
823 delete rpDesc;
824 rpDesc = nullptr;
825 }
826 void reset() {
828 delete texture;
829 delete depthStencil;
830 delete depthTexture;
831 *this = QSSGRhiRenderableTexture();
832 }
833};
834
836{
837 float d = 0.0f;
839};
840
853
864
866{
867public:
870 struct {
872 } extra;
873 static QSSGComputePipelineStateKey create(const QShader &shader,
874 const QRhiShaderResourceBindings *srb)
875 {
876 const QVector<quint32> srbDesc = srb->serializedLayoutDescription();
877 return { shader, srbDesc, { qHash(srbDesc) } };
878 }
879};
880
881inline bool operator==(const QSSGComputePipelineStateKey &a, const QSSGComputePipelineStateKey &b) Q_DECL_NOTHROW
882{
883 return a.shader == b.shader && a.srbLayoutDescription == b.srbLayoutDescription;
884}
885
886inline bool operator!=(const QSSGComputePipelineStateKey &a, const QSSGComputePipelineStateKey &b) Q_DECL_NOTHROW
887{
888 return !(a == b);
889}
890
891inline size_t qHash(const QSSGComputePipelineStateKey &k, size_t seed = 0) Q_DECL_NOTHROW
892{
893 return qHash(k.shader, seed) ^ k.extra.srbLayoutDescriptionHash;
894}
895
896struct QSSGRhiDummyTextureKey
897{
898 QRhiTexture::Flags flags;
899 QSize size;
900 QColor color;
901 int arraySize;
902};
903
904inline size_t qHash(const QSSGRhiDummyTextureKey &k, size_t seed) Q_DECL_NOTHROW
905{
906 return qHash(k.flags, seed)
907 ^ qHash(k.size.width() ^ k.size.height() ^ k.color.red() ^ k.color.green()
908 ^ k.color.blue() ^ k.color.alpha() ^ k.arraySize);
909}
910
911inline bool operator==(const QSSGRhiDummyTextureKey &a, const QSSGRhiDummyTextureKey &b) Q_DECL_NOTHROW
912{
913 return a.flags == b.flags && a.size == b.size && a.color == b.color && a.arraySize == b.arraySize;
914}
915
916inline bool operator!=(const QSSGRhiDummyTextureKey &a, const QSSGRhiDummyTextureKey &b) Q_DECL_NOTHROW
917{
918 return !(a == b);
919}
920
921class QSSGGraphicsPipelineStateKey
922{
923public:
924 QSSGRhiGraphicsPipelineState state;
925 QVector<quint32> renderTargetDescription;
926 QVector<quint32> srbLayoutDescription;
927 struct {
928 size_t renderTargetDescriptionHash;
929 size_t srbLayoutDescriptionHash;
930 } extra;
931 static QSSGGraphicsPipelineStateKey create(const QSSGRhiGraphicsPipelineState &state,
932 const QRhiRenderPassDescriptor *rpDesc,
933 const QRhiShaderResourceBindings *srb)
934 {
935 const QVector<quint32> rtDesc = rpDesc->serializedFormat();
936 const QVector<quint32> srbDesc = srb->serializedLayoutDescription();
937 return { state, rtDesc, srbDesc, { qHash(rtDesc), qHash(srbDesc) } };
938 }
939};
940
941inline bool operator==(const QSSGGraphicsPipelineStateKey &a, const QSSGGraphicsPipelineStateKey &b) Q_DECL_NOTHROW
942{
943 return a.state == b.state
944 && a.renderTargetDescription == b.renderTargetDescription
945 && a.srbLayoutDescription == b.srbLayoutDescription;
946}
947
948inline bool operator!=(const QSSGGraphicsPipelineStateKey &a, const QSSGGraphicsPipelineStateKey &b) Q_DECL_NOTHROW
949{
950 return !(a == b);
951}
952
953inline size_t qHash(const QSSGGraphicsPipelineStateKey &k, size_t seed) Q_DECL_NOTHROW
954{
955 return qHash(k.state, seed)
956 ^ k.extra.renderTargetDescriptionHash
957 ^ k.extra.srbLayoutDescriptionHash;
958}
959
960#define QSSGRHICTX_STAT(ctx, f)
961 for (bool qssgrhictxlog_enabled = QSSGRhiContextStats::get(*ctx).isEnabled(); qssgrhictxlog_enabled; qssgrhictxlog_enabled = false)
962 QSSGRhiContextStats::get(*ctx).f
963
964class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiContextStats
965{
966public:
967 [[nodiscard]] static QSSGRhiContextStats &get(QSSGRhiContext &rhiCtx);
968 [[nodiscard]] static const QSSGRhiContextStats &get(const QSSGRhiContext &rhiCtx);
969
970 struct DrawInfo {
971 quint64 callCount = 0;
972 quint64 vertexOrIndexCount = 0;
973 };
974 struct InstancedDrawInfo {
975 quint64 callCount = 0;
976 quint64 vertexOrIndexCount = 0;
977 quint64 instanceCount = 0;
978 };
979 struct RenderPassInfo {
980 QByteArray rtName;
981 QSize pixelSize;
982 DrawInfo indexedDraws;
983 DrawInfo draws;
984 InstancedDrawInfo instancedIndexedDraws;
985 InstancedDrawInfo instancedDraws;
986 };
987 struct PerLayerInfo {
988 PerLayerInfo()
989 {
990 externalRenderPass.rtName = QByteArrayLiteral("Qt Quick");
991 }
992
993 // The main render pass if renderMode==Offscreen, plus render passes
994 // for shadow maps, postprocessing effects, etc.
995 QVector<RenderPassInfo> renderPasses;
996
997 // An Underlay/Overlay/Inline renderMode will make the View3D add stuff
998 // to a render pass managed by Qt Quick. (external == not under the
999 // control of Qt Quick 3D)
1000 RenderPassInfo externalRenderPass;
1001
1002 int currentRenderPassIndex = -1;
1003 };
1004 struct GlobalInfo { // global as in per QSSGRhiContext which is per-QQuickWindow
1005 quint64 meshDataSize = 0;
1006 quint64 imageDataSize = 0;
1007 qint64 materialGenerationTime = 0;
1008 qint64 effectGenerationTime = 0;
1009 };
1010
1011 QHash<QSSGRenderLayer *, PerLayerInfo> perLayerInfo;
1012 GlobalInfo globalInfo;
1013
1014 QSSGRhiContextStats(QSSGRhiContext &context)
1015 : rhiCtx(&context)
1016 {
1017 }
1018
1019 // The data collected have four consumers:
1020 //
1021 // - Printed on debug output when QSG_RENDERER_DEBUG has the relevant key.
1022 // (this way the debug output from the 2D scenegraph renderer and these 3D
1023 // statistics appear nicely intermixed)
1024 // - Passed on to the QML profiler when profiling is enabled.
1025 // - DebugView via QQuick3DRenderStats.
1026 // - When tracing is enabled
1027 //
1028 // The first two are enabled globally, but DebugView needs a dynamic
1029 // enable/disable since we want to collect data when a DebugView item
1030 // becomes visible, but not otherwise.
1031
1032 static bool profilingEnabled();
1033 static bool rendererDebugEnabled();
1034
1035 bool isEnabled() const;
1036 void drawIndexed(quint32 indexCount, quint32 instanceCount);
1037 void draw(quint32 vertexCount, quint32 instanceCount);
1038
1039 void meshDataSizeChanges(quint64 newSize) // can be called outside start-stop
1040 {
1041 globalInfo.meshDataSize = newSize;
1042 }
1043
1044 void imageDataSizeChanges(quint64 newSize) // can be called outside start-stop
1045 {
1046 globalInfo.imageDataSize = newSize;
1047 }
1048
1049 void registerMaterialShaderGenerationTime(qint64 ms)
1050 {
1051 globalInfo.materialGenerationTime += ms;
1052 }
1053
1054 void registerEffectShaderGenerationTime(qint64 ms)
1055 {
1056 globalInfo.effectGenerationTime += ms;
1057 }
1058
1059 static quint64 totalDrawCallCountForPass(const QSSGRhiContextStats::RenderPassInfo &pass)
1060 {
1061 return pass.draws.callCount
1062 + pass.indexedDraws.callCount
1063 + pass.instancedDraws.callCount
1064 + pass.instancedIndexedDraws.callCount;
1065 }
1066
1067 static quint64 totalVertexCountForPass(const QSSGRhiContextStats::RenderPassInfo &pass)
1068 {
1069 return pass.draws.vertexOrIndexCount
1070 + pass.indexedDraws.vertexOrIndexCount
1071 + pass.instancedDraws.vertexOrIndexCount
1072 + pass.instancedIndexedDraws.vertexOrIndexCount;
1073 }
1074
1075 void start(QSSGRenderLayer *layer);
1076 void stop(QSSGRenderLayer *layer);
1077 void beginRenderPass(QRhiTextureRenderTarget *rt);
1078 void endRenderPass();
1079 void printRenderPass(const RenderPassInfo &rp);
1080 void cleanupLayerInfo(QSSGRenderLayer *layer);
1081
1082 QSSGRhiContext *rhiCtx;
1083 QSSGRenderLayer *layerKey = nullptr;
1084 QSet<QSSGRenderLayer *> dynamicDataSources;
1085};
1086
1087class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiContextPrivate
1088{
1089 Q_DECLARE_PUBLIC(QSSGRhiContext)
1090
1091 explicit QSSGRhiContextPrivate(QSSGRhiContext &rhiCtx, QRhi *rhi_)
1092 : q_ptr(&rhiCtx)
1093 , m_rhi(rhi_)
1094 , m_stats(rhiCtx)
1095 {}
1096
1097public:
1098 using Textures = QSet<QRhiTexture *>;
1099 using Meshes = QSet<QSSGRenderMesh *>;
1100
1101 [[nodiscard]] static QSSGRhiContextPrivate *get(QSSGRhiContext *q) { return q->d_ptr.get(); }
1102 [[nodiscard]] static const QSSGRhiContextPrivate *get(const QSSGRhiContext *q) { return q->d_ptr.get(); }
1103
1104 [[nodiscard]] static bool shaderDebuggingEnabled();
1105 [[nodiscard]] static bool editorMode();
1106
1107 void setMainRenderPassDescriptor(QRhiRenderPassDescriptor *rpDesc);
1108 void setCommandBuffer(QRhiCommandBuffer *cb);
1109 void setRenderTarget(QRhiRenderTarget *rt);
1110 void setMainPassSampleCount(int samples);
1111 void setMainPassViewCount(int viewCount);
1112
1113 void releaseCachedResources();
1114
1115 void registerTexture(QRhiTexture *texture);
1116 void releaseTexture(QRhiTexture *texture);
1117
1118 void registerMesh(QSSGRenderMesh *mesh);
1119 void releaseMesh(QSSGRenderMesh *mesh);
1120
1121 QRhiShaderResourceBindings *srb(const QSSGRhiShaderResourceBindingList &bindings);
1122 void releaseCachedSrb(QSSGRhiShaderResourceBindingList &bindings);
1123
1124 QRhiGraphicsPipeline *pipeline(const QSSGRhiGraphicsPipelineState &ps,
1125 QRhiRenderPassDescriptor *rpDesc,
1126 QRhiShaderResourceBindings *srb);
1127
1128 QRhiGraphicsPipeline *pipeline(const QSSGGraphicsPipelineStateKey &key,
1129 QRhiRenderPassDescriptor *rpDesc,
1130 QRhiShaderResourceBindings *srb);
1131
1132 QRhiComputePipeline *computePipeline(const QShader &shader,
1133 QRhiShaderResourceBindings *srb);
1134
1136 QRhiShaderResourceBindings *srb);
1137
1138 QSSGRhiDrawCallData &drawCallData(const QSSGRhiDrawCallDataKey &key);
1139 void releaseDrawCallData(QSSGRhiDrawCallData &dcd);
1140 void cleanupDrawCallData(const QSSGRenderModel *model);
1141 void cleanupDrawCallDataForResource(const void *resource);
1142 void cleanupDrawCallDataForCid(const void *cid);
1143 void cleanupDrawCallDataForSkyMaterial(QSSGRenderSkyMaterial *skyMaterial);
1144
1145 QSSGRhiInstanceBufferData &instanceBufferData(QSSGRenderInstanceTable *instanceTable);
1146 void releaseInstanceBuffer(QSSGRenderInstanceTable *instanceTable);
1147
1148 QSSGRhiInstanceBufferData &instanceBufferData(const QSSGRenderModel *model);
1149
1150 QSSGRhiParticleData &particleData(const QSSGRenderGraphObject *particlesOrModel);
1151
1152 QSSGRhiContext *q_ptr = nullptr;
1153 QRhi *m_rhi = nullptr;
1154
1162
1164
1174};
1175
1176inline bool operator==(const QSSGRhiDrawCallDataKey &a, const QSSGRhiDrawCallDataKey &b) noexcept
1177{
1178 return a.cid == b.cid && a.model == b.model && a.resource == b.resource && a.mapEntry == b.mapEntry
1179 && a.resourceIdx == b.resourceIdx;
1180}
1181
1182inline bool operator!=(const QSSGRhiDrawCallDataKey &a, const QSSGRhiDrawCallDataKey &b) noexcept
1183{
1184 return !(a == b);
1185}
1186
1187inline size_t qHash(const QSSGRhiDrawCallDataKey &k, size_t seed = 0) noexcept
1188{
1189 return qHashMulti(seed, k.cid, k.model, k.resource, k.mapEntry, k.resourceIdx);
1190}
1191
1192QT_END_NAMESPACE
1193
1194#endif // QSSGRHICONTEXT_P_H
friend bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are equal, otherwise returns false.
Definition qbytearray.h:842
friend bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are different, otherwise returns false.
Definition qbytearray.h:853
QObject * q_ptr
Definition qobject.h:73
Q_DECLARE_FLAGS(InitFlags, InitFlag)
static QSSGComputePipelineStateKey create(const QShader &shader, const QRhiShaderResourceBindings *srb)
QVector< quint32 > srbLayoutDescription
QRhiBuffer * buffer() const
QRhiCommandBuffer::IndexFormat indexFormat() const
quint32 stride() const
quint32 numVertices() const
void setMainRenderPassDescriptor(QRhiRenderPassDescriptor *rpDesc)
void releaseInstanceBuffer(QSSGRenderInstanceTable *instanceTable)
QSSGRhiInstanceBufferData & instanceBufferData(const QSSGRenderModel *model)
void releaseDrawCallData(QSSGRhiDrawCallData &dcd)
QRhiRenderPassDescriptor * m_mainRpDesc
QRhiShaderResourceBindings * srb(const QSSGRhiShaderResourceBindingList &bindings)
QSSGRhiDrawCallData & drawCallData(const QSSGRhiDrawCallDataKey &key)
QRhiGraphicsPipeline * pipeline(const QSSGRhiGraphicsPipelineState &ps, QRhiRenderPassDescriptor *rpDesc, QRhiShaderResourceBindings *srb)
void cleanupDrawCallDataForCid(const void *cid)
void releaseCachedSrb(QSSGRhiShaderResourceBindingList &bindings)
void releaseMesh(QSSGRenderMesh *mesh)
QRhiComputePipeline * computePipeline(const QSSGComputePipelineStateKey &key, QRhiShaderResourceBindings *srb)
QHash< QSSGRenderInstanceTable *, QSSGRhiInstanceBufferData > m_instanceBuffers
void setCommandBuffer(QRhiCommandBuffer *cb)
QVector< QPair< QSSGRhiSamplerDescription, QRhiSampler * > > m_samplers
void setMainPassSampleCount(int samples)
QRhiRenderTarget * m_rt
void cleanupDrawCallData(const QSSGRenderModel *model)
QHash< const QSSGRenderGraphObject *, QSSGRhiParticleData > m_particleData
QSSGRhiContextStats m_stats
void cleanupDrawCallDataForResource(const void *resource)
QHash< const QSSGRenderModel *, QSSGRhiInstanceBufferData > m_instanceBuffersLod
QHash< QSSGRhiDummyTextureKey, QRhiTexture * > m_dummyTextures
void registerMesh(QSSGRenderMesh *mesh)
static bool shaderDebuggingEnabled()
QSSGRhiParticleData & particleData(const QSSGRenderGraphObject *particlesOrModel)
void setRenderTarget(QRhiRenderTarget *rt)
QHash< QSSGRhiShaderResourceBindingList, QRhiShaderResourceBindings * > m_srbCache
QHash< QSSGRhiDrawCallDataKey, QSSGRhiDrawCallData > m_drawCallData
void setMainPassViewCount(int viewCount)
QRhiCommandBuffer * m_cb
QRhiComputePipeline * computePipeline(const QShader &shader, QRhiShaderResourceBindings *srb)
QHash< QSSGComputePipelineStateKey, QRhiComputePipeline * > m_computePipelines
QHash< QSSGGraphicsPipelineStateKey, QRhiGraphicsPipeline * > m_pipelines
void cleanupDrawCallDataForSkyMaterial(QSSGRenderSkyMaterial *skyMaterial)
QSSGRhiInstanceBufferData & instanceBufferData(QSSGRenderInstanceTable *instanceTable)
const QSSGManagedRhiTexturePtr & getColorTexture(int index) const
const std::unique_ptr< QRhiRenderPassDescriptor > & getRenderPassDescriptor() const
void setName(const QByteArray &name)
const std::unique_ptr< QRhiTextureRenderTarget > & getRenderTarget() const
const std::unique_ptr< QRhiRenderBuffer > & getDepthStencil() const
const QByteArray & getName() const
const QSSGManagedRhiTexturePtr & getDepthTexture() const
void setUniformValue(char *ubufData, const char *name, const QVariant &value, QSSGRenderShaderValue::Type type)
const QRhiShaderStage * cendStages() const
QRhiTexture * ssaoTexture() const
const QHash< QSSGRhiInputAssemblerState::InputSemantic, QShaderDescription::InOutVariable > & vertexInputs() const
QRhiTexture * lightProbeTexture() const
QRhiTexture * shadowMapAtlasTexture() const
void applyAndClearStorageBindings(QRhiShaderResourceBinding::StageFlags stage, QSSGRhiShaderResourceBindingList &bindings)
int bindingForStorageImage(QByteArrayView name)
QPair< QSSGRenderTextureCoordOp, QSSGRenderTextureCoordOp > lightProbeTiling() const
InstanceLocations instanceBufferLocations() const
const StorageBindingMap & storageImageBindings() const
int bindingForStorageBuffer(QByteArrayView name)
void addStage(const QRhiShaderStage &stage, StageFlags flags={})
QRhiTexture * screenTexture() const
void ensureUniformBuffer(QRhiBuffer **ubuf)
QRhiTexture * MotionVectorTexture() const
QRhiTexture * shadowMapBlueNoiseTexture() const
const QRhiShaderStage * cbeginStages() const
const QRhiShaderStage * fragmentStage() const
QRhiTexture * depthTexture() const
void addExtraTexture(const QSSGRhiTexture &t)
void addStorageBufferBinding(const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiBuffer *buffer, int binding)
void setLightsEnabled(bool enable)
QSSGShaderDirectionalLightsUniformData & directionalLightsUniformData()
int offsetOfUniform(const QByteArray &name)
int bindingForTexture(const char *name, int hint=-1)
void ensureCombinedUniformBuffer(QRhiBuffer **ubuf)
void setShaderResources(char *ubufData, QSSGBufferManager &theBufferManager, const QByteArray &inPropertyName, const QVariant &propertyValue, QSSGRenderShaderValue::Type inPropertyType)
QRhiTexture ** oitImages()
void setUniformArray(char *ubufData, const char *name, const void *data, size_t itemCount, QSSGRenderShaderValue::Type type, int *storeIndex=nullptr)
QRhiTexture * normalTexture() const
int ub0DirectionalLightDataOffset() const
const QRhiShaderStage * vertexStage() const
QSSGShaderLightsUniformData & lightsUniformData()
void setUniform(char *ubufData, const char *name, const void *data, size_t size, int *storeIndex=nullptr, UniformFlags flags={})
QRhiTexture * lightmapTexture() const
const QSSGRhiTexture & extraTextureAt(int index) const
const StorageBindingMap & storageBufferBindings() const
QRhiVertexInputAttribute::Format toVertexInputFormat(QSSGRenderComponentType compType, quint32 numComps)
QRhiGraphicsPipeline::CullMode toCullMode(QSSGCullFaceMode cullFaceMode)
QRhiGraphicsPipeline::Topology toTopology(QSSGRenderDrawMode drawMode)
QRhiSampler::Filter toRhi(QSSGRenderTextureFilterOp op)
Combined button and popup list for selecting options.
static bool skyIblCreatePrefilterTargets(QRhi *rhi, QRhiTexture *texture, const QSize &environmentMapSize, const QByteArray &namePrefix, QSSGSkyIblPrefilterTargets *outTargets, bool preserveColorContents=false)
static constexpr QRhiTexture::Format cTextureFormat
static bool ensureSrb(QRhi *rhi, QRhiShaderResourceBindings *&dst, std::initializer_list< QRhiShaderResourceBinding > bindings, const char *errorMessage)
static bool skyIblCreateFaceTargets(QRhi *rhi, QRhiTexture *texture, const QByteArray &namePrefix, QSSGSkyIblFaceTargets *outTargets, bool preserveColorContents=false)
static QRhiGraphicsPipeline * createPrefilterPipeline(QRhi *rhi, const QRhiVertexInputLayout &inputLayout, const PrefilterPipelineConfig &cfg, const char *errorMessage)
static void drawCubeFace(QRhiCommandBuffer *cb, QSSGRhiContext *ctx, QRhiTextureRenderTarget *rt, QSize viewport, QRhiGraphicsPipeline *pipeline, QRhiShaderResourceBindings *srb, const QRhiCommandBuffer::VertexInput &vbufBinding, const QVector< QPair< int, quint32 > > &dynamicOffsets, const QByteArray &profilerLabel, const QByteArray &passDebugLabel, const QColor &clearColor=QColor(0, 0, 0, 1))
static void skyIblInitializeUnrenderedMips(QRhi *rhi, QRhiCommandBuffer *cb, QSSGRhiContext *context, QRhiTexture *texture, int firstMip, int mipCountExclusive, const QByteArray &debugObjectName)
static bool ensureDynamicUBuf(QRhi *rhi, QRhiBuffer *&dst, int size, const char *errorMessage)
static QVarLengthArray< QMatrix4x4, 6 > skyIblEnvironmentMapViews(QRhi *rhi)
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
Definition qsize.h:192
#define QSSGRHICTX_STAT(ctx, f)
#define QSSG_MAX_NUM_LIGHTS
#define QSSG_MAX_NUM_DIRECTIONAL_LIGHTS
QSSGRhiSamplerBindingHints
static constexpr const QSSGRhiShaderPipeline * getShaderPipeline(const QSSGRhiGraphicsPipelineState &ps)
static const InputAssemblerState & get(const QSSGRhiGraphicsPipelineState &ps)
static InputAssemblerState & get(QSSGRhiGraphicsPipelineState &ps)
QList< QSSGRhiSortData > sortData
QList< QSSGRhiSortData > sortData
QRhiTextureRenderTarget * rt
QRhiRenderPassDescriptor * rpDesc
QRhiRenderBuffer * depthStencil
QVarLengthArray< ImageIndices, 16 > imageIndices
StorageResourceBinding(int binding, const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiBuffer *buffer)
QSSGShaderDirectionalLightData directionalLightData[QSSG_MAX_NUM_DIRECTIONAL_LIGHTS]
QSSGShaderLightData lightData[QSSG_MAX_NUM_LIGHTS]