summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qshader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/rhi/qshader.cpp')
-rw-r--r--src/gui/rhi/qshader.cpp73
1 files changed, 66 insertions, 7 deletions
diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp
index af2275f088..d5fb53e7e6 100644
--- a/src/gui/rhi/qshader.cpp
+++ b/src/gui/rhi/qshader.cpp
@@ -141,7 +141,7 @@ QT_BEGIN_NAMESPACE
A default constructed QShaderVersion contains a version of 100 and no
flags set.
- \note This a RHI API with limited compatibility guarantees, see \l QShader
+ \note This is a RHI API with limited compatibility guarantees, see \l QShader
for details.
*/
@@ -163,7 +163,7 @@ QT_BEGIN_NAMESPACE
A default constructed QShaderKey has source set to SpirvShader and
sourceVersion set to 100. sourceVariant defaults to StandardShader.
- \note This a RHI API with limited compatibility guarantees, see \l QShader
+ \note This is a RHI API with limited compatibility guarantees, see \l QShader
for details.
*/
@@ -214,6 +214,28 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \enum QShader::SerializedFormatVersion
+ Describes the desired output format when serializing the QShader.
+
+ The default value for the \c version argument of serialized() is \c Latest.
+ This is sufficient in the vast majority of cases. Specifying another value
+ is needed only when the intention is to generate serialized data that can
+ be loaded by earlier Qt versions. For example, the \c qsb tool uses these
+ enum values when the \c{--qsbversion} command-line argument is given.
+
+ \note Targeting earlier versions will make certain features disfunctional
+ with the generated asset. This is not an issue when using the asset with
+ the specified, older Qt version, given that that Qt version does not have
+ the newer features in newer Qt versions that rely on additional data
+ generated in the QShader and the serialized data stream, but may become a
+ problem if the generated asset is then used with a newer Qt version.
+
+ \value Latest The current Qt version
+ \value Qt_6_5 Qt 6.5
+ \value Qt_6_4 Qt 6.4
+ */
+
+/*!
\class QShaderCode
\inmodule QtGui
\since 6.6
@@ -223,7 +245,7 @@ QT_BEGIN_NAMESPACE
When shader() is empty after retrieving a QShaderCode instance from
QShader, it indicates no shader code was found for the requested key.
- \note This a RHI API with limited compatibility guarantees, see \l QShader
+ \note This is a RHI API with limited compatibility guarantees, see \l QShader
for details.
*/
@@ -277,6 +299,28 @@ QShader &QShader::operator=(const QShader &other)
}
/*!
+ \fn QShader::QShader(QShader &&other) noexcept
+ \since 6.7
+
+ Move-constructs a new QShader from \a other.
+
+ \note The moved-from object \a other is placed in a
+ partially-formed state, in which the only valid operations are
+ destruction and assignment of a new value.
+*/
+
+/*!
+ \fn QShader &QShader::operator=(QShader &&other)
+ \since 6.7
+
+ Move-assigns \a other to this QShader instance.
+
+ \note The moved-from object \a other is placed in a
+ partially-formed state, in which the only valid operations are
+ destruction and assignment of a new value.
+*/
+
+/*!
Destructor.
*/
QShader::~QShader()
@@ -286,6 +330,14 @@ QShader::~QShader()
}
/*!
+ \fn void QShader::swap(QShader &other)
+ \since 6.7
+
+ Swaps shader \a other with this shader. This operation is very fast and
+ never fails.
+*/
+
+/*!
\return true if the QShader contains at least one shader version.
*/
bool QShader::isValid() const
@@ -387,7 +439,11 @@ static void writeShaderKey(QDataStream *ds, const QShaderKey &k)
QShader, suitable for writing to files or other I/O devices.
By default the latest serialization format is used. Use \a version
- parameter to serialize for a compatibility Qt version.
+ parameter to serialize for a compatibility Qt version. Only when it is
+ known that the generated data stream must be made compatible with an older
+ Qt version at the expense of making it incompatible with features
+ introduced since that Qt version, should another value (for example,
+ \l{SerializedFormatVersion}{Qt_6_5} for Qt 6.5) be used.
\sa fromSerialized()
*/
@@ -476,6 +532,9 @@ static void readShaderKey(QDataStream *ds, QShaderKey *k)
/*!
Creates a new QShader instance from the given \a data.
+ If \a data cannot be deserialized successfully, the result is a default
+ constructed QShader for which isValid() returns \c false.
+
\sa serialized()
*/
QShader QShader::fromSerialized(const QByteArray &data)
@@ -748,7 +807,7 @@ size_t qHash(const QShader &s, size_t seed) noexcept
seed = hash(seed, s.stage());
if (!s.d->shaders.isEmpty()) {
seed = hash(seed, s.d->shaders.firstKey());
- seed = hash(seed, s.d->shaders.first());
+ seed = hash(seed, std::as_const(s.d->shaders).first());
}
}
return seed;
@@ -1021,7 +1080,7 @@ void QShader::removeResourceBindingMap(const QShaderKey &key)
\c{_54} which corresponds to two separate resource bindings (\c 1 and \c 2)
in the original shader.
- \note This a RHI API with limited compatibility guarantees, see \l QShader
+ \note This is a RHI API with limited compatibility guarantees, see \l QShader
for details.
*/
@@ -1103,7 +1162,7 @@ void QShader::removeSeparateToCombinedImageSamplerMappingList(const QShaderKey &
that the shader code relies on such a buffer present can be indicated by
the data in this struct.
- \note This a RHI API with limited compatibility guarantees, see \l QShader
+ \note This is a RHI API with limited compatibility guarantees, see \l QShader
for details.
*/