aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/quick/scenegraph/graph/linenode.cpp4
-rw-r--r--examples/quick/scenegraph/graph/noisynode.cpp4
-rw-r--r--examples/quick/scenegraph/twotextureproviders/xorblender.cpp4
-rw-r--r--src/particles/CMakeLists.txt4
-rw-r--r--src/particles/particles.qrc5
-rw-r--r--src/particles/qquickimageparticle.cpp504
-rw-r--r--src/particles/shaders/imageparticle.frag42
-rw-r--r--src/particles/shaders/imageparticle.vert141
-rw-r--r--src/particles/shaders/imageparticle_core.frag44
-rw-r--r--src/particles/shaders/imageparticle_core.vert141
-rw-r--r--src/quick/CMakeLists.txt67
-rw-r--r--src/quick/items/qquickopenglshadereffectnode.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp91
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h9
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.cpp43
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.h7
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp630
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialrhishader.h182
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialrhishader_p.h114
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialshader.cpp611
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialshader.h143
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialshader_p.h55
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer_p.h11
-rw-r--r--src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp6
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp351
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalimagenode.cpp54
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp64
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext.cpp6
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext_p.h7
-rw-r--r--src/quick/scenegraph/qsgdefaultspritenode.cpp52
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp394
-rw-r--r--src/quick/scenegraph/qsgrhishadereffectnode.cpp7
-rw-r--r--src/quick/scenegraph/scenegraph.pri3
-rw-r--r--src/quick/scenegraph/scenegraph.qrc66
-rw-r--r--src/quick/scenegraph/shaders/24bittextmask.frag10
-rw-r--r--src/quick/scenegraph/shaders/24bittextmask_core.frag14
-rw-r--r--src/quick/scenegraph/shaders/32bitcolortext.frag9
-rw-r--r--src/quick/scenegraph/shaders/32bitcolortext_core.frag13
-rw-r--r--src/quick/scenegraph/shaders/8bittextmask.frag9
-rw-r--r--src/quick/scenegraph/shaders/8bittextmask_core.frag13
-rw-r--r--src/quick/scenegraph/shaders/distancefieldoutlinetext.frag16
-rw-r--r--src/quick/scenegraph/shaders/distancefieldoutlinetext_core.frag20
-rw-r--r--src/quick/scenegraph/shaders/distancefieldshiftedtext.frag17
-rw-r--r--src/quick/scenegraph/shaders/distancefieldshiftedtext.vert17
-rw-r--r--src/quick/scenegraph/shaders/distancefieldshiftedtext_core.frag20
-rw-r--r--src/quick/scenegraph/shaders/distancefieldshiftedtext_core.vert18
-rw-r--r--src/quick/scenegraph/shaders/distancefieldtext.frag13
-rw-r--r--src/quick/scenegraph/shaders/distancefieldtext.vert13
-rw-r--r--src/quick/scenegraph/shaders/distancefieldtext_core.frag16
-rw-r--r--src/quick/scenegraph/shaders/distancefieldtext_core.vert15
-rw-r--r--src/quick/scenegraph/shaders/flatcolor.frag6
-rw-r--r--src/quick/scenegraph/shaders/flatcolor.vert7
-rw-r--r--src/quick/scenegraph/shaders/flatcolor_core.frag10
-rw-r--r--src/quick/scenegraph/shaders/flatcolor_core.vert10
-rw-r--r--src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag58
-rw-r--r--src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert34
-rw-r--r--src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext_core.frag32
-rw-r--r--src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext_core.vert36
-rw-r--r--src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.frag17
-rw-r--r--src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.vert27
-rw-r--r--src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext_core.frag21
-rw-r--r--src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext_core.vert29
-rw-r--r--src/quick/scenegraph/shaders/opaquetexture.frag8
-rw-r--r--src/quick/scenegraph/shaders/opaquetexture.vert12
-rw-r--r--src/quick/scenegraph/shaders/opaquetexture_core.frag12
-rw-r--r--src/quick/scenegraph/shaders/opaquetexture_core.vert14
-rw-r--r--src/quick/scenegraph/shaders/outlinedtext.frag21
-rw-r--r--src/quick/scenegraph/shaders/outlinedtext.vert24
-rw-r--r--src/quick/scenegraph/shaders/outlinedtext_core.frag25
-rw-r--r--src/quick/scenegraph/shaders/outlinedtext_core.vert26
-rw-r--r--src/quick/scenegraph/shaders/rendernode.frag8
-rw-r--r--src/quick/scenegraph/shaders/rendernode.vert10
-rw-r--r--src/quick/scenegraph/shaders/rendernode_core.frag12
-rw-r--r--src/quick/scenegraph/shaders/rendernode_core.vert12
-rw-r--r--src/quick/scenegraph/shaders/smoothcolor.frag6
-rw-r--r--src/quick/scenegraph/shaders/smoothcolor.vert45
-rw-r--r--src/quick/scenegraph/shaders/smoothcolor_core.frag10
-rw-r--r--src/quick/scenegraph/shaders/smoothcolor_core.vert47
-rw-r--r--src/quick/scenegraph/shaders/smoothtexture.frag9
-rw-r--r--src/quick/scenegraph/shaders/smoothtexture.vert55
-rw-r--r--src/quick/scenegraph/shaders/smoothtexture_core.frag13
-rw-r--r--src/quick/scenegraph/shaders/smoothtexture_core.vert57
-rw-r--r--src/quick/scenegraph/shaders/sprite.frag12
-rw-r--r--src/quick/scenegraph/shaders/sprite.vert23
-rw-r--r--src/quick/scenegraph/shaders/sprite_core.frag16
-rw-r--r--src/quick/scenegraph/shaders/sprite_core.vert24
-rw-r--r--src/quick/scenegraph/shaders/styledtext.frag14
-rw-r--r--src/quick/scenegraph/shaders/styledtext.vert18
-rw-r--r--src/quick/scenegraph/shaders/styledtext_core.frag18
-rw-r--r--src/quick/scenegraph/shaders/styledtext_core.vert20
-rw-r--r--src/quick/scenegraph/shaders/textmask.frag10
-rw-r--r--src/quick/scenegraph/shaders/textmask.vert15
-rw-r--r--src/quick/scenegraph/shaders/textmask_core.frag14
-rw-r--r--src/quick/scenegraph/shaders/textmask_core.vert17
-rw-r--r--src/quick/scenegraph/shaders/texture.frag9
-rw-r--r--src/quick/scenegraph/shaders/texture_core.frag13
-rw-r--r--src/quick/scenegraph/shaders/vertexcolor.frag6
-rw-r--r--src/quick/scenegraph/shaders/vertexcolor.vert13
-rw-r--r--src/quick/scenegraph/shaders/vertexcolor_core.frag10
-rw-r--r--src/quick/scenegraph/shaders/vertexcolor_core.vert15
-rw-r--r--src/quick/scenegraph/util/qsgflatcolormaterial.cpp86
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp107
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial_p.h28
-rw-r--r--src/quick/scenegraph/util/qsgvertexcolormaterial.cpp64
-rw-r--r--src/quickshapes/CMakeLists.txt26
-rw-r--r--src/quickshapes/qquicknvprfunctions.cpp281
-rw-r--r--src/quickshapes/qquicknvprfunctions_p.h401
-rw-r--r--src/quickshapes/qquicknvprfunctions_p_p.h71
-rw-r--r--src/quickshapes/qquickshape.cpp37
-rw-r--r--src/quickshapes/qquickshapegenericrenderer.cpp179
-rw-r--r--src/quickshapes/qquickshapegenericrenderer_p.h74
-rw-r--r--src/quickshapes/qquickshapenvprrenderer.cpp1001
-rw-r--r--src/quickshapes/qquickshapenvprrenderer_p.h238
-rw-r--r--src/quickshapes/qtquickshapes.qrc16
-rw-r--r--src/quickshapes/quickshapes.pro11
-rw-r--r--src/quickshapes/shaders/blit.frag9
-rw-r--r--src/quickshapes/shaders/blit.vert12
-rw-r--r--src/quickshapes/shaders/blit_core.frag13
-rw-r--r--src/quickshapes/shaders/blit_core.vert14
-rw-r--r--src/quickshapes/shaders/conicalgradient.frag19
-rw-r--r--src/quickshapes/shaders/conicalgradient.vert13
-rw-r--r--src/quickshapes/shaders/conicalgradient_core.frag22
-rw-r--r--src/quickshapes/shaders/conicalgradient_core.vert15
-rw-r--r--src/quickshapes/shaders/lineargradient.frag9
-rw-r--r--src/quickshapes/shaders/lineargradient.vert15
-rw-r--r--src/quickshapes/shaders/lineargradient_core.frag12
-rw-r--r--src/quickshapes/shaders/lineargradient_core.vert17
-rw-r--r--src/quickshapes/shaders/radialgradient.frag25
-rw-r--r--src/quickshapes/shaders/radialgradient.vert13
-rw-r--r--src/quickshapes/shaders/radialgradient_core.frag29
-rw-r--r--src/quickshapes/shaders/radialgradient_core.vert15
132 files changed, 685 insertions, 7272 deletions
diff --git a/examples/quick/scenegraph/graph/linenode.cpp b/examples/quick/scenegraph/graph/linenode.cpp
index 5d4d8acd20..6cdf063bb9 100644
--- a/examples/quick/scenegraph/graph/linenode.cpp
+++ b/examples/quick/scenegraph/graph/linenode.cpp
@@ -54,7 +54,7 @@
#include <QtQuick/QSGMaterial>
-class LineShader : public QSGMaterialRhiShader
+class LineShader : public QSGMaterialShader
{
public:
LineShader() {
@@ -70,7 +70,6 @@ class LineMaterial : public QSGMaterial
public:
LineMaterial()
{
- setFlag(SupportsRhiShader);
setFlag(Blending);
}
@@ -82,7 +81,6 @@ public:
QSGMaterialShader *createShader() const override
{
- Q_ASSERT(flags().testFlag(RhiShaderWanted));
return new LineShader;
}
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp
index c39e775e98..c35b4ee01e 100644
--- a/examples/quick/scenegraph/graph/noisynode.cpp
+++ b/examples/quick/scenegraph/graph/noisynode.cpp
@@ -58,7 +58,7 @@
#define NOISE_SIZE 64
-class NoisyShader : public QSGMaterialRhiShader
+class NoisyShader : public QSGMaterialShader
{
public:
NoisyShader() {
@@ -76,7 +76,6 @@ class NoisyMaterial : public QSGMaterial
public:
NoisyMaterial()
{
- setFlag(SupportsRhiShader);
setFlag(Blending);
}
@@ -93,7 +92,6 @@ public:
QSGMaterialShader *createShader() const override
{
- Q_ASSERT(flags().testFlag(RhiShaderWanted));
return new NoisyShader;
}
diff --git a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp
index 9971f202a7..cb61679141 100644
--- a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp
+++ b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp
@@ -78,7 +78,7 @@ public:
} state;
};
-class XorBlendRhiShader : public QSGMaterialRhiShader
+class XorBlendRhiShader : public QSGMaterialShader
{
public:
XorBlendRhiShader();
@@ -90,13 +90,11 @@ public:
XorBlendMaterial::XorBlendMaterial()
{
- setFlag(SupportsRhiShader);
setFlag(Blending);
}
QSGMaterialShader *XorBlendMaterial::createShader() const
{
- Q_ASSERT(flags().testFlag(RhiShaderWanted));
return new XorBlendRhiShader;
}
diff --git a/src/particles/CMakeLists.txt b/src/particles/CMakeLists.txt
index 085b4d27f1..c0c72578bd 100644
--- a/src/particles/CMakeLists.txt
+++ b/src/particles/CMakeLists.txt
@@ -64,10 +64,6 @@ qt_add_resource(QuickParticles "particles"
${particles_resource_files}
)
set(particles1_resource_files
- "shaders/imageparticle.frag"
- "shaders/imageparticle.vert"
- "shaders/imageparticle_core.frag"
- "shaders/imageparticle_core.vert"
"shaders_ng/imageparticle_colored.frag.qsb"
"shaders_ng/imageparticle_colored.vert.qsb"
"shaders_ng/imageparticle_deformed.frag.qsb"
diff --git a/src/particles/particles.qrc b/src/particles/particles.qrc
index 7727691233..5e76563842 100644
--- a/src/particles/particles.qrc
+++ b/src/particles/particles.qrc
@@ -6,11 +6,6 @@
<file>particleresources/star.png</file>
</qresource>
<qresource prefix="/particles">
- <file>shaders/imageparticle.frag</file>
- <file>shaders/imageparticle.vert</file>
- <file>shaders/imageparticle_core.frag</file>
- <file>shaders/imageparticle_core.vert</file>
-
<file>shaders_ng/imageparticle_simple.vert.qsb</file>
<file>shaders_ng/imageparticle_simple.frag.qsb</file>
<file>shaders_ng/imageparticle_tabled.vert.qsb</file>
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index f2e3715061..d33db8de76 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -48,7 +48,6 @@
#include "qquickparticleemitter_p.h"
#include <private/qquicksprite_p.h>
#include <private/qquickspriteengine_p.h>
-#include <QOpenGLFunctions>
#include <QSGRendererInterface>
#include <QtQuick/private/qsgshadersourcebuilder_p.h>
#include <QtQuick/private/qsgplaintexture_p.h>
@@ -86,91 +85,7 @@ class ImageMaterialData
QSizeF animSheetSize;
};
-class TabledMaterialShader : public QSGMaterialShader
-{
-public:
- TabledMaterialShader()
- {
- QSGShaderSourceBuilder builder;
- const bool isES = QOpenGLContext::currentContext()->isOpenGLES();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert"));
- builder.addDefinition(QByteArrayLiteral("TABLE"));
- builder.addDefinition(QByteArrayLiteral("DEFORM"));
- builder.addDefinition(QByteArrayLiteral("COLOR"));
- if (isES)
- builder.removeVersion();
-
- m_vertex_code = builder.source();
- builder.clear();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag"));
- builder.addDefinition(QByteArrayLiteral("TABLE"));
- builder.addDefinition(QByteArrayLiteral("DEFORM"));
- builder.addDefinition(QByteArrayLiteral("COLOR"));
- if (isES)
- builder.removeVersion();
-
- m_fragment_code = builder.source();
-
- Q_ASSERT(!m_vertex_code.isNull());
- Q_ASSERT(!m_fragment_code.isNull());
- }
-
- const char *vertexShader() const override { return m_vertex_code.constData(); }
- const char *fragmentShader() const override { return m_fragment_code.constData(); }
-
- char const *const *attributeNames() const override
- {
- static const char *const attr[] = { "vPosTex", "vData", "vVec", "vColor", "vDeformVec", "vRotation", nullptr };
- return attr;
- }
-
- void initialize() override {
- program()->bind();
- program()->setUniformValue("_qt_texture", 0);
- program()->setUniformValue("colortable", 1);
- glFuncs = QOpenGLContext::currentContext()->functions();
- m_matrix_id = program()->uniformLocation("qt_Matrix");
- m_opacity_id = program()->uniformLocation("qt_Opacity");
- m_timestamp_id = program()->uniformLocation("timestamp");
- m_entry_id = program()->uniformLocation("entry");
- m_sizetable_id = program()->uniformLocation("sizetable");
- m_opacitytable_id = program()->uniformLocation("opacitytable");
- }
-
- void updateState(const RenderState &renderState, QSGMaterial *mat, QSGMaterial *) override {
- ImageMaterialData *state = static_cast<ImageMaterial *>(mat)->state();
-
- if (renderState.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, renderState.combinedMatrix());
- if (renderState.isOpacityDirty() && m_opacity_id >= 0)
- program()->setUniformValue(m_opacity_id, renderState.opacity());
-
- glFuncs->glActiveTexture(GL_TEXTURE1);
- state->colorTable->bind();
-
- glFuncs->glActiveTexture(GL_TEXTURE0);
- state->texture->bind();
-
- program()->setUniformValue(m_timestamp_id, (float) state->timestamp);
- program()->setUniformValue(m_entry_id, (float) state->entry);
- program()->setUniformValueArray(m_sizetable_id, (const float*) state->sizeTable, UNIFORM_ARRAY_SIZE, 1);
- program()->setUniformValueArray(m_opacitytable_id, (const float*) state->opacityTable, UNIFORM_ARRAY_SIZE, 1);
- }
-
- int m_matrix_id;
- int m_opacity_id;
- int m_entry_id;
- int m_timestamp_id;
- int m_sizetable_id;
- int m_opacitytable_id;
- QByteArray m_vertex_code;
- QByteArray m_fragment_code;
- QOpenGLFunctions* glFuncs;
-};
-
-class TabledMaterialRhiShader : public QSGMaterialRhiShader
+class TabledMaterialRhiShader : public QSGMaterialShader
{
public:
TabledMaterialRhiShader()
@@ -233,12 +148,8 @@ public:
class TabledMaterial : public ImageMaterial
{
public:
- TabledMaterial() { setFlag(SupportsRhiShader, true); }
QSGMaterialShader *createShader() const override {
- if (flags().testFlag(RhiShaderWanted))
- return new TabledMaterialRhiShader;
- else
- return new TabledMaterialShader;
+ return new TabledMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -251,78 +162,7 @@ private:
QSGMaterialType TabledMaterial::m_type;
-class DeformableMaterialShader : public QSGMaterialShader
-{
-public:
- DeformableMaterialShader()
- {
- QSGShaderSourceBuilder builder;
- const bool isES = QOpenGLContext::currentContext()->isOpenGLES();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert"));
- builder.addDefinition(QByteArrayLiteral("DEFORM"));
- builder.addDefinition(QByteArrayLiteral("COLOR"));
- if (isES)
- builder.removeVersion();
-
- m_vertex_code = builder.source();
- builder.clear();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag"));
- builder.addDefinition(QByteArrayLiteral("DEFORM"));
- builder.addDefinition(QByteArrayLiteral("COLOR"));
- if (isES)
- builder.removeVersion();
-
- m_fragment_code = builder.source();
-
- Q_ASSERT(!m_vertex_code.isNull());
- Q_ASSERT(!m_fragment_code.isNull());
- }
-
- const char *vertexShader() const override { return m_vertex_code.constData(); }
- const char *fragmentShader() const override { return m_fragment_code.constData(); }
-
- char const *const *attributeNames() const override
- {
- static const char *const attr[] = { "vPosTex", "vData", "vVec", "vColor", "vDeformVec", "vRotation", nullptr };
- return attr;
- }
-
- void initialize() override {
- program()->bind();
- program()->setUniformValue("_qt_texture", 0);
- glFuncs = QOpenGLContext::currentContext()->functions();
- m_matrix_id = program()->uniformLocation("qt_Matrix");
- m_opacity_id = program()->uniformLocation("qt_Opacity");
- m_timestamp_id = program()->uniformLocation("timestamp");
- m_entry_id = program()->uniformLocation("entry");
- }
-
- void updateState(const RenderState &renderState, QSGMaterial *mat, QSGMaterial *) override {
- ImageMaterialData *state = static_cast<ImageMaterial *>(mat)->state();
-
- if (renderState.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, renderState.combinedMatrix());
- if (renderState.isOpacityDirty() && m_opacity_id >= 0)
- program()->setUniformValue(m_opacity_id, renderState.opacity());
-
- state->texture->bind();
-
- program()->setUniformValue(m_timestamp_id, (float) state->timestamp);
- program()->setUniformValue(m_entry_id, (float) state->entry);
- }
-
- int m_matrix_id;
- int m_opacity_id;
- int m_entry_id;
- int m_timestamp_id;
- QByteArray m_vertex_code;
- QByteArray m_fragment_code;
- QOpenGLFunctions* glFuncs;
-};
-
-class DeformableMaterialRhiShader : public QSGMaterialRhiShader
+class DeformableMaterialRhiShader : public QSGMaterialShader
{
public:
DeformableMaterialRhiShader()
@@ -371,12 +211,8 @@ public:
class DeformableMaterial : public ImageMaterial
{
public:
- DeformableMaterial() { setFlag(SupportsRhiShader, true); }
QSGMaterialShader *createShader() const override {
- if (flags().testFlag(RhiShaderWanted))
- return new DeformableMaterialRhiShader;
- else
- return new DeformableMaterialShader;
+ return new DeformableMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -389,96 +225,7 @@ private:
QSGMaterialType DeformableMaterial::m_type;
-class ParticleSpriteMaterialShader : public QSGMaterialShader
-{
-public:
- ParticleSpriteMaterialShader()
- {
- QSGShaderSourceBuilder builder;
- const bool isES = QOpenGLContext::currentContext()->isOpenGLES();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert"));
- builder.addDefinition(QByteArrayLiteral("SPRITE"));
- builder.addDefinition(QByteArrayLiteral("TABLE"));
- builder.addDefinition(QByteArrayLiteral("DEFORM"));
- builder.addDefinition(QByteArrayLiteral("COLOR"));
- if (isES)
- builder.removeVersion();
-
- m_vertex_code = builder.source();
- builder.clear();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag"));
- builder.addDefinition(QByteArrayLiteral("SPRITE"));
- builder.addDefinition(QByteArrayLiteral("TABLE"));
- builder.addDefinition(QByteArrayLiteral("DEFORM"));
- builder.addDefinition(QByteArrayLiteral("COLOR"));
- if (isES)
- builder.removeVersion();
-
- m_fragment_code = builder.source();
-
- Q_ASSERT(!m_vertex_code.isNull());
- Q_ASSERT(!m_fragment_code.isNull());
- }
-
- const char *vertexShader() const override { return m_vertex_code.constData(); }
- const char *fragmentShader() const override { return m_fragment_code.constData(); }
-
- char const *const *attributeNames() const override
- {
- static const char *const attr[] = { "vPosTex", "vData", "vVec", "vColor", "vDeformVec", "vRotation",
- "vAnimData", "vAnimPos", nullptr };
- return attr;
- }
-
- void initialize() override {
- program()->bind();
- program()->setUniformValue("_qt_texture", 0);
- program()->setUniformValue("colortable", 1);
- glFuncs = QOpenGLContext::currentContext()->functions();
- m_matrix_id = program()->uniformLocation("qt_Matrix");
- m_opacity_id = program()->uniformLocation("qt_Opacity");
- //Don't actually expose the animSheetSize in the shader, it's currently only used for CPU calculations.
- m_timestamp_id = program()->uniformLocation("timestamp");
- m_entry_id = program()->uniformLocation("entry");
- m_sizetable_id = program()->uniformLocation("sizetable");
- m_opacitytable_id = program()->uniformLocation("opacitytable");
- }
-
- void updateState(const RenderState &renderState, QSGMaterial *mat, QSGMaterial *) override {
- ImageMaterialData *state = static_cast<ImageMaterial *>(mat)->state();
-
- if (renderState.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, renderState.combinedMatrix());
- if (renderState.isOpacityDirty() && m_opacity_id >= 0)
- program()->setUniformValue(m_opacity_id, renderState.opacity());
-
- glFuncs->glActiveTexture(GL_TEXTURE1);
- state->colorTable->bind();
-
- // make sure we end by setting GL_TEXTURE0 as active texture
- glFuncs->glActiveTexture(GL_TEXTURE0);
- state->texture->bind();
-
- program()->setUniformValue(m_timestamp_id, (float) state->timestamp);
- program()->setUniformValue(m_entry_id, (float) state->entry);
- program()->setUniformValueArray(m_sizetable_id, (const float*) state->sizeTable, 64, 1);
- program()->setUniformValueArray(m_opacitytable_id, (const float*) state->opacityTable, UNIFORM_ARRAY_SIZE, 1);
- }
-
- int m_matrix_id;
- int m_opacity_id;
- int m_timestamp_id;
- int m_entry_id;
- int m_sizetable_id;
- int m_opacitytable_id;
- QByteArray m_vertex_code;
- QByteArray m_fragment_code;
- QOpenGLFunctions* glFuncs;
-};
-
-class ParticleSpriteMaterialRhiShader : public QSGMaterialRhiShader
+class ParticleSpriteMaterialRhiShader : public QSGMaterialShader
{
public:
ParticleSpriteMaterialRhiShader()
@@ -541,12 +288,8 @@ public:
class SpriteMaterial : public ImageMaterial
{
public:
- SpriteMaterial() { setFlag(SupportsRhiShader, true); }
QSGMaterialShader *createShader() const override {
- if (flags().testFlag(RhiShaderWanted))
- return new ParticleSpriteMaterialRhiShader;
- else
- return new ParticleSpriteMaterialShader;
+ return new ParticleSpriteMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -559,90 +302,7 @@ private:
QSGMaterialType SpriteMaterial::m_type;
-class ColoredMaterialShader : public QSGMaterialShader
-{
-public:
- ColoredMaterialShader()
- {
- QSGShaderSourceBuilder builder;
- const bool isES = QOpenGLContext::currentContext()->isOpenGLES();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert"));
- builder.addDefinition(QByteArrayLiteral("COLOR"));
- if (isES)
- builder.removeVersion();
-
- m_vertex_code = builder.source();
- builder.clear();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag"));
- builder.addDefinition(QByteArrayLiteral("COLOR"));
- if (isES)
- builder.removeVersion();
-
- m_fragment_code = builder.source();
-
- Q_ASSERT(!m_vertex_code.isNull());
- Q_ASSERT(!m_fragment_code.isNull());
- }
-
- const char *vertexShader() const override { return m_vertex_code.constData(); }
- const char *fragmentShader() const override { return m_fragment_code.constData(); }
-
- char const *const *attributeNames() const override
- {
- static const char *const attr[] = { "vPos", "vData", "vVec", "vColor", nullptr };
- return attr;
- }
-
- void initialize() override {
- program()->bind();
- program()->setUniformValue("_qt_texture", 0);
- glFuncs = QOpenGLContext::currentContext()->functions();
- m_matrix_id = program()->uniformLocation("qt_Matrix");
- m_opacity_id = program()->uniformLocation("qt_Opacity");
- m_timestamp_id = program()->uniformLocation("timestamp");
- m_entry_id = program()->uniformLocation("entry");
- }
-
- void activate() override {
-#if !QT_CONFIG(opengles2) && !defined(Q_OS_WIN)
- glEnable(GL_POINT_SPRITE);
- glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
-#endif
- }
-
- void deactivate() override {
-#if !QT_CONFIG(opengles2) && !defined(Q_OS_WIN)
- glDisable(GL_POINT_SPRITE);
- glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
-#endif
- }
-
- void updateState(const RenderState &renderState, QSGMaterial *mat, QSGMaterial *) override {
- ImageMaterialData *state = static_cast<ImageMaterial *>(mat)->state();
-
- if (renderState.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, renderState.combinedMatrix());
- if (renderState.isOpacityDirty() && m_opacity_id >= 0)
- program()->setUniformValue(m_opacity_id, renderState.opacity());
-
- state->texture->bind();
-
- program()->setUniformValue(m_timestamp_id, (float) state->timestamp);
- program()->setUniformValue(m_entry_id, (float) state->entry);
- }
-
- int m_matrix_id;
- int m_opacity_id;
- int m_timestamp_id;
- int m_entry_id;
- QByteArray m_vertex_code;
- QByteArray m_fragment_code;
- QOpenGLFunctions* glFuncs;
-};
-
-class ColoredMaterialRhiShader : public QSGMaterialRhiShader
+class ColoredMaterialRhiShader : public QSGMaterialShader
{
public:
ColoredMaterialRhiShader()
@@ -691,12 +351,8 @@ public:
class ColoredMaterial : public ImageMaterial
{
public:
- ColoredMaterial() { setFlag(SupportsRhiShader, true); }
QSGMaterialShader *createShader() const override {
- if (flags().testFlag(RhiShaderWanted))
- return new ColoredMaterialRhiShader;
- else
- return new ColoredMaterialShader;
+ return new ColoredMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -709,88 +365,7 @@ private:
QSGMaterialType ColoredMaterial::m_type;
-class SimpleMaterialShader : public QSGMaterialShader
-{
-public:
- SimpleMaterialShader()
- {
- QSGShaderSourceBuilder builder;
- const bool isES = QOpenGLContext::currentContext()->isOpenGLES();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert"));
- if (isES)
- builder.removeVersion();
-
- m_vertex_code = builder.source();
- builder.clear();
-
- builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag"));
- if (isES)
- builder.removeVersion();
-
- m_fragment_code = builder.source();
-
- Q_ASSERT(!m_vertex_code.isNull());
- Q_ASSERT(!m_fragment_code.isNull());
- }
-
- const char *vertexShader() const override { return m_vertex_code.constData(); }
- const char *fragmentShader() const override { return m_fragment_code.constData(); }
-
- char const *const *attributeNames() const override
- {
- static const char *const attr[] = { "vPos", "vData", "vVec", nullptr };
- return attr;
- }
-
- void initialize() override {
- program()->bind();
- program()->setUniformValue("_qt_texture", 0);
- glFuncs = QOpenGLContext::currentContext()->functions();
- m_matrix_id = program()->uniformLocation("qt_Matrix");
- m_opacity_id = program()->uniformLocation("qt_Opacity");
- m_timestamp_id = program()->uniformLocation("timestamp");
- m_entry_id = program()->uniformLocation("entry");
- }
-
- void activate() override {
-#if !QT_CONFIG(opengles2) && !defined(Q_OS_WIN)
- glEnable(GL_POINT_SPRITE);
- glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
-#endif
- }
-
- void deactivate() override {
-#if !QT_CONFIG(opengles2) && !defined(Q_OS_WIN)
- glDisable(GL_POINT_SPRITE);
- glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
-#endif
- }
-
- void updateState(const RenderState &renderState, QSGMaterial *mat, QSGMaterial *) override {
- ImageMaterialData *state = static_cast<ImageMaterial *>(mat)->state();
-
- if (renderState.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, renderState.combinedMatrix());
- if (renderState.isOpacityDirty() && m_opacity_id >= 0)
- program()->setUniformValue(m_opacity_id, renderState.opacity());
-
- state->texture->bind();
-
- program()->setUniformValue(m_timestamp_id, (float) state->timestamp);
- program()->setUniformValue(m_entry_id, (float) state->entry);
- }
-
- int m_matrix_id;
- int m_opacity_id;
- int m_timestamp_id;
- int m_entry_id;
- QByteArray m_vertex_code;
- QByteArray m_fragment_code;
- QOpenGLFunctions* glFuncs;
-};
-
-class SimpleMaterialRhiShader : public QSGMaterialRhiShader
+class SimpleMaterialRhiShader : public QSGMaterialShader
{
public:
SimpleMaterialRhiShader()
@@ -839,12 +414,8 @@ public:
class SimpleMaterial : public ImageMaterial
{
public:
- SimpleMaterial() { setFlag(SupportsRhiShader, true); }
QSGMaterialShader *createShader() const override {
- if (flags().testFlag(RhiShaderWanted))
- return new SimpleMaterialRhiShader;
- else
- return new SimpleMaterialShader;
+ return new SimpleMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -1634,7 +1205,7 @@ void QQuickImageParticle::buildParticleNodes(QSGNode** passThrough)
void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
{
- if (!m_rhi && !QOpenGLContext::currentContext())
+ if (!m_rhi)
return;
if (m_count * 4 > 0xffff) {
@@ -1682,36 +1253,11 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
}
}
- if (!m_rhi) { // the RHI may be backed by GL but these checks should be obsolete in any case
-#ifdef Q_OS_WIN
- if (perfLevel < Deformable) //QTBUG-24540 , point sprite 'extension' isn't working on windows.
- perfLevel = Deformable;
-#endif
-
-#ifdef Q_OS_MAC
- // macOS 10.8.3 introduced a bug in the AMD drivers, for at least the 2011 macbook pros,
- // causing point sprites who read gl_PointCoord in the frag shader to come out as
- // green-red blobs.
- const GLubyte *glVendor = QOpenGLContext::currentContext()->functions()->glGetString(GL_VENDOR);
- if (perfLevel < Deformable && glVendor && strstr((char *) glVendor, "ATI")) {
- perfLevel = Deformable;
- }
-#endif
-
-#ifdef Q_OS_LINUX
- // Nouveau drivers can potentially freeze a machine entirely when taking the point-sprite path.
- const GLubyte *glVendor = QOpenGLContext::currentContext()->functions()->glGetString(GL_VENDOR);
- if (perfLevel < Deformable && glVendor && strstr((const char *) glVendor, "nouveau"))
- perfLevel = Deformable;
-#endif
-
- } else {
- // Points with a size other than 1 are an optional feature with QRhi
- // because some of the underlying APIs have no support for this.
- // Therefore, avoid the point sprite path with APIs like Direct3D.
- if (perfLevel < Deformable && !m_rhi->isFeatureSupported(QRhi::VertexShaderPointSize))
- perfLevel = Deformable;
- }
+ // Points with a size other than 1 are an optional feature with QRhi
+ // because some of the underlying APIs have no support for this.
+ // Therefore, avoid the point sprite path with APIs like Direct3D.
+ if (perfLevel < Deformable && !m_rhi->isFeatureSupported(QRhi::VertexShaderPointSize))
+ perfLevel = Deformable;
if (perfLevel >= Colored && !m_color.isValid())
m_color = QColor(Qt::white);//Hidden default, but different from unset
@@ -1850,19 +1396,8 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
node->setGeometry(g);
if (perfLevel <= Colored){
g->setDrawingMode(QSGGeometry::DrawPoints);
- if (m_debugMode) {
- if (m_rhi) {
- qDebug("Using point sprites");
- } else {
-#if QT_CONFIG(opengl)
- GLfloat pointSizeRange[2];
- QOpenGLContext::currentContext()->functions()->glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, pointSizeRange);
- qDebug() << "Using point sprites, GL_ALIASED_POINT_SIZE_RANGE " <<pointSizeRange[0] << ":" << pointSizeRange[1];
-#else
- qDebug("Using point sprites");
-#endif
- }
- }
+ if (m_debugMode)
+ qDebug("Using point sprites");
} else {
g->setDrawingMode(QSGGeometry::DrawTriangles);
}
@@ -1918,10 +1453,9 @@ QSGNode *QQuickImageParticle::updatePaintNode(QSGNode *node, UpdatePaintNodeData
return nullptr;
QSGRendererInterface::GraphicsApi api = rif->graphicsApi();
- const bool isDirectOpenGL = api == QSGRendererInterface::OpenGL;
const bool isRhi = QSGRendererInterface::isApiRhiBased(api);
- if (!node && !isDirectOpenGL && !isRhi)
+ if (!node && !isRhi)
return nullptr;
if (isRhi)
diff --git a/src/particles/shaders/imageparticle.frag b/src/particles/shaders/imageparticle.frag
deleted file mode 100644
index 92795a5381..0000000000
--- a/src/particles/shaders/imageparticle.frag
+++ /dev/null
@@ -1,42 +0,0 @@
-#version 120
-
-uniform sampler2D _qt_texture;
-uniform lowp float qt_Opacity;
-
-#if defined(SPRITE)
-varying highp vec4 fTexS;
-#elif defined(DEFORM)
-varying highp vec2 fTex;
-#endif
-
-#if defined(COLOR)
-varying lowp vec4 fColor;
-#else
-varying lowp float fFade;
-#endif
-
-#if defined(TABLE)
-varying lowp vec2 tt;
-uniform sampler2D colortable;
-#endif
-
-void main()
-{
-#if defined(SPRITE)
- gl_FragColor = mix(texture2D(_qt_texture, fTexS.xy), texture2D(_qt_texture, fTexS.zw), tt.y)
- * fColor
- * texture2D(colortable, tt)
- * qt_Opacity;
-#elif defined(TABLE)
- gl_FragColor = texture2D(_qt_texture, fTex)
- * fColor
- * texture2D(colortable, tt)
- * qt_Opacity;
-#elif defined(DEFORM)
- gl_FragColor = (texture2D(_qt_texture, fTex)) * fColor * qt_Opacity;
-#elif defined(COLOR)
- gl_FragColor = (texture2D(_qt_texture, gl_PointCoord)) * fColor * qt_Opacity;
-#else
- gl_FragColor = texture2D(_qt_texture, gl_PointCoord) * (fFade * qt_Opacity);
-#endif
-} \ No newline at end of file
diff --git a/src/particles/shaders/imageparticle.vert b/src/particles/shaders/imageparticle.vert
deleted file mode 100644
index 4057a9eb4b..0000000000
--- a/src/particles/shaders/imageparticle.vert
+++ /dev/null
@@ -1,141 +0,0 @@
-#version 120
-
-#if defined(DEFORM)
-attribute highp vec4 vPosTex;
-#else
-attribute highp vec2 vPos;
-#endif
-
-attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
-attribute highp vec4 vVec; // x,y = constant velocity, z,w = acceleration
-uniform highp float entry;
-
-#if defined(COLOR)
-attribute highp vec4 vColor;
-#endif
-
-#if defined(DEFORM)
-attribute highp vec4 vDeformVec; // x,y x unit vector; z,w = y unit vector
-attribute highp vec3 vRotation; // x = radians of rotation, y = rotation velocity, z = bool autoRotate
-#endif
-
-#if defined(SPRITE)
-attribute highp vec3 vAnimData; // w,h(premultiplied of anim), interpolation progress
-attribute highp vec4 vAnimPos; // x,y, x,y (two frames for interpolation)
-#endif
-
-uniform highp mat4 qt_Matrix;
-uniform highp float timestamp;
-
-#if defined(TABLE)
-varying lowp vec2 tt;//y is progress if Sprite mode
-uniform highp float sizetable[64];
-uniform highp float opacitytable[64];
-#endif
-
-#if defined(SPRITE)
-varying highp vec4 fTexS;
-#elif defined(DEFORM)
-varying highp vec2 fTex;
-#endif
-
-#if defined(COLOR)
-varying lowp vec4 fColor;
-#else
-varying lowp float fFade;
-#endif
-
-
-void main()
-{
- highp float t = (timestamp - vData.x) / vData.y;
- if (t < 0. || t > 1.) {
-#if defined(DEFORM)
- gl_Position = qt_Matrix * vec4(vPosTex.x, vPosTex.y, 0., 1.);
-#else
- gl_PointSize = 0.;
-#endif
- } else {
-#if defined(SPRITE)
- tt.y = vAnimData.z;
-
- // Calculate frame location in texture
- fTexS.xy = vAnimPos.xy + vPosTex.zw * vAnimData.xy;
-
- // Next frame is also passed, for interpolation
- fTexS.zw = vAnimPos.zw + vPosTex.zw * vAnimData.xy;
-
-#elif defined(DEFORM)
- fTex = vPosTex.zw;
-#endif
- highp float currentSize = mix(vData.z, vData.w, t * t);
- lowp float fade = 1.;
- highp float fadeIn = min(t * 10., 1.);
- highp float fadeOut = 1. - clamp((t - 0.75) * 4.,0., 1.);
-
-#if defined(TABLE)
- currentSize = currentSize * sizetable[int(floor(t*64.))];
- fade = fade * opacitytable[int(floor(t*64.))];
-#endif
-
- if (entry == 1.)
- fade = fade * fadeIn * fadeOut;
- else if (entry == 2.)
- currentSize = currentSize * fadeIn * fadeOut;
-
- if (currentSize <= 0.) {
-#if defined(DEFORM)
- gl_Position = qt_Matrix * vec4(vPosTex.x, vPosTex.y, 0., 1.);
-#else
- gl_PointSize = 0.;
-#endif
- } else {
- if (currentSize < 3.) // Sizes too small look jittery as they move
- currentSize = 3.;
-
- highp vec2 pos;
-#if defined(DEFORM)
- highp float rotation = vRotation.x + vRotation.y * t * vData.y;
- if (vRotation.z == 1.0){
- highp vec2 curVel = vVec.zw * t * vData.y + vVec.xy;
- if (length(curVel) > 0.)
- rotation += atan(curVel.y, curVel.x);
- }
- highp vec2 trigCalcs = vec2(cos(rotation), sin(rotation));
- highp vec4 deform = vDeformVec * currentSize * (vPosTex.zzww - 0.5);
- highp vec4 rotatedDeform = deform.xxzz * trigCalcs.xyxy;
- rotatedDeform = rotatedDeform + (deform.yyww * trigCalcs.yxyx * vec4(-1.,1.,-1.,1.));
- /* The readable version:
- highp vec2 xDeform = vDeformVec.xy * currentSize * (vTex.x-0.5);
- highp vec2 yDeform = vDeformVec.zw * currentSize * (vTex.y-0.5);
- highp vec2 xRotatedDeform;
- xRotatedDeform.x = trigCalcs.x*xDeform.x - trigCalcs.y*xDeform.y;
- xRotatedDeform.y = trigCalcs.y*xDeform.x + trigCalcs.x*xDeform.y;
- highp vec2 yRotatedDeform;
- yRotatedDeform.x = trigCalcs.x*yDeform.x - trigCalcs.y*yDeform.y;
- yRotatedDeform.y = trigCalcs.y*yDeform.x + trigCalcs.x*yDeform.y;
- */
- pos = vPosTex.xy
- + rotatedDeform.xy
- + rotatedDeform.zw
- + vVec.xy * t * vData.y // apply velocity
- + 0.5 * vVec.zw * pow(t * vData.y, 2.); // apply acceleration
-#else
- pos = vPos
- + vVec.xy * t * vData.y // apply velocity vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
- gl_PointSize = currentSize;
-#endif
- gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
-
-#if defined(COLOR)
- fColor = vColor * fade;
-#else
- fFade = fade;
-#endif
-#if defined(TABLE)
- tt.x = t;
-#endif
- }
- }
-}
diff --git a/src/particles/shaders/imageparticle_core.frag b/src/particles/shaders/imageparticle_core.frag
deleted file mode 100644
index 3ac8c8d34e..0000000000
--- a/src/particles/shaders/imageparticle_core.frag
+++ /dev/null
@@ -1,44 +0,0 @@
-#version 150 core
-
-#if defined(SPRITE)
-in vec4 fTexS;
-#elif defined(DEFORM)
-in vec2 fTex;
-#endif
-
-#if defined(COLOR)
-in vec4 fColor;
-#else
-in float fFade;
-#endif
-
-#if defined(TABLE)
-in vec2 tt;
-uniform sampler2D colortable;
-#endif
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform float qt_Opacity;
-
-void main()
-{
-#if defined(SPRITE)
- fragColor = mix(texture(_qt_texture, fTexS.xy), texture(_qt_texture, fTexS.zw), tt.y)
- * fColor
- * texture(colortable, tt)
- * qt_Opacity;
-#elif defined(TABLE)
- fragColor = texture(_qt_texture, fTex)
- * fColor
- * texture(colortable, tt)
- * qt_Opacity;
-#elif defined(DEFORM)
- fragColor = texture(_qt_texture, fTex) * fColor * qt_Opacity;
-#elif defined(COLOR)
- fragColor = texture(_qt_texture, gl_PointCoord) * fColor * qt_Opacity;
-#else
- fragColor = texture(_qt_texture, gl_PointCoord) * fFade * qt_Opacity;
-#endif
-} \ No newline at end of file
diff --git a/src/particles/shaders/imageparticle_core.vert b/src/particles/shaders/imageparticle_core.vert
deleted file mode 100644
index cfa0d57dfd..0000000000
--- a/src/particles/shaders/imageparticle_core.vert
+++ /dev/null
@@ -1,141 +0,0 @@
-#version 150 core
-
-#if defined(DEFORM)
-in vec4 vPosTex;
-#else
-in vec2 vPos;
-#endif
-
-in vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
-in vec4 vVec; // x,y = constant velocity, z,w = acceleration
-uniform float entry;
-
-#if defined(COLOR)
-in vec4 vColor;
-#endif
-
-#if defined(DEFORM)
-in vec4 vDeformVec; // x,y x unit vector; z,w = y unit vector
-in vec3 vRotation; // x = radians of rotation, y = rotation velocity, z = bool autoRotate
-#endif
-
-#if defined(SPRITE)
-in vec3 vAnimData; // w,h(premultiplied of anim), interpolation progress
-in vec4 vAnimPos; // x,y, x,y (two frames for interpolation)
-#endif
-
-uniform mat4 qt_Matrix;
-uniform float timestamp;
-
-#if defined(TABLE)
-out vec2 tt;//y is progress if Sprite mode
-uniform float sizetable[64];
-uniform float opacitytable[64];
-#endif
-
-#if defined(SPRITE)
-out vec4 fTexS;
-#elif defined(DEFORM)
-out vec2 fTex;
-#endif
-
-#if defined(COLOR)
-out vec4 fColor;
-#else
-out float fFade;
-#endif
-
-
-void main()
-{
- float t = (timestamp - vData.x) / vData.y;
- if (t < 0. || t > 1.) {
-#if defined(DEFORM)
- gl_Position = qt_Matrix * vec4(vPosTex.x, vPosTex.y, 0., 1.);
-#else
- gl_PointSize = 0.;
-#endif
- } else {
-#if defined(SPRITE)
- tt.y = vAnimData.z;
-
- // Calculate frame location in texture
- fTexS.xy = vAnimPos.xy + vPosTex.zw * vAnimData.xy;
-
- // Next frame is also passed, for interpolation
- fTexS.zw = vAnimPos.zw + vPosTex.zw * vAnimData.xy;
-
-#elif defined(DEFORM)
- fTex = vPosTex.zw;
-#endif
- float currentSize = mix(vData.z, vData.w, t * t);
- float fade = 1.;
- float fadeIn = min(t * 10., 1.);
- float fadeOut = 1. - clamp((t - 0.75) * 4.,0., 1.);
-
-#if defined(TABLE)
- currentSize = currentSize * sizetable[int(floor(t*64.))];
- fade = fade * opacitytable[int(floor(t*64.))];
-#endif
-
- if (entry == 1.)
- fade = fade * fadeIn * fadeOut;
- else if (entry == 2.)
- currentSize = currentSize * fadeIn * fadeOut;
-
- if (currentSize <= 0.) {
-#if defined(DEFORM)
- gl_Position = qt_Matrix * vec4(vPosTex.x, vPosTex.y, 0., 1.);
-#else
- gl_PointSize = 0.;
-#endif
- } else {
- if (currentSize < 3.) // Sizes too small look jittery as they move
- currentSize = 3.;
-
- vec2 pos;
-#if defined(DEFORM)
- float rotation = vRotation.x + vRotation.y * t * vData.y;
- if (vRotation.z == 1.0) {
- vec2 curVel = vVec.zw * t * vData.y + vVec.xy;
- if (length(curVel) > 0.)
- rotation += atan(curVel.y, curVel.x);
- }
- vec2 trigCalcs = vec2(cos(rotation), sin(rotation));
- vec4 deform = vDeformVec * currentSize * (vPosTex.zzww - 0.5);
- vec4 rotatedDeform = deform.xxzz * trigCalcs.xyxy;
- rotatedDeform = rotatedDeform + (deform.yyww * trigCalcs.yxyx * vec4(-1.,1.,-1.,1.));
- /* The readable version:
- vec2 xDeform = vDeformVec.xy * currentSize * (vTex.x-0.5);
- vec2 yDeform = vDeformVec.zw * currentSize * (vTex.y-0.5);
- vec2 xRotatedDeform;
- xRotatedDeform.x = trigCalcs.x*xDeform.x - trigCalcs.y*xDeform.y;
- xRotatedDeform.y = trigCalcs.y*xDeform.x + trigCalcs.x*xDeform.y;
- vec2 yRotatedDeform;
- yRotatedDeform.x = trigCalcs.x*yDeform.x - trigCalcs.y*yDeform.y;
- yRotatedDeform.y = trigCalcs.y*yDeform.x + trigCalcs.x*yDeform.y;
- */
- pos = vPosTex.xy
- + rotatedDeform.xy
- + rotatedDeform.zw
- + vVec.xy * t * vData.y // apply velocity
- + 0.5 * vVec.zw * pow(t * vData.y, 2.); // apply acceleration
-#else
- pos = vPos
- + vVec.xy * t * vData.y // apply velocity vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
- gl_PointSize = currentSize;
-#endif
- gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
-
-#if defined(COLOR)
- fColor = vColor * fade;
-#else
- fFade = fade;
-#endif
-#if defined(TABLE)
- tt.x = t;
-#endif
- }
- }
-}
diff --git a/src/quick/CMakeLists.txt b/src/quick/CMakeLists.txt
index a8c8aa378c..5450be04ad 100644
--- a/src/quick/CMakeLists.txt
+++ b/src/quick/CMakeLists.txt
@@ -110,7 +110,6 @@ qt_add_module(Quick
scenegraph/coreapi/qsgabstractrenderer_p_p.h
scenegraph/coreapi/qsggeometry.cpp scenegraph/coreapi/qsggeometry.h scenegraph/coreapi/qsggeometry_p.h
scenegraph/coreapi/qsgmaterial.cpp scenegraph/coreapi/qsgmaterial.h
- scenegraph/coreapi/qsgmaterialrhishader.cpp scenegraph/coreapi/qsgmaterialrhishader.h scenegraph/coreapi/qsgmaterialrhishader_p.h
scenegraph/coreapi/qsgmaterialshader.cpp scenegraph/coreapi/qsgmaterialshader.h scenegraph/coreapi/qsgmaterialshader_p.h
scenegraph/coreapi/qsgmaterialtype.h
scenegraph/coreapi/qsgnode.cpp scenegraph/coreapi/qsgnode.h scenegraph/coreapi/qsgnode_p.h
@@ -199,76 +198,10 @@ qt_add_module(Quick
# Resources:
set(scenegraph_resource_files
- "shaders/24bittextmask.frag"
- "shaders/24bittextmask_core.frag"
- "shaders/32bitcolortext.frag"
- "shaders/32bitcolortext_core.frag"
- "shaders/8bittextmask.frag"
- "shaders/8bittextmask_core.frag"
- "shaders/distancefieldoutlinetext.frag"
- "shaders/distancefieldoutlinetext_core.frag"
- "shaders/distancefieldshiftedtext.frag"
- "shaders/distancefieldshiftedtext.vert"
- "shaders/distancefieldshiftedtext_core.frag"
- "shaders/distancefieldshiftedtext_core.vert"
- "shaders/distancefieldtext.frag"
- "shaders/distancefieldtext.vert"
- "shaders/distancefieldtext_core.frag"
- "shaders/distancefieldtext_core.vert"
- "shaders/flatcolor.frag"
- "shaders/flatcolor.vert"
- "shaders/flatcolor_core.frag"
- "shaders/flatcolor_core.vert"
- "shaders/hiqsubpixeldistancefieldtext.frag"
- "shaders/hiqsubpixeldistancefieldtext.vert"
- "shaders/hiqsubpixeldistancefieldtext_core.frag"
- "shaders/hiqsubpixeldistancefieldtext_core.vert"
- "shaders/loqsubpixeldistancefieldtext.frag"
- "shaders/loqsubpixeldistancefieldtext.vert"
- "shaders/loqsubpixeldistancefieldtext_core.frag"
- "shaders/loqsubpixeldistancefieldtext_core.vert"
- "shaders/opaquetexture.frag"
- "shaders/opaquetexture.vert"
- "shaders/opaquetexture_core.frag"
- "shaders/opaquetexture_core.vert"
- "shaders/outlinedtext.frag"
- "shaders/outlinedtext.vert"
- "shaders/outlinedtext_core.frag"
- "shaders/outlinedtext_core.vert"
- "shaders/rendernode.frag"
- "shaders/rendernode.vert"
- "shaders/rendernode_core.frag"
- "shaders/rendernode_core.vert"
- "shaders/smoothcolor.frag"
- "shaders/smoothcolor.vert"
- "shaders/smoothcolor_core.frag"
- "shaders/smoothcolor_core.vert"
- "shaders/smoothtexture.frag"
- "shaders/smoothtexture.vert"
- "shaders/smoothtexture_core.frag"
- "shaders/smoothtexture_core.vert"
- "shaders/sprite.frag"
- "shaders/sprite.vert"
- "shaders/sprite_core.frag"
- "shaders/sprite_core.vert"
"shaders/stencilclip.frag"
"shaders/stencilclip.vert"
"shaders/stencilclip_core.frag"
"shaders/stencilclip_core.vert"
- "shaders/styledtext.frag"
- "shaders/styledtext.vert"
- "shaders/styledtext_core.frag"
- "shaders/styledtext_core.vert"
- "shaders/textmask.frag"
- "shaders/textmask.vert"
- "shaders/textmask_core.frag"
- "shaders/textmask_core.vert"
- "shaders/texture.frag"
- "shaders/texture_core.frag"
- "shaders/vertexcolor.frag"
- "shaders/vertexcolor.vert"
- "shaders/vertexcolor_core.frag"
- "shaders/vertexcolor_core.vert"
"shaders/visualization.frag"
"shaders/visualization.vert"
"shaders_ng/24bittextmask.frag.qsb"
diff --git a/src/quick/items/qquickopenglshadereffectnode.cpp b/src/quick/items/qquickopenglshadereffectnode.cpp
index 919b92780a..019450935f 100644
--- a/src/quick/items/qquickopenglshadereffectnode.cpp
+++ b/src/quick/items/qquickopenglshadereffectnode.cpp
@@ -107,7 +107,7 @@ void QQuickCustomMaterialShader::deactivate()
QOpenGLContext::currentContext()->functions()->glDisable(GL_CULL_FACE);
}
-void QQuickCustomMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
+void QQuickCustomMaterialShader::updateState(const RenderState &, QSGMaterial *newEffect, QSGMaterial *)
{
typedef QQuickOpenGLShaderEffectMaterial::UniformData UniformData;
@@ -142,6 +142,7 @@ void QQuickCustomMaterialShader::updateState(const RenderState &state, QSGMateri
textureProviderIndex = 0;
}
+#if 0
QOpenGLFunctions *functions = state.context()->functions();
for (int shaderType = 0; shaderType < QQuickOpenGLShaderEffectMaterialKey::ShaderTypeCount; ++shaderType) {
for (int i = 0; i < material->uniforms[shaderType].size(); ++i) {
@@ -254,6 +255,7 @@ void QQuickCustomMaterialShader::updateState(const RenderState &state, QSGMateri
break;
}
}
+#endif
}
char const *const *QQuickCustomMaterialShader::attributeNames() const
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index bf26b44498..a3305bf93e 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -58,7 +58,7 @@
#include <private/qnumeric_p.h>
#include <private/qquickprofiler_p.h>
-#include "qsgmaterialrhishader_p.h"
+#include "qsgmaterialshader_p.h"
#include "qsgopenglvisualizer_p.h"
#include "qsgrhivisualizer_p.h"
@@ -181,12 +181,12 @@ QRhiVertexInputAttribute::Format qsg_vertexInputFormat(const QSGGeometry::Attrib
return QRhiVertexInputAttribute::Float;
}
-static QRhiVertexInputLayout calculateVertexInputLayout(const QSGMaterialRhiShader *s, const QSGGeometry *geometry, bool batchable)
+static QRhiVertexInputLayout calculateVertexInputLayout(const QSGMaterialShader *s, const QSGGeometry *geometry, bool batchable)
{
Q_ASSERT(geometry);
- const QSGMaterialRhiShaderPrivate *sd = QSGMaterialRhiShaderPrivate::get(s);
+ const QSGMaterialShaderPrivate *sd = QSGMaterialShaderPrivate::get(s);
if (!sd->vertexShader) {
- qWarning("No vertex shader in QSGMaterialRhiShader %p", s);
+ qWarning("No vertex shader in QSGMaterialShader %p", s);
return QRhiVertexInputLayout();
}
@@ -269,11 +269,6 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material, boo
if (shader)
return shader;
- if (enableRhiShaders && !material->flags().testFlag(QSGMaterial::SupportsRhiShader)) {
- qWarning("The material failed to provide a working QShader pack");
- return nullptr;
- }
-
Q_TRACE_SCOPE(QSG_prepareMaterial);
if (QSG_LOG_TIME_COMPILATION().isDebugEnabled())
qsg_renderer_timer.start();
@@ -281,13 +276,11 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material, boo
shader = new Shader;
if (enableRhiShaders) {
- material->setFlag(QSGMaterial::RhiShaderWanted, true);
- QSGMaterialRhiShader *s = static_cast<QSGMaterialRhiShader *>(material->createShader());
- material->setFlag(QSGMaterial::RhiShaderWanted, false);
+ QSGMaterialShader *s = static_cast<QSGMaterialShader *>(material->createShader());
context->initializeRhiShader(s, QShader::BatchableVertexShader);
shader->programRhi.program = s;
shader->programRhi.inputLayout = calculateVertexInputLayout(s, geometry, true);
- QSGMaterialRhiShaderPrivate *sD = QSGMaterialRhiShaderPrivate::get(s);
+ QSGMaterialShaderPrivate *sD = QSGMaterialShaderPrivate::get(s);
shader->programRhi.shaderStages = {
{ QRhiGraphicsShaderStage::Vertex, sD->shader(QShader::VertexStage), QShader::BatchableVertexShader },
{ QRhiGraphicsShaderStage::Fragment, sD->shader(QShader::FragmentStage) }
@@ -332,11 +325,6 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate
if (shader)
return shader;
- if (enableRhiShaders && !material->flags().testFlag(QSGMaterial::SupportsRhiShader)) {
- qWarning("The material failed to provide a working QShader pack");
- return nullptr;
- }
-
Q_TRACE_SCOPE(QSG_prepareMaterial);
if (QSG_LOG_TIME_COMPILATION().isDebugEnabled())
qsg_renderer_timer.start();
@@ -344,13 +332,11 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate
shader = new Shader;
if (enableRhiShaders) {
- material->setFlag(QSGMaterial::RhiShaderWanted, true);
- QSGMaterialRhiShader *s = static_cast<QSGMaterialRhiShader *>(material->createShader());
- material->setFlag(QSGMaterial::RhiShaderWanted, false);
+ QSGMaterialShader *s = static_cast<QSGMaterialShader *>(material->createShader());
context->initializeRhiShader(s, QShader::StandardShader);
shader->programRhi.program = s;
shader->programRhi.inputLayout = calculateVertexInputLayout(s, geometry, false);
- QSGMaterialRhiShaderPrivate *sD = QSGMaterialRhiShaderPrivate::get(s);
+ QSGMaterialShaderPrivate *sD = QSGMaterialShaderPrivate::get(s);
shader->programRhi.shaderStages = {
{ QRhiGraphicsShaderStage::Vertex, sD->shader(QShader::VertexStage) },
{ QRhiGraphicsShaderStage::Fragment, sD->shader(QShader::FragmentStage) }
@@ -393,16 +379,16 @@ void ShaderManager::invalidated()
void ShaderManager::clearCachedRendererData()
{
for (ShaderManager::Shader *sms : stockShaders) {
- QSGMaterialRhiShader *s = sms->programRhi.program;
+ QSGMaterialShader *s = sms->programRhi.program;
if (s) {
- QSGMaterialRhiShaderPrivate *sd = QSGMaterialRhiShaderPrivate::get(s);
+ QSGMaterialShaderPrivate *sd = QSGMaterialShaderPrivate::get(s);
sd->clearCachedRendererData();
}
}
for (ShaderManager::Shader *sms : rewrittenShaders) {
- QSGMaterialRhiShader *s = sms->programRhi.program;
+ QSGMaterialShader *s = sms->programRhi.program;
if (s) {
- QSGMaterialRhiShaderPrivate *sd = QSGMaterialRhiShaderPrivate::get(s);
+ QSGMaterialShaderPrivate *sd = QSGMaterialShaderPrivate::get(s);
sd->clearCachedRendererData();
}
}
@@ -2892,10 +2878,10 @@ void Renderer::updateClipState(const QSGClipNode *clipList, Batch *batch) // RHI
}
if (!m_stencilClipCommon.vs.isValid())
- m_stencilClipCommon.vs = QSGMaterialRhiShaderPrivate::loadShader(QLatin1String(":/qt-project.org/scenegraph/shaders_ng/stencilclip.vert.qsb"));
+ m_stencilClipCommon.vs = QSGMaterialShaderPrivate::loadShader(QLatin1String(":/qt-project.org/scenegraph/shaders_ng/stencilclip.vert.qsb"));
if (!m_stencilClipCommon.fs.isValid())
- m_stencilClipCommon.fs = QSGMaterialRhiShaderPrivate::loadShader(QLatin1String(":/qt-project.org/scenegraph/shaders_ng/stencilclip.frag.qsb"));
+ m_stencilClipCommon.fs = QSGMaterialShaderPrivate::loadShader(QLatin1String(":/qt-project.org/scenegraph/shaders_ng/stencilclip.frag.qsb"));
if (!m_stencilClipCommon.replacePs)
m_stencilClipCommon.replacePs = buildStencilPipeline(batch, true);
@@ -2952,10 +2938,10 @@ void Renderer::enqueueStencilDraw(const Batch *batch) // RHI only
}
}
-void Renderer::setActiveRhiShader(QSGMaterialRhiShader *program, ShaderManager::Shader *shader) // RHI only
+void Renderer::setActiveRhiShader(QSGMaterialShader *program, ShaderManager::Shader *shader) // RHI only
{
Q_ASSERT(m_rhi);
- m_currentRhiProgram = program;
+ m_currentProgram = program;
m_currentShader = shader;
m_currentMaterial = nullptr;
}
@@ -3400,26 +3386,26 @@ QRhiTexture *Renderer::dummyTexture()
return m_dummyTexture;
}
-static void rendererToMaterialGraphicsState(QSGMaterialRhiShader::GraphicsPipelineState *dst,
+static void rendererToMaterialGraphicsState(QSGMaterialShader::GraphicsPipelineState *dst,
GraphicsState *src)
{
dst->blendEnable = src->blending;
// the enum values should match, sanity check it
- Q_ASSERT(int(QSGMaterialRhiShader::GraphicsPipelineState::OneMinusSrc1Alpha) == int(QRhiGraphicsPipeline::OneMinusSrc1Alpha));
- Q_ASSERT(int(QSGMaterialRhiShader::GraphicsPipelineState::A) == int(QRhiGraphicsPipeline::A));
- Q_ASSERT(int(QSGMaterialRhiShader::GraphicsPipelineState::CullBack) == int(QRhiGraphicsPipeline::Back));
+ Q_ASSERT(int(QSGMaterialShader::GraphicsPipelineState::OneMinusSrc1Alpha) == int(QRhiGraphicsPipeline::OneMinusSrc1Alpha));
+ Q_ASSERT(int(QSGMaterialShader::GraphicsPipelineState::A) == int(QRhiGraphicsPipeline::A));
+ Q_ASSERT(int(QSGMaterialShader::GraphicsPipelineState::CullBack) == int(QRhiGraphicsPipeline::Back));
- dst->srcColor = QSGMaterialRhiShader::GraphicsPipelineState::BlendFactor(src->srcColor);
- dst->dstColor = QSGMaterialRhiShader::GraphicsPipelineState::BlendFactor(src->dstColor);
+ dst->srcColor = QSGMaterialShader::GraphicsPipelineState::BlendFactor(src->srcColor);
+ dst->dstColor = QSGMaterialShader::GraphicsPipelineState::BlendFactor(src->dstColor);
- dst->colorWrite = QSGMaterialRhiShader::GraphicsPipelineState::ColorMask(int(src->colorWrite));
+ dst->colorWrite = QSGMaterialShader::GraphicsPipelineState::ColorMask(int(src->colorWrite));
- dst->cullMode = QSGMaterialRhiShader::GraphicsPipelineState::CullMode(src->cullMode);
+ dst->cullMode = QSGMaterialShader::GraphicsPipelineState::CullMode(src->cullMode);
}
static void materialToRendererGraphicsState(GraphicsState *dst,
- QSGMaterialRhiShader::GraphicsPipelineState *src)
+ QSGMaterialShader::GraphicsPipelineState *src)
{
dst->blending = src->blendEnable;
dst->srcColor = QRhiGraphicsPipeline::BlendFactor(src->srcColor);
@@ -3429,7 +3415,7 @@ static void materialToRendererGraphicsState(GraphicsState *dst,
}
void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
- QSGMaterialRhiShader::RenderState &renderState,
+ QSGMaterialShader::RenderState &renderState,
QSGMaterial *material,
ShaderManager::ShaderResourceBindingList *bindings,
const Batch *batch,
@@ -3438,8 +3424,8 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
{
m_current_resource_update_batch = m_resourceUpdates;
- QSGMaterialRhiShader *shader = sms->programRhi.program;
- QSGMaterialRhiShaderPrivate *pd = QSGMaterialRhiShaderPrivate::get(shader);
+ QSGMaterialShader *shader = sms->programRhi.program;
+ QSGMaterialShaderPrivate *pd = QSGMaterialShaderPrivate::get(shader);
if (pd->ubufBinding >= 0) {
m_current_uniform_data = &pd->masterUniformData;
const bool changed = shader->updateUniformData(renderState, material, m_currentMaterial);
@@ -3455,7 +3441,7 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
ubufRegionSize));
}
- for (int binding = 0; binding < QSGMaterialRhiShaderPrivate::MAX_SHADER_RESOURCE_BINDINGS; ++binding) {
+ for (int binding = 0; binding < QSGMaterialShaderPrivate::MAX_SHADER_RESOURCE_BINDINGS; ++binding) {
const QRhiShaderResourceBinding::StageFlags stages = pd->combinedImageSamplerBindings[binding];
if (!stages)
continue;
@@ -3520,18 +3506,18 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
}
void Renderer::updateMaterialStaticData(ShaderManager::Shader *sms,
- QSGMaterialRhiShader::RenderState &renderState,
+ QSGMaterialShader::RenderState &renderState,
QSGMaterial *material,
Batch *batch,
bool *gstateChanged) // RHI only, [prepare step]
{
- QSGMaterialRhiShader *shader = sms->programRhi.program;
+ QSGMaterialShader *shader = sms->programRhi.program;
*gstateChanged = false;
- if (shader->flags().testFlag(QSGMaterialRhiShader::UpdatesGraphicsPipelineState)) {
+ if (shader->flags().testFlag(QSGMaterialShader::UpdatesGraphicsPipelineState)) {
// generate the public mini-state from m_gstate, invoke the material,
// write the changes, if any, back to m_gstate, together with a way to
// roll those back.
- QSGMaterialRhiShader::GraphicsPipelineState shaderPs;
+ QSGMaterialShader::GraphicsPipelineState shaderPs;
rendererToMaterialGraphicsState(&shaderPs, &m_gstate);
const bool changed = shader->updateGraphicsPipelineState(renderState, &shaderPs, material, m_currentMaterial);
if (changed) {
@@ -3604,7 +3590,7 @@ bool Renderer::prepareRenderMergedBatch(Batch *batch, PreparedRenderBatch *rende
sms->lastOpacity = m_current_opacity;
}
- QSGMaterialRhiShaderPrivate *pd = QSGMaterialRhiShaderPrivate::get(sms->programRhi.program);
+ QSGMaterialShaderPrivate *pd = QSGMaterialShaderPrivate::get(sms->programRhi.program);
const int ubufSize = pd->masterUniformData.size();
if (pd->ubufBinding >= 0) {
bool ubufRebuild = false;
@@ -3628,7 +3614,7 @@ bool Renderer::prepareRenderMergedBatch(Batch *batch, PreparedRenderBatch *rende
}
}
- QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty)));
+ QSGMaterialShader::RenderState renderState = state(QSGMaterialShader::RenderState::DirtyStates(int(dirty)));
bool pendingGStatePop = false;
updateMaterialStaticData(sms, renderState, material, batch, &pendingGStatePop);
@@ -3776,7 +3762,7 @@ bool Renderer::prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *ren
QMatrix4x4 rootMatrix = batch->root ? qsg_matrixForRoot(batch->root) : QMatrix4x4();
- QSGMaterialRhiShaderPrivate *pd = QSGMaterialRhiShaderPrivate::get(sms->programRhi.program);
+ QSGMaterialShaderPrivate *pd = QSGMaterialShaderPrivate::get(sms->programRhi.program);
const int ubufSize = pd->masterUniformData.size();
if (pd->ubufBinding >= 0) {
int totalUBufSize = 0;
@@ -3805,7 +3791,7 @@ bool Renderer::prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *ren
}
}
- QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty)));
+ QSGMaterialShader::RenderState renderState = state(QSGMaterialShader::RenderState::DirtyStates(int(dirty)));
bool pendingGStatePop = false;
updateMaterialStaticData(sms, renderState,
material, batch, &pendingGStatePop);
@@ -3826,7 +3812,7 @@ bool Renderer::prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *ren
m_current_projection_matrix(2, 3) = 1.0f - e->order * m_zRange;
}
- QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty)));
+ QSGMaterialShader::RenderState renderState = state(QSGMaterialShader::RenderState::DirtyStates(int(dirty)));
ShaderManager::ShaderResourceBindingList bindings;
updateMaterialDynamicData(sms, renderState,
material, &bindings, batch, ubufOffset, ubufSize);
@@ -3970,7 +3956,6 @@ void Renderer::renderBatches()
m_currentMaterial = nullptr;
m_currentShader = nullptr;
m_currentProgram = nullptr;
- m_currentRhiProgram = nullptr;
m_currentClip = nullptr;
m_currentClipState.reset();
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index 3db93bee41..7ac6435fc0 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -672,7 +672,7 @@ struct ShaderManagerShader
int pos_order;
} programGL;
struct {
- QSGMaterialRhiShader *program = nullptr;
+ QSGMaterialShader *program = nullptr;
QRhiVertexInputLayout inputLayout;
QVarLengthArray<QRhiGraphicsShaderStage, 2> shaderStages;
} programRhi;
@@ -804,10 +804,10 @@ private:
void renderBatches();
bool ensurePipelineState(Element *e, const ShaderManager::Shader *sms);
QRhiTexture *dummyTexture();
- void updateMaterialDynamicData(ShaderManager::Shader *sms, QSGMaterialRhiShader::RenderState &renderState,
+ void updateMaterialDynamicData(ShaderManager::Shader *sms, QSGMaterialShader::RenderState &renderState,
QSGMaterial *material, ShaderManager::ShaderResourceBindingList *bindings,
const Batch *batch, int ubufOffset, int ubufRegionSize);
- void updateMaterialStaticData(ShaderManager::Shader *sms, QSGMaterialRhiShader::RenderState &renderState,
+ void updateMaterialStaticData(ShaderManager::Shader *sms, QSGMaterialShader::RenderState &renderState,
QSGMaterial *material, Batch *batch, bool *gstateChanged);
void checkLineWidth(QSGGeometry *g);
bool prepareRenderMergedBatch(Batch *batch, PreparedRenderBatch *renderBatch);
@@ -828,7 +828,7 @@ private:
bool prepareRhiRenderNode(Batch *batch, PreparedRenderBatch *renderBatch);
void renderRhiRenderNode(const Batch *batch);
void setActiveShader(QSGMaterialShader *program, ShaderManager::Shader *shader);
- void setActiveRhiShader(QSGMaterialRhiShader *program, ShaderManager::Shader *shader);
+ void setActiveRhiShader(QSGMaterialShader *program, ShaderManager::Shader *shader);
bool changeBatchRoot(Node *node, Node *newRoot);
void registerBatchRoot(Node *childRoot, Node *parentRoot);
@@ -884,7 +884,6 @@ private:
ShaderManager *m_shaderManager; // per rendercontext, shared
QSGMaterial *m_currentMaterial;
QSGMaterialShader *m_currentProgram;
- QSGMaterialRhiShader *m_currentRhiProgram;
ShaderManager::Shader *m_currentShader;
ClipState m_currentClipState;
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
index 7984547ef1..0094fc2015 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
@@ -98,9 +98,9 @@ static void qt_print_material_count()
\inmodule QtQuick
\ingroup qtquick-scenegraph-materials
- The QSGMaterial, QSGMaterialShader and QSGMaterialRhiShader subclasses
+ The QSGMaterial, QSGMaterialShader and QSGMaterialShader subclasses
form a tight relationship. For one scene graph (including nested graphs),
- there is one unique QSGMaterialShader or QSGMaterialRhiShader instance
+ there is one unique QSGMaterialShader or QSGMaterialShader instance
which encapsulates the shaders the scene graph uses to render that
material, such as a shader to flat coloring of geometry. Each
QSGGeometryNode can have a unique QSGMaterial containing the how the shader
@@ -110,7 +110,7 @@ static void qt_print_material_count()
QSGMaterial has two virtual functions that both need to be implemented. The
function type() should return a unique instance for all instances of a
specific subclass. The createShader() function should return a new instance
- of QSGMaterialShader or QSGMaterialRhiShader, specific to that subclass of
+ of QSGMaterialShader or QSGMaterialShader, specific to that subclass of
QSGMaterial.
A minimal QSGMaterial implementation could look like this:
@@ -123,27 +123,6 @@ static void qt_print_material_count()
};
\endcode
- This is suitable only for the OpenGL-based, traditional renderer of the
- scene graph. When using the new, graphics API abstracted renderer,
- materials must create QSGMaterialRhiShader instances instead, or in
- addition:
- \code
- class Material : public QSGMaterial
- {
- public:
- Material() { setFlag(SupportsRhiShader, true); }
- QSGMaterialType *type() const { static QSGMaterialType type; return &type; }
- QSGMaterialShader *createShader() {
- if (flags().testFlag(RhiShaderWanted)) {
- return new RhiShader;
- } else {
- // this is optional, relevant for materials that intend to be usable with the legacy OpenGL renderer as well
- return new Shader;
- }
- }
- };
- \endcode
-
\note All classes with QSG prefix should be used solely on the scene graph's
rendering thread. See \l {Scene Graph and Rendering} for more information.
*/
@@ -203,17 +182,6 @@ QSGMaterial::~QSGMaterial()
\value CustomCompileStep Starting with Qt 5.2, the scene graph will not always call
QSGMaterialShader::compile() when its shader program is compiled and linked.
Set this flag to enforce that the function is called.
-
- \value SupportsRhiShader Starting with Qt 5.14, the scene graph supports
- QSGMaterialRhiShader as an alternative to the OpenGL-specific
- QSGMaterialShader. Set this flag to indicate createShader() is capable of
- returning QSGMaterialRhiShader instances when the RhiShaderWanted flag is
- set.
-
- \value RhiShaderWanted This flag is set by the scene graph, not by the
- QSGMaterial. When set, and that can only happen when SupportsRhiShader was
- set by the material, it indicates that createShader() must return a
- QSGMaterialRhiShader instance instead of QSGMaterialShader.
*/
/*!
@@ -279,11 +247,6 @@ int QSGMaterial::compare(const QSGMaterial *other) const
The function will be called only once for each material type that
exists in the scene graph and will be cached internally.
-
- When the QSGMaterial reports SupportsRhiShader in flags(), the scene graph
- may request a QSGMaterialRhiShader instead of QSGMaterialShader. This is
- indicated by having the RhiShaderWanted flag set. In this case the return
- value must be a QSGRhiMaterialShader subclass.
*/
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h
index cb6e9a456a..fd98c64cca 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.h
@@ -42,7 +42,6 @@
#include <QtQuick/qtquickglobal.h>
#include <QtQuick/qsgmaterialshader.h>
-#include <QtQuick/qsgmaterialrhishader.h>
#include <QtQuick/qsgmaterialtype.h>
QT_BEGIN_NAMESPACE
@@ -56,11 +55,7 @@ public:
RequiresFullMatrixExceptTranslate = 0x0004 | RequiresDeterminant, // Allow precalculated translation
RequiresFullMatrix = 0x0008 | RequiresFullMatrixExceptTranslate,
- CustomCompileStep = 0x0010,
-
- SupportsRhiShader = 0x0020,
-
- RhiShaderWanted = 0x1000 // // ### Qt 6: remove
+ CustomCompileStep = 0x0010
};
Q_DECLARE_FLAGS(Flags, Flag)
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp
deleted file mode 100644
index c5cbd0c979..0000000000
--- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp
+++ /dev/null
@@ -1,630 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsgmaterial.h"
-#include "qsgrenderer_p.h"
-#include "qsgmaterialrhishader_p.h"
-#include <QtCore/QFile>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QSGMaterialRhiShader
- \brief The QSGMaterialRhiShader class represents a graphics API independent shader program.
- \inmodule QtQuick
- \ingroup qtquick-scenegraph-materials
- \since 5.14
-
- QSGMaterialRhiShader is a modern, cross-platform alternative to
- QSGMaterialShader. The latter is tied to OpenGL and GLSL by design, whereas
- QSGMaterialRhiShader is based on QShader, a container for multiple
- versions of a graphics shader together with reflection information.
-
- \note All classes with QSG prefix should be used solely on the scene graph's
- rendering thread. See \l {Scene Graph and Rendering} for more information.
- */
-
-/*!
- \enum QSGMaterialRhiShader::Flag
- Flag values to indicate special material properties.
-
- \value UpdatesGraphicsPipelineState Setting this flag enables calling
- updateGraphicsPipelineState().
- */
-
-QShader QSGMaterialRhiShaderPrivate::loadShader(const QString &filename)
-{
- QFile f(filename);
- if (!f.open(QIODevice::ReadOnly)) {
- qWarning() << "Failed to find shader" << filename;
- return QShader();
- }
- return QShader::fromSerialized(f.readAll());
-}
-
-void QSGMaterialRhiShaderPrivate::clearCachedRendererData()
-{
- for (int i = 0; i < MAX_SHADER_RESOURCE_BINDINGS; ++i)
- textureBindingTable[i] = nullptr;
- for (int i = 0; i < MAX_SHADER_RESOURCE_BINDINGS; ++i)
- samplerBindingTable[i] = nullptr;
-}
-
-static inline QRhiShaderResourceBinding::StageFlags toSrbStage(QShader::Stage stage)
-{
- switch (stage) {
- case QShader::VertexStage:
- return QRhiShaderResourceBinding::VertexStage;
- case QShader::FragmentStage:
- return QRhiShaderResourceBinding::FragmentStage;
- default:
- Q_UNREACHABLE();
- break;
- }
- return { };
-}
-
-void QSGMaterialRhiShaderPrivate::prepare(QShader::Variant vertexShaderVariant)
-{
- ubufBinding = -1;
- ubufSize = 0;
- ubufStages = { };
- memset(combinedImageSamplerBindings, 0, sizeof(combinedImageSamplerBindings));
- vertexShader = fragmentShader = nullptr;
- masterUniformData.clear();
-
- clearCachedRendererData();
-
- for (QShader::Stage stage : { QShader::VertexStage, QShader::FragmentStage }) {
- auto it = shaderFileNames.find(stage);
- if (it != shaderFileNames.end()) {
- QString fn = *it;
- const QShader s = loadShader(*it);
- if (!s.isValid())
- continue;
- shaders[stage] = ShaderStageData(s);
- // load only once, subsequent prepare() calls will have it all in shaders already
- shaderFileNames.erase(it);
- }
- }
-
- auto vsIt = shaders.find(QShader::VertexStage);
- if (vsIt != shaders.end()) {
- vsIt->shaderVariant = vertexShaderVariant;
- vsIt->vertexInputLocations.clear();
- vsIt->qt_order_attrib_location = -1;
-
- const QShaderDescription desc = vsIt->shader.description();
- const QVector<QShaderDescription::InOutVariable> vertexInputs = desc.inputVariables();
- for (const QShaderDescription::InOutVariable &v : vertexInputs) {
- const QByteArray name = v.name.toUtf8();
- if (vertexShaderVariant == QShader::BatchableVertexShader
- && name == QByteArrayLiteral("_qt_order"))
- {
- vsIt->qt_order_attrib_location = v.location;
- } else {
- vsIt->vertexInputLocations.append(v.location);
- }
- }
-
- if (vsIt->vertexInputLocations.contains(vsIt->qt_order_attrib_location)) {
- qWarning("Vertex input clash in rewritten (batchable) vertex shader at input location %d. "
- "Vertex shaders must avoid using this location.", vsIt->qt_order_attrib_location);
- }
- }
-
- for (auto it = shaders.begin(); it != shaders.end(); ++it) {
- const QShaderDescription desc = it->shader.description();
-
- const QVector<QShaderDescription::UniformBlock> ubufs = desc.uniformBlocks();
- const int ubufCount = ubufs.count();
- if (ubufCount > 1) {
- qWarning("Multiple uniform blocks found in shader. "
- "This should be avoided as Qt Quick supports only one.");
- }
- for (int i = 0; i < ubufCount; ++i) {
- const QShaderDescription::UniformBlock &ubuf(ubufs[i]);
- if (ubufBinding == -1 && ubuf.binding >= 0) {
- ubufBinding = ubuf.binding;
- ubufSize = ubuf.size;
- ubufStages |= toSrbStage(it->shader.stage());
- masterUniformData.fill('\0', ubufSize);
- } else if (ubufBinding == ubuf.binding && ubuf.binding >= 0) {
- if (ubuf.size > ubufSize) {
- ubufSize = ubuf.size;
- masterUniformData.fill('\0', ubufSize);
- }
- ubufStages |= toSrbStage(it->shader.stage());
- } else {
- qWarning("Uniform block %s (binding %d) ignored", qPrintable(ubuf.blockName), ubuf.binding);
- }
- }
-
- const QVector<QShaderDescription::InOutVariable> imageSamplers = desc.combinedImageSamplers();
- const int imageSamplersCount = imageSamplers.count();
- for (int i = 0; i < imageSamplersCount; ++i) {
- const QShaderDescription::InOutVariable &var(imageSamplers[i]);
- if (var.binding >= 0 && var.binding < MAX_SHADER_RESOURCE_BINDINGS)
- combinedImageSamplerBindings[var.binding] |= toSrbStage(it->shader.stage());
- else
- qWarning("Encountered invalid combined image sampler (%s) binding %d",
- qPrintable(var.name), var.binding);
- }
-
- if (it.key() == QShader::VertexStage)
- vertexShader = &it.value();
- else if (it.key() == QShader::FragmentStage)
- fragmentShader = &it.value();
- }
-
- if (vertexShader && vertexShaderVariant == QShader::BatchableVertexShader && vertexShader->qt_order_attrib_location == -1)
- qWarning("No rewriter-inserted attribute found, this should not happen.");
-}
-
-/*!
- Constructs a new QSGMaterialRhiShader.
- */
-QSGMaterialRhiShader::QSGMaterialRhiShader()
- : d_ptr(new QSGMaterialRhiShaderPrivate(this))
-{
-}
-
-/*!
- \internal
- */
-QSGMaterialRhiShader::QSGMaterialRhiShader(QSGMaterialRhiShaderPrivate &dd)
- : d_ptr(&dd)
-{
-}
-
-/*!
- \internal
- */
-QSGMaterialRhiShader::~QSGMaterialRhiShader()
-{
-}
-
-// We have our own enum as QShader is not initially public. Internally
-// everything works with QShader::Stage however. So convert.
-static inline QShader::Stage toShaderStage(QSGMaterialRhiShader::Stage stage)
-{
- switch (stage) {
- case QSGMaterialRhiShader::VertexStage:
- return QShader::VertexStage;
- case QSGMaterialRhiShader::FragmentStage:
- return QShader::FragmentStage;
- default:
- Q_UNREACHABLE();
- return QShader::VertexStage;
- }
-}
-
-/*!
- Sets the \a shader for the specified \a stage.
- */
-void QSGMaterialRhiShader::setShader(Stage stage, const QShader &shader)
-{
- Q_D(QSGMaterialRhiShader);
- d->shaders[toShaderStage(stage)] = QSGMaterialRhiShaderPrivate::ShaderStageData(shader);
-}
-
-/*!
- Sets the \a filename for the shader for the specified \a stage.
-
- The file is expected to contain a serialized QRhiShader.
- */
-void QSGMaterialRhiShader::setShaderFileName(Stage stage, const QString &filename)
-{
- Q_D(QSGMaterialRhiShader);
- d->shaderFileNames[toShaderStage(stage)] = filename;
-}
-
-/*!
- \return the currently set flags for this material shader.
- */
-QSGMaterialRhiShader::Flags QSGMaterialRhiShader::flags() const
-{
- Q_D(const QSGMaterialRhiShader);
- return d->flags;
-}
-
-/*!
- Sets the \a flags on this material shader if \a on is true;
- otherwise clears the specified flags.
-*/
-void QSGMaterialRhiShader::setFlag(Flags flags, bool on)
-{
- Q_D(QSGMaterialRhiShader);
- if (on)
- d->flags |= flags;
- else
- d->flags &= ~flags;
-}
-
-/*!
- This function is called by the scene graph to get the contents of the
- shader program's uniform buffer updated. The implementation is not expected
- to perform any real graphics operations, it is merely responsible for
- copying data to the QByteArray returned from RenderState::uniformData().
- The scene graph takes care of making that buffer visible in the shaders.
-
- The current rendering \a state is passed from the scene graph. If the state
- indicates that any relevant state is dirty, the implementation must update
- the appropriate region in the buffer data that is accessible via
- RenderState::uniformData(). When a state, such as, matrix or opacity, is
- not dirty, there is no need to touch the corresponding region since the
- data is persistent.
-
- The return value must be \c true whenever any change was made to the uniform data.
-
- The subclass specific state, such as the color of a flat color material,
- should be extracted from \a newMaterial to update the relevant regions in
- the buffer accordingly.
-
- \a oldMaterial can be used to minimize buffer changes (which are typically
- memcpy calls) when updating material states. When \a oldMaterial is null,
- this shader was just activated.
- */
-bool QSGMaterialRhiShader::updateUniformData(RenderState &state,
- QSGMaterial *newMaterial,
- QSGMaterial *oldMaterial)
-{
- Q_UNUSED(state);
- Q_UNUSED(newMaterial);
- Q_UNUSED(oldMaterial);
- return false;
-}
-
-/*!
- This function is called by the scene graph to prepare using a sampled image
- in the shader, typically in form of a combined image sampler.
-
- \a binding is the binding number of the sampler. The function is called for
- each variable in the material's shaders'
- \l{QShaderDescription::combinedImageSamplers()}.
-
- When *\a{texture} is null, it must be set to a QSGTexture pointer before
- returning. When non-null, it is up to the material to decide if a new
- \c{QSGTexture *} is stored to it, or if it updates some parameters on the
- already known QSGTexture. The ownership of the QSGTexture is not
- transferred.
-
- The current rendering \a state is passed from the scene graph. It is up to
- the material to enqueue the texture data uploads to the
- QRhiResourceUpdateBatch retriveable via RenderState::resourceUpdateBatch().
-
- The subclass specific state can be extracted from \a newMaterial.
-
- \a oldMaterial can be used to minimize changes. When \a oldMaterial is null,
- this shader was just activated.
- */
-void QSGMaterialRhiShader::updateSampledImage(RenderState &state,
- int binding,
- QSGTexture **texture,
- QSGMaterial *newMaterial,
- QSGMaterial *oldMaterial)
-{
- Q_UNUSED(state);
- Q_UNUSED(binding);
- Q_UNUSED(texture);
- Q_UNUSED(newMaterial);
- Q_UNUSED(oldMaterial);
-}
-
-/*!
- This function is called by the scene graph to enable the material to
- provide a custom set of graphics state. The set of states that are
- customizable by material is limited to blending and related settings.
-
- \note This function is only called when the UpdatesGraphicsPipelineState
- flag was enabled via setFlags(). By default it is not set, and so this
- function is never called.
-
- The return value must be \c true whenever a change was made to any of the
- members in \a ps.
-
- \note The contents of \a ps is not persistent between invocations of this
- function.
-
- The current rendering \a state is passed from the scene graph.
-
- The subclass specific state can be extracted from \a newMaterial. When \a
- oldMaterial is null, this shader was just activated.
- */
-bool QSGMaterialRhiShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
- QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
-{
- Q_UNUSED(state);
- Q_UNUSED(ps);
- Q_UNUSED(newMaterial);
- Q_UNUSED(oldMaterial);
- return false;
-}
-
-/*!
- \class QSGMaterialRhiShader::RenderState
-
- \brief Encapsulates the current rendering state during a call to
- QSGMaterialRhiShader::updateUniformData() and the other \c update type of
- functions.
-
- \inmodule QtQuick
- \since 5.14
-
- The render state contains a number of accessors that the shader needs to
- respect in order to conform to the current state of the scene graph.
- */
-
-/*!
- \enum QSGMaterialRhiShader::RenderState::DirtyState
-
- \value DirtyMatrix Used to indicate that the matrix has changed and must be
- updated.
-
- \value DirtyOpacity Used to indicate that the opacity has changed and must
- be updated.
-
- \value DirtyAll Used to indicate that everything needs to be updated.
- */
-
-/*!
- \fn bool QSGMaterialRhiShader::RenderState::isMatrixDirty() const
-
- Returns \c true if the dirtyStates() contain the dirty matrix state,
- otherwise returns \c false.
- */
-
-/*!
- \fn bool QSGMaterialRhiShader::RenderState::isOpacityDirty() const
-
- Returns \c true if the dirtyStates() contains the dirty opacity state,
- otherwise returns \c false.
- */
-
-/*!
- \fn QSGMaterialRhiShader::RenderState::DirtyStates QSGMaterialRhiShader::RenderState::dirtyStates() const
-
- Returns which rendering states that have changed and needs to be updated
- for geometry rendered with this material to conform to the current
- rendering state.
- */
-
-/*!
- \class QSGMaterialRhiShader::GraphicsPipelineState
-
- \brief Describes state changes that the material wants to apply to the
- currently active graphics pipeline state.
-
- \inmodule QtQuick
- \since 5.14
-
- Unlike QSGMaterialShader, directly issuing state change commands with the
- underlying graphics API is not possible with QSGMaterialRhiShader. This is
- mainly because the concept of individually changeable states is considered
- deprecated and not supported with modern graphics APIs.
-
- Therefore, it is up to QSGMaterialRhiShader to expose a data structure with
- the set of supported states, which the material can change in its
- updatePipelineState() implementation, if there is one. The scenegraph will
- then internally apply these changes to the active graphics pipeline state,
- then rolling them back as appropriate.
- */
-
-/*!
- \enum QSGMaterialRhiShader::GraphicsPipelineState::BlendFactor
- \since 5.14
-
- \value Zero
- \value One
- \value SrcColor
- \value OneMinusSrcColor
- \value DstColor
- \value OneMinusDstColor
- \value SrcAlpha
- \value OneMinusSrcAlpha
- \value DstAlpha
- \value OneMinusDstAlpha
- \value ConstantColor
- \value OneMinusConstantColor
- \value ConstantAlpha
- \value OneMinusConstantAlpha
- \value SrcAlphaSaturate
- \value Src1Color
- \value OneMinusSrc1Color
- \value Src1Alpha
- \value OneMinusSrc1Alpha
- */
-
-/*!
- \enum QSGMaterialRhiShader::GraphicsPipelineState::ColorMaskComponent
- \since 5.14
-
- \value R
- \value G
- \value B
- \value A
- */
-
-/*!
- \enum QSGMaterialRhiShader::GraphicsPipelineState::CullMode
- \since 5.14
-
- \value CullNone
- \value CullFront
- \value CullBack
- */
-
-/*!
- Returns the accumulated opacity to be used for rendering.
- */
-float QSGMaterialRhiShader::RenderState::opacity() const
-{
- Q_ASSERT(m_data);
- return float(static_cast<const QSGRenderer *>(m_data)->currentOpacity());
-}
-
-/*!
- Returns the modelview determinant to be used for rendering.
- */
-float QSGMaterialRhiShader::RenderState::determinant() const
-{
- Q_ASSERT(m_data);
- return float(static_cast<const QSGRenderer *>(m_data)->determinant());
-}
-
-/*!
- Returns the matrix combined of modelview matrix and project matrix.
- */
-QMatrix4x4 QSGMaterialRhiShader::RenderState::combinedMatrix() const
-{
- Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->currentCombinedMatrix();
-}
-
-/*!
- Returns the ratio between physical pixels and device-independent pixels
- to be used for rendering.
-*/
-float QSGMaterialRhiShader::RenderState::devicePixelRatio() const
-{
- Q_ASSERT(m_data);
- return float(static_cast<const QSGRenderer *>(m_data)->devicePixelRatio());
-}
-
-/*!
- Returns the model view matrix.
-
- If the material has the RequiresFullMatrix flag set, this is guaranteed to
- be the complete transform matrix calculated from the scenegraph.
-
- However, if this flag is not set, the renderer may choose to alter this
- matrix. For example, it may pre-transform vertices on the CPU and set this
- matrix to identity.
-
- In a situation such as the above, it is still possible to retrieve the
- actual matrix determinant by setting the RequiresDeterminant flag in the
- material and calling the determinant() accessor.
- */
-QMatrix4x4 QSGMaterialRhiShader::RenderState::modelViewMatrix() const
-{
- Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->currentModelViewMatrix();
-}
-
-/*!
- Returns the projection matrix.
- */
-QMatrix4x4 QSGMaterialRhiShader::RenderState::projectionMatrix() const
-{
- Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->currentProjectionMatrix();
-}
-
-/*!
- Returns the viewport rect of the surface being rendered to.
- */
-QRect QSGMaterialRhiShader::RenderState::viewportRect() const
-{
- Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->viewportRect();
-}
-
-/*!
- Returns the device rect of the surface being rendered to
- */
-QRect QSGMaterialRhiShader::RenderState::deviceRect() const
-{
- Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->deviceRect();
-}
-
-/*!
- Returns a pointer to the data for the uniform (constant) buffer in the
- shader. Uniform data must only be updated from
- QSGMaterialRhiShader::updateUniformData(). The return value is null in the
- other reimplementable functions, such as,
- QSGMaterialRhiShader::updateSampledImage().
-
- \note It is strongly recommended to declare the uniform block with \c
- std140 in the shader, and to carefully study the standard uniform block
- layout as described in section 7.6.2.2 of the OpenGL specification. It is
- up to the QSGMaterialRhiShader implementation to ensure data gets placed
- at the right location in this QByteArray, taking alignment requirements
- into account. Shader code translated to other shading languages is expected
- to use the same offsets for block members, even when the target language
- uses different packing rules by default.
-
- \note Avoid copying from C++ POD types, such as, structs, in order to
- update multiple members at once, unless it has been verified that the
- layouts of the C++ struct and the GLSL uniform block match.
- */
-QByteArray *QSGMaterialRhiShader::RenderState::uniformData()
-{
- Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->currentUniformData();
-}
-
-/*!
- Returns a resource update batch to which upload and copy operatoins can be
- queued. This is typically used by
- QSGMaterialRhiShader::updateSampledImage() to enqueue texture image
- content updates.
- */
-QRhiResourceUpdateBatch *QSGMaterialRhiShader::RenderState::resourceUpdateBatch()
-{
- Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->currentResourceUpdateBatch();
-}
-
-/*!
- Returns the current QRhi.
- */
-QRhi *QSGMaterialRhiShader::RenderState::rhi()
-{
- Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->currentRhi();
-}
-
-char const *const *QSGMaterialRhiShader::attributeNames() const
-{
- Q_ASSERT_X(false, "QSGMaterialRhiShader::attributeNames()", "Not implemented for RHI");
- return nullptr;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h
deleted file mode 100644
index 86208516cd..0000000000
--- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSGMATERIALRHISHADER_H
-#define QSGMATERIALRHISHADER_H
-
-#include <QtQuick/qtquickglobal.h>
-#include <QtCore/QRect>
-#include <QtGui/QMatrix4x4>
-#include <QtGui/QColor>
-#include <QtQuick/qsgmaterialshader.h>
-
-QT_BEGIN_NAMESPACE
-
-class QSGMaterial;
-class QSGMaterialRhiShaderPrivate;
-class QSGTexture;
-class QRhiResourceUpdateBatch;
-class QRhi;
-class QShader;
-
-class Q_QUICK_EXPORT QSGMaterialRhiShader : public QSGMaterialShader // ### Qt 6: remove inheritance
-{
-public:
- class Q_QUICK_EXPORT RenderState {
- public:
- using DirtyStates = QSGMaterialShader::RenderState::DirtyStates;
-
- inline DirtyStates dirtyStates() const { return m_dirty; }
-
- inline bool isMatrixDirty() const { return m_dirty & QSGMaterialShader::RenderState::DirtyMatrix; }
- inline bool isOpacityDirty() const { return m_dirty & QSGMaterialShader::RenderState::DirtyOpacity; }
-
- float opacity() const;
- QMatrix4x4 combinedMatrix() const;
- QMatrix4x4 modelViewMatrix() const;
- QMatrix4x4 projectionMatrix() const;
- QRect viewportRect() const;
- QRect deviceRect() const;
- float determinant() const;
- float devicePixelRatio() const;
-
- QByteArray *uniformData();
- QRhiResourceUpdateBatch *resourceUpdateBatch();
- QRhi *rhi();
-
- private:
- friend class QSGRenderer;
- DirtyStates m_dirty;
- const void *m_data;
- };
-
- struct Q_QUICK_EXPORT GraphicsPipelineState {
- enum BlendFactor {
- Zero,
- One,
- SrcColor,
- OneMinusSrcColor,
- DstColor,
- OneMinusDstColor,
- SrcAlpha,
- OneMinusSrcAlpha,
- DstAlpha,
- OneMinusDstAlpha,
- ConstantColor,
- OneMinusConstantColor,
- ConstantAlpha,
- OneMinusConstantAlpha,
- SrcAlphaSaturate,
- Src1Color,
- OneMinusSrc1Color,
- Src1Alpha,
- OneMinusSrc1Alpha
- };
-
- enum ColorMaskComponent {
- R = 1 << 0,
- G = 1 << 1,
- B = 1 << 2,
- A = 1 << 3
- };
- Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)
-
- enum CullMode {
- CullNone,
- CullFront,
- CullBack
- };
-
- bool blendEnable;
- BlendFactor srcColor;
- BlendFactor dstColor;
- ColorMask colorWrite;
- QColor blendConstant;
- CullMode cullMode;
- // This struct is extensible while keeping BC since apps only ever get
- // a ptr to the struct, it is not created by them.
- };
-
- enum Flag {
- UpdatesGraphicsPipelineState = 0x0001
- };
- Q_DECLARE_FLAGS(Flags, Flag)
-
- enum Stage {
- VertexStage,
- FragmentStage,
- };
-
- QSGMaterialRhiShader();
- virtual ~QSGMaterialRhiShader();
-
- virtual bool updateUniformData(RenderState &state,
- QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
-
- virtual void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
- QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
-
- virtual bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
- QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
-
- Flags flags() const;
- void setFlag(Flags flags, bool on = true);
-
- // dummy impl for base class pure virtual, never called
- char const *const *attributeNames() const override;
-
-protected:
- Q_DECLARE_PRIVATE(QSGMaterialRhiShader)
- QSGMaterialRhiShader(QSGMaterialRhiShaderPrivate &dd);
-
- // filename is for a file containing a serialized QShader.
- void setShaderFileName(Stage stage, const QString &filename);
-
- void setShader(Stage stage, const QShader &shader);
-
-private:
- QScopedPointer<QSGMaterialRhiShaderPrivate> d_ptr;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialRhiShader::GraphicsPipelineState::ColorMask)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialRhiShader::Flags)
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader_p.h b/src/quick/scenegraph/coreapi/qsgmaterialrhishader_p.h
deleted file mode 100644
index 153b4b120a..0000000000
--- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSGMATERIALRHISHADER_P_H
-#define QSGMATERIALRHISHADER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qtquickglobal_p.h>
-#include "qsgmaterialrhishader.h"
-#include "qsgmaterial.h"
-#include <QtGui/private/qrhi_p.h>
-#include <QtGui/private/qshader_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QRhiSampler;
-
-class Q_QUICK_PRIVATE_EXPORT QSGMaterialRhiShaderPrivate
-{
-public:
- Q_DECLARE_PUBLIC(QSGMaterialRhiShader)
-
- QSGMaterialRhiShaderPrivate(QSGMaterialRhiShader *q) : q_ptr(q) { }
- static QSGMaterialRhiShaderPrivate *get(QSGMaterialRhiShader *s) { return s->d_func(); }
- static const QSGMaterialRhiShaderPrivate *get(const QSGMaterialRhiShader *s) { return s->d_func(); }
-
- void clearCachedRendererData();
- void prepare(QShader::Variant vertexShaderVariant);
-
- QShader shader(QShader::Stage stage) const { return shaders[stage].shader; }
-
- static QShader loadShader(const QString &filename);
-
- QSGMaterialRhiShader *q_ptr;
- QHash<QShader::Stage, QString> shaderFileNames;
- QSGMaterialRhiShader::Flags flags;
-
- struct ShaderStageData {
- ShaderStageData() { } // so shader.isValid() == false
- ShaderStageData(const QShader &shader) : shader(shader) { }
- QShader shader;
- QShader::Variant shaderVariant = QShader::StandardShader;
- QVector<int> vertexInputLocations; // excluding rewriter-inserted ones
- int qt_order_attrib_location = -1; // rewriter-inserted
- };
- QHash<QShader::Stage, ShaderStageData> shaders;
-
- static const int MAX_SHADER_RESOURCE_BINDINGS = 32;
-
- int ubufBinding = -1;
- int ubufSize = 0;
- QRhiShaderResourceBinding::StageFlags ubufStages;
- QRhiShaderResourceBinding::StageFlags combinedImageSamplerBindings[MAX_SHADER_RESOURCE_BINDINGS];
-
- ShaderStageData *vertexShader = nullptr;
- ShaderStageData *fragmentShader = nullptr;
-
- QByteArray masterUniformData;
-
- QSGTexture *textureBindingTable[MAX_SHADER_RESOURCE_BINDINGS];
- QRhiSampler *samplerBindingTable[MAX_SHADER_RESOURCE_BINDINGS];
-};
-
-Q_DECLARE_TYPEINFO(QSGMaterialRhiShaderPrivate::ShaderStageData, Q_MOVABLE_TYPE);
-
-QT_END_NAMESPACE
-
-#endif // QSGMATERIALRHISHADER_P_H
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
index 64956e2ca4..57c6007e47 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
@@ -40,37 +40,26 @@
#include "qsgmaterial.h"
#include "qsgrenderer_p.h"
#include "qsgmaterialshader_p.h"
-#if QT_CONFIG(opengl)
-# include <private/qsgshadersourcebuilder_p.h>
-# include <private/qsgdefaultcontext_p.h>
-# include <private/qsgdefaultrendercontext_p.h>
-# include <QOpenGLFunctions>
-# include <QOpenGLContext>
-#endif
+#include <QtCore/QFile>
QT_BEGIN_NAMESPACE
-#if QT_CONFIG(opengl)
-const char *QSGMaterialShaderPrivate::loadShaderSource(QOpenGLShader::ShaderType type) const
-{
- const QStringList files = m_sourceFiles[type];
- QSGShaderSourceBuilder builder;
- for (const QString &file : files)
- builder.appendSourceFile(file);
- m_sources[type] = builder.source();
- return m_sources[type].constData();
-}
-#endif
-
/*!
\class QSGMaterialShader
- \brief The QSGMaterialShader class represents an OpenGL shader program
- in the renderer.
+ \brief The QSGMaterialShader class represents a graphics API independent shader program.
\inmodule QtQuick
\ingroup qtquick-scenegraph-materials
+ \since 5.14
+
+ // ### glpurge Rewrite to not talk about OpenGL and GLSL directly anymore
+
+ QSGMaterialShader is a modern, cross-platform alternative to
+ QSGMaterialShader. The latter is tied to OpenGL and GLSL by design, whereas
+ QSGMaterialShader is based on QShader, a container for multiple
+ versions of a graphics shader together with reflection information.
- \warning This class is only functional when running with the legacy OpenGL
- renderer of the Qt Quick scenegraph.
+ \note All classes with QSG prefix should be used solely on the scene graph's
+ rendering thread. See \l {Scene Graph and Rendering} for more information.
The QSGMaterial and QSGMaterialShader form a tight relationship. For one
scene graph (including nested graphs), there is one unique QSGMaterialShader
@@ -160,16 +149,150 @@ const char *QSGMaterialShaderPrivate::loadShaderSource(QOpenGLShader::ShaderType
\note All classes with QSG prefix should be used solely on the scene graph's
rendering thread. See \l {Scene Graph and Rendering} for more information.
+ */
+
+/*!
+ \enum QSGMaterialShader::Flag
+ Flag values to indicate special material properties.
+ \value UpdatesGraphicsPipelineState Setting this flag enables calling
+ updateGraphicsPipelineState().
*/
+QShader QSGMaterialShaderPrivate::loadShader(const QString &filename)
+{
+ QFile f(filename);
+ if (!f.open(QIODevice::ReadOnly)) {
+ qWarning() << "Failed to find shader" << filename;
+ return QShader();
+ }
+ return QShader::fromSerialized(f.readAll());
+}
+
+void QSGMaterialShaderPrivate::clearCachedRendererData()
+{
+ for (int i = 0; i < MAX_SHADER_RESOURCE_BINDINGS; ++i)
+ textureBindingTable[i] = nullptr;
+ for (int i = 0; i < MAX_SHADER_RESOURCE_BINDINGS; ++i)
+ samplerBindingTable[i] = nullptr;
+}
+
+static inline QRhiShaderResourceBinding::StageFlags toSrbStage(QShader::Stage stage)
+{
+ switch (stage) {
+ case QShader::VertexStage:
+ return QRhiShaderResourceBinding::VertexStage;
+ case QShader::FragmentStage:
+ return QRhiShaderResourceBinding::FragmentStage;
+ default:
+ Q_UNREACHABLE();
+ break;
+ }
+ return { };
+}
+
+void QSGMaterialShaderPrivate::prepare(QShader::Variant vertexShaderVariant)
+{
+ ubufBinding = -1;
+ ubufSize = 0;
+ ubufStages = { };
+ memset(combinedImageSamplerBindings, 0, sizeof(combinedImageSamplerBindings));
+ vertexShader = fragmentShader = nullptr;
+ masterUniformData.clear();
+
+ clearCachedRendererData();
+
+ for (QShader::Stage stage : { QShader::VertexStage, QShader::FragmentStage }) {
+ auto it = shaderFileNames.find(stage);
+ if (it != shaderFileNames.end()) {
+ QString fn = *it;
+ const QShader s = loadShader(*it);
+ if (!s.isValid())
+ continue;
+ shaders[stage] = ShaderStageData(s);
+ // load only once, subsequent prepare() calls will have it all in shaders already
+ shaderFileNames.erase(it);
+ }
+ }
+
+ auto vsIt = shaders.find(QShader::VertexStage);
+ if (vsIt != shaders.end()) {
+ vsIt->shaderVariant = vertexShaderVariant;
+ vsIt->vertexInputLocations.clear();
+ vsIt->qt_order_attrib_location = -1;
+
+ const QShaderDescription desc = vsIt->shader.description();
+ const QVector<QShaderDescription::InOutVariable> vertexInputs = desc.inputVariables();
+ for (const QShaderDescription::InOutVariable &v : vertexInputs) {
+ const QByteArray name = v.name.toUtf8();
+ if (vertexShaderVariant == QShader::BatchableVertexShader
+ && name == QByteArrayLiteral("_qt_order"))
+ {
+ vsIt->qt_order_attrib_location = v.location;
+ } else {
+ vsIt->vertexInputLocations.append(v.location);
+ }
+ }
+
+ if (vsIt->vertexInputLocations.contains(vsIt->qt_order_attrib_location)) {
+ qWarning("Vertex input clash in rewritten (batchable) vertex shader at input location %d. "
+ "Vertex shaders must avoid using this location.", vsIt->qt_order_attrib_location);
+ }
+ }
+
+ for (auto it = shaders.begin(); it != shaders.end(); ++it) {
+ const QShaderDescription desc = it->shader.description();
+
+ const QVector<QShaderDescription::UniformBlock> ubufs = desc.uniformBlocks();
+ const int ubufCount = ubufs.count();
+ if (ubufCount > 1) {
+ qWarning("Multiple uniform blocks found in shader. "
+ "This should be avoided as Qt Quick supports only one.");
+ }
+ for (int i = 0; i < ubufCount; ++i) {
+ const QShaderDescription::UniformBlock &ubuf(ubufs[i]);
+ if (ubufBinding == -1 && ubuf.binding >= 0) {
+ ubufBinding = ubuf.binding;
+ ubufSize = ubuf.size;
+ ubufStages |= toSrbStage(it->shader.stage());
+ masterUniformData.fill('\0', ubufSize);
+ } else if (ubufBinding == ubuf.binding && ubuf.binding >= 0) {
+ if (ubuf.size > ubufSize) {
+ ubufSize = ubuf.size;
+ masterUniformData.fill('\0', ubufSize);
+ }
+ ubufStages |= toSrbStage(it->shader.stage());
+ } else {
+ qWarning("Uniform block %s (binding %d) ignored", qPrintable(ubuf.blockName), ubuf.binding);
+ }
+ }
+
+ const QVector<QShaderDescription::InOutVariable> imageSamplers = desc.combinedImageSamplers();
+ const int imageSamplersCount = imageSamplers.count();
+ for (int i = 0; i < imageSamplersCount; ++i) {
+ const QShaderDescription::InOutVariable &var(imageSamplers[i]);
+ if (var.binding >= 0 && var.binding < MAX_SHADER_RESOURCE_BINDINGS)
+ combinedImageSamplerBindings[var.binding] |= toSrbStage(it->shader.stage());
+ else
+ qWarning("Encountered invalid combined image sampler (%s) binding %d",
+ qPrintable(var.name), var.binding);
+ }
+
+ if (it.key() == QShader::VertexStage)
+ vertexShader = &it.value();
+ else if (it.key() == QShader::FragmentStage)
+ fragmentShader = &it.value();
+ }
+ if (vertexShader && vertexShaderVariant == QShader::BatchableVertexShader && vertexShader->qt_order_attrib_location == -1)
+ qWarning("No rewriter-inserted attribute found, this should not happen.");
+}
/*!
- Creates a new QSGMaterialShader.
+ Constructs a new QSGMaterialShader.
*/
QSGMaterialShader::QSGMaterialShader()
- : d_ptr(new QSGMaterialShaderPrivate)
+ : d_ptr(new QSGMaterialShaderPrivate(this))
{
}
@@ -188,217 +311,189 @@ QSGMaterialShader::~QSGMaterialShader()
{
}
-/*!
- \fn char const *const *QSGMaterialShader::attributeNames() const
-
- Returns a zero-terminated array describing the names of the
- attributes used in the vertex shader.
-
- This function is called when the shader is compiled to specify
- which attributes exist. The order of the attribute names
- defines the attribute register position in the vertex shader.
- */
-
-#if QT_CONFIG(opengl)
-/*!
- \fn const char *QSGMaterialShader::vertexShader() const
-
- Called when the shader is being initialized to get the vertex
- shader source code.
-
- The contents returned from this function should never change.
-*/
-const char *QSGMaterialShader::vertexShader() const
+// We have our own enum as QShader is not initially public. Internally
+// everything works with QShader::Stage however. So convert.
+static inline QShader::Stage toShaderStage(QSGMaterialShader::Stage stage)
{
- Q_D(const QSGMaterialShader);
- return d->loadShaderSource(QOpenGLShader::Vertex);
+ switch (stage) {
+ case QSGMaterialShader::VertexStage:
+ return QShader::VertexStage;
+ case QSGMaterialShader::FragmentStage:
+ return QShader::FragmentStage;
+ default:
+ Q_UNREACHABLE();
+ return QShader::VertexStage;
+ }
}
-
/*!
- \fn const char *QSGMaterialShader::fragmentShader() const
-
- Called when the shader is being initialized to get the fragment
- shader source code.
-
- The contents returned from this function should never change.
-*/
-const char *QSGMaterialShader::fragmentShader() const
+ Sets the \a shader for the specified \a stage.
+ */
+void QSGMaterialShader::setShader(Stage stage, const QShader &shader)
{
- Q_D(const QSGMaterialShader);
- return d->loadShaderSource(QOpenGLShader::Fragment);
+ Q_D(QSGMaterialShader);
+ d->shaders[toShaderStage(stage)] = QSGMaterialShaderPrivate::ShaderStageData(shader);
}
-
-/*!
- \fn QOpenGLShaderProgram *QSGMaterialShader::program()
-
- Returns the shader program used by this QSGMaterialShader.
- */
-#endif
-
/*!
- \fn void QSGMaterialShader::initialize()
+ Sets the \a filename for the shader for the specified \a stage.
- Reimplement this function to do one-time initialization when the
- shader program is compiled. The OpenGL shader program is compiled
- and linked, but not bound, when this function is called.
+ The file is expected to contain a serialized QShader.
*/
-
+void QSGMaterialShader::setShaderFileName(Stage stage, const QString &filename)
+{
+ Q_D(QSGMaterialShader);
+ d->shaderFileNames[toShaderStage(stage)] = filename;
+}
/*!
- This function is called by the scene graph to indicate that geometry is
- about to be rendered using this shader.
-
- State that is global for all uses of the shader, independent of the geometry
- that is being drawn, can be setup in this function.
+ \return the currently set flags for this material shader.
*/
-
-void QSGMaterialShader::activate()
+QSGMaterialShader::Flags QSGMaterialShader::flags() const
{
+ Q_D(const QSGMaterialShader);
+ return d->flags;
}
-
-
/*!
- This function is called by the scene graph to indicate that geometry will
- no longer to be rendered using this shader.
- */
-
-void QSGMaterialShader::deactivate()
+ Sets the \a flags on this material shader if \a on is true;
+ otherwise clears the specified flags.
+*/
+void QSGMaterialShader::setFlag(Flags flags, bool on)
{
+ Q_D(QSGMaterialShader);
+ if (on)
+ d->flags |= flags;
+ else
+ d->flags &= ~flags;
}
-
-
/*!
- This function is called by the scene graph before geometry is rendered
- to make sure the shader is in the right state.
+ This function is called by the scene graph to get the contents of the
+ shader program's uniform buffer updated. The implementation is not expected
+ to perform any real graphics operations, it is merely responsible for
+ copying data to the QByteArray returned from RenderState::uniformData().
+ The scene graph takes care of making that buffer visible in the shaders.
The current rendering \a state is passed from the scene graph. If the state
- indicates that any state is dirty, the updateState implementation must
- update accordingly for the geometry to render correctly.
+ indicates that any relevant state is dirty, the implementation must update
+ the appropriate region in the buffer data that is accessible via
+ RenderState::uniformData(). When a state, such as, matrix or opacity, is
+ not dirty, there is no need to touch the corresponding region since the
+ data is persistent.
- The subclass specific state, such as the color of a flat color material, should
- be extracted from \a newMaterial to update the color uniforms accordingly.
+ The return value must be \c true whenever any change was made to the uniform data.
- The \a oldMaterial can be used to minimze state changes when updating
- material states. The \a oldMaterial is 0 if this shader was just activated.
+ The subclass specific state, such as the color of a flat color material,
+ should be extracted from \a newMaterial to update the relevant regions in
+ the buffer accordingly.
- \sa activate(), deactivate()
+ \a oldMaterial can be used to minimize buffer changes (which are typically
+ memcpy calls) when updating material states. When \a oldMaterial is null,
+ this shader was just activated.
*/
-
-void QSGMaterialShader::updateState(const RenderState & /* state */, QSGMaterial * /* newMaterial */, QSGMaterial * /* oldMaterial */)
+bool QSGMaterialShader::updateUniformData(RenderState &state,
+ QSGMaterial *newMaterial,
+ QSGMaterial *oldMaterial)
{
+ Q_UNUSED(state);
+ Q_UNUSED(newMaterial);
+ Q_UNUSED(oldMaterial);
+ return false;
}
-#if QT_CONFIG(opengl)
/*!
- Sets the GLSL source file for the shader stage \a type to \a sourceFile. The
- default implementation of the vertexShader() and fragmentShader() functions
- will load the source files set by this function.
+ This function is called by the scene graph to prepare using a sampled image
+ in the shader, typically in form of a combined image sampler.
- This function is useful when you have a single source file for a given shader
- stage. If your shader consists of multiple source files then use
- setShaderSourceFiles()
+ \a binding is the binding number of the sampler. The function is called for
+ each variable in the material's shaders'
+ \l{QShaderDescription::combinedImageSamplers()}.
- \sa setShaderSourceFiles(), vertexShader(), fragmentShader()
- */
-void QSGMaterialShader::setShaderSourceFile(QOpenGLShader::ShaderType type, const QString &sourceFile)
-{
- Q_D(QSGMaterialShader);
- d->m_sourceFiles[type] = (QStringList() << sourceFile);
-}
+ When *\a{texture} is null, it must be set to a QSGTexture pointer before
+ returning. When non-null, it is up to the material to decide if a new
+ \c{QSGTexture *} is stored to it, or if it updates some parameters on the
+ already known QSGTexture. The ownership of the QSGTexture is not
+ transferred.
-/*!
- Sets the GLSL source files for the shader stage \a type to \a sourceFiles. The
- default implementation of the vertexShader() and fragmentShader() functions
- will load the source files set by this function in the order given.
+ The current rendering \a state is passed from the scene graph. It is up to
+ the material to enqueue the texture data uploads to the
+ QRhiResourceUpdateBatch retriveable via RenderState::resourceUpdateBatch().
- \sa setShaderSourceFile(), vertexShader(), fragmentShader()
+ The subclass specific state can be extracted from \a newMaterial.
+
+ \a oldMaterial can be used to minimize changes. When \a oldMaterial is null,
+ this shader was just activated.
*/
-void QSGMaterialShader::setShaderSourceFiles(QOpenGLShader::ShaderType type, const QStringList &sourceFiles)
+void QSGMaterialShader::updateSampledImage(RenderState &state,
+ int binding,
+ QSGTexture **texture,
+ QSGMaterial *newMaterial,
+ QSGMaterial *oldMaterial)
{
- Q_D(QSGMaterialShader);
- d->m_sourceFiles[type] = sourceFiles;
+ Q_UNUSED(state);
+ Q_UNUSED(binding);
+ Q_UNUSED(texture);
+ Q_UNUSED(newMaterial);
+ Q_UNUSED(oldMaterial);
}
/*!
- This function is called when the shader is initialized to compile the
- actual QOpenGLShaderProgram. Do not call it explicitly.
+ This function is called by the scene graph to enable the material to
+ provide a custom set of graphics state. The set of states that are
+ customizable by material is limited to blending and related settings.
- The default implementation will extract the vertexShader() and
- fragmentShader() and bind the names returned from attributeNames()
- to consecutive vertex attribute registers starting at 0.
- */
+ \note This function is only called when the UpdatesGraphicsPipelineState
+ flag was enabled via setFlags(). By default it is not set, and so this
+ function is never called.
-void QSGMaterialShader::compile()
-{
- Q_ASSERT_X(!m_program.isLinked(), "QSGSMaterialShader::compile()", "Compile called multiple times!");
-
- program()->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader());
- program()->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader());
-
- char const *const *attr = attributeNames();
-#ifndef QT_NO_DEBUG
- int maxVertexAttribs = 0;
- QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
- funcs->glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
- for (int i = 0; attr[i]; ++i) {
- if (i >= maxVertexAttribs) {
- qFatal("List of attribute names is either too long or not null-terminated.\n"
- "Maximum number of attributes on this hardware is %i.\n"
- "Vertex shader:\n%s\n"
- "Fragment shader:\n%s\n",
- maxVertexAttribs, vertexShader(), fragmentShader());
- }
- if (*attr[i])
- program()->bindAttributeLocation(attr[i], i);
- }
-#else
- for (int i = 0; attr[i]; ++i) {
- if (*attr[i])
- program()->bindAttributeLocation(attr[i], i);
- }
-#endif
+ The return value must be \c true whenever a change was made to any of the
+ members in \a ps.
- if (!program()->link()) {
- qWarning("QSGMaterialShader: Shader compilation failed:");
- qWarning() << program()->log();
- }
-}
+ \note The contents of \a ps is not persistent between invocations of this
+ function.
-#endif
+ The current rendering \a state is passed from the scene graph.
+
+ The subclass specific state can be extracted from \a newMaterial. When \a
+ oldMaterial is null, this shader was just activated.
+ */
+bool QSGMaterialShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
+ QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
+{
+ Q_UNUSED(state);
+ Q_UNUSED(ps);
+ Q_UNUSED(newMaterial);
+ Q_UNUSED(oldMaterial);
+ return false;
+}
/*!
\class QSGMaterialShader::RenderState
- \brief The QSGMaterialShader::RenderState encapsulates the current rendering state
- during a call to QSGMaterialShader::updateState().
- \inmodule QtQuick
- The render state contains a number of accessors that the shader needs to respect
- in order to conform to the current state of the scene graph.
-
- The instance is only valid inside a call to QSGMaterialShader::updateState() and
- should not be used outisde this function.
- */
+ \brief Encapsulates the current rendering state during a call to
+ QSGMaterialShader::updateUniformData() and the other \c update type of
+ functions.
+ \inmodule QtQuick
+ \since 5.14
+ The render state contains a number of accessors that the shader needs to
+ respect in order to conform to the current state of the scene graph.
+ */
/*!
\enum QSGMaterialShader::RenderState::DirtyState
- \value DirtyMatrix Used to indicate that the matrix has changed and must be updated.
-
- \value DirtyOpacity Used to indicate that the opacity has changed and must be updated.
+ \value DirtyMatrix Used to indicate that the matrix has changed and must be
+ updated.
- \value DirtyCachedMaterialData Used to indicate that the cached material data have changed and must be updated.
+ \value DirtyOpacity Used to indicate that the opacity has changed and must
+ be updated.
\value DirtyAll Used to indicate that everything needs to be updated.
*/
-
-
/*!
\fn bool QSGMaterialShader::RenderState::isMatrixDirty() const
@@ -406,8 +501,6 @@ void QSGMaterialShader::compile()
otherwise returns \c false.
*/
-
-
/*!
\fn bool QSGMaterialShader::RenderState::isOpacityDirty() const
@@ -416,13 +509,6 @@ void QSGMaterialShader::compile()
*/
/*!
- \fn bool QSGMaterialShader::RenderState::isCachedMaterialDataDirty() const
-
- Returns \c true if the dirtyStates() contains the dirty cached material state,
- otherwise returns \c false.
- */
-
-/*!
\fn QSGMaterialShader::RenderState::DirtyStates QSGMaterialShader::RenderState::dirtyStates() const
Returns which rendering states that have changed and needs to be updated
@@ -430,37 +516,98 @@ void QSGMaterialShader::compile()
rendering state.
*/
+/*!
+ \class QSGMaterialShader::GraphicsPipelineState
+
+ \brief Describes state changes that the material wants to apply to the
+ currently active graphics pipeline state.
+ \inmodule QtQuick
+ \since 5.14
+
+ Unlike QSGMaterialShader, directly issuing state change commands with the
+ underlying graphics API is not possible with QSGMaterialShader. This is
+ mainly because the concept of individually changeable states is considered
+ deprecated and not supported with modern graphics APIs.
+
+ Therefore, it is up to QSGMaterialShader to expose a data structure with
+ the set of supported states, which the material can change in its
+ updatePipelineState() implementation, if there is one. The scenegraph will
+ then internally apply these changes to the active graphics pipeline state,
+ then rolling them back as appropriate.
+ */
/*!
- Returns the accumulated opacity to be used for rendering.
+ \enum QSGMaterialShader::GraphicsPipelineState::BlendFactor
+ \since 5.14
+
+ \value Zero
+ \value One
+ \value SrcColor
+ \value OneMinusSrcColor
+ \value DstColor
+ \value OneMinusDstColor
+ \value SrcAlpha
+ \value OneMinusSrcAlpha
+ \value DstAlpha
+ \value OneMinusDstAlpha
+ \value ConstantColor
+ \value OneMinusConstantColor
+ \value ConstantAlpha
+ \value OneMinusConstantAlpha
+ \value SrcAlphaSaturate
+ \value Src1Color
+ \value OneMinusSrc1Color
+ \value Src1Alpha
+ \value OneMinusSrc1Alpha
+ */
+
+/*!
+ \enum QSGMaterialShader::GraphicsPipelineState::ColorMaskComponent
+ \since 5.14
+
+ \value R
+ \value G
+ \value B
+ \value A
*/
+/*!
+ \enum QSGMaterialShader::GraphicsPipelineState::CullMode
+ \since 5.14
+
+ \value CullNone
+ \value CullFront
+ \value CullBack
+ */
+
+/*!
+ Returns the accumulated opacity to be used for rendering.
+ */
float QSGMaterialShader::RenderState::opacity() const
{
Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->currentOpacity();
+ return float(static_cast<const QSGRenderer *>(m_data)->currentOpacity());
}
/*!
Returns the modelview determinant to be used for rendering.
*/
-
float QSGMaterialShader::RenderState::determinant() const
{
Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->determinant();
+ return float(static_cast<const QSGRenderer *>(m_data)->determinant());
}
/*!
Returns the matrix combined of modelview matrix and project matrix.
*/
-
QMatrix4x4 QSGMaterialShader::RenderState::combinedMatrix() const
{
Q_ASSERT(m_data);
return static_cast<const QSGRenderer *>(m_data)->currentCombinedMatrix();
}
+
/*!
Returns the ratio between physical pixels and device-independent pixels
to be used for rendering.
@@ -468,29 +615,23 @@ QMatrix4x4 QSGMaterialShader::RenderState::combinedMatrix() const
float QSGMaterialShader::RenderState::devicePixelRatio() const
{
Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->devicePixelRatio();
+ return float(static_cast<const QSGRenderer *>(m_data)->devicePixelRatio());
}
-
-
/*!
Returns the model view matrix.
- If the material has the RequiresFullMatrix flag
- set, this is guaranteed to be the complete transform
- matrix calculated from the scenegraph.
+ If the material has the RequiresFullMatrix flag set, this is guaranteed to
+ be the complete transform matrix calculated from the scenegraph.
- However, if this flag is not set, the renderer may
- choose to alter this matrix. For example, it may
- pre-transform vertices on the CPU and set this matrix
- to identity.
+ However, if this flag is not set, the renderer may choose to alter this
+ matrix. For example, it may pre-transform vertices on the CPU and set this
+ matrix to identity.
- In a situation such as the above, it is still possible
- to retrieve the actual matrix determinant by setting
- the RequiresDeterminant flag in the material and
- calling the determinant() accessor.
+ In a situation such as the above, it is still possible to retrieve the
+ actual matrix determinant by setting the RequiresDeterminant flag in the
+ material and calling the determinant() accessor.
*/
-
QMatrix4x4 QSGMaterialShader::RenderState::modelViewMatrix() const
{
Q_ASSERT(m_data);
@@ -500,53 +641,75 @@ QMatrix4x4 QSGMaterialShader::RenderState::modelViewMatrix() const
/*!
Returns the projection matrix.
*/
-
QMatrix4x4 QSGMaterialShader::RenderState::projectionMatrix() const
{
Q_ASSERT(m_data);
return static_cast<const QSGRenderer *>(m_data)->currentProjectionMatrix();
}
-
-
/*!
Returns the viewport rect of the surface being rendered to.
*/
-
QRect QSGMaterialShader::RenderState::viewportRect() const
{
Q_ASSERT(m_data);
return static_cast<const QSGRenderer *>(m_data)->viewportRect();
}
-
-
/*!
Returns the device rect of the surface being rendered to
*/
-
QRect QSGMaterialShader::RenderState::deviceRect() const
{
Q_ASSERT(m_data);
return static_cast<const QSGRenderer *>(m_data)->deviceRect();
}
-#if QT_CONFIG(opengl)
-
/*!
- Returns the QOpenGLContext that is being used for rendering
+ Returns a pointer to the data for the uniform (constant) buffer in the
+ shader. Uniform data must only be updated from
+ QSGMaterialShader::updateUniformData(). The return value is null in the
+ other reimplementable functions, such as,
+ QSGMaterialShader::updateSampledImage().
+
+ \note It is strongly recommended to declare the uniform block with \c
+ std140 in the shader, and to carefully study the standard uniform block
+ layout as described in section 7.6.2.2 of the OpenGL specification. It is
+ up to the QSGMaterialShader implementation to ensure data gets placed
+ at the right location in this QByteArray, taking alignment requirements
+ into account. Shader code translated to other shading languages is expected
+ to use the same offsets for block members, even when the target language
+ uses different packing rules by default.
+
+ \note Avoid copying from C++ POD types, such as, structs, in order to
+ update multiple members at once, unless it has been verified that the
+ layouts of the C++ struct and the GLSL uniform block match.
*/
+QByteArray *QSGMaterialShader::RenderState::uniformData()
+{
+ Q_ASSERT(m_data);
+ return static_cast<const QSGRenderer *>(m_data)->currentUniformData();
+}
-QOpenGLContext *QSGMaterialShader::RenderState::context() const
+/*!
+ Returns a resource update batch to which upload and copy operatoins can be
+ queued. This is typically used by
+ QSGMaterialShader::updateSampledImage() to enqueue texture image
+ content updates.
+ */
+QRhiResourceUpdateBatch *QSGMaterialShader::RenderState::resourceUpdateBatch()
{
- // Only the QSGDefaultRenderContext will have an OpenGL Context to query
- auto openGLRenderContext = static_cast<const QSGDefaultRenderContext *>(static_cast<const QSGRenderer *>(m_data)->context());
- if (openGLRenderContext != nullptr)
- return openGLRenderContext->openglContext();
- else
- return nullptr;
+ Q_ASSERT(m_data);
+ return static_cast<const QSGRenderer *>(m_data)->currentResourceUpdateBatch();
}
-#endif
+/*!
+ Returns the current QRhi.
+ */
+QRhi *QSGMaterialShader::RenderState::rhi()
+{
+ Q_ASSERT(m_data);
+ return static_cast<const QSGRenderer *>(m_data)->currentRhi();
+}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader.h b/src/quick/scenegraph/coreapi/qsgmaterialshader.h
index 6783b3f890..765a8ee513 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialshader.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterialshader.h
@@ -41,21 +41,24 @@
#define QSGMATERIALSHADER_H
#include <QtQuick/qtquickglobal.h>
+#include <QtCore/QRect>
+#include <QtGui/QMatrix4x4>
+#include <QtGui/QColor>
+#include <QtQuick/qsgmaterialtype.h>
+
+// ### glpurge Remove when purging direct OpenGL usage
#if QT_CONFIG(opengl)
# include <qopenglshaderprogram.h>
#endif
-#include <QtGui/QMatrix4x4>
-#include <QtCore/QRect>
-#include <QtQuick/qsgmaterialtype.h> // for source compat
QT_BEGIN_NAMESPACE
class QSGMaterial;
class QSGMaterialShaderPrivate;
-
-namespace QSGBatchRenderer {
- class ShaderManager;
-}
+class QSGTexture;
+class QRhiResourceUpdateBatch;
+class QRhi;
+class QShader;
class Q_QUICK_EXPORT QSGMaterialShader
{
@@ -73,9 +76,8 @@ public:
inline DirtyStates dirtyStates() const { return m_dirty; }
- inline bool isMatrixDirty() const { return m_dirty & DirtyMatrix; }
- inline bool isOpacityDirty() const { return m_dirty & DirtyOpacity; }
- bool isCachedMaterialDataDirty() const { return m_dirty & DirtyCachedMaterialData; }
+ inline bool isMatrixDirty() const { return m_dirty & QSGMaterialShader::RenderState::DirtyMatrix; }
+ inline bool isOpacityDirty() const { return m_dirty & QSGMaterialShader::RenderState::DirtyOpacity; }
float opacity() const;
QMatrix4x4 combinedMatrix() const;
@@ -85,51 +87,124 @@ public:
QRect deviceRect() const;
float determinant() const;
float devicePixelRatio() const;
-#if QT_CONFIG(opengl)
- QOpenGLContext *context() const;
-#endif
+
+ QByteArray *uniformData();
+ QRhiResourceUpdateBatch *resourceUpdateBatch();
+ QRhi *rhi();
+
private:
friend class QSGRenderer;
DirtyStates m_dirty;
const void *m_data;
};
+ struct Q_QUICK_EXPORT GraphicsPipelineState {
+ enum BlendFactor {
+ Zero,
+ One,
+ SrcColor,
+ OneMinusSrcColor,
+ DstColor,
+ OneMinusDstColor,
+ SrcAlpha,
+ OneMinusSrcAlpha,
+ DstAlpha,
+ OneMinusDstAlpha,
+ ConstantColor,
+ OneMinusConstantColor,
+ ConstantAlpha,
+ OneMinusConstantAlpha,
+ SrcAlphaSaturate,
+ Src1Color,
+ OneMinusSrc1Color,
+ Src1Alpha,
+ OneMinusSrc1Alpha
+ };
+
+ enum ColorMaskComponent {
+ R = 1 << 0,
+ G = 1 << 1,
+ B = 1 << 2,
+ A = 1 << 3
+ };
+ Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)
+
+ enum CullMode {
+ CullNone,
+ CullFront,
+ CullBack
+ };
+
+ bool blendEnable;
+ BlendFactor srcColor;
+ BlendFactor dstColor;
+ ColorMask colorWrite;
+ QColor blendConstant;
+ CullMode cullMode;
+ // This struct is extensible while keeping BC since apps only ever get
+ // a ptr to the struct, it is not created by them.
+ };
+
+ enum Flag {
+ UpdatesGraphicsPipelineState = 0x0001
+ };
+ Q_DECLARE_FLAGS(Flags, Flag)
+
+ enum Stage {
+ VertexStage,
+ FragmentStage,
+ };
+
QSGMaterialShader();
virtual ~QSGMaterialShader();
- virtual void activate();
- virtual void deactivate();
- // First time a material is used, oldMaterial is null.
- virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
- virtual char const *const *attributeNames() const = 0; // Array must end with null.
+ virtual bool updateUniformData(RenderState &state,
+ QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
+
+ virtual void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
+ QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
+
+ virtual bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
+ QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
+
+ Flags flags() const;
+ void setFlag(Flags flags, bool on = true);
+
+ // ### glpurge Remove when purging direct OpenGL usage
+ virtual char const *const *attributeNames() const { return nullptr; }
+ virtual void activate() { }
+ virtual void deactivate() { }
+ virtual void updateState(const RenderState &, QSGMaterial *, QSGMaterial *) { }
#if QT_CONFIG(opengl)
- inline QOpenGLShaderProgram *program() { return &m_program; }
+ inline QOpenGLShaderProgram *program() { return nullptr; }
#endif
-protected:
- Q_DECLARE_PRIVATE(QSGMaterialShader)
- QSGMaterialShader(QSGMaterialShaderPrivate &dd);
-
- friend class QSGDefaultRenderContext;
- friend class QSGBatchRenderer::ShaderManager;
#if QT_CONFIG(opengl)
- void setShaderSourceFile(QOpenGLShader::ShaderType type, const QString &sourceFile);
- void setShaderSourceFiles(QOpenGLShader::ShaderType type, const QStringList &sourceFiles);
-
- virtual void compile();
+ void setShaderSourceFile(QOpenGLShader::ShaderType, const QString &) { }
+ void setShaderSourceFiles(QOpenGLShader::ShaderType, const QStringList &) { }
+ virtual void compile() { }
#endif
virtual void initialize() { }
#if QT_CONFIG(opengl)
- virtual const char *vertexShader() const;
- virtual const char *fragmentShader() const;
+ virtual const char *vertexShader() const { return nullptr; }
+ virtual const char *fragmentShader() const { return nullptr; }
#endif
+
+protected:
+ Q_DECLARE_PRIVATE(QSGMaterialShader)
+ QSGMaterialShader(QSGMaterialShaderPrivate &dd);
+
+ // filename is for a file containing a serialized QShader.
+ void setShaderFileName(Stage stage, const QString &filename);
+
+ void setShader(Stage stage, const QShader &shader);
+
private:
-#if QT_CONFIG(opengl)
- QOpenGLShaderProgram m_program;
-#endif
QScopedPointer<QSGMaterialShaderPrivate> d_ptr;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialShader::RenderState::DirtyStates)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialShader::GraphicsPipelineState::ColorMask)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QSGMaterialShader::Flags)
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h b/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h
index ae23b4a8ce..4104e32dbc 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
-** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -53,21 +52,63 @@
//
#include <private/qtquickglobal_p.h>
+#include "qsgmaterialshader.h"
#include "qsgmaterial.h"
+#include <QtGui/private/qrhi_p.h>
+#include <QtGui/private/qshader_p.h>
QT_BEGIN_NAMESPACE
+class QRhiSampler;
+
class Q_QUICK_PRIVATE_EXPORT QSGMaterialShaderPrivate
{
public:
-#if QT_CONFIG(opengl)
- const char *loadShaderSource(QOpenGLShader::ShaderType type) const;
+ Q_DECLARE_PUBLIC(QSGMaterialShader)
- QHash<QOpenGLShader::ShaderType, QStringList> m_sourceFiles;
- mutable QHash<QOpenGLShader::ShaderType, QByteArray> m_sources;
-#endif
+ QSGMaterialShaderPrivate(QSGMaterialShader *q) : q_ptr(q) { }
+ static QSGMaterialShaderPrivate *get(QSGMaterialShader *s) { return s->d_func(); }
+ static const QSGMaterialShaderPrivate *get(const QSGMaterialShader *s) { return s->d_func(); }
+
+ void clearCachedRendererData();
+ void prepare(QShader::Variant vertexShaderVariant);
+
+ QShader shader(QShader::Stage stage) const { return shaders[stage].shader; }
+
+ static QShader loadShader(const QString &filename);
+
+ QSGMaterialShader *q_ptr;
+ QHash<QShader::Stage, QString> shaderFileNames;
+ QSGMaterialShader::Flags flags;
+
+ struct ShaderStageData {
+ ShaderStageData() { } // so shader.isValid() == false
+ ShaderStageData(const QShader &shader) : shader(shader) { }
+ QShader shader;
+ QShader::Variant shaderVariant = QShader::StandardShader;
+ QVector<int> vertexInputLocations; // excluding rewriter-inserted ones
+ int qt_order_attrib_location = -1; // rewriter-inserted
+ };
+ QHash<QShader::Stage, ShaderStageData> shaders;
+
+ static const int MAX_SHADER_RESOURCE_BINDINGS = 32;
+
+ int ubufBinding = -1;
+ int ubufSize = 0;
+ QRhiShaderResourceBinding::StageFlags ubufStages;
+ QRhiShaderResourceBinding::StageFlags combinedImageSamplerBindings[MAX_SHADER_RESOURCE_BINDINGS];
+
+ ShaderStageData *vertexShader = nullptr;
+ ShaderStageData *fragmentShader = nullptr;
+
+ QByteArray masterUniformData;
+
+ QSGTexture *textureBindingTable[MAX_SHADER_RESOURCE_BINDINGS];
+ QRhiSampler *samplerBindingTable[MAX_SHADER_RESOURCE_BINDINGS];
};
+Q_DECLARE_TYPEINFO(QSGMaterialShaderPrivate::ShaderStageData, Q_MOVABLE_TYPE);
+
QT_END_NAMESPACE
-#endif // QSGMATERIALSHADER_P_H
+#endif
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
index 3f2154e3c1..f9d7d3a65a 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
@@ -94,7 +94,6 @@ public:
QSGNodeUpdater *nodeUpdater() const;
void setNodeUpdater(QSGNodeUpdater *updater);
inline QSGMaterialShader::RenderState state(QSGMaterialShader::RenderState::DirtyStates dirty) const;
- inline QSGMaterialRhiShader::RenderState rhiState(QSGMaterialRhiShader::RenderState::DirtyStates dirty) const;
virtual void setCustomRenderMode(const QByteArray &) { }
virtual bool hasCustomRenderModeWithContinuousUpdate() const { return false; }
virtual void releaseCachedResources() { }
@@ -102,7 +101,7 @@ public:
void clearChangedFlag() { m_changed_emitted = false; }
- // Accessed by QSGMaterialRhiShader::RenderState.
+ // Accessed by QSGMaterialShader::RenderState.
QByteArray *currentUniformData() const { return m_current_uniform_data; }
QRhiResourceUpdateBatch *currentResourceUpdateBatch() const { return m_current_resource_update_batch; }
QRhi *currentRhi() const { return m_rhi; }
@@ -197,14 +196,6 @@ QSGMaterialShader::RenderState QSGRenderer::state(QSGMaterialShader::RenderState
return s;
}
-QSGMaterialRhiShader::RenderState QSGRenderer::rhiState(QSGMaterialRhiShader::RenderState::DirtyStates dirty) const
-{
- QSGMaterialRhiShader::RenderState s;
- s.m_dirty = dirty;
- s.m_data = this;
- return s;
-}
-
class Q_QUICK_PRIVATE_EXPORT QSGNodeDumper : public QSGNodeVisitor {
diff --git a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp
index 3468cc270d..b26cba3ac3 100644
--- a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp
@@ -42,7 +42,7 @@
#include "qsgrhivisualizer_p.h"
#include <qmath.h>
#include <QQuickWindow>
-#include <private/qsgmaterialrhishader_p.h>
+#include <private/qsgmaterialshader_p.h>
#include <private/qsgshadersourcebuilder_p.h>
QT_BEGIN_NAMESPACE
@@ -94,9 +94,9 @@ void RhiVisualizer::prepareVisualize()
return;
if (!m_vs.isValid()) {
- m_vs = QSGMaterialRhiShaderPrivate::loadShader(
+ m_vs = QSGMaterialShaderPrivate::loadShader(
QLatin1String(":/qt-project.org/scenegraph/shaders_ng/visualization.vert.qsb"));
- m_fs = QSGMaterialRhiShaderPrivate::loadShader(
+ m_fs = QSGMaterialShaderPrivate::loadShader(
QLatin1String(":/qt-project.org/scenegraph/shaders_ng/visualization.frag.qsb"));
}
diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp
index 65a43785aa..b90dff910d 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture.cpp
+++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp
@@ -451,7 +451,7 @@ QSGTexture::~QSGTexture()
\a resourceUpdates is an optional resource update batch, on which texture
operations, if any, are enqueued. Materials can retrieve an instance from
- QSGMaterialRhiShader::RenderState. When null, the removedFromAtlas()
+ QSGMaterialShader::RenderState. When null, the removedFromAtlas()
implementation creates its own batch and submit it right away. However,
when a valid instance is specified, this function will not submit the
update batch.
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 44fef4ddef..e13b16c95b 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -90,9 +90,6 @@ static inline qreal fontSmoothingGamma()
return fontSmoothingGamma;
}
-
-// ***** legacy (GL) material shader implementations
-
static inline qreal qsg_device_pixel_ratio(QOpenGLContext *ctx)
{
qreal devicePixelRatio = 1;
@@ -108,304 +105,7 @@ static inline qreal qsg_device_pixel_ratio(QOpenGLContext *ctx)
return devicePixelRatio;
}
-class QSGTextMaskShader : public QSGMaterialShader
-{
-public:
- QSGTextMaskShader(QFontEngine::GlyphFormat glyphFormat);
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-protected:
- void initialize() override;
-
- int m_matrix_id;
- int m_color_id;
- int m_textureScale_id;
- float m_devicePixelRatio;
-
- QFontEngine::GlyphFormat m_glyphFormat;
-};
-
-char const *const *QSGTextMaskShader::attributeNames() const
-{
- static char const *const attr[] = { "vCoord", "tCoord", nullptr };
- return attr;
-}
-
-QSGTextMaskShader::QSGTextMaskShader(QFontEngine::GlyphFormat glyphFormat)
- : QSGMaterialShader(*new QSGMaterialShaderPrivate)
- , m_matrix_id(-1)
- , m_color_id(-1)
- , m_textureScale_id(-1)
- , m_glyphFormat(glyphFormat)
-{
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/textmask.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/textmask.frag"));
-}
-
-void QSGTextMaskShader::initialize()
-{
- m_matrix_id = program()->uniformLocation("matrix");
- m_color_id = program()->uniformLocation("color");
- m_textureScale_id = program()->uniformLocation("textureScale");
- m_devicePixelRatio = (float) qsg_device_pixel_ratio(QOpenGLContext::currentContext());
- program()->setUniformValue("dpr", m_devicePixelRatio);
-}
-
-void QSGTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect);
- QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect);
- Q_ASSERT(oldEffect == nullptr || newEffect->type() == oldEffect->type());
- bool updated = material->ensureUpToDate();
- Q_ASSERT(material->texture());
-
- Q_ASSERT(oldMaterial == nullptr || oldMaterial->texture());
- if (updated
- || oldMaterial == nullptr
- || oldMaterial->texture()->textureId() != material->texture()->textureId()) {
- program()->setUniformValue(m_textureScale_id, QVector2D(1.0 / material->openglGlyphCache()->width(),
- 1.0 / material->openglGlyphCache()->height()));
- QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
- funcs->glBindTexture(GL_TEXTURE_2D, material->texture()->textureId());
-
- // Set the mag/min filters to be nearest. We only need to do this when the texture
- // has been recreated.
- if (updated) {
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- }
- }
-
- float devicePixelRatio = (float) qsg_device_pixel_ratio(QOpenGLContext::currentContext());
- if (m_devicePixelRatio != devicePixelRatio) {
- m_devicePixelRatio = devicePixelRatio;
- program()->setUniformValue("dpr", m_devicePixelRatio);
- }
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, state.combinedMatrix());
-}
-
-class QSG8BitTextMaskShader : public QSGTextMaskShader
-{
-public:
- QSG8BitTextMaskShader(QFontEngine::GlyphFormat glyphFormat)
- : QSGTextMaskShader(glyphFormat)
- {
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/8bittextmask.frag"));
- }
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
-};
-
-void QSG8BitTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- QSGTextMaskShader::updateState(state, newEffect, oldEffect);
- QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect);
- QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect);
-
- if (oldMaterial == nullptr || material->color() != oldMaterial->color() || state.isOpacityDirty()) {
- QVector4D color = qsg_premultiply(material->color(), state.opacity());
- program()->setUniformValue(m_color_id, color);
- }
-}
-
-class QSG24BitTextMaskShader : public QSGTextMaskShader
-{
-public:
- QSG24BitTextMaskShader(QFontEngine::GlyphFormat glyphFormat)
- : QSGTextMaskShader(glyphFormat)
- , m_useSRGB(false)
- {
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/24bittextmask.frag"));
- }
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- void initialize() override;
- void activate() override;
- void deactivate() override;
-
- bool useSRGB() const;
- uint m_useSRGB : 1;
-};
-
-void QSG24BitTextMaskShader::initialize()
-{
- QSGTextMaskShader::initialize();
- // 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0,
- // but using sRGB looks okay.
- if (QOpenGLContext::currentContext()->hasExtension(QByteArrayLiteral("GL_ARB_framebuffer_sRGB"))
- && m_glyphFormat == QFontEngine::Format_A32
- && qAbs(fontSmoothingGamma() - 2.2) < 0.25) {
- QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
- GLint srgbCapable = 0;
- funcs->glGetIntegerv(GL_FRAMEBUFFER_SRGB_CAPABLE, &srgbCapable);
- if (srgbCapable)
- m_useSRGB = true;
- }
-}
-
-bool QSG24BitTextMaskShader::useSRGB() const
-{
-#ifdef Q_OS_MACOS
- if (!m_useSRGB)
- return false;
-
- // m_useSRGB is true, but if some QOGLFBO was bound check it's texture format:
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
- QOpenGLFramebufferObject *qfbo = QOpenGLContextPrivate::get(ctx)->qgl_current_fbo;
- bool fboInvalid = QOpenGLContextPrivate::get(ctx)->qgl_current_fbo_invalid;
- return !qfbo || fboInvalid || qfbo->format().internalTextureFormat() == GL_SRGB8_ALPHA8_EXT;
-#else
- return m_useSRGB;
-#endif
-}
-
-void QSG24BitTextMaskShader::activate()
-{
- QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
- funcs->glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR);
- if (useSRGB())
- funcs->glEnable(GL_FRAMEBUFFER_SRGB);
-}
-
-void QSG24BitTextMaskShader::deactivate()
-{
- QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
- funcs->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- if (useSRGB())
- funcs->glDisable(GL_FRAMEBUFFER_SRGB);
-}
-
-void QSG24BitTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- QSGTextMaskShader::updateState(state, newEffect, oldEffect);
- QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect);
- QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect);
-
- if (oldMaterial == nullptr || material->color() != oldMaterial->color() || state.isOpacityDirty()) {
- QVector4D color = material->color();
- if (useSRGB())
- color = qt_sRGB_to_linear_RGB(color);
- QOpenGLContext::currentContext()->functions()->glBlendColor(color.x(), color.y(), color.z(), color.w());
- color = qsg_premultiply(color, state.opacity());
- program()->setUniformValue(m_color_id, color.w());
- }
-}
-
-class QSG32BitColorTextShader : public QSGTextMaskShader
-{
-public:
- QSG32BitColorTextShader(QFontEngine::GlyphFormat glyphFormat)
- : QSGTextMaskShader(glyphFormat)
- {
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/32bitcolortext.frag"));
- }
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
-};
-
-void QSG32BitColorTextShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- QSGTextMaskShader::updateState(state, newEffect, oldEffect);
- QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect);
- QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect);
-
- if (oldMaterial == nullptr || material->color() != oldMaterial->color() || state.isOpacityDirty()) {
- float opacity = material->color().w() * state.opacity();
- program()->setUniformValue(m_color_id, opacity);
- }
-}
-
-class QSGStyledTextShader : public QSG8BitTextMaskShader
-{
-public:
- QSGStyledTextShader(QFontEngine::GlyphFormat glyphFormat)
- : QSG8BitTextMaskShader(glyphFormat)
- {
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/styledtext.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/styledtext.frag"));
- }
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
-
-private:
- void initialize() override;
-
- int m_shift_id;
- int m_styleColor_id;
-};
-
-void QSGStyledTextShader::initialize()
-{
- QSG8BitTextMaskShader::initialize();
- m_shift_id = program()->uniformLocation("shift");
- m_styleColor_id = program()->uniformLocation("styleColor");
-}
-
-void QSGStyledTextShader::updateState(const RenderState &state,
- QSGMaterial *newEffect,
- QSGMaterial *oldEffect)
-{
- Q_ASSERT(oldEffect == nullptr || newEffect->type() == oldEffect->type());
-
- QSGStyledTextMaterial *material = static_cast<QSGStyledTextMaterial *>(newEffect);
- QSGStyledTextMaterial *oldMaterial = static_cast<QSGStyledTextMaterial *>(oldEffect);
-
- if (oldMaterial == nullptr || oldMaterial->styleShift() != material->styleShift())
- program()->setUniformValue(m_shift_id, material->styleShift());
-
- if (oldMaterial == nullptr || material->color() != oldMaterial->color() || state.isOpacityDirty()) {
- QVector4D color = qsg_premultiply(material->color(), state.opacity());
- program()->setUniformValue(m_color_id, color);
- }
-
- if (oldMaterial == nullptr || material->styleColor() != oldMaterial->styleColor() || state.isOpacityDirty()) {
- QVector4D styleColor = qsg_premultiply(material->styleColor(), state.opacity());
- program()->setUniformValue(m_styleColor_id, styleColor);
- }
-
- bool updated = material->ensureUpToDate();
- Q_ASSERT(material->texture());
-
- Q_ASSERT(oldMaterial == nullptr || oldMaterial->texture());
- if (updated
- || oldMaterial == nullptr
- || oldMaterial->texture()->textureId() != material->texture()->textureId()) {
- program()->setUniformValue(m_textureScale_id, QVector2D(1.0 / material->openglGlyphCache()->width(),
- 1.0 / material->openglGlyphCache()->height()));
- QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
- funcs->glBindTexture(GL_TEXTURE_2D, material->texture()->textureId());
-
- // Set the mag/min filters to be nearest. We only need to do this when the texture
- // has been recreated.
- if (updated) {
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- }
- }
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, state.combinedMatrix());
-}
-
-class QSGOutlinedTextShader : public QSGStyledTextShader
-{
-public:
- QSGOutlinedTextShader(QFontEngine::GlyphFormat glyphFormat)
- : QSGStyledTextShader(glyphFormat)
- {
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/outlinedtext.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/outlinedtext.frag"));
- }
-};
-
-
-// ***** RHI shader implementations
-
-class QSGTextMaskRhiShader : public QSGMaterialRhiShader
+class QSGTextMaskRhiShader : public QSGMaterialShader
{
public:
QSGTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat);
@@ -721,7 +421,6 @@ void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat)
{
Q_ASSERT(m_font.isValid());
- setFlag(SupportsRhiShader, true);
setFlag(Blending, true);
Q_ASSERT(m_rc);
@@ -902,28 +601,16 @@ QSGRhiTextureGlyphCache *QSGTextMaskMaterial::rhiGlyphCache() const
QSGMaterialShader *QSGTextMaskMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted)) {
- QSGRhiTextureGlyphCache *gc = rhiGlyphCache();
- const QFontEngine::GlyphFormat glyphFormat = gc->glyphFormat();
- switch (glyphFormat) {
- case QFontEngine::Format_ARGB:
- return new QSG32BitColorTextRhiShader(glyphFormat);
- case QFontEngine::Format_A32:
- return new QSG24BitTextMaskRhiShader(glyphFormat);
- case QFontEngine::Format_A8:
- default:
- return new QSG8BitTextMaskRhiShader(glyphFormat, gc->eightBitFormatIsAlphaSwizzled());
- }
- } else {
- switch (QFontEngine::GlyphFormat glyphFormat = glyphCache()->glyphFormat()) {
- case QFontEngine::Format_ARGB:
- return new QSG32BitColorTextShader(glyphFormat);
- case QFontEngine::Format_A32:
- return new QSG24BitTextMaskShader(glyphFormat);
- case QFontEngine::Format_A8:
- default:
- return new QSG8BitTextMaskShader(glyphFormat);
- }
+ QSGRhiTextureGlyphCache *gc = rhiGlyphCache();
+ const QFontEngine::GlyphFormat glyphFormat = gc->glyphFormat();
+ switch (glyphFormat) {
+ case QFontEngine::Format_ARGB:
+ return new QSG32BitColorTextRhiShader(glyphFormat);
+ case QFontEngine::Format_A32:
+ return new QSG24BitTextMaskRhiShader(glyphFormat);
+ case QFontEngine::Format_A8:
+ default:
+ return new QSG8BitTextMaskRhiShader(glyphFormat, gc->eightBitFormatIsAlphaSwizzled());
}
}
@@ -996,12 +683,8 @@ QSGMaterialType *QSGStyledTextMaterial::type() const
QSGMaterialShader *QSGStyledTextMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted)) {
- QSGRhiTextureGlyphCache *gc = rhiGlyphCache();
- return new QSGStyledTextRhiShader(gc->glyphFormat(), gc->eightBitFormatIsAlphaSwizzled());
- } else {
- return new QSGStyledTextShader(glyphCache()->glyphFormat());
- }
+ QSGRhiTextureGlyphCache *gc = rhiGlyphCache();
+ return new QSGStyledTextRhiShader(gc->glyphFormat(), gc->eightBitFormatIsAlphaSwizzled());
}
int QSGStyledTextMaterial::compare(const QSGMaterial *o) const
@@ -1031,12 +714,8 @@ QSGMaterialType *QSGOutlinedTextMaterial::type() const
QSGMaterialShader *QSGOutlinedTextMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted)) {
- QSGRhiTextureGlyphCache *gc = rhiGlyphCache();
- return new QSGOutlinedTextRhiShader(gc->glyphFormat(), gc->eightBitFormatIsAlphaSwizzled());
- } else {
- return new QSGOutlinedTextShader(glyphCache()->glyphFormat());
- }
+ QSGRhiTextureGlyphCache *gc = rhiGlyphCache();
+ return new QSGOutlinedTextRhiShader(gc->glyphFormat(), gc->eightBitFormatIsAlphaSwizzled());
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
index e609bea439..6cd4dcec78 100644
--- a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
@@ -47,20 +47,6 @@
QT_BEGIN_NAMESPACE
-class SmoothTextureMaterialShader : public QSGTextureMaterialShader
-{
-public:
- SmoothTextureMaterialShader();
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-protected:
- void initialize() override;
-
- int m_pixelSizeLoc;
-};
-
class SmoothTextureMaterialRhiShader : public QSGTextureMaterialRhiShader
{
public:
@@ -72,7 +58,6 @@ public:
QSGSmoothTextureMaterial::QSGSmoothTextureMaterial()
{
- setFlag(SupportsRhiShader, true);
setFlag(RequiresFullMatrixExceptTranslate, true);
setFlag(Blending, true);
}
@@ -90,44 +75,7 @@ QSGMaterialType *QSGSmoothTextureMaterial::type() const
QSGMaterialShader *QSGSmoothTextureMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new SmoothTextureMaterialRhiShader;
- else
- return new SmoothTextureMaterialShader;
-}
-
-SmoothTextureMaterialShader::SmoothTextureMaterialShader()
-{
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothtexture.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothtexture.frag"));
-}
-
-void SmoothTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- if (oldEffect == nullptr) {
- // The viewport is constant, so set the pixel size uniform only once.
- QRect r = state.viewportRect();
- program()->setUniformValue(m_pixelSizeLoc, 2.0f / r.width(), 2.0f / r.height());
- }
- QSGTextureMaterialShader::updateState(state, newEffect, oldEffect);
-}
-
-char const *const *SmoothTextureMaterialShader::attributeNames() const
-{
- static char const *const attributes[] = {
- "vertex",
- "multiTexCoord",
- "vertexOffset",
- "texCoordOffset",
- nullptr
- };
- return attributes;
-}
-
-void SmoothTextureMaterialShader::initialize()
-{
- m_pixelSizeLoc = program()->uniformLocation("pixelSize");
- QSGTextureMaterialShader::initialize();
+ return new SmoothTextureMaterialRhiShader;
}
SmoothTextureMaterialRhiShader::SmoothTextureMaterialRhiShader()
diff --git a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp
index 5e4affbf90..5f0932af82 100644
--- a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp
@@ -50,63 +50,7 @@
QT_BEGIN_NAMESPACE
-class SmoothColorMaterialShader : public QSGMaterialShader
-{
-public:
- SmoothColorMaterialShader();
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-private:
- void initialize() override;
-
- int m_matrixLoc;
- int m_opacityLoc;
- int m_pixelSizeLoc;
-};
-
-SmoothColorMaterialShader::SmoothColorMaterialShader()
-{
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothcolor.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothcolor.frag"));
-}
-
-void SmoothColorMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *oldEffect)
-{
- if (state.isOpacityDirty())
- program()->setUniformValue(m_opacityLoc, state.opacity());
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrixLoc, state.combinedMatrix());
-
- if (oldEffect == nullptr) {
- // The viewport is constant, so set the pixel size uniform only once.
- QRect r = state.viewportRect();
- program()->setUniformValue(m_pixelSizeLoc, 2.0f / r.width(), 2.0f / r.height());
- }
-}
-
-char const *const *SmoothColorMaterialShader::attributeNames() const
-{
- static char const *const attributes[] = {
- "vertex",
- "vertexColor",
- "vertexOffset",
- nullptr
- };
- return attributes;
-}
-
-void SmoothColorMaterialShader::initialize()
-{
- m_matrixLoc = program()->uniformLocation("matrix");
- m_opacityLoc = program()->uniformLocation("opacity");
- m_pixelSizeLoc = program()->uniformLocation("pixelSize");
-}
-
-
-class SmoothColorMaterialRhiShader : public QSGMaterialRhiShader
+class SmoothColorMaterialRhiShader : public QSGMaterialShader
{
public:
SmoothColorMaterialRhiShader();
@@ -154,7 +98,6 @@ QSGSmoothColorMaterial::QSGSmoothColorMaterial()
{
setFlag(RequiresFullMatrixExceptTranslate, true);
setFlag(Blending, true);
- setFlag(SupportsRhiShader, true);
}
int QSGSmoothColorMaterial::compare(const QSGMaterial *) const
@@ -171,10 +114,7 @@ QSGMaterialType *QSGSmoothColorMaterial::type() const
QSGMaterialShader *QSGSmoothColorMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new SmoothColorMaterialRhiShader;
- else
- return new SmoothColorMaterialShader;
+ return new SmoothColorMaterialRhiShader;
}
QSGDefaultInternalRectangleNode::QSGDefaultInternalRectangleNode()
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
index d51d9e7bbe..a4ce8be967 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
@@ -46,7 +46,7 @@
#include <QtQuick/private/qsgrenderer_p.h>
#include <QtQuick/private/qsgrhiatlastexture_p.h>
#include <QtQuick/private/qsgrhidistancefieldglyphcache_p.h>
-#include <QtQuick/private/qsgmaterialrhishader_p.h>
+#include <QtQuick/private/qsgmaterialshader_p.h>
#include <QtQuick/private/qsgopenglatlastexture_p.h>
#include <QtQuick/private/qsgcompressedtexture_p.h>
@@ -411,9 +411,9 @@ void QSGDefaultRenderContext::initializeShader(QSGMaterialShader *shader)
shader->initialize();
}
-void QSGDefaultRenderContext::initializeRhiShader(QSGMaterialRhiShader *shader, QShader::Variant shaderVariant)
+void QSGDefaultRenderContext::initializeRhiShader(QSGMaterialShader *shader, QShader::Variant shaderVariant)
{
- QSGMaterialRhiShaderPrivate::get(shader)->prepare(shaderVariant);
+ QSGMaterialShaderPrivate::get(shader)->prepare(shaderVariant);
}
void QSGDefaultRenderContext::setAttachToGraphicsContext(bool attach)
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext_p.h b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
index be83f5a9f5..b6ed57ba6a 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext_p.h
+++ b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
@@ -65,7 +65,6 @@ class QRhiCommandBuffer;
class QRhiRenderPassDescriptor;
class QOpenGLContext;
class QSGMaterialShader;
-class QSGMaterialRhiShader;
class QOpenGLFramebufferObject;
class QSGDepthStencilBufferManager;
class QSGDepthStencilBuffer;
@@ -130,9 +129,9 @@ public:
QSGRenderer *createRenderer() override;
QSGTexture *compressedTextureForFactory(const QSGCompressedTextureFactory *factory) const override;
- virtual void compileShader(QSGMaterialShader *shader, QSGMaterial *material, const char *vertexCode = nullptr, const char *fragmentCode = nullptr);
- virtual void initializeShader(QSGMaterialShader *shader);
- virtual void initializeRhiShader(QSGMaterialRhiShader *shader, QShader::Variant shaderVariant);
+ virtual void compileShader(QSGMaterialShader *shader, QSGMaterial *material, const char *vertexCode = nullptr, const char *fragmentCode = nullptr); // legacy GL only
+ virtual void initializeShader(QSGMaterialShader *shader); // legacy GL only
+ virtual void initializeRhiShader(QSGMaterialShader *shader, QShader::Variant shaderVariant);
void setAttachToGraphicsContext(bool attach) override;
diff --git a/src/quick/scenegraph/qsgdefaultspritenode.cpp b/src/quick/scenegraph/qsgdefaultspritenode.cpp
index 573c6e7a5d..2f3a384891 100644
--- a/src/quick/scenegraph/qsgdefaultspritenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultspritenode.cpp
@@ -80,7 +80,6 @@ public:
QQuickSpriteMaterial::QQuickSpriteMaterial()
{
setFlag(Blending, true);
- setFlag(SupportsRhiShader, true);
}
QQuickSpriteMaterial::~QQuickSpriteMaterial()
@@ -88,51 +87,7 @@ QQuickSpriteMaterial::~QQuickSpriteMaterial()
delete texture;
}
-class SpriteMaterialShader : public QSGMaterialShader
-{
-public:
- SpriteMaterialShader()
- {
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/sprite.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/sprite.frag"));
- }
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) override
- {
- QQuickSpriteMaterial *m = static_cast<QQuickSpriteMaterial *>(newEffect);
- m->texture->bind();
-
- program()->setUniformValue(m_opacity_id, state.opacity());
- program()->setUniformValue(m_animData_id, m->animW, m->animH, m->animT);
- program()->setUniformValue(m_animPos_id, m->animX1, m->animY1, m->animX2, m->animY2);
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, state.combinedMatrix());
- }
-
- void initialize() override {
- m_matrix_id = program()->uniformLocation("qt_Matrix");
- m_opacity_id = program()->uniformLocation("qt_Opacity");
- m_animData_id = program()->uniformLocation("animData");
- m_animPos_id = program()->uniformLocation("animPos");
- }
-
- char const *const *attributeNames() const override {
- static const char *attr[] = {
- "vPos",
- "vTex",
- nullptr
- };
- return attr;
- }
-
- int m_matrix_id;
- int m_opacity_id;
- int m_animData_id;
- int m_animPos_id;
-};
-
-class SpriteMaterialRhiShader : public QSGMaterialRhiShader
+class SpriteMaterialRhiShader : public QSGMaterialShader
{
public:
SpriteMaterialRhiShader();
@@ -201,10 +156,7 @@ void SpriteMaterialRhiShader::updateSampledImage(RenderState &state, int binding
QSGMaterialShader *QQuickSpriteMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new SpriteMaterialRhiShader;
- else
- return new SpriteMaterialShader;
+ return new SpriteMaterialRhiShader;
}
static QSGGeometry::Attribute Sprite_Attributes[] = {
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index 30e17bbe04..8a4e0d0e9f 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -70,144 +70,7 @@ static float spreadFunc(float glyphScale)
return range / glyphScale;
}
-class QSGDistanceFieldTextMaterialShader : public QSGMaterialShader
-{
-public:
- QSGDistanceFieldTextMaterialShader();
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-protected:
- void initialize() override;
-
- void updateAlphaRange();
- void updateColor(const QVector4D &c);
- void updateTextureScale(const QVector2D &ts);
-
- float m_fontScale = 1.0;
- float m_matrixScale = 1.0;
-
- int m_matrix_id = -1;
- int m_textureScale_id = -1;
- int m_alphaMin_id = -1;
- int m_alphaMax_id = -1;
- int m_color_id = -1;
-
- QVector2D m_lastTextureScale;
- QVector4D m_lastColor;
- float m_lastAlphaMin = -1;
- float m_lastAlphaMax = -1;
-};
-
-char const *const *QSGDistanceFieldTextMaterialShader::attributeNames() const {
- static char const *const attr[] = { "vCoord", "tCoord", nullptr };
- return attr;
-}
-
-QSGDistanceFieldTextMaterialShader::QSGDistanceFieldTextMaterialShader()
-{
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldtext.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldtext.frag"));
-}
-
-void QSGDistanceFieldTextMaterialShader::updateAlphaRange()
-{
- float combinedScale = m_fontScale * m_matrixScale;
- float base = thresholdFunc(combinedScale);
- float range = spreadFunc(combinedScale);
- float alphaMin = qMax(0.0f, base - range);
- float alphaMax = qMin(base + range, 1.0f);
- if (alphaMin != m_lastAlphaMin) {
- program()->setUniformValue(m_alphaMin_id, GLfloat(alphaMin));
- m_lastAlphaMin = alphaMin;
- }
- if (alphaMax != m_lastAlphaMax) {
- program()->setUniformValue(m_alphaMax_id, GLfloat(alphaMax));
- m_lastAlphaMax = alphaMax;
- }
-}
-
-void QSGDistanceFieldTextMaterialShader::updateColor(const QVector4D &c)
-{
- if (m_lastColor != c) {
- program()->setUniformValue(m_color_id, c);
- m_lastColor = c;
- }
-}
-
-void QSGDistanceFieldTextMaterialShader::updateTextureScale(const QVector2D &ts)
-{
- if (m_lastTextureScale != ts) {
- program()->setUniformValue(m_textureScale_id, ts);
- m_lastTextureScale = ts;
- }
-}
-
-void QSGDistanceFieldTextMaterialShader::initialize()
-{
- QSGMaterialShader::initialize();
- m_matrix_id = program()->uniformLocation("matrix");
- m_textureScale_id = program()->uniformLocation("textureScale");
- m_color_id = program()->uniformLocation("color");
- m_alphaMin_id = program()->uniformLocation("alphaMin");
- m_alphaMax_id = program()->uniformLocation("alphaMax");
-}
-
-void QSGDistanceFieldTextMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- Q_ASSERT(oldEffect == nullptr || newEffect->type() == oldEffect->type());
- QSGDistanceFieldTextMaterial *material = static_cast<QSGDistanceFieldTextMaterial *>(newEffect);
- QSGDistanceFieldTextMaterial *oldMaterial = static_cast<QSGDistanceFieldTextMaterial *>(oldEffect);
-
- bool updated = material->updateTextureSize();
-
- if (oldMaterial == nullptr
- || material->color() != oldMaterial->color()
- || state.isOpacityDirty()) {
- QVector4D color = material->color();
- color *= state.opacity();
- updateColor(color);
- }
-
- bool updateRange = false;
- if (oldMaterial == nullptr
- || material->fontScale() != oldMaterial->fontScale()) {
- m_fontScale = material->fontScale();
- updateRange = true;
- }
- if (state.isMatrixDirty()) {
- program()->setUniformValue(m_matrix_id, state.combinedMatrix());
- m_matrixScale = qSqrt(qAbs(state.determinant())) * state.devicePixelRatio();
- updateRange = true;
- }
- if (updateRange) {
- updateAlphaRange();
- }
-
- Q_ASSERT(material->glyphCache());
-
- if (updated
- || oldMaterial == nullptr
- || oldMaterial->texture()->textureId != material->texture()->textureId) {
- updateTextureScale(QVector2D(1.0 / material->textureSize().width(),
- 1.0 / material->textureSize().height()));
-
- QOpenGLFunctions *funcs = state.context()->functions();
- funcs->glBindTexture(GL_TEXTURE_2D, material->texture()->textureId);
-
- if (updated) {
- // Set the mag/min filters to be linear. We only need to do this when the texture
- // has been recreated.
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
- }
-}
-
-class QSGDistanceFieldTextMaterialRhiShader : public QSGMaterialRhiShader
+class QSGDistanceFieldTextMaterialRhiShader : public QSGMaterialShader
{
public:
QSGDistanceFieldTextMaterialRhiShader(bool alphaTexture);
@@ -310,7 +173,7 @@ QSGDistanceFieldTextMaterial::QSGDistanceFieldTextMaterial()
, m_fontScale(1.0)
, m_sgTexture(nullptr)
{
- setFlag(Blending | RequiresDeterminant | SupportsRhiShader, true);
+ setFlag(Blending | RequiresDeterminant, true);
}
QSGDistanceFieldTextMaterial::~QSGDistanceFieldTextMaterial()
@@ -334,10 +197,7 @@ void QSGDistanceFieldTextMaterial::setColor(const QColor &color)
QSGMaterialShader *QSGDistanceFieldTextMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new QSGDistanceFieldTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
- else
- return new QSGDistanceFieldTextMaterialShader;
+ return new QSGDistanceFieldTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
}
bool QSGDistanceFieldTextMaterial::updateTextureSize()
@@ -387,47 +247,6 @@ int QSGDistanceFieldTextMaterial::compare(const QSGMaterial *o) const
return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
}
-
-class DistanceFieldStyledTextMaterialShader : public QSGDistanceFieldTextMaterialShader
-{
-public:
- DistanceFieldStyledTextMaterialShader();
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
-
-protected:
- void initialize() override;
-
- int m_styleColor_id = -1;
-};
-
-DistanceFieldStyledTextMaterialShader::DistanceFieldStyledTextMaterialShader()
- : QSGDistanceFieldTextMaterialShader()
-{
-}
-
-void DistanceFieldStyledTextMaterialShader::initialize()
-{
- QSGDistanceFieldTextMaterialShader::initialize();
- m_styleColor_id = program()->uniformLocation("styleColor");
-}
-
-void DistanceFieldStyledTextMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- QSGDistanceFieldTextMaterialShader::updateState(state, newEffect, oldEffect);
-
- QSGDistanceFieldStyledTextMaterial *material = static_cast<QSGDistanceFieldStyledTextMaterial *>(newEffect);
- QSGDistanceFieldStyledTextMaterial *oldMaterial = static_cast<QSGDistanceFieldStyledTextMaterial *>(oldEffect);
-
- if (oldMaterial == nullptr
- || material->styleColor() != oldMaterial->styleColor()
- || (state.isOpacityDirty())) {
- QVector4D color = material->styleColor();
- color *= state.opacity();
- program()->setUniformValue(m_styleColor_id, color);
- }
-}
-
class DistanceFieldStyledTextMaterialRhiShader : public QSGDistanceFieldTextMaterialRhiShader
{
public:
@@ -487,63 +306,6 @@ int QSGDistanceFieldStyledTextMaterial::compare(const QSGMaterial *o) const
return QSGDistanceFieldTextMaterial::compare(o);
}
-
-class DistanceFieldOutlineTextMaterialShader : public DistanceFieldStyledTextMaterialShader
-{
-public:
- DistanceFieldOutlineTextMaterialShader();
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
-
-protected:
- void initialize() override;
-
- void updateOutlineAlphaRange(int dfRadius);
-
- int m_outlineAlphaMax0_id = -1;
- int m_outlineAlphaMax1_id = -1;
-};
-
-DistanceFieldOutlineTextMaterialShader::DistanceFieldOutlineTextMaterialShader()
- : DistanceFieldStyledTextMaterialShader()
-{
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldoutlinetext.frag"));
-}
-
-void DistanceFieldOutlineTextMaterialShader::initialize()
-{
- DistanceFieldStyledTextMaterialShader::initialize();
- m_outlineAlphaMax0_id = program()->uniformLocation("outlineAlphaMax0");
- m_outlineAlphaMax1_id = program()->uniformLocation("outlineAlphaMax1");
-}
-
-void DistanceFieldOutlineTextMaterialShader::updateOutlineAlphaRange(int dfRadius)
-{
- float combinedScale = m_fontScale * m_matrixScale;
- float base = thresholdFunc(combinedScale);
- float range = spreadFunc(combinedScale);
- float outlineLimit = qMax(0.2f, base - 0.5f / dfRadius / m_fontScale);
-
- float alphaMin = qMax(0.0f, base - range);
- float styleAlphaMin0 = qMax(0.0f, outlineLimit - range);
- float styleAlphaMin1 = qMin(outlineLimit + range, alphaMin);
- program()->setUniformValue(m_outlineAlphaMax0_id, GLfloat(styleAlphaMin0));
- program()->setUniformValue(m_outlineAlphaMax1_id, GLfloat(styleAlphaMin1));
-}
-
-void DistanceFieldOutlineTextMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- DistanceFieldStyledTextMaterialShader::updateState(state, newEffect, oldEffect);
-
- QSGDistanceFieldOutlineTextMaterial *material = static_cast<QSGDistanceFieldOutlineTextMaterial *>(newEffect);
- QSGDistanceFieldOutlineTextMaterial *oldMaterial = static_cast<QSGDistanceFieldOutlineTextMaterial *>(oldEffect);
-
- if (oldMaterial == nullptr
- || material->fontScale() != oldMaterial->fontScale()
- || state.isMatrixDirty())
- updateOutlineAlphaRange(material->glyphCache()->distanceFieldRadius());
-}
-
class DistanceFieldOutlineTextMaterialRhiShader : public DistanceFieldStyledTextMaterialRhiShader
{
public:
@@ -609,61 +371,7 @@ QSGMaterialType *QSGDistanceFieldOutlineTextMaterial::type() const
QSGMaterialShader *QSGDistanceFieldOutlineTextMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new DistanceFieldOutlineTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
- else
- return new DistanceFieldOutlineTextMaterialShader;
-}
-
-
-class DistanceFieldShiftedStyleTextMaterialShader : public DistanceFieldStyledTextMaterialShader
-{
-public:
- DistanceFieldShiftedStyleTextMaterialShader();
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
-
-protected:
- void initialize() override;
-
- void updateShift(qreal fontScale, const QPointF& shift);
-
- int m_shift_id = -1;
-};
-
-DistanceFieldShiftedStyleTextMaterialShader::DistanceFieldShiftedStyleTextMaterialShader()
- : DistanceFieldStyledTextMaterialShader()
-{
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldshiftedtext.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldshiftedtext.frag"));
-}
-
-void DistanceFieldShiftedStyleTextMaterialShader::initialize()
-{
- DistanceFieldStyledTextMaterialShader::initialize();
- m_shift_id = program()->uniformLocation("shift");
-}
-
-void DistanceFieldShiftedStyleTextMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- DistanceFieldStyledTextMaterialShader::updateState(state, newEffect, oldEffect);
-
- QSGDistanceFieldShiftedStyleTextMaterial *material = static_cast<QSGDistanceFieldShiftedStyleTextMaterial *>(newEffect);
- QSGDistanceFieldShiftedStyleTextMaterial *oldMaterial = static_cast<QSGDistanceFieldShiftedStyleTextMaterial *>(oldEffect);
-
- if (oldMaterial == nullptr
- || oldMaterial->fontScale() != material->fontScale()
- || oldMaterial->shift() != material->shift()
- || oldMaterial->textureSize() != material->textureSize()) {
- updateShift(material->fontScale(), material->shift());
- }
-}
-
-void DistanceFieldShiftedStyleTextMaterialShader::updateShift(qreal fontScale, const QPointF &shift)
-{
- QPointF texel(1.0 / fontScale * shift.x(),
- 1.0 / fontScale * shift.y());
- program()->setUniformValue(m_shift_id, texel);
+ return new DistanceFieldOutlineTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
}
class DistanceFieldShiftedStyleTextMaterialRhiShader : public DistanceFieldStyledTextMaterialRhiShader
@@ -726,10 +434,7 @@ QSGMaterialType *QSGDistanceFieldShiftedStyleTextMaterial::type() const
QSGMaterialShader *QSGDistanceFieldShiftedStyleTextMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new DistanceFieldShiftedStyleTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
- else
- return new DistanceFieldShiftedStyleTextMaterialShader;
+ return new DistanceFieldShiftedStyleTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
}
int QSGDistanceFieldShiftedStyleTextMaterial::compare(const QSGMaterial *o) const
@@ -740,71 +445,6 @@ int QSGDistanceFieldShiftedStyleTextMaterial::compare(const QSGMaterial *o) cons
return QSGDistanceFieldStyledTextMaterial::compare(o);
}
-
-class QSGHiQSubPixelDistanceFieldTextMaterialShader : public QSGDistanceFieldTextMaterialShader
-{
-public:
- QSGHiQSubPixelDistanceFieldTextMaterialShader();
-
- void initialize() override;
- void activate() override;
- void deactivate() override;
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
-
-private:
- int m_fontScale_id = -1;
- int m_vecDelta_id = -1;
-};
-
-QSGHiQSubPixelDistanceFieldTextMaterialShader::QSGHiQSubPixelDistanceFieldTextMaterialShader()
- : QSGDistanceFieldTextMaterialShader()
-{
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag"));
-}
-
-void QSGHiQSubPixelDistanceFieldTextMaterialShader::initialize()
-{
- QSGDistanceFieldTextMaterialShader::initialize();
- m_fontScale_id = program()->uniformLocation("fontScale");
- m_vecDelta_id = program()->uniformLocation("vecDelta");
-}
-
-void QSGHiQSubPixelDistanceFieldTextMaterialShader::activate()
-{
- QSGDistanceFieldTextMaterialShader::activate();
- QOpenGLContext::currentContext()->functions()->glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR);
-}
-
-void QSGHiQSubPixelDistanceFieldTextMaterialShader::deactivate()
-{
- QSGDistanceFieldTextMaterialShader::deactivate();
- QOpenGLContext::currentContext()->functions()->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-}
-
-void QSGHiQSubPixelDistanceFieldTextMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- Q_ASSERT(oldEffect == nullptr || newEffect->type() == oldEffect->type());
- QSGDistanceFieldTextMaterial *material = static_cast<QSGDistanceFieldTextMaterial *>(newEffect);
- QSGDistanceFieldTextMaterial *oldMaterial = static_cast<QSGDistanceFieldTextMaterial *>(oldEffect);
-
- if (oldMaterial == nullptr || material->color() != oldMaterial->color()) {
- QVector4D c = material->color();
- state.context()->functions()->glBlendColor(c.x(), c.y(), c.z(), 1.0f);
- }
-
- if (oldMaterial == nullptr || material->fontScale() != oldMaterial->fontScale())
- program()->setUniformValue(m_fontScale_id, GLfloat(material->fontScale()));
-
- if (oldMaterial == nullptr || state.isMatrixDirty()) {
- int viewportWidth = state.viewportRect().width();
- QMatrix4x4 mat = state.combinedMatrix().inverted();
- program()->setUniformValue(m_vecDelta_id, mat.column(0) * (qreal(2) / viewportWidth));
- }
-
- QSGDistanceFieldTextMaterialShader::updateState(state, newEffect, oldEffect);
-}
-
class QSGHiQSubPixelDistanceFieldTextMaterialRhiShader : public QSGDistanceFieldTextMaterialRhiShader
{
public:
@@ -882,24 +522,7 @@ QSGMaterialType *QSGHiQSubPixelDistanceFieldTextMaterial::type() const
QSGMaterialShader *QSGHiQSubPixelDistanceFieldTextMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new QSGHiQSubPixelDistanceFieldTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
- else
- return new QSGHiQSubPixelDistanceFieldTextMaterialShader;
-}
-
-
-class QSGLoQSubPixelDistanceFieldTextMaterialShader : public QSGHiQSubPixelDistanceFieldTextMaterialShader
-{
-public:
- QSGLoQSubPixelDistanceFieldTextMaterialShader();
-};
-
-QSGLoQSubPixelDistanceFieldTextMaterialShader::QSGLoQSubPixelDistanceFieldTextMaterialShader()
- : QSGHiQSubPixelDistanceFieldTextMaterialShader()
-{
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/loqsubpixeldistancefieldtext.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/loqsubpixeldistancefieldtext.frag"));
+ return new QSGHiQSubPixelDistanceFieldTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
}
class QSGLoQSubPixelDistanceFieldTextMaterialRhiShader : public QSGHiQSubPixelDistanceFieldTextMaterialRhiShader
@@ -929,10 +552,7 @@ QSGMaterialType *QSGLoQSubPixelDistanceFieldTextMaterial::type() const
QSGMaterialShader *QSGLoQSubPixelDistanceFieldTextMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new QSGLoQSubPixelDistanceFieldTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
- else
- return new QSGLoQSubPixelDistanceFieldTextMaterialShader;
+ return new QSGLoQSubPixelDistanceFieldTextMaterialRhiShader(m_glyph_cache->eightBitFormatIsAlphaSwizzled());
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
index f4477918c0..cc2a887a9c 100644
--- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp
+++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
@@ -40,7 +40,7 @@
#include "qsgrhishadereffectnode_p.h"
#include "qsgdefaultrendercontext_p.h"
#include "qsgrhisupport_p.h"
-#include <qsgmaterialrhishader.h>
+#include <qsgmaterialshader.h>
#include <qsgtextureprovider.h>
#include <private/qsgplaintexture_p.h>
#include <QtGui/private/qshaderdescription_p.h>
@@ -209,7 +209,7 @@ QSGMaterialType *QSGRhiShaderMaterialTypeCache::get(const QShader &vs, const QSh
static QSGRhiShaderMaterialTypeCache shaderMaterialTypeCache;
-class QSGRhiShaderEffectMaterialShader : public QSGMaterialRhiShader
+class QSGRhiShaderEffectMaterialShader : public QSGMaterialShader
{
public:
QSGRhiShaderEffectMaterialShader(const QSGRhiShaderEffectMaterial *material);
@@ -450,7 +450,7 @@ bool QSGRhiShaderEffectMaterialShader::updateGraphicsPipelineState(RenderState &
QSGRhiShaderEffectMaterial::QSGRhiShaderEffectMaterial(QSGRhiShaderEffectNode *node)
: m_node(node)
{
- setFlag(SupportsRhiShader | Blending | RequiresFullMatrix, true); // may be changed in syncMaterial()
+ setFlag(Blending | RequiresFullMatrix, true); // may be changed in syncMaterial()
}
QSGRhiShaderEffectMaterial::~QSGRhiShaderEffectMaterial()
@@ -521,7 +521,6 @@ QSGMaterialType *QSGRhiShaderEffectMaterial::type() const
QSGMaterialShader *QSGRhiShaderEffectMaterial::createShader() const
{
- Q_ASSERT(flags().testFlag(RhiShaderWanted));
return new QSGRhiShaderEffectMaterialShader(this);
}
diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri
index 87146dcac8..d03e79a272 100644
--- a/src/quick/scenegraph/scenegraph.pri
+++ b/src/quick/scenegraph/scenegraph.pri
@@ -7,8 +7,6 @@ HEADERS += \
$$PWD/coreapi/qsgmaterialtype.h \
$$PWD/coreapi/qsgmaterialshader.h \
$$PWD/coreapi/qsgmaterialshader_p.h \
- $$PWD/coreapi/qsgmaterialrhishader.h \
- $$PWD/coreapi/qsgmaterialrhishader_p.h \
$$PWD/coreapi/qsgnode.h \
$$PWD/coreapi/qsgnode_p.h \
$$PWD/coreapi/qsgnodeupdater_p.h \
@@ -27,7 +25,6 @@ SOURCES += \
$$PWD/coreapi/qsggeometry.cpp \
$$PWD/coreapi/qsgmaterial.cpp \
$$PWD/coreapi/qsgmaterialshader.cpp \
- $$PWD/coreapi/qsgmaterialrhishader.cpp \
$$PWD/coreapi/qsgtexture.cpp \
$$PWD/coreapi/qsgnode.cpp \
$$PWD/coreapi/qsgnodeupdater.cpp \
diff --git a/src/quick/scenegraph/scenegraph.qrc b/src/quick/scenegraph/scenegraph.qrc
index e409f07610..ba93c2476c 100644
--- a/src/quick/scenegraph/scenegraph.qrc
+++ b/src/quick/scenegraph/scenegraph.qrc
@@ -1,77 +1,11 @@
<RCC>
<qresource prefix="/qt-project.org/scenegraph">
- <file>shaders/flatcolor.frag</file>
- <file>shaders/flatcolor.vert</file>
- <file>shaders/8bittextmask.frag</file>
- <file>shaders/24bittextmask.frag</file>
- <file>shaders/32bitcolortext.frag</file>
- <file>shaders/opaquetexture.frag</file>
- <file>shaders/opaquetexture.vert</file>
- <file>shaders/outlinedtext.frag</file>
- <file>shaders/outlinedtext.vert</file>
- <file>shaders/smoothcolor.frag</file>
- <file>shaders/smoothcolor.vert</file>
- <file>shaders/smoothtexture.frag</file>
- <file>shaders/smoothtexture.vert</file>
- <file>shaders/styledtext.frag</file>
- <file>shaders/styledtext.vert</file>
- <file>shaders/textmask.frag</file>
- <file>shaders/textmask.vert</file>
- <file>shaders/texture.frag</file>
- <file>shaders/distancefieldoutlinetext.frag</file>
- <file>shaders/distancefieldshiftedtext.frag</file>
- <file>shaders/distancefieldshiftedtext.vert</file>
- <file>shaders/distancefieldtext.frag</file>
- <file>shaders/distancefieldtext.vert</file>
- <file>shaders/hiqsubpixeldistancefieldtext.frag</file>
- <file>shaders/hiqsubpixeldistancefieldtext.vert</file>
- <file>shaders/loqsubpixeldistancefieldtext.frag</file>
- <file>shaders/loqsubpixeldistancefieldtext.vert</file>
- <file>shaders/vertexcolor.frag</file>
- <file>shaders/vertexcolor.vert</file>
- <file>shaders/rendernode.vert</file>
- <file>shaders/rendernode.frag</file>
<file>shaders/stencilclip.frag</file>
<file>shaders/stencilclip.vert</file>
- <file>shaders/8bittextmask_core.frag</file>
- <file>shaders/24bittextmask_core.frag</file>
- <file>shaders/32bitcolortext_core.frag</file>
- <file>shaders/distancefieldoutlinetext_core.frag</file>
- <file>shaders/distancefieldshiftedtext_core.frag</file>
- <file>shaders/distancefieldshiftedtext_core.vert</file>
- <file>shaders/distancefieldtext_core.frag</file>
- <file>shaders/distancefieldtext_core.vert</file>
- <file>shaders/flatcolor_core.frag</file>
- <file>shaders/flatcolor_core.vert</file>
- <file>shaders/hiqsubpixeldistancefieldtext_core.frag</file>
- <file>shaders/hiqsubpixeldistancefieldtext_core.vert</file>
- <file>shaders/loqsubpixeldistancefieldtext_core.frag</file>
- <file>shaders/loqsubpixeldistancefieldtext_core.vert</file>
- <file>shaders/opaquetexture_core.frag</file>
- <file>shaders/opaquetexture_core.vert</file>
- <file>shaders/outlinedtext_core.frag</file>
- <file>shaders/outlinedtext_core.vert</file>
- <file>shaders/rendernode_core.frag</file>
- <file>shaders/rendernode_core.vert</file>
- <file>shaders/smoothcolor_core.frag</file>
- <file>shaders/smoothcolor_core.vert</file>
- <file>shaders/smoothtexture_core.frag</file>
- <file>shaders/smoothtexture_core.vert</file>
<file>shaders/stencilclip_core.frag</file>
<file>shaders/stencilclip_core.vert</file>
- <file>shaders/styledtext_core.frag</file>
- <file>shaders/styledtext_core.vert</file>
- <file>shaders/textmask_core.frag</file>
- <file>shaders/textmask_core.vert</file>
- <file>shaders/texture_core.frag</file>
- <file>shaders/vertexcolor_core.frag</file>
- <file>shaders/vertexcolor_core.vert</file>
<file>shaders/visualization.vert</file>
<file>shaders/visualization.frag</file>
- <file>shaders/sprite.frag</file>
- <file>shaders/sprite.vert</file>
- <file>shaders/sprite_core.frag</file>
- <file>shaders/sprite_core.vert</file>
<file>shaders_ng/vertexcolor.vert.qsb</file>
<file>shaders_ng/vertexcolor.frag.qsb</file>
diff --git a/src/quick/scenegraph/shaders/24bittextmask.frag b/src/quick/scenegraph/shaders/24bittextmask.frag
deleted file mode 100644
index 5c21e202f9..0000000000
--- a/src/quick/scenegraph/shaders/24bittextmask.frag
+++ /dev/null
@@ -1,10 +0,0 @@
-varying highp vec2 sampleCoord;
-
-uniform lowp sampler2D _qt_texture;
-uniform lowp float color; // just the alpha, really...
-
-void main()
-{
- lowp vec4 glyph = texture2D(_qt_texture, sampleCoord);
- gl_FragColor = vec4(glyph.rgb * color, glyph.a);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/24bittextmask_core.frag b/src/quick/scenegraph/shaders/24bittextmask_core.frag
deleted file mode 100644
index 29d1f23017..0000000000
--- a/src/quick/scenegraph/shaders/24bittextmask_core.frag
+++ /dev/null
@@ -1,14 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform float color; // just the alpha, really...
-
-void main()
-{
- vec4 glyph = texture(_qt_texture, sampleCoord);
- fragColor = vec4(glyph.rgb * color, glyph.a);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/32bitcolortext.frag b/src/quick/scenegraph/shaders/32bitcolortext.frag
deleted file mode 100644
index 6fdb6e6aeb..0000000000
--- a/src/quick/scenegraph/shaders/32bitcolortext.frag
+++ /dev/null
@@ -1,9 +0,0 @@
-varying highp vec2 sampleCoord;
-
-uniform sampler2D _qt_texture;
-uniform lowp float color; // just the alpha, really...
-
-void main()
-{
- gl_FragColor = texture2D(_qt_texture, sampleCoord) * color;
-}
diff --git a/src/quick/scenegraph/shaders/32bitcolortext_core.frag b/src/quick/scenegraph/shaders/32bitcolortext_core.frag
deleted file mode 100644
index 010aca97b4..0000000000
--- a/src/quick/scenegraph/shaders/32bitcolortext_core.frag
+++ /dev/null
@@ -1,13 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform float color; // just the alpha, really...
-
-void main()
-{
- fragColor = texture(_qt_texture, sampleCoord) * color;
-}
diff --git a/src/quick/scenegraph/shaders/8bittextmask.frag b/src/quick/scenegraph/shaders/8bittextmask.frag
deleted file mode 100644
index 44ffb279cb..0000000000
--- a/src/quick/scenegraph/shaders/8bittextmask.frag
+++ /dev/null
@@ -1,9 +0,0 @@
-varying highp vec2 sampleCoord;
-
-uniform lowp sampler2D _qt_texture;
-uniform lowp vec4 color;
-
-void main()
-{
- gl_FragColor = color * texture2D(_qt_texture, sampleCoord).a;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/8bittextmask_core.frag b/src/quick/scenegraph/shaders/8bittextmask_core.frag
deleted file mode 100644
index 2d67a4676a..0000000000
--- a/src/quick/scenegraph/shaders/8bittextmask_core.frag
+++ /dev/null
@@ -1,13 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform vec4 color;
-
-void main()
-{
- fragColor = color * texture(_qt_texture, sampleCoord).r;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag b/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag
deleted file mode 100644
index 250ed322a1..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag
+++ /dev/null
@@ -1,16 +0,0 @@
-varying highp vec2 sampleCoord;
-
-uniform sampler2D _qt_texture;
-uniform lowp vec4 color;
-uniform lowp vec4 styleColor;
-uniform mediump float alphaMin;
-uniform mediump float alphaMax;
-uniform mediump float outlineAlphaMax0;
-uniform mediump float outlineAlphaMax1;
-
-void main()
-{
- mediump float d = texture2D(_qt_texture, sampleCoord).a;
- gl_FragColor = mix(styleColor, color, smoothstep(alphaMin, alphaMax, d))
- * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldoutlinetext_core.frag b/src/quick/scenegraph/shaders/distancefieldoutlinetext_core.frag
deleted file mode 100644
index 80fa05ca3c..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldoutlinetext_core.frag
+++ /dev/null
@@ -1,20 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform vec4 color;
-uniform vec4 styleColor;
-uniform float alphaMin;
-uniform float alphaMax;
-uniform float outlineAlphaMax0;
-uniform float outlineAlphaMax1;
-
-void main()
-{
- float d = texture(_qt_texture, sampleCoord).r;
- fragColor = mix(styleColor, color, smoothstep(alphaMin, alphaMax, d))
- * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldshiftedtext.frag b/src/quick/scenegraph/shaders/distancefieldshiftedtext.frag
deleted file mode 100644
index 42fead8713..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldshiftedtext.frag
+++ /dev/null
@@ -1,17 +0,0 @@
-varying highp vec2 sampleCoord;
-varying highp vec2 shiftedSampleCoord;
-
-uniform mediump sampler2D _qt_texture;
-uniform lowp vec4 color;
-uniform lowp vec4 styleColor;
-uniform mediump float alphaMin;
-uniform mediump float alphaMax;
-
-void main()
-{
- highp float a = smoothstep(alphaMin, alphaMax, texture2D(_qt_texture, sampleCoord).a);
- highp vec4 shifted = styleColor * smoothstep(alphaMin,
- alphaMax,
- texture2D(_qt_texture, shiftedSampleCoord).a);
- gl_FragColor = mix(shifted, color, a);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldshiftedtext.vert b/src/quick/scenegraph/shaders/distancefieldshiftedtext.vert
deleted file mode 100644
index 800eadc4f1..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldshiftedtext.vert
+++ /dev/null
@@ -1,17 +0,0 @@
-uniform highp mat4 matrix;
-uniform highp vec2 textureScale;
-
-attribute highp vec4 vCoord;
-attribute highp vec2 tCoord;
-
-uniform highp vec2 shift;
-
-varying highp vec2 sampleCoord;
-varying highp vec2 shiftedSampleCoord;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- shiftedSampleCoord = (tCoord - shift) * textureScale;
- gl_Position = matrix * vCoord;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldshiftedtext_core.frag b/src/quick/scenegraph/shaders/distancefieldshiftedtext_core.frag
deleted file mode 100644
index 3f66965e78..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldshiftedtext_core.frag
+++ /dev/null
@@ -1,20 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-in vec2 shiftedSampleCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform vec4 color;
-uniform vec4 styleColor;
-uniform float alphaMin;
-uniform float alphaMax;
-
-void main()
-{
- float a = smoothstep(alphaMin, alphaMax, texture(_qt_texture, sampleCoord).r);
- vec4 shifted = styleColor * smoothstep(alphaMin, alphaMax,
- texture(_qt_texture, shiftedSampleCoord).r);
- fragColor = mix(shifted, color, a);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldshiftedtext_core.vert b/src/quick/scenegraph/shaders/distancefieldshiftedtext_core.vert
deleted file mode 100644
index b7a3ecc667..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldshiftedtext_core.vert
+++ /dev/null
@@ -1,18 +0,0 @@
-#version 150 core
-
-in vec4 vCoord;
-in vec2 tCoord;
-
-out vec2 sampleCoord;
-out vec2 shiftedSampleCoord;
-
-uniform mat4 matrix;
-uniform vec2 textureScale;
-uniform vec2 shift;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- shiftedSampleCoord = (tCoord - shift) * textureScale;
- gl_Position = matrix * vCoord;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldtext.frag b/src/quick/scenegraph/shaders/distancefieldtext.frag
deleted file mode 100644
index 951fb2a825..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldtext.frag
+++ /dev/null
@@ -1,13 +0,0 @@
-varying highp vec2 sampleCoord;
-
-uniform mediump sampler2D _qt_texture;
-uniform lowp vec4 color;
-uniform mediump float alphaMin;
-uniform mediump float alphaMax;
-
-void main()
-{
- gl_FragColor = color * smoothstep(alphaMin,
- alphaMax,
- texture2D(_qt_texture, sampleCoord).a);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldtext.vert b/src/quick/scenegraph/shaders/distancefieldtext.vert
deleted file mode 100644
index c4963977a5..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldtext.vert
+++ /dev/null
@@ -1,13 +0,0 @@
-uniform highp mat4 matrix;
-uniform highp vec2 textureScale;
-
-attribute highp vec4 vCoord;
-attribute highp vec2 tCoord;
-
-varying highp vec2 sampleCoord;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- gl_Position = matrix * vCoord;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldtext_core.frag b/src/quick/scenegraph/shaders/distancefieldtext_core.frag
deleted file mode 100644
index 9c64a60d3d..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldtext_core.frag
+++ /dev/null
@@ -1,16 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform vec4 color;
-uniform float alphaMin;
-uniform float alphaMax;
-
-void main()
-{
- fragColor = color * smoothstep(alphaMin, alphaMax,
- texture(_qt_texture, sampleCoord).r);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldtext_core.vert b/src/quick/scenegraph/shaders/distancefieldtext_core.vert
deleted file mode 100644
index 7fc693d139..0000000000
--- a/src/quick/scenegraph/shaders/distancefieldtext_core.vert
+++ /dev/null
@@ -1,15 +0,0 @@
-#version 150 core
-
-in vec4 vCoord;
-in vec2 tCoord;
-
-out vec2 sampleCoord;
-
-uniform mat4 matrix;
-uniform vec2 textureScale;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- gl_Position = matrix * vCoord;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/flatcolor.frag b/src/quick/scenegraph/shaders/flatcolor.frag
deleted file mode 100644
index 8c225bf5a4..0000000000
--- a/src/quick/scenegraph/shaders/flatcolor.frag
+++ /dev/null
@@ -1,6 +0,0 @@
-uniform lowp vec4 color;
-
-void main()
-{
- gl_FragColor = color;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/flatcolor.vert b/src/quick/scenegraph/shaders/flatcolor.vert
deleted file mode 100644
index a61de97f85..0000000000
--- a/src/quick/scenegraph/shaders/flatcolor.vert
+++ /dev/null
@@ -1,7 +0,0 @@
-attribute highp vec4 vCoord;
-uniform highp mat4 matrix;
-
-void main()
-{
- gl_Position = matrix * vCoord;
-}
diff --git a/src/quick/scenegraph/shaders/flatcolor_core.frag b/src/quick/scenegraph/shaders/flatcolor_core.frag
deleted file mode 100644
index 23a957ad7b..0000000000
--- a/src/quick/scenegraph/shaders/flatcolor_core.frag
+++ /dev/null
@@ -1,10 +0,0 @@
-#version 150 core
-
-out vec4 fragColor;
-
-uniform vec4 color;
-
-void main()
-{
- fragColor = color;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/flatcolor_core.vert b/src/quick/scenegraph/shaders/flatcolor_core.vert
deleted file mode 100644
index e33c591b95..0000000000
--- a/src/quick/scenegraph/shaders/flatcolor_core.vert
+++ /dev/null
@@ -1,10 +0,0 @@
-#version 150 core
-
-in vec4 vCoord;
-
-uniform mat4 matrix;
-
-void main()
-{
- gl_Position = matrix * vCoord;
-}
diff --git a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag b/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag
deleted file mode 100644
index 9b65e5f79b..0000000000
--- a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag
+++ /dev/null
@@ -1,58 +0,0 @@
-varying highp vec2 sampleCoord;
-varying highp vec3 sampleFarLeft;
-varying highp vec3 sampleNearLeft;
-varying highp vec3 sampleNearRight;
-varying highp vec3 sampleFarRight;
-
-uniform sampler2D _qt_texture;
-uniform lowp vec4 color;
-uniform mediump float alphaMin;
-uniform mediump float alphaMax;
-
-void main()
-{
- highp vec4 n;
- n.x = texture2DProj(_qt_texture, sampleFarLeft).a;
- n.y = texture2DProj(_qt_texture, sampleNearLeft).a;
- highp float c = texture2D(_qt_texture, sampleCoord).a;
- n.z = texture2DProj(_qt_texture, sampleNearRight).a;
- n.w = texture2DProj(_qt_texture, sampleFarRight).a;
-#if 0
- // Blurrier, faster.
- n = smoothstep(alphaMin, alphaMax, n);
- c = smoothstep(alphaMin, alphaMax, c);
-#else
- // Sharper, slower.
- highp vec2 d = min(abs(n.yw - n.xz) * 2., 0.67);
- highp vec2 lo = mix(vec2(alphaMin), vec2(0.5), d);
- highp vec2 hi = mix(vec2(alphaMax), vec2(0.5), d);
- n = smoothstep(lo.xxyy, hi.xxyy, n);
- c = smoothstep(lo.x + lo.y, hi.x + hi.y, 2. * c);
-#endif
- gl_FragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w;
-}
-
-/*
-#extension GL_OES_standard_derivatives: enable
-
-varying highp vec2 sampleCoord;
-
-uniform sampler2D _qt_texture;
-uniform lowp vec4 color;
-uniform highp float alphaMin;
-uniform highp float alphaMax;
-
-void main()
-{
- highp vec2 delta = dFdx(sampleCoord);
- highp vec4 n;
- n.x = texture2D(_qt_texture, sampleCoord - 0.667 * delta).a;
- n.y = texture2D(_qt_texture, sampleCoord - 0.333 * delta).a;
- highp float c = texture2D(_qt_texture, sampleCoord).a;
- n.z = texture2D(_qt_texture, sampleCoord + 0.333 * delta).a;
- n.w = texture2D(_qt_texture, sampleCoord + 0.667 * delta).a;
- n = smoothstep(alphaMin, alphaMax, n);
- c = smoothstep(alphaMin, alphaMax, c);
- gl_FragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w;
-};
-*/ \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert b/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert
deleted file mode 100644
index 62768e88e1..0000000000
--- a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert
+++ /dev/null
@@ -1,34 +0,0 @@
-uniform highp mat4 matrix;
-uniform highp vec2 textureScale;
-uniform highp float fontScale;
-uniform highp vec4 vecDelta;
-
-attribute highp vec4 vCoord;
-attribute highp vec2 tCoord;
-
-varying highp vec2 sampleCoord;
-varying highp vec3 sampleFarLeft;
-varying highp vec3 sampleNearLeft;
-varying highp vec3 sampleNearRight;
-varying highp vec3 sampleFarRight;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- gl_Position = matrix * vCoord;
-
- // Calculate neighbor pixel position in item space.
- highp vec3 wDelta = gl_Position.w * vecDelta.xyw;
- highp vec3 farLeft = vCoord.xyw - 0.667 * wDelta;
- highp vec3 nearLeft = vCoord.xyw - 0.333 * wDelta;
- highp vec3 nearRight = vCoord.xyw + 0.333 * wDelta;
- highp vec3 farRight = vCoord.xyw + 0.667 * wDelta;
-
- // Calculate neighbor texture coordinate.
- highp vec2 scale = textureScale / fontScale;
- highp vec2 base = sampleCoord - scale * vCoord.xy;
- sampleFarLeft = vec3(base * farLeft.z + scale * farLeft.xy, farLeft.z);
- sampleNearLeft = vec3(base * nearLeft.z + scale * nearLeft.xy, nearLeft.z);
- sampleNearRight = vec3(base * nearRight.z + scale * nearRight.xy, nearRight.z);
- sampleFarRight = vec3(base * farRight.z + scale * farRight.xy, farRight.z);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext_core.frag b/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext_core.frag
deleted file mode 100644
index cf6ba2b8d9..0000000000
--- a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext_core.frag
+++ /dev/null
@@ -1,32 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-in vec3 sampleFarLeft;
-in vec3 sampleNearLeft;
-in vec3 sampleNearRight;
-in vec3 sampleFarRight;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform vec4 color;
-uniform float alphaMin;
-uniform float alphaMax;
-
-void main()
-{
- vec4 n;
- n.x = textureProj(_qt_texture, sampleFarLeft).r;
- n.y = textureProj(_qt_texture, sampleNearLeft).r;
- float c = texture(_qt_texture, sampleCoord).r;
- n.z = textureProj(_qt_texture, sampleNearRight).r;
- n.w = textureProj(_qt_texture, sampleFarRight).r;
-
- vec2 d = min(abs(n.yw - n.xz) * 2., 0.67);
- vec2 lo = mix(vec2(alphaMin), vec2(0.5), d);
- vec2 hi = mix(vec2(alphaMax), vec2(0.5), d);
- n = smoothstep(lo.xxyy, hi.xxyy, n);
- c = smoothstep(lo.x + lo.y, hi.x + hi.y, 2. * c);
-
- fragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext_core.vert b/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext_core.vert
deleted file mode 100644
index 936f74725b..0000000000
--- a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext_core.vert
+++ /dev/null
@@ -1,36 +0,0 @@
-#version 150 core
-
-in vec4 vCoord;
-in vec2 tCoord;
-
-out vec2 sampleCoord;
-out vec3 sampleFarLeft;
-out vec3 sampleNearLeft;
-out vec3 sampleNearRight;
-out vec3 sampleFarRight;
-
-uniform mat4 matrix;
-uniform vec2 textureScale;
-uniform float fontScale;
-uniform vec4 vecDelta;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- gl_Position = matrix * vCoord;
-
- // Calculate neighbor pixel position in item space.
- vec3 wDelta = gl_Position.w * vecDelta.xyw;
- vec3 farLeft = vCoord.xyw - 0.667 * wDelta;
- vec3 nearLeft = vCoord.xyw - 0.333 * wDelta;
- vec3 nearRight = vCoord.xyw + 0.333 * wDelta;
- vec3 farRight = vCoord.xyw + 0.667 * wDelta;
-
- // Calculate neighbor texture coordinate.
- vec2 scale = textureScale / fontScale;
- vec2 base = sampleCoord - scale * vCoord.xy;
- sampleFarLeft = vec3(base * farLeft.z + scale * farLeft.xy, farLeft.z);
- sampleNearLeft = vec3(base * nearLeft.z + scale * nearLeft.xy, nearLeft.z);
- sampleNearRight = vec3(base * nearRight.z + scale * nearRight.xy, nearRight.z);
- sampleFarRight = vec3(base * farRight.z + scale * farRight.xy, farRight.z);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.frag b/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.frag
deleted file mode 100644
index 61b6c8dd9a..0000000000
--- a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.frag
+++ /dev/null
@@ -1,17 +0,0 @@
-varying highp vec3 sampleNearLeft;
-varying highp vec3 sampleNearRight;
-
-uniform sampler2D _qt_texture;
-uniform lowp vec4 color;
-uniform mediump float alphaMin;
-uniform mediump float alphaMax;
-
-void main()
-{
- highp vec2 n;
- n.x = texture2DProj(_qt_texture, sampleNearLeft).a;
- n.y = texture2DProj(_qt_texture, sampleNearRight).a;
- n = smoothstep(alphaMin, alphaMax, n);
- highp float c = 0.5 * (n.x + n.y);
- gl_FragColor = vec4(n.x, c, n.y, c) * color.w;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.vert b/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.vert
deleted file mode 100644
index 33cb7efb19..0000000000
--- a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.vert
+++ /dev/null
@@ -1,27 +0,0 @@
-uniform highp mat4 matrix;
-uniform highp vec2 textureScale;
-uniform highp float fontScale;
-uniform highp vec4 vecDelta;
-
-attribute highp vec4 vCoord;
-attribute highp vec2 tCoord;
-
-varying highp vec3 sampleNearLeft;
-varying highp vec3 sampleNearRight;
-
-void main()
-{
- highp vec2 sampleCoord = tCoord * textureScale;
- gl_Position = matrix * vCoord;
-
- // Calculate neighbor pixel position in item space.
- highp vec3 wDelta = gl_Position.w * vecDelta.xyw;
- highp vec3 nearLeft = vCoord.xyw - 0.25 * wDelta;
- highp vec3 nearRight = vCoord.xyw + 0.25 * wDelta;
-
- // Calculate neighbor texture coordinate.
- highp vec2 scale = textureScale / fontScale;
- highp vec2 base = sampleCoord - scale * vCoord.xy;
- sampleNearLeft = vec3(base * nearLeft.z + scale * nearLeft.xy, nearLeft.z);
- sampleNearRight = vec3(base * nearRight.z + scale * nearRight.xy, nearRight.z);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext_core.frag b/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext_core.frag
deleted file mode 100644
index 2dd588d307..0000000000
--- a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext_core.frag
+++ /dev/null
@@ -1,21 +0,0 @@
-#version 150 core
-
-in vec3 sampleNearLeft;
-in vec3 sampleNearRight;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform vec4 color;
-uniform float alphaMin;
-uniform float alphaMax;
-
-void main()
-{
- vec2 n;
- n.x = textureProj(_qt_texture, sampleNearLeft).r;
- n.y = textureProj(_qt_texture, sampleNearRight).r;
- n = smoothstep(alphaMin, alphaMax, n);
- float c = 0.5 * (n.x + n.y);
- fragColor = vec4(n.x, c, n.y, c) * color.w;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext_core.vert b/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext_core.vert
deleted file mode 100644
index b887a70001..0000000000
--- a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext_core.vert
+++ /dev/null
@@ -1,29 +0,0 @@
-#version 150 core
-
-in vec4 vCoord;
-in vec2 tCoord;
-
-out vec3 sampleNearLeft;
-out vec3 sampleNearRight;
-
-uniform mat4 matrix;
-uniform vec2 textureScale;
-uniform float fontScale;
-uniform vec4 vecDelta;
-
-void main()
-{
- vec2 sampleCoord = tCoord * textureScale;
- gl_Position = matrix * vCoord;
-
- // Calculate neighbor pixel position in item space.
- vec3 wDelta = gl_Position.w * vecDelta.xyw;
- vec3 nearLeft = vCoord.xyw - 0.25 * wDelta;
- vec3 nearRight = vCoord.xyw + 0.25 * wDelta;
-
- // Calculate neighbor texture coordinate.
- vec2 scale = textureScale / fontScale;
- vec2 base = sampleCoord - scale * vCoord.xy;
- sampleNearLeft = vec3(base * nearLeft.z + scale * nearLeft.xy, nearLeft.z);
- sampleNearRight = vec3(base * nearRight.z + scale * nearRight.xy, nearRight.z);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/opaquetexture.frag b/src/quick/scenegraph/shaders/opaquetexture.frag
deleted file mode 100644
index b7e07de385..0000000000
--- a/src/quick/scenegraph/shaders/opaquetexture.frag
+++ /dev/null
@@ -1,8 +0,0 @@
-varying highp vec2 qt_TexCoord;
-
-uniform sampler2D qt_Texture;
-
-void main()
-{
- gl_FragColor = texture2D(qt_Texture, qt_TexCoord);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/opaquetexture.vert b/src/quick/scenegraph/shaders/opaquetexture.vert
deleted file mode 100644
index 32cf02df25..0000000000
--- a/src/quick/scenegraph/shaders/opaquetexture.vert
+++ /dev/null
@@ -1,12 +0,0 @@
-uniform highp mat4 qt_Matrix;
-
-attribute highp vec4 qt_VertexPosition;
-attribute highp vec2 qt_VertexTexCoord;
-
-varying highp vec2 qt_TexCoord;
-
-void main()
-{
- qt_TexCoord = qt_VertexTexCoord;
- gl_Position = qt_Matrix * qt_VertexPosition;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/opaquetexture_core.frag b/src/quick/scenegraph/shaders/opaquetexture_core.frag
deleted file mode 100644
index 5f30e68677..0000000000
--- a/src/quick/scenegraph/shaders/opaquetexture_core.frag
+++ /dev/null
@@ -1,12 +0,0 @@
-#version 150 core
-
-in vec2 qt_TexCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D qt_Texture;
-
-void main()
-{
- fragColor = texture(qt_Texture, qt_TexCoord);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/opaquetexture_core.vert b/src/quick/scenegraph/shaders/opaquetexture_core.vert
deleted file mode 100644
index 419b1a825c..0000000000
--- a/src/quick/scenegraph/shaders/opaquetexture_core.vert
+++ /dev/null
@@ -1,14 +0,0 @@
-#version 150 core
-
-uniform mat4 qt_Matrix;
-
-in vec4 qt_VertexPosition;
-in vec2 qt_VertexTexCoord;
-
-out vec2 qt_TexCoord;
-
-void main()
-{
- qt_TexCoord = qt_VertexTexCoord;
- gl_Position = qt_Matrix * qt_VertexPosition;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/outlinedtext.frag b/src/quick/scenegraph/shaders/outlinedtext.frag
deleted file mode 100644
index b3e5475d5d..0000000000
--- a/src/quick/scenegraph/shaders/outlinedtext.frag
+++ /dev/null
@@ -1,21 +0,0 @@
-varying highp vec2 sampleCoord;
-varying highp vec2 sCoordUp;
-varying highp vec2 sCoordDown;
-varying highp vec2 sCoordLeft;
-varying highp vec2 sCoordRight;
-
-uniform sampler2D _qt_texture;
-uniform lowp vec4 color;
-uniform lowp vec4 styleColor;
-
-void main()
-{
- lowp float glyph = texture2D(_qt_texture, sampleCoord).a;
- lowp float outline = clamp(clamp(texture2D(_qt_texture, sCoordUp).a +
- texture2D(_qt_texture, sCoordDown).a +
- texture2D(_qt_texture, sCoordLeft).a +
- texture2D(_qt_texture, sCoordRight).a,
- 0.0, 1.0) - glyph,
- 0.0, 1.0);
- gl_FragColor = outline * styleColor + glyph * color;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/outlinedtext.vert b/src/quick/scenegraph/shaders/outlinedtext.vert
deleted file mode 100644
index 9df832de3c..0000000000
--- a/src/quick/scenegraph/shaders/outlinedtext.vert
+++ /dev/null
@@ -1,24 +0,0 @@
-uniform highp mat4 matrix;
-uniform highp vec2 textureScale;
-uniform highp vec2 shift;
-uniform highp float dpr;
-
-attribute highp vec4 vCoord;
-attribute highp vec2 tCoord;
-
-varying highp vec2 sampleCoord;
-varying highp vec2 sCoordUp;
-varying highp vec2 sCoordDown;
-varying highp vec2 sCoordLeft;
-varying highp vec2 sCoordRight;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- sCoordUp = (tCoord - vec2(0.0, -1.0)) * textureScale;
- sCoordDown = (tCoord - vec2(0.0, 1.0)) * textureScale;
- sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * textureScale;
- sCoordRight = (tCoord - vec2(1.0, 0.0)) * textureScale;
- vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr;
- gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/outlinedtext_core.frag b/src/quick/scenegraph/shaders/outlinedtext_core.frag
deleted file mode 100644
index e19c8937f9..0000000000
--- a/src/quick/scenegraph/shaders/outlinedtext_core.frag
+++ /dev/null
@@ -1,25 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-in vec2 sCoordUp;
-in vec2 sCoordDown;
-in vec2 sCoordLeft;
-in vec2 sCoordRight;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform vec4 color;
-uniform vec4 styleColor;
-
-void main()
-{
- float glyph = texture(_qt_texture, sampleCoord).r;
- float outline = clamp(clamp(texture(_qt_texture, sCoordUp).r +
- texture(_qt_texture, sCoordDown).r +
- texture(_qt_texture, sCoordLeft).r +
- texture(_qt_texture, sCoordRight).r,
- 0.0, 1.0) - glyph,
- 0.0, 1.0);
- fragColor = outline * styleColor + glyph * color;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/outlinedtext_core.vert b/src/quick/scenegraph/shaders/outlinedtext_core.vert
deleted file mode 100644
index a854355460..0000000000
--- a/src/quick/scenegraph/shaders/outlinedtext_core.vert
+++ /dev/null
@@ -1,26 +0,0 @@
-#version 150 core
-
-in vec4 vCoord;
-in vec2 tCoord;
-
-out vec2 sampleCoord;
-out vec2 sCoordUp;
-out vec2 sCoordDown;
-out vec2 sCoordLeft;
-out vec2 sCoordRight;
-
-uniform mat4 matrix;
-uniform vec2 textureScale;
-uniform vec2 shift;
-uniform float dpr;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- sCoordUp = (tCoord - vec2(0.0, -1.0)) * textureScale;
- sCoordDown = (tCoord - vec2(0.0, 1.0)) * textureScale;
- sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * textureScale;
- sCoordRight = (tCoord - vec2(1.0, 0.0)) * textureScale;
- vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr;
- gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/rendernode.frag b/src/quick/scenegraph/shaders/rendernode.frag
deleted file mode 100644
index b4e9b0209c..0000000000
--- a/src/quick/scenegraph/shaders/rendernode.frag
+++ /dev/null
@@ -1,8 +0,0 @@
-uniform lowp sampler2D tex;
-
-varying highp vec2 t;
-
-void main()
-{
- gl_FragColor = texture2D(tex, t);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/rendernode.vert b/src/quick/scenegraph/shaders/rendernode.vert
deleted file mode 100644
index fbfe9ef8ae..0000000000
--- a/src/quick/scenegraph/shaders/rendernode.vert
+++ /dev/null
@@ -1,10 +0,0 @@
-attribute highp vec4 av;
-attribute highp vec2 at;
-
-varying highp vec2 t;
-
-void main()
-{
- gl_Position = av;
- t = at;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/rendernode_core.frag b/src/quick/scenegraph/shaders/rendernode_core.frag
deleted file mode 100644
index b29301b058..0000000000
--- a/src/quick/scenegraph/shaders/rendernode_core.frag
+++ /dev/null
@@ -1,12 +0,0 @@
-#version 150 core
-
-uniform sampler2D tex;
-
-in vec2 t;
-
-out vec4 fragColor;
-
-void main()
-{
- fragColor = texture(tex, t);
-}
diff --git a/src/quick/scenegraph/shaders/rendernode_core.vert b/src/quick/scenegraph/shaders/rendernode_core.vert
deleted file mode 100644
index a76d519a5a..0000000000
--- a/src/quick/scenegraph/shaders/rendernode_core.vert
+++ /dev/null
@@ -1,12 +0,0 @@
-#version 150 core
-
-in vec4 av;
-in vec2 at;
-
-out vec2 t;
-
-void main()
-{
- gl_Position = av;
- t = at;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothcolor.frag b/src/quick/scenegraph/shaders/smoothcolor.frag
deleted file mode 100644
index 71de9dbfc2..0000000000
--- a/src/quick/scenegraph/shaders/smoothcolor.frag
+++ /dev/null
@@ -1,6 +0,0 @@
-varying lowp vec4 color;
-
-void main()
-{
- gl_FragColor = color;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothcolor.vert b/src/quick/scenegraph/shaders/smoothcolor.vert
deleted file mode 100644
index df70fea92a..0000000000
--- a/src/quick/scenegraph/shaders/smoothcolor.vert
+++ /dev/null
@@ -1,45 +0,0 @@
-uniform highp vec2 pixelSize;
-uniform highp mat4 matrix;
-uniform lowp float opacity;
-
-attribute highp vec4 vertex;
-attribute lowp vec4 vertexColor;
-attribute highp vec2 vertexOffset;
-
-varying lowp vec4 color;
-
-void main()
-{
- highp vec4 pos = matrix * vertex;
- gl_Position = pos;
-
- if (vertexOffset.x != 0.) {
- highp vec4 delta = matrix[0] * vertexOffset.x;
- highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
- dir -= ndir * delta.w * pos.w;
- highp float numerator = dot(dir, ndir * pos.w * pos.w);
- highp float scale = 0.0;
- if (numerator < 0.0)
- scale = 1.0;
- else
- scale = min(1.0, numerator / dot(dir, dir));
- gl_Position += scale * delta;
- }
-
- if (vertexOffset.y != 0.) {
- highp vec4 delta = matrix[1] * vertexOffset.y;
- highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
- dir -= ndir * delta.w * pos.w;
- highp float numerator = dot(dir, ndir * pos.w * pos.w);
- highp float scale = 0.0;
- if (numerator < 0.0)
- scale = 1.0;
- else
- scale = min(1.0, numerator / dot(dir, dir));
- gl_Position += scale * delta;
- }
-
- color = vertexColor * opacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothcolor_core.frag b/src/quick/scenegraph/shaders/smoothcolor_core.frag
deleted file mode 100644
index 84533c2b40..0000000000
--- a/src/quick/scenegraph/shaders/smoothcolor_core.frag
+++ /dev/null
@@ -1,10 +0,0 @@
-#version 150 core
-
-in vec4 color;
-
-out vec4 fragColor;
-
-void main()
-{
- fragColor = color;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothcolor_core.vert b/src/quick/scenegraph/shaders/smoothcolor_core.vert
deleted file mode 100644
index 1eed751ccd..0000000000
--- a/src/quick/scenegraph/shaders/smoothcolor_core.vert
+++ /dev/null
@@ -1,47 +0,0 @@
-#version 150 core
-
-in vec4 vertex;
-in vec4 vertexColor;
-in vec2 vertexOffset;
-
-out vec4 color;
-
-uniform vec2 pixelSize;
-uniform mat4 matrix;
-uniform float opacity;
-
-void main()
-{
- vec4 pos = matrix * vertex;
- gl_Position = pos;
-
- if (vertexOffset.x != 0.) {
- vec4 delta = matrix[0] * vertexOffset.x;
- vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
- dir -= ndir * delta.w * pos.w;
- float numerator = dot(dir, ndir * pos.w * pos.w);
- float scale = 0.0;
- if (numerator < 0.0)
- scale = 1.0;
- else
- scale = min(1.0, numerator / dot(dir, dir));
- gl_Position += scale * delta;
- }
-
- if (vertexOffset.y != 0.) {
- vec4 delta = matrix[1] * vertexOffset.y;
- vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
- dir -= ndir * delta.w * pos.w;
- float numerator = dot(dir, ndir * pos.w * pos.w);
- float scale = 0.0;
- if (numerator < 0.0)
- scale = 1.0;
- else
- scale = min(1.0, numerator / dot(dir, dir));
- gl_Position += scale * delta;
- }
-
- color = vertexColor * opacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothtexture.frag b/src/quick/scenegraph/shaders/smoothtexture.frag
deleted file mode 100644
index e4f6359f3d..0000000000
--- a/src/quick/scenegraph/shaders/smoothtexture.frag
+++ /dev/null
@@ -1,9 +0,0 @@
-uniform sampler2D qt_Texture;
-
-varying highp vec2 texCoord;
-varying lowp float vertexOpacity;
-
-void main()
-{
- gl_FragColor = texture2D(qt_Texture, texCoord) * vertexOpacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothtexture.vert b/src/quick/scenegraph/shaders/smoothtexture.vert
deleted file mode 100644
index 900fbc6a72..0000000000
--- a/src/quick/scenegraph/shaders/smoothtexture.vert
+++ /dev/null
@@ -1,55 +0,0 @@
-uniform highp vec2 pixelSize;
-uniform highp mat4 qt_Matrix;
-uniform lowp float opacity;
-
-attribute highp vec4 vertex;
-attribute highp vec2 multiTexCoord;
-attribute highp vec2 vertexOffset;
-attribute highp vec2 texCoordOffset;
-
-varying highp vec2 texCoord;
-varying lowp float vertexOpacity;
-
-void main()
-{
- highp vec4 pos = qt_Matrix * vertex;
- gl_Position = pos;
- texCoord = multiTexCoord;
-
- if (vertexOffset.x != 0.) {
- highp vec4 delta = qt_Matrix[0] * vertexOffset.x;
- highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
- dir -= ndir * delta.w * pos.w;
- highp float numerator = dot(dir, ndir * pos.w * pos.w);
- highp float scale = 0.0;
- if (numerator < 0.0)
- scale = 1.0;
- else
- scale = min(1.0, numerator / dot(dir, dir));
- gl_Position += scale * delta;
- texCoord.x += scale * texCoordOffset.x;
- }
-
- if (vertexOffset.y != 0.) {
- highp vec4 delta = qt_Matrix[1] * vertexOffset.y;
- highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
- dir -= ndir * delta.w * pos.w;
- highp float numerator = dot(dir, ndir * pos.w * pos.w);
- highp float scale = 0.0;
- if (numerator < 0.0)
- scale = 1.0;
- else
- scale = min(1.0, numerator / dot(dir, dir));
- gl_Position += scale * delta;
- texCoord.y += scale * texCoordOffset.y;
- }
-
- bool onEdge = any(notEqual(vertexOffset, vec2(0.)));
- bool outerEdge = all(equal(texCoordOffset, vec2(0.)));
- if (onEdge && outerEdge)
- vertexOpacity = 0.;
- else
- vertexOpacity = opacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothtexture_core.frag b/src/quick/scenegraph/shaders/smoothtexture_core.frag
deleted file mode 100644
index 8a9aefd4c8..0000000000
--- a/src/quick/scenegraph/shaders/smoothtexture_core.frag
+++ /dev/null
@@ -1,13 +0,0 @@
-#version 150 core
-
-in vec2 texCoord;
-in float vertexOpacity;
-
-out vec4 fragColor;
-
-uniform sampler2D qt_Texture;
-
-void main()
-{
- fragColor = texture(qt_Texture, texCoord) * vertexOpacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothtexture_core.vert b/src/quick/scenegraph/shaders/smoothtexture_core.vert
deleted file mode 100644
index 6821398e57..0000000000
--- a/src/quick/scenegraph/shaders/smoothtexture_core.vert
+++ /dev/null
@@ -1,57 +0,0 @@
-#version 150 core
-
-in vec4 vertex;
-in vec2 multiTexCoord;
-in vec2 vertexOffset;
-in vec2 texCoordOffset;
-
-out vec2 texCoord;
-out float vertexOpacity;
-
-uniform vec2 pixelSize;
-uniform mat4 qt_Matrix;
-uniform float opacity;
-
-void main()
-{
- vec4 pos = qt_Matrix * vertex;
- gl_Position = pos;
- texCoord = multiTexCoord;
-
- if (vertexOffset.x != 0.) {
- vec4 delta = qt_Matrix[0] * vertexOffset.x;
- vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
- dir -= ndir * delta.w * pos.w;
- float numerator = dot(dir, ndir * pos.w * pos.w);
- float scale = 0.0;
- if (numerator < 0.0)
- scale = 1.0;
- else
- scale = min(1.0, numerator / dot(dir, dir));
- gl_Position += scale * delta;
- texCoord.x += scale * texCoordOffset.x;
- }
-
- if (vertexOffset.y != 0.) {
- vec4 delta = qt_Matrix[1] * vertexOffset.y;
- vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
- vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
- dir -= ndir * delta.w * pos.w;
- float numerator = dot(dir, ndir * pos.w * pos.w);
- float scale = 0.0;
- if (numerator < 0.0)
- scale = 1.0;
- else
- scale = min(1.0, numerator / dot(dir, dir));
- gl_Position += scale * delta;
- texCoord.y += scale * texCoordOffset.y;
- }
-
- bool onEdge = any(notEqual(vertexOffset, vec2(0.)));
- bool outerEdge = all(equal(texCoordOffset, vec2(0.)));
- if (onEdge && outerEdge)
- vertexOpacity = 0.;
- else
- vertexOpacity = opacity;
-}
diff --git a/src/quick/scenegraph/shaders/sprite.frag b/src/quick/scenegraph/shaders/sprite.frag
deleted file mode 100644
index e1fcb0f006..0000000000
--- a/src/quick/scenegraph/shaders/sprite.frag
+++ /dev/null
@@ -1,12 +0,0 @@
-uniform sampler2D _qt_texture;
-uniform lowp float qt_Opacity;
-
-varying highp vec4 fTexS;
-varying lowp float progress;
-
-void main()
-{
- gl_FragColor = mix(texture2D(_qt_texture, fTexS.xy),
- texture2D(_qt_texture, fTexS.zw),
- progress) * qt_Opacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/sprite.vert b/src/quick/scenegraph/shaders/sprite.vert
deleted file mode 100644
index fc826f60b4..0000000000
--- a/src/quick/scenegraph/shaders/sprite.vert
+++ /dev/null
@@ -1,23 +0,0 @@
-attribute highp vec2 vPos;
-attribute highp vec2 vTex;
-
-uniform highp vec3 animData;// w,h(premultiplied of anim), interpolation progress
-uniform highp vec4 animPos;//x,y, x,y (two frames for interpolation)
-
-uniform highp mat4 qt_Matrix;
-
-varying highp vec4 fTexS;
-varying lowp float progress;
-
-void main()
-{
- progress = animData.z;
-
- // Calculate frame location in texture
- fTexS.xy = animPos.xy + vTex.xy * animData.xy;
-
- // Next frame is also passed, for interpolation
- fTexS.zw = animPos.zw + vTex.xy * animData.xy;
-
- gl_Position = qt_Matrix * vec4(vPos.x, vPos.y, 0, 1);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/sprite_core.frag b/src/quick/scenegraph/shaders/sprite_core.frag
deleted file mode 100644
index c1087a8754..0000000000
--- a/src/quick/scenegraph/shaders/sprite_core.frag
+++ /dev/null
@@ -1,16 +0,0 @@
-#version 150 core
-
-in vec4 fTexS;
-in float progress;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform float qt_Opacity;
-
-void main()
-{
- fragColor = mix(texture(_qt_texture, fTexS.xy),
- texture(_qt_texture, fTexS.zw),
- progress) * qt_Opacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/sprite_core.vert b/src/quick/scenegraph/shaders/sprite_core.vert
deleted file mode 100644
index 5027bf03fc..0000000000
--- a/src/quick/scenegraph/shaders/sprite_core.vert
+++ /dev/null
@@ -1,24 +0,0 @@
-#version 150 core
-
-in vec2 vPos;
-in vec2 vTex;
-
-out vec4 fTexS;
-out float progress;
-
-uniform vec3 animData; // w,h(premultiplied of anim), interpolation progress
-uniform vec4 animPos; // x,y, x,y (two frames for interpolation)
-uniform mat4 qt_Matrix;
-
-void main()
-{
- progress = animData.z;
-
- // Calculate frame location in texture
- fTexS.xy = animPos.xy + vTex.xy * animData.xy;
-
- // Next frame is also passed, for interpolation
- fTexS.zw = animPos.zw + vTex.xy * animData.xy;
-
- gl_Position = qt_Matrix * vec4(vPos.x, vPos.y, 0, 1);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/styledtext.frag b/src/quick/scenegraph/shaders/styledtext.frag
deleted file mode 100644
index 662dbef2fc..0000000000
--- a/src/quick/scenegraph/shaders/styledtext.frag
+++ /dev/null
@@ -1,14 +0,0 @@
-varying highp vec2 sampleCoord;
-varying highp vec2 shiftedSampleCoord;
-
-uniform sampler2D _qt_texture;
-uniform lowp vec4 color;
-uniform lowp vec4 styleColor;
-
-void main()
-{
- lowp float glyph = texture2D(_qt_texture, sampleCoord).a;
- lowp float style = clamp(texture2D(_qt_texture, shiftedSampleCoord).a - glyph,
- 0.0, 1.0);
- gl_FragColor = style * styleColor + glyph * color;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/styledtext.vert b/src/quick/scenegraph/shaders/styledtext.vert
deleted file mode 100644
index 29c9902609..0000000000
--- a/src/quick/scenegraph/shaders/styledtext.vert
+++ /dev/null
@@ -1,18 +0,0 @@
-uniform highp mat4 matrix;
-uniform highp vec2 textureScale;
-uniform highp vec2 shift;
-uniform highp float dpr;
-
-attribute highp vec4 vCoord;
-attribute highp vec2 tCoord;
-
-varying highp vec2 sampleCoord;
-varying highp vec2 shiftedSampleCoord;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- shiftedSampleCoord = (tCoord - shift) * textureScale;
- vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr;
- gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
-}
diff --git a/src/quick/scenegraph/shaders/styledtext_core.frag b/src/quick/scenegraph/shaders/styledtext_core.frag
deleted file mode 100644
index 5480e95a42..0000000000
--- a/src/quick/scenegraph/shaders/styledtext_core.frag
+++ /dev/null
@@ -1,18 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-in vec2 shiftedSampleCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform vec4 color;
-uniform vec4 styleColor;
-
-void main()
-{
- float glyph = texture(_qt_texture, sampleCoord).r;
- float style = clamp(texture(_qt_texture, shiftedSampleCoord).r - glyph,
- 0.0, 1.0);
- fragColor = style * styleColor + glyph * color;
-}
diff --git a/src/quick/scenegraph/shaders/styledtext_core.vert b/src/quick/scenegraph/shaders/styledtext_core.vert
deleted file mode 100644
index 04a0e88da8..0000000000
--- a/src/quick/scenegraph/shaders/styledtext_core.vert
+++ /dev/null
@@ -1,20 +0,0 @@
-#version 150 core
-
-in vec4 vCoord;
-in vec2 tCoord;
-
-out vec2 sampleCoord;
-out vec2 shiftedSampleCoord;
-
-uniform mat4 matrix;
-uniform vec2 textureScale;
-uniform vec2 shift;
-uniform float dpr;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- shiftedSampleCoord = (tCoord - shift) * textureScale;
- vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr;
- gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
-}
diff --git a/src/quick/scenegraph/shaders/textmask.frag b/src/quick/scenegraph/shaders/textmask.frag
deleted file mode 100644
index 7715688ecc..0000000000
--- a/src/quick/scenegraph/shaders/textmask.frag
+++ /dev/null
@@ -1,10 +0,0 @@
-varying highp vec2 sampleCoord;
-
-uniform sampler2D _qt_texture;
-uniform lowp vec4 color;
-
-void main()
-{
- lowp vec4 glyph = texture2D(_qt_texture, sampleCoord);
- gl_FragColor = vec4(glyph.rgb * color.a, glyph.a);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/textmask.vert b/src/quick/scenegraph/shaders/textmask.vert
deleted file mode 100644
index 1692159d2c..0000000000
--- a/src/quick/scenegraph/shaders/textmask.vert
+++ /dev/null
@@ -1,15 +0,0 @@
-uniform highp mat4 matrix;
-uniform highp vec2 textureScale;
-uniform highp float dpr;
-
-attribute highp vec4 vCoord;
-attribute highp vec2 tCoord;
-
-varying highp vec2 sampleCoord;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr;
- gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
-}
diff --git a/src/quick/scenegraph/shaders/textmask_core.frag b/src/quick/scenegraph/shaders/textmask_core.frag
deleted file mode 100644
index 17dda53c97..0000000000
--- a/src/quick/scenegraph/shaders/textmask_core.frag
+++ /dev/null
@@ -1,14 +0,0 @@
-#version 150 core
-
-in vec2 sampleCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D _qt_texture;
-uniform vec4 color;
-
-void main()
-{
- vec4 glyph = texture(_qt_texture, sampleCoord);
- fragColor = vec4(glyph.rgb * color.a, glyph.a);
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/textmask_core.vert b/src/quick/scenegraph/shaders/textmask_core.vert
deleted file mode 100644
index b0efc1e731..0000000000
--- a/src/quick/scenegraph/shaders/textmask_core.vert
+++ /dev/null
@@ -1,17 +0,0 @@
-#version 150 core
-
-in vec4 vCoord;
-in vec2 tCoord;
-
-out vec2 sampleCoord;
-
-uniform mat4 matrix;
-uniform vec2 textureScale;
-uniform float dpr;
-
-void main()
-{
- sampleCoord = tCoord * textureScale;
- vec3 dprSnapPos = floor(vCoord.xyz * dpr + 0.5) / dpr;
- gl_Position = matrix * vec4(dprSnapPos, vCoord.w);
-}
diff --git a/src/quick/scenegraph/shaders/texture.frag b/src/quick/scenegraph/shaders/texture.frag
deleted file mode 100644
index 2d97f2e66a..0000000000
--- a/src/quick/scenegraph/shaders/texture.frag
+++ /dev/null
@@ -1,9 +0,0 @@
-varying highp vec2 qt_TexCoord;
-
-uniform sampler2D qt_Texture;
-uniform lowp float opacity;
-
-void main()
-{
- gl_FragColor = texture2D(qt_Texture, qt_TexCoord) * opacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/texture_core.frag b/src/quick/scenegraph/shaders/texture_core.frag
deleted file mode 100644
index d9bdf6a238..0000000000
--- a/src/quick/scenegraph/shaders/texture_core.frag
+++ /dev/null
@@ -1,13 +0,0 @@
-#version 150 core
-
-in vec2 qt_TexCoord;
-
-out vec4 fragColor;
-
-uniform sampler2D qt_Texture;
-uniform float opacity;
-
-void main()
-{
- fragColor = texture(qt_Texture, qt_TexCoord) * opacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/vertexcolor.frag b/src/quick/scenegraph/shaders/vertexcolor.frag
deleted file mode 100644
index 71de9dbfc2..0000000000
--- a/src/quick/scenegraph/shaders/vertexcolor.frag
+++ /dev/null
@@ -1,6 +0,0 @@
-varying lowp vec4 color;
-
-void main()
-{
- gl_FragColor = color;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/vertexcolor.vert b/src/quick/scenegraph/shaders/vertexcolor.vert
deleted file mode 100644
index 750d520114..0000000000
--- a/src/quick/scenegraph/shaders/vertexcolor.vert
+++ /dev/null
@@ -1,13 +0,0 @@
-attribute highp vec4 vertexCoord;
-attribute highp vec4 vertexColor;
-
-uniform highp mat4 matrix;
-uniform highp float opacity;
-
-varying lowp vec4 color;
-
-void main()
-{
- gl_Position = matrix * vertexCoord;
- color = vertexColor * opacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/vertexcolor_core.frag b/src/quick/scenegraph/shaders/vertexcolor_core.frag
deleted file mode 100644
index 84533c2b40..0000000000
--- a/src/quick/scenegraph/shaders/vertexcolor_core.frag
+++ /dev/null
@@ -1,10 +0,0 @@
-#version 150 core
-
-in vec4 color;
-
-out vec4 fragColor;
-
-void main()
-{
- fragColor = color;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/vertexcolor_core.vert b/src/quick/scenegraph/shaders/vertexcolor_core.vert
deleted file mode 100644
index 219b840913..0000000000
--- a/src/quick/scenegraph/shaders/vertexcolor_core.vert
+++ /dev/null
@@ -1,15 +0,0 @@
-#version 150 core
-
-in vec4 vertexCoord;
-in vec4 vertexColor;
-
-out vec4 color;
-
-uniform mat4 matrix;
-uniform float opacity;
-
-void main()
-{
- gl_Position = matrix * vertexCoord;
- color = vertexColor * opacity;
-} \ No newline at end of file
diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
index 87941bf31a..ab37a05ce6 100644
--- a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
@@ -39,90 +39,20 @@
#include "qsgflatcolormaterial.h"
#include <private/qsgmaterialshader_p.h>
-#if QT_CONFIG(opengl)
-# include <qopenglshaderprogram.h>
-#endif
QT_BEGIN_NAMESPACE
-class FlatColorMaterialShader : public QSGMaterialShader
+class FlatColorMaterialRhiShader : public QSGMaterialShader
{
public:
- FlatColorMaterialShader();
+ FlatColorMaterialRhiShader();
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
static QSGMaterialType type;
-
-private:
- void initialize() override;
-#if QT_CONFIG(opengl)
- int m_matrix_id;
- int m_color_id;
-#endif
};
-QSGMaterialType FlatColorMaterialShader::type;
-
-FlatColorMaterialShader::FlatColorMaterialShader()
- : QSGMaterialShader(*new QSGMaterialShaderPrivate)
-{
-#if QT_CONFIG(opengl)
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/flatcolor.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/flatcolor.frag"));
-#endif
-}
-
-void FlatColorMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
-#if QT_CONFIG(opengl)
- Q_ASSERT(oldEffect == nullptr || newEffect->type() == oldEffect->type());
- QSGFlatColorMaterial *oldMaterial = static_cast<QSGFlatColorMaterial *>(oldEffect);
- QSGFlatColorMaterial *newMaterial = static_cast<QSGFlatColorMaterial *>(newEffect);
-
- const QColor &c = newMaterial->color();
-
- if (oldMaterial == nullptr || c != oldMaterial->color() || state.isOpacityDirty()) {
- float opacity = state.opacity() * c.alphaF();
- QVector4D v(c.redF() * opacity,
- c.greenF() * opacity,
- c.blueF() * opacity,
- opacity);
- program()->setUniformValue(m_color_id, v);
- }
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, state.combinedMatrix());
-#else
- Q_UNUSED(state)
- Q_UNUSED(newEffect)
- Q_UNUSED(oldEffect)
-#endif
-}
-
-char const *const *FlatColorMaterialShader::attributeNames() const
-{
- static char const *const attr[] = { "vCoord", nullptr };
- return attr;
-}
-
-void FlatColorMaterialShader::initialize()
-{
-#if QT_CONFIG(opengl)
- m_matrix_id = program()->uniformLocation("matrix");
- m_color_id = program()->uniformLocation("color");
-#endif
-}
-
-
-class FlatColorMaterialRhiShader : public QSGMaterialRhiShader
-{
-public:
- FlatColorMaterialRhiShader();
-
- bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
-};
+QSGMaterialType FlatColorMaterialRhiShader::type;
FlatColorMaterialRhiShader::FlatColorMaterialRhiShader()
{
@@ -195,7 +125,6 @@ bool FlatColorMaterialRhiShader::updateUniformData(RenderState &state,
QSGFlatColorMaterial::QSGFlatColorMaterial() : m_color(QColor(255, 255, 255))
{
- setFlag(SupportsRhiShader, true);
}
/*!
@@ -226,7 +155,7 @@ void QSGFlatColorMaterial::setColor(const QColor &color)
QSGMaterialType *QSGFlatColorMaterial::type() const
{
- return &FlatColorMaterialShader::type;
+ return &FlatColorMaterialRhiShader::type;
}
@@ -237,10 +166,7 @@ QSGMaterialType *QSGFlatColorMaterial::type() const
QSGMaterialShader *QSGFlatColorMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new FlatColorMaterialRhiShader;
- else
- return new FlatColorMaterialShader;
+ return new FlatColorMaterialRhiShader;
}
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index 0e70d0638b..38776dbaa6 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -39,10 +39,6 @@
#include "qsgtexturematerial_p.h"
#include <private/qsgtexture_p.h>
-#if QT_CONFIG(opengl)
-# include <qopenglshaderprogram.h>
-# include <qopenglfunctions.h>
-#endif
#include <QtGui/private/qrhi_p.h>
QT_BEGIN_NAMESPACE
@@ -53,72 +49,6 @@ inline static bool isPowerOfTwo(int x)
return x == (x & -x);
}
-QSGOpaqueTextureMaterialShader::QSGOpaqueTextureMaterialShader()
-{
-#if QT_CONFIG(opengl)
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.frag"));
-#endif
-}
-
-char const *const *QSGOpaqueTextureMaterialShader::attributeNames() const
-{
- static char const *const attr[] = { "qt_VertexPosition", "qt_VertexTexCoord", nullptr };
- return attr;
-}
-
-void QSGOpaqueTextureMaterialShader::initialize()
-{
-#if QT_CONFIG(opengl)
- m_matrix_id = program()->uniformLocation("qt_Matrix");
-#endif
-}
-
-void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- Q_ASSERT(oldEffect == nullptr || newEffect->type() == oldEffect->type());
- QSGOpaqueTextureMaterial *tx = static_cast<QSGOpaqueTextureMaterial *>(newEffect);
- QSGOpaqueTextureMaterial *oldTx = static_cast<QSGOpaqueTextureMaterial *>(oldEffect);
-
- QSGTexture *t = tx->texture();
-
-#ifndef QT_NO_DEBUG
- if (!qsg_safeguard_texture(t))
- return;
-#endif
-
- t->setFiltering(tx->filtering());
-
- t->setHorizontalWrapMode(tx->horizontalWrapMode());
- t->setVerticalWrapMode(tx->verticalWrapMode());
-#if QT_CONFIG(opengl)
- bool npotSupported = const_cast<QOpenGLContext *>(state.context())
- ->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat);
- if (!npotSupported) {
- QSize size = t->textureSize();
- const bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height());
- if (isNpot) {
- t->setHorizontalWrapMode(QSGTexture::ClampToEdge);
- t->setVerticalWrapMode(QSGTexture::ClampToEdge);
- }
- }
-#else
- Q_UNUSED(state)
-#endif
- t->setMipmapFiltering(tx->mipmapFiltering());
- t->setAnisotropyLevel(tx->anisotropyLevel());
-
- if (oldTx == nullptr || oldTx->texture()->textureId() != t->textureId())
- t->bind();
- else
- t->updateBindOptions();
-#if QT_CONFIG(opengl)
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, state.combinedMatrix());
-#endif
-}
-
-
QSGOpaqueTextureMaterialRhiShader::QSGOpaqueTextureMaterialRhiShader()
{
setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/opaquetexture.vert.qsb"));
@@ -226,7 +156,6 @@ QSGOpaqueTextureMaterial::QSGOpaqueTextureMaterial()
, m_vertical_wrap(QSGTexture::ClampToEdge)
, m_anisotropy_level(QSGTexture::AnisotropyNone)
{
- setFlag(SupportsRhiShader, true);
}
@@ -244,10 +173,7 @@ QSGMaterialType *QSGOpaqueTextureMaterial::type() const
*/
QSGMaterialShader *QSGOpaqueTextureMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new QSGOpaqueTextureMaterialRhiShader;
- else
- return new QSGOpaqueTextureMaterialShader;
+ return new QSGOpaqueTextureMaterialRhiShader;
}
@@ -435,36 +361,7 @@ QSGMaterialType *QSGTextureMaterial::type() const
QSGMaterialShader *QSGTextureMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new QSGTextureMaterialRhiShader;
- else
- return new QSGTextureMaterialShader;
-}
-
-
-QSGTextureMaterialShader::QSGTextureMaterialShader()
-{
-#if QT_CONFIG(opengl)
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/texture.frag"));
-#endif
-}
-
-void QSGTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
-{
- Q_ASSERT(oldEffect == nullptr || newEffect->type() == oldEffect->type());
-#if QT_CONFIG(opengl)
- if (state.isOpacityDirty())
- program()->setUniformValue(m_opacity_id, state.opacity());
-#endif
- QSGOpaqueTextureMaterialShader::updateState(state, newEffect, oldEffect);
-}
-
-void QSGTextureMaterialShader::initialize()
-{
- QSGOpaqueTextureMaterialShader::initialize();
-#if QT_CONFIG(opengl)
- m_opacity_id = program()->uniformLocation("opacity");
-#endif
+ return new QSGTextureMaterialRhiShader;
}
diff --git a/src/quick/scenegraph/util/qsgtexturematerial_p.h b/src/quick/scenegraph/util/qsgtexturematerial_p.h
index d1ef7d1d7f..cdd3e416a6 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial_p.h
+++ b/src/quick/scenegraph/util/qsgtexturematerial_p.h
@@ -56,21 +56,7 @@
QT_BEGIN_NAMESPACE
-class Q_QUICK_PRIVATE_EXPORT QSGOpaqueTextureMaterialShader : public QSGMaterialShader
-{
-public:
- QSGOpaqueTextureMaterialShader();
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-protected:
- void initialize() override;
-
- int m_matrix_id;
-};
-
-class Q_QUICK_PRIVATE_EXPORT QSGOpaqueTextureMaterialRhiShader : public QSGMaterialRhiShader
+class Q_QUICK_PRIVATE_EXPORT QSGOpaqueTextureMaterialRhiShader : public QSGMaterialShader
{
public:
QSGOpaqueTextureMaterialRhiShader();
@@ -79,18 +65,6 @@ public:
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
-class QSGTextureMaterialShader : public QSGOpaqueTextureMaterialShader
-{
-public:
- QSGTextureMaterialShader();
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- void initialize() override;
-
-protected:
- int m_opacity_id;
-};
-
class QSGTextureMaterialRhiShader : public QSGOpaqueTextureMaterialRhiShader
{
public:
diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
index c27dd7d1f0..9f2836d6aa 100644
--- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
@@ -38,64 +38,10 @@
****************************************************************************/
#include "qsgvertexcolormaterial.h"
-#if QT_CONFIG(opengl)
-# include <qopenglshaderprogram.h>
-#endif
-QT_BEGIN_NAMESPACE
-
-class QSGVertexColorMaterialShader : public QSGMaterialShader
-{
-public:
- QSGVertexColorMaterialShader();
-
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-private:
- void initialize() override;
-#if QT_CONFIG(opengl)
- int m_matrix_id;
- int m_opacity_id;
-#endif
-};
-
-QSGVertexColorMaterialShader::QSGVertexColorMaterialShader()
-{
-#if QT_CONFIG(opengl)
- setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.frag"));
-#endif
-}
-
-void QSGVertexColorMaterialShader::updateState(const RenderState &state, QSGMaterial * /*newEffect*/, QSGMaterial *)
-{
-#if QT_CONFIG(opengl)
- if (state.isOpacityDirty())
- program()->setUniformValue(m_opacity_id, state.opacity());
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrix_id, state.combinedMatrix());
-#else
- Q_UNUSED(state)
-#endif
-}
-
-char const *const *QSGVertexColorMaterialShader::attributeNames() const
-{
- static const char *const attr[] = { "vertexCoord", "vertexColor", nullptr };
- return attr;
-}
-
-void QSGVertexColorMaterialShader::initialize()
-{
-#if QT_CONFIG(opengl)
- m_matrix_id = program()->uniformLocation("matrix");
- m_opacity_id = program()->uniformLocation("opacity");
-#endif
-}
+QT_BEGIN_NAMESPACE
-class QSGVertexColorMaterialRhiShader : public QSGMaterialRhiShader
+class QSGVertexColorMaterialRhiShader : public QSGMaterialShader
{
public:
QSGVertexColorMaterialRhiShader();
@@ -168,7 +114,6 @@ bool QSGVertexColorMaterialRhiShader::updateUniformData(RenderState &state,
QSGVertexColorMaterial::QSGVertexColorMaterial()
{
setFlag(Blending, true);
- setFlag(SupportsRhiShader, true);
}
@@ -204,10 +149,7 @@ QSGMaterialType *QSGVertexColorMaterial::type() const
QSGMaterialShader *QSGVertexColorMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new QSGVertexColorMaterialRhiShader;
- else
- return new QSGVertexColorMaterialShader;
+ return new QSGVertexColorMaterialRhiShader;
}
QT_END_NAMESPACE
diff --git a/src/quickshapes/CMakeLists.txt b/src/quickshapes/CMakeLists.txt
index b8a37288f0..0833d51e1b 100644
--- a/src/quickshapes/CMakeLists.txt
+++ b/src/quickshapes/CMakeLists.txt
@@ -22,22 +22,6 @@ qt_add_module(QuickShapes
# Resources:
set(qtquickshapes_resource_files
- "shaders/blit.frag"
- "shaders/blit.vert"
- "shaders/blit_core.frag"
- "shaders/blit_core.vert"
- "shaders/conicalgradient.frag"
- "shaders/conicalgradient.vert"
- "shaders/conicalgradient_core.frag"
- "shaders/conicalgradient_core.vert"
- "shaders/lineargradient.frag"
- "shaders/lineargradient.vert"
- "shaders/lineargradient_core.frag"
- "shaders/lineargradient_core.vert"
- "shaders/radialgradient.frag"
- "shaders/radialgradient.vert"
- "shaders/radialgradient_core.frag"
- "shaders/radialgradient_core.vert"
"shaders_ng/conicalgradient.frag.qsb"
"shaders_ng/conicalgradient.vert.qsb"
"shaders_ng/lineargradient.frag.qsb"
@@ -60,16 +44,6 @@ qt_add_resource(QuickShapes "qtquickshapes"
# QML_IMPORT_NAME = "QtQuick.Shapes"
# QML_IMPORT_VERSION = "$$QT_VERSION"
-## Scopes:
-#####################################################################
-
-qt_extend_target(QuickShapes CONDITION QT_FEATURE_opengl
- SOURCES
- qquicknvprfunctions.cpp qquicknvprfunctions_p.h
- qquicknvprfunctions_p_p.h
- qquickshapenvprrenderer.cpp qquickshapenvprrenderer_p.h
-)
-
set_target_properties(QuickShapes PROPERTIES
QT_QML_MODULE_INSTALL_QMLTYPES TRUE
QT_QML_MODULE_VERSION ${CMAKE_PROJECT_VERSION}
diff --git a/src/quickshapes/qquicknvprfunctions.cpp b/src/quickshapes/qquicknvprfunctions.cpp
deleted file mode 100644
index 409a59be7f..0000000000
--- a/src/quickshapes/qquicknvprfunctions.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquicknvprfunctions_p.h"
-
-#if QT_CONFIG(opengl)
-
-#include <QOpenGLContext>
-#include <QOffscreenSurface>
-#include <QOpenGLExtraFunctions>
-#include "qquicknvprfunctions_p_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QQuickNvprFunctions
-
- \brief Function resolvers and other helpers for GL_NV_path_rendering
- for both desktop (GL 4.3+) and mobile/embedded (GLES 3.1+) in a manner
- that does not distract builds that do not have NVPR support either at
- compile or run time.
-
- \internal
- */
-
-QQuickNvprFunctions::QQuickNvprFunctions()
- : d(new QQuickNvprFunctionsPrivate(this))
-{
-}
-
-QQuickNvprFunctions::~QQuickNvprFunctions()
-{
- delete d;
-}
-
-/*!
- \return a recommended QSurfaceFormat suitable for GL_NV_path_rendering on top
- of OpenGL 4.3 or OpenGL ES 3.1.
- */
-QSurfaceFormat QQuickNvprFunctions::format()
-{
- QSurfaceFormat fmt;
- fmt.setDepthBufferSize(24);
- fmt.setStencilBufferSize(8);
- if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
- fmt.setVersion(4, 3);
- fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
- } else if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
- fmt.setVersion(3, 1);
- }
- return fmt;
-}
-
-#define PROC(type, name) reinterpret_cast<type>(ctx->getProcAddress(#name))
-
-/*!
- \return true if GL_NV_path_rendering is supported with the current OpenGL
- context.
-
- When there is no current context, a temporary dummy one will be created and
- made current.
- */
-bool QQuickNvprFunctions::isSupported()
-{
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
- QScopedPointer<QOpenGLContext> tempContext;
- QScopedPointer<QOffscreenSurface> tempSurface;
- if (!ctx) {
- tempContext.reset(new QOpenGLContext);
- if (!tempContext->create())
- return false;
- ctx = tempContext.data();
- tempSurface.reset(new QOffscreenSurface);
- tempSurface->setFormat(ctx->format());
- tempSurface->create();
- if (!ctx->makeCurrent(tempSurface.data()))
- return false;
- }
-
- if (!ctx->hasExtension(QByteArrayLiteral("GL_NV_path_rendering")))
- return false;
-
- // Check that GL_NV_Path_rendering extension is at least API revision 1.3
- if (!PROC(PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC, glProgramPathFragmentInputGenNV))
- return false;
-
- // Do not check for DSA as the string may not be exposed on ES
- // drivers, yet the functions we need are resolvable.
-#if 0
- if (!ctx->hasExtension(QByteArrayLiteral("GL_EXT_direct_state_access"))) {
- qWarning("QtQuickPath/NVPR: GL_EXT_direct_state_access not supported");
- return false;
- }
-#endif
-
- return true;
-}
-
-/*!
- Initializes using the current OpenGL context.
-
- \return true when GL_NV_path_rendering is supported and initialization was
- successful.
- */
-bool QQuickNvprFunctions::create()
-{
- return isSupported() && d->resolve();
-}
-
-/*!
- Creates a program pipeline consisting of a separable fragment shader program.
-
- This is essential for using NVPR with OpenGL ES 3.1+ since normal,
- GLES2-style programs would not work without a vertex shader.
-
- \note \a fragmentShaderSource should be a \c{version 310 es} shader since
- this works both on desktop and embedded NVIDIA drivers, thus avoiding the
- need to fight GLSL and GLSL ES differences.
-
- The pipeline object is stored into \a pipeline, the fragment shader program
- into \a program.
-
- Use QOpenGLExtraFunctions to set uniforms, bind the pipeline, etc.
-
- \return \c false on failure in which case the error log is printed on the
- debug output. \c true on success.
- */
-bool QQuickNvprFunctions::createFragmentOnlyPipeline(const char *fragmentShaderSource, GLuint *pipeline, GLuint *program)
-{
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
- if (!ctx)
- return false;
-
- QOpenGLExtraFunctions *f = ctx->extraFunctions();
- *program = f->glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &fragmentShaderSource);
- GLint status = 0;
- f->glGetProgramiv(*program, GL_LINK_STATUS, &status);
- if (!status) {
- GLint len = 0;
- f->glGetProgramiv(*program, GL_INFO_LOG_LENGTH, &len);
- if (len) {
- QByteArray s;
- s.resize(len);
- f->glGetProgramInfoLog(*program, s.count(), nullptr, s.data());
- qWarning("Failed to create separable shader program:\n%s", s.constData());
- }
- return false;
- }
-
- f->glGenProgramPipelines(1, pipeline);
- f->glUseProgramStages(*pipeline, GL_FRAGMENT_SHADER_BIT, *program);
- f->glActiveShaderProgram(*pipeline, *program);
-
- f->glValidateProgramPipeline(*pipeline);
- status = 0;
- f->glGetProgramPipelineiv(*pipeline, GL_VALIDATE_STATUS, &status);
- if (!status) {
- GLint len = 0;
- f->glGetProgramPipelineiv(*pipeline, GL_INFO_LOG_LENGTH, &len);
- if (len) {
- QByteArray s;
- s.resize(len);
- f->glGetProgramPipelineInfoLog(*pipeline, s.count(), nullptr, s.data());
- qWarning("Program pipeline validation failed:\n%s", s.constData());
- }
- return false;
- }
-
- return true;
-}
-
-bool QQuickNvprFunctionsPrivate::resolve()
-{
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
-
- q->genPaths = PROC(PFNGLGENPATHSNVPROC, glGenPathsNV);
- q->deletePaths = PROC(PFNGLDELETEPATHSNVPROC, glDeletePathsNV);
- q->isPath = PROC(PFNGLISPATHNVPROC, glIsPathNV);
- q->pathCommands = PROC(PFNGLPATHCOMMANDSNVPROC, glPathCommandsNV);
- q->pathCoords = PROC(PFNGLPATHCOORDSNVPROC, glPathCoordsNV);
- q->pathSubCommands = PROC(PFNGLPATHSUBCOMMANDSNVPROC, glPathSubCommandsNV);
- q->pathSubCoords = PROC(PFNGLPATHSUBCOORDSNVPROC, glPathSubCoordsNV);
- q->pathString = PROC(PFNGLPATHSTRINGNVPROC, glPathStringNV);
- q->pathGlyphs = PROC(PFNGLPATHGLYPHSNVPROC, glPathGlyphsNV);
- q->pathGlyphRange = PROC(PFNGLPATHGLYPHRANGENVPROC, glPathGlyphRangeNV);
- q->weightPaths = PROC(PFNGLWEIGHTPATHSNVPROC, glWeightPathsNV);
- q->copyPath = PROC(PFNGLCOPYPATHNVPROC, glCopyPathNV);
- q->interpolatePaths = PROC(PFNGLINTERPOLATEPATHSNVPROC, glInterpolatePathsNV);
- q->transformPath = PROC(PFNGLTRANSFORMPATHNVPROC, glTransformPathNV);
- q->pathParameteriv = PROC(PFNGLPATHPARAMETERIVNVPROC, glPathParameterivNV);
- q->pathParameteri = PROC(PFNGLPATHPARAMETERINVPROC, glPathParameteriNV);
- q->pathParameterfv = PROC(PFNGLPATHPARAMETERFVNVPROC, glPathParameterfvNV);
- q->pathParameterf = PROC(PFNGLPATHPARAMETERFNVPROC, glPathParameterfNV);
- q->pathDashArray = PROC(PFNGLPATHDASHARRAYNVPROC, glPathDashArrayNV);
- q->pathStencilFunc = PROC(PFNGLPATHSTENCILFUNCNVPROC, glPathStencilFuncNV);
- q->pathStencilDepthOffset = PROC(PFNGLPATHSTENCILDEPTHOFFSETNVPROC, glPathStencilDepthOffsetNV);
- q->stencilFillPath = PROC(PFNGLSTENCILFILLPATHNVPROC, glStencilFillPathNV);
- q->stencilStrokePath = PROC(PFNGLSTENCILSTROKEPATHNVPROC, glStencilStrokePathNV);
- q->stencilFillPathInstanced = PROC(PFNGLSTENCILFILLPATHINSTANCEDNVPROC, glStencilFillPathInstancedNV);
- q->stencilStrokePathInstanced = PROC(PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC, glStencilStrokePathInstancedNV);
- q->pathCoverDepthFunc = PROC(PFNGLPATHCOVERDEPTHFUNCNVPROC, glPathCoverDepthFuncNV);
- q->coverFillPath = PROC(PFNGLCOVERFILLPATHNVPROC, glCoverFillPathNV);
- q->coverStrokePath = PROC(PFNGLCOVERSTROKEPATHNVPROC, glCoverStrokePathNV);
- q->coverFillPathInstanced = PROC(PFNGLCOVERFILLPATHINSTANCEDNVPROC, glCoverFillPathInstancedNV);
- q->coverStrokePathInstanced = PROC(PFNGLCOVERSTROKEPATHINSTANCEDNVPROC, glCoverStrokePathInstancedNV);
- q->getPathParameteriv = PROC(PFNGLGETPATHPARAMETERIVNVPROC, glGetPathParameterivNV);
- q->getPathParameterfv = PROC(PFNGLGETPATHPARAMETERFVNVPROC, glGetPathParameterfvNV);
- q->getPathCommands = PROC(PFNGLGETPATHCOMMANDSNVPROC, glGetPathCommandsNV);
- q->getPathCoords = PROC(PFNGLGETPATHCOORDSNVPROC, glGetPathCoordsNV);
- q->getPathDashArray = PROC(PFNGLGETPATHDASHARRAYNVPROC, glGetPathDashArrayNV);
- q->getPathMetrics = PROC(PFNGLGETPATHMETRICSNVPROC, glGetPathMetricsNV);
- q->getPathMetricRange = PROC(PFNGLGETPATHMETRICRANGENVPROC, glGetPathMetricRangeNV);
- q->getPathSpacing = PROC(PFNGLGETPATHSPACINGNVPROC, glGetPathSpacingNV);
- q->isPointInFillPath = PROC(PFNGLISPOINTINFILLPATHNVPROC, glIsPointInFillPathNV);
- q->isPointInStrokePath = PROC(PFNGLISPOINTINSTROKEPATHNVPROC, glIsPointInStrokePathNV);
- q->getPathLength = PROC(PFNGLGETPATHLENGTHNVPROC, glGetPathLengthNV);
- q->getPointAlongPath = PROC(PFNGLPOINTALONGPATHNVPROC, glPointAlongPathNV);
- q->matrixLoad3x2f = PROC(PFNGLMATRIXLOAD3X2FNVPROC, glMatrixLoad3x2fNV);
- q->matrixLoad3x3f = PROC(PFNGLMATRIXLOAD3X3FNVPROC, glMatrixLoad3x3fNV);
- q->matrixLoadTranspose3x3f = PROC(PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC, glMatrixLoadTranspose3x3fNV);
- q->matrixMult3x2f = PROC(PFNGLMATRIXMULT3X2FNVPROC, glMatrixMult3x2fNV);
- q->matrixMult3x3f = PROC(PFNGLMATRIXMULT3X3FNVPROC, glMatrixMult3x3fNV);
- q->matrixMultTranspose3x3f = PROC(PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC, glMatrixMultTranspose3x3fNV);
- q->stencilThenCoverFillPath = PROC(PFNGLSTENCILTHENCOVERFILLPATHNVPROC, glStencilThenCoverFillPathNV);
- q->stencilThenCoverStrokePath = PROC(PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC, glStencilThenCoverStrokePathNV);
- q->stencilThenCoverFillPathInstanced = PROC(PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC, glStencilThenCoverFillPathInstancedNV);
- q->stencilThenCoverStrokePathInstanced = PROC(PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC, glStencilThenCoverStrokePathInstancedNV);
- q->pathGlyphIndexRange = PROC(PFNGLPATHGLYPHINDEXRANGENVPROC, glPathGlyphIndexRangeNV);
- q->pathGlyphIndexArray = PROC(PFNGLPATHGLYPHINDEXARRAYNVPROC, glPathGlyphIndexArrayNV);
- q->pathMemoryGlyphIndexArray = PROC(PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC, glPathMemoryGlyphIndexArrayNV);
- q->programPathFragmentInputGen = PROC(PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC, glProgramPathFragmentInputGenNV);
- q->getProgramResourcefv = PROC(PFNGLGETPROGRAMRESOURCEFVNVPROC, glGetProgramResourcefvNV);
-
- q->matrixLoadf = PROC(PFNGLMATRIXLOADFEXTPROC, glMatrixLoadfEXT);
- q->matrixLoadIdentity = PROC(PFNGLMATRIXLOADIDENTITYEXTPROC, glMatrixLoadIdentityEXT);
-
- return q->genPaths != nullptr // base path rendering ext
- && q->programPathFragmentInputGen != nullptr // updated path rendering ext
- && q->matrixLoadf != nullptr // direct state access ext
- && q->matrixLoadIdentity != nullptr;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_CONFIG(opengl)
diff --git a/src/quickshapes/qquicknvprfunctions_p.h b/src/quickshapes/qquicknvprfunctions_p.h
deleted file mode 100644
index 92246cf4c8..0000000000
--- a/src/quickshapes/qquicknvprfunctions_p.h
+++ /dev/null
@@ -1,401 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKNVPRFUNCTIONS_P_H
-#define QQUICKNVPRFUNCTIONS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of a number of Qt sources files. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtQuickShapes/private/qquickshapesglobal_p.h>
-#include <qopengl.h>
-#include <QtGui/qsurfaceformat.h>
-
-#if QT_CONFIG(opengl)
-
-QT_BEGIN_NAMESPACE
-
-// note: fixed pipeline specific functions are removed - modern ES ext
-// headers have all this, but not the fixed stuff
-
-#ifndef GL_NV_path_rendering
-#define GL_PATH_FORMAT_SVG_NV 0x9070
-#define GL_PATH_FORMAT_PS_NV 0x9071
-#define GL_STANDARD_FONT_NAME_NV 0x9072
-#define GL_SYSTEM_FONT_NAME_NV 0x9073
-#define GL_FILE_NAME_NV 0x9074
-#define GL_PATH_STROKE_WIDTH_NV 0x9075
-#define GL_PATH_END_CAPS_NV 0x9076
-#define GL_PATH_INITIAL_END_CAP_NV 0x9077
-#define GL_PATH_TERMINAL_END_CAP_NV 0x9078
-#define GL_PATH_JOIN_STYLE_NV 0x9079
-#define GL_PATH_MITER_LIMIT_NV 0x907A
-#define GL_PATH_DASH_CAPS_NV 0x907B
-#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C
-#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D
-#define GL_PATH_DASH_OFFSET_NV 0x907E
-#define GL_PATH_CLIENT_LENGTH_NV 0x907F
-#define GL_PATH_FILL_MODE_NV 0x9080
-#define GL_PATH_FILL_MASK_NV 0x9081
-#define GL_PATH_FILL_COVER_MODE_NV 0x9082
-#define GL_PATH_STROKE_COVER_MODE_NV 0x9083
-#define GL_PATH_STROKE_MASK_NV 0x9084
-#define GL_COUNT_UP_NV 0x9088
-#define GL_COUNT_DOWN_NV 0x9089
-#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A
-#define GL_CONVEX_HULL_NV 0x908B
-#define GL_BOUNDING_BOX_NV 0x908D
-#define GL_TRANSLATE_X_NV 0x908E
-#define GL_TRANSLATE_Y_NV 0x908F
-#define GL_TRANSLATE_2D_NV 0x9090
-#define GL_TRANSLATE_3D_NV 0x9091
-#define GL_AFFINE_2D_NV 0x9092
-#define GL_AFFINE_3D_NV 0x9094
-#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096
-#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098
-#define GL_UTF8_NV 0x909A
-#define GL_UTF16_NV 0x909B
-#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C
-#define GL_PATH_COMMAND_COUNT_NV 0x909D
-#define GL_PATH_COORD_COUNT_NV 0x909E
-#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F
-#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0
-#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1
-#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2
-#define GL_SQUARE_NV 0x90A3
-#define GL_ROUND_NV 0x90A4
-#define GL_TRIANGULAR_NV 0x90A5
-#define GL_BEVEL_NV 0x90A6
-#define GL_MITER_REVERT_NV 0x90A7
-#define GL_MITER_TRUNCATE_NV 0x90A8
-#define GL_SKIP_MISSING_GLYPH_NV 0x90A9
-#define GL_USE_MISSING_GLYPH_NV 0x90AA
-#define GL_PATH_ERROR_POSITION_NV 0x90AB
-#define GL_PATH_FOG_GEN_MODE_NV 0x90AC
-#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD
-#define GL_ADJACENT_PAIRS_NV 0x90AE
-#define GL_FIRST_TO_REST_NV 0x90AF
-#define GL_PATH_GEN_MODE_NV 0x90B0
-#define GL_PATH_GEN_COEFF_NV 0x90B1
-#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2
-#define GL_PATH_GEN_COMPONENTS_NV 0x90B3
-#define GL_PATH_STENCIL_FUNC_NV 0x90B7
-#define GL_PATH_STENCIL_REF_NV 0x90B8
-#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9
-#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD
-#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE
-#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF
-#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4
-#define GL_MOVE_TO_RESETS_NV 0x90B5
-#define GL_MOVE_TO_CONTINUES_NV 0x90B6
-#define GL_CLOSE_PATH_NV 0x00
-#define GL_MOVE_TO_NV 0x02
-#define GL_RELATIVE_MOVE_TO_NV 0x03
-#define GL_LINE_TO_NV 0x04
-#define GL_RELATIVE_LINE_TO_NV 0x05
-#define GL_HORIZONTAL_LINE_TO_NV 0x06
-#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07
-#define GL_VERTICAL_LINE_TO_NV 0x08
-#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09
-#define GL_QUADRATIC_CURVE_TO_NV 0x0A
-#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B
-#define GL_CUBIC_CURVE_TO_NV 0x0C
-#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D
-#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E
-#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F
-#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10
-#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11
-#define GL_SMALL_CCW_ARC_TO_NV 0x12
-#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13
-#define GL_SMALL_CW_ARC_TO_NV 0x14
-#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15
-#define GL_LARGE_CCW_ARC_TO_NV 0x16
-#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17
-#define GL_LARGE_CW_ARC_TO_NV 0x18
-#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19
-#define GL_RESTART_PATH_NV 0xF0
-#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2
-#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4
-#define GL_RECT_NV 0xF6
-#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8
-#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA
-#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC
-#define GL_ARC_TO_NV 0xFE
-#define GL_RELATIVE_ARC_TO_NV 0xFF
-#define GL_BOLD_BIT_NV 0x01
-#define GL_ITALIC_BIT_NV 0x02
-#define GL_GLYPH_WIDTH_BIT_NV 0x01
-#define GL_GLYPH_HEIGHT_BIT_NV 0x02
-#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04
-#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08
-#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10
-#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20
-#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40
-#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80
-#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100
-#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000
-#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000
-#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000
-#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000
-#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000
-#define GL_FONT_ASCENDER_BIT_NV 0x00200000
-#define GL_FONT_DESCENDER_BIT_NV 0x00400000
-#define GL_FONT_HEIGHT_BIT_NV 0x00800000
-#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000
-#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000
-#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000
-#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000
-#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000
-#define GL_PRIMARY_COLOR_NV 0x852C
-#define GL_SECONDARY_COLOR_NV 0x852D
-#define GL_ROUNDED_RECT_NV 0xE8
-#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9
-#define GL_ROUNDED_RECT2_NV 0xEA
-#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB
-#define GL_ROUNDED_RECT4_NV 0xEC
-#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED
-#define GL_ROUNDED_RECT8_NV 0xEE
-#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF
-#define GL_RELATIVE_RECT_NV 0xF7
-#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368
-#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369
-#define GL_FONT_UNAVAILABLE_NV 0x936A
-#define GL_FONT_UNINTELLIGIBLE_NV 0x936B
-#define GL_CONIC_CURVE_TO_NV 0x1A
-#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B
-#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000
-#define GL_STANDARD_FONT_FORMAT_NV 0x936C
-#define GL_2_BYTES_NV 0x1407
-#define GL_3_BYTES_NV 0x1408
-#define GL_4_BYTES_NV 0x1409
-#define GL_EYE_LINEAR_NV 0x2400
-#define GL_OBJECT_LINEAR_NV 0x2401
-#define GL_CONSTANT_NV 0x8576
-#define GL_PATH_PROJECTION_NV 0x1701
-#define GL_PATH_MODELVIEW_NV 0x1700
-#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3
-#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6
-#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36
-#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3
-#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4
-#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7
-#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38
-#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4
-#define GL_FRAGMENT_INPUT_NV 0x936D
-
-typedef GLuint (QOPENGLF_APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range);
-typedef void (QOPENGLF_APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range);
-typedef GLboolean (QOPENGLF_APIENTRYP PFNGLISPATHNVPROC) (GLuint path);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
-typedef void (QOPENGLF_APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights);
-typedef void (QOPENGLF_APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath);
-typedef void (QOPENGLF_APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);
-typedef void (QOPENGLF_APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units);
-typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask);
-typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask);
-typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);
-typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);
-typedef void (QOPENGLF_APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func);
-typedef void (QOPENGLF_APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode);
-typedef void (QOPENGLF_APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode);
-typedef void (QOPENGLF_APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
-typedef void (QOPENGLF_APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
-typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value);
-typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value);
-typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands);
-typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords);
-typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray);
-typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);
-typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics);
-typedef void (QOPENGLF_APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);
-typedef GLboolean (QOPENGLF_APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y);
-typedef GLboolean (QOPENGLF_APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y);
-typedef GLfloat (QOPENGLF_APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments);
-typedef GLboolean (QOPENGLF_APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);
-typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m);
-typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
-typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
-typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m);
-typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
-typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
-typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode);
-typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode);
-typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
-typedef void (QOPENGLF_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
-typedef GLenum (QOPENGLF_APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]);
-typedef GLenum (QOPENGLF_APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
-typedef GLenum (QOPENGLF_APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
-typedef void (QOPENGLF_APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs);
-typedef void (QOPENGLF_APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params);
-#endif
-
-#ifndef GL_FLAT
-#define GL_FLAT 0x1D00
-#endif
-
-#ifndef GL_INVERT
-#define GL_INVERT 0x150A
-#endif
-
-// this one originates from fixed pipeline so may not be in GLES ext headers, but we need it still
-#ifndef GL_OBJECT_LINEAR_NV
-#define GL_OBJECT_LINEAR_NV 0x2401
-#endif
-
-#ifndef GL_EXT_direct_state_access
-typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m);
-typedef void (QOPENGLF_APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode);
-#endif
-
-// When building on a system with GLES 2.0 or 3.0, we may still compile the NVPR
-// code path even though it's never used. Keep it compiling by defining the
-// necessary ES 3.1 separable program constants.
-#ifndef GL_FRAGMENT_SHADER_BIT
-#define GL_FRAGMENT_SHADER_BIT 0x00000002
-#endif
-#ifndef GL_UNIFORM
-#define GL_UNIFORM 0x92E1
-#endif
-
-class QQuickNvprFunctionsPrivate;
-
-class QQuickNvprFunctions
-{
-public:
- QQuickNvprFunctions();
- ~QQuickNvprFunctions();
-
- static QSurfaceFormat format();
- static bool isSupported();
-
- bool create();
-
- bool createFragmentOnlyPipeline(const char *fragmentShaderSource, GLuint *pipeline, GLuint *program);
-
- PFNGLGENPATHSNVPROC genPaths = nullptr;
- PFNGLDELETEPATHSNVPROC deletePaths = nullptr;
- PFNGLISPATHNVPROC isPath = nullptr;
- PFNGLPATHCOMMANDSNVPROC pathCommands = nullptr;
- PFNGLPATHCOORDSNVPROC pathCoords = nullptr;
- PFNGLPATHSUBCOMMANDSNVPROC pathSubCommands = nullptr;
- PFNGLPATHSUBCOORDSNVPROC pathSubCoords = nullptr;
- PFNGLPATHSTRINGNVPROC pathString = nullptr;
- PFNGLPATHGLYPHSNVPROC pathGlyphs = nullptr;
- PFNGLPATHGLYPHRANGENVPROC pathGlyphRange = nullptr;
- PFNGLWEIGHTPATHSNVPROC weightPaths = nullptr;
- PFNGLCOPYPATHNVPROC copyPath = nullptr;
- PFNGLINTERPOLATEPATHSNVPROC interpolatePaths = nullptr;
- PFNGLTRANSFORMPATHNVPROC transformPath = nullptr;
- PFNGLPATHPARAMETERIVNVPROC pathParameteriv = nullptr;
- PFNGLPATHPARAMETERINVPROC pathParameteri = nullptr;
- PFNGLPATHPARAMETERFVNVPROC pathParameterfv = nullptr;
- PFNGLPATHPARAMETERFNVPROC pathParameterf = nullptr;
- PFNGLPATHDASHARRAYNVPROC pathDashArray = nullptr;
- PFNGLPATHSTENCILFUNCNVPROC pathStencilFunc = nullptr;
- PFNGLPATHSTENCILDEPTHOFFSETNVPROC pathStencilDepthOffset = nullptr;
- PFNGLSTENCILFILLPATHNVPROC stencilFillPath = nullptr;
- PFNGLSTENCILSTROKEPATHNVPROC stencilStrokePath = nullptr;
- PFNGLSTENCILFILLPATHINSTANCEDNVPROC stencilFillPathInstanced = nullptr;
- PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC stencilStrokePathInstanced = nullptr;
- PFNGLPATHCOVERDEPTHFUNCNVPROC pathCoverDepthFunc = nullptr;
- PFNGLCOVERFILLPATHNVPROC coverFillPath = nullptr;
- PFNGLCOVERSTROKEPATHNVPROC coverStrokePath = nullptr;
- PFNGLCOVERFILLPATHINSTANCEDNVPROC coverFillPathInstanced = nullptr;
- PFNGLCOVERSTROKEPATHINSTANCEDNVPROC coverStrokePathInstanced = nullptr;
- PFNGLGETPATHPARAMETERIVNVPROC getPathParameteriv = nullptr;
- PFNGLGETPATHPARAMETERFVNVPROC getPathParameterfv = nullptr;
- PFNGLGETPATHCOMMANDSNVPROC getPathCommands = nullptr;
- PFNGLGETPATHCOORDSNVPROC getPathCoords = nullptr;
- PFNGLGETPATHDASHARRAYNVPROC getPathDashArray = nullptr;
- PFNGLGETPATHMETRICSNVPROC getPathMetrics = nullptr;
- PFNGLGETPATHMETRICRANGENVPROC getPathMetricRange = nullptr;
- PFNGLGETPATHSPACINGNVPROC getPathSpacing = nullptr;
- PFNGLISPOINTINFILLPATHNVPROC isPointInFillPath = nullptr;
- PFNGLISPOINTINSTROKEPATHNVPROC isPointInStrokePath = nullptr;
- PFNGLGETPATHLENGTHNVPROC getPathLength = nullptr;
- PFNGLPOINTALONGPATHNVPROC getPointAlongPath = nullptr;
- PFNGLMATRIXLOAD3X2FNVPROC matrixLoad3x2f = nullptr;
- PFNGLMATRIXLOAD3X3FNVPROC matrixLoad3x3f = nullptr;
- PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC matrixLoadTranspose3x3f = nullptr;
- PFNGLMATRIXMULT3X2FNVPROC matrixMult3x2f = nullptr;
- PFNGLMATRIXMULT3X3FNVPROC matrixMult3x3f = nullptr;
- PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC matrixMultTranspose3x3f = nullptr;
- PFNGLSTENCILTHENCOVERFILLPATHNVPROC stencilThenCoverFillPath = nullptr;
- PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC stencilThenCoverStrokePath = nullptr;
- PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC stencilThenCoverFillPathInstanced = nullptr;
- PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC stencilThenCoverStrokePathInstanced = nullptr;
- PFNGLPATHGLYPHINDEXRANGENVPROC pathGlyphIndexRange = nullptr;
- PFNGLPATHGLYPHINDEXARRAYNVPROC pathGlyphIndexArray = nullptr;
- PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC pathMemoryGlyphIndexArray = nullptr;
- PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC programPathFragmentInputGen = nullptr;
- PFNGLGETPROGRAMRESOURCEFVNVPROC getProgramResourcefv = nullptr;
-
- PFNGLMATRIXLOADFEXTPROC matrixLoadf = nullptr;
- PFNGLMATRIXLOADIDENTITYEXTPROC matrixLoadIdentity = nullptr;
-
-private:
- QQuickNvprFunctionsPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_CONFIG(opengl)
-
-#endif // QQUICKNVPRFUNCTIONS_P_H
diff --git a/src/quickshapes/qquicknvprfunctions_p_p.h b/src/quickshapes/qquicknvprfunctions_p_p.h
deleted file mode 100644
index 3d9ca0de9f..0000000000
--- a/src/quickshapes/qquicknvprfunctions_p_p.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKNVPRFUNCTIONS_P_P_H
-#define QQUICKNVPRFUNCTIONS_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of a number of Qt sources files. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtQuickShapes/private/qquickshapesglobal_p.h>
-#include <QtQuickShapes/private/qquicknvprfunctions_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickNvprFunctionsPrivate
-{
-public:
- QQuickNvprFunctionsPrivate(QQuickNvprFunctions *q_ptr) : q(q_ptr) { }
-
- bool resolve();
-
- QQuickNvprFunctions *q;
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKNVPRFUNCTIONS_P_P_H
diff --git a/src/quickshapes/qquickshape.cpp b/src/quickshapes/qquickshape.cpp
index 563303b84a..5e2cfc6622 100644
--- a/src/quickshapes/qquickshape.cpp
+++ b/src/quickshapes/qquickshape.cpp
@@ -40,7 +40,6 @@
#include "qquickshape_p.h"
#include "qquickshape_p_p.h"
#include "qquickshapegenericrenderer_p.h"
-#include "qquickshapenvprrenderer_p.h"
#include "qquickshapesoftwarerenderer_p.h"
#include <private/qsgplaintexture_p.h>
#include <private/qquicksvgparser_p.h>
@@ -694,12 +693,6 @@ QQuickShape::~QQuickShape()
engine. This is the default on non-NVIDIA hardware when the default,
OpenGL Qt Quick scenegraph backend is in use.
- \value Shape.NvprRenderer
- Path items are rendered by performing OpenGL calls using the
- \c{GL_NV_path_rendering} extension. This is the default on NVIDIA
- hardware when the default, OpenGL Qt Quick scenegraph backend is in
- use.
-
\value Shape.SoftwareRenderer
Pure QPainter drawing using the raster paint engine. This is the
default, and only, option when the Qt Quick scenegraph is running
@@ -755,12 +748,9 @@ void QQuickShape::setAsynchronous(bool async)
As of Qt 5.12 Shape.NvprRenderer is disabled by default and a uniform
behavior, based on triangulating the path and generating QSGGeometryNode
- instances, is used regardless of the graphics card and drivers. To enable
- using vendor-specific path rendering approaches set the value to \c true.
- Depending on the platform and content, this can lead to improved
- performance. Setting the value to \c true is safe in any case since
- rendering falls back to the default method when the vendor-specific
- approach, such as \c GL_NV_path_rendering, is not supported at run time.
+ instances, is used regardless of the graphics card and drivers.
+
+ As of Qt 6.0 there are no vendor-specific rendering paths implemented.
*/
bool QQuickShape::vendorExtensionsEnabled() const
@@ -993,13 +983,8 @@ void QQuickShapePrivate::createRenderer()
switch (ri->graphicsApi()) {
#if QT_CONFIG(opengl)
case QSGRendererInterface::OpenGL:
- if (enableVendorExts && QQuickShapeNvprRenderNode::isSupported()) {
- rendererType = QQuickShape::NvprRenderer;
- renderer = new QQuickShapeNvprRenderer;
- } else {
- rendererType = QQuickShape::GeometryRenderer;
- renderer = new QQuickShapeGenericRenderer(q);
- }
+ rendererType = QQuickShape::GeometryRenderer;
+ renderer = new QQuickShapeGenericRenderer(q);
break;
#endif
case QSGRendererInterface::Software:
@@ -1031,15 +1016,9 @@ QSGNode *QQuickShapePrivate::createNode()
switch (ri->graphicsApi()) {
#if QT_CONFIG(opengl)
case QSGRendererInterface::OpenGL:
- if (enableVendorExts && QQuickShapeNvprRenderNode::isSupported()) {
- node = new QQuickShapeNvprRenderNode;
- static_cast<QQuickShapeNvprRenderer *>(renderer)->setNode(
- static_cast<QQuickShapeNvprRenderNode *>(node));
- } else {
- node = new QQuickShapeGenericNode;
- static_cast<QQuickShapeGenericRenderer *>(renderer)->setRootNode(
- static_cast<QQuickShapeGenericNode *>(node));
- }
+ node = new QQuickShapeGenericNode;
+ static_cast<QQuickShapeGenericRenderer *>(renderer)->setRootNode(
+ static_cast<QQuickShapeGenericNode *>(node));
break;
#endif
case QSGRendererInterface::Software:
diff --git a/src/quickshapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp
index 9fbff8fdda..148cbca3d0 100644
--- a/src/quickshapes/qquickshapegenericrenderer.cpp
+++ b/src/quickshapes/qquickshapegenericrenderer.cpp
@@ -752,51 +752,6 @@ QSGMaterial *QQuickShapeGenericMaterialFactory::createConicalGradient(QQuickWind
return nullptr;
}
-#if QT_CONFIG(opengl)
-
-QQuickShapeLinearGradientShader::QQuickShapeLinearGradientShader()
-{
- setShaderSourceFile(QOpenGLShader::Vertex,
- QStringLiteral(":/qt-project.org/shapes/shaders/lineargradient.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment,
- QStringLiteral(":/qt-project.org/shapes/shaders/lineargradient.frag"));
-}
-
-void QQuickShapeLinearGradientShader::initialize()
-{
- m_opacityLoc = program()->uniformLocation("opacity");
- m_matrixLoc = program()->uniformLocation("matrix");
- m_gradStartLoc = program()->uniformLocation("gradStart");
- m_gradEndLoc = program()->uniformLocation("gradEnd");
-}
-
-void QQuickShapeLinearGradientShader::updateState(const RenderState &state, QSGMaterial *mat, QSGMaterial *)
-{
- QQuickShapeLinearGradientMaterial *m = static_cast<QQuickShapeLinearGradientMaterial *>(mat);
-
- if (state.isOpacityDirty())
- program()->setUniformValue(m_opacityLoc, state.opacity());
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrixLoc, state.combinedMatrix());
-
- QQuickShapeGenericStrokeFillNode *node = m->node();
- program()->setUniformValue(m_gradStartLoc, QVector2D(node->m_fillGradient.a));
- program()->setUniformValue(m_gradEndLoc, QVector2D(node->m_fillGradient.b));
-
- const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, node->m_fillGradient.spread);
- QSGTexture *tx = QQuickShapeGradientOpenGLCache::currentCache()->get(cacheKey);
- tx->bind();
-}
-
-char const *const *QQuickShapeLinearGradientShader::attributeNames() const
-{
- static const char *const attr[] = { "vertexCoord", "vertexColor", nullptr };
- return attr;
-}
-
-#endif // QT_CONFIG(opengl)
-
QQuickShapeLinearGradientRhiShader::QQuickShapeLinearGradientRhiShader()
{
setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/shapes/shaders_ng/lineargradient.vert.qsb"));
@@ -903,73 +858,9 @@ int QQuickShapeLinearGradientMaterial::compare(const QSGMaterial *other) const
QSGMaterialShader *QQuickShapeLinearGradientMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new QQuickShapeLinearGradientRhiShader;
-#if QT_CONFIG(opengl)
- else
- return new QQuickShapeLinearGradientShader;
-#else
- return nullptr;
-#endif
-}
-
-#if QT_CONFIG(opengl)
-
-QQuickShapeRadialGradientShader::QQuickShapeRadialGradientShader()
-{
- setShaderSourceFile(QOpenGLShader::Vertex,
- QStringLiteral(":/qt-project.org/shapes/shaders/radialgradient.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment,
- QStringLiteral(":/qt-project.org/shapes/shaders/radialgradient.frag"));
-}
-
-void QQuickShapeRadialGradientShader::initialize()
-{
- QOpenGLShaderProgram *prog = program();
- m_opacityLoc = prog->uniformLocation("opacity");
- m_matrixLoc = prog->uniformLocation("matrix");
- m_translationPointLoc = prog->uniformLocation("translationPoint");
- m_focalToCenterLoc = prog->uniformLocation("focalToCenter");
- m_centerRadiusLoc = prog->uniformLocation("centerRadius");
- m_focalRadiusLoc = prog->uniformLocation("focalRadius");
-}
-
-void QQuickShapeRadialGradientShader::updateState(const RenderState &state, QSGMaterial *mat, QSGMaterial *)
-{
- QQuickShapeRadialGradientMaterial *m = static_cast<QQuickShapeRadialGradientMaterial *>(mat);
-
- if (state.isOpacityDirty())
- program()->setUniformValue(m_opacityLoc, state.opacity());
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrixLoc, state.combinedMatrix());
-
- QQuickShapeGenericStrokeFillNode *node = m->node();
-
- const QPointF centerPoint = node->m_fillGradient.a;
- const QPointF focalPoint = node->m_fillGradient.b;
- const QPointF focalToCenter = centerPoint - focalPoint;
- const GLfloat centerRadius = node->m_fillGradient.v0;
- const GLfloat focalRadius = node->m_fillGradient.v1;
-
- program()->setUniformValue(m_translationPointLoc, focalPoint);
- program()->setUniformValue(m_centerRadiusLoc, centerRadius);
- program()->setUniformValue(m_focalRadiusLoc, focalRadius);
- program()->setUniformValue(m_focalToCenterLoc, focalToCenter);
-
- const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, node->m_fillGradient.spread);
- QSGTexture *tx = QQuickShapeGradientOpenGLCache::currentCache()->get(cacheKey);
- tx->bind();
-}
-
-char const *const *QQuickShapeRadialGradientShader::attributeNames() const
-{
- static const char *const attr[] = { "vertexCoord", "vertexColor", nullptr };
- return attr;
+ return new QQuickShapeLinearGradientRhiShader;
}
-#endif // QT_CONFIG(opengl)
-
QQuickShapeRadialGradientRhiShader::QQuickShapeRadialGradientRhiShader()
{
setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/shapes/shaders_ng/radialgradient.vert.qsb"));
@@ -1100,66 +991,9 @@ int QQuickShapeRadialGradientMaterial::compare(const QSGMaterial *other) const
QSGMaterialShader *QQuickShapeRadialGradientMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new QQuickShapeRadialGradientRhiShader;
-#if QT_CONFIG(opengl)
- else
- return new QQuickShapeRadialGradientShader;
-#else
- return nullptr;
-#endif
-}
-
-#if QT_CONFIG(opengl)
-
-QQuickShapeConicalGradientShader::QQuickShapeConicalGradientShader()
-{
- setShaderSourceFile(QOpenGLShader::Vertex,
- QStringLiteral(":/qt-project.org/shapes/shaders/conicalgradient.vert"));
- setShaderSourceFile(QOpenGLShader::Fragment,
- QStringLiteral(":/qt-project.org/shapes/shaders/conicalgradient.frag"));
+ return new QQuickShapeRadialGradientRhiShader;
}
-void QQuickShapeConicalGradientShader::initialize()
-{
- QOpenGLShaderProgram *prog = program();
- m_opacityLoc = prog->uniformLocation("opacity");
- m_matrixLoc = prog->uniformLocation("matrix");
- m_angleLoc = prog->uniformLocation("angle");
- m_translationPointLoc = prog->uniformLocation("translationPoint");
-}
-
-void QQuickShapeConicalGradientShader::updateState(const RenderState &state, QSGMaterial *mat, QSGMaterial *)
-{
- QQuickShapeConicalGradientMaterial *m = static_cast<QQuickShapeConicalGradientMaterial *>(mat);
-
- if (state.isOpacityDirty())
- program()->setUniformValue(m_opacityLoc, state.opacity());
-
- if (state.isMatrixDirty())
- program()->setUniformValue(m_matrixLoc, state.combinedMatrix());
-
- QQuickShapeGenericStrokeFillNode *node = m->node();
-
- const QPointF centerPoint = node->m_fillGradient.a;
- const GLfloat angle = -qDegreesToRadians(node->m_fillGradient.v0);
-
- program()->setUniformValue(m_angleLoc, angle);
- program()->setUniformValue(m_translationPointLoc, centerPoint);
-
- const QQuickShapeGradientCacheKey cacheKey(node->m_fillGradient.stops, QQuickShapeGradient::RepeatSpread);
- QSGTexture *tx = QQuickShapeGradientOpenGLCache::currentCache()->get(cacheKey);
- tx->bind();
-}
-
-char const *const *QQuickShapeConicalGradientShader::attributeNames() const
-{
- static const char *const attr[] = { "vertexCoord", "vertexColor", nullptr };
- return attr;
-}
-
-#endif // QT_CONFIG(opengl)
-
QQuickShapeConicalGradientRhiShader::QQuickShapeConicalGradientRhiShader()
{
setShaderFileName(VertexStage, QStringLiteral(":/qt-project.org/shapes/shaders_ng/conicalgradient.vert.qsb"));
@@ -1265,14 +1099,7 @@ int QQuickShapeConicalGradientMaterial::compare(const QSGMaterial *other) const
QSGMaterialShader *QQuickShapeConicalGradientMaterial::createShader() const
{
- if (flags().testFlag(RhiShaderWanted))
- return new QQuickShapeConicalGradientRhiShader;
-#if QT_CONFIG(opengl)
- else
- return new QQuickShapeConicalGradientShader;
-#else
- return nullptr;
-#endif
+ return new QQuickShapeConicalGradientRhiShader;
}
QT_END_NAMESPACE
diff --git a/src/quickshapes/qquickshapegenericrenderer_p.h b/src/quickshapes/qquickshapegenericrenderer_p.h
index 75c4277383..cb206cea87 100644
--- a/src/quickshapes/qquickshapegenericrenderer_p.h
+++ b/src/quickshapes/qquickshapegenericrenderer_p.h
@@ -243,27 +243,7 @@ public:
static QSGMaterial *createConicalGradient(QQuickWindow *window, QQuickShapeGenericStrokeFillNode *node);
};
-#if QT_CONFIG(opengl)
-
- class QQuickShapeLinearGradientShader : public QSGMaterialShader
-{
-public:
- QQuickShapeLinearGradientShader();
-
- void initialize() override;
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-private:
- int m_opacityLoc = -1;
- int m_matrixLoc = -1;
- int m_gradStartLoc = -1;
- int m_gradEndLoc = -1;
-};
-
-#endif // QT_CONFIG(opengl)
-
-class QQuickShapeLinearGradientRhiShader : public QSGMaterialRhiShader
+class QQuickShapeLinearGradientRhiShader : public QSGMaterialShader
{
public:
QQuickShapeLinearGradientRhiShader();
@@ -289,7 +269,7 @@ public:
// the vertex data. The shader will rely on the fact that
// vertexCoord.xy is the Shape-space coordinate and so no modifications
// are welcome.
- setFlag(Blending | RequiresFullMatrix | SupportsRhiShader);
+ setFlag(Blending | RequiresFullMatrix);
}
QSGMaterialType *type() const override;
@@ -302,29 +282,7 @@ private:
QQuickShapeGenericStrokeFillNode *m_node;
};
-#if QT_CONFIG(opengl)
-
-class QQuickShapeRadialGradientShader : public QSGMaterialShader
-{
-public:
- QQuickShapeRadialGradientShader();
-
- void initialize() override;
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-private:
- int m_opacityLoc = -1;
- int m_matrixLoc = -1;
- int m_translationPointLoc = -1;
- int m_focalToCenterLoc = -1;
- int m_centerRadiusLoc = -1;
- int m_focalRadiusLoc = -1;
-};
-
-#endif // QT_CONFIG(opengl)
-
-class QQuickShapeRadialGradientRhiShader : public QSGMaterialRhiShader
+class QQuickShapeRadialGradientRhiShader : public QSGMaterialShader
{
public:
QQuickShapeRadialGradientRhiShader();
@@ -347,7 +305,7 @@ public:
QQuickShapeRadialGradientMaterial(QQuickShapeGenericStrokeFillNode *node)
: m_node(node)
{
- setFlag(Blending | RequiresFullMatrix | SupportsRhiShader);
+ setFlag(Blending | RequiresFullMatrix);
}
QSGMaterialType *type() const override;
@@ -360,27 +318,7 @@ private:
QQuickShapeGenericStrokeFillNode *m_node;
};
-#if QT_CONFIG(opengl)
-
-class QQuickShapeConicalGradientShader : public QSGMaterialShader
-{
-public:
- QQuickShapeConicalGradientShader();
-
- void initialize() override;
- void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
- char const *const *attributeNames() const override;
-
-private:
- int m_opacityLoc = -1;
- int m_matrixLoc = -1;
- int m_angleLoc = -1;
- int m_translationPointLoc = -1;
-};
-
-#endif // QT_CONFIG(opengl)
-
-class QQuickShapeConicalGradientRhiShader : public QSGMaterialRhiShader
+class QQuickShapeConicalGradientRhiShader : public QSGMaterialShader
{
public:
QQuickShapeConicalGradientRhiShader();
@@ -401,7 +339,7 @@ public:
QQuickShapeConicalGradientMaterial(QQuickShapeGenericStrokeFillNode *node)
: m_node(node)
{
- setFlag(Blending | RequiresFullMatrix | SupportsRhiShader);
+ setFlag(Blending | RequiresFullMatrix);
}
QSGMaterialType *type() const override;
diff --git a/src/quickshapes/qquickshapenvprrenderer.cpp b/src/quickshapes/qquickshapenvprrenderer.cpp
deleted file mode 100644
index 721091b669..0000000000
--- a/src/quickshapes/qquickshapenvprrenderer.cpp
+++ /dev/null
@@ -1,1001 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickshapenvprrenderer_p.h"
-#include <QOpenGLExtraFunctions>
-#include <QOpenGLFramebufferObject>
-#include <QOpenGLShaderProgram>
-#include <QOpenGLBuffer>
-#include <qmath.h>
-#include <private/qpainterpath_p.h>
-#include <private/qquickpath_p_p.h>
-
-QT_BEGIN_NAMESPACE
-
-void QQuickShapeNvprRenderer::beginSync(int totalCount)
-{
- if (m_sp.count() != totalCount) {
- m_sp.resize(totalCount);
- m_accDirty |= DirtyList;
- }
-}
-
-void QQuickShapeNvprRenderer::setPath(int index, const QQuickPath *path)
-{
- ShapePathGuiData &d(m_sp[index]);
- convertPath(path, &d);
- d.dirty |= DirtyPath;
- m_accDirty |= DirtyPath;
-}
-
-void QQuickShapeNvprRenderer::setStrokeColor(int index, const QColor &color)
-{
- ShapePathGuiData &d(m_sp[index]);
- d.strokeColor = color;
- d.dirty |= DirtyStyle;
- m_accDirty |= DirtyStyle;
-}
-
-void QQuickShapeNvprRenderer::setStrokeWidth(int index, qreal w)
-{
- ShapePathGuiData &d(m_sp[index]);
- d.strokeWidth = w;
- d.dirty |= DirtyStyle;
- m_accDirty |= DirtyStyle;
-}
-
-void QQuickShapeNvprRenderer::setFillColor(int index, const QColor &color)
-{
- ShapePathGuiData &d(m_sp[index]);
- d.fillColor = color;
- d.dirty |= DirtyStyle;
- m_accDirty |= DirtyStyle;
-}
-
-void QQuickShapeNvprRenderer::setFillRule(int index, QQuickShapePath::FillRule fillRule)
-{
- ShapePathGuiData &d(m_sp[index]);
- d.fillRule = fillRule;
- d.dirty |= DirtyFillRule;
- m_accDirty |= DirtyFillRule;
-}
-
-void QQuickShapeNvprRenderer::setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit)
-{
- ShapePathGuiData &d(m_sp[index]);
- d.joinStyle = joinStyle;
- d.miterLimit = miterLimit;
- d.dirty |= DirtyStyle;
- m_accDirty |= DirtyStyle;
-}
-
-void QQuickShapeNvprRenderer::setCapStyle(int index, QQuickShapePath::CapStyle capStyle)
-{
- ShapePathGuiData &d(m_sp[index]);
- d.capStyle = capStyle;
- d.dirty |= DirtyStyle;
- m_accDirty |= DirtyStyle;
-}
-
-void QQuickShapeNvprRenderer::setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle,
- qreal dashOffset, const QVector<qreal> &dashPattern)
-{
- ShapePathGuiData &d(m_sp[index]);
- d.dashActive = strokeStyle == QQuickShapePath::DashLine;
- d.dashOffset = dashOffset;
- d.dashPattern = dashPattern;
- d.dirty |= DirtyDash;
- m_accDirty |= DirtyDash;
-}
-
-void QQuickShapeNvprRenderer::setFillGradient(int index, QQuickShapeGradient *gradient)
-{
- ShapePathGuiData &d(m_sp[index]);
- if (gradient) {
- d.fillGradient.stops = gradient->gradientStops(); // sorted
- d.fillGradient.spread = gradient->spread();
- if (QQuickShapeLinearGradient *g = qobject_cast<QQuickShapeLinearGradient *>(gradient)) {
- d.fillGradientActive = LinearGradient;
- d.fillGradient.a = QPointF(g->x1(), g->y1());
- d.fillGradient.b = QPointF(g->x2(), g->y2());
- } else if (QQuickShapeRadialGradient *g = qobject_cast<QQuickShapeRadialGradient *>(gradient)) {
- d.fillGradientActive = RadialGradient;
- d.fillGradient.a = QPointF(g->centerX(), g->centerY());
- d.fillGradient.b = QPointF(g->focalX(), g->focalY());
- d.fillGradient.v0 = g->centerRadius();
- d.fillGradient.v1 = g->focalRadius();
- } else if (QQuickShapeConicalGradient *g = qobject_cast<QQuickShapeConicalGradient *>(gradient)) {
- d.fillGradientActive = ConicalGradient;
- d.fillGradient.a = QPointF(g->centerX(), g->centerY());
- d.fillGradient.v0 = g->angle();
- } else {
- Q_UNREACHABLE();
- }
- } else {
- d.fillGradientActive = NoGradient;
- }
- d.dirty |= DirtyFillGradient;
- m_accDirty |= DirtyFillGradient;
-}
-
-void QQuickShapeNvprRenderer::endSync(bool)
-{
-}
-
-void QQuickShapeNvprRenderer::setNode(QQuickShapeNvprRenderNode *node)
-{
- if (m_node != node) {
- m_node = node;
- m_accDirty |= DirtyList;
- }
-}
-
-QDebug operator<<(QDebug debug, const QQuickShapeNvprRenderer::NvprPath &path)
-{
- QDebugStateSaver saver(debug);
- debug.space().noquote();
- if (!path.str.isEmpty()) {
- debug << "Path with SVG string" << path.str;
- return debug;
- }
- debug << "Path with" << path.cmd.count() << "commands";
- int ci = 0;
- for (GLubyte cmd : path.cmd) {
- static struct { GLubyte cmd; const char *s; int coordCount; } nameTabs[] = {
- { GL_MOVE_TO_NV, "moveTo", 2 },
- { GL_LINE_TO_NV, "lineTo", 2 },
- { GL_QUADRATIC_CURVE_TO_NV, "quadTo", 4 },
- { GL_CUBIC_CURVE_TO_NV, "cubicTo", 6 },
- { GL_LARGE_CW_ARC_TO_NV, "arcTo-large-CW", 5 },
- { GL_LARGE_CCW_ARC_TO_NV, "arcTo-large-CCW", 5 },
- { GL_SMALL_CW_ARC_TO_NV, "arcTo-small-CW", 5 },
- { GL_SMALL_CCW_ARC_TO_NV, "arcTo-small-CCW", 5 },
- { GL_CLOSE_PATH_NV, "closePath", 0 } };
- for (const auto &nameTab : nameTabs) {
- if (nameTab.cmd == cmd) {
- QByteArray cs;
- for (int j = 0; j < nameTab.coordCount; ++j) {
- cs.append(QByteArray::number(path.coord[ci++]));
- cs.append(' ');
- }
- debug << "\n " << nameTab.s << " " << cs;
- break;
- }
- }
- }
- return debug;
-}
-
-static inline void appendCoords(QVector<GLfloat> *v, QQuickCurve *c, QPointF *pos)
-{
- QPointF p(c->hasRelativeX() ? pos->x() + c->relativeX() : c->x(),
- c->hasRelativeY() ? pos->y() + c->relativeY() : c->y());
- v->append(p.x());
- v->append(p.y());
- *pos = p;
-}
-
-static inline void appendControlCoords(QVector<GLfloat> *v, QQuickPathQuad *c, const QPointF &pos)
-{
- QPointF p(c->hasRelativeControlX() ? pos.x() + c->relativeControlX() : c->controlX(),
- c->hasRelativeControlY() ? pos.y() + c->relativeControlY() : c->controlY());
- v->append(p.x());
- v->append(p.y());
-}
-
-static inline void appendControl1Coords(QVector<GLfloat> *v, QQuickPathCubic *c, const QPointF &pos)
-{
- QPointF p(c->hasRelativeControl1X() ? pos.x() + c->relativeControl1X() : c->control1X(),
- c->hasRelativeControl1Y() ? pos.y() + c->relativeControl1Y() : c->control1Y());
- v->append(p.x());
- v->append(p.y());
-}
-
-static inline void appendControl2Coords(QVector<GLfloat> *v, QQuickPathCubic *c, const QPointF &pos)
-{
- QPointF p(c->hasRelativeControl2X() ? pos.x() + c->relativeControl2X() : c->control2X(),
- c->hasRelativeControl2Y() ? pos.y() + c->relativeControl2Y() : c->control2Y());
- v->append(p.x());
- v->append(p.y());
-}
-
-void QQuickShapeNvprRenderer::convertPath(const QQuickPath *path, ShapePathGuiData *d)
-{
- d->path = NvprPath();
- if (!path)
- return;
-
- const QList<QQuickPathElement *> &pp(QQuickPathPrivate::get(path)->_pathElements);
- if (pp.isEmpty())
- return;
-
- QPointF startPos(path->startX(), path->startY());
- QPointF pos(startPos);
- if (!qFuzzyIsNull(pos.x()) || !qFuzzyIsNull(pos.y())) {
- d->path.cmd.append(GL_MOVE_TO_NV);
- d->path.coord.append(pos.x());
- d->path.coord.append(pos.y());
- }
-
- for (QQuickPathElement *e : pp) {
- if (QQuickPathMove *o = qobject_cast<QQuickPathMove *>(e)) {
- d->path.cmd.append(GL_MOVE_TO_NV);
- appendCoords(&d->path.coord, o, &pos);
- startPos = pos;
- } else if (QQuickPathLine *o = qobject_cast<QQuickPathLine *>(e)) {
- d->path.cmd.append(GL_LINE_TO_NV);
- appendCoords(&d->path.coord, o, &pos);
- } else if (QQuickPathQuad *o = qobject_cast<QQuickPathQuad *>(e)) {
- d->path.cmd.append(GL_QUADRATIC_CURVE_TO_NV);
- appendControlCoords(&d->path.coord, o, pos);
- appendCoords(&d->path.coord, o, &pos);
- } else if (QQuickPathCubic *o = qobject_cast<QQuickPathCubic *>(e)) {
- d->path.cmd.append(GL_CUBIC_CURVE_TO_NV);
- appendControl1Coords(&d->path.coord, o, pos);
- appendControl2Coords(&d->path.coord, o, pos);
- appendCoords(&d->path.coord, o, &pos);
- } else if (QQuickPathArc *o = qobject_cast<QQuickPathArc *>(e)) {
- const bool sweepFlag = o->direction() == QQuickPathArc::Clockwise; // maps to CCW, not a typo
- GLenum cmd;
- if (o->useLargeArc())
- cmd = sweepFlag ? GL_LARGE_CCW_ARC_TO_NV : GL_LARGE_CW_ARC_TO_NV;
- else
- cmd = sweepFlag ? GL_SMALL_CCW_ARC_TO_NV : GL_SMALL_CW_ARC_TO_NV;
- d->path.cmd.append(cmd);
- d->path.coord.append(o->radiusX());
- d->path.coord.append(o->radiusY());
- d->path.coord.append(o->xAxisRotation());
- appendCoords(&d->path.coord, o, &pos);
- } else if (QQuickPathSvg *o = qobject_cast<QQuickPathSvg *>(e)) {
- // PathSvg cannot be combined with other elements. But take at
- // least startX and startY into account.
- if (d->path.str.isEmpty())
- d->path.str = QString(QStringLiteral("M %1 %2 ")).arg(pos.x()).arg(pos.y()).toUtf8();
- d->path.str.append(o->path().toUtf8());
- } else if (QQuickPathAngleArc *o = qobject_cast<QQuickPathAngleArc *>(e)) {
- QRectF rect(o->centerX() - o->radiusX(), o->centerY() - o->radiusY(), o->radiusX() * 2, o->radiusY() * 2);
- QPointF startPoint;
- QPointF endPoint;
- qt_find_ellipse_coords(rect, o->startAngle(), -o->sweepAngle(), &startPoint, &endPoint);
-
- // get to our starting position
- if (o->moveToStart())
- d->path.cmd.append(GL_MOVE_TO_NV);
- else
- d->path.cmd.append(GL_LINE_TO_NV); // ### should we check if startPoint == pos?
- d->path.coord.append(startPoint.x());
- d->path.coord.append(startPoint.y());
-
- const bool sweepFlag = o->sweepAngle() > 0; // maps to CCW, not a typo
- d->path.cmd.append(qAbs(o->sweepAngle()) > 180.0
- ? (sweepFlag ? GL_LARGE_CCW_ARC_TO_NV : GL_LARGE_CW_ARC_TO_NV)
- : (sweepFlag ? GL_SMALL_CCW_ARC_TO_NV : GL_SMALL_CW_ARC_TO_NV));
- d->path.coord.append(o->radiusX());
- d->path.coord.append(o->radiusY());
- d->path.coord.append(0); // xAxisRotation
- d->path.coord.append(endPoint.x());
- d->path.coord.append(endPoint.y());
- pos = endPoint;
- } else {
- qWarning() << "Shape/NVPR: unsupported Path element" << e;
- }
- }
-
- // For compatibility with QTriangulatingStroker. SVG and others would not
- // implicitly close the path when end_pos == start_pos (start_pos being the
- // last moveTo pos); that would still need an explicit 'z' or similar. We
- // don't have an explicit close command, so just fake a close when the
- // positions match.
- if (pos == startPos)
- d->path.cmd.append(GL_CLOSE_PATH_NV);
-}
-
-static inline QVector4D qsg_premultiply(const QColor &c, float globalOpacity)
-{
- const float o = c.alphaF() * globalOpacity;
- return QVector4D(c.redF() * o, c.greenF() * o, c.blueF() * o, o);
-}
-
-void QQuickShapeNvprRenderer::updateNode()
-{
- // Called on the render thread with gui blocked -> update the node with its
- // own copy of all relevant data.
-
- if (!m_accDirty)
- return;
-
- const int count = m_sp.count();
- const bool listChanged = m_accDirty & DirtyList;
- if (listChanged)
- m_node->m_sp.resize(count);
-
- for (int i = 0; i < count; ++i) {
- ShapePathGuiData &src(m_sp[i]);
- QQuickShapeNvprRenderNode::ShapePathRenderData &dst(m_node->m_sp[i]);
-
- int dirty = src.dirty;
- src.dirty = 0;
- if (listChanged)
- dirty |= DirtyPath | DirtyStyle | DirtyFillRule | DirtyDash | DirtyFillGradient;
-
- // updateNode() can be called several times with different dirty
- // states before render() gets invoked. So accumulate.
- dst.dirty |= dirty;
-
- if (dirty & DirtyPath)
- dst.source = src.path;
-
- if (dirty & DirtyStyle) {
- dst.strokeWidth = src.strokeWidth;
- dst.strokeColor = qsg_premultiply(src.strokeColor, 1.0f);
- dst.fillColor = qsg_premultiply(src.fillColor, 1.0f);
- switch (src.joinStyle) {
- case QQuickShapePath::MiterJoin:
- dst.joinStyle = GL_MITER_TRUNCATE_NV;
- break;
- case QQuickShapePath::BevelJoin:
- dst.joinStyle = GL_BEVEL_NV;
- break;
- case QQuickShapePath::RoundJoin:
- dst.joinStyle = GL_ROUND_NV;
- break;
- default:
- Q_UNREACHABLE();
- }
- dst.miterLimit = src.miterLimit;
- switch (src.capStyle) {
- case QQuickShapePath::FlatCap:
- dst.capStyle = GL_FLAT;
- break;
- case QQuickShapePath::SquareCap:
- dst.capStyle = GL_SQUARE_NV;
- break;
- case QQuickShapePath::RoundCap:
- dst.capStyle = GL_ROUND_NV;
- break;
- default:
- Q_UNREACHABLE();
- }
- }
-
- if (dirty & DirtyFillRule) {
- switch (src.fillRule) {
- case QQuickShapePath::OddEvenFill:
- dst.fillRule = GL_INVERT;
- break;
- case QQuickShapePath::WindingFill:
- dst.fillRule = GL_COUNT_UP_NV;
- break;
- default:
- Q_UNREACHABLE();
- }
- }
-
- if (dirty & DirtyDash) {
- // Multiply by strokeWidth because the Shape API follows QPen
- // meaning the input dash pattern and dash offset here are in width units.
- dst.dashOffset = src.dashOffset * src.strokeWidth;
- if (src.dashActive) {
- if (src.dashPattern.isEmpty()) {
- // default values for DashLine as defined in qpen.cpp
- dst.dashPattern.resize(2);
- dst.dashPattern[0] = 4 * src.strokeWidth; // dash
- dst.dashPattern[1] = 2 * src.strokeWidth; // space
- } else {
- dst.dashPattern.resize(src.dashPattern.count());
- for (int i = 0; i < src.dashPattern.count(); ++i)
- dst.dashPattern[i] = GLfloat(src.dashPattern[i]) * src.strokeWidth;
-
- // QPen expects a dash pattern of even length and so should we
- if (src.dashPattern.count() % 2 != 0) {
- qWarning("QQuickShapeNvprRenderNode: dash pattern not of even length");
- dst.dashPattern << src.strokeWidth;
- }
- }
- } else {
- dst.dashPattern.clear();
- }
- }
-
- if (dirty & DirtyFillGradient) {
- dst.fillGradientActive = src.fillGradientActive;
- if (src.fillGradientActive)
- dst.fillGradient = src.fillGradient;
- }
- }
-
- m_node->markDirty(QSGNode::DirtyMaterial);
- m_accDirty = 0;
-}
-
-bool QQuickShapeNvprRenderNode::nvprInited = false;
-QQuickNvprFunctions QQuickShapeNvprRenderNode::nvpr;
-QQuickNvprMaterialManager QQuickShapeNvprRenderNode::mtlmgr;
-
-QQuickShapeNvprRenderNode::~QQuickShapeNvprRenderNode()
-{
- releaseResources();
-}
-
-void QQuickShapeNvprRenderNode::releaseResources()
-{
- for (ShapePathRenderData &d : m_sp) {
- if (d.path) {
- nvpr.deletePaths(d.path, 1);
- d.path = 0;
- }
- if (d.fallbackFbo) {
- delete d.fallbackFbo;
- d.fallbackFbo = nullptr;
- }
- }
-
- m_fallbackBlitter.destroy();
-}
-
-void QQuickNvprMaterialManager::create(QQuickNvprFunctions *nvpr)
-{
- m_nvpr = nvpr;
-}
-
-void QQuickNvprMaterialManager::releaseResources()
-{
- QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions();
- for (MaterialDesc &mtl : m_materials) {
- if (mtl.ppl) {
- f->glDeleteProgramPipelines(1, &mtl.ppl);
- mtl = MaterialDesc();
- }
- }
-}
-
-QQuickNvprMaterialManager::MaterialDesc *QQuickNvprMaterialManager::activateMaterial(Material m)
-{
- QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions();
- MaterialDesc &mtl(m_materials[m]);
-
- if (!mtl.ppl) {
- if (m == MatSolid) {
- static const char *fragSrc =
- "#version 310 es\n"
- "precision highp float;\n"
- "out vec4 fragColor;\n"
- "uniform vec4 color;\n"
- "uniform float opacity;\n"
- "void main() {\n"
- " fragColor = color * opacity;\n"
- "}\n";
- if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)) {
- qWarning("NVPR: Failed to create shader pipeline for solid fill");
- return nullptr;
- }
- Q_ASSERT(mtl.ppl && mtl.prg);
- mtl.uniLoc[0] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "color");
- Q_ASSERT(mtl.uniLoc[0] >= 0);
- mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "opacity");
- Q_ASSERT(mtl.uniLoc[1] >= 0);
- } else if (m == MatLinearGradient) {
- static const char *fragSrc =
- "#version 310 es\n"
- "precision highp float;\n"
- "layout(location = 0) in vec2 uv;"
- "uniform float opacity;\n"
- "uniform sampler2D gradTab;\n"
- "uniform vec2 gradStart;\n"
- "uniform vec2 gradEnd;\n"
- "out vec4 fragColor;\n"
- "void main() {\n"
- " vec2 gradVec = gradEnd - gradStart;\n"
- " float gradTabIndex = dot(gradVec, uv - gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y);\n"
- " fragColor = texture(gradTab, vec2(gradTabIndex, 0.5)) * opacity;\n"
- "}\n";
- if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)) {
- qWarning("NVPR: Failed to create shader pipeline for linear gradient");
- return nullptr;
- }
- Q_ASSERT(mtl.ppl && mtl.prg);
- mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "opacity");
- Q_ASSERT(mtl.uniLoc[1] >= 0);
- mtl.uniLoc[2] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "gradStart");
- Q_ASSERT(mtl.uniLoc[2] >= 0);
- mtl.uniLoc[3] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "gradEnd");
- Q_ASSERT(mtl.uniLoc[3] >= 0);
- } else if (m == MatRadialGradient) {
- static const char *fragSrc =
- "#version 310 es\n"
- "precision highp float;\n"
- "uniform sampler2D gradTab;\n"
- "uniform float opacity;\n"
- "uniform vec2 focalToCenter;\n"
- "uniform float centerRadius;\n"
- "uniform float focalRadius;\n"
- "uniform vec2 translationPoint;\n"
- "layout(location = 0) in vec2 uv;\n"
- "out vec4 fragColor;\n"
- "void main() {\n"
- " vec2 coord = uv - translationPoint;\n"
- " float rd = centerRadius - focalRadius;\n"
- " float b = 2.0 * (rd * focalRadius + dot(coord, focalToCenter));\n"
- " float fmp2_m_radius2 = -focalToCenter.x * focalToCenter.x - focalToCenter.y * focalToCenter.y + rd * rd;\n"
- " float inverse_2_fmp2_m_radius2 = 1.0 / (2.0 * fmp2_m_radius2);\n"
- " float det = b * b - 4.0 * fmp2_m_radius2 * ((focalRadius * focalRadius) - dot(coord, coord));\n"
- " vec4 result = vec4(0.0);\n"
- " if (det >= 0.0) {\n"
- " float detSqrt = sqrt(det);\n"
- " float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2);\n"
- " if (focalRadius + w * (centerRadius - focalRadius) >= 0.0)\n"
- " result = texture(gradTab, vec2(w, 0.5)) * opacity;\n"
- " }\n"
- " fragColor = result;\n"
- "}\n";
- if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)) {
- qWarning("NVPR: Failed to create shader pipeline for radial gradient");
- return nullptr;
- }
- Q_ASSERT(mtl.ppl && mtl.prg);
- mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "opacity");
- Q_ASSERT(mtl.uniLoc[1] >= 0);
- mtl.uniLoc[2] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "focalToCenter");
- Q_ASSERT(mtl.uniLoc[2] >= 0);
- mtl.uniLoc[3] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "centerRadius");
- Q_ASSERT(mtl.uniLoc[3] >= 0);
- mtl.uniLoc[4] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "focalRadius");
- Q_ASSERT(mtl.uniLoc[4] >= 0);
- mtl.uniLoc[5] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "translationPoint");
- Q_ASSERT(mtl.uniLoc[5] >= 0);
- } else if (m == MatConicalGradient) {
- static const char *fragSrc =
- "#version 310 es\n"
- "precision highp float;\n"
- "#define INVERSE_2PI 0.1591549430918953358\n"
- "uniform sampler2D gradTab;\n"
- "uniform float opacity;\n"
- "uniform float angle;\n"
- "uniform vec2 translationPoint;\n"
- "layout(location = 0) in vec2 uv;\n"
- "out vec4 fragColor;\n"
- "void main() {\n"
- " vec2 coord = uv - translationPoint;\n"
- " float t;\n"
- " if (abs(coord.y) == abs(coord.x))\n"
- " t = (atan(-coord.y + 0.002, coord.x) + angle) * INVERSE_2PI;\n"
- " else\n"
- " t = (atan(-coord.y, coord.x) + angle) * INVERSE_2PI;\n"
- " fragColor = texture(gradTab, vec2(t - floor(t), 0.5)) * opacity;\n"
- "}\n";
- if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)) {
- qWarning("NVPR: Failed to create shader pipeline for conical gradient");
- return nullptr;
- }
- Q_ASSERT(mtl.ppl && mtl.prg);
- mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "opacity");
- Q_ASSERT(mtl.uniLoc[1] >= 0);
- mtl.uniLoc[2] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "angle");
- Q_ASSERT(mtl.uniLoc[2] >= 0);
- mtl.uniLoc[3] = f->glGetProgramResourceLocation(mtl.prg, GL_UNIFORM, "translationPoint");
- Q_ASSERT(mtl.uniLoc[3] >= 0);
- } else {
- Q_UNREACHABLE();
- }
- }
-
- f->glBindProgramPipeline(mtl.ppl);
-
- return &mtl;
-}
-
-void QQuickShapeNvprRenderNode::updatePath(ShapePathRenderData *d)
-{
- if (d->dirty & QQuickShapeNvprRenderer::DirtyPath) {
- if (!d->path) {
- d->path = nvpr.genPaths(1);
- Q_ASSERT(d->path != 0);
- }
- if (d->source.str.isEmpty()) {
- nvpr.pathCommands(d->path, d->source.cmd.count(), d->source.cmd.constData(),
- d->source.coord.count(), GL_FLOAT, d->source.coord.constData());
- } else {
- nvpr.pathString(d->path, GL_PATH_FORMAT_SVG_NV, d->source.str.count(), d->source.str.constData());
- }
- }
-
- if (d->dirty & QQuickShapeNvprRenderer::DirtyStyle) {
- nvpr.pathParameterf(d->path, GL_PATH_STROKE_WIDTH_NV, d->strokeWidth);
- nvpr.pathParameteri(d->path, GL_PATH_JOIN_STYLE_NV, d->joinStyle);
- nvpr.pathParameteri(d->path, GL_PATH_MITER_LIMIT_NV, d->miterLimit);
- nvpr.pathParameteri(d->path, GL_PATH_END_CAPS_NV, d->capStyle);
- nvpr.pathParameteri(d->path, GL_PATH_DASH_CAPS_NV, d->capStyle);
- }
-
- if (d->dirty & QQuickShapeNvprRenderer::DirtyDash) {
- nvpr.pathParameterf(d->path, GL_PATH_DASH_OFFSET_NV, d->dashOffset);
- // count == 0 -> no dash
- nvpr.pathDashArray(d->path, d->dashPattern.count(), d->dashPattern.constData());
- }
-
- if (d->dirty)
- d->fallbackValid = false;
-}
-
-void QQuickShapeNvprRenderNode::renderStroke(ShapePathRenderData *d, int strokeStencilValue, int writeMask)
-{
- QQuickNvprMaterialManager::MaterialDesc *mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatSolid);
- f->glProgramUniform4f(mtl->prg, mtl->uniLoc[0],
- d->strokeColor.x(), d->strokeColor.y(), d->strokeColor.z(), d->strokeColor.w());
- f->glProgramUniform1f(mtl->prg, mtl->uniLoc[1], inheritedOpacity());
-
- nvpr.stencilThenCoverStrokePath(d->path, strokeStencilValue, writeMask, GL_CONVEX_HULL_NV);
-}
-
-void QQuickShapeNvprRenderNode::renderFill(ShapePathRenderData *d)
-{
- QQuickNvprMaterialManager::MaterialDesc *mtl = nullptr;
- if (d->fillGradientActive) {
- QQuickShapeGradient::SpreadMode spread = d->fillGradient.spread;
- if (d->fillGradientActive == QQuickAbstractPathRenderer::LinearGradient) {
- mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatLinearGradient);
- // uv = vec2(coeff[0] * x + coeff[1] * y + coeff[2], coeff[3] * x + coeff[4] * y + coeff[5])
- // where x and y are in path coordinate space, which is just what
- // we need since the gradient's start and stop are in that space too.
- GLfloat coeff[6] = { 1, 0, 0,
- 0, 1, 0 };
- nvpr.programPathFragmentInputGen(mtl->prg, 0, GL_OBJECT_LINEAR_NV, 2, coeff);
- f->glProgramUniform2f(mtl->prg, mtl->uniLoc[2], d->fillGradient.a.x(), d->fillGradient.a.y());
- f->glProgramUniform2f(mtl->prg, mtl->uniLoc[3], d->fillGradient.b.x(), d->fillGradient.b.y());
- } else if (d->fillGradientActive == QQuickAbstractPathRenderer::RadialGradient) {
- mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatRadialGradient);
- // simply drive uv (location 0) with x and y, just like for the linear gradient
- GLfloat coeff[6] = { 1, 0, 0,
- 0, 1, 0 };
- nvpr.programPathFragmentInputGen(mtl->prg, 0, GL_OBJECT_LINEAR_NV, 2, coeff);
-
- const QPointF centerPoint = d->fillGradient.a;
- const QPointF focalPoint = d->fillGradient.b;
- const QPointF focalToCenter = centerPoint - focalPoint;
- const GLfloat centerRadius = d->fillGradient.v0;
- const GLfloat focalRadius = d->fillGradient.v1;
-
- f->glProgramUniform2f(mtl->prg, mtl->uniLoc[2], focalToCenter.x(), focalToCenter.y());
- f->glProgramUniform1f(mtl->prg, mtl->uniLoc[3], centerRadius);
- f->glProgramUniform1f(mtl->prg, mtl->uniLoc[4], focalRadius);
- f->glProgramUniform2f(mtl->prg, mtl->uniLoc[5], focalPoint.x(), focalPoint.y());
- } else if (d->fillGradientActive == QQuickAbstractPathRenderer::ConicalGradient) {
- mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatConicalGradient);
- // same old
- GLfloat coeff[6] = { 1, 0, 0,
- 0, 1, 0 };
- nvpr.programPathFragmentInputGen(mtl->prg, 0, GL_OBJECT_LINEAR_NV, 2, coeff);
-
- const QPointF centerPoint = d->fillGradient.a;
- const GLfloat angle = -qDegreesToRadians(d->fillGradient.v0);
-
- f->glProgramUniform1f(mtl->prg, mtl->uniLoc[2], angle);
- f->glProgramUniform2f(mtl->prg, mtl->uniLoc[3], centerPoint.x(), centerPoint.y());
-
- spread = QQuickShapeGradient::RepeatSpread;
- } else {
- Q_UNREACHABLE();
- }
- const QQuickShapeGradientCacheKey cacheKey(d->fillGradient.stops, spread);
- QSGTexture *tx = QQuickShapeGradientOpenGLCache::currentCache()->get(cacheKey);
- tx->bind();
- } else {
- mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatSolid);
- f->glProgramUniform4f(mtl->prg, mtl->uniLoc[0],
- d->fillColor.x(), d->fillColor.y(), d->fillColor.z(), d->fillColor.w());
- }
- f->glProgramUniform1f(mtl->prg, mtl->uniLoc[1], inheritedOpacity());
-
- const int writeMask = 0xFF;
- nvpr.stencilThenCoverFillPath(d->path, d->fillRule, writeMask, GL_BOUNDING_BOX_NV);
-}
-
-void QQuickShapeNvprRenderNode::renderOffscreenFill(ShapePathRenderData *d)
-{
- if (d->fallbackValid && d->fallbackFbo)
- return;
-
- GLfloat bb[4];
- nvpr.getPathParameterfv(d->path, GL_PATH_STROKE_BOUNDING_BOX_NV, bb);
- QSize sz = QSizeF(bb[2] - bb[0] + 1, bb[3] - bb[1] + 1).toSize();
- d->fallbackSize = QSize(qMax(32, sz.width()), qMax(32, sz.height()));
- d->fallbackTopLeft = QPointF(bb[0], bb[1]);
-
- if (d->fallbackFbo && d->fallbackFbo->size() != d->fallbackSize) {
- delete d->fallbackFbo;
- d->fallbackFbo = nullptr;
- }
- if (!d->fallbackFbo)
- d->fallbackFbo = new QOpenGLFramebufferObject(d->fallbackSize, QOpenGLFramebufferObject::CombinedDepthStencil);
- if (!d->fallbackFbo->bind())
- return;
-
- GLint prevViewport[4];
- f->glGetIntegerv(GL_VIEWPORT, prevViewport);
-
- f->glViewport(0, 0, d->fallbackSize.width(), d->fallbackSize.height());
- f->glDisable(GL_DEPTH_TEST);
- f->glClearColor(0, 0, 0, 0);
- f->glClearStencil(0);
- f->glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- f->glStencilFunc(GL_NOTEQUAL, 0, 0xFF);
- f->glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
-
- QMatrix4x4 mv;
- mv.translate(-d->fallbackTopLeft.x(), -d->fallbackTopLeft.y());
- nvpr.matrixLoadf(GL_PATH_MODELVIEW_NV, mv.constData());
- QMatrix4x4 proj;
- proj.ortho(0, d->fallbackSize.width(), d->fallbackSize.height(), 0, 1, -1);
- nvpr.matrixLoadf(GL_PATH_PROJECTION_NV, proj.constData());
-
- renderFill(d);
-
- d->fallbackFbo->release();
- f->glEnable(GL_DEPTH_TEST);
- f->glViewport(prevViewport[0], prevViewport[1], prevViewport[2], prevViewport[3]);
-
- d->fallbackValid = true;
-}
-
-void QQuickShapeNvprRenderNode::setupStencilForCover(bool stencilClip, int sv)
-{
- if (!stencilClip) {
- // Assume stencil buffer is cleared to 0 for each frame.
- // Within the frame dppass=GL_ZERO for glStencilOp ensures stencil is reset and so no need to clear.
- f->glStencilFunc(GL_NOTEQUAL, 0, 0xFF);
- f->glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
- } else {
- f->glStencilFunc(GL_LESS, sv, 0xFF); // pass if (sv & 0xFF) < (stencil_value & 0xFF)
- f->glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); // dppass: replace with the original value (clip's stencil ref value)
- }
-}
-
-void QQuickShapeNvprRenderNode::render(const RenderState *state)
-{
- f = QOpenGLContext::currentContext()->extraFunctions();
-
- if (!nvprInited) {
- if (!nvpr.create()) {
- qWarning("NVPR init failed");
- return;
- }
- mtlmgr.create(&nvpr);
- nvprInited = true;
- }
-
- f->glUseProgram(0);
- f->glStencilMask(~0);
- f->glEnable(GL_STENCIL_TEST);
-
- const bool stencilClip = state->stencilEnabled();
- // when true, the stencil buffer already has a clip path with a ref value of sv
- const int sv = state->stencilValue();
- const bool hasScissor = state->scissorEnabled();
-
- if (hasScissor) {
- // scissor rect is already set, just enable scissoring
- f->glEnable(GL_SCISSOR_TEST);
- }
-
- // Depth test against the opaque batches rendered before.
- f->glEnable(GL_DEPTH_TEST);
- f->glDepthFunc(GL_LESS);
- nvpr.pathCoverDepthFunc(GL_LESS);
- nvpr.pathStencilDepthOffset(-0.05f, -1);
-
- bool reloadMatrices = true;
-
- for (ShapePathRenderData &d : m_sp) {
- updatePath(&d);
-
- const bool hasFill = d.hasFill();
- const bool hasStroke = d.hasStroke();
-
- if (hasFill && stencilClip) {
- // Fall back to a texture when complex clipping is in use and we have
- // to fill. Reconciling glStencilFillPath's and the scenegraph's clip
- // stencil semantics has not succeeded so far...
- if (hasScissor)
- f->glDisable(GL_SCISSOR_TEST);
- renderOffscreenFill(&d);
- reloadMatrices = true;
- if (hasScissor)
- f->glEnable(GL_SCISSOR_TEST);
- }
-
- if (reloadMatrices) {
- reloadMatrices = false;
- nvpr.matrixLoadf(GL_PATH_MODELVIEW_NV, matrix()->constData());
- nvpr.matrixLoadf(GL_PATH_PROJECTION_NV, state->projectionMatrix()->constData());
- }
-
- // Fill!
- if (hasFill) {
- if (!stencilClip) {
- setupStencilForCover(false, 0);
- renderFill(&d);
- } else {
- if (!m_fallbackBlitter.isCreated())
- m_fallbackBlitter.create();
- f->glStencilFunc(GL_EQUAL, sv, 0xFF);
- f->glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
- QMatrix4x4 mv = *matrix();
- mv.translate(d.fallbackTopLeft.x(), d.fallbackTopLeft.y());
- m_fallbackBlitter.texturedQuad(d.fallbackFbo->texture(), d.fallbackFbo->size(),
- *state->projectionMatrix(), mv,
- inheritedOpacity());
- }
- }
-
- // Stroke!
- if (hasStroke) {
- const int strokeStencilValue = 0x80;
- const int writeMask = 0x80;
-
- setupStencilForCover(stencilClip, sv);
- if (stencilClip) {
- // for the stencil step (eff. read mask == 0xFF & ~writeMask)
- nvpr.pathStencilFunc(GL_EQUAL, sv, 0xFF);
- // With stencilCLip == true the read mask for the stencil test before the stencil step is 0x7F.
- // This assumes the clip stencil value is <= 127.
- if (sv >= strokeStencilValue)
- qWarning("Shape/NVPR: stencil clip ref value %d too large; expect rendering errors", sv);
- }
-
- renderStroke(&d, strokeStencilValue, writeMask);
- }
-
- if (stencilClip)
- nvpr.pathStencilFunc(GL_ALWAYS, 0, ~0);
-
- d.dirty = 0;
- }
-
- f->glBindProgramPipeline(0);
-}
-
-QSGRenderNode::StateFlags QQuickShapeNvprRenderNode::changedStates() const
-{
- return BlendState | StencilState | DepthState | ScissorState;
-}
-
-QSGRenderNode::RenderingFlags QQuickShapeNvprRenderNode::flags() const
-{
- return DepthAwareRendering; // avoid hitting the less optimal no-opaque-batch path in the renderer
-}
-
-bool QQuickShapeNvprRenderNode::isSupported()
-{
- static const bool nvprDisabled = qEnvironmentVariableIntValue("QT_NO_NVPR") != 0;
- return !nvprDisabled && QQuickNvprFunctions::isSupported();
-}
-
-bool QQuickNvprBlitter::create()
-{
- if (isCreated())
- destroy();
-
- m_program = new QOpenGLShaderProgram;
- if (QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile) {
- m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/shapes/shaders/blit_core.vert"));
- m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/shapes/shaders/blit_core.frag"));
- } else {
- m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/shapes/shaders/blit.vert"));
- m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/shapes/shaders/blit.frag"));
- }
- m_program->bindAttributeLocation("qt_Vertex", 0);
- m_program->bindAttributeLocation("qt_MultiTexCoord0", 1);
- if (!m_program->link())
- return false;
-
- m_matrixLoc = m_program->uniformLocation("qt_Matrix");
- m_opacityLoc = m_program->uniformLocation("qt_Opacity");
-
- m_buffer = new QOpenGLBuffer;
- if (!m_buffer->create())
- return false;
- m_buffer->bind();
- m_buffer->allocate(4 * sizeof(GLfloat) * 6);
- m_buffer->release();
-
- return true;
-}
-
-void QQuickNvprBlitter::destroy()
-{
- if (m_program) {
- delete m_program;
- m_program = nullptr;
- }
- if (m_buffer) {
- delete m_buffer;
- m_buffer = nullptr;
- }
-}
-
-void QQuickNvprBlitter::texturedQuad(GLuint textureId, const QSize &size,
- const QMatrix4x4 &proj, const QMatrix4x4 &modelview,
- float opacity)
-{
- QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions();
-
- m_program->bind();
-
- QMatrix4x4 m = proj * modelview;
- m_program->setUniformValue(m_matrixLoc, m);
- m_program->setUniformValue(m_opacityLoc, opacity);
-
- m_buffer->bind();
-
- if (size != m_prevSize) {
- m_prevSize = size;
-
- QPointF p0(size.width() - 1, size.height() - 1);
- QPointF p1(0, 0);
- QPointF p2(0, size.height() - 1);
- QPointF p3(size.width() - 1, 0);
-
- GLfloat vertices[6 * 4] = {
- GLfloat(p0.x()), GLfloat(p0.y()), 1, 0,
- GLfloat(p1.x()), GLfloat(p1.y()), 0, 1,
- GLfloat(p2.x()), GLfloat(p2.y()), 0, 0,
-
- GLfloat(p0.x()), GLfloat(p0.y()), 1, 0,
- GLfloat(p3.x()), GLfloat(p3.y()), 1, 1,
- GLfloat(p1.x()), GLfloat(p1.y()), 0, 1,
- };
-
- m_buffer->write(0, vertices, sizeof(vertices));
- }
-
- m_program->enableAttributeArray(0);
- m_program->enableAttributeArray(1);
- f->glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), nullptr);
- f->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (const void *) (2 * sizeof(GLfloat)));
-
- f->glBindTexture(GL_TEXTURE_2D, textureId);
-
- f->glDrawArrays(GL_TRIANGLES, 0, 6);
-
- f->glBindTexture(GL_TEXTURE_2D, 0);
- m_buffer->release();
- m_program->release();
-}
-
-QT_END_NAMESPACE
diff --git a/src/quickshapes/qquickshapenvprrenderer_p.h b/src/quickshapes/qquickshapenvprrenderer_p.h
deleted file mode 100644
index d40eb1bce9..0000000000
--- a/src/quickshapes/qquickshapenvprrenderer_p.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKSHAPENVPRRENDERER_P_H
-#define QQUICKSHAPENVPRRENDERER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of a number of Qt sources files. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtQuickShapes/private/qquickshapesglobal_p.h>
-#include <QtQuickShapes/private/qquickshape_p_p.h>
-#include <QtQuickShapes/private/qquicknvprfunctions_p.h>
-#include <qsgrendernode.h>
-#include <QColor>
-#include <QVector4D>
-#include <QDebug>
-
-#if QT_CONFIG(opengl)
-
-QT_BEGIN_NAMESPACE
-
-class QQuickShapeNvprRenderNode;
-class QOpenGLFramebufferObject;
-class QOpenGLBuffer;
-class QOpenGLExtraFunctions;
-
-class QQuickShapeNvprRenderer : public QQuickAbstractPathRenderer
-{
-public:
- enum Dirty {
- DirtyPath = 0x01,
- DirtyStyle = 0x02,
- DirtyFillRule = 0x04,
- DirtyDash = 0x08,
- DirtyFillGradient = 0x10,
- DirtyList = 0x20
- };
-
- void beginSync(int totalCount) override;
- void setPath(int index, const QQuickPath *path) override;
- void setStrokeColor(int index, const QColor &color) override;
- void setStrokeWidth(int index, qreal w) override;
- void setFillColor(int index, const QColor &color) override;
- void setFillRule(int index, QQuickShapePath::FillRule fillRule) override;
- void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override;
- void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override;
- void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle,
- qreal dashOffset, const QVector<qreal> &dashPattern) override;
- void setFillGradient(int index, QQuickShapeGradient *gradient) override;
- void endSync(bool async) override;
-
- void updateNode() override;
-
- void setNode(QQuickShapeNvprRenderNode *node);
-
- struct NvprPath {
- QVector<GLubyte> cmd;
- QVector<GLfloat> coord;
- QByteArray str;
- };
-
-private:
- struct ShapePathGuiData {
- int dirty = 0;
- NvprPath path;
- qreal strokeWidth;
- QColor strokeColor;
- QColor fillColor;
- QQuickShapePath::JoinStyle joinStyle;
- int miterLimit;
- QQuickShapePath::CapStyle capStyle;
- QQuickShapePath::FillRule fillRule;
- bool dashActive;
- qreal dashOffset;
- QVector<qreal> dashPattern;
- FillGradientType fillGradientActive;
- GradientDesc fillGradient;
- };
-
- void convertPath(const QQuickPath *path, ShapePathGuiData *d);
-
- QQuickShapeNvprRenderNode *m_node = nullptr;
- int m_accDirty = 0;
-
- QVector<ShapePathGuiData> m_sp;
-};
-
-QDebug operator<<(QDebug debug, const QQuickShapeNvprRenderer::NvprPath &path);
-
-class QQuickNvprMaterialManager
-{
-public:
- enum Material {
- MatSolid,
- MatLinearGradient,
- MatRadialGradient,
- MatConicalGradient,
-
- NMaterials
- };
-
- struct MaterialDesc {
- GLuint ppl = 0;
- GLuint prg = 0;
- int uniLoc[8];
- };
-
- void create(QQuickNvprFunctions *nvpr);
- MaterialDesc *activateMaterial(Material m);
- void releaseResources();
-
-private:
- QQuickNvprFunctions *m_nvpr = nullptr;
- MaterialDesc m_materials[NMaterials];
-};
-
-class QQuickNvprBlitter
-{
-public:
- bool create();
- void destroy();
- bool isCreated() const { return m_program != nullptr; }
- void texturedQuad(GLuint textureId, const QSize &size,
- const QMatrix4x4 &proj, const QMatrix4x4 &modelview,
- float opacity);
-
-private:
- QOpenGLShaderProgram *m_program = nullptr;
- QOpenGLBuffer *m_buffer = nullptr;
- int m_matrixLoc = -1;
- int m_opacityLoc = -1;
- QSize m_prevSize;
-};
-
-class QQuickShapeNvprRenderNode : public QSGRenderNode
-{
-public:
- ~QQuickShapeNvprRenderNode();
-
- void render(const RenderState *state) override;
- void releaseResources() override;
- StateFlags changedStates() const override;
- RenderingFlags flags() const override;
-
- static bool isSupported();
-
-private:
- struct ShapePathRenderData {
- GLuint path = 0;
- int dirty = 0;
- QQuickShapeNvprRenderer::NvprPath source;
- GLfloat strokeWidth;
- QVector4D strokeColor;
- QVector4D fillColor;
- GLenum joinStyle;
- GLint miterLimit;
- GLenum capStyle;
- GLenum fillRule;
- GLfloat dashOffset;
- QVector<GLfloat> dashPattern;
- QQuickAbstractPathRenderer::FillGradientType fillGradientActive;
- QQuickAbstractPathRenderer::GradientDesc fillGradient;
- QOpenGLFramebufferObject *fallbackFbo = nullptr;
- bool fallbackValid = false;
- QSize fallbackSize;
- QPointF fallbackTopLeft;
-
- bool hasFill() const { return !qFuzzyIsNull(fillColor.w()) || fillGradientActive; }
- bool hasStroke() const { return strokeWidth >= 0.0f && !qFuzzyIsNull(strokeColor.w()); }
- };
-
- void updatePath(ShapePathRenderData *d);
- void renderStroke(ShapePathRenderData *d, int strokeStencilValue, int writeMask);
- void renderFill(ShapePathRenderData *d);
- void renderOffscreenFill(ShapePathRenderData *d);
- void setupStencilForCover(bool stencilClip, int sv);
-
- static bool nvprInited;
- static QQuickNvprFunctions nvpr;
- static QQuickNvprMaterialManager mtlmgr;
-
- QQuickNvprBlitter m_fallbackBlitter;
- QOpenGLExtraFunctions *f = nullptr;
-
- QVector<ShapePathRenderData> m_sp;
-
- friend class QQuickShapeNvprRenderer;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_CONFIG(opengl)
-
-#endif // QQUICKSHAPENVPRRENDERER_P_H
diff --git a/src/quickshapes/qtquickshapes.qrc b/src/quickshapes/qtquickshapes.qrc
index 1e3dcdef4e..2484d62d22 100644
--- a/src/quickshapes/qtquickshapes.qrc
+++ b/src/quickshapes/qtquickshapes.qrc
@@ -1,25 +1,9 @@
<RCC>
<qresource prefix="/qt-project.org/shapes">
- <file>shaders/blit.vert</file>
- <file>shaders/blit.frag</file>
- <file>shaders/blit_core.frag</file>
- <file>shaders/blit_core.vert</file>
- <file>shaders/lineargradient.vert</file>
- <file>shaders/lineargradient.frag</file>
- <file>shaders/lineargradient_core.vert</file>
- <file>shaders/lineargradient_core.frag</file>
<file>shaders_ng/lineargradient.vert.qsb</file>
<file>shaders_ng/lineargradient.frag.qsb</file>
- <file>shaders/radialgradient.vert</file>
- <file>shaders/radialgradient.frag</file>
- <file>shaders/radialgradient_core.vert</file>
- <file>shaders/radialgradient_core.frag</file>
<file>shaders_ng/radialgradient.vert.qsb</file>
<file>shaders_ng/radialgradient.frag.qsb</file>
- <file>shaders/conicalgradient.vert</file>
- <file>shaders/conicalgradient.frag</file>
- <file>shaders/conicalgradient_core.vert</file>
- <file>shaders/conicalgradient_core.frag</file>
<file>shaders_ng/conicalgradient.vert.qsb</file>
<file>shaders_ng/conicalgradient.frag.qsb</file>
</qresource>
diff --git a/src/quickshapes/quickshapes.pro b/src/quickshapes/quickshapes.pro
index 7b77391d92..c53d267df6 100644
--- a/src/quickshapes/quickshapes.pro
+++ b/src/quickshapes/quickshapes.pro
@@ -17,17 +17,6 @@ SOURCES += \
qquickshapegenericrenderer.cpp \
qquickshapesoftwarerenderer.cpp
-qtConfig(opengl) {
- HEADERS += \
- qquicknvprfunctions_p.h \
- qquicknvprfunctions_p_p.h \
- qquickshapenvprrenderer_p.h
-
- SOURCES += \
- qquicknvprfunctions.cpp \
- qquickshapenvprrenderer.cpp
-}
-
RESOURCES += qtquickshapes.qrc
load(qt_module)
diff --git a/src/quickshapes/shaders/blit.frag b/src/quickshapes/shaders/blit.frag
deleted file mode 100644
index 505f0db179..0000000000
--- a/src/quickshapes/shaders/blit.frag
+++ /dev/null
@@ -1,9 +0,0 @@
-varying highp vec2 qt_TexCoord0;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-
-void main()
-{
- gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity;
-}
diff --git a/src/quickshapes/shaders/blit.vert b/src/quickshapes/shaders/blit.vert
deleted file mode 100644
index f8306bd945..0000000000
--- a/src/quickshapes/shaders/blit.vert
+++ /dev/null
@@ -1,12 +0,0 @@
-uniform highp mat4 qt_Matrix;
-
-attribute highp vec4 qt_Vertex;
-attribute highp vec2 qt_MultiTexCoord0;
-
-varying highp vec2 qt_TexCoord0;
-
-void main()
-{
- qt_TexCoord0 = qt_MultiTexCoord0;
- gl_Position = qt_Matrix * qt_Vertex;
-}
diff --git a/src/quickshapes/shaders/blit_core.frag b/src/quickshapes/shaders/blit_core.frag
deleted file mode 100644
index 7073808fba..0000000000
--- a/src/quickshapes/shaders/blit_core.frag
+++ /dev/null
@@ -1,13 +0,0 @@
-#version 150 core
-
-in vec2 qt_TexCoord0;
-
-out vec4 fragColor;
-
-uniform sampler2D source;
-uniform float qt_Opacity;
-
-void main()
-{
- fragColor = texture(source, qt_TexCoord0) * qt_Opacity;
-}
diff --git a/src/quickshapes/shaders/blit_core.vert b/src/quickshapes/shaders/blit_core.vert
deleted file mode 100644
index 5246441da3..0000000000
--- a/src/quickshapes/shaders/blit_core.vert
+++ /dev/null
@@ -1,14 +0,0 @@
-#version 150 core
-
-in vec4 qt_Vertex;
-in vec2 qt_MultiTexCoord0;
-
-out vec2 qt_TexCoord0;
-
-uniform mat4 qt_Matrix;
-
-void main()
-{
- qt_TexCoord0 = qt_MultiTexCoord0;
- gl_Position = qt_Matrix * qt_Vertex;
-}
diff --git a/src/quickshapes/shaders/conicalgradient.frag b/src/quickshapes/shaders/conicalgradient.frag
deleted file mode 100644
index af5fdd5ee0..0000000000
--- a/src/quickshapes/shaders/conicalgradient.frag
+++ /dev/null
@@ -1,19 +0,0 @@
-#define INVERSE_2PI 0.1591549430918953358
-
-uniform sampler2D gradTabTexture;
-uniform lowp float opacity;
-
-uniform highp float angle;
-
-varying highp vec2 coord;
-
-void main()
-{
- highp float t;
- if (abs(coord.y) == abs(coord.x))
- t = (atan(-coord.y + 0.002, coord.x) + angle) * INVERSE_2PI;
- else
- t = (atan(-coord.y, coord.x) + angle) * INVERSE_2PI;
- gl_FragColor = texture2D(gradTabTexture, vec2(t - floor(t), 0.5)) * opacity;
-
-}
diff --git a/src/quickshapes/shaders/conicalgradient.vert b/src/quickshapes/shaders/conicalgradient.vert
deleted file mode 100644
index 3350b0675a..0000000000
--- a/src/quickshapes/shaders/conicalgradient.vert
+++ /dev/null
@@ -1,13 +0,0 @@
-attribute vec4 vertexCoord;
-attribute vec4 vertexColor;
-
-uniform mat4 matrix;
-uniform vec2 translationPoint;
-
-varying vec2 coord;
-
-void main()
-{
- coord = vertexCoord.xy - translationPoint;
- gl_Position = matrix * vertexCoord;
-}
diff --git a/src/quickshapes/shaders/conicalgradient_core.frag b/src/quickshapes/shaders/conicalgradient_core.frag
deleted file mode 100644
index e18b80159a..0000000000
--- a/src/quickshapes/shaders/conicalgradient_core.frag
+++ /dev/null
@@ -1,22 +0,0 @@
-#version 150 core
-
-#define INVERSE_2PI 0.1591549430918953358
-
-uniform sampler2D gradTabTexture;
-uniform float opacity;
-
-uniform float angle;
-
-in vec2 coord;
-
-out vec4 fragColor;
-
-void main()
-{
- float t;
- if (abs(coord.y) == abs(coord.x))
- t = (atan(-coord.y + 0.002, coord.x) + angle) * INVERSE_2PI;
- else
- t = (atan(-coord.y, coord.x) + angle) * INVERSE_2PI;
- fragColor = texture(gradTabTexture, vec2(t - floor(t), 0.5)) * opacity;
-}
diff --git a/src/quickshapes/shaders/conicalgradient_core.vert b/src/quickshapes/shaders/conicalgradient_core.vert
deleted file mode 100644
index f94a56401b..0000000000
--- a/src/quickshapes/shaders/conicalgradient_core.vert
+++ /dev/null
@@ -1,15 +0,0 @@
-#version 150 core
-
-in vec4 vertexCoord;
-in vec4 vertexColor;
-
-uniform mat4 matrix;
-uniform vec2 translationPoint;
-
-out vec2 coord;
-
-void main()
-{
- coord = vertexCoord.xy - translationPoint;
- gl_Position = matrix * vertexCoord;
-}
diff --git a/src/quickshapes/shaders/lineargradient.frag b/src/quickshapes/shaders/lineargradient.frag
deleted file mode 100644
index 7f4a739109..0000000000
--- a/src/quickshapes/shaders/lineargradient.frag
+++ /dev/null
@@ -1,9 +0,0 @@
-uniform sampler2D gradTabTexture;
-uniform highp float opacity;
-
-varying highp float gradTabIndex;
-
-void main()
-{
- gl_FragColor = texture2D(gradTabTexture, vec2(gradTabIndex, 0.5)) * opacity;
-}
diff --git a/src/quickshapes/shaders/lineargradient.vert b/src/quickshapes/shaders/lineargradient.vert
deleted file mode 100644
index eb21b8886b..0000000000
--- a/src/quickshapes/shaders/lineargradient.vert
+++ /dev/null
@@ -1,15 +0,0 @@
-attribute vec4 vertexCoord;
-attribute vec4 vertexColor;
-
-uniform mat4 matrix;
-uniform vec2 gradStart;
-uniform vec2 gradEnd;
-
-varying float gradTabIndex;
-
-void main()
-{
- vec2 gradVec = gradEnd - gradStart;
- gradTabIndex = dot(gradVec, vertexCoord.xy - gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y);
- gl_Position = matrix * vertexCoord;
-}
diff --git a/src/quickshapes/shaders/lineargradient_core.frag b/src/quickshapes/shaders/lineargradient_core.frag
deleted file mode 100644
index 5908acfa67..0000000000
--- a/src/quickshapes/shaders/lineargradient_core.frag
+++ /dev/null
@@ -1,12 +0,0 @@
-#version 150 core
-
-uniform sampler2D gradTabTexture;
-uniform float opacity;
-
-in float gradTabIndex;
-out vec4 fragColor;
-
-void main()
-{
- fragColor = texture(gradTabTexture, vec2(gradTabIndex, 0.5)) * opacity;
-}
diff --git a/src/quickshapes/shaders/lineargradient_core.vert b/src/quickshapes/shaders/lineargradient_core.vert
deleted file mode 100644
index 60b56f38e3..0000000000
--- a/src/quickshapes/shaders/lineargradient_core.vert
+++ /dev/null
@@ -1,17 +0,0 @@
-#version 150 core
-
-in vec4 vertexCoord;
-in vec4 vertexColor;
-
-uniform mat4 matrix;
-uniform vec2 gradStart;
-uniform vec2 gradEnd;
-
-out float gradTabIndex;
-
-void main()
-{
- vec2 gradVec = gradEnd - gradStart;
- gradTabIndex = dot(gradVec, vertexCoord.xy - gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y);
- gl_Position = matrix * vertexCoord;
-}
diff --git a/src/quickshapes/shaders/radialgradient.frag b/src/quickshapes/shaders/radialgradient.frag
deleted file mode 100644
index 0f503bc0f7..0000000000
--- a/src/quickshapes/shaders/radialgradient.frag
+++ /dev/null
@@ -1,25 +0,0 @@
-uniform sampler2D gradTabTexture;
-uniform lowp float opacity;
-
-uniform highp vec2 focalToCenter;
-uniform highp float centerRadius;
-uniform highp float focalRadius;
-
-varying highp vec2 coord;
-
-void main()
-{
- highp float rd = centerRadius - focalRadius;
- highp float b = 2.0 * (rd * focalRadius + dot(coord, focalToCenter));
- highp float fmp2_m_radius2 = -focalToCenter.x * focalToCenter.x - focalToCenter.y * focalToCenter.y + rd * rd;
- highp float inverse_2_fmp2_m_radius2 = 1.0 / (2.0 * fmp2_m_radius2);
- highp float det = b * b - 4.0 * fmp2_m_radius2 * ((focalRadius * focalRadius) - dot(coord, coord));
- lowp vec4 result = vec4(0.0);
- if (det >= 0.0) {
- highp float detSqrt = sqrt(det);
- highp float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2);
- if (focalRadius + w * (centerRadius - focalRadius) >= 0.0)
- result = texture2D(gradTabTexture, vec2(w, 0.5)) * opacity;
- }
- gl_FragColor = result;
-}
diff --git a/src/quickshapes/shaders/radialgradient.vert b/src/quickshapes/shaders/radialgradient.vert
deleted file mode 100644
index 3350b0675a..0000000000
--- a/src/quickshapes/shaders/radialgradient.vert
+++ /dev/null
@@ -1,13 +0,0 @@
-attribute vec4 vertexCoord;
-attribute vec4 vertexColor;
-
-uniform mat4 matrix;
-uniform vec2 translationPoint;
-
-varying vec2 coord;
-
-void main()
-{
- coord = vertexCoord.xy - translationPoint;
- gl_Position = matrix * vertexCoord;
-}
diff --git a/src/quickshapes/shaders/radialgradient_core.frag b/src/quickshapes/shaders/radialgradient_core.frag
deleted file mode 100644
index 706ce53e4d..0000000000
--- a/src/quickshapes/shaders/radialgradient_core.frag
+++ /dev/null
@@ -1,29 +0,0 @@
-#version 150 core
-
-uniform sampler2D gradTabTexture;
-uniform float opacity;
-
-uniform vec2 focalToCenter;
-uniform float centerRadius;
-uniform float focalRadius;
-
-in vec2 coord;
-
-out vec4 fragColor;
-
-void main()
-{
- float rd = centerRadius - focalRadius;
- float b = 2.0 * (rd * focalRadius + dot(coord, focalToCenter));
- float fmp2_m_radius2 = -focalToCenter.x * focalToCenter.x - focalToCenter.y * focalToCenter.y + rd * rd;
- float inverse_2_fmp2_m_radius2 = 1.0 / (2.0 * fmp2_m_radius2);
- float det = b * b - 4.0 * fmp2_m_radius2 * ((focalRadius * focalRadius) - dot(coord, coord));
- vec4 result = vec4(0.0);
- if (det >= 0.0) {
- float detSqrt = sqrt(det);
- float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2);
- if (focalRadius + w * (centerRadius - focalRadius) >= 0.0)
- result = texture(gradTabTexture, vec2(w, 0.5)) * opacity;
- }
- fragColor = result;
-}
diff --git a/src/quickshapes/shaders/radialgradient_core.vert b/src/quickshapes/shaders/radialgradient_core.vert
deleted file mode 100644
index f94a56401b..0000000000
--- a/src/quickshapes/shaders/radialgradient_core.vert
+++ /dev/null
@@ -1,15 +0,0 @@
-#version 150 core
-
-in vec4 vertexCoord;
-in vec4 vertexColor;
-
-uniform mat4 matrix;
-uniform vec2 translationPoint;
-
-out vec2 coord;
-
-void main()
-{
- coord = vertexCoord.xy - translationPoint;
- gl_Position = matrix * vertexCoord;
-}