@@ -43,20 +43,44 @@ struct RenderStateCacheCreateInfo
4343 // / if the object was found in the cache or not.
4444 bool EnableLogging DEFAULT_INITIALIZER (false );
4545
46+ // / Whether to enable hot shader and pipeline state reloading.
47+ // /
48+ // / \note Hot reloading introduces some overhead and should
49+ // / generally be disabled in production builds.
50+ bool EnableHotReload DEFAULT_INITIALIZER (false );
51+
52+ // / Optional shader source input stream factory to use when reloading
53+ // / shaders. If null, original source factory will be used.
54+ IShaderSourceInputStreamFactory* pReloadSource DEFAULT_INITIALIZER (nullptr );
55+
4656#if DILIGENT_CPP_INTERFACE
4757 constexpr RenderStateCacheCreateInfo () noexcept
4858 {}
4959
5060 constexpr explicit RenderStateCacheCreateInfo (
51- IRenderDevice* _pDevice,
52- bool _EnableLogging = RenderStateCacheCreateInfo{}.EnableLogging ) noexcept :
61+ IRenderDevice* _pDevice,
62+ bool _EnableLogging = RenderStateCacheCreateInfo{}.EnableLogging ,
63+ bool _EnableHotReload = RenderStateCacheCreateInfo{}.EnableHotReload ,
64+ IShaderSourceInputStreamFactory* _pReloadSource = RenderStateCacheCreateInfo{}.pReloadSource ) noexcept :
5365 pDevice{_pDevice},
54- EnableLogging{_EnableLogging}
66+ EnableLogging{_EnableLogging},
67+ EnableHotReload{_EnableHotReload},
68+ pReloadSource{_pReloadSource}
5569 {}
5670#endif
5771};
5872typedef struct RenderStateCacheCreateInfo RenderStateCacheCreateInfo;
5973
74+ #if DILIGENT_C_INTERFACE
75+ # define REF *
76+ #else
77+ # define REF &
78+ #endif
79+
80+ // / Type of the callback function called by the IRenderStateCache::Reload method.
81+ typedef void (DILIGENT_CALL_TYPE* ModifyPipelineReloadInfoCallbackType)(PipelineStateCreateInfo REF CreateInfo, void * pUserData);
82+
83+ #undef REF
6084
6185// clang-format on
6286
@@ -161,6 +185,23 @@ DILIGENT_BEGIN_INTERFACE(IRenderStateCache, IObject)
161185
162186 // / Resets the cache to default state.
163187 VIRTUAL void METHOD (Reset)(THIS) PURE;
188+
189+ // / Reloads render states in the cache.
190+
191+ // / \param [in] ModifyReloadInfo - An optional callback function that will be called by the render state cache
192+ // / to let the application modify pipeline state create info before creating new
193+ // / pipeline.
194+ // /
195+ // / \return The total number of render states (shaders and pipelines) that were reloaded.
196+ // /
197+ // / \remars Reloading is only enabled if the cache was created with the EnableHotReload member of
198+ // / RenderStateCacheCreateInfo member set to true.
199+ // /
200+ // / ModifyReloadInfo callback is not allowed to modify shaders, resource layout or pipeline resource
201+ // / signatures. Its main use is to modify the graphics states of a graphics pipeline (blend state,
202+ // / rasterizer state, depth state, etc.).
203+ VIRTUAL Uint32 METHOD (Reload)(THIS_
204+ ModifyPipelineReloadInfoCallbackType ModifyReloadInfo DEFAULT_VALUE (nullptr )) PURE;
164205};
165206DILIGENT_END_INTERFACE
166207
@@ -178,6 +219,7 @@ DILIGENT_END_INTERFACE
178219# define IRenderStateCache_WriteToBlob (This, ...) CALL_IFACE_METHOD(RenderStateCache, WriteToBlob, This, __VA_ARGS__)
179220# define IRenderStateCache_WriteToStream (This, ...) CALL_IFACE_METHOD(RenderStateCache, WriteToStream, This, __VA_ARGS__)
180221# define IRenderStateCache_Reset (This ) CALL_IFACE_METHOD(RenderStateCache, Reset, This)
222+ # define IRenderStateCache_Reload (This, ...) CALL_IFACE_METHOD(RenderStateCache, Reload, This, __VA_ARGS__)
181223// clang-format on
182224
183225#endif
0 commit comments