Merge pull request #5501 from iwubcode/d3d_apply_state_loop Fix for loop in D3D Renderer ApplyState function