Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qssgrendershadertokenizer_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QSSGRENDERSHADERTOKENIZER_P_H
6#define QSSGRENDERSHADERTOKENIZER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qtquick3druntimerenderexports.h"
20
21#include <QtCore/qbytearray.h>
22
24
25// A minimal tokenizer for the GLSL-ish shader snippets used by the custom
26// material, effect, quad texture provider and user render pass APIs. It does not
27// try to be a full GLSL lexer; it only classifies the tokens these code paths
28// need (identifiers, numeric literals, comments, braces, parens, brackets and
29// semicolons) so that keyword detection/replacement can be done without
30// re-implementing comment skipping and identifier boundary handling in each
31// caller. For Token_Identifier and Token_Value, the text is [identifier, pos).
32//
33// This is based on the Qt Quick shader rewriter (with fixes).
34class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGShaderTokenizer
35{
36public:
37 enum Token {
38 Token_Comment,
39 Token_OpenBrace,
40 Token_CloseBrace,
41 Token_OpenParen,
42 Token_CloseParen,
43 Token_SemiColon,
44 Token_Identifier,
45 Token_OpenBraket,
46 Token_CloseBraket,
47 Token_Value,
48 Token_Unspecified,
49
50 Token_EOF
51 };
52
53 void initialize(const char *input);
54 Token next();
55
56 const char *stream = nullptr;
57 const char *pos = nullptr;
58 const char *identifier = nullptr;
59};
60
61QT_END_NAMESPACE
62
63#endif // QSSGRENDERSHADERTOKENIZER_P_H
QSSGAddShaderDefine(const QByteArray &name, int value=0)
void addDebug(QDebug &stream) const
void setFormat(QSSGRenderTextureFormat format)
QSSGAllocateTexture(QSSGRenderTextureFormat inFormat)
const QSSGManagedRhiTexture & texture() const
void addDebug(QDebug &stream) const
QSSGRenderTextureFormat format() const
void setTexture(const QSSGManagedRhiTexture &tex)
void addDebug(QDebug &stream) const
QSSGColorAttachment(const QByteArray &name)
QSSGAllocateTexturePtr m_textureCmd
QSSGRenderTextureFormat format() const
QSSGColorAttachment(const QByteArray &name, CommandType type)
void addDebug(QDebug &stream) const
void addDebug(QDebug &stream) const
QSSGDepthTextureAttachment(const QByteArray &name)
void addDebug(QDebug &stream) const
QSSGDispatch(QSSGRenderShaderValue::ivec3 groupCount)
QSSGRenderShaderValue::ivec3 m_groupCount
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend2
std::optional< QRhiGraphicsPipeline::CompareOp > m_depthFunction
std::optional< QRhiGraphicsPipeline::PolygonMode > m_polygonMode
std::optional< QRhiViewport > m_viewport
std::optional< bool > m_usesStencilReference
std::optional< quint32 > m_stencilReference
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend1
std::optional< QRhiGraphicsPipeline::StencilOpState > m_stencilOpFrontState
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend5
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend7
std::optional< QRhiGraphicsPipeline::CullMode > m_cullMode
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend4
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend0
std::optional< QRhiScissor > m_scissor
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend6
std::optional< QRhiGraphicsPipeline::TargetBlend > m_targetBlend3
void addDebug(QDebug &stream) const
std::optional< quint32 > m_stencilWriteMask
QSSGRhiShaderPipelinePtr compileGeneratedRhiShader(const QByteArray &inMaterialInfoString, const QSSGShaderFeatures &inFeatureSet, QSSGShaderLibraryManager &shaderLibraryManager, QSSGShaderCache &theCache, QSSGRhiShaderPipeline::StageFlags stageFlags, const QSSGUserShaderAugmentation &shaderAugmentation, int viewCount, bool perTargetCompilation, const QByteArray &inCacheKey={})
void registerShaderMetaDataFromSource(QSSGShaderResourceMergeContext *mergeContext, const QByteArray &contents, QSSGShaderGeneratorStage stage)
static constexpr QSSGShaderGeneratorStageFlags defaultFlags()
QSSGShaderGeneratorStageFlags m_enabledStages
QSSGComputeShaderGenerator m_cs
QSSGStageGeneratorBase * getStage(QSSGShaderGeneratorStage inStage)
QSSGStageGeneratorBase & internalGetStage(QSSGShaderGeneratorStage inStage)
QSSGShaderGeneratorStageFlags getEnabledStages() const
void beginProgram(QSSGShaderGeneratorStageFlags inEnabledStages=defaultFlags())
QSSGFragmentShaderGenerator m_fs
void addDebug(QDebug &stream) const
static constexpr RenderableTypeT AllRenderableTypes
friend class QSSGRenderContextInterface
void addDebug(QDebug &stream) const
void setSubPass(QSSGResourceId userPassId)
QSSGResourceId m_userPassId
Combined button and popup list for selecting options.
static QSet< QByteArray > shaderIdentifiers(const QByteArray &shaderCode)
void prepareComputePass(QSSGRenderer &renderer, QSSGLayerRenderData &data, QSSGRenderComputePass *passNode, ComputeUserPassData &userData, QSSGPassKey key)
static const QByteArrayList rhiProperties
static const QByteArrayList cameraUniforms
static const QByteArrayList lightUniforms
static QT_BEGIN_NAMESPACE constexpr int s_maxDirectionalLights
static const QByteArrayList positionalShadows
static constexpr int s_maxPositionalLights
static QSSGRhiShaderPipelinePtr generateRhiShaderPipeline(const QByteArray &inKey, QSSGRenderContextInterface *cif, const QSSGRenderComputePass *pass, const QSSGComputeLightContext &lightContext, const bool multiview, int viewCount)
static const QByteArrayList screenTextures
bool finalizeComputeShader(QSSGUserComputeShader &computeShader)
static bool containsAny(const QSet< QByteArray > &identifiers, const QByteArrayList &list)
static quint32 softShadowQualityToInt(QSSGRenderLight::SoftShadowQuality quality)
void prepareComputePass(QSSGRenderer &renderer, QSSGLayerRenderData &data, QSSGRenderComputePass *passNode, ComputeUserPassData &passData, QSSGPassKey key)
AllocateBufferFlagValues
QSSGShaderDefineList m_shaderDefines
QSSGRhiShaderPipelinePtr m_computePipeline
QRhiShaderResourceBindings * m_computeBindings
QSSGRenderShaderValue::ivec3 m_groupCount
QSSGAllocateBufferFlags(quint32 inValues)
void setSceneLifetime(bool inValue)
QSSGRenderTextureFormat m_format
QSSGAllocateBuffer(const QByteArray &inName, QSSGRenderTextureFormat inFormat, QSSGRenderTextureFilterOp inFilterOp, QSSGRenderTextureCoordOp inCoordOp, float inMultiplier, QSSGAllocateBufferFlags inFlags)
void addDebug(QDebug &stream) const
QSSGRenderTextureFilterOp m_filterOp
QSSGRenderTextureCoordOp m_texCoordOp
QSSGAllocateBufferFlags m_bufferFlags
QSSGAllocateBuffer(const QSSGAllocateBuffer &command)
void addDebug(QDebug &stream) const
QSSGApplyBufferValue(const QByteArray &bufferName, const QByteArray &shaderSampler)
QSSGApplyBufferValue(const QSSGApplyBufferValue &command)
QSSGApplyInstanceValue(const QSSGApplyInstanceValue &command)
QSSGApplyInstanceValue(const QByteArray &inName, QSSGRenderShaderValue::Type inValueType, quint32 inValueOffset)
QSSGRenderShaderValue::Type m_valueType
void addDebug(QDebug &stream) const
QSSGApplyValue(const QByteArray &inName)
void addDebug(QDebug &stream) const
QSSGApplyValue(const QSSGApplyValue &command)
void addDebug(QDebug &stream) const
QSSGBindBuffer(const QSSGBindBuffer &command)
QSSGBindBuffer(const QByteArray &inBufName)
QSSGBindShader(const QSSGBindShader &command)
void addDebug(QDebug &stream) const
QSSGBindShader(const QByteArray &inShaderPathKey)
QSSGBindTarget(const QSSGBindTarget &command)
QSSGRenderTextureFormat m_outputFormat
void addDebug(QDebug &stream) const
QSSGBindTarget(QSSGRenderTextureFormat inFormat=QSSGRenderTextureFormat::RGBA8)
void addDebug(QDebug &stream) const
QSSGRender(const QSSGRender &)