How can we convert ID3D11Texture2D into a memory buffer? I have ID3D11Texture2D* and need to read data from it to a memory buffer.
1 Answer
You need to create a second texture with the same format/size, but create it as staging.
Cpu access flags needs to be set to D3D11_CPU_ACCESS_READ
and usage needs to be set to D3D11_USAGE_STAGING.
Then you can call ID3D11DeviceContext::CopyResource to copy from the texture to the staging one.
And then you call Map to access data.