Skip to main content
gamedev.net
🔒 Locked

Setting the same state twice...

Started by wasd Mar 4, 2004 at 10:59 AM 2 replies 500+ views
Original Post
wasd
wasd
Does Direct3D 9 keep a record of what the current render states/textures/materials are? So if I did something like: set texture (1) draw vertices set texture (1) draw vertices set texture (2) draw vertices Would it ignore the middle texture set command, or would it still incur a penalty like I''d switched to a different texture? --------------------------------------- Let''s struggle for our dream of Game! http://andrewporritt.4t.com
neneboricua19
neneboricua19
In general, if you create your D3D device as a PURE device, then most states will not be saved. State changes are passed on to the driver as fast as possible. That means that D3D would not be able to detect if you set a redundant state because it doesn''t keep track of state information.

If you create your D3D device as a NON-PURE device, then D3D will keep track of state and check all state changes for redundancy. It will only pass to the driver those state changes that are not redundant. The problem with this is that it may degrade performance.

The best bet is to use a PURE device and keep track of your own states. That being said, even a PURE device will keep track of *some* states. Thanks to Coder for clearing me up on this issue. A PURE device will keep track of those states that have an associated interface, with the exception of SetPixelShader. For example, calling SetTexture requires you to pass in a pointer to an object of the IDirect3DTexture9 interface. A PURE D3D device will keep track of this and even if you call SetTexture again with the same argument, it will not pass it on to the driver. This applies to other methods that take interfaces as arguements, like SetStreamSource, SetIndices, and SetVertexShader.

But note that this does not apply to SetPixelShader. There are some underlying reasons for this that I think were explained in messages in the DirectXDev mailing list. On a PURE device, SetPixelShader will pass any arguments on to the driver, so you have to take care to not call it redundantly.

Hope this helps,
neneboricua
dx elliot
dx elliot
Also run in debug mode with the details set to max, it''ll actually list all the redundant renderstates and other flags... over and over.

Topic Locked

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

Sign in to reply to this topic.