| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSPIRVCOMPILER_P_H |
| 5 | #define QSPIRVCOMPILER_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of a number of Qt sources files. This header file may change from |
| 13 | // version to version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtShaderTools/private/qtshadertoolsglobal_p.h> |
| 19 | #include <rhi/qshader.h> |
| 20 | #include <QtCore/QString> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | struct QSpirvCompilerPrivate; |
| 25 | class QIODevice; |
| 26 | |
| 27 | class Q_SHADERTOOLS_EXPORT QSpirvCompiler |
| 28 | { |
| 29 | public: |
| 30 | QSpirvCompiler(); |
| 31 | ~QSpirvCompiler(); |
| 32 | |
| 33 | enum Flag { |
| 34 | RewriteToMakeBatchableForSG = 0x01, |
| 35 | FullDebugInfo = 0x02 |
| 36 | }; |
| 37 | Q_DECLARE_FLAGS(Flags, Flag) |
| 38 | |
| 39 | void setSourceFileName(const QString &fileName); |
| 40 | void setSourceFileName(const QString &fileName, QShader::Stage stage); |
| 41 | void setSourceDevice(QIODevice *device, QShader::Stage stage, const QString &fileName = QString()); |
| 42 | void setSourceString(const QByteArray &sourceString, QShader::Stage stage, const QString &fileName = QString()); |
| 43 | void setFlags(Flags flags); |
| 44 | void setPreamble(const QByteArray &preamble); |
| 45 | void setSGBatchingVertexInputLocation(int location); |
| 46 | |
| 47 | QByteArray compileToSpirv(); |
| 48 | QString errorMessage() const; |
| 49 | |
| 50 | private: |
| 51 | Q_DISABLE_COPY(QSpirvCompiler) |
| 52 | QSpirvCompilerPrivate *d = nullptr; |
| 53 | }; |
| 54 | |
| 55 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSpirvCompiler::Flags) |
| 56 | |
| 57 | QT_END_NAMESPACE |
| 58 | |
| 59 | #endif |
| 60 | |