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 Sheen = 1 << 20,
118 Anisotropy = 1 << 21,
119 Iridescence = 1 << 22,
120 Dispersion = 1 << 23
121 };
122 Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
123
124 enum {
125 RegularShaderPathKeyIndex = 0,
126 MultiViewShaderPathKeyIndex = 1
127 };
128 QByteArray m_shaderPathKey[2];
129 CustomShaderPresence m_customShaderPresence;
130
131 TexturePropertyList m_textureProperties;
132 PropertyList m_properties;
133
134 QSSGRenderImage *m_iblProbe = nullptr;
135 QSSGRenderImage *m_emissiveMap = nullptr;
136 QSSGCullFaceMode m_cullMode = QSSGCullFaceMode::Back;
137 QSSGDepthDrawMode m_depthDrawMode = QSSGDepthDrawMode::OpaqueOnly;
138 RenderFlags m_renderFlags;
139 QRhiGraphicsPipeline::BlendFactor m_srcBlend;
140 QRhiGraphicsPipeline::BlendFactor m_dstBlend;
141 QRhiGraphicsPipeline::BlendFactor m_srcAlphaBlend;
142 QRhiGraphicsPipeline::BlendFactor m_dstAlphaBlend;
143 float m_lineWidth = 1.0f;
144
145 QSSGRenderGraphObject *m_nextSibling = nullptr;
146
147 ShadingMode m_shadingMode = ShadingMode::Shaded;
148
149 FlagT m_flags { FlagT(Flags::Dirty) };
150 bool incompleteBuildTimeObject = false; // Used by the shadergen tool
151 bool m_usesSharedVariables = false;
152
153 void markDirty();
154 void clearDirty();
155 void setAlwaysDirty(bool v);
156 [[nodiscard]] inline bool isDirty() const { return ((m_flags & (FlagT(Flags::Dirty) | FlagT(Flags::AlwaysDirty))) != 0); }
157
158 QSSGShaderMaterialAdapter *adapter = nullptr;
159
160 QString debugObjectName;
161};
162
163
164
165Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRenderCustomMaterial::CustomShaderPresence)
166
167QT_END_NAMESPACE
168
169#endif
QSSGPickResultProcessResult(const QSSGRenderPickResult &inSrc, bool consumed)
QSSGPickResultProcessResult(const QSSGRenderPickResult &inSrc)
friend class QSSGRenderContextInterface
Combined button and popup list for selecting options.
static QVector3D closestPointOnTriangle(const QVector3D &p, const QVector3D &a, const QVector3D &b, const QVector3D &c, const Dot &dot, float &u, float &v, float &w)
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
Definition qsize.h:192
static void cleanupResourcesImpl(const QSSGRenderContextInterface &rci, const Container &resources)
static void getPickableRecursive(const QSSGRenderNode &node, RenderableList &renderables, bool pickEverything=false)
static void dfs(const QSSGRenderNode &node, RenderableList &renderables)
static QByteArray rendererLogPrefix()
static QSSGCullFaceMode mirroredCullMode(QSSGCullFaceMode cullMode)
static QSSGCullFaceMode cullModeForSubset(const QSSGRenderModel &model, int subset)
TShaderMapKey< QSSGShaderParticleMaterialKey > QSSGParticleShaderMapKey