1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QSSG_RENDER_REFLECTION_MAP_H
#define QSSG_RENDER_REFLECTION_MAP_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrenderreflectionprobe_p.h>
QT_BEGIN_NAMESPACE
class QRhi;
class QRhiCommandBuffer;
class QSSGRhiContext;
class QSSGRenderContextInterface;
class QRhiRenderBuffer;
class QRhiTextureRenderTarget;
class QRhiRenderPassDescriptor;
class QRhiTexture;
class QRhiGraphicsPipeline;
class QRhiShaderResourceBindings;
class QRhiBuffer;
struct QSSGReflectionMapEntry
{
QSSGReflectionMapEntry();
static QSSGReflectionMapEntry withRhiTexturedCubeMap(quint32 probeIdx,
QRhiTexture *preFiltered);
static QSSGReflectionMapEntry withRhiCubeMap(quint32 probeIdx,
QRhiTexture *cube,
QRhiTexture *prefiltered,
QRhiRenderBuffer *depthStencil);
void renderMips(QSSGRhiContext *rhiCtx);
void destroyRhiResources();
quint32 m_probeIndex;
// RHI resources
QRhiTexture *m_rhiCube = nullptr;
QRhiTexture *m_rhiPrefilteredCube = nullptr;
QRhiRenderBuffer *m_rhiDepthStencil = nullptr;
QVarLengthArray<QRhiTextureRenderTarget *, 6> m_rhiRenderTargets;
QRhiRenderPassDescriptor *m_rhiRenderPassDesc = nullptr;
QRhiGraphicsPipeline *m_prefilterPipeline = nullptr;
QRhiGraphicsPipeline *m_irradiancePipeline = nullptr;
QRhiShaderResourceBindings *m_prefilterSrb = nullptr;
QRhiShaderResourceBindings *m_irradianceSrb = nullptr;
QRhiBuffer *m_prefilterVertBuffer = nullptr;
QRhiBuffer *m_prefilterFragBuffer = nullptr;
QRhiBuffer *m_irradianceFragBuffer = nullptr;
QMap<int, QVarLengthArray<QRhiTextureRenderTarget *, 6>> m_rhiPrefilterRenderTargetsMap;
QRhiRenderPassDescriptor *m_rhiPrefilterRenderPassDesc = nullptr;
QMap<int, QSize> m_prefilterMipLevelSizes;
QVarLengthArray<QRhiShaderResourceBindings *, 6> m_skyBoxSrbs;
QMatrix4x4 m_viewProjection;
bool m_needsRender = false;
bool m_rendered = false;
QSSGRenderReflectionProbe::ReflectionTimeSlicing m_timeSlicing = QSSGRenderReflectionProbe::ReflectionTimeSlicing::None;
int m_timeSliceFrame = 1;
QSSGRenderTextureCubeFace m_timeSliceFace = { QSSGRenderTextureCubeFaces[0] };
Q_QUICK3D_PROFILE_ID
};
class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderReflectionMap
{
typedef QVector<QSSGReflectionMapEntry> TReflectionMapEntryList;
Q_DISABLE_COPY(QSSGRenderReflectionMap)
public:
const QSSGRenderContextInterface &m_context;
explicit QSSGRenderReflectionMap(const QSSGRenderContextInterface &inContext);
~QSSGRenderReflectionMap();
void releaseCachedResources();
void addReflectionMapEntry(qint32 probeIdx, const QSSGRenderReflectionProbe &probe);
void addTexturedReflectionMapEntry(qint32 probeIdx, const QSSGRenderReflectionProbe &probe);
QSSGReflectionMapEntry *reflectionMapEntry(int probeIdx);
qint32 reflectionMapEntryCount() { return m_reflectionMapList.size(); }
private:
TReflectionMapEntryList m_reflectionMapList;
};
using QSSGRenderReflectionMapPtr = std::shared_ptr<QSSGRenderReflectionMap>;
QT_END_NAMESPACE
#endif
|