Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Too large shaders - micro specializations.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 #Include Graphics   Members   -  Reputation: 405

Like
0Likes
Like

Posted 17 June 2014 - 01:53 AM

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



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5412

Like
4Likes
Like

Posted 17 June 2014 - 04:25 AM

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...



#3 bwhiting   Members   -  Reputation: 816

Like
4Likes
Like

Posted 17 June 2014 - 05:08 AM

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)



#4 #Include Graphics   Members   -  Reputation: 405

Like
0Likes
Like

Posted 17 June 2014 - 09:13 AM

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?



#5 Promit   Moderators   -  Reputation: 7671

Like
2Likes
Like

Posted 18 June 2014 - 05:56 PM


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.

#6 #Include Graphics   Members   -  Reputation: 405

Like
0Likes
Like

Posted 19 June 2014 - 02:54 AM

 


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?



#7 #Include Graphics   Members   -  Reputation: 405

Like
0Likes
Like

Posted 19 June 2014 - 02:59 AM

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>



#8 Krohm   Crossbones+   -  Reputation: 3261

Like
0Likes
Like

Posted 19 June 2014 - 06:48 AM


- 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.



#9 #Include Graphics   Members   -  Reputation: 405

Like
0Likes
Like

Posted 19 June 2014 - 08:02 AM

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.



#10 Krohm   Crossbones+   -  Reputation: 3261

Like
0Likes
Like

Posted 19 June 2014 - 09:42 AM

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.



#11 Jason Z   Crossbones+   -  Reputation: 5412

Like
1Likes
Like

Posted 19 June 2014 - 02:34 PM

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.

 

There are lots of people that are still supporting DX9, and I think it makes perfect sense to optimize a rendering sequence in an existing program.  The algorithm runs on the same GPU regardless of which API you use, it is just a different API so I don't really see why you are pushing so hard about DX9 being dead.  The API still exists, and will continue to exist more or less forever in the Desktop environment.  Small batches cause issues at some point in DX9, but there are many ways to address those types of problems.

 

@Promit: You are right of course.  The general case is that in D3D9 if you are doing lots of small batches that the CPU will become the bottleneck pretty quickly.  However, in some cases it could be possible that you are also causing the GPU to be inefficient.  I guess this is why you need to profile before you can find and fix the problems!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS