6#ifndef QSSGRHICONTEXT_P_H
7#define QSSGRHICONTEXT_P_H
20#include <QtGui/rhi/qrhi.h>
22#include <QtQuick3DRuntimeRender/qtquick3druntimerenderexports.h>
23#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
24#include <QtQuick3DUtils/private/qssgutils_p.h>
25#include <ssg/qssgrhicontext.h>
29struct QSSGRenderLayer;
30struct QSSGRenderInstanceTable;
31struct QSSGRenderModel;
33class QSSGRenderGraphObject;
34class QSSGBufferManager;
35class QSSGUserRenderPassManager;
44using QSSGRhiInputAssemblerState = QSSGRhiInputAssemblerStatePrivate::InputAssemblerState;
48 static void setShaderPipeline(QSSGRhiGraphicsPipelineState &ps,
const QSSGRhiShaderPipeline *pipeline)
50 ps.shaderPipeline = pipeline;
55 return ps.shaderPipeline;
65 case QSSGRenderTextureFilterOp::Nearest:
66 return QRhiSampler::Nearest;
67 case QSSGRenderTextureFilterOp::Linear:
68 return QRhiSampler::Linear;
69 case QSSGRenderTextureFilterOp::None:
70 return QRhiSampler::Linear;
73 Q_UNREACHABLE_RETURN(QRhiSampler::Linear);
79 case QSSGRenderTextureCoordOp::Repeat:
80 return QRhiSampler::Repeat;
81 case QSSGRenderTextureCoordOp::MirroredRepeat:
82 return QRhiSampler::Mirror;
83 case QSSGRenderTextureCoordOp::ClampToEdge:
84 return QRhiSampler::ClampToEdge;
85 case QSSGRenderTextureCoordOp::Unknown:
86 return QRhiSampler::ClampToEdge;
89 Q_UNREACHABLE_RETURN(QRhiSampler::ClampToEdge);
94 switch (cullFaceMode) {
95 case QSSGCullFaceMode::Back:
96 return QRhiGraphicsPipeline::Back;
97 case QSSGCullFaceMode::Front:
98 return QRhiGraphicsPipeline::Front;
99 case QSSGCullFaceMode::Disabled:
100 return QRhiGraphicsPipeline::None;
101 case QSSGCullFaceMode::FrontAndBack:
102 qWarning(
"FrontAndBack cull mode not supported");
103 return QRhiGraphicsPipeline::None;
104 case QSSGCullFaceMode::Unknown:
105 return QRhiGraphicsPipeline::None;
108 Q_UNREACHABLE_RETURN(QRhiGraphicsPipeline::None);
115void bakeVertexInputLocations(QSSGRhiInputAssemblerState *ia,
const QSSGRhiShaderPipeline &shaders,
int instanceBufferBinding = 0);
119inline bool operator==(
const QSSGRhiGraphicsPipelineState &a,
const QSSGRhiGraphicsPipelineState &b) Q_DECL_NOTHROW
121 const auto &ia_a = QSSGRhiInputAssemblerStatePrivate::get(a);
122 const auto &ia_b = QSSGRhiInputAssemblerStatePrivate::get(b);
123 const auto compareTargetBlend = [](
const std::array<QRhiGraphicsPipeline::TargetBlend, 8> &a,
124 const std::array<QRhiGraphicsPipeline::TargetBlend, 8> &b,
125 const int count) ->
bool {
126 for (
int i = 0; i < count; i++) {
127 if (a[i].colorWrite != b[i].colorWrite
128 || a[i].srcColor != b[i].srcColor
129 || a[i].dstColor != b[i].dstColor
130 || a[i].opColor != b[i].opColor
131 || a[i].srcAlpha != b[i].srcAlpha
132 || a[i].dstAlpha != b[i].dstAlpha
133 || a[i].opAlpha != b[i].opAlpha) {
139 return QSSGRhiGraphicsPipelineStatePrivate::getShaderPipeline(a) == QSSGRhiGraphicsPipelineStatePrivate::getShaderPipeline(b)
140 && a.samples == b.samples
141 && a.flags == b.flags
142 && a.stencilRef == b.stencilRef
143 && (std::memcmp(&a.stencilOpFrontState, &b.stencilOpFrontState,
sizeof(QRhiGraphicsPipeline::StencilOpState)) == 0)
144 && a.stencilWriteMask == b.stencilWriteMask
145 && a.depthFunc == b.depthFunc
146 && a.cullMode == b.cullMode
147 && a.depthBias == b.depthBias
148 && a.slopeScaledDepthBias == b.slopeScaledDepthBias
149 && a.viewport == b.viewport
150 && a.scissor == b.scissor
151 && ia_a.topology == ia_b.topology
152 && ia_a.inputLayout == ia_b.inputLayout
153 && a.colorAttachmentCount == b.colorAttachmentCount
154 && compareTargetBlend(a.targetBlend, b.targetBlend, a.colorAttachmentCount)
155 && a.lineWidth == b.lineWidth
156 && a.polygonMode == b.polygonMode
157 && a.viewCount == b.viewCount;
160inline bool operator!=(
const QSSGRhiGraphicsPipelineState &a,
const QSSGRhiGraphicsPipelineState &b) Q_DECL_NOTHROW
165inline size_t qHash(
const QSSGRhiGraphicsPipelineState &s, size_t seed) Q_DECL_NOTHROW
168 return qHash(QSSGRhiGraphicsPipelineStatePrivate::getShaderPipeline(s), seed)
171 ^ qHash(s.targetBlend[0].dstColor)
174 ^ qHash(s.colorAttachmentCount)
176 ^ qHash(s.polygonMode)
177 ^ qHashBits(&s.stencilOpFrontState,
sizeof(QRhiGraphicsPipeline::StencilOpState))
179 ^ (s.stencilRef << 6)
180 ^ (s.stencilWriteMask << 7);
191struct QSSGRhiDrawCallDataKey
193 const void *cid =
nullptr;
194 const void *model =
nullptr;
195 const void *entry =
nullptr;
196 quintptr entryIdx = 0;
201 Q_DISABLE_COPY(QSSGRhiBuffer)
203 QSSGRhiBuffer(QSSGRhiContext &context,
204 QRhiBuffer::Type type,
205 QRhiBuffer::UsageFlags usageMask,
208 QRhiCommandBuffer::IndexFormat indexFormat = QRhiCommandBuffer::IndexUInt16);
210 virtual ~QSSGRhiBuffer();
215 const quint32 sz = quint32(m_buffer->size());
216 Q_ASSERT((sz % m_stride) == 0);
217 return sz / m_stride;
222 QSSGRhiContext &m_context;
223 QRhiBuffer *m_buffer =
nullptr;
225 QRhiCommandBuffer::IndexFormat m_indexFormat;
235 bool maybeExists =
true;
236 friend class QSSGRhiShaderPipeline;
248 bool maybeExists =
true;
249 friend class QSSGRhiShaderPipeline;
252using QSSGRhiBufferPtr = std::shared_ptr<QSSGRhiBuffer>;
254inline bool operator==(
const QSSGRhiSamplerDescription &a,
const QSSGRhiSamplerDescription &b) Q_DECL_NOTHROW
256 return a.hTiling == b.hTiling && a.vTiling == b.vTiling && a.zTiling == b.zTiling
257 && a.minFilter == b.minFilter && a.magFilter == b.magFilter
258 && a.mipmap == b.mipmap;
261inline bool operator!=(
const QSSGRhiSamplerDescription &a,
const QSSGRhiSamplerDescription &b) Q_DECL_NOTHROW
269 QRhiTexture *texture =
nullptr;
270 QSSGRhiSamplerDescription samplerDesc;
290#define QSSG_MAX_NUM_LIGHTS 16
291#define QSSG_MAX_NUM_DIRECTIONAL_LIGHTS 4
292#define QSSG_REDUCED_MAX_NUM_LIGHTS 8
293#define QSSG_REDUCED_MAX_NUM_DIRECTIONAL_LIGHTS 2
365 Q_DISABLE_COPY(QSSGRhiShaderPipeline)
367 explicit QSSGRhiShaderPipeline(QSSGRhiContext &context) : m_context(context) { }
369 QSSGRhiContext &context()
const {
return m_context; }
370 bool isNull()
const {
return m_stages.isEmpty(); }
380 void addStage(
const QRhiShaderStage &stage, StageFlags flags = {});
385 for (
const QRhiShaderStage &s : m_stages) {
386 if (s.type() == QRhiShaderStage::Vertex)
392 for (
const QRhiShaderStage &s : m_stages) {
393 if (s.type() == QRhiShaderStage::Fragment)
464 } commonUniformIndices;
479 void setUniformValue(
char *ubufData,
const char *name,
const QVariant &value, QSSGRenderShaderValue::Type type);
480 void setUniform(
char *ubufData,
const char *name,
const void *data, size_t size,
int *storeIndex =
nullptr, UniformFlags flags = {});
481 void setUniformArray(
char *ubufData,
const char *name,
const void *data, size_t itemCount, QSSGRenderShaderValue::Type type,
int *storeIndex =
nullptr);
486 QSSGBufferManager &theBufferManager,
487 const QByteArray &inPropertyName,
488 const QVariant &propertyValue,
489 QSSGRenderShaderValue::Type inPropertyType);
497 void setLightProbeTexture(QRhiTexture *texture,
498 QSSGRenderTextureCoordOp hTile = QSSGRenderTextureCoordOp::ClampToEdge,
499 QSSGRenderTextureCoordOp vTile = QSSGRenderTextureCoordOp::ClampToEdge)
501 m_lightProbeTexture = texture; m_lightProbeHorzTile = hTile; m_lightProbeVertTile = vTile;
506 return {m_lightProbeHorzTile, m_lightProbeVertTile};
509 void setScreenTexture(QRhiTexture *texture) { m_screenTexture = texture; }
512 void setDepthTexture(QRhiTexture *texture) { m_depthTexture = texture; }
515 void setNormalTexture(QRhiTexture *texture) { m_normalTexture = texture; }
518 void setSsaoTexture(QRhiTexture *texture) { m_ssaoTexture = texture; }
521 void setLightmapTexture(QRhiTexture *texture) { m_lightmapTexture = texture; }
524 void setMotionVectorTexture(QRhiTexture *texture) { m_motionVectorTexture = texture; }
526 void setShadowMapAtlasTexture(QRhiTexture *texture) { m_shadowMapAtlasTexture = texture; }
529 void setShadowMapBlueNoiseTexture(QRhiTexture *texture) { m_shadowMapBlueNoiseTexture = texture; }
532 void setOITImages(QRhiTexture *accumulator, QRhiTexture *auxiliary, QRhiTexture *counter)
534 m_oitImages[0] = accumulator;
535 m_oitImages[1] = auxiliary;
536 m_oitImages[2] = counter;
553 QSSGRhiContext &m_context;
554 QVarLengthArray<QRhiShaderStage, 2> m_stages;
556 int m_ub0NextUBufOffset = 0;
557 QHash<QByteArray, QShaderDescription::BlockVariable> m_ub0;
558 QHash<QSSGRhiInputAssemblerState::InputSemantic, QShaderDescription::InOutVariable> m_vertexInputs;
559 QHash<QByteArray, QShaderDescription::InOutVariable> m_combinedImageSamplers;
560 QHash<QByteArray, QShaderDescription::InOutVariable> m_storageImages;
563 QVarLengthArray<QSSGRhiShaderUniform, 32> m_uniforms;
564 QVarLengthArray<QSSGRhiShaderUniformArray, 8> m_uniformArrays;
565 QHash<QByteArray, size_t> m_uniformIndex;
568 bool m_lightsEnabled =
false;
571 QRhiTexture *m_shadowMapAtlasTexture =
nullptr;
572 QRhiTexture *m_shadowMapBlueNoiseTexture =
nullptr;
573 QRhiTexture *m_lightProbeTexture =
nullptr;
574 QSSGRenderTextureCoordOp m_lightProbeHorzTile = QSSGRenderTextureCoordOp::ClampToEdge;
575 QSSGRenderTextureCoordOp m_lightProbeVertTile = QSSGRenderTextureCoordOp::ClampToEdge;
576 QRhiTexture *m_screenTexture =
nullptr;
577 QRhiTexture *m_depthTexture =
nullptr;
578 QRhiTexture *m_normalTexture =
nullptr;
579 QRhiTexture *m_ssaoTexture =
nullptr;
580 QRhiTexture *m_lightmapTexture =
nullptr;
581 QRhiTexture *m_oitImages[3] = {
nullptr};
582 QRhiTexture *m_motionVectorTexture =
nullptr;
583 QVarLengthArray<QSSGRhiTexture, 8> m_extraTextures;
586Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRhiShaderPipeline::StageFlags)
587Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRhiShaderPipeline::UniformFlags)
589using QSSGRhiShaderPipelinePtr = std::shared_ptr<QSSGRhiShaderPipeline>;
594 static const int MAX_SIZE = 32;
598 QRhiShaderResourceBinding v[MAX_SIZE];
600 void clear() { p = 0; h = 0; }
602 QSSGRhiShaderResourceBindingList() { }
604 QSSGRhiShaderResourceBindingList(
const QSSGRhiShaderResourceBindingList &other)
608 for (
int i = 0; i < p; ++i)
612 QSSGRhiShaderResourceBindingList &operator=(
const QSSGRhiShaderResourceBindingList &other) Q_DECL_NOTHROW
614 if (
this != &other) {
617 for (
int i = 0; i < p; ++i)
623 void addUniformBuffer(
int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf,
int offset = 0 ,
int size = 0);
624 void addTexture(
int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler);
625 void addImageLoad(
int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex,
int level);
626 void addImageStore(
int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex,
int level);
627 void addImageLoadStore(
int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex,
int level);
628 void addStorageBuffer(
int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf,
int offset = 0 ,
int size = 0);
631inline bool operator==(
const QSSGRhiShaderResourceBindingList &a,
const QSSGRhiShaderResourceBindingList &b) Q_DECL_NOTHROW
637 for (
int i = 0; i < a.p; ++i) {
638 if (a.v[i] != b.v[i])
644inline bool operator!=(
const QSSGRhiShaderResourceBindingList &a,
const QSSGRhiShaderResourceBindingList &b) Q_DECL_NOTHROW
649inline size_t qHash(
const QSSGRhiShaderResourceBindingList &bl, size_t seed) Q_DECL_NOTHROW
654struct QSSGRhiDrawCallData
656 QRhiBuffer *ubuf =
nullptr;
657 QRhiShaderResourceBindings *srb =
nullptr;
658 QSSGRhiShaderResourceBindingList bindings;
659 QRhiGraphicsPipeline *pipeline =
nullptr;
660 size_t renderTargetDescriptionHash = 0;
661 QVector<quint32> renderTargetDescription;
662 QSSGRhiGraphicsPipelineState ps;
675 enum class Private { Initialize };
676 Q_DISABLE_COPY(QSSGManagedRhiTexture)
678 using Ptr = std::unique_ptr<QSSGManagedRhiTexture>;
680 const std::unique_ptr<QRhiTexture> &texture()
const {
return m_texture; }
682 [[nodiscard]]
bool isValid()
const {
return m_texture !=
nullptr; }
684 QSSGManagedRhiTexture() =
default;
685 QSSGManagedRhiTexture(
const std::shared_ptr<QSSGUserRenderPassManager> &manager, QRhiTexture *texture, Private);
686 QSSGManagedRhiTexture(
const std::shared_ptr<QSSGUserRenderPassManager> &manager, std::unique_ptr<QRhiTexture> texture);
687 ~QSSGManagedRhiTexture();
689 [[nodiscard]]
static Ptr make_copy(
const Ptr &other)
691 return std::make_unique<QSSGManagedRhiTexture>(other->m_manager, other->m_texture.get(), Private::Initialize);
695 friend class QSSGRhiRenderableTextureV2;
696 friend class QSSGUserRenderPassManager;
700 std::shared_ptr<QSSGUserRenderPassManager> m_manager;
701 std::unique_ptr<QRhiTexture> m_texture;
704using QSSGManagedRhiTexturePtr = QSSGManagedRhiTexture::Ptr;
708 enum class Private { Initialize };
716 void setDescription(QRhi *rhi, QRhiTextureRenderTargetDescription rtDesc, QRhiTextureRenderTarget::Flags = {});
718 void setName(
const QByteArray &name) { rtName = name; }
729 bool isValid()
const {
return (textures.size() > 0) && rt && rpDesc; }
737 friend class QSSGUserRenderPassManager;
741 ColorTextureDirty = 0x1,
742 DepthStencilDirty = 0x2,
743 DepthTextureDirty = 0x4,
750 std::shared_ptr<QSSGUserRenderPassManager> m_manager;
752 QVarLengthArray<QSSGManagedRhiTexturePtr, 4> textures {};
753 std::unique_ptr<QRhiRenderBuffer> depthStencil;
754 QSSGManagedRhiTexturePtr depthTexture;
756 std::unique_ptr<QRhiRenderPassDescriptor> rpDesc;
757 std::unique_ptr<QRhiTextureRenderTarget> rt;
762using QSSGRhiRenderableTextureV2Ptr = std::shared_ptr<QSSGRhiRenderableTextureV2>;
771 bool isValid()
const {
return texture && rpDesc && rt; }
826 const QRhiShaderResourceBindings *srb)
828 const QVector<quint32> srbDesc = srb->serializedLayoutDescription();
829 return { shader, srbDesc, { qHash(srbDesc) } };
833inline bool operator==(
const QSSGComputePipelineStateKey &a,
const QSSGComputePipelineStateKey &b) Q_DECL_NOTHROW
835 return a.shader == b.shader && a.srbLayoutDescription == b.srbLayoutDescription;
838inline bool operator!=(
const QSSGComputePipelineStateKey &a,
const QSSGComputePipelineStateKey &b) Q_DECL_NOTHROW
843inline size_t qHash(
const QSSGComputePipelineStateKey &k, size_t seed = 0) Q_DECL_NOTHROW
845 return qHash(k.shader, seed) ^ k.extra.srbLayoutDescriptionHash;
848struct QSSGRhiDummyTextureKey
850 QRhiTexture::Flags flags;
856inline size_t qHash(
const QSSGRhiDummyTextureKey &k, size_t seed) Q_DECL_NOTHROW
858 return qHash(k.flags, seed)
859 ^ qHash(k.size.width() ^ k.size.height() ^ k.color.red() ^ k.color.green()
860 ^ k.color.blue() ^ k.color.alpha() ^ k.arraySize);
863inline bool operator==(
const QSSGRhiDummyTextureKey &a,
const QSSGRhiDummyTextureKey &b) Q_DECL_NOTHROW
865 return a.flags == b.flags && a.size == b.size && a.color == b.color && a.arraySize == b.arraySize;
868inline bool operator!=(
const QSSGRhiDummyTextureKey &a,
const QSSGRhiDummyTextureKey &b) Q_DECL_NOTHROW
873class QSSGGraphicsPipelineStateKey
876 QSSGRhiGraphicsPipelineState state;
877 QVector<quint32> renderTargetDescription;
878 QVector<quint32> srbLayoutDescription;
880 size_t renderTargetDescriptionHash;
881 size_t srbLayoutDescriptionHash;
883 static QSSGGraphicsPipelineStateKey create(
const QSSGRhiGraphicsPipelineState &state,
884 const QRhiRenderPassDescriptor *rpDesc,
885 const QRhiShaderResourceBindings *srb)
887 const QVector<quint32> rtDesc = rpDesc->serializedFormat();
888 const QVector<quint32> srbDesc = srb->serializedLayoutDescription();
889 return { state, rtDesc, srbDesc, { qHash(rtDesc), qHash(srbDesc) } };
893inline bool operator==(
const QSSGGraphicsPipelineStateKey &a,
const QSSGGraphicsPipelineStateKey &b) Q_DECL_NOTHROW
895 return a.state == b.state
896 && a.renderTargetDescription == b.renderTargetDescription
897 && a.srbLayoutDescription == b.srbLayoutDescription;
900inline bool operator!=(
const QSSGGraphicsPipelineStateKey &a,
const QSSGGraphicsPipelineStateKey &b) Q_DECL_NOTHROW
905inline size_t qHash(
const QSSGGraphicsPipelineStateKey &k, size_t seed) Q_DECL_NOTHROW
907 return qHash(k.state, seed)
908 ^ k.extra.renderTargetDescriptionHash
909 ^ k.extra.srbLayoutDescriptionHash;
912#define QSSGRHICTX_STAT(ctx, f)
913 for (bool qssgrhictxlog_enabled = QSSGRhiContextStats::get(*ctx).isEnabled(); qssgrhictxlog_enabled; qssgrhictxlog_enabled = false)
914 QSSGRhiContextStats::get(*ctx).f
916class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiContextStats
919 [[nodiscard]]
static QSSGRhiContextStats &get(QSSGRhiContext &rhiCtx);
920 [[nodiscard]]
static const QSSGRhiContextStats &get(
const QSSGRhiContext &rhiCtx);
923 quint64 callCount = 0;
924 quint64 vertexOrIndexCount = 0;
926 struct InstancedDrawInfo {
927 quint64 callCount = 0;
928 quint64 vertexOrIndexCount = 0;
929 quint64 instanceCount = 0;
931 struct RenderPassInfo {
934 DrawInfo indexedDraws;
936 InstancedDrawInfo instancedIndexedDraws;
937 InstancedDrawInfo instancedDraws;
939 struct PerLayerInfo {
942 externalRenderPass.rtName = QByteArrayLiteral(
"Qt Quick");
947 QVector<RenderPassInfo> renderPasses;
952 RenderPassInfo externalRenderPass;
954 int currentRenderPassIndex = -1;
957 quint64 meshDataSize = 0;
958 quint64 imageDataSize = 0;
959 qint64 materialGenerationTime = 0;
960 qint64 effectGenerationTime = 0;
963 QHash<QSSGRenderLayer *, PerLayerInfo> perLayerInfo;
964 GlobalInfo globalInfo;
966 QSSGRhiContextStats(QSSGRhiContext &context)
984 static bool profilingEnabled();
985 static bool rendererDebugEnabled();
987 bool isEnabled()
const;
988 void drawIndexed(quint32 indexCount, quint32 instanceCount);
989 void draw(quint32 vertexCount, quint32 instanceCount);
991 void meshDataSizeChanges(quint64 newSize)
993 globalInfo.meshDataSize = newSize;
996 void imageDataSizeChanges(quint64 newSize)
998 globalInfo.imageDataSize = newSize;
1001 void registerMaterialShaderGenerationTime(qint64 ms)
1003 globalInfo.materialGenerationTime += ms;
1006 void registerEffectShaderGenerationTime(qint64 ms)
1008 globalInfo.effectGenerationTime += ms;
1011 static quint64 totalDrawCallCountForPass(
const QSSGRhiContextStats::RenderPassInfo &pass)
1013 return pass.draws.callCount
1014 + pass.indexedDraws.callCount
1015 + pass.instancedDraws.callCount
1016 + pass.instancedIndexedDraws.callCount;
1019 static quint64 totalVertexCountForPass(
const QSSGRhiContextStats::RenderPassInfo &pass)
1021 return pass.draws.vertexOrIndexCount
1022 + pass.indexedDraws.vertexOrIndexCount
1023 + pass.instancedDraws.vertexOrIndexCount
1024 + pass.instancedIndexedDraws.vertexOrIndexCount;
1027 void start(QSSGRenderLayer *layer);
1028 void stop(QSSGRenderLayer *layer);
1029 void beginRenderPass(QRhiTextureRenderTarget *rt);
1030 void endRenderPass();
1031 void printRenderPass(
const RenderPassInfo &rp);
1032 void cleanupLayerInfo(QSSGRenderLayer *layer);
1034 QSSGRhiContext *rhiCtx;
1035 QSSGRenderLayer *layerKey =
nullptr;
1036 QSet<QSSGRenderLayer *> dynamicDataSources;
1041 Q_DECLARE_PUBLIC(QSSGRhiContext)
1043 explicit QSSGRhiContextPrivate(QSSGRhiContext &rhiCtx, QRhi *rhi_)
1050 using Textures = QSet<QRhiTexture *>;
1051 using Meshes = QSet<QSSGRenderMesh *>;
1065 void releaseCachedResources();
1067 void registerTexture(QRhiTexture *texture);
1068 void releaseTexture(QRhiTexture *texture);
1077 QRhiRenderPassDescriptor *rpDesc,
1078 QRhiShaderResourceBindings *srb);
1081 QRhiRenderPassDescriptor *rpDesc,
1082 QRhiShaderResourceBindings *srb);
1085 QRhiShaderResourceBindings *srb);
1088 QRhiShaderResourceBindings *srb);
1125inline bool operator==(
const QSSGRhiDrawCallDataKey &a,
const QSSGRhiDrawCallDataKey &b)
noexcept
1127 return a.cid == b.cid && a.model == b.model && a.entry == b.entry && a.entryIdx == b.entryIdx;
1130inline bool operator!=(
const QSSGRhiDrawCallDataKey &a,
const QSSGRhiDrawCallDataKey &b)
noexcept
1135inline size_t qHash(
const QSSGRhiDrawCallDataKey &k, size_t seed = 0)
noexcept
1137 return qHash(quintptr(k.cid)
1140 ^ quintptr(k.entryIdx), seed);
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.
Q_DECLARE_FLAGS(InitFlags, InitFlag)
static QSSGComputePipelineStateKey create(const QShader &shader, const QRhiShaderResourceBindings *srb)
size_t srbLayoutDescriptionHash
QVector< quint32 > srbLayoutDescription
QRhiBuffer * buffer() const
QRhiCommandBuffer::IndexFormat indexFormat() 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 releaseCachedSrb(QSSGRhiShaderResourceBindingList &bindings)
static const QSSGRhiContextPrivate * get(const QSSGRhiContext *q)
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)
void cleanupDrawCallData(const QSSGRenderModel *model)
QHash< const QSSGRenderGraphObject *, QSSGRhiParticleData > m_particleData
QSSGRhiContextStats m_stats
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)
static QSSGRhiContextPrivate * get(QSSGRhiContext *q)
QRhiComputePipeline * computePipeline(const QShader &shader, QRhiShaderResourceBindings *srb)
QHash< QSSGComputePipelineStateKey, QRhiComputePipeline * > m_computePipelines
QHash< QSSGGraphicsPipelineStateKey, QRhiGraphicsPipeline * > m_pipelines
QSSGRhiInstanceBufferData & instanceBufferData(QSSGRenderInstanceTable *instanceTable)
const QSSGManagedRhiTexturePtr & getColorTexture(int index) const
const std::unique_ptr< QRhiRenderPassDescriptor > & getRenderPassDescriptor() const
void setName(const QByteArray &name)
void finialize(QRhi *rhi)
const std::unique_ptr< QRhiTextureRenderTarget > & getRenderTarget() const
~QSSGRhiRenderableTextureV2()
const std::unique_ptr< QRhiRenderBuffer > & getDepthStencil() const
size_t colorAttachmentCount() const
void setDescription(QRhi *rhi, QRhiTextureRenderTargetDescription rtDesc, QRhiTextureRenderTarget::Flags={})
const QByteArray & getName() const
const QSSGManagedRhiTexturePtr & getDepthTexture() const
QSSGRhiRenderableTextureV2(const std::shared_ptr< QSSGUserRenderPassManager > &manager, Private)
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
int bindingForImage(const char *name)
void resetExtraTextures()
QPair< QSSGRenderTextureCoordOp, QSSGRenderTextureCoordOp > lightProbeTiling() const
InstanceLocations instanceBufferLocations() const
bool isLightingEnabled() const
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)
int ub0LightDataOffset() const
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 extraTextureCount() 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
QRhiVertexInputAttribute::Format toVertexInputFormat(QSSGRenderComponentType compType, quint32 numComps)
QRhiGraphicsPipeline::CullMode toCullMode(QSSGCullFaceMode cullFaceMode)
QRhiGraphicsPipeline::Topology toTopology(QSSGRenderDrawMode drawMode)
void bakeVertexInputLocations(QSSGRhiInputAssemblerState *ia, const QSSGRhiShaderPipeline &shaders, int instanceBufferBinding)
QRhiSampler::Filter toRhi(QSSGRenderTextureFilterOp op)
Q_TRACE_POINT(qtcore, QCoreApplication_postEvent_exit)
Q_TRACE_POINT(qtcore, QFactoryLoader_update, const QString &fileName)
Q_TRACE_POINT(qtquick3d, QSSG_renderFrame_entry, int width, int height)
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
static QString getUBMemberSizeWarning(QLatin1StringView name, qsizetype correctedSize, qsizetype requestedSize)
#define QSSG_MAX_NUM_LIGHTS
#define QSSG_MAX_NUM_DIRECTIONAL_LIGHTS
QSSGRhiSamplerBindingHints
static constexpr const QSSGRhiShaderPipeline * getShaderPipeline(const QSSGRhiGraphicsPipelineState &ps)
static void setShaderPipeline(QSSGRhiGraphicsPipelineState &ps, const QSSGRhiShaderPipeline *pipeline)
QList< QSSGRhiSortData > sortData
QVector3D sortedCameraDirection
QList< QSSGRhiSortData > sortData
QRhiTextureRenderTarget * rt
QRhiTexture * depthTexture
QRhiRenderPassDescriptor * rpDesc
QRhiRenderBuffer * depthStencil
float atlasLocations[4][4]
float dimensionsInverted[4][4]
float constantAttenuation
float quadraticAttenuation