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;
103 int m_accumulatedSamples = 0;
104 int m_accumIblSampleCount = 0;
105 bool m_haveConvergedResult =
false;
106 bool m_envTailMipsInitialized =
false;
107 bool m_prefilteredTailMipsInitialized =
false;
109 struct PrefilterResourceCache
112 QSize environmentMapSize;
113 bool enableIBL =
false;
114 int prefilterTotalMipCount = 0;
115 QRhiTexture *envCubeMap =
nullptr;
116 QRhiTexture *prefilteredCubeMap =
nullptr;
118 QList<QRhiTexture *> prefilterAccumulators;
119 QSSGRhiShaderPipeline *envShaderPipeline =
nullptr;
122 QRhiBuffer *vertexBuffer =
nullptr;
123 QRhiBuffer *uBuf =
nullptr;
124 QRhiBuffer *uBufSlice =
nullptr;
125 QRhiBuffer *uBufNormalize =
nullptr;
126 QRhiBuffer *uBufIrradiance =
nullptr;
134 QList<QSSGSkyIblFaceTargets> accumPreserveFaceTargets;
135 QList<QSSGSkyIblFaceTargets> accumClearFaceTargets;
137 QRhiShaderResourceBindings *sliceSrb =
nullptr;
140 QVarLengthArray<QRhiShaderResourceBindings *, 6> normalizeSrbs;
141 QRhiShaderResourceBindings *irradianceSrb =
nullptr;
143 QRhiGraphicsPipeline *envMapPipeline =
nullptr;
144 QRhiGraphicsPipeline *slicePipeline =
nullptr;
145 QRhiGraphicsPipeline *normalizeCubePipeline =
nullptr;
146 QRhiGraphicsPipeline *irradiancePipeline =
nullptr;
149 PrefilterResourceCache m_cache;
151 void clearPrefilterCache();