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
qssgrhicustommaterialsystem_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_RHI_CUSTOM_MATERIAL_SYSTEM_H
8#define QSSG_RHI_CUSTOM_MATERIAL_SYSTEM_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 <QtQuick3DRuntimeRender/qtquick3druntimerenderglobal.h>
22#include <QtQuick3DRuntimeRender/private/qssgrendershaderlibrarymanager_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrenderableobjects_p.h>
24#include <QtQuick3DRuntimeRender/private/qssgrendercustommaterial_p.h>
25#include <QtQuick3DRuntimeRender/private/qssgrendershaderkeys_p.h>
26#include <QtQuick3DRuntimeRender/private/qssgshadermapkey_p.h>
27#include <QtCore/qhash.h>
28#include <QtGui/QMatrix4x4>
29
30QT_BEGIN_NAMESPACE
31
32struct QSSGRenderCustomMaterial;
33struct QSSGRenderSubset;
34struct QSSGRenderModel;
36struct QSSGRenderableImage;
37struct QSSGRenderLayer;
38struct QSSGRenderLight;
39class QSSGRenderCamera;
41class QRhiTexture;
42
43
44class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGCustomMaterialSystem
45{
46 Q_DISABLE_COPY(QSSGCustomMaterialSystem)
47 typedef QPair<QByteArray, QByteArray> TStrStrPair;
48 typedef QHash<QSSGShaderMapKey, QSSGRhiShaderPipelinePtr> TShaderMap;
49
50 QSSGRenderContextInterface *context = nullptr;
51 TShaderMap shaderMap;
52
53 void setShaderResources(char *ubufData,
54 const QSSGRenderCustomMaterial &inMaterial,
55 const QByteArray &inPropertyName,
56 const QVariant &propertyValue,
57 QSSGRenderShaderValue::Type inPropertyType,
58 QSSGRhiShaderPipeline &shaderPipeline);
59
60public:
61 QSSGCustomMaterialSystem();
62 ~QSSGCustomMaterialSystem();
63
64 void setRenderContextInterface(QSSGRenderContextInterface *inContext);
65
66 void releaseCachedResources();
67
68 // Returns true if the material is dirty and thus will produce a different render result
69 // than previously. This effects things like progressive AA.
70 bool prepareForRender(const QSSGRenderModel &inModel,
71 const QSSGRenderSubset &inSubset,
72 QSSGRenderCustomMaterial &inMaterial);
73
74 QSSGRhiShaderPipelinePtr shadersForCustomMaterial(QSSGRhiGraphicsPipelineState *ps,
75 const QSSGRenderCustomMaterial &material,
76 QSSGSubsetRenderable &renderable,
77 const QSSGShaderDefaultMaterialKeyProperties &defaultMaterialShaderKeyProperties,
78 const QSSGShaderFeatures &featureSet,
79 const QSSGUserShaderAugmentation &shaderAugmentation = {});
80
81 void updateUniformsForCustomMaterial(QSSGRhiShaderPipeline &shaderPipeline,
82 QSSGRhiContext *rhiCtx,
83 const QSSGLayerRenderData &inData,
84 char *ubufData,
85 QSSGRhiGraphicsPipelineState *ps,
86 const QSSGRenderCustomMaterial &material,
87 QSSGSubsetRenderable &renderable,
88 const QSSGRenderCameraList &cameras,
89 const QVector2D *depthAdjust,
90 const QMatrix4x4 *alteredModelViewProjection);
91
92 void rhiPrepareRenderable(QSSGRhiGraphicsPipelineState *ps,
93 QSSGPassKey passKey,
94 QSSGSubsetRenderable &renderable,
95 const QSSGShaderFeatures &featureSet,
96 const QSSGRenderCustomMaterial &material,
97 const QSSGLayerRenderData &layerData,
98 QRhiRenderPassDescriptor *renderPassDescriptor,
99 int samples,
100 int viewCount,
101 QSSGRenderCamera *camera = nullptr,
102 QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone,
103 QMatrix4x4 *modelViewProjection = nullptr,
104 QSSGReflectionMapEntry *entry = nullptr,
105 bool oit = false);
106 void applyRhiShaderPropertyValues(char *ubufData,
107 const QSSGRenderCustomMaterial &inMaterial,
108 QSSGRhiShaderPipeline &shaderPipeline);
109 void rhiRenderRenderable(QSSGRhiContext *rhiCtx,
110 QSSGSubsetRenderable &renderable,
111 bool *needsSetViewport,
112 QSSGRenderTextureCubeFace cubeFace,
113 const QSSGRhiGraphicsPipelineState &state,
114 qsizetype userPassIndex = -1);
115};
116
117QT_END_NAMESPACE
118
119#endif
void rhiPrepareRenderable(QSSGRhiGraphicsPipelineState *ps, QSSGPassKey passKey, QSSGSubsetRenderable &renderable, const QSSGShaderFeatures &featureSet, const QSSGRenderCustomMaterial &material, const QSSGLayerRenderData &layerData, QRhiRenderPassDescriptor *renderPassDescriptor, int samples, int viewCount, QSSGRenderCamera *camera=nullptr, QSSGRenderTextureCubeFace cubeFace=QSSGRenderTextureCubeFaceNone, QMatrix4x4 *modelViewProjection=nullptr, QSSGReflectionMapEntry *entry=nullptr, bool oit=false)
void updateUniformsForCustomMaterial(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, char *ubufData, QSSGRhiGraphicsPipelineState *ps, const QSSGRenderCustomMaterial &material, QSSGSubsetRenderable &renderable, const QSSGRenderCameraList &cameras, const QVector2D *depthAdjust, const QMatrix4x4 *alteredModelViewProjection)
void applyRhiShaderPropertyValues(char *ubufData, const QSSGRenderCustomMaterial &inMaterial, QSSGRhiShaderPipeline &shaderPipeline)
void setRenderContextInterface(QSSGRenderContextInterface *inContext)
void rhiRenderRenderable(QSSGRhiContext *rhiCtx, QSSGSubsetRenderable &renderable, bool *needsSetViewport, QSSGRenderTextureCubeFace cubeFace, const QSSGRhiGraphicsPipelineState &state, qsizetype userPassIndex=-1)
QSSGRhiShaderPipelinePtr shadersForCustomMaterial(QSSGRhiGraphicsPipelineState *ps, const QSSGRenderCustomMaterial &material, QSSGSubsetRenderable &renderable, const QSSGShaderDefaultMaterialKeyProperties &defaultMaterialShaderKeyProperties, const QSSGShaderFeatures &featureSet, const QSSGUserShaderAugmentation &shaderAugmentation={})
bool prepareForRender(const QSSGRenderModel &inModel, const QSSGRenderSubset &inSubset, QSSGRenderCustomMaterial &inMaterial)
Combined button and popup list for selecting options.
static const QRhiShaderResourceBinding::StageFlags CUSTOM_MATERIAL_VISIBILITY_ALL