compare metadata for hot reloading#4
Conversation
|
|
||
| var shader_compilations = {} | ||
| var shader_code_cache = {} | ||
| var shader_compilation_time = {} |
There was a problem hiding this comment.
I think this might be better named shader_modified_time or raw_shader_modified_time. It's possible the shader may be modified while this is not running, making modification time != compilation time.
| # Compare current shader code with cached shader code and recompile if changed | ||
| for file_path in compute_shader_file_paths: | ||
| if shader_code_cache[file_path] != FileAccess.open(file_path, FileAccess.READ).get_as_text(): | ||
| if shader_compilation_time[file_path] != FileAccess.get_modified_time(file_path): |
There was a problem hiding this comment.
Maybe keep the file content check after the modification time check? Would still cut down time considerably, but also avoids edge cases—for example, an autosaving editor writing the exact same content to the file.
Don't have the stats, but I'm fairly certain compilation is much more expensive in almost all cases than reading the file contents so it's best avoided if possible. Compilations should be infrequent anyway so the negligible increase in cost of also reading the file contents as well should be okay.
this PR makes it so the shader hot reloading code checks for a file's last modified time instead of constantly reading the file and comparing the sources