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
qssgrendercustommaterial_p.h
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2019 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6
7#ifndef QSSG_RENDER_CUSTOM_MATERIAL_H
8#define QSSG_RENDER_CUSTOM_MATERIAL_H
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include <QtCore/qurl.h>
22#include <QtCore/qvariant.h>
23#include <QtCore/qvector.h>
24#include <rhi/qrhi.h>
25
26#include <QtQuick3DRuntimeRender/qtquick3druntimerenderexports.h>
27#include <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h>
28#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
29
31
32struct QSSGRenderImage;
33struct QSSGShaderMaterialAdapter;
34class QQuick3DShaderUtilsTextureInput;
35class QQuick3DTexture;
36
37struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderCustomMaterial : public QSSGRenderGraphObject
38{
39 QSSGRenderCustomMaterial();
40 ~QSSGRenderCustomMaterial();
41
42 struct TextureProperty
43 {
44 QQuick3DShaderUtilsTextureInput *texInput = nullptr;
45 QSSGRenderImage *texImage = nullptr;
46 QByteArray name;
47 QSSGRenderShaderValue::Type shaderDataType;
48 QSSGRenderTextureFilterOp minFilterType = QSSGRenderTextureFilterOp::Linear;
49 QSSGRenderTextureFilterOp magFilterType = QSSGRenderTextureFilterOp::Linear;
50 QSSGRenderTextureFilterOp mipFilterType = QSSGRenderTextureFilterOp::Linear;
51 QSSGRenderTextureCoordOp horizontalClampType = QSSGRenderTextureCoordOp::ClampToEdge;
52 QSSGRenderTextureCoordOp verticalClampType = QSSGRenderTextureCoordOp::ClampToEdge;
53 QSSGRenderTextureCoordOp zClampType = QSSGRenderTextureCoordOp::ClampToEdge;
54 QQuick3DTexture *lastConnectedTexture = nullptr;
55 QMetaObject::Connection minFilterChangedConn;
56 QMetaObject::Connection magFilterChangedConn;
57 QMetaObject::Connection mipFilterChangedConn;
58 QMetaObject::Connection horizontalTilingChangedConn;
59 QMetaObject::Connection verticalTilingChangedConn;
60 QMetaObject::Connection depthTilingChangedConn;
61 };
62 using TexturePropertyList = QList<TextureProperty>;
63
64 struct Property
65 {
66 Property() = default;
67 Property(const QByteArray &name, const QVariant &value, QSSGRenderShaderValue::Type shaderDataType, int pid = -1)
68 : name(name), value(value), shaderDataType(shaderDataType), pid(pid)
69 { }
70 QByteArray name;
71 QVariant value;
72 QSSGRenderShaderValue::Type shaderDataType;
73 int pid;
74 };
75 using PropertyList = QList<Property>;
76
77 enum class Flags : quint8
78 {
79 Dirty = 0x1,
80 AlwaysDirty = 0x2
81 };
82 using FlagT = std::underlying_type_t<Flags>;
83
84 enum class ShadingMode // must match QQuick3DCustomMaterial::ShadingMode
85 {
86 Unshaded,
87 Shaded
88 };
89
90 enum class CustomShaderPresenceFlag {
91 Vertex = 1 << 0,
92 Fragment = 1 << 1
93 };
94 Q_DECLARE_FLAGS(CustomShaderPresence, CustomShaderPresenceFlag)
95
96 enum class RenderFlag {
97 Blending = 1 << 0,
98 ScreenTexture = 1 << 1,
99 DepthTexture = 1 << 2,
100 AoTexture = 1 << 3,
101 OverridesPosition = 1 << 4,
102 ProjectionMatrix = 1 << 5,
103 InverseProjectionMatrix = 1 << 6,
104 ScreenMipTexture = 1 << 7,
105 VarColor = 1 << 8,
106 IblOrientation = 1 << 9,
107 Lightmap = 1 << 10,
108 Skinning = 1 << 11,
109 Morphing = 1 << 12,
110 ViewIndex = 1 << 13,
111 Clearcoat = 1 << 14,
112 ClearcoatFresnelScaleBias = 1 << 15,
113 FresnelScaleBias = 1 << 16,
114 Transmission = 1 << 17,
115 NormalTexture = 1 << 18,
116 MotionVectorTexture = 1 << 19
117 };
118 Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
119
120 enum {
121 RegularShaderPathKeyIndex = 0,
122 MultiViewShaderPathKeyIndex = 1
123 };
124 QByteArray m_shaderPathKey[2];
125 CustomShaderPresence m_customShaderPresence;
126
127 TexturePropertyList m_textureProperties;
128 PropertyList m_properties;
129
130 QSSGRenderImage *m_iblProbe = nullptr;
131 QSSGRenderImage *m_emissiveMap = nullptr;
132 QSSGCullFaceMode m_cullMode = QSSGCullFaceMode::Back;
133 QSSGDepthDrawMode m_depthDrawMode = QSSGDepthDrawMode::OpaqueOnly;
134 RenderFlags m_renderFlags;
135 QRhiGraphicsPipeline::BlendFactor m_srcBlend;
136 QRhiGraphicsPipeline::BlendFactor m_dstBlend;
137 QRhiGraphicsPipeline::BlendFactor m_srcAlphaBlend;
138 QRhiGraphicsPipeline::BlendFactor m_dstAlphaBlend;
139 float m_lineWidth = 1.0f;
140
141 QSSGRenderGraphObject *m_nextSibling = nullptr;
142
143 ShadingMode m_shadingMode = ShadingMode::Shaded;
144
145 FlagT m_flags { FlagT(Flags::Dirty) };
146 bool incompleteBuildTimeObject = false; // Used by the shadergen tool
147 bool m_usesSharedVariables = false;
148
149 void markDirty();
150 void clearDirty();
151 void setAlwaysDirty(bool v);
152 [[nodiscard]] inline bool isDirty() const { return ((m_flags & (FlagT(Flags::Dirty) | FlagT(Flags::AlwaysDirty))) != 0); }
153
154 QSSGShaderMaterialAdapter *adapter = nullptr;
155
156 QString debugObjectName;
157};
158
159
160
161Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRenderCustomMaterial::CustomShaderPresence)
162
163QT_END_NAMESPACE
164
165#endif
Combined button and popup list for selecting options.