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
qsgrhishadereffectnode_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QSGRHISHADEREFFECTNODE_P_H
6#define QSGRHISHADEREFFECTNODE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qsgadaptationlayer_p.h>
20#include <qsgmaterial.h>
21#include <QUrl>
22
23QT_BEGIN_NAMESPACE
24
25class QSGDefaultRenderContext;
26class QSGPlainTexture;
28class QFileSelector;
29
31{
32public:
33 void reset(const QShader &vs, const QShader &fs);
34
35 void feedConstants(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices = nullptr);
36 void feedSamplers(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices = nullptr);
38
39 void dump();
40
41 struct Constant {
45 bool operator==(const Constant &other) const {
46 return size == other.size && specialType == other.specialType
47 && (specialType == QSGShaderEffectNode::VariableData::None ? value == other.value : true);
48 }
49 };
50
51 bool m_error;
54 QHash<uint, Constant> m_constants; // offset -> Constant
55 QHash<int, QVariant> m_samplers; // binding -> value (source ref)
56 QHash<QByteArray, int> m_samplerNameMap; // name -> binding
58};
59
60QDebug operator<<(QDebug debug, const QSGRhiShaderLinker::Constant &c);
61
63{
64public:
67
68 int compare(const QSGMaterial *other) const override;
69 QSGMaterialType *type() const override;
70 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
71
72 void updateTextureProviders(bool layoutChange);
73
74 bool usesSubRectUniform(int binding) const { return m_linker.m_subRectBindings.contains(binding); }
75
76 static const int MAX_BINDINGS = 32;
77
80 void *m_materialTypeCacheKey = nullptr;
82 QList<QSGTextureProvider *> m_textureProviders; // [binding] = QSGTextureProvider
89 QSGPlainTexture *m_dummyTexture = nullptr;
90};
91
93{
95
96public:
98
99 QRectF updateNormalizedTextureSubRect(bool supportsAtlasTextures) override;
100 void syncMaterial(SyncData *syncData) override;
101 void preprocess() override;
102
103 static void resetMaterialTypeCache(void *materialTypeCacheKey);
104 static void garbageCollectMaterialTypeCache(void *materialTypeCacheKey);
105
106private Q_SLOTS:
107 void handleTextureChange();
108 void handleTextureProviderDestroyed(QObject *object);
109
110private:
112};
113
115{
116public:
118 QString log() const override;
119 Status status() const override;
120 void prepareShaderCode(ShaderInfo::Type typeHint, const QUrl &src, ShaderInfo *result) override;
121
122private:
123 bool reflect(ShaderInfo *result);
124 Status m_status = Uncompiled;
125 QFileSelector *m_fileSelector = nullptr;
126};
127
128QT_END_NAMESPACE
129
130#endif // QSGRHISHADEREFFECTNODE_P_H
void prepareShaderCode(ShaderInfo::Type typeHint, const QUrl &src, ShaderInfo *result) override
bool hasSeparateSamplerAndTextureObjects() const override
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
QSGRhiShaderEffectMaterialShader(const QSGRhiShaderEffectMaterial *material)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to enable the material to provide a custom set of graphics...
QList< QSGTextureProvider * > m_textureProviders
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QSGRhiShaderEffectMaterial(QSGRhiShaderEffectNode *node)
bool usesSubRectUniform(int binding) const
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
QSGRhiShaderEffectNode * m_node
QSGShaderEffectNode::CullMode m_cullMode
void updateTextureProviders(bool layoutChange)
void preprocess() override
Override this function to do processing on the node before it is rendered.
static void garbageCollectMaterialTypeCache(void *materialTypeCacheKey)
QRectF updateNormalizedTextureSubRect(bool supportsAtlasTextures) override
void syncMaterial(SyncData *syncData) override
static void resetMaterialTypeCache(void *materialTypeCacheKey)
void feedSamplers(const QSGShaderEffectNode::ShaderData &shader, const QSet< int > *dirtyIndices=nullptr)
QHash< QByteArray, int > m_samplerNameMap
void reset(const QShader &vs, const QShader &fs)
QHash< uint, Constant > m_constants
QHash< int, QVariant > m_samplers
void feedConstants(const QSGShaderEffectNode::ShaderData &shader, const QSet< int > *dirtyIndices=nullptr)
Combined button and popup list for selecting options.
static void fillUniformBlockMember(char *dst, const T *value, int valueCount, int fieldSizeBytes)
static QShader loadShaderFromFile(const QString &filename)
size_t qHash(const QSGRhiShaderMaterialTypeCache::Key &key, size_t seed=0)
static QHash< void *, QSGRhiShaderMaterialTypeCache > shaderMaterialTypeCache
static QColor qsg_premultiply_color(const QColor &c)
static QMutex shaderMaterialTypeCacheMutex
QDebug operator<<(QDebug debug, const QSGRhiShaderLinker::Constant &c)
static bool hasAtlasTexture(const QList< QSGTextureProvider * > &textureProviders)
static QSGRhiShaderEffectDefaultShader create(const QString &filename, int viewCount)
QSGShaderEffectNode::VariableData::SpecialType specialType
bool operator==(const Constant &other) const
Key(const QShader &vs, const QShader &fs)
void unref(const QShader &vs, const QShader &fs)
QSGMaterialType * ref(const QShader &vs, const QShader &fs)
QHash< Key, QSGMaterialType * > m_graveyard