D3D speedups

This PR picks 4 commits of galop1n's D3D branch which are simple d3d backend changes.
`auto` shouldn't be used out of typing laziness, but just when writing the actual type worsens readability (or cannot be easily deduced).