56 Q_DISABLE_COPY(QSSGRenderSkyMaterialManager)
58 explicit QSSGRenderSkyMaterialManager(
const QSSGRenderContextInterface &inContext);
59 ~QSSGRenderSkyMaterialManager();
61 void releaseCachedResources();
66 bool ensureEnvironmentMap(QSSGRenderSkyMaterial *settings);
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,
77 const QSSGRhiShaderPipelinePtr &shaderPipeline,
78 QRhiCommandBuffer *cb,
79 QRhiResourceUpdateBatch *rub);
80 void runEnvironmentMipChain(
const FrameState &fs, QRhiCommandBuffer *cb);
81 bool runPrefilterCycle(QSSGRenderSkyMaterial *inSky,
const FrameState &fs, QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *&rub);
82 void initializeTailMips(
const FrameState &fs, QRhiCommandBuffer *cb);
86 QSSGRenderImageTexture m_skyIblTexture;
90 QRhiTexture *m_envCubeMap =
nullptr;
91 QRhiTexture *m_prefilteredCubeMap =
nullptr;
93 int m_prefilteredMipCount = 0;
101 QList<QRhiTexture *> m_prefilterAccumulators;
105 bool m_finalizeIblPending =
false;
107 int m_accumulatedSamples = 0;
108 int m_accumIblSampleCount = 0;
109 bool m_haveConvergedResult =
false;
110 bool m_envTailMipsInitialized =
false;
111 bool m_prefilteredTailMipsInitialized =
false;
113 struct PrefilterResourceCache
116 QSize environmentMapSize;
117 bool enableIBL =
false;
118 int prefilterTotalMipCount = 0;
119 QRhiTexture *envCubeMap =
nullptr;
120 QRhiTexture *prefilteredCubeMap =
nullptr;
122 QList<QRhiTexture *> prefilterAccumulators;
123 QSSGRhiShaderPipeline *envShaderPipeline =
nullptr;
126 QRhiBuffer *vertexBuffer =
nullptr;
127 QRhiBuffer *uBuf =
nullptr;
128 QRhiBuffer *uBufSlice =
nullptr;
129 QRhiBuffer *uBufNormalize =
nullptr;
130 QRhiBuffer *uBufIrradiance =
nullptr;
138 QList<QSSGSkyIblFaceTargets> accumPreserveFaceTargets;
139 QList<QSSGSkyIblFaceTargets> accumClearFaceTargets;
141 QRhiShaderResourceBindings *sliceSrb =
nullptr;
144 QVarLengthArray<QRhiShaderResourceBindings *, 6> normalizeSrbs;
145 QRhiShaderResourceBindings *irradianceSrb =
nullptr;
147 QRhiGraphicsPipeline *envMapPipeline =
nullptr;
148 QRhiGraphicsPipeline *slicePipeline =
nullptr;
149 QRhiGraphicsPipeline *normalizeCubePipeline =
nullptr;
150 QRhiGraphicsPipeline *irradiancePipeline =
nullptr;
153 PrefilterResourceCache m_cache;
155 void clearPrefilterCache();