Search code examples
directxdirectx-9

If IDirect3DStateBlock9 persist after device lost or reset?


If i catch device (directx 9) state with IDirect3DStateBlock9, can i use that previously created interface to restore device state AFTER it was resetted or lost?


Solution

  • No, you can't. With the debug runtime turn on, and running with debug mode, you will get the following error.

    Direct3D9: (ERROR) :All user created stateblocks must be freed before ResetEx can succeed. ResetEx Fails.
    

    An alternative way is you can save/restore the device state manually without using stateblocks. when you change the state before rendering, use a variable to save each state and then restore the state after reset device.