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 using Property = QSSGBaseTypeProperty;
64 using PropertyUniformsList = QList<Property>;
65
66 enum class Flags : quint8
67 {
68 Dirty = 0x1,
69 AlwaysDirty = 0x2
70 };
71 using FlagT = std::underlying_type_t<Flags>;
72
73 enum class ShadingMode // must match QQuick3DCustomMaterial::ShadingMode
74 {
75 Unshaded,
76 Shaded
77 };
78
79 enum class CustomShaderPresenceFlag {
80 Vertex = 1 << 0,
81 Fragment = 1 << 1
82 };
83 Q_DECLARE_FLAGS(CustomShaderPresence, CustomShaderPresenceFlag)
84
85 enum class RenderFlag {
86 Blending = 1 << 0,
87 ScreenTexture = 1 << 1,
88 DepthTexture = 1 << 2,
89 AoTexture = 1 << 3,
90 OverridesPosition = 1 << 4,
91 ProjectionMatrix = 1 << 5,
92 InverseProjectionMatrix = 1 << 6,
93 ScreenMipTexture = 1 << 7,
94 VarColor = 1 << 8,
95 IblOrientation = 1 << 9,
96 Lightmap = 1 << 10,
97 Skinning = 1 << 11,
98 Morphing = 1 << 12,
99 ViewIndex = 1 << 13,
100 Clearcoat = 1 << 14,
101 ClearcoatFresnelScaleBias = 1 << 15,
102 FresnelScaleBias = 1 << 16,
103 Transmission = 1 << 17,
104 NormalTexture = 1 << 18,
105 MotionVectorTexture = 1 << 19,
106 Sheen = 1 << 20,
107 Anisotropy = 1 << 21,
108 Iridescence = 1 << 22,
109 Dispersion = 1 << 23
110 };
111 Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
112
113 enum {
114 RegularShaderPathKeyIndex = 0,
115 MultiViewShaderPathKeyIndex = 1
116 };
117 QByteArray m_shaderPathKey[2];
118 CustomShaderPresence m_customShaderPresence;
119
120 TexturePropertyList m_textureProperties;
121 PropertyUniformsList m_properties;
122
123 QSSGRenderImage *m_iblProbe = nullptr;
124 QSSGRenderImage *m_emissiveMap = nullptr;
125 QSSGCullFaceMode m_cullMode = QSSGCullFaceMode::Back;
126 QSSGDepthDrawMode m_depthDrawMode = QSSGDepthDrawMode::OpaqueOnly;
127 RenderFlags m_renderFlags;
128 QRhiGraphicsPipeline::BlendFactor m_srcBlend;
129 QRhiGraphicsPipeline::BlendFactor m_dstBlend;
130 QRhiGraphicsPipeline::BlendFactor m_srcAlphaBlend;
131 QRhiGraphicsPipeline::BlendFactor m_dstAlphaBlend;
132 float m_lineWidth = 1.0f;
133
134 QSSGRenderGraphObject *m_nextSibling = nullptr;
135
136 ShadingMode m_shadingMode = ShadingMode::Shaded;
137
138 FlagT m_flags { FlagT(Flags::Dirty) };
139 bool incompleteBuildTimeObject = false; // Used by the shadergen tool
140 bool m_usesSharedVariables = false;
141
142 void markDirty();
143 void clearDirty();
144 void setAlwaysDirty(bool v);
145 [[nodiscard]] inline bool isDirty() const { return ((m_flags & (FlagT(Flags::Dirty) | FlagT(Flags::AlwaysDirty))) != 0); }
146
147 QSSGShaderMaterialAdapter *adapter = nullptr;
148
149 QString debugObjectName;
150};
151
152
153
154Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRenderCustomMaterial::CustomShaderPresence)
155
156QT_END_NAMESPACE
157
158#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