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
qssgrhieffectsystem_p.h
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2020 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6
7#ifndef QSSGRHIEFFECTSYSTEM_P_H
8#define QSSGRHIEFFECTSYSTEM_P_H
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include <QtQuick3DRuntimeRender/private/qssgrendereffect_p.h>
22#include <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrendercommands_p.h>
24
25QT_BEGIN_NAMESPACE
26
27struct QSSGRhiEffectTexture;
28class QSSGRenderer;
29
30class QSSGProgramGenerator;
31class QSSGShaderLibraryManager;
32class QSSGShaderCache;
33
35{
39
41
42 static size_t generateHashCode(const QByteArray &shaderPathKey, quintptr cmd, int ubufIndex)
43 {
44 return qHash(shaderPathKey) ^ qHash(cmd) ^ qHash(ubufIndex);
45 }
46
48 {
49 m_hashCode = generateHashCode(m_shaderPathKey, m_cmd, m_ubufIndex);
50 }
51
52 bool operator==(const QSSGEffectSceneCacheKey &other) const
53 {
54 return m_shaderPathKey == other.m_shaderPathKey
55 && m_cmd == other.m_cmd
56 && m_ubufIndex == other.m_ubufIndex;
57 }
58};
59
61{
62 return key.m_hashCode;
63}
64
65class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiEffectSystem
66{
67public:
68 explicit QSSGRhiEffectSystem(const std::shared_ptr<QSSGRenderContextInterface> &sgContext);
69 ~QSSGRhiEffectSystem();
70
71 void setup(QSize outputSize);
72 QRhiTexture *process(const QSSGRenderLayer &layer,
73 QRhiTexture *inTexture,
74 QRhiTexture *inDepthTexture,
75 QRhiTexture *inNormalTexture,
76 QRhiTexture *inMotionVectorTexture);
77
78 static QSSGRenderTextureFormat::Format overriddenOutputFormat(const QSSGRenderEffect *inEffect);
79
80 static QSSGRhiShaderPipelinePtr buildShaderForEffect(const QSSGBindShader &inCmd,
81 QSSGProgramGenerator &generator,
82 QSSGShaderLibraryManager &shaderLib,
83 QSSGShaderCache &shaderCache,
84 bool isYUpInFramebuffer,
85 int viewCount);
86
87private:
88 void releaseResources();
89 QSSGRhiEffectTexture *doRenderEffect(const QSSGRenderEffect *inEffect,
90 QSSGRhiEffectTexture *inTexture,
91 quint8 viewCount);
92
93 void allocateBufferCmd(const QSSGAllocateBuffer *inCmd, QSSGRhiEffectTexture *inTexture, const QSSGRenderEffect *inEffect, quint8 viewCount);
94 void applyInstanceValueCmd(const QSSGApplyInstanceValue *inCmd, const QSSGRenderEffect *inEffect);
95 void applyValueCmd(const QSSGApplyValue *inCmd, const QSSGRenderEffect *inEffect);
96 void bindShaderCmd(const QSSGBindShader *inCmd, const QSSGRenderEffect *inEffect, quint8 viewCount);
97 void renderCmd(const QSSGRenderEffect *inEffect, QSSGRhiEffectTexture *inTexture, QSSGRhiEffectTexture *target, quint8 viewCount);
98
99 void addCommonEffectUniforms(const QSSGRenderEffect *inEffect, const QSize &inputSize, const QSize &outputSize, quint8 viewCount);
100 void addTextureToShaderPipeline(const QByteArray &name, QRhiTexture *texture, const QSSGRhiSamplerDescription &samplerDesc);
101
102 QSSGRhiEffectTexture *findTexture(const QByteArray &bufferName);
103 QSSGRhiEffectTexture *getTexture(const QByteArray &bufferName, const QSize &size,
104 QRhiTexture::Format format, bool isFinalOutput,
105 const QSSGRenderEffect *inEffect, quint8 viewCount);
106 void releaseTexture(QSSGRhiEffectTexture *texture);
107 void releaseTextures();
108
109 QSize m_outSize;
110 std::shared_ptr<QSSGRenderContextInterface> m_sgContext;
111 QVector<QSSGRhiEffectTexture *> m_textures;
112 QRhiTexture *m_depthTexture = nullptr;
113 QRhiTexture *m_normalTexture = nullptr;
114 QRhiTexture *m_motionVectorTexture = nullptr;
115 QVector2D m_cameraClipRange;
116 QVarLengthArray<QMatrix4x4, 2> m_projectionMatrices;
117 QVarLengthArray<QMatrix4x4, 2> m_viewMatrices;
118 int m_currentUbufIndex = 0;
119 QHash<QSSGEffectSceneCacheKey, QSSGRhiShaderPipelinePtr> m_shaderPipelines;
120 QSSGRhiShaderPipeline *m_currentShaderPipeline = nullptr;
121 char *m_currentUBufData = nullptr;
122 QHash<QByteArray, QSSGRhiTexture> m_currentTextures;
123 QSet<QRhiTextureRenderTarget *> m_pendingClears;
124};
125
126QT_END_NAMESPACE
127
128#endif
size_t qHash(const QSSGEffectSceneCacheKey &key)
bool operator==(const QSSGEffectSceneCacheKey &other) const
static size_t generateHashCode(const QByteArray &shaderPathKey, quintptr cmd, int ubufIndex)