1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSG_RENDER_EFFECT_H
5#define QSSG_RENDER_EFFECT_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 purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h>
19#include <QtQuick3DRuntimeRender/private/qssgrendernode_p.h>
20
21#include <QtQuick3DRuntimeRender/private/qssgrenderimage_p.h>
22#include <QtQuick3DRuntimeRender/private/qssgrendershaderlibrarymanager_p.h>
23
24#include <QtCore/QVariant>
25
26QT_BEGIN_NAMESPACE
27
28struct QSSGRenderLayer;
29struct QSSGCommand;
30class QSSGRenderContextInterface;
31
32struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderEffect : public QSSGRenderGraphObject
33{
34 QSSGRenderEffect();
35 ~QSSGRenderEffect();
36
37 void finalizeShaders(const QSSGRenderLayer &layer, QSSGRenderContextInterface *renderContext);
38
39 enum class Flags : quint8
40 {
41 Dirty = 0x1u
42 };
43 using FlagT = std::underlying_type_t<Flags>;
44
45 struct TextureProperty
46 {
47 QSSGRenderImage *texImage = nullptr;
48 QByteArray name;
49 QSSGRenderShaderValue::Type shaderDataType;
50 QSSGRenderTextureFilterOp minFilterType = QSSGRenderTextureFilterOp::Linear;
51 QSSGRenderTextureFilterOp magFilterType = QSSGRenderTextureFilterOp::Linear;
52 QSSGRenderTextureFilterOp mipFilterType = QSSGRenderTextureFilterOp::Linear;
53 QSSGRenderTextureCoordOp horizontalClampType = QSSGRenderTextureCoordOp::ClampToEdge;
54 QSSGRenderTextureCoordOp verticalClampType = QSSGRenderTextureCoordOp::ClampToEdge;
55 QSSGRenderTextureTypeValue usageType;
56 };
57
58 QVector<TextureProperty> textureProperties;
59
60 struct Property
61 {
62 Property() = default;
63 Property(const QByteArray &name, const QByteArray &typeName, const QVariant &value, QSSGRenderShaderValue::Type shaderDataType, int pid = -1)
64 : name(name), typeName(typeName), value(value), shaderDataType(shaderDataType), pid(pid)
65 { }
66 QByteArray name;
67 QByteArray typeName;
68 mutable QVariant value;
69 QSSGRenderShaderValue::Type shaderDataType;
70 int pid;
71 };
72
73 QVector<Property> properties;
74
75 QSSGRenderEffect *m_nextEffect = nullptr;
76
77 void markDirty();
78 void clearDirty();
79 [[nodiscard]] inline bool isDirty() const { return ((flags & FlagT(Flags::Dirty)) != 0); }
80
81 struct Command {
82 QSSGCommand *command;
83 quint8 own : 1;
84 };
85 QVector<Command> commands;
86
87 void resetCommands();
88
89 const char *className = nullptr;
90 FlagT flags = FlagT(Flags::Dirty);
91 bool requiresDepthTexture = false;
92 bool incompleteBuildTimeObject = false; // Used by the shadergen tool
93 QSSGRenderTextureFormat::Format outputFormat = QSSGRenderTextureFormat::Unknown;
94
95 struct ShaderPrepPassData
96 {
97 QByteArray shaderPathKeyPrefix; // to be completed in finalizeShaders
98 QByteArray vertexShaderCode; // without main(), to be completed in finalizeShaders
99 QByteArray fragmentShaderCode; // same here
100 QSSGCustomShaderMetaData vertexMetaData;
101 QSSGCustomShaderMetaData fragmentMetaData;
102 int bindShaderCmdIndex = 0;
103 };
104
105 struct {
106 bool valid = false;
107 QVector<ShaderPrepPassData> passes;
108 } shaderPrepData;
109
110 QString debugObjectName;
111};
112
113QT_END_NAMESPACE
114
115#endif
116

source code of qtquick3d/src/runtimerender/graphobjects/qssgrendereffect_p.h