d3dretrace: Move HRESULT message lookup code into its own function.

Instead of duplicating it on every generated function.
d3dretrace: Replace casts with templates.

Smaller generated code, same type checking guarantees.
d3dretrace: Check for pitch mismatch.

We should swizzle memcpies when pitches don't match.  But until we do,
at least warn about the issue.