Hi,
I would like to know how is shader's lifespan handled in game engines. I know that shaders are precompiled, shipped, and then at the end fully compiled on the user's GPU. But when? And how long do they stay compiled?
I have a simple system where shader counts references and when it is not referenced for some time by any mesh then it is deleted.
I think this is quite a good system because some shaders are not used often and they would take up memory on GPU. But I have to recompile the shader again when it is used which takes some time.
How bad is this approach? Should I rather load all shaders at once at the beginning of the program? Wouldn't that take up too much space?
Or there a way so that I can retrieve the compiled shaders before deleting them, storing them on disk, and then just push them back to GPU without compilation when needed?
Any help will be appreciated.