Too large shaders - micro specializations.

Started by
9 comments, last by Jason Z 9 years, 10 months ago

Hey all,

There has been assaulting me some doubts about how to manage better the drawcalls. Actually I am using a vast generic effect which commsumate all the possible materials but .... I have several object types that are very similar, should I have to specialize some materials for each "object type" branch for having less material state changes?, does it really affect performance so much?.

I saw that at least for DX9, the dynamic branching isnt very good carried and all the branches seems to be executed... that carried me to think about real object material specializations.

May you spare some knowledge with me?, thanks in advance. smile.png

Advertisement

Have you profiled your application to see if the CPU is the bottleneck? If it isn't the bottleneck, then reducing draw calls probably won't help much - so you should start there. Regarding your question about having a number of similar effects being soaked up into one, I would take a close look at the effects and see why they are different. Is it a substantial difference, or is it something that is just a superficial difference? The effort and effects of combining them depend greatly on how similar they are, so it is hard to give a good answer to your question...

Jason is spot on here, if the shaders are not the bottle neck then no need to try to fix it!

I would recommend Intel's GPA (graphics performance analyzer) if you want a pretty easy profiling solution. Just run it then run your app and boom - useful stats.

(You can even override your shader with a really simple one, so right away you get feedback without having to write a line of code yourself)

The cpu and gpu are alternatively my bottleneck, it depends a lot every frame, so I am spending a little time on optimizing both and trying to upgrade synchronizations.

But I reached to have no more ideas and thought on cpu wait times for the gpu...I hope the render calls and material states would be multithreaded, can they be parallelized? I am thinking on a gpu which saves the info of the threads that are calling it and launch execution when a whole drawcall loop is completed. Maybe a dream?


Have you profiled your application to see if the CPU is the bottleneck? If it isn't the bottleneck, then reducing draw calls probably won't help much - so you should start there.
That depends on his batch sizes, doesn't it? If he's submitting large blocks of polygons then sure, but if we're talking about small batches and frequent effect changes, then he's going to see GPU side inefficiency stemming from that too.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.


Have you profiled your application to see if the CPU is the bottleneck? If it isn't the bottleneck, then reducing draw calls probably won't help much - so you should start there.
That depends on his batch sizes, doesn't it? If he's submitting large blocks of polygons then sure, but if we're talking about small batches and frequent effect changes, then he's going to see GPU side inefficiency stemming from that too.

So, this is what alarms more to me:

- I always apply the materials begin/end with each object which is being drawn, no matter if it has exactly the same material as before.

I know this is not the best way to do, how is this affecting my cpu/gpu?

- I am drawing about 58 type of different materials each frame!

Is this normal?, Do i have to try to compact some effects to make this state changes less at the expense of having some more branches in some shaders?

The cpu and gpu are alternatively my bottleneck, it depends a lot every frame, so I am spending a little time on optimizing both and trying to upgrade synchronizations.

But I reached to have no more ideas and thought on cpu wait times for the gpu...I hope the render calls and material states would be multithreaded, can they be parallelized? I am thinking on a gpu which saves the info of the threads that are calling it and launch execution when a whole drawcall loop is completed. Maybe a dream?

Answering to myself <Gollum mode on>:

This is not a dream myself....this is done at the API level in DX11. The technology advances, thanks god.

<Gollum mode off>


- I am drawing about 58 type of different materials each frame!
It is a very affordable amount. What's about the '!' ?

Personally if I would still have to be stuck in D3D9 I'd drop all optimizations. It's not going anywhere.

Previously "Krohm"

Well I think most pc games still support directx9 and are always trying to be if so the more optimized there because of his base lack of resources management. But its my opinion, you can have yours.

I am not giving you my opinion. I am giving you my experience.

My render loop can draw 80+ materials, over 20k tris total without even pulling the CPU out of the energy saving mode.

You are cracking your head open, spending your time which will never came back... to optimize for an API which is dead in the water and has been for quite a while.

But... you are free to make your choices.

Previously "Krohm"

This topic is closed to new replies.

Advertisement