Sign in to follow this  
GoodFun

DirectX 10 number of shaders

Recommended Posts

Hi there, In my DirectX 10 application, I'm currently using 46 shader objects, per rendering call, I select the shader I need, set one or two texture views for it and then render the image. The texture only change about every 5 minutes. I'm currently contemplating if I should make one shader object for each texture combination (total of 1026) and hence not have to set the textures per render call. Is there a drawback in DirectX 10 where that many shaders would negatively impact performance? I am currently using about 8 gigs of textures (on a machine with a 1Gig graphics card and 16Gigs of RAM), so the system has to swap textures from System RAM to Video RAM either way, but by not setting the textures on every call, I might have more chances of actually hitting texture combinations that are already on the card. I might have to say that some of the texture combinations are more likely to be used than others, hence I might get more cache hits on those. Any insight on this would be greatly appreciated Thanks Marcel

Share this post


Link to post
Share on other sites
you could try a batching system, keep track of what the current effect/texture/etc.. are, and/or if all objects of the same class use the same shader or texture, you could make it a static member, so there's only one copy of it.
It may also help cut down on the number of textures needed, cutting the amount of moving data between systemmem and videomem, and increases the chances of a cache hit


Share this post


Link to post
Share on other sites
The thing is that these are multi threaded random requests of images rendering data representations. As such, I don't have the ability to batch it, if I don't do seperate shaders I would have a hard time figuring out what the texture in the previous call was.

Well, I guess I could make a Hash of the texture name and set that during the lock I'm doing on the shader while rendering that frame. I'll give that a try and see if that improves my performance...

I'm currently at about 900 tiles/sec at 256x256 resolution which is pretty good, though I wouldn't mind increasing it a bit more if I can.

Share this post


Link to post
Share on other sites
phantom,

when you say changing shaders is more expensive than changing textures, can you explain that a bit? I'm not sure I fully understand what's happening in the graphics card if I use multiple different shaders that have been parsed and created at program initialization.

Thanks
Marcel

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this