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
4#ifndef QSGRHISHADEREFFECTNODE_P_H
5#define QSGRHISHADEREFFECTNODE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qsgadaptationlayer_p.h>
19#include <qsgmaterial.h>
20#include <QUrl>
21
22QT_BEGIN_NAMESPACE
23
24class QSGDefaultRenderContext;
25class QSGPlainTexture;
27class QFileSelector;
28
30{
31public:
32 void reset(const QShader &vs, const QShader &fs);
33
34 void feedConstants(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices = nullptr);
35 void feedSamplers(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices = nullptr);
37
38 void dump();
39
40 struct Constant {
44 bool operator==(const Constant &other) const {
45 return size == other.size && specialType == other.specialType
46 && (specialType == QSGShaderEffectNode::VariableData::None ? value == other.value : true);
47 }
48 };
49
50 bool m_error;
53 QHash<uint, Constant> m_constants; // offset -> Constant
54 QHash<int, QVariant> m_samplers; // binding -> value (source ref)
55 QHash<QByteArray, int> m_samplerNameMap; // name -> binding
57};
58
59QDebug operator<<(QDebug debug, const QSGRhiShaderLinker::Constant &c);
60
62{
63public:
66
67 int compare(const QSGMaterial *other) const override;
68 QSGMaterialType *type() const override;
69 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
70
71 void updateTextureProviders(bool layoutChange);
72
73 bool usesSubRectUniform(int binding) const { return m_linker.m_subRectBindings.contains(binding); }
74
75 static const int MAX_BINDINGS = 32;
76
79 void *m_materialTypeCacheKey = nullptr;
81 QVector<QSGTextureProvider *> m_textureProviders; // [binding] = QSGTextureProvider
88 QSGPlainTexture *m_dummyTexture = nullptr;
89};
90
92{
94
95public:
97
98 QRectF updateNormalizedTextureSubRect(bool supportsAtlasTextures) override;
99 void syncMaterial(SyncData *syncData) override;
100 void preprocess() override;
101
102 static void resetMaterialTypeCache(void *materialTypeCacheKey);
103 static void garbageCollectMaterialTypeCache(void *materialTypeCacheKey);
104
105private Q_SLOTS:
106 void handleTextureChange();
107 void handleTextureProviderDestroyed(QObject *object);
108
109private:
111};
112
114{
115public:
117 QString log() const override;
118 Status status() const override;
119 void prepareShaderCode(ShaderInfo::Type typeHint, const QUrl &src, ShaderInfo *result) override;
120
121private:
122 bool reflect(ShaderInfo *result);
123 Status m_status = Uncompiled;
124 QFileSelector *m_fileSelector = nullptr;
125};
126
127QT_END_NAMESPACE
128
129#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...
QVector< 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)
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
static bool hasAtlasTexture(const QVector< QSGTextureProvider * > &textureProviders)
QDebug operator<<(QDebug debug, const QSGRhiShaderLinker::Constant &c)
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