Jump to content
  • Advertisement
Sign in to follow this  
skyfire360

Redundant SetSampleState?

This topic is 4866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I run my program with Direct3D9 debugging enabled, the debug spew gives me 12 warnings that say "Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 15" where the "State:" part on each line has 13,14,25,15,16,17,18,19,20,21,29, and 30. It appears on the line Effect->BeginPass(0). From what I've gathered in other posts, this error is due to something calling SetSamplerState and setting a certain state, though the "new" state was the same before the call. That's understandable, as that creates an unnecessary API call overhead. So what am I confused about? I'm not actually calling SetSamplerState at all! It seems that Effect->BeginPass(int) automatically calls the SetSamplerState function, as I have the following sampler in my code:
sampler gSamp = sampler_state 
{
    texture = <gTexture>;
    AddressU  = CLAMP;        
    AddressV  = CLAMP;
    AddressW  = CLAMP;
    MIPFILTER = LINEAR;
    MINFILTER = LINEAR;
    MAGFILTER = LINEAR;
};
I've tried removing all the sampler_state members but the texture itself and I still get the warnings. Is there something I should be doing in order to avoid this warning? Or at the very least, is there any way I can turn off the warning without turning off Direct3D debugging? All the debug spew makes the debugger go painfully slow and sometimes choke on the buffered Direct3D debug info calls.

Share this post


Link to post
Share on other sites
Advertisement
As far as I know ID3DXEffect uses SetSamplerState, and I know that this has been brought up several times before... however I don't know anything about the solution/outcome of it... but guessing that ID3DXEffect is an independent object it might just be the way it behaves...

Someone else with a definite answer?
(Try searching the forum in the mean time and you'll likely find something)

Share this post


Link to post
Share on other sites
Look at the StateManager sample that comes with the DirectX SDK. It shows how to filter out redundant state changes with the Effect interface. Note that on an "impure" device, these changes are filtered out for you by the runtime, but on a pure device, redundant state changes are not filtered for you, and can adversely affect performance.

Share this post


Link to post
Share on other sites
Interesting program, but one thing I noticed is that even the SDK example is full of the "Ignoring redundant SetSamplerState" debug spew! I would have thought that a StateManager example would have fixed this...

Is there a #define that I can use at compiletime to get rid of this warning? I'd still like to be able to use the debug information regarding memory leaks and fileIO. If Microsoft's own StateManager sample can't get rid of the debug spew when using Effect files, then it doesn't seem like a very pressing issue.

Share this post


Link to post
Share on other sites
Thanks guys, that cleared it. In the future though, it seems like keeping track of state changes should be a big concern, as it can cause quite a bit of overhead.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!