When managing shader’s, does it make sense to have all of them compiled and in memory at all times? Or is it better to have only the shader’s I need in memory, and unload those that have not been used for awhile?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Depending on the app, the most important factor will probably be that you dont want to have a blocking situation where the current frame needs a material that uses an unloaded shader, and you must reload/compile it before the frame can continue rendering, hence blocking rendering and possibly causing a hiccup in framerate. If you can avoid this and pre-emptively reload shaders just before you need them, then it should be OK.
But I would first do some memory profiling to see how much memory the shaders are taking up – it seems to me like a micro-optimisation (unless you have some obscenely large number of loaded shaders). My guess is you would save a lot more memory by focusing on textures.