On 5/26/22 10:36, Dmitry Timoshkov wrote:
- texture_desc.Usage = D3D11_USAGE_STAGING;
- texture_desc.BindFlags = 0;
- texture_desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
- ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &staging_texture);
This should check for failures.
- if (SUCCEEDED(hr = ID3D11DeviceContext_Map(context, (ID3D11Resource *)staging_texture, 0,
D3D11_MAP_READ, 0, &mapped_subresource)))
- {
mapped_rect->pitch = mapped_subresource.RowPitch;
mapped_rect->bits = mapped_subresource.pData;
bitmap->staging_resource = (ID3D11Resource *)staging_texture;
- }
- else
- {
WARN("Failed to map resource, hr %#lx.\n", hr);
ID3D11Texture2D_Release(staging_texture);
- }
Staging texture has to be released at some point.