(XDK D3D) Refactor set_viewport code