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 }
410 for (const QRhiShaderStage &s : m_stages) {
411 if (s.type() == QRhiShaderStage::Compute)
412 return &s;
413 }
414 return nullptr;
415 }
416
417 int ub0Size() const { return m_ub0Size; }
418 int ub0LightDataOffset() const { return m_ub0NextUBufOffset; }
420
422
423 // This struct is used purely for performance. It is used to quickly store
424 // and index common uniform names using the storeIndex argument in the
425 // setUniform method.
427 {
463 int pointSizeIdx = -1;
470 int fogColorIdx = -1;
478 int viewSize = -1;
479 int samples = -1;
480
487 } commonUniformIndices;
488
490 int transform0 = -1;
491 int transform1 = -1;
492 int transform2 = -1;
493 int color = -1;
494 int data = -1;
495 } instanceLocations;
496
497 enum class UniformFlag {
498 Mat3 = 0x01
499 };
500 Q_DECLARE_FLAGS(UniformFlags, UniformFlag)
501
502 void setUniformValue(char *ubufData, const char *name, const QVariant &value, QSSGRenderShaderValue::Type type);
503 void setUniform(char *ubufData, const char *name, const void *data, size_t size, int *storeIndex = nullptr, UniformFlags flags = {});
504 void setUniformArray(char *ubufData, const char *name, const void *data, size_t itemCount, QSSGRenderShaderValue::Type type, int *storeIndex = nullptr);
505 int bindingForTexture(const char *name, int hint = -1);
506 int bindingForStorageImage(QByteArrayView name);
507 int bindingForStorageBuffer(QByteArrayView name);
508
509 void setShaderResources(char *ubufData,
510 QSSGBufferManager &theBufferManager,
511 const QByteArray &inPropertyName,
512 const QVariant &propertyValue,
513 QSSGRenderShaderValue::Type inPropertyType);
514
515 void setLightsEnabled(bool enable) { m_lightsEnabled = enable; }
516 bool isLightingEnabled() const { return m_lightsEnabled; }
517
518 void ensureCombinedUniformBuffer(QRhiBuffer **ubuf);
519 void ensureUniformBuffer(QRhiBuffer **ubuf);
520
521 void setLightProbeTexture(QRhiTexture *texture,
522 QSSGRenderTextureCoordOp hTile = QSSGRenderTextureCoordOp::ClampToEdge,
523 QSSGRenderTextureCoordOp vTile = QSSGRenderTextureCoordOp::ClampToEdge)
524 {
525 m_lightProbeTexture = texture; m_lightProbeHorzTile = hTile; m_lightProbeVertTile = vTile;
526 }
527 QRhiTexture *lightProbeTexture() const { return m_lightProbeTexture; }
529 {
530 return {m_lightProbeHorzTile, m_lightProbeVertTile};
531 }
532
533 void setScreenTexture(QRhiTexture *texture) { m_screenTexture = texture; }
534 QRhiTexture *screenTexture() const { return m_screenTexture; }
535
536 void setDepthTexture(QRhiTexture *texture) { m_depthTexture = texture; }
537 QRhiTexture *depthTexture() const { return m_depthTexture; }
538
539 void setNormalTexture(QRhiTexture *texture) { m_normalTexture = texture; }
540 QRhiTexture *normalTexture() const { return m_normalTexture; }
541
542 void setSsaoTexture(QRhiTexture *texture) { m_ssaoTexture = texture; }
543 QRhiTexture *ssaoTexture() const { return m_ssaoTexture; }
544
545 void setLightmapTexture(QRhiTexture *texture) { m_lightmapTexture = texture; }
546 QRhiTexture *lightmapTexture() const { return m_lightmapTexture; }
547
548 void setMotionVectorTexture(QRhiTexture *texture) { m_motionVectorTexture = texture; }
549 QRhiTexture *MotionVectorTexture() const { return m_motionVectorTexture; }
550 void setShadowMapAtlasTexture(QRhiTexture *texture) { m_shadowMapAtlasTexture = texture; }
551 QRhiTexture *shadowMapAtlasTexture() const { return m_shadowMapAtlasTexture; }
552
553 void setShadowMapBlueNoiseTexture(QRhiTexture *texture) { m_shadowMapBlueNoiseTexture = texture; }
554 QRhiTexture *shadowMapBlueNoiseTexture() const { return m_shadowMapBlueNoiseTexture; }
555
556 void setOITImages(QRhiTexture *accumulator, QRhiTexture *auxiliary, QRhiTexture *counter)
557 {
558 m_oitImages[0] = accumulator;
559 m_oitImages[1] = auxiliary;
560 m_oitImages[2] = counter;
561 }
562 QRhiTexture **oitImages() { return m_oitImages; }
563
564 void resetExtraTextures() { m_extraTextures.clear(); }
565 void addExtraTexture(const QSSGRhiTexture &t) { m_extraTextures.append(t); }
566 int extraTextureCount() const { return m_extraTextures.size(); }
567 const QSSGRhiTexture &extraTextureAt(int index) const { return m_extraTextures[index]; }
568 QSSGRhiTexture &extraTextureAt(int index) { return m_extraTextures[index]; }
569
571 {
572 int binding = 0;
575 QRhiBuffer *buffer = nullptr;
578 StorageResourceBinding(int binding, const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiBuffer *buffer)
579 : binding(binding), name(name), type(type), buffer(buffer), texture(nullptr) {}
580 StorageResourceBinding(int binding, const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiTexture *texture)
581 : binding(binding), name(name), type(type), buffer(nullptr), texture(texture) {}
582 };
583 using StorageBindingMap = QMap<int, StorageResourceBinding>;
584
585 void addStorageBufferBinding(const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiBuffer *buffer, int binding);
586 void addStorageImageBinding(const QByteArray &name, QRhiShaderResourceBinding::Type type, QRhiTexture *texture, int binding);
587 void applyAndClearStorageBindings(QRhiShaderResourceBinding::StageFlags stage, QSSGRhiShaderResourceBindingList &bindings);
588 const StorageBindingMap &storageBufferBindings() const { return m_storageBufferBindings; }
589 const StorageBindingMap &storageImageBindings() const { return m_storageImageBindings; }
590
591 QSSGShaderLightsUniformData &lightsUniformData() { return m_lightsUniformData; }
592 QSSGShaderDirectionalLightsUniformData &directionalLightsUniformData() { return m_directionalLightsUniformData; }
593 InstanceLocations instanceBufferLocations() const { return instanceLocations; }
594
595 int offsetOfUniform(const QByteArray &name);
596
597private:
598 QSSGRhiContext &m_context;
599 QVarLengthArray<QRhiShaderStage, 2> m_stages;
600 int m_ub0Size = 0;
601 int m_ub0NextUBufOffset = 0;
602 QHash<QByteArray, QShaderDescription::BlockVariable> m_ub0;
603 QHash<QSSGRhiInputAssemblerState::InputSemantic, QShaderDescription::InOutVariable> m_vertexInputs;
604 QHash<QByteArray, QShaderDescription::InOutVariable> m_combinedImageSamplers;
605 QHash<QByteArray, QShaderDescription::InOutVariable> m_storageImages;
606 QHash<QByteArray, QShaderDescription::StorageBlock> m_storageBuffers;
607 int m_materialImageSamplerBindings[size_t(QSSGRhiSamplerBindingHints::BindingMapSize)];
608
609 QVarLengthArray<QSSGRhiShaderUniform, 32> m_uniforms; // members of the main (binding 0) uniform buffer
610 QVarLengthArray<QSSGRhiShaderUniformArray, 8> m_uniformArrays;
611 QHash<QByteArray, size_t> m_uniformIndex; // Maps uniform name to index in m_uniforms and m_uniformArrays
612
613 // transient (per-object) data; pointers are all non-owning
614 bool m_lightsEnabled = false;
615 QSSGShaderLightsUniformData m_lightsUniformData;
616 QSSGShaderDirectionalLightsUniformData m_directionalLightsUniformData;
617 QRhiTexture *m_shadowMapAtlasTexture = nullptr;
618 QRhiTexture *m_shadowMapBlueNoiseTexture = nullptr;
619 QRhiTexture *m_lightProbeTexture = nullptr;
620 QSSGRenderTextureCoordOp m_lightProbeHorzTile = QSSGRenderTextureCoordOp::ClampToEdge;
621 QSSGRenderTextureCoordOp m_lightProbeVertTile = QSSGRenderTextureCoordOp::ClampToEdge;
622 QRhiTexture *m_screenTexture = nullptr;
623 QRhiTexture *m_depthTexture = nullptr;
624 QRhiTexture *m_normalTexture = nullptr;
625 QRhiTexture *m_ssaoTexture = nullptr;
626 QRhiTexture *m_lightmapTexture = nullptr;
627 QRhiTexture *m_oitImages[3] = {nullptr};
628 QRhiTexture *m_motionVectorTexture = nullptr;
629 QVarLengthArray<QSSGRhiTexture, 8> m_extraTextures;
630
631 QMap<int, StorageResourceBinding> m_storageImageBindings;
632 QMap<int, StorageResourceBinding> m_storageBufferBindings;
633};
634
635Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRhiShaderPipeline::StageFlags)
636Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRhiShaderPipeline::UniformFlags)
637
638using QSSGRhiShaderPipelinePtr = std::shared_ptr<QSSGRhiShaderPipeline>;
639
640class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiShaderResourceBindingList
641{
642public:
643 static const int MAX_SIZE = 32;
644
645 int p = 0;
646 size_t h = 0;
647 QRhiShaderResourceBinding v[MAX_SIZE];
648
649 void clear() { p = 0; h = 0; }
650
651 QSSGRhiShaderResourceBindingList() { }
652
653 QSSGRhiShaderResourceBindingList(const QSSGRhiShaderResourceBindingList &other)
654 : p(other.p),
655 h(other.h)
656 {
657 for (int i = 0; i < p; ++i)
658 v[i] = other.v[i];
659 }
660
661 QSSGRhiShaderResourceBindingList &operator=(const QSSGRhiShaderResourceBindingList &other) Q_DECL_NOTHROW
662 {
663 if (this != &other) {
664 p = other.p;
665 h = other.h;
666 for (int i = 0; i < p; ++i)
667 v[i] = other.v[i];
668 }
669 return *this;
670 }
671
672 void addUniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset = 0 , int size = 0, bool hasDynamicOffset = false);
673 void addTexture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler);
674 void addImageLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level);
675 void addImageStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level);
676 void addImageLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level);
677 void addStorageBufferLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset = 0 , int size = 0);
678 void addStorageBufferStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset = 0 , int size = 0);
679 void addStorageBufferLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset = 0 , int size = 0);
680private:
681 template<QRhiShaderResourceBinding::Type T>
682 void fillImage(QRhiShaderResourceBinding::Data *d, int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level);
683 template<QRhiShaderResourceBinding::Type T>
684 void fillStorageBuffer(QRhiShaderResourceBinding::Data *d, int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int size);
685 QRhiShaderResourceBinding::Data *newBinding();
686};
687
688inline bool operator==(const QSSGRhiShaderResourceBindingList &a, const QSSGRhiShaderResourceBindingList &b) Q_DECL_NOTHROW
689{
690 if (a.h != b.h)
691 return false;
692 if (a.p != b.p)
693 return false;
694 for (int i = 0; i < a.p; ++i) {
695 if (a.v[i] != b.v[i])
696 return false;
697 }
698 return true;
699}
700
701inline bool operator!=(const QSSGRhiShaderResourceBindingList &a, const QSSGRhiShaderResourceBindingList &b) Q_DECL_NOTHROW
702{
703 return !(a == b);
704}
705
706inline size_t qHash(const QSSGRhiShaderResourceBindingList &bl, size_t seed) Q_DECL_NOTHROW
707{
708 return bl.h ^ seed;
709}
710
711struct QSSGRhiDrawCallData
712{
713 QRhiBuffer *ubuf = nullptr; // owned
714 QRhiShaderResourceBindings *srb = nullptr; // not owned
715 QSSGRhiShaderResourceBindingList bindings;
716 QRhiGraphicsPipeline *pipeline = nullptr; // not owned
717 size_t renderTargetDescriptionHash = 0;
718 QVector<quint32> renderTargetDescription;
719 QSSGRhiGraphicsPipelineState ps;
720
721 void reset()
722 {
723 delete ubuf;
724 ubuf = nullptr;
725 srb = nullptr;
726 pipeline = nullptr;
727 }
728};
729
730class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGManagedRhiTexture
731{
732 enum class Private { Initialize };
733 Q_DISABLE_COPY(QSSGManagedRhiTexture)
734public:
735 using Ptr = std::unique_ptr<QSSGManagedRhiTexture>;
736
737 const std::unique_ptr<QRhiTexture> &texture() const { return m_texture; }
738
739 [[nodiscard]] bool isValid() const { return m_texture != nullptr; }
740
741 QSSGManagedRhiTexture() = default;
742 QSSGManagedRhiTexture(const std::shared_ptr<QSSGUserRenderPassManager> &manager, QRhiTexture *texture, Private);
743 QSSGManagedRhiTexture(const std::shared_ptr<QSSGUserRenderPassManager> &manager, std::unique_ptr<QRhiTexture> texture);
744 ~QSSGManagedRhiTexture();
745
746 [[nodiscard]] static Ptr make_copy(const Ptr &other)
747 {
748 return std::make_unique<QSSGManagedRhiTexture>(other->m_manager, other->m_texture.get(), Private::Initialize);
749 }
750
751private:
752 friend class QSSGRhiRenderableTextureV2;
753 friend class QSSGUserRenderPassManager;
754
755 void invalidate();
756
757 std::shared_ptr<QSSGUserRenderPassManager> m_manager;
758 std::unique_ptr<QRhiTexture> m_texture;
759};
760
761using QSSGManagedRhiTexturePtr = QSSGManagedRhiTexture::Ptr;
762
764{
765 enum class Private { Initialize };
766public:
767 QSSGRhiRenderableTextureV2(const std::shared_ptr<QSSGUserRenderPassManager> &manager, Private)
768 : m_manager(manager)
769 {
770 }
772
773 void setDescription(QRhi *rhi, QRhiTextureRenderTargetDescription rtDesc, QRhiTextureRenderTarget::Flags = {});
774
775 void setName(const QByteArray &name) { rtName = name; }
776 const QByteArray &getName() const { return rtName; }
777
778 const QSSGManagedRhiTexturePtr &getDepthTexture() const { return depthTexture; }
779 const std::unique_ptr<QRhiRenderBuffer> &getDepthStencil() const { return depthStencil; }
782
783 size_t colorAttachmentCount() const { return textures.size(); }
784 const QSSGManagedRhiTexturePtr &getColorTexture(int index) const { return textures[index]; }
785
786 bool isValid() const { return (textures.size() > 0) && rt && rpDesc; }
787
788 void finialize(QRhi *rhi);
789
790 void resetRenderTarget();
791 void reset();
792
793private:
794 friend class QSSGUserRenderPassManager;
795
796 enum Dirty : quint32
797 {
798 ColorTextureDirty = 0x1,
799 DepthStencilDirty = 0x2,
800 DepthTextureDirty = 0x4,
801 };
802
803 void invalidate();
804
806
807 std::shared_ptr<QSSGUserRenderPassManager> m_manager;
808
809 QVarLengthArray<QSSGManagedRhiTexturePtr, 4> textures {};
810 std::unique_ptr<QRhiRenderBuffer> depthStencil;
811 QSSGManagedRhiTexturePtr depthTexture; // either depthStencil or depthTexture are valid, never both
812
813 std::unique_ptr<QRhiRenderPassDescriptor> rpDesc;
814 std::unique_ptr<QRhiTextureRenderTarget> rt;
815 QByteArray rtName;
816 DirtyT dirty = 0;
817};
818
819using QSSGRhiRenderableTextureV2Ptr = std::shared_ptr<QSSGRhiRenderableTextureV2>;
820
822{
825 QRhiTexture *depthTexture = nullptr; // either depthStencil or depthTexture are valid, never both
828 bool isValid() const { return texture && rpDesc && rt; }
830 delete rt;
831 rt = nullptr;
832 delete rpDesc;
833 rpDesc = nullptr;
834 }
835 void reset() {
837 delete texture;
838 delete depthStencil;
839 delete depthTexture;
840 *this = QSSGRhiRenderableTexture();
841 }
842};
843
845{
846 float d = 0.0f;
848};
849
862
873
875{
876public:
879 struct {
880 size_t srbLayoutDescriptionHash;
881 } extra;
882 static QSSGComputePipelineStateKey create(const QShader &shader,
883 const QRhiShaderResourceBindings *srb)
884 {
885 const QVector<quint32> srbDesc = srb->serializedLayoutDescription();
886 return { shader, srbDesc, { qHash(srbDesc) } };
887 }
888};
889
890inline bool operator==(const QSSGComputePipelineStateKey &a, const QSSGComputePipelineStateKey &b) Q_DECL_NOTHROW
891{
892 return a.shader == b.shader && a.srbLayoutDescription == b.srbLayoutDescription;
893}
894
895inline bool operator!=(const QSSGComputePipelineStateKey &a, const QSSGComputePipelineStateKey &b) Q_DECL_NOTHROW
896{
897 return !(a == b);
898}
899
900inline size_t qHash(const QSSGComputePipelineStateKey &k, size_t seed = 0) Q_DECL_NOTHROW
901{
902 return qHash(k.shader, seed) ^ k.extra.srbLayoutDescriptionHash;
903}
904
905struct QSSGRhiDummyTextureKey
906{
907 QRhiTexture::Flags flags;
908 QSize size;
909 QColor color;
910 int arraySize;
911};
912
913inline size_t qHash(const QSSGRhiDummyTextureKey &k, size_t seed) Q_DECL_NOTHROW
914{
915 return qHash(k.flags, seed)
916 ^ qHash(k.size.width() ^ k.size.height() ^ k.color.red() ^ k.color.green()
917 ^ k.color.blue() ^ k.color.alpha() ^ k.arraySize);
918}
919
920inline bool operator==(const QSSGRhiDummyTextureKey &a, const QSSGRhiDummyTextureKey &b) Q_DECL_NOTHROW
921{
922 return a.flags == b.flags && a.size == b.size && a.color == b.color && a.arraySize == b.arraySize;
923}
924
925inline bool operator!=(const QSSGRhiDummyTextureKey &a, const QSSGRhiDummyTextureKey &b) Q_DECL_NOTHROW
926{
927 return !(a == b);
928}
929
930class QSSGGraphicsPipelineStateKey
931{
932public:
933 QSSGRhiGraphicsPipelineState state;
934 QVector<quint32> renderTargetDescription;
935 QVector<quint32> srbLayoutDescription;
936 struct {
937 size_t renderTargetDescriptionHash;
938 size_t srbLayoutDescriptionHash;
939 } extra;
940 static QSSGGraphicsPipelineStateKey create(const QSSGRhiGraphicsPipelineState &state,
941 const QRhiRenderPassDescriptor *rpDesc,
942 const QRhiShaderResourceBindings *srb)
943 {
944 const QVector<quint32> rtDesc = rpDesc->serializedFormat();
945 const QVector<quint32> srbDesc = srb->serializedLayoutDescription();
946 return { state, rtDesc, srbDesc, { qHash(rtDesc), qHash(srbDesc) } };
947 }
948};
949
950inline bool operator==(const QSSGGraphicsPipelineStateKey &a, const QSSGGraphicsPipelineStateKey &b) Q_DECL_NOTHROW
951{
952 return a.state == b.state
953 && a.renderTargetDescription == b.renderTargetDescription
954 && a.srbLayoutDescription == b.srbLayoutDescription;
955}
956
957inline bool operator!=(const QSSGGraphicsPipelineStateKey &a, const QSSGGraphicsPipelineStateKey &b) Q_DECL_NOTHROW
958{
959 return !(a == b);
960}
961
962inline size_t qHash(const QSSGGraphicsPipelineStateKey &k, size_t seed) Q_DECL_NOTHROW
963{
964 return qHash(k.state, seed)
965 ^ k.extra.renderTargetDescriptionHash
966 ^ k.extra.srbLayoutDescriptionHash;
967}
968
969#define QSSGRHICTX_STAT(ctx, f)
970 for (bool qssgrhictxlog_enabled = QSSGRhiContextStats::get(*ctx).isEnabled(); qssgrhictxlog_enabled; qssgrhictxlog_enabled = false)
971 QSSGRhiContextStats::get(*ctx).f
972
973class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiContextStats
974{
975public:
976 [[nodiscard]] static QSSGRhiContextStats &get(QSSGRhiContext &rhiCtx);
977 [[nodiscard]] static const QSSGRhiContextStats &get(const QSSGRhiContext &rhiCtx);
978
979 struct DrawInfo {
980 quint64 callCount = 0;
981 quint64 vertexOrIndexCount = 0;
982 };
983 struct InstancedDrawInfo {
984 quint64 callCount = 0;
985 quint64 vertexOrIndexCount = 0;
986 quint64 instanceCount = 0;
987 };
988 struct RenderPassInfo {
989 QByteArray rtName;
990 QSize pixelSize;
991 DrawInfo indexedDraws;
992 DrawInfo draws;
993 InstancedDrawInfo instancedIndexedDraws;
994 InstancedDrawInfo instancedDraws;
995 };
996 struct PerLayerInfo {
997 PerLayerInfo()
998 {
999 externalRenderPass.rtName = QByteArrayLiteral("Qt Quick");
1000 }
1001
1002 // The main render pass if renderMode==Offscreen, plus render passes
1003 // for shadow maps, postprocessing effects, etc.
1004 QVector<RenderPassInfo> renderPasses;
1005
1006 // An Underlay/Overlay/Inline renderMode will make the View3D add stuff
1007 // to a render pass managed by Qt Quick. (external == not under the
1008 // control of Qt Quick 3D)
1009 RenderPassInfo externalRenderPass;
1010
1011 int currentRenderPassIndex = -1;
1012 };
1013 struct GlobalInfo { // global as in per QSSGRhiContext which is per-QQuickWindow
1014 quint64 meshDataSize = 0;
1015 quint64 imageDataSize = 0;
1016 qint64 materialGenerationTime = 0;
1017 qint64 effectGenerationTime = 0;
1018 };
1019
1020 QHash<QSSGRenderLayer *, PerLayerInfo> perLayerInfo;
1021 GlobalInfo globalInfo;
1022
1023 QSSGRhiContextStats(QSSGRhiContext &context)
1024 : rhiCtx(&context)
1025 {
1026 }
1027
1028 // The data collected have four consumers:
1029 //
1030 // - Printed on debug output when QSG_RENDERER_DEBUG has the relevant key.
1031 // (this way the debug output from the 2D scenegraph renderer and these 3D
1032 // statistics appear nicely intermixed)
1033 // - Passed on to the QML profiler when profiling is enabled.
1034 // - DebugView via QQuick3DRenderStats.
1035 // - When tracing is enabled
1036 //
1037 // The first two are enabled globally, but DebugView needs a dynamic
1038 // enable/disable since we want to collect data when a DebugView item
1039 // becomes visible, but not otherwise.
1040
1041 static bool profilingEnabled();
1042 static bool rendererDebugEnabled();
1043
1044 bool isEnabled() const;
1045 void drawIndexed(quint32 indexCount, quint32 instanceCount);
1046 void draw(quint32 vertexCount, quint32 instanceCount);
1047
1048 void meshDataSizeChanges(quint64 newSize) // can be called outside start-stop
1049 {
1050 globalInfo.meshDataSize = newSize;
1051 }
1052
1053 void imageDataSizeChanges(quint64 newSize) // can be called outside start-stop
1054 {
1055 globalInfo.imageDataSize = newSize;
1056 }
1057
1058 void registerMaterialShaderGenerationTime(qint64 ms)
1059 {
1060 globalInfo.materialGenerationTime += ms;
1061 }
1062
1063 void registerEffectShaderGenerationTime(qint64 ms)
1064 {
1065 globalInfo.effectGenerationTime += ms;
1066 }
1067
1068 static quint64 totalDrawCallCountForPass(const QSSGRhiContextStats::RenderPassInfo &pass)
1069 {
1070 return pass.draws.callCount
1071 + pass.indexedDraws.callCount
1072 + pass.instancedDraws.callCount
1073 + pass.instancedIndexedDraws.callCount;
1074 }
1075
1076 static quint64 totalVertexCountForPass(const QSSGRhiContextStats::RenderPassInfo &pass)
1077 {
1078 return pass.draws.vertexOrIndexCount
1079 + pass.indexedDraws.vertexOrIndexCount
1080 + pass.instancedDraws.vertexOrIndexCount
1081 + pass.instancedIndexedDraws.vertexOrIndexCount;
1082 }
1083
1084 void start(QSSGRenderLayer *layer);
1085 void stop(QSSGRenderLayer *layer);
1086 void beginRenderPass(QRhiTextureRenderTarget *rt);
1087 void endRenderPass();
1088 void printRenderPass(const RenderPassInfo &rp);
1089 void cleanupLayerInfo(QSSGRenderLayer *layer);
1090
1091 QSSGRhiContext *rhiCtx;
1092 QSSGRenderLayer *layerKey = nullptr;
1093 QSet<QSSGRenderLayer *> dynamicDataSources;
1094};
1095
1096class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiContextPrivate
1097{
1098 Q_DECLARE_PUBLIC(QSSGRhiContext)
1099
1100 explicit QSSGRhiContextPrivate(QSSGRhiContext &rhiCtx, QRhi *rhi_)
1101 : q_ptr(&rhiCtx)
1102 , m_rhi(rhi_)
1103 , m_stats(rhiCtx)
1104 {}
1105
1106public:
1107 using Textures = QSet<QRhiTexture *>;
1108 using Meshes = QSet<QSSGRenderMesh *>;
1109
1110 [[nodiscard]] static QSSGRhiContextPrivate *get(QSSGRhiContext *q) { return q->d_ptr.get(); }
1111 [[nodiscard]] static const QSSGRhiContextPrivate *get(const QSSGRhiContext *q) { return q->d_ptr.get(); }
1112
1113 [[nodiscard]] static bool shaderDebuggingEnabled();
1114 [[nodiscard]] static bool editorMode();
1115
1116 void setMainRenderPassDescriptor(QRhiRenderPassDescriptor *rpDesc);
1117 void setCommandBuffer(QRhiCommandBuffer *cb);
1118 void setRenderTarget(QRhiRenderTarget *rt);
1119 void setMainPassSampleCount(int samples);
1120 void setMainPassViewCount(int viewCount);
1121
1122 void releaseCachedResources();
1123
1124 void registerTexture(QRhiTexture *texture);
1125 void releaseTexture(QRhiTexture *texture);
1126
1127 void registerMesh(QSSGRenderMesh *mesh);
1128 void releaseMesh(QSSGRenderMesh *mesh);
1129
1130 QRhiShaderResourceBindings *srb(const QSSGRhiShaderResourceBindingList &bindings);
1131 void releaseCachedSrb(QSSGRhiShaderResourceBindingList &bindings);
1132
1133 QRhiGraphicsPipeline *pipeline(const QSSGRhiGraphicsPipelineState &ps,
1134 QRhiRenderPassDescriptor *rpDesc,
1135 QRhiShaderResourceBindings *srb);
1136
1137 QRhiGraphicsPipeline *pipeline(const QSSGGraphicsPipelineStateKey &key,
1138 QRhiRenderPassDescriptor *rpDesc,
1139 QRhiShaderResourceBindings *srb);
1140
1141 QRhiComputePipeline *computePipeline(const QShader &shader,
1142 QRhiShaderResourceBindings *srb);
1143
1145 QRhiShaderResourceBindings *srb);
1146
1147 QSSGRhiDrawCallData &drawCallData(const QSSGRhiDrawCallDataKey &key);
1148 void releaseDrawCallData(QSSGRhiDrawCallData &dcd);
1149 void cleanupDrawCallData(const QSSGRenderModel *model);
1150 void cleanupDrawCallDataForResource(const void *resource);
1151 void cleanupDrawCallDataForCid(const void *cid);
1152 void cleanupDrawCallDataForSkyMaterial(QSSGRenderSkyMaterial *skyMaterial);
1153
1154 QSSGRhiInstanceBufferData &instanceBufferData(QSSGRenderInstanceTable *instanceTable);
1155 void releaseInstanceBuffer(QSSGRenderInstanceTable *instanceTable);
1156
1157 QSSGRhiInstanceBufferData &instanceBufferData(const QSSGRenderModel *model);
1158
1159 QSSGRhiParticleData &particleData(const QSSGRenderGraphObject *particlesOrModel);
1160
1161 QSSGRhiContext *q_ptr = nullptr;
1162 QRhi *m_rhi = nullptr;
1163
1167 Textures m_textures;
1171
1173
1183};
1184
1185inline bool operator==(const QSSGRhiDrawCallDataKey &a, const QSSGRhiDrawCallDataKey &b) noexcept
1186{
1187 return a.cid == b.cid && a.model == b.model && a.resource == b.resource && a.mapEntry == b.mapEntry
1188 && a.resourceIdx == b.resourceIdx;
1189}
1190
1191inline bool operator!=(const QSSGRhiDrawCallDataKey &a, const QSSGRhiDrawCallDataKey &b) noexcept
1192{
1193 return !(a == b);
1194}
1195
1196inline size_t qHash(const QSSGRhiDrawCallDataKey &k, size_t seed = 0) noexcept
1197{
1198 return qHashMulti(seed, k.cid, k.model, k.resource, k.mapEntry, k.resourceIdx);
1199}
1200
1201QT_END_NAMESPACE
1202
1203#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
const QRhiShaderStage * computeStage() 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]