(D3D9 only) This is basically the same as revision e58692653a, just for scaled textures and with a LOT more work...
e58692653a