Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Maximum number of shaders, performance hit?

Author
Message
pdq
19
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 21st Jun 2012 23:22
Something I've always wondered about and now I am posting. Is there a limit to the number of shaders that can be loaded? Is there a performance hit for using too many shaders?

Thanks.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Jun 2012 14:59
Define 'too many'. The number that can be active at once and the effect they have on your rendering speed is purely a function of the capabilities of your graphics card.

DBPro can load up to 22000000 shaders at once... if you have the PC memory and graphics memory to hold them all.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jun 2012 15:14
If you are loading many shaders - or many copies of one shader - make sure you don't calculate tangents, etc, if the shader doesn't need them. DBPro seems to calculate the "extra data" by default even if not needed and I obtained a big increase in loading time when the extra data was turned off in one application. You use the first form of the syntax and set the final flag to 1:



I'm not sure whether this affects actual running speed once the shaders are loaded though. A bit of experimenting will tell you.

Quote: "DBPro can load up to 22000000 shaders at once"


I'd be more than happy with 0.01% of that number.
pdq
19
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 26th Jun 2012 17:00
Thanks both. That answered my question.
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 26th Jun 2012 17:27 Edited at: 26th Jun 2012 17:28
AFAIK, using many different shaders will cause a performance hit. Everytime the GPU has to use a different shader to render an object, it has to swap the shader programs round.

Whether DBP orders objects to be rendered by the shader they use, I don't know. I would suspect not, as it seems to order them based on other things like Z distance, transparency and even index ID. So if you have 100 objects, and they use 2 different shaders, it's possible the GPU may have to swap the shader program up to 50 times, which would generate a noticeable performance hit.

So, if possible, reused shaders as much as possible for multiple objects, of course taking into account how GPU intensive the shader actually is.

Login to post a reply

Server time is: 2026-07-11 11:58:45
Your offset time is: 2026-07-11 11:58:45