Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
23
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
47 }
48 };
49
50 bool m_error;
54 QHash<uint, Constant> m_constants; // offset -> Constant
55 QHash<int, QVariant> m_samplers; // binding -> value (source ref)
58};
59
61
63{
64public:
67
68 int compare(const QSGMaterial *other) const override;
69 QSGMaterialType *type() 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 QVector<QSGTextureProvider *> m_textureProviders; // [binding] = QSGTextureProvider
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:
117 bool hasSeparateSamplerAndTextureObjects() const override;
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
129
130#endif // QSGRHISHADEREFFECTNODE_P_H
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qhash.h:818
Definition qlist.h:74
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore\reentrant
Definition qrect.h:483
The QSGMaterialShader class represents a graphics API independent shader program.
The QSGMaterial class encapsulates rendering state for a shader program.
Definition qsgmaterial.h:15
RenderMode
\value RenderMode2D Normal 2D rendering \value RenderMode2DNoDepthBuffer Normal 2D rendering with dep...
void prepareShaderCode(ShaderInfo::Type typeHint, const QUrl &src, ShaderInfo *result) override
bool hasSeparateSamplerAndTextureObjects() const override
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...
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
QHash< uint, Constant > m_constants
QHash< int, QVariant > m_samplers
void feedConstants(const QSGShaderEffectNode::ShaderData &shader, const QSet< int > *dirtyIndices=nullptr)
Definition qset.h:18
bool contains(const T &value) const
Definition qset.h:71
\inmodule QtGui
Definition qshader.h:81
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:64
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum src
GLboolean reset
const GLubyte * c
GLuint shader
Definition qopenglext.h:665
GLuint64EXT * result
[6]
QDebug operator<<(QDebug debug, const QSGRhiShaderLinker::Constant &c)
#define Q_OBJECT
#define Q_SLOTS
unsigned int uint
Definition qtypes.h:29
QSharedPointer< T > other(t)
[5]
The QSGMaterialType class is used as a unique type token in combination with QSGMaterial.
QSGShaderEffectNode::VariableData::SpecialType specialType
bool operator==(const Constant &other) const