Skip to main content
gamedev.net
🔒 Locked

DX9 SetRenderState() question

Started by steve coward 4 replies 2.1k views
Original Post
steve coward
steve coward
Is there a performance penalty for calling SetRenderState() if the call is not actually changing a render state attribute? For example, if SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVSRCALPHA) is performed prior to every DrawPrimitive(), will there be a performance penalty? thanks
Promit
Promit
If you change at least one render state, there is a penalty at the next draw call. It doesn't matter how many render states you change in between, only broad categories matter. (Vertex processing is separate from pixel processing.)
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
xoyojank
xoyojank
if you create the device with D3DCREATE_PUREDEVICE, the device does not check redundant calls.
the sample "StateManager" in the SDK is a good example for that
MSN:xoyojank#live.com
steve coward
steve coward
In my app every drawPrimitive() is immediately preceded by a source texture change (except for the rare case when the vertex buffer is full and a D3DLOCK_DISCARD lock is necessary.) So, if I understand the replies to my initial post, my app takes no additional performance hit if each drawPrimitive() is also preceded by a (possibly redundant) SetStreamSource(), SetFVF(), and/or multiple SetRenderState()'s. Is this true?

thanks
Matt Aufderheide
Matt Aufderheide
In relation to this question, here is something I've never been clear on: does setting renderstates in the shader technique (using the FX interface) produce the same penalty?

On looking at my shader techniques, I find I'm setting a bunch of possibly redundant renderstates...Should I remove anything that may be redundant?
Krokhin
Krokhin
Quote:
Original post by Matt Aufderheide
In relation to this question, here is something I've never been clear on: does setting renderstates in the shader technique (using the FX interface) produce the same penalty?

I think,they (i mean FX system creators) use render state blocks records,
it seems more logical.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.