State management in D3D