porting my D3D11 code merge from Andrew's branch