PipelineManager, ApplyXXX() and check redundancy

Jan 20, 2012 at 1:49 PM
Edited Jan 20, 2012 at 1:49 PM

As i can see PipelineManager uses some pattern to manage all the stage/state resource set's to avoid sending duplicate commands to driver when possible.

Problem is that ApplyPipelineResources() in most usage scenarios (Enity3D Draw(..), for example) will check everything before each draw call, through there could be nothing useful to check.

Is there any particular reason why duplicate state set checks are done on draw, not on individual state set basis?

Coordinator
Jan 20, 2012 at 8:07 PM

This is a good point - you are on a roll :)

Originally I did it this way to ensure that if something tried to set two subsequent states to different values, then the first one would be ignored.  However, as you pointed out, this is more of a programming error than a normal occurrence, and it just makes lots of CPU work necessary for little gain on the API.

I think I will do a little testing to ensure that this change won't break anything, but this is a good suggestion.  Can you add a Issue in the issue tracker to describe making this change?  Then I will get it implemented as soon as I can get it tested out.

Thanks again!

Feb 26, 2012 at 11:19 PM

Since it still hasn't been done, I let myself to add this issue to the issue tracker, I hope that's not a problem.

Coordinator
Feb 27, 2012 at 1:17 PM

That is the right way to track the issues - so thanks for adding it in.  I have been thinking about this topic, and there is more to it than I initially considered.  The problem is that there are many different ways that states can be set, and they aren't all set by the same object.  Therefore it must be checked to see if it has changed or not before being set.

This could be optimized somewhat by using a hash code for the states or something like that, but I'm not so sure it would be too helpful.  If anyone has any ideas about how to incrementally check the states and ensure that they are already set properly, then lets discuss it here!