@@ -182,6 +182,8 @@ class LoadShaderPrograms:
182182 text_fg_override_threshold : tuple [float , Literal ['%' , 'ratio' ]] = 0 , '%'
183183 text_old_gamma : bool = False
184184 custom_shaders : tuple [str , ...] = ()
185+ force_recompile_of_custom_shaders : bool = False
186+ last_built_custom_shaders : dict [int , Any ] = {}
185187
186188 opts : Options | None = None
187189
@@ -205,7 +207,7 @@ def recompile_if_needed(self) -> None:
205207 self (allow_recompile = True )
206208 else :
207209 opts = self .get_options ()
208- if opts .custom_shaders != self .custom_shaders :
210+ if opts .custom_shaders != self .custom_shaders or self . force_recompile_of_custom_shaders :
209211 self .compile_custom_shaders (allow_recompile = True )
210212
211213 def __call__ (self , allow_recompile : bool = False ) -> None :
@@ -244,6 +246,7 @@ def cell(prog: int) -> None:
244246 self .compile_custom_shaders (allow_recompile )
245247
246248 def compile_custom_shaders (self , allow_recompile : bool = False ) -> None :
249+ self .force_recompile_of_custom_shaders = False
247250 opts = self .get_options ()
248251 self .custom_shaders = tuple (opts .custom_shaders )
249252 pmap = {}
@@ -267,7 +270,9 @@ def do(prog: int, slot: str) -> None:
267270 compile_program (prog , (), (), {}, allow_recompile )
268271 else :
269272 try :
270- compile_program (prog , (vert ,), (frag ,), metadata , allow_recompile )
273+ if self .last_built_custom_shaders .get (prog ) != (vert , frag , metadata ):
274+ compile_program (prog , (vert ,), (frag ,), metadata , allow_recompile )
275+ self .last_built_custom_shaders [prog ] = vert , frag , metadata
271276 except Exception as e :
272277 log_error (f'Failed to load custom shader for slot { slot } with error: { e } ' )
273278 compile_program (prog , (), (), {}, allow_recompile )
@@ -1355,6 +1360,7 @@ def clear_caches() -> None:
13551360 custom_shader .cache_clear ()
13561361 pipeline_definition .cache_clear ()
13571362 parse_pipeline .cache_clear ()
1363+ load_shader_programs .force_recompile_of_custom_shaders = True
13581364
13591365
13601366def test_slang_build () -> None :
0 commit comments