| 1 | // Copyright (C) 2023 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 QSHADERBAKER_H |
| 5 | #define QSHADERBAKER_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is part of the RHI API, with limited compatibility guarantees. |
| 12 | // Usage of this API may make your code source and binary incompatible with |
| 13 | // future versions of Qt. |
| 14 | // |
| 15 | |
| 16 | #include <QtShaderTools/qtshadertoolsglobal.h> |
| 17 | #include <rhi/qshader.h> |
| 18 | |
| 19 | QT_BEGIN_NAMESPACE |
| 20 | |
| 21 | struct QShaderBakerPrivate; |
| 22 | class QIODevice; |
| 23 | |
| 24 | class Q_SHADERTOOLS_EXPORT QShaderBaker |
| 25 | { |
| 26 | public: |
| 27 | enum class SpirvOption { |
| 28 | GenerateFullDebugInfo = 0x01, |
| 29 | StripDebugAndVarInfo = 0x02 |
| 30 | }; |
| 31 | Q_DECLARE_FLAGS(SpirvOptions, SpirvOption) |
| 32 | |
| 33 | QShaderBaker(); |
| 34 | ~QShaderBaker(); |
| 35 | |
| 36 | void setSourceFileName(const QString &fileName); |
| 37 | void setSourceFileName(const QString &fileName, QShader::Stage stage); |
| 38 | |
| 39 | void setSourceDevice(QIODevice *device, QShader::Stage stage, |
| 40 | const QString &fileName = QString()); |
| 41 | |
| 42 | void setSourceString(const QByteArray &sourceString, QShader::Stage stage, |
| 43 | const QString &fileName = QString()); |
| 44 | |
| 45 | typedef QPair<QShader::Source, QShaderVersion> GeneratedShader; |
| 46 | void setGeneratedShaders(const QList<GeneratedShader> &v); |
| 47 | void setGeneratedShaderVariants(const QList<QShader::Variant> &v); |
| 48 | |
| 49 | void setPreamble(const QByteArray &preamble); |
| 50 | void setBatchableVertexShaderExtraInputLocation(int location); |
| 51 | void setPerTargetCompilation(bool enable); |
| 52 | void setBreakOnShaderTranslationError(bool enable); |
| 53 | void setTessellationMode(QShaderDescription::TessellationMode mode); |
| 54 | void setTessellationOutputVertexCount(int count); |
| 55 | void setMultiViewCount(int count); |
| 56 | |
| 57 | void setSpirvOptions(SpirvOptions options); |
| 58 | |
| 59 | QShader bake(); |
| 60 | |
| 61 | QString errorMessage() const; |
| 62 | |
| 63 | private: |
| 64 | Q_DISABLE_COPY(QShaderBaker) |
| 65 | QShaderBakerPrivate *d = nullptr; |
| 66 | }; |
| 67 | |
| 68 | Q_DECLARE_OPERATORS_FOR_FLAGS(QShaderBaker::SpirvOptions) |
| 69 | |
| 70 | QT_END_NAMESPACE |
| 71 | |
| 72 | #endif |
| 73 |
