Is it posible to do such a thing? so far, when we compile a shader, it stays from the compilation moment to the end of the program execution, but what if, for some reason, we wanted to get rid of one? a posible scenario, for instance, could be authoring shaders, think of a tool that creates them, say, via nodes (it is just a suposition, such tool doesn't exist) During the execution, it must compile every created shader, if the old shaders aren't replaced, i guess that sooner or later, you run out of resources. So, is it posible to update, or replace, or delete them? Couldn't it be a feature useful for Irrlicht?
Think that, for instance, it was posible to replace the fixed function materials, with the proper provisions so the engine suffered the least, just by dropping them, and creating new shaders with better functionality.
Dropping shaders when no longer needed
Dropping shaders when no longer needed
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: Dropping shaders when no longer needed
It is possible, but the irrlicht system binds shader program objects to integer IDs, so its very hard to signal to SMaterials that the material type they are using is not alive anymore.
So it would basically have to create a "default" shader, which could be solid as it is now for all invalid IDs or even better a full "render discard" shader (throwing all vertices to same position off-screen, if possible using geometry shader to kill them, and discard any pixels).
But then you'd have a problem of gaps in the list of assigned IDs, and if shaders were assigned the smallest value item in the gap then you'd have a problem of random integer IDs which wouldnt play nice (you'd have to respecify ALL of your SMaterials with new Material IDs, everytime you delete or replace a shader).
So I'd suggest a "add"/"replace"/"delete" system, where you effectively fuse delete+add so that your new shader keeps the irrlicht integer ID of the one you've dropped.
This is all possible in OpenGL with glDeleteProgram() etc., so it would take you 45 minutes to implement yourself if you read the openGL wiki.
So it would basically have to create a "default" shader, which could be solid as it is now for all invalid IDs or even better a full "render discard" shader (throwing all vertices to same position off-screen, if possible using geometry shader to kill them, and discard any pixels).
But then you'd have a problem of gaps in the list of assigned IDs, and if shaders were assigned the smallest value item in the gap then you'd have a problem of random integer IDs which wouldnt play nice (you'd have to respecify ALL of your SMaterials with new Material IDs, everytime you delete or replace a shader).
So I'd suggest a "add"/"replace"/"delete" system, where you effectively fuse delete+add so that your new shader keeps the irrlicht integer ID of the one you've dropped.
This is all possible in OpenGL with glDeleteProgram() etc., so it would take you 45 minutes to implement yourself if you read the openGL wiki.
Re: Dropping shaders when no longer needed
Hmm, from the looks of it, D3D doesn't have a way to drop shaders.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: Dropping shaders when no longer needed
I don't need anything more complex either
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: Dropping shaders when no longer needed
Just adding this feature to my fork (recompiling post processing shaders on screen resize)