summaryrefslogtreecommitdiffstats
path: root/src/render/materialsystem
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/materialsystem')
-rw-r--r--src/render/materialsystem/qeffect.cpp40
-rw-r--r--src/render/materialsystem/qfilterkey.cpp40
-rw-r--r--src/render/materialsystem/qmaterial.cpp80
-rw-r--r--src/render/materialsystem/qrenderpass.cpp112
-rw-r--r--src/render/materialsystem/qrenderpass.h4
-rw-r--r--src/render/materialsystem/qshaderprogram.cpp139
-rw-r--r--src/render/materialsystem/qtechnique.cpp92
-rw-r--r--src/render/materialsystem/shaderdata.cpp195
-rw-r--r--src/render/materialsystem/shaderdata_p.h25
9 files changed, 383 insertions, 344 deletions
diff --git a/src/render/materialsystem/qeffect.cpp b/src/render/materialsystem/qeffect.cpp
index 70810676c..7778b5621 100644
--- a/src/render/materialsystem/qeffect.cpp
+++ b/src/render/materialsystem/qeffect.cpp
@@ -58,12 +58,17 @@ QEffectPrivate::QEffectPrivate()
}
/*!
- \class Qt3DRender::QEffect
- \inmodule Qt3DRender
- \since 5.7
- \brief The base class for effects in a Qt 3D scene.
+ \class Qt3DRender::QEffect
+ \inmodule Qt3DRender
+ \inherits Qt3DCore::QNode
+ \since 5.7
+ \brief The base class for effects in a Qt 3D scene.
- */
+ The QEffect class combines a set of techniques and parameters used by those techniques to
+ produce a rendering effect for a material.
+
+ \sa QMaterial, QTechnique, QParameter
+*/
/*!
\qmltype Effect
@@ -72,18 +77,18 @@ QEffectPrivate::QEffectPrivate()
\inqmlmodule Qt3D.Render
\since 5.7
\brief The base class for effects in a Qt 3D scene.
+
+ The Effect type combines a set of techniques and parameters used by those techniques to
+ produce a rendering effect for a material.
+
+ \sa Material, Technique, Parameter
*/
-/*!
- \fn Qt3DRender::QEffect::QEffect(Qt3DCore::QNode *parent)
- Constructs a new QEffect with the specified \a parent.
- */
QEffect::QEffect(QNode *parent)
: QNode(*new QEffectPrivate, parent)
{
}
-/*! \internal */
QEffect::~QEffect()
{
}
@@ -95,8 +100,21 @@ QEffect::QEffect(QEffectPrivate &dd, QNode *parent)
}
/*!
+ \qmlproperty list<Technique> Effect::techniques
+
+ Holds the list of techniques used by this effect.
+*/
+/*!
+ \qmlproperty list<Parameter> Effect::parameters
+
+ Holds the list of parameters used by this effect.
+ A parameter is used to set a corresponding uniform value in the shader used by this effect.
+*/
+
+/*!
* Adds \a parameter to the effect. It sends a QPropertyNodeAddedChange to the backend.
- * The \a parameter will be used to set a corresponding uniform value in the shader used by this effect.
+ * The \a parameter will be used to set a corresponding uniform value in the shader used
+ * by this effect.
*/
void QEffect::addParameter(QParameter *parameter)
{
diff --git a/src/render/materialsystem/qfilterkey.cpp b/src/render/materialsystem/qfilterkey.cpp
index d4bc26515..547c56d26 100644
--- a/src/render/materialsystem/qfilterkey.cpp
+++ b/src/render/materialsystem/qfilterkey.cpp
@@ -55,8 +55,12 @@ QFilterKeyPrivate::QFilterKeyPrivate()
/*!
\class Qt3DRender::QFilterKey
\inmodule Qt3DRender
+ \inherits Qt3DCore::QNode
\since 5.5
- \brief The QFilterKey class provides storage for filter keys and their values
+ \brief The QFilterKey class provides storage for filter keys and their values.
+
+ Filter keys are used by QTechnique and QRenderPass to specify at which stage of rendering the
+ technique or the render pass is used.
*/
/*!
@@ -65,18 +69,18 @@ QFilterKeyPrivate::QFilterKeyPrivate()
\inherits Node
\inqmlmodule Qt3D.Render
\since 5.5
- \brief For storing filter keys and their value
+ \brief Stores filter keys and their values.
+
+ A FilterKey is a storage type for filter key and value pair.
+ Filter keys are used by Technique and RenderPass to specify at which stage of rendering the
+ technique or the render pass is used.
*/
-/*!
- The constructor creates a new QFilterKey under \a parent.
- */
QFilterKey::QFilterKey(QNode *parent)
: QNode(*new QFilterKeyPrivate, parent)
{
}
-/*! \internal */
QFilterKey::~QFilterKey()
{
}
@@ -100,13 +104,15 @@ void QFilterKey::setName(const QString &name)
}
/*!
- \property QFilterKey::value
- Specifies the value of the filter key
+ \property QFilterKey::value
+
+ Holds the value of the filter key.
*/
/*!
- \qmlproperty variant Qt3D.Render::Annotation::value
- Specifies the value of the filter key
+ \qmlproperty variant FilterKey::value
+
+ Holds the value of the filter key.
*/
QVariant QFilterKey::value() const
@@ -116,14 +122,16 @@ QVariant QFilterKey::value() const
}
/*!
- \property QFilterKey::name
- Specifies the name of the filter key
- */
+ \property QFilterKey::name
+
+ Holds the name of the filter key.
+*/
/*!
- \qmlproperty string Qt3D.Render::Annotation::name
- Specifies the name of the filter key
- */
+ \qmlproperty string FilterKey::name
+
+ Holds the name of the filter key.
+*/
QString QFilterKey::name() const
{
diff --git a/src/render/materialsystem/qmaterial.cpp b/src/render/materialsystem/qmaterial.cpp
index 5b3fe63af..ca0f86463 100644
--- a/src/render/materialsystem/qmaterial.cpp
+++ b/src/render/materialsystem/qmaterial.cpp
@@ -48,29 +48,37 @@
#include <Qt3DCore/qpropertynoderemovedchange.h>
/*!
- * \qmltype Material
- * \instantiates Qt3DRender::QMaterial
- * \inqmlmodule Qt3D.Render
- * \brief Non-creatable abstract base for materials.
- * \inherits Component
- */
+ \qmltype Material
+ \instantiates Qt3DRender::QMaterial
+ \inqmlmodule Qt3D.Render
+ \brief Non-creatable abstract base for materials.
+ \since 5.5
+
+ Material provides a way to specify the rendering of an \l{Qt3D.Core::Entity}{entity}.
+ Any aspect can define its own subtype of Material so that a
+ Material can be used to describe a visual element; for example, the way
+ sound should reflect off an element, the temperature of a surface,
+ and so on.
+
+ \sa Effect
+*/
/*!
- * \class Qt3DRender::QMaterial
- * \inmodule Qt3DRender
- *
- *
- * \brief Provides an abstract class that should be the base of all
- * Material component classes in a scene.
- *
- * QMaterial provides a way to specify the rendering of an Entity.
- * Any aspect can define its own subclass of QMaterial so that a
- * Material can be used to describe a visual element; for example, the way
- * sound should reflect off an element, the temperature of a surface,
- * and so on.
- *
- * \sa QEffect, QMesh, {Qt3DCore::}{QComponent}
- */
+ \class Qt3DRender::QMaterial
+ \inmodule Qt3DRender
+ \inherits Qt3DCore::QComponent
+ \brief Provides an abstract class that should be the base of all material component classes
+ in a scene.
+ \since 5.5
+
+ QMaterial provides a way to specify the rendering of an \l{Qt3DCore::QEntity}{entity}.
+ Any aspect can define its own subclass of QMaterial so that a
+ Material can be used to describe a visual element; for example, the way
+ sound should reflect off an element, the temperature of a surface,
+ and so on.
+
+ \sa QEffect
+*/
QT_BEGIN_NAMESPACE
@@ -88,16 +96,11 @@ QMaterialPrivate::~QMaterialPrivate()
{
}
-/*!
- \fn Qt3DRender::QMaterial::QMaterial(Qt3DCore::QNode *parent)
- Constructs a new QMaterial with the specified \a parent.
- */
QMaterial::QMaterial(QNode *parent)
: QComponent(*new QMaterialPrivate, parent)
{
}
-/*! \internal */
QMaterial::~QMaterial()
{
}
@@ -109,16 +112,20 @@ QMaterial::QMaterial(QMaterialPrivate &dd, QNode *parent)
}
/*!
- \qmlproperty QEffect Qt3D.Render::Material::effect
- Specifies the effect to be used with the material
+ \qmlproperty list<Parameter> Material::parameters
+
+ Holds the list of parameters used by the material.
*/
/*!
- \property Qt3DRender::QMaterial::effect
- Specifies the effect to be used with the material
- */
+ \qmlproperty Effect Material::effect
+
+ Specifies the effect to be used with the material.
+*/
/*!
- * Sets the \a effect to be used with the Material.
+ \property QMaterial::effect
+
+ Specifies the effect to be used with the material.
*/
void QMaterial::setEffect(QEffect *effect)
{
@@ -144,9 +151,6 @@ void QMaterial::setEffect(QEffect *effect)
}
}
-/*!
- * Returns the effect used by the Material.
- */
QEffect *QMaterial::effect() const
{
Q_D(const QMaterial);
@@ -154,7 +158,7 @@ QEffect *QMaterial::effect() const
}
/*!
- * Add \a parameter to the Materials parameter.
+ * Add a \a parameter to the material's parameters.
*/
void QMaterial::addParameter(QParameter *parameter)
{
@@ -182,7 +186,7 @@ void QMaterial::addParameter(QParameter *parameter)
}
/*!
- * Remove \a parameter from the Material parameters.
+ * Remove a \a parameter from the material's parameters.
*/
void QMaterial::removeParameter(QParameter *parameter)
{
@@ -197,7 +201,7 @@ void QMaterial::removeParameter(QParameter *parameter)
}
/*!
- * Returns a vector of the materials current parameters
+ * Returns a vector of the material's current parameters
*/
QVector<QParameter *> QMaterial::parameters() const
{
diff --git a/src/render/materialsystem/qrenderpass.cpp b/src/render/materialsystem/qrenderpass.cpp
index b10660730..dd6363816 100644
--- a/src/render/materialsystem/qrenderpass.cpp
+++ b/src/render/materialsystem/qrenderpass.cpp
@@ -60,19 +60,65 @@ QRenderPassPrivate::QRenderPassPrivate()
{
}
/*!
- * \qmltype RenderPass
- * \instantiates Qt3DRender::QRenderPass
- * \inqmlmodule Qt3D.Render
- * \brief Encapsulates a Render Pass.
+ \qmltype RenderPass
+ \instantiates Qt3DRender::QRenderPass
+ \inqmlmodule Qt3D.Render
+ \inherits Node
+ \since 5.7
+ \brief Encapsulates a Render Pass.
+
+ A RenderPass specifies a single rendering pass - an instance of shader program
+ execution - used by Technique. A Render pass consists of a ShaderProgram and
+ a list of FilterKey objects, a list of RenderState objects and a list
+ of \l Parameter objects.
+
+ RenderPass executes the ShaderProgram using the given render states and parameters
+ when its filter keys match the filter keys in RenderPassFilter or when no filter
+ keys are specified and no RenderPassFilter is present in the FrameGraph.
*/
/*!
- * \class Qt3DRender::QRenderPass
- * \inmodule Qt3DRender
- *
- * \inherits Node
- *
- * \brief Encapsulates a Render Pass.
+ \class Qt3DRender::QRenderPass
+ \inmodule Qt3DRender
+ \since 5.7
+ \brief Encapsulates a Render Pass.
+
+ A Qt3DRender::QRenderPass specifies a single rendering pass - an instance of shader
+ program execution - used by Qt3DRender::QTechnique. Render pass consists
+ of a Qt3DRender::QShaderProgram and a list of Qt3DRender::QFilterKey objects,
+ a list of Qt3DRender::QRenderState objects and a list of Qt3DRender::QParameter objects.
+
+ QRenderPass executes the QShaderProgram using the given render states and parameters
+ when its filter keys match the filter keys in Qt3DRender::QRenderPassFilter or
+ when no filter keys are specified and no QRenderPassFilter is present
+ in the FrameGraph.
+ */
+/*!
+ \typedef ParameterList
+ \relates Qt3DRender::QRenderPass
+
+ A list of Qt3DRender::QParameter parameters.
+*/
+/*!
+ \qmlproperty ShaderProgram Qt3D.Render::RenderPass::shaderProgram
+ Holds the shader program to be used for this render pass.
+*/
+/*!
+ \qmlproperty list<FilterKey> Qt3D.Render::RenderPass::filterKeys
+ Holds the filter keys enabling the use of this render pass.
+*/
+/*!
+ \qmlproperty list<RenderState> Qt3D.Render::RenderPass::renderStates
+ Holds the render states used by the render pass.
+*/
+/*!
+ \qmlproperty list<Parameter> Qt3D.Render::RenderPass::parameters
+ Holds the shader parameter values used by the render pass.
+*/
+
+/*!
+ \property Qt3DRender::QRenderPass::shaderProgram
+ Specifies the shader program to be used for this render pass.
*/
/*!
@@ -95,18 +141,6 @@ QRenderPass::QRenderPass(QRenderPassPrivate &dd, QNode *parent)
{
}
-/*!
- \qmlproperty ShaderProgram Qt3D.Render::RenderPass::shaderProgram
- Specifies the shader program to be used for this render pass
-*/
-
-/*!
- \property Qt3DRender::QRenderPass::shaderProgram
- Specifies the shader program to be used for this render pass
- */
-/*!
- * Sets the pass' \a shaderProgram.
- */
void QRenderPass::setShaderProgram(QShaderProgram *shaderProgram)
{
Q_D(QRenderPass);
@@ -145,7 +179,7 @@ QShaderProgram *QRenderPass::shaderProgram() const
}
/*!
- * Adds \a filterKey from to the Qt3DRender::QRenderPass local filter keys.
+ Adds \a filterKey to the Qt3DRender::QRenderPass local filter keys.
*/
void QRenderPass::addFilterKey(QFilterKey *filterKey)
{
@@ -173,7 +207,7 @@ void QRenderPass::addFilterKey(QFilterKey *filterKey)
}
/*!
- * Removes \a filterKey from the Qt3DRender::QRenderPass local filter keys.
+ Removes \a filterKey from the Qt3DRender::QRenderPass local filter keys.
*/
void QRenderPass::removeFilterKey(QFilterKey *filterKey)
{
@@ -190,8 +224,8 @@ void QRenderPass::removeFilterKey(QFilterKey *filterKey)
}
/*!
- * Returns the list of Qt3DCore::QFilterKey key objects making up the filter keys
- * of the Qt3DRender::QRenderPass.
+ Returns the list of Qt3DRender::QFilterKey key objects making up the filter keys
+ of the Qt3DRender::QRenderPass.
*/
QVector<QFilterKey *> QRenderPass::filterKeys() const
{
@@ -200,12 +234,12 @@ QVector<QFilterKey *> QRenderPass::filterKeys() const
}
/*!
- * Adds a Qt3DCore::QRenderState \a state to the rendering pass. That implies that
- * when the pass is executed at render time, the globally set render state will
- * be modifed by the states defined locally by the Qt3DRender::QRenderPass.
- *
- * \note not defining any Qt3DCore::QRenderState in a pass will result in the pass using
- * the globally set render state for a given FrameGraph branch execution path.
+ Adds a render \a state to the rendering pass. That implies that
+ when the pass is executed at render time, the globally set render state will
+ be modifed by the states defined locally by the Qt3DRender::QRenderPass.
+
+ \note not defining any Qt3DRender::QRenderState in a pass will result in the pass using
+ the globally set render state for a given FrameGraph branch execution path.
*/
void QRenderPass::addRenderState(QRenderState *state)
{
@@ -229,7 +263,7 @@ void QRenderPass::addRenderState(QRenderState *state)
}
/*!
- * Removes \a state from the Qt3DRender::QRenderPass local render state.
+ Removes \a state from the Qt3DRender::QRenderPass local render state.
*/
void QRenderPass::removeRenderState(QRenderState *state)
{
@@ -246,8 +280,8 @@ void QRenderPass::removeRenderState(QRenderState *state)
}
/*!
- * Returns the list of Qt3DCore::QRenderState state objects making up the render
- * state of the Qt3DRender::QRenderPass.
+ Returns the list of Qt3DRender::QRenderState state objects making up the render
+ state of the Qt3DRender::QRenderPass.
*/
QVector<QRenderState *> QRenderPass::renderStates() const
{
@@ -256,7 +290,7 @@ QVector<QRenderState *> QRenderPass::renderStates() const
}
/*!
- * Add \a parameter to the render pass' parameters.
+ Add \a parameter to the render pass' parameters.
*/
void QRenderPass::addParameter(QParameter *parameter)
{
@@ -284,7 +318,7 @@ void QRenderPass::addParameter(QParameter *parameter)
}
/*!
- * Remove \a parameter from the render pass' parameters.
+ Remove \a parameter from the render pass' parameters.
*/
void QRenderPass::removeParameter(QParameter *parameter)
{
@@ -301,9 +335,9 @@ void QRenderPass::removeParameter(QParameter *parameter)
}
/*!
- * Returns a vector of the render pass' current parameters
+ Returns a vector of the render pass' current parameters
*/
-QVector<QParameter *> QRenderPass::parameters() const
+ParameterList QRenderPass::parameters() const
{
Q_D(const QRenderPass);
return d->m_parameters;
diff --git a/src/render/materialsystem/qrenderpass.h b/src/render/materialsystem/qrenderpass.h
index e2eb96a9a..9c608d0c4 100644
--- a/src/render/materialsystem/qrenderpass.h
+++ b/src/render/materialsystem/qrenderpass.h
@@ -70,8 +70,8 @@ public:
QShaderProgram *shaderProgram() const;
- void addFilterKey(QFilterKey*filterKey);
- void removeFilterKey(QFilterKey*filterKey);
+ void addFilterKey(QFilterKey *filterKey);
+ void removeFilterKey(QFilterKey *filterKey);
QVector<QFilterKey*> filterKeys() const;
void addRenderState(QRenderState *state);
diff --git a/src/render/materialsystem/qshaderprogram.cpp b/src/render/materialsystem/qshaderprogram.cpp
index da954210b..522f021aa 100644
--- a/src/render/materialsystem/qshaderprogram.cpp
+++ b/src/render/materialsystem/qshaderprogram.cpp
@@ -47,29 +47,37 @@
#include <QUrl>
/*!
- * \qmltype ShaderProgram
- * \instantiates Qt3DRender::QShaderProgram
- * \inqmlmodule Qt3D.Render
- * \brief Encapsulates a Shader Program.
- */
+ \class Qt3DRender::QShaderProgram
+ \inmodule Qt3DRender
+ \brief Encapsulates a Shader Program.
+ \inherits Qt3DCore::QNode
+ \since 5.5
+
+ A shader program consists of several different shaders, such as vertex and fragment shaders.
+*/
/*!
- * \class Qt3DRender::QShaderProgram
- * \inmodule Qt3DRender
- *
- * \brief Encapsulates a Shader Program.
- */
+ \qmltype ShaderProgram
+ \instantiates Qt3DRender::QShaderProgram
+ \inqmlmodule Qt3D.Render
+ \brief Encapsulates a Shader Program.
+ \since 5.5
+
+ ShaderProgram class encapsulates a shader program. A shader program consists of several
+ different shaders, such as vertex and fragment shaders.
+*/
/*!
\enum QShaderProgram::ShaderType
- This enum identifies the type of shader used
- \value Vertex
- \value Fragment
- \value TessellationControl
- \value TessellationEvaluation
- \value Geometry
- \value Compute
+ This enum identifies the type of shader used.
+
+ \value Vertex Vertex shader
+ \value Fragment Fragment shader
+ \value TessellationControl Tesselation control shader
+ \value TessellationEvaluation Tesselation evaluation shader
+ \value Geometry Geometry shader
+ \value Compute Compute shader
*/
QT_BEGIN_NAMESPACE
@@ -81,16 +89,11 @@ QShaderProgramPrivate::QShaderProgramPrivate()
{
}
-/*!
- \fn Qt3DRender::QShaderProgram::QShaderProgram(Qt3DCore::QNode *parent)
- Constructs a new QShaderProgram with the specified \a parent.
- */
QShaderProgram::QShaderProgram(QNode *parent)
: QNode(*new QShaderProgramPrivate, parent)
{
}
-/*! \internal */
QShaderProgram::~QShaderProgram()
{
}
@@ -102,14 +105,15 @@ QShaderProgram::QShaderProgram(QShaderProgramPrivate &dd, QNode *parent)
}
/*!
- \qmlproperty QByteArray Qt3D.Render::ShaderProgram::vertexShaderCode
- Specifies the vertex shader code to be used
-*/
+ \qmlproperty string ShaderProgram::vertexShaderCode
+ Holds the vertex shader code used by this shader program.
+*/
/*!
- \property Qt3DRender::QShaderProgram::vertexShaderCode
- Specifies the vertex shader code to be used
- */
+ \property QShaderProgram::vertexShaderCode
+
+ Holds the vertex shader code used by this shader program.
+*/
void QShaderProgram::setVertexShaderCode(const QByteArray &vertexShaderCode)
{
Q_D(QShaderProgram);
@@ -126,14 +130,15 @@ QByteArray QShaderProgram::vertexShaderCode() const
}
/*!
- \qmlproperty QByteArray Qt3D.Render::ShaderProgram::tessellationControlShaderCode
- Specifies the tessellation control shader code to be used
-*/
+ \qmlproperty string ShaderProgram::tessellationControlShaderCode
+ Holds the tesselation control shader code used by this shader program.
+*/
/*!
- \property Qt3DRender::QShaderProgram::tessellationControlShaderCode
- Specifies the tessellation control shader code to be used
- */
+ \property QShaderProgram::tessellationControlShaderCode
+
+ Holds the tesselation control shader code used by this shader program.
+*/
void QShaderProgram::setTessellationControlShaderCode(const QByteArray &tessellationControlShaderCode)
{
Q_D(QShaderProgram);
@@ -150,14 +155,15 @@ QByteArray QShaderProgram::tessellationControlShaderCode() const
}
/*!
- \qmlproperty QByteArray Qt3D.Render::ShaderProgram::tessellationEvaluationShaderCode
- Specifies the tessellation evaluation shader code to be used
-*/
+ \qmlproperty string ShaderProgram::tessellationEvaluationShaderCode
+ Holds the tesselation evaluation shader code used by this shader program.
+*/
/*!
- \property Qt3DRender::QShaderProgram::tessellationEvaluationShaderCode
- Specifies the tessellation evaluation shader code to be used
- */
+ \property QShaderProgram::tessellationEvaluationShaderCode
+
+ Holds the tesselation evaluation shader code used by this shader program.
+*/
void QShaderProgram::setTessellationEvaluationShaderCode(const QByteArray &tessellationEvaluationShaderCode)
{
Q_D(QShaderProgram);
@@ -174,14 +180,15 @@ QByteArray QShaderProgram::tessellationEvaluationShaderCode() const
}
/*!
- \qmlproperty QByteArray Qt3D.Render::ShaderProgram::geometryShaderCode
- Specifies the geometry shader code to be used
-*/
+ \qmlproperty string ShaderProgram::geometryShaderCode
+ Holds the geometry shader code used by this shader program.
+*/
/*!
- \property Qt3DRender::QShaderProgram::geometryShaderCode
- Specifies the geometry shader code to be used
- */
+ \property QShaderProgram::geometryShaderCode
+
+ Holds the geometry shader code used by this shader program.
+*/
void QShaderProgram::setGeometryShaderCode(const QByteArray &geometryShaderCode)
{
Q_D(QShaderProgram);
@@ -198,14 +205,15 @@ QByteArray QShaderProgram::geometryShaderCode() const
}
/*!
- \qmlproperty QByteArray Qt3D.Render::ShaderProgram::fragmentShaderCode
- Specifies the fragment shader code to be used
-*/
+ \qmlproperty string ShaderProgram::fragmentShaderCode
+ Holds the fragment shader code used by this shader program.
+*/
/*!
- \property Qt3DRender::QShaderProgram::fragmentShaderCode
- Specifies the fragment shader code to be used
- */
+ \property QShaderProgram::fragmentShaderCode
+
+ Holds the fragment shader code used by this shader program.
+*/
void QShaderProgram::setFragmentShaderCode(const QByteArray &fragmentShaderCode)
{
Q_D(QShaderProgram);
@@ -222,14 +230,15 @@ QByteArray QShaderProgram::fragmentShaderCode() const
}
/*!
- \qmlproperty QByteArray Qt3D.Render::ShaderProgram::computeShaderCode
- Specifies the compute shader code to be used
-*/
+ \qmlproperty string ShaderProgram::computeShaderCode
+ Holds the compute shader code used by this shader program.
+*/
/*!
- \property Qt3DRender::QShaderProgram::computeShaderCode
- Specifies the compute shader code to be used
- */
+ \property QShaderProgram::computeShaderCode
+
+ Holds the compute shader code used by this shader program.
+*/
void QShaderProgram::setComputeShaderCode(const QByteArray &computeShaderCode)
{
Q_D(QShaderProgram);
@@ -247,8 +256,8 @@ QByteArray QShaderProgram::computeShaderCode() const
/*!
- * Sets the \a type shader from raw data in \a shaderCode.
- */
+ Sets the shader code for \a type of shader to the \a shaderCode.
+*/
void QShaderProgram::setShaderCode(ShaderType type, const QByteArray &shaderCode)
{
switch (type) {
@@ -276,8 +285,8 @@ void QShaderProgram::setShaderCode(ShaderType type, const QByteArray &shaderCode
}
/*!
- * Returns the \a type shader code.
- */
+ Returns the shader code for \a type.
+*/
QByteArray QShaderProgram::shaderCode(ShaderType type) const
{
Q_D(const QShaderProgram);
@@ -332,13 +341,13 @@ static QByteArray deincludify(const QString &filePath)
}
/*!
- \qmlmethod QByteArray ShaderProgram::loadSource(const QUrl &sourceUrl)
+ \qmlmethod string ShaderProgram::loadSource(url sourceUrl)
Returns the shader code loaded from \a sourceUrl.
*/
/*!
- * Returns the shader code loaded from \a sourceUrl.
- */
+ Returns the shader code loaded from \a sourceUrl.
+*/
QByteArray QShaderProgram::loadSource(const QUrl &sourceUrl)
{
// TO DO: Handle remote path
diff --git a/src/render/materialsystem/qtechnique.cpp b/src/render/materialsystem/qtechnique.cpp
index f114e2754..74505bfbd 100644
--- a/src/render/materialsystem/qtechnique.cpp
+++ b/src/render/materialsystem/qtechnique.cpp
@@ -61,25 +61,62 @@ QTechniquePrivate::~QTechniquePrivate()
}
/*!
- * \qmltype Technique
- * \instantiates Qt3DRender::QTechnique
- * \inqmlmodule Qt3D.Render
- * \brief Encapsulates a Technique.
+ \qmltype Technique
+ \instantiates Qt3DRender::QTechnique
+ \inqmlmodule Qt3D.Render
+ \inherits Qt3DCore::QNode
+ \since 5.7
+ \brief Encapsulates a Technique.
+
+ A Technique specifies a set of RenderPass objects, FilterKey objects, Parameter objects
+ and a GraphicsApiFilter, which together define a rendering technique the given
+ graphics API can render. The filter keys are used by TechniqueFilter
+ to select specific techinques at specific parts of the FrameGraph.
+ If the same parameter is specified both in Technique and RenderPass, the one
+ in Technique overrides the one used in the RenderPass.
+
+ \sa Qt3D.Render::Effect
*/
/*!
- * \class Qt3DRender::QTechnique
- * \inmodule Qt3DRender
- *
- * \inherits Node
- *
- * \brief Encapsulates a Technique.
+ \class Qt3DRender::QTechnique
+ \inmodule Qt3DRender
+ \inherits Node
+ \since 5.7
+ \brief Encapsulates a Technique.
+
+ A Qt3DRender::QTechnique specifies a set of Qt3DRender::QRenderPass objects,
+ Qt3DRender::QFilterKey objects, Qt3DRender::QParameter objects and
+ a Qt3DRender::QGraphicsApiFilter, which together define a rendering technique the given
+ graphics API can render. The filter keys are used by Qt3DRender::QTechniqueFilter
+ to select specific techinques at specific parts of the FrameGraph.
+ If the same parameter is specified both in QTechnique and QRenderPass, the one
+ in QTechnique overrides the one used in the QRenderPass.
+
+ \sa Qt3DRender::QEffect
*/
/*!
- \fn Qt3DRender::QTechnique::QTechnique(Qt3DCore::QNode *parent)
- Constructs a new QTechnique with the specified \a parent.
+ \qmlproperty GraphicsApiFilter Qt3D.Render::Technique::graphicsApiFilter
+ Specifies the graphics API filter being used
+*/
+/*!
+ \qmlproperty list<FilterKey> Qt3D.Render::Technique::filterKeys
+ Specifies the list of filter keys enabling this technique
+*/
+/*!
+ \qmlproperty list<RenderPass> Qt3D.Render::Technique::renderPasses
+ Specifies the render passes used by the tehcnique
+*/
+/*!
+ \qmlproperty list<Parameter> Qt3D.Render::Technique::parameters
+ Specifies the parameters used by the technique
+*/
+/*!
+ \property Qt3DRender::QTechnique::graphicsApiFilter
+ Specifies the graphics API filter being used
*/
+
QTechnique::QTechnique(QNode *parent)
: QNode(*new QTechniquePrivate, parent)
{
@@ -112,7 +149,7 @@ void QTechniquePrivate::_q_graphicsApiFilterChanged()
}
/*!
- * Add \a filterKey to the Qt3DRender::QTechnique local filter keys.
+ Add \a filterKey to the Qt3DRender::QTechnique local filter keys.
*/
void QTechnique::addFilterKey(QFilterKey *filterKey)
{
@@ -140,7 +177,7 @@ void QTechnique::addFilterKey(QFilterKey *filterKey)
}
/*!
- * Removes \a filterKey from the Qt3DRender::QTechnique local filter keys.
+ Removes \a filterKey from the Qt3DRender::QTechnique local filter keys.
*/
void QTechnique::removeFilterKey(QFilterKey *filterKey)
{
@@ -157,8 +194,8 @@ void QTechnique::removeFilterKey(QFilterKey *filterKey)
}
/*!
- * Returns the list of Qt3DCore::QFilterKey key objects making up the filter keys
- * of the Qt3DRender::QTechnique.
+ Returns the list of Qt3DCore::QFilterKey key objects making up the filter keys
+ of the Qt3DRender::QTechnique.
*/
QVector<QFilterKey *> QTechnique::filterKeys() const
{
@@ -167,7 +204,7 @@ QVector<QFilterKey *> QTechnique::filterKeys() const
}
/*!
- * Add \a parameter to the techniques parameters.
+ Add \a parameter to the technique's parameters.
*/
void QTechnique::addParameter(QParameter *parameter)
{
@@ -195,7 +232,7 @@ void QTechnique::addParameter(QParameter *parameter)
}
/*!
- * Remove \a parameter from the techniques parameters.
+ Remove \a parameter from the technique's parameters.
*/
void QTechnique::removeParameter(QParameter *parameter)
{
@@ -212,7 +249,7 @@ void QTechnique::removeParameter(QParameter *parameter)
}
/*!
- * Appends a \a pass to the technique.
+ Appends a \a pass to the technique.
*/
void QTechnique::addRenderPass(QRenderPass *pass)
{
@@ -240,14 +277,14 @@ void QTechnique::addRenderPass(QRenderPass *pass)
}
/*!
- * Removes a \a pass from the technique.
+ Removes a \a pass from the technique.
*/
void QTechnique::removeRenderPass(QRenderPass *pass)
{
Q_ASSERT(pass);
Q_D(QTechnique);
if (d->m_changeArbiter) {
- const auto change = QPropertyNodeAddedChangePtr::create(id(), pass);
+ const auto change = QPropertyNodeRemovedChangePtr::create(id(), pass);
change->setPropertyName("pass");
d->notifyObservers(change);
}
@@ -257,7 +294,7 @@ void QTechnique::removeRenderPass(QRenderPass *pass)
}
/*!
- * Returns the list of render passes contained in the technique.
+ Returns the list of render passes contained in the technique.
*/
QVector<QRenderPass *> QTechnique::renderPasses() const
{
@@ -266,7 +303,7 @@ QVector<QRenderPass *> QTechnique::renderPasses() const
}
/*!
- * Returns a vector of the techniques current parameters
+ Returns a vector of the techniques current parameters
*/
QVector<QParameter *> QTechnique::parameters() const
{
@@ -274,15 +311,6 @@ QVector<QParameter *> QTechnique::parameters() const
return d->m_parameters;
}
-/*!
- \qmlproperty QByteArray Qt3D.Render::Technique::graphicsApiFilter
- Specifies the graphics API filter being used
-*/
-
-/*!
- \property Qt3DRender::QTechnique::graphicsApiFilter
- Specifies the graphics API filter being used
- */
QGraphicsApiFilter *QTechnique::graphicsApiFilter()
{
Q_D(QTechnique);
diff --git a/src/render/materialsystem/shaderdata.cpp b/src/render/materialsystem/shaderdata.cpp
index 1f68bed13..e7c8a1c37 100644
--- a/src/render/materialsystem/shaderdata.cpp
+++ b/src/render/materialsystem/shaderdata.cpp
@@ -94,7 +94,6 @@ void ShaderData::initializeFromPeer(const QNodeCreatedChangeBasePtr &change)
const QVariant &propertyValue = entry.second;
const QString propertyName = QString::fromLatin1(entry.first);
- m_properties.insert(propertyName, propertyValue);
m_originalProperties.insert(propertyName, propertyValue);
// We check if the property is a QNodeId or QVector<QNodeId> so that we can
@@ -108,14 +107,15 @@ void ShaderData::initializeFromPeer(const QNodeCreatedChangeBasePtr &change)
}
}
- // We look for transformed properties
- QHash<QString, QVariant>::iterator it = m_properties.begin();
- const QHash<QString, QVariant>::iterator end = m_properties.end();
+ // We look for transformed properties once the complete hash of
+ // originalProperties is available
+ QHash<QString, QVariant>::iterator it = m_originalProperties.begin();
+ const QHash<QString, QVariant>::iterator end = m_originalProperties.end();
while (it != end) {
if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QVector3D) {
// if there is a matching QShaderData::TransformType propertyTransformed
- QVariant value = m_properties.value(it.key() + QLatin1String("Transformed"));
+ QVariant value = m_originalProperties.value(it.key() + QLatin1String("Transformed"));
// if that's the case, we apply a space transformation to the property
if (value.isValid() && value.type() == QVariant::Int)
m_transformedProperties.insert(it.key(), static_cast<TransformType>(value.toInt()));
@@ -138,135 +138,67 @@ ShaderData *ShaderData::lookupResource(QNodeId id)
// Call by cleanup job (single thread)
void ShaderData::clearUpdatedProperties()
{
- m_updatedProperties.clear();
- const QHash<QString, QVariant>::const_iterator end = m_nestedShaderDataProperties.end();
- QHash<QString, QVariant>::const_iterator it = m_nestedShaderDataProperties.begin();
-
- while (it != end) {
- if (it.value().userType() == QMetaType::QVariantList) {
- const auto values = it.value().value<QVariantList>();
- for (const QVariant &v : values) {
- ShaderData *nested = lookupResource(v.value<QNodeId>());
- if (nested != nullptr)
- nested->clearUpdatedProperties();
- }
- } else {
- ShaderData *nested = lookupResource(it.value().value<QNodeId>());
- if (nested != nullptr)
- nested->clearUpdatedProperties();
- }
- ++it;
- }
+ // DISABLED: Is only useful when building UBO from a ShaderData, which is disable since 5.7
+ // const QHash<QString, QVariant>::const_iterator end = m_nestedShaderDataProperties.end();
+ // QHash<QString, QVariant>::const_iterator it = m_nestedShaderDataProperties.begin();
+
+ // while (it != end) {
+ // if (it.value().userType() == QMetaType::QVariantList) {
+ // const auto values = it.value().value<QVariantList>();
+ // for (const QVariant &v : values) {
+ // ShaderData *nested = lookupResource(v.value<QNodeId>());
+ // if (nested != nullptr)
+ // nested->clearUpdatedProperties();
+ // }
+ // } else {
+ // ShaderData *nested = lookupResource(it.value().value<QNodeId>());
+ // if (nested != nullptr)
+ // nested->clearUpdatedProperties();
+ // }
+ // ++it;
+ // }
}
void ShaderData::cleanup(NodeManagers *managers)
{
- for (Qt3DCore::QNodeId id : qAsConst(m_updatedShaderData)) {
- ShaderData *shaderData = ShaderData::lookupResource(managers, id);
- if (shaderData)
- shaderData->clearUpdatedProperties();
- }
+ Q_UNUSED(managers)
+ // DISABLED: Is only useful when building UBO from a ShaderData, which is disable since 5.7
+ // for (Qt3DCore::QNodeId id : qAsConst(m_updatedShaderData)) {
+ // ShaderData *shaderData = ShaderData::lookupResource(managers, id);
+ // if (shaderData)
+ // shaderData->clearUpdatedProperties();
+ // }
m_updatedShaderData.clear();
}
-// Called by renderview jobs (several concurrent threads)
-/*!
- \internal
- Lookup if the current ShaderData or a nested ShaderData has updated properties.
- UpdateProperties contains either the value of the propertie of a QNodeId if it's another ShaderData.
- Transformed properties are updated for all of ShaderData that have ones at the point.
-
- \note This needs to be performed for every top level ShaderData every time it is used.
- As we don't know if the transformed properties use the same viewMatrix for all RenderViews.
- */
-bool ShaderData::updateViewTransform(const QMatrix4x4 &viewMatrix)
+QVariant ShaderData::getTransformedProperty(const QString &name, const QMatrix4x4 &viewMatrix)
{
- // We can't perform this only once as we don't know if we would be call as the root or a
- // nested ShaderData
- QMutexLocker lock(&m_mutex);
-
- // Update transformed properties
- // We check the matrices and decide if the transform has changed since the previous call to needsUpdate
- if (m_viewMatrix != viewMatrix) {
- m_viewMatrix = viewMatrix;
- const QHash<QString, TransformType>::const_iterator transformedEnd = m_transformedProperties.end();
- QHash<QString, TransformType>::const_iterator transformedIt = m_transformedProperties.begin();
-
- while (transformedIt != transformedEnd) {
- if (transformedIt.value() == ModelToEye) {
- m_updatedProperties.insert(transformedIt.key(), m_viewMatrix * m_worldMatrix * m_originalProperties.value(transformedIt.key()).value<QVector3D>());
- m_properties.insert(transformedIt.key(), m_viewMatrix * m_worldMatrix * m_originalProperties.value(transformedIt.key()).value<QVector3D>());
- }
- ++transformedIt;
+ // Note protecting m_worldMatrix at this point as we assume all world updates
+ // have been performed when reaching this point
+ auto it = m_transformedProperties.find(name);
+ if (it != m_transformedProperties.end()) {
+ const TransformType transformType = it.value();
+ switch (transformType) {
+ case ModelToEye:
+ return QVariant::fromValue(viewMatrix * m_worldMatrix * m_originalProperties.value(name).value<QVector3D>());
+ case ModelToWorld:
+ return QVariant::fromValue(m_worldMatrix * m_originalProperties.value(it.key()).value<QVector3D>());
+ case ModelToWorldDirection:
+ return QVariant::fromValue((m_worldMatrix * QVector4D(m_originalProperties.value(it.key()).value<QVector3D>(), 0.0f)).toVector3D());
+ case NoTransform:
+ break;
}
}
- const QHash<QString, QVariant>::const_iterator end = m_nestedShaderDataProperties.end();
- QHash<QString, QVariant>::const_iterator it = m_nestedShaderDataProperties.begin();
-
- while (it != end) {
- const int userType = it.value().userType();
-
- if (userType == QMetaType::QVariantList) {
- QVariantList updatedNodes;
- bool nestedNeedsUpdate = false;
- const QVariantList values = variant_value<QVariantList>(it.value());
- for (const QVariant &v : values) {
- if (v.userType() != qNodeIdTypeId)
- continue;
-
- const Qt3DCore::QNodeId nestedId = variant_value<Qt3DCore::QNodeId>(v);
- ShaderData *nested = lookupResource(nestedId);
- if (nested != nullptr) {
- // We need to add the nested nodes to the updated property list
- // as we need to maintain order
- // if node[0] doesn't need update but node[1] does,
- // if we only have a single element, the renderer would update element [0]
- nestedNeedsUpdate |= nested->updateViewTransform(viewMatrix);
- updatedNodes << v;
- }
- }
- // Of course we only add all the nodes if at least one of the nested nodes required and update
- if (nestedNeedsUpdate && !updatedNodes.empty())
- m_updatedProperties.insert(it.key(), updatedNodes);
- } else if (userType == qNodeIdTypeId) {
- const Qt3DCore::QNodeId nestedId = variant_value<Qt3DCore::QNodeId>(it.value());
- ShaderData *nested = lookupResource(nestedId);
- if (nested != nullptr && nested->updateViewTransform(viewMatrix))
- m_updatedProperties.insert(it.key(), it.value());
- }
- ++it;
- }
- return m_updatedProperties.size() > 0;
+ return QVariant();
}
-bool ShaderData::updateWorldTransform(const QMatrix4x4 &worldMatrix)
+// Called by FramePreparationJob or by RenderView when dealing with lights
+void ShaderData::updateWorldTransform(const QMatrix4x4 &worldMatrix)
{
- // TODO: Factor this out into a job that populates data in the corresponding
- // renderview or other intermediate data structure. See QTBUG-54818
QMutexLocker lock(&m_mutex);
if (m_worldMatrix != worldMatrix) {
m_worldMatrix = worldMatrix;
-
- const QHash<QString, TransformType>::const_iterator transformedEnd = m_transformedProperties.end();
- QHash<QString, TransformType>::const_iterator transformedIt = m_transformedProperties.begin();
-
- while (transformedIt != transformedEnd) {
- if (transformedIt.value() == ModelToEye) {
- m_updatedProperties.insert(transformedIt.key(), m_viewMatrix * m_worldMatrix * m_originalProperties.value(transformedIt.key()).value<QVector3D>());
- m_properties.insert(transformedIt.key(), m_viewMatrix * m_worldMatrix * m_originalProperties.value(transformedIt.key()).value<QVector3D>());
- } else if (transformedIt.value() == ModelToWorldDirection) {
- auto localDirection = QVector4D(m_originalProperties.value(transformedIt.key()).value<QVector3D>(), 0.0f);
- auto worldDirection = (m_worldMatrix * localDirection).toVector3D();
- m_updatedProperties.insert(transformedIt.key(), worldDirection);
- m_properties.insert(transformedIt.key(), worldDirection);
- } else {
- m_updatedProperties.insert(transformedIt.key(), m_worldMatrix * m_originalProperties.value(transformedIt.key()).value<QVector3D>());
- m_properties.insert(transformedIt.key(), m_worldMatrix * m_originalProperties.value(transformedIt.key()).value<QVector3D>());
- }
- ++transformedIt;
- }
}
- return m_updatedProperties.size() > 0;
}
// This will add the ShaderData to be cleared from updates at the end of the frame
@@ -279,6 +211,21 @@ void ShaderData::markDirty()
ShaderData::m_updatedShaderData.append(peerId());
}
+/*!
+ \internal
+ Lookup if the current ShaderData or a nested ShaderData has updated properties.
+ UpdateProperties contains either the value of the propertie of a QNodeId if it's another ShaderData.
+ Transformed properties are updated for all of ShaderData that have ones at the point.
+
+ \note This needs to be performed for every top level ShaderData every time it is used.
+ As we don't know if the transformed properties use the same viewMatrix for all RenderViews.
+ */
+
+ShaderData::TransformType ShaderData::propertyTransformType(const QString &name) const
+{
+ return m_transformedProperties.value(name, TransformType::NoTransform);
+}
+
void ShaderData::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
if (!m_propertyReader.isNull() && e->type() == PropertyUpdated) {
@@ -297,19 +244,7 @@ void ShaderData::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
// Note we aren't notified about nested QShaderData in this call
// only scalar / vec properties
- if (m_properties.contains(propertyName)) {
- // If this is a Transformed property, we need to multiply against the correct
- // matrices
- m_originalProperties.insert(propertyName, propertyValue);
- if (m_transformedProperties.contains(propertyName)) {
- if (m_transformedProperties[propertyName] == ModelToEye)
- propertyValue = m_viewMatrix * m_worldMatrix * propertyValue.value<QVector3D>();
- else
- propertyValue = m_worldMatrix * propertyValue.value<QVector3D>();
- }
- m_properties.insert(propertyName, propertyValue);
- m_updatedProperties.insert(propertyName, propertyValue);
- }
+ m_originalProperties.insert(propertyName, propertyValue);
BackendNode::markDirty(AbstractRenderer::AllDirty);
}
diff --git a/src/render/materialsystem/shaderdata_p.h b/src/render/materialsystem/shaderdata_p.h
index 46dd26faf..6ce0c734c 100644
--- a/src/render/materialsystem/shaderdata_p.h
+++ b/src/render/materialsystem/shaderdata_p.h
@@ -71,6 +71,7 @@ class Q_AUTOTEST_EXPORT ShaderData : public BackendNode
{
public:
enum TransformType {
+ NoTransform = -1,
ModelToEye = 0,
ModelToWorld,
ModelToWorldDirection
@@ -79,15 +80,16 @@ public:
ShaderData();
~ShaderData();
- QHash<QString, QVariant> properties() const { return m_properties; }
- QHash<QString, QVariant> updatedProperties() const { return m_updatedProperties; }
+ QHash<QString, QVariant> properties() const { return m_originalProperties; }
// Called by FramePreparationJob
- bool updateWorldTransform(const QMatrix4x4 &worldMatrix);
+ void updateWorldTransform(const QMatrix4x4 &worldMatrix);
// Call by RenderViewJob
void markDirty();
- bool updateViewTransform(const QMatrix4x4 &viewMatrix);
+
+ TransformType propertyTransformType(const QString &name) const;
+ QVariant getTransformedProperty(const QString &name, const QMatrix4x4 &viewMatrix);
// Called by FrameCleanupJob
static void cleanup(NodeManagers *managers);
@@ -98,17 +100,18 @@ protected:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_OVERRIDE;
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE;
+ PropertyReaderInterfacePtr m_propertyReader;
+
// 1 to 1 match with frontend properties, modified only by sceneChangeEvent
QHash<QString, QVariant> m_originalProperties;
- // 1 to 1 match with frontend properties apart from Transformed
- // properties which contain the matrices product
- QHash<QString, QVariant> m_properties;
- // only updated properties, Transformed properties have the same
- // value as in m_properties
- QHash<QString, QVariant> m_updatedProperties;
- PropertyReaderInterfacePtr m_propertyReader;
+
+ // Contains properties thar are of type ShaderData
QHash<QString, QVariant> m_nestedShaderDataProperties;
+
+ // Contains property that are defined like: postionTransformed: ModelToEye
QHash<QString, TransformType> m_transformedProperties;
+
+
QMutex m_mutex;
static QVector<Qt3DCore::QNodeId> m_updatedShaderData;
QMatrix4x4 m_worldMatrix;