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
5#ifndef QSSG_RHI_CUSTOM_MATERIAL_SYSTEM_H
6#define QSSG_RHI_CUSTOM_MATERIAL_SYSTEM_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuick3DRuntimeRender/qtquick3druntimerenderglobal.h>
20#include <QtQuick3DRuntimeRender/private/qssgrendershaderlibrarymanager_p.h>
21#include <QtQuick3DRuntimeRender/private/qssgrenderableobjects_p.h>
22#include <QtQuick3DRuntimeRender/private/qssgrendercustommaterial_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrendershaderkeys_p.h>
24#include <QtQuick3DRuntimeRender/private/qssgshadermapkey_p.h>
25#include <QtCore/qhash.h>
26#include <QtGui/QMatrix4x4>
27
28QT_BEGIN_NAMESPACE
29
30struct QSSGRenderCustomMaterial;
31struct QSSGRenderSubset;
32struct QSSGRenderModel;
34struct QSSGRenderableImage;
35struct QSSGRenderLayer;
36struct QSSGRenderLight;
37struct QSSGRenderCamera;
39class QRhiTexture;
40
41
42class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGCustomMaterialSystem
43{
44 Q_DISABLE_COPY(QSSGCustomMaterialSystem)
45 typedef QPair<QByteArray, QByteArray> TStrStrPair;
46 typedef QHash<QSSGShaderMapKey, QSSGRhiShaderPipelinePtr> TShaderMap;
47
48 QSSGRenderContextInterface *context = nullptr;
49 TShaderMap shaderMap;
50
51 void setShaderResources(char *ubufData,
52 const QSSGRenderCustomMaterial &inMaterial,
53 const QByteArray &inPropertyName,
54 const QVariant &propertyValue,
55 QSSGRenderShaderValue::Type inPropertyType,
56 QSSGRhiShaderPipeline &shaderPipeline);
57
58public:
59 QSSGCustomMaterialSystem();
60 ~QSSGCustomMaterialSystem();
61
62 void setRenderContextInterface(QSSGRenderContextInterface *inContext);
63
64 void releaseCachedResources();
65
66 // Returns true if the material is dirty and thus will produce a different render result
67 // than previously. This effects things like progressive AA.
68 bool prepareForRender(const QSSGRenderModel &inModel,
69 const QSSGRenderSubset &inSubset,
70 QSSGRenderCustomMaterial &inMaterial);
71
72 QSSGRhiShaderPipelinePtr shadersForCustomMaterial(QSSGRhiGraphicsPipelineState *ps,
73 const QSSGRenderCustomMaterial &material,
74 QSSGSubsetRenderable &renderable,
75 const QSSGShaderDefaultMaterialKeyProperties &defaultMaterialShaderKeyProperties,
76 const QSSGShaderFeatures &featureSet);
77
78 void updateUniformsForCustomMaterial(QSSGRhiShaderPipeline &shaderPipeline,
79 QSSGRhiContext *rhiCtx,
80 const QSSGLayerRenderData &inData,
81 char *ubufData,
82 QSSGRhiGraphicsPipelineState *ps,
83 const QSSGRenderCustomMaterial &material,
84 QSSGSubsetRenderable &renderable,
85 const QSSGRenderCameraList &cameras,
86 const QVector2D *depthAdjust,
87 const QMatrix4x4 *alteredModelViewProjection);
88
89 void rhiPrepareRenderable(QSSGRhiGraphicsPipelineState *ps,
90 QSSGPassKey passKey,
91 QSSGSubsetRenderable &renderable,
92 const QSSGShaderFeatures &featureSet,
93 const QSSGRenderCustomMaterial &material,
94 const QSSGLayerRenderData &layerData,
95 QRhiRenderPassDescriptor *renderPassDescriptor,
96 int samples,
97 int viewCount,
98 QSSGRenderCamera *camera = nullptr,
99 QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone,
100 QMatrix4x4 *modelViewProjection = nullptr,
101 QSSGReflectionMapEntry *entry = nullptr);
102 void applyRhiShaderPropertyValues(char *ubufData,
103 const QSSGRenderCustomMaterial &inMaterial,
104 QSSGRhiShaderPipeline &shaderPipeline);
105 void rhiRenderRenderable(QSSGRhiContext *rhiCtx,
106 QSSGSubsetRenderable &renderable,
107 bool *needsSetViewport,
108 QSSGRenderTextureCubeFace cubeFace,
109 const QSSGRhiGraphicsPipelineState &state);
110};
111
112QT_END_NAMESPACE
113
114#endif
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 rhiRenderRenderable(QSSGRhiContext *rhiCtx, QSSGSubsetRenderable &renderable, bool *needsSetViewport, QSSGRenderTextureCubeFace cubeFace, const QSSGRhiGraphicsPipelineState &state)
void applyRhiShaderPropertyValues(char *ubufData, const QSSGRenderCustomMaterial &inMaterial, QSSGRhiShaderPipeline &shaderPipeline)
void setRenderContextInterface(QSSGRenderContextInterface *inContext)
QSSGRhiShaderPipelinePtr shadersForCustomMaterial(QSSGRhiGraphicsPipelineState *ps, const QSSGRenderCustomMaterial &material, QSSGSubsetRenderable &renderable, const QSSGShaderDefaultMaterialKeyProperties &defaultMaterialShaderKeyProperties, const QSSGShaderFeatures &featureSet)
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 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