I need to convert ID3D11Texture2D texture of type DXGI_FORMAT_R32G32B32A32_TYPELESS to a texture of type DXGI_FORMAT_B8G8R8A8_TYPELESS (or any other 32-bit RGBA type) efficiently. Basically reducing 128 bits per pixel texture to 32 bits per pixel. Looks like ID3D11DeviceContext::CopyResource-method can not handle such a format conversion. Should I use a shader to achieve that? If yes, can the shader be used with CopyResource-method or do I need to set up full rendering pipeline? Tried doing conversion on CPU but it is way too slow.
Asked
Active
Viewed 1,260 times
1 Answers
3
Generally speaking, the fastest way to do these conversions to use the GPU to render a 'full-screen quad' of the source format texture to a render target of the destination format. The limitations will be based on the Direct3D hardware feature level for which render target formats are supported. For example, on all feature levels with modern drivers, you can count on DXGI_FORMAT_B8G8R8A8_UNORM
being supported as a render target but not DXGI_FORMAT_B8G8R8A8_SNORM
.
See MSDN and Direct3D Feature Levels
For a CPU-based fallback for all possible DXGI format conversions, see DirectXTex.

Chuck Walbourn
- 38,259
- 2
- 58
- 81