Dropping shaders when no longer needed

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.

Dropping shaders when no longer needed

Postby Mel » Fri Jan 15, 2016 2:38 pm

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.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
User avatar
Mel
Competition winner
 
Posts: 2201
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Dropping shaders when no longer needed

Postby devsh » Fri Jan 15, 2016 3:28 pm

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.
We chose to stream mesh data from Multiple OpenGL Contexts in many threads and do the other things, not because they are easy, but because they are hard! - JFK
User avatar
devsh
Competition winner
 
Posts: 1758
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK

Re: Dropping shaders when no longer needed

Postby Mel » Wed Jan 20, 2016 11:21 am

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
User avatar
Mel
Competition winner
 
Posts: 2201
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Dropping shaders when no longer needed

Postby devsh » Wed Jan 20, 2016 12:32 pm

well,, stop using D3D
We chose to stream mesh data from Multiple OpenGL Contexts in many threads and do the other things, not because they are easy, but because they are hard! - JFK
User avatar
devsh
Competition winner
 
Posts: 1758
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK

Re: Dropping shaders when no longer needed

Postby Mel » Thu Jan 21, 2016 9:58 am

I don't need anything more complex either :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
User avatar
Mel
Competition winner
 
Posts: 2201
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Dropping shaders when no longer needed

Postby devsh » Tue Jan 26, 2016 11:42 am

Just adding this feature to my fork (recompiling post processing shaders on screen resize)
We chose to stream mesh data from Multiple OpenGL Contexts in many threads and do the other things, not because they are easy, but because they are hard! - JFK
User avatar
devsh
Competition winner
 
Posts: 1758
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK


Return to Open Discussion and Dev Announcements

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest

cron