56 Q_DISABLE_COPY(QSSGRenderSkyMaterialManager)
58 explicit QSSGRenderSkyMaterialManager(
const QSSGRenderContextInterface &inContext);
59 ~QSSGRenderSkyMaterialManager();
61 void releaseCachedResources();
66 bool ensureEnvironmentMap(QSSGRenderSkyMaterial *settings, QSSGPassKey passKey);
70 bool computeFrameState(QSSGRenderSkyMaterial *inSky, FrameState &fs);
71 bool ensureTextures(FrameState &fs);
72 void deriveCycleState(QSSGRenderSkyMaterial *inSky, FrameState &fs);
73 void validateAndUpdateCacheKey(
const FrameState &fs, QSSGRhiShaderPipeline *envShaderPipelineKey);
74 bool ensureSharedResources(FrameState &fs, QRhiCommandBuffer *cb);
75 bool renderEnvironmentCube(QSSGRenderSkyMaterial *inSky,
78 const QSSGRhiShaderPipelinePtr &shaderPipeline,
79 QRhiCommandBuffer *cb,
80 QRhiResourceUpdateBatch *rub);
81 void runEnvironmentMipChain(
const FrameState &fs, QRhiCommandBuffer *cb);
82 bool runPrefilterCycle(QSSGRenderSkyMaterial *inSky,
const FrameState &fs, QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *&rub);
83 void initializeTailMips(
const FrameState &fs, QRhiCommandBuffer *cb);
87 QSSGRenderImageTexture m_skyIblTexture;
91 QRhiTexture *m_envCubeMap =
nullptr;
92 QRhiTexture *m_prefilteredCubeMap =
nullptr;
94 int m_prefilteredMipCount = 0;
102 QList<QRhiTexture *> m_prefilterAccumulators;
106 bool m_finalizeIblPending =
false;
108 int m_accumulatedSamples = 0;
109 int m_accumIblSampleCount = 0;
110 bool m_haveConvergedResult =
false;
111 bool m_envTailMipsInitialized =
false;
112 bool m_prefilteredTailMipsInitialized =
false;
114 struct PrefilterResourceCache
117 QSize environmentMapSize;
118 bool enableIBL =
false;
119 int prefilterTotalMipCount = 0;
120 QRhiTexture *envCubeMap =
nullptr;
121 QRhiTexture *prefilteredCubeMap =
nullptr;
123 QList<QRhiTexture *> prefilterAccumulators;
124 QSSGRhiShaderPipeline *envShaderPipeline =
nullptr;
127 QRhiBuffer *vertexBuffer =
nullptr;
128 QRhiBuffer *uBuf =
nullptr;
129 QRhiBuffer *uBufSlice =
nullptr;
130 QRhiBuffer *uBufNormalize =
nullptr;
131 QRhiBuffer *uBufIrradiance =
nullptr;
139 QList<QSSGSkyIblFaceTargets> accumPreserveFaceTargets;
140 QList<QSSGSkyIblFaceTargets> accumClearFaceTargets;
142 QRhiShaderResourceBindings *sliceSrb =
nullptr;
145 QVarLengthArray<QRhiShaderResourceBindings *, 6> normalizeSrbs;
146 QRhiShaderResourceBindings *irradianceSrb =
nullptr;
148 QRhiGraphicsPipeline *envMapPipeline =
nullptr;
149 QRhiGraphicsPipeline *slicePipeline =
nullptr;
150 QRhiGraphicsPipeline *normalizeCubePipeline =
nullptr;
151 QRhiGraphicsPipeline *irradiancePipeline =
nullptr;
154 PrefilterResourceCache m_cache;
156 void clearPrefilterCache();