summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-06-05 17:22:44 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-06-11 13:58:37 +0000
commit9fa867d0907c675a2e32957d7866f3e77c8f8de5 (patch)
tree1c6468c4e9c48df648de77134eeae2d9f258e73d /src
parent76118c14eb57fd21982e6cfc0c936a7ed0711463 (diff)
Follow QRhiShader API cleanup
Change-Id: I4ebde6e68fe8c8fe0105981f9bea6f01aba96c60 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/shadertools/qshaderbaker.cpp110
-rw-r--r--src/shadertools/qshaderbaker.h14
-rw-r--r--src/shadertools/qspirvcompiler.cpp20
-rw-r--r--src/shadertools/qspirvcompiler_p.h8
-rw-r--r--src/shadertools/qspirvshader.cpp98
-rw-r--r--src/shadertools/qspirvshader_p.h4
6 files changed, 127 insertions, 127 deletions
diff --git a/src/shadertools/qshaderbaker.cpp b/src/shadertools/qshaderbaker.cpp
index 982a2fd..11c3699 100644
--- a/src/shadertools/qshaderbaker.cpp
+++ b/src/shadertools/qshaderbaker.cpp
@@ -53,14 +53,14 @@ QT_BEGIN_NAMESPACE
QShaderBaker takes a graphics (vertex, fragment, etc.) or compute shader,
and produces multiple - either source or bytecode - variants of it,
together with reflection information. The results are represented by a
- QRhiShader instance, which also provides simple and fast serialization
+ QShader instance, which also provides simple and fast serialization
and deserialization.
\note Applications and libraries are recommended to avoid using this class
directly. Rather, all Qt users are encouraged to rely on offline
compilation by invoking the \c qsb command-line tool at build time. This
tool uses QShaderBaker itself and writes the serialized version of the
- generated QRhiShader into a file. The usage of this class should be
+ generated QShader into a file. The usage of this class should be
restricted to cases where run time compilation cannot be avoided, such as
when working with user-provided shader source strings.
@@ -76,8 +76,8 @@ QT_BEGIN_NAMESPACE
\l{https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/dx-graphics-hlsl}{HLSL}
as a source format, once HLSL to SPIR-V compilation is deemed suitable.
- The reflection metadata is retrievable from the resulting QRhiShader by
- calling QRhiShader::description(). This is essential when having to
+ The reflection metadata is retrievable from the resulting QShader by
+ calling QShader::description(). This is essential when having to
discover what set of vertex inputs and shader resources a shader expects,
and what the layouts of those are, as many modern graphics APIs offer no
built-in shader reflection capabilities.
@@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE
Fragment shader:
\snippet color.frag 0
- To get QRhiShader instances that can be passed as-is to a
+ To get QShader instances that can be passed as-is to a
QRhiGraphicsPipeline, there are two options: doing the shader pack
generation off line, or at run time.
@@ -111,12 +111,12 @@ QT_BEGIN_NAMESPACE
setGeneratedShaders(). Once the resulting files are available, they can be
shipped with the application (typically embedded into the executable the
the Qt Resource System), and can be loaded and passed to
- QRhiShader::fromSerialized() at run time.
+ QShader::fromSerialized() at run time.
While not shown here, \c qsb can do more: it is also able to invoke \c fxc
on Windows or the appropriate XCode tools on macOS to compile the generated
HLSL or Metal shader code into bytecode and include the compiled versions
- in the QRhiShader. After a baked shader pack is written into a file, its
+ in the QShader. After a baked shader pack is written into a file, its
contents can be examined by running \c{qsb -d} on it. Run \c qsb with
\c{--help} for more information.
@@ -125,20 +125,20 @@ QT_BEGIN_NAMESPACE
setting up the translation targets via setGeneratedShaders():
\badcode
- baker.setGeneratedShaderVariants({ QRhiShaderKey::StandardShader });
+ baker.setGeneratedShaderVariants({ QShader::StandardShader });
QVector<QShaderBaker::GeneratedShader> targets;
- targets.append({ QRhiShaderKey::SpirvShader, QRhiShaderVersion(100) });
- targets.append({ QRhiShaderKey::GlslShader, QRhiShaderVersion(100, QRhiShaderVersion::GlslEs) });
- targets.append({ QRhiShaderKey::SpirvShader, QRhiShaderVersion(120) });
- targets.append({ QRhiShaderKey::HlslShader, QRhiShaderVersion(50) });
- targets.append({ QRhiShaderKey::MslShader, QRhiShaderVersion(12) });
+ targets.append({ QShader::SpirvShader, QShaderVersion(100) });
+ targets.append({ QShader::GlslShader, QShaderVersion(100, QShaderVersion::GlslEs) });
+ targets.append({ QShader::SpirvShader, QShaderVersion(120) });
+ targets.append({ QShader::HlslShader, QShaderVersion(50) });
+ targets.append({ QShader::MslShader, QShaderVersion(12) });
baker.setGeneratedShaders(targets);
- QRhiShader shaders = baker.bake();
+ QShader shaders = baker.bake();
if (!shaders.isValid())
qWarning() << baker.errorMessage();
\endcode
- \sa QRhiShader
+ \sa QShader
*/
struct QShaderBakerPrivate
@@ -147,9 +147,9 @@ struct QShaderBakerPrivate
QString sourceFileName;
QByteArray source;
- QRhiShader::ShaderStage stage;
+ QShader::Stage stage;
QVector<QShaderBaker::GeneratedShader> reqVersions;
- QVector<QRhiShaderKey::ShaderVariant> variants;
+ QVector<QShader::Variant> variants;
QByteArray preamble;
QSpirvCompiler compiler;
QString errorMessage;
@@ -206,20 +206,20 @@ void QShaderBaker::setSourceFileName(const QString &fileName)
const QString suffix = QFileInfo(fileName).suffix();
if (suffix == QStringLiteral("vert")) {
- d->stage = QRhiShader::VertexStage;
+ d->stage = QShader::VertexStage;
} else if (suffix == QStringLiteral("frag")) {
- d->stage = QRhiShader::FragmentStage;
+ d->stage = QShader::FragmentStage;
} else if (suffix == QStringLiteral("tesc")) {
- d->stage = QRhiShader::TessControlStage;
+ d->stage = QShader::TessellationControlStage;
} else if (suffix == QStringLiteral("tese")) {
- d->stage = QRhiShader::TessEvaluationStage;
+ d->stage = QShader::TessellationEvaluationStage;
} else if (suffix == QStringLiteral("geom")) {
- d->stage = QRhiShader::GeometryStage;
+ d->stage = QShader::GeometryStage;
} else if (suffix == QStringLiteral("comp")) {
- d->stage = QRhiShader::ComputeStage;
+ d->stage = QShader::ComputeStage;
} else {
qWarning("QShaderBaker: Unknown shader stage, defaulting to vertex");
- d->stage = QRhiShader::VertexStage;
+ d->stage = QShader::VertexStage;
}
}
@@ -228,7 +228,7 @@ void QShaderBaker::setSourceFileName(const QString &fileName)
that will be read when calling bake(). The shader stage is specified by \a
stage.
*/
-void QShaderBaker::setSourceFileName(const QString &fileName, QRhiShader::ShaderStage stage)
+void QShaderBaker::setSourceFileName(const QString &fileName, QShader::Stage stage)
{
if (d->readFile(fileName))
d->stage = stage;
@@ -239,7 +239,7 @@ void QShaderBaker::setSourceFileName(const QString &fileName, QRhiShader::Shader
files. \a stage specifies the shader stage, while the optional \a fileName
contains a filename that is used in the error messages.
*/
-void QShaderBaker::setSourceDevice(QIODevice *device, QRhiShader::ShaderStage stage, const QString &fileName)
+void QShaderBaker::setSourceDevice(QIODevice *device, QShader::Stage stage, const QString &fileName)
{
setSourceString(device->readAll(), stage, fileName);
}
@@ -249,7 +249,7 @@ void QShaderBaker::setSourceDevice(QIODevice *device, QRhiShader::ShaderStage st
while the optional \a fileName contains a filename that is used in the
error messages.
*/
-void QShaderBaker::setSourceString(const QByteArray &sourceString, QRhiShader::ShaderStage stage, const QString &fileName)
+void QShaderBaker::setSourceString(const QByteArray &sourceString, QShader::Stage stage, const QString &fileName)
{
d->sourceFileName = fileName; // for error messages, include handling, etc.
d->source = sourceString;
@@ -259,7 +259,7 @@ void QShaderBaker::setSourceString(const QByteArray &sourceString, QRhiShader::S
/*!
\typedef QShaderBaker::GeneratedShader
- Synonym for QPair<QRhiShaderKey::ShaderSource, QRhiShaderVersion>.
+ Synonym for QPair<QShader::Source, QShaderVersion>.
*/
/*!
@@ -267,13 +267,13 @@ void QShaderBaker::setSourceString(const QByteArray &sourceString, QRhiShader::S
generated by default so calling this function before bake() is mandatory
\note when this function is not called or \a v is empty or contains only invalid
- entries, the resulting QRhiShader will be empty and thus invalid.
+ entries, the resulting QShader will be empty and thus invalid.
For example, the minimal possible baking target is SPIR-V, without any
additional translations to other languages. To request this, do:
\badcode
- baker.setGeneratedShaders({ QRhiShaderKey::SpirvShader, QRhiShaderVersion(100) });
+ baker.setGeneratedShaders({ QShader::SpirvShader, QShaderVersion(100) });
\endcode
*/
void QShaderBaker::setGeneratedShaders(const QVector<GeneratedShader> &v)
@@ -283,14 +283,14 @@ void QShaderBaker::setGeneratedShaders(const QVector<GeneratedShader> &v)
/*!
Specifies which shader variants are generated. Each shader version can have
- multiple variants in the resulting QRhiShader.
+ multiple variants in the resulting QShader.
- In most cases \a v contains a single entry, QRhiShaderKey::StandardShader.
+ In most cases \a v contains a single entry, QShader::StandardShader.
- \note when no variants are set, the resulting QRhiShader will be empty and
+ \note when no variants are set, the resulting QShader will be empty and
thus invalid.
*/
-void QShaderBaker::setGeneratedShaderVariants(const QVector<QRhiShaderKey::ShaderVariant> &v)
+void QShaderBaker::setGeneratedShaderVariants(const QVector<QShader::Variant> &v)
{
d->variants = v;
}
@@ -315,8 +315,8 @@ void QShaderBaker::setPreamble(const QByteArray &preamble)
/*!
Runs the compilation and translation process.
- \return a QRhiShader instance. To check if the process was successful,
- call QRhiShader::isValid(). When that indicates \c false, call
+ \return a QShader instance. To check if the process was successful,
+ call QShader::isValid(). When that indicates \c false, call
errorMessage() to retrieve the log.
This is an expensive operation. When calling this from applications, it can
@@ -326,13 +326,13 @@ void QShaderBaker::setPreamble(const QByteArray &preamble)
instance can be used with different inputs again. However, a QShaderBaker
instance should only be used on one single thread during its lifetime.
*/
-QRhiShader QShaderBaker::bake()
+QShader QShaderBaker::bake()
{
d->errorMessage.clear();
if (d->source.isEmpty()) {
d->errorMessage = QLatin1String("QShaderBaker: No source specified");
- return QRhiShader();
+ return QShader();
}
d->compiler.setSourceString(d->source, d->stage, d->sourceFileName);
@@ -341,20 +341,20 @@ QRhiShader QShaderBaker::bake()
QByteArray spirv = d->compiler.compileToSpirv();
if (spirv.isEmpty()) {
d->errorMessage = d->compiler.errorMessage();
- return QRhiShader();
+ return QShader();
}
QByteArray batchableSpirv;
- if (d->stage == QRhiShader::VertexStage && d->variants.contains(QRhiShaderKey::BatchableVertexShader)) {
+ if (d->stage == QShader::VertexStage && d->variants.contains(QShader::BatchableVertexShader)) {
d->compiler.setFlags(QSpirvCompiler::RewriteToMakeBatchableForSG);
batchableSpirv = d->compiler.compileToSpirv();
if (batchableSpirv.isEmpty()) {
d->errorMessage = d->compiler.errorMessage();
- return QRhiShader();
+ return QShader();
}
}
- QRhiShader bs;
+ QShader bs;
bs.setStage(d->stage);
QSpirvShader spirvShader;
@@ -369,10 +369,10 @@ QRhiShader QShaderBaker::bake()
}
for (const GeneratedShader &req: d->reqVersions) {
- for (const QRhiShaderKey::ShaderVariant &v : d->variants) {
+ for (const QShader::Variant &v : d->variants) {
QByteArray *currentSpirv = &spirv;
QSpirvShader *currentSpirvShader = &spirvShader;
- if (v == QRhiShaderKey::BatchableVertexShader) {
+ if (v == QShader::BatchableVertexShader) {
if (!batchableSpirv.isEmpty()) {
currentSpirv = &batchableSpirv;
currentSpirvShader = &batchableSpirvShader;
@@ -380,37 +380,37 @@ QRhiShader QShaderBaker::bake()
continue;
}
}
- const QRhiShaderKey key(req.first, req.second, v);
- QRhiShaderCode shader;
+ const QShaderKey key(req.first, req.second, v);
+ QShaderCode shader;
shader.setEntryPoint(QByteArrayLiteral("main"));
switch (req.first) {
- case QRhiShaderKey::SpirvShader:
+ case QShader::SpirvShader:
shader.setShader(*currentSpirv);
break;
- case QRhiShaderKey::GlslShader:
+ case QShader::GlslShader:
{
QSpirvShader::GlslFlags flags = 0;
- if (req.second.flags().testFlag(QRhiShaderVersion::GlslEs))
+ if (req.second.flags().testFlag(QShaderVersion::GlslEs))
flags |= QSpirvShader::GlslEs;
shader.setShader(currentSpirvShader->translateToGLSL(req.second.version(), flags));
if (shader.shader().isEmpty()) {
d->errorMessage = currentSpirvShader->translationErrorMessage();
- return QRhiShader();
+ return QShader();
}
}
break;
- case QRhiShaderKey::HlslShader:
+ case QShader::HlslShader:
shader.setShader(currentSpirvShader->translateToHLSL(req.second.version()));
if (shader.shader().isEmpty()) {
d->errorMessage = currentSpirvShader->translationErrorMessage();
- return QRhiShader();
+ return QShader();
}
break;
- case QRhiShaderKey::MslShader:
+ case QShader::MslShader:
shader.setShader(currentSpirvShader->translateToMSL(req.second.version()));
if (shader.shader().isEmpty()) {
d->errorMessage = currentSpirvShader->translationErrorMessage();
- return QRhiShader();
+ return QShader();
}
shader.setEntryPoint(QByteArrayLiteral("main0"));
break;
@@ -430,7 +430,7 @@ QRhiShader QShaderBaker::bake()
\note Errors include file read errors, compilation, and translation
failures. Not requesting any targets or variants does not count as an error
- even though the resulting QRhiShader is invalid.
+ even though the resulting QShader is invalid.
*/
QString QShaderBaker::errorMessage() const
{
diff --git a/src/shadertools/qshaderbaker.h b/src/shadertools/qshaderbaker.h
index 68f0672..edac5fb 100644
--- a/src/shadertools/qshaderbaker.h
+++ b/src/shadertools/qshaderbaker.h
@@ -38,7 +38,7 @@
#define QSHADERBAKER_H
#include <QtShaderTools/qtshadertoolsglobal.h>
-#include <QtGui/qrhishader.h>
+#include <QtGui/private/qshader_p_p.h>
QT_BEGIN_NAMESPACE
@@ -52,21 +52,21 @@ public:
~QShaderBaker();
void setSourceFileName(const QString &fileName);
- void setSourceFileName(const QString &fileName, QRhiShader::ShaderStage stage);
+ void setSourceFileName(const QString &fileName, QShader::Stage stage);
- void setSourceDevice(QIODevice *device, QRhiShader::ShaderStage stage,
+ void setSourceDevice(QIODevice *device, QShader::Stage stage,
const QString &fileName = QString());
- void setSourceString(const QByteArray &sourceString, QRhiShader::ShaderStage stage,
+ void setSourceString(const QByteArray &sourceString, QShader::Stage stage,
const QString &fileName = QString());
- typedef QPair<QRhiShaderKey::ShaderSource, QRhiShaderVersion> GeneratedShader;
+ typedef QPair<QShader::Source, QShaderVersion> GeneratedShader;
void setGeneratedShaders(const QVector<GeneratedShader> &v);
- void setGeneratedShaderVariants(const QVector<QRhiShaderKey::ShaderVariant> &v);
+ void setGeneratedShaderVariants(const QVector<QShader::Variant> &v);
void setPreamble(const QByteArray &preamble);
- QRhiShader bake();
+ QShader bake();
QString errorMessage() const;
diff --git a/src/shadertools/qspirvcompiler.cpp b/src/shadertools/qspirvcompiler.cpp
index d2f5703..0496c3a 100644
--- a/src/shadertools/qspirvcompiler.cpp
+++ b/src/shadertools/qspirvcompiler.cpp
@@ -334,27 +334,27 @@ void QSpirvCompiler::setSourceFileName(const QString &fileName)
}
}
-static inline EShLanguage mapShaderStage(QRhiShader::ShaderStage stage)
+static inline EShLanguage mapShaderStage(QShader::Stage stage)
{
switch (stage) {
- case QRhiShader::VertexStage:
+ case QShader::VertexStage:
return EShLangVertex;
- case QRhiShader::TessControlStage:
+ case QShader::TessellationControlStage:
return EShLangTessControl;
- case QRhiShader::TessEvaluationStage:
+ case QShader::TessellationEvaluationStage:
return EShLangTessEvaluation;
- case QRhiShader::GeometryStage:
+ case QShader::GeometryStage:
return EShLangGeometry;
- case QRhiShader::FragmentStage:
+ case QShader::FragmentStage:
return EShLangFragment;
- case QRhiShader::ComputeStage:
+ case QShader::ComputeStage:
return EShLangCompute;
default:
return EShLangVertex;
}
}
-void QSpirvCompiler::setSourceFileName(const QString &fileName, QRhiShader::ShaderStage stage)
+void QSpirvCompiler::setSourceFileName(const QString &fileName, QShader::Stage stage)
{
if (!d->readFile(fileName))
return;
@@ -362,12 +362,12 @@ void QSpirvCompiler::setSourceFileName(const QString &fileName, QRhiShader::Shad
d->stage = mapShaderStage(stage);
}
-void QSpirvCompiler::setSourceDevice(QIODevice *device, QRhiShader::ShaderStage stage, const QString &fileName)
+void QSpirvCompiler::setSourceDevice(QIODevice *device, QShader::Stage stage, const QString &fileName)
{
setSourceString(device->readAll(), stage, fileName);
}
-void QSpirvCompiler::setSourceString(const QByteArray &sourceString, QRhiShader::ShaderStage stage, const QString &fileName)
+void QSpirvCompiler::setSourceString(const QByteArray &sourceString, QShader::Stage stage, const QString &fileName)
{
d->sourceFileName = fileName; // for error messages, include handling, etc.
d->source = sourceString;
diff --git a/src/shadertools/qspirvcompiler_p.h b/src/shadertools/qspirvcompiler_p.h
index 8637795..4843f5d 100644
--- a/src/shadertools/qspirvcompiler_p.h
+++ b/src/shadertools/qspirvcompiler_p.h
@@ -49,7 +49,7 @@
//
#include <QtShaderTools/private/qtshadertoolsglobal_p.h>
-#include <QtGui/qrhishader.h>
+#include <QtGui/private/qshader_p.h>
#include <QtCore/QString>
QT_BEGIN_NAMESPACE
@@ -69,9 +69,9 @@ public:
Q_DECLARE_FLAGS(Flags, Flag)
void setSourceFileName(const QString &fileName);
- void setSourceFileName(const QString &fileName, QRhiShader::ShaderStage stage);
- void setSourceDevice(QIODevice *device, QRhiShader::ShaderStage stage, const QString &fileName = QString());
- void setSourceString(const QByteArray &sourceString, QRhiShader::ShaderStage stage, const QString &fileName = QString());
+ void setSourceFileName(const QString &fileName, QShader::Stage stage);
+ void setSourceDevice(QIODevice *device, QShader::Stage stage, const QString &fileName = QString());
+ void setSourceString(const QByteArray &sourceString, QShader::Stage stage, const QString &fileName = QString());
void setFlags(Flags flags);
void setPreamble(const QByteArray &preamble);
diff --git a/src/shadertools/qspirvshader.cpp b/src/shadertools/qspirvshader.cpp
index 5402f7b..c855268 100644
--- a/src/shadertools/qspirvshader.cpp
+++ b/src/shadertools/qspirvshader.cpp
@@ -35,7 +35,7 @@
****************************************************************************/
#include "qspirvshader_p.h"
-#include <QtGui/private/qrhishaderdescription_p.h>
+#include <QtGui/private/qshaderdescription_p_p.h>
#include <QFile>
#include <QDebug>
@@ -54,8 +54,8 @@ struct QSpirvShaderPrivate
void createGLSLCompiler();
void processResources();
- QRhiShaderDescription::InOutVariable inOutVar(const spirv_cross::Resource &r);
- QRhiShaderDescription::BlockVariable blockVar(uint32_t typeId,
+ QShaderDescription::InOutVariable inOutVar(const spirv_cross::Resource &r);
+ QShaderDescription::BlockVariable blockVar(uint32_t typeId,
uint32_t memberIdx,
uint32_t memberTypeId);
@@ -63,7 +63,7 @@ struct QSpirvShaderPrivate
void remapLogHandler(const std::string &s);
QByteArray ir;
- QRhiShaderDescription shaderDescription;
+ QShaderDescription shaderDescription;
spirv_cross::CompilerGLSL *glslGen = nullptr;
spirv_cross::CompilerHLSL *hlslGen = nullptr;
@@ -86,78 +86,78 @@ void QSpirvShaderPrivate::createGLSLCompiler()
glslGen = new spirv_cross::CompilerGLSL(reinterpret_cast<const uint32_t *>(ir.constData()), ir.size() / 4);
}
-static QRhiShaderDescription::VarType matVarType(const spirv_cross::SPIRType &t, QRhiShaderDescription::VarType compType)
+static QShaderDescription::VariableType matVarType(const spirv_cross::SPIRType &t, QShaderDescription::VariableType compType)
{
switch (t.columns) {
case 2:
- return QRhiShaderDescription::VarType(compType + 4 + (t.vecsize == 3 ? 1 : t.vecsize == 4 ? 2 : 0));
+ return QShaderDescription::VariableType(compType + 4 + (t.vecsize == 3 ? 1 : t.vecsize == 4 ? 2 : 0));
case 3:
- return QRhiShaderDescription::VarType(compType + 7 + (t.vecsize == 2 ? 1 : t.vecsize == 4 ? 2 : 0));
+ return QShaderDescription::VariableType(compType + 7 + (t.vecsize == 2 ? 1 : t.vecsize == 4 ? 2 : 0));
case 4:
- return QRhiShaderDescription::VarType(compType + 10 + (t.vecsize == 2 ? 1 : t.vecsize == 3 ? 2 : 0));
+ return QShaderDescription::VariableType(compType + 10 + (t.vecsize == 2 ? 1 : t.vecsize == 3 ? 2 : 0));
default:
- return QRhiShaderDescription::Unknown;
+ return QShaderDescription::Unknown;
}
}
-static QRhiShaderDescription::VarType vecVarType(const spirv_cross::SPIRType &t, QRhiShaderDescription::VarType compType)
+static QShaderDescription::VariableType vecVarType(const spirv_cross::SPIRType &t, QShaderDescription::VariableType compType)
{
switch (t.vecsize) {
case 1:
return compType;
case 2:
- return QRhiShaderDescription::VarType(compType + 1);
+ return QShaderDescription::VariableType(compType + 1);
case 3:
- return QRhiShaderDescription::VarType(compType + 2);
+ return QShaderDescription::VariableType(compType + 2);
case 4:
- return QRhiShaderDescription::VarType(compType + 3);
+ return QShaderDescription::VariableType(compType + 3);
default:
- return QRhiShaderDescription::Unknown;
+ return QShaderDescription::Unknown;
}
}
-static QRhiShaderDescription::VarType imageVarType(const spirv_cross::SPIRType &t)
+static QShaderDescription::VariableType imageVarType(const spirv_cross::SPIRType &t)
{
switch (t.image.dim) {
case spv::Dim1D:
- return t.image.arrayed ? QRhiShaderDescription::Sampler1DArray : QRhiShaderDescription::Sampler1D;
+ return t.image.arrayed ? QShaderDescription::Sampler1DArray : QShaderDescription::Sampler1D;
case spv::Dim2D:
return t.image.arrayed
- ? (t.image.ms ? QRhiShaderDescription::Sampler2DMSArray : QRhiShaderDescription::Sampler2DArray)
- : (t.image.ms ? QRhiShaderDescription::Sampler2DMS : QRhiShaderDescription::Sampler2D);
+ ? (t.image.ms ? QShaderDescription::Sampler2DMSArray : QShaderDescription::Sampler2DArray)
+ : (t.image.ms ? QShaderDescription::Sampler2DMS : QShaderDescription::Sampler2D);
case spv::Dim3D:
- return t.image.arrayed ? QRhiShaderDescription::Sampler3DArray : QRhiShaderDescription::Sampler3D;
+ return t.image.arrayed ? QShaderDescription::Sampler3DArray : QShaderDescription::Sampler3D;
case spv::DimCube:
- return t.image.arrayed ? QRhiShaderDescription::SamplerCubeArray : QRhiShaderDescription::SamplerCube;
+ return t.image.arrayed ? QShaderDescription::SamplerCubeArray : QShaderDescription::SamplerCube;
default:
- return QRhiShaderDescription::Unknown;
+ return QShaderDescription::Unknown;
}
}
-static QRhiShaderDescription::VarType varType(const spirv_cross::SPIRType &t)
+static QShaderDescription::VariableType varType(const spirv_cross::SPIRType &t)
{
- QRhiShaderDescription::VarType vt = QRhiShaderDescription::Unknown;
+ QShaderDescription::VariableType vt = QShaderDescription::Unknown;
switch (t.basetype) {
case spirv_cross::SPIRType::Float:
- vt = t.columns > 1 ? matVarType(t, QRhiShaderDescription::Float) : vecVarType(t, QRhiShaderDescription::Float);
+ vt = t.columns > 1 ? matVarType(t, QShaderDescription::Float) : vecVarType(t, QShaderDescription::Float);
break;
case spirv_cross::SPIRType::Double:
- vt = t.columns > 1 ? matVarType(t, QRhiShaderDescription::Double) : vecVarType(t, QRhiShaderDescription::Double);
+ vt = t.columns > 1 ? matVarType(t, QShaderDescription::Double) : vecVarType(t, QShaderDescription::Double);
break;
case spirv_cross::SPIRType::UInt:
- vt = vecVarType(t, QRhiShaderDescription::Uint);
+ vt = vecVarType(t, QShaderDescription::Uint);
break;
case spirv_cross::SPIRType::Int:
- vt = vecVarType(t, QRhiShaderDescription::Int);
+ vt = vecVarType(t, QShaderDescription::Int);
break;
case spirv_cross::SPIRType::Boolean:
- vt = vecVarType(t, QRhiShaderDescription::Uint);
+ vt = vecVarType(t, QShaderDescription::Uint);
break;
case spirv_cross::SPIRType::SampledImage:
vt = imageVarType(t);
break;
case spirv_cross::SPIRType::Struct:
- vt = QRhiShaderDescription::Struct;
+ vt = QShaderDescription::Struct;
break;
// ### separate image/sampler, atomic counter, ...
default:
@@ -166,9 +166,9 @@ static QRhiShaderDescription::VarType varType(const spirv_cross::SPIRType &t)
return vt;
}
-QRhiShaderDescription::InOutVariable QSpirvShaderPrivate::inOutVar(const spirv_cross::Resource &r)
+QShaderDescription::InOutVariable QSpirvShaderPrivate::inOutVar(const spirv_cross::Resource &r)
{
- QRhiShaderDescription::InOutVariable v;
+ QShaderDescription::InOutVariable v;
v.name = QString::fromStdString(r.name);
const spirv_cross::SPIRType &t = glslGen->get_type(r.base_type_id);
@@ -186,11 +186,11 @@ QRhiShaderDescription::InOutVariable QSpirvShaderPrivate::inOutVar(const spirv_c
return v;
}
-QRhiShaderDescription::BlockVariable QSpirvShaderPrivate::blockVar(uint32_t typeId,
+QShaderDescription::BlockVariable QSpirvShaderPrivate::blockVar(uint32_t typeId,
uint32_t memberIdx,
uint32_t memberTypeId)
{
- QRhiShaderDescription::BlockVariable v;
+ QShaderDescription::BlockVariable v;
v.name = QString::fromStdString(glslGen->get_member_name(typeId, memberIdx));
const spirv_cross::SPIRType &memberType(glslGen->get_type(memberTypeId));
@@ -212,7 +212,7 @@ QRhiShaderDescription::BlockVariable QSpirvShaderPrivate::blockVar(uint32_t type
if (glslGen->has_member_decoration(typeId, memberIdx, spv::DecorationRowMajor))
v.matrixIsRowMajor = true;
- if (v.type == QRhiShaderDescription::Struct) {
+ if (v.type == QShaderDescription::Struct) {
uint32_t memberMemberIdx = 0;
for (uint32_t memberMemberType : memberType.member_types) {
v.structMembers.append(blockVar(memberType.self, memberMemberIdx, memberMemberType));
@@ -225,8 +225,8 @@ QRhiShaderDescription::BlockVariable QSpirvShaderPrivate::blockVar(uint32_t type
void QSpirvShaderPrivate::processResources()
{
- shaderDescription = QRhiShaderDescription();
- QRhiShaderDescriptionPrivate *dd = QRhiShaderDescriptionPrivate::get(&shaderDescription);
+ shaderDescription = QShaderDescription();
+ QShaderDescriptionPrivate *dd = QShaderDescriptionPrivate::get(&shaderDescription);
spirv_cross::ShaderResources resources = glslGen->get_shader_resources();
@@ -245,21 +245,21 @@ void QSpirvShaderPrivate::processResources()
*/
for (const spirv_cross::Resource &r : resources.stage_inputs) {
- const QRhiShaderDescription::InOutVariable v = inOutVar(r);
- if (v.type != QRhiShaderDescription::Unknown)
+ const QShaderDescription::InOutVariable v = inOutVar(r);
+ if (v.type != QShaderDescription::Unknown)
dd->inVars.append(v);
}
for (const spirv_cross::Resource &r : resources.stage_outputs) {
- const QRhiShaderDescription::InOutVariable v = inOutVar(r);
- if (v.type != QRhiShaderDescription::Unknown)
+ const QShaderDescription::InOutVariable v = inOutVar(r);
+ if (v.type != QShaderDescription::Unknown)
dd->outVars.append(v);
}
// uniform blocks map to either a uniform buffer or a plain struct
for (const spirv_cross::Resource &r : resources.uniform_buffers) {
const spirv_cross::SPIRType &t = glslGen->get_type(r.base_type_id);
- QRhiShaderDescription::UniformBlock block;
+ QShaderDescription::UniformBlock block;
block.blockName = QString::fromStdString(r.name);
block.structName = QString::fromStdString(glslGen->get_name(r.id));
block.size = int(glslGen->get_declared_struct_size(t));
@@ -269,9 +269,9 @@ void QSpirvShaderPrivate::processResources()
block.descriptorSet = glslGen->get_decoration(r.id, spv::DecorationDescriptorSet);
uint32_t idx = 0;
for (uint32_t memberTypeId : t.member_types) {
- const QRhiShaderDescription::BlockVariable v = blockVar(r.base_type_id, idx, memberTypeId);
+ const QShaderDescription::BlockVariable v = blockVar(r.base_type_id, idx, memberTypeId);
++idx;
- if (v.type != QRhiShaderDescription::Unknown)
+ if (v.type != QShaderDescription::Unknown)
block.members.append(v);
}
dd->uniformBlocks.append(block);
@@ -280,22 +280,22 @@ void QSpirvShaderPrivate::processResources()
// push constant blocks map to a plain GLSL struct regardless of version
for (const spirv_cross::Resource &r : resources.push_constant_buffers) {
const spirv_cross::SPIRType &t = glslGen->get_type(r.base_type_id);
- QRhiShaderDescription::PushConstantBlock block;
+ QShaderDescription::PushConstantBlock block;
block.name = QString::fromStdString(glslGen->get_name(r.id));
block.size = int(glslGen->get_declared_struct_size(t));
uint32_t idx = 0;
for (uint32_t memberTypeId : t.member_types) {
- const QRhiShaderDescription::BlockVariable v = blockVar(r.base_type_id, idx, memberTypeId);
+ const QShaderDescription::BlockVariable v = blockVar(r.base_type_id, idx, memberTypeId);
++idx;
- if (v.type != QRhiShaderDescription::Unknown)
+ if (v.type != QShaderDescription::Unknown)
block.members.append(v);
}
dd->pushConstantBlocks.append(block);
}
for (const spirv_cross::Resource &r : resources.sampled_images) {
- const QRhiShaderDescription::InOutVariable v = inOutVar(r);
- if (v.type != QRhiShaderDescription::Unknown)
+ const QShaderDescription::InOutVariable v = inOutVar(r);
+ if (v.type != QShaderDescription::Unknown)
dd->combinedImageSamplers.append(v);
}
}
@@ -334,7 +334,7 @@ void QSpirvShader::setSpirvBinary(const QByteArray &spirv)
d->processResources();
}
-QRhiShaderDescription QSpirvShader::shaderDescription() const
+QShaderDescription QSpirvShader::shaderDescription() const
{
return d->shaderDescription;
}
diff --git a/src/shadertools/qspirvshader_p.h b/src/shadertools/qspirvshader_p.h
index 3191173..018fc30 100644
--- a/src/shadertools/qspirvshader_p.h
+++ b/src/shadertools/qspirvshader_p.h
@@ -49,7 +49,7 @@
//
#include <QtShaderTools/private/qtshadertoolsglobal_p.h>
-#include <QtGui/qrhishaderdescription.h>
+#include <QtGui/private/qshaderdescription_p.h>
QT_BEGIN_NAMESPACE
@@ -78,7 +78,7 @@ public:
void setDevice(QIODevice *device);
void setSpirvBinary(const QByteArray &spirv);
- QRhiShaderDescription shaderDescription() const;
+ QShaderDescription shaderDescription() const;
QByteArray strippedSpirvBinary(StripFlags flags = StripFlags(), QString *errorMessage = nullptr) const;