问题
I am hoping this is a easy answer to an easy question which I cannot find an answer to.
How do I access the front buffer in Directx 11 / DXGI? I have found in Directx 9 you can use GetFrontBufferData() and you can use GetBuffer() in Directx 11 to get access to the backbuffer but there are problems with this. The backbuffer doesn't have calculations done to it that the front buffer does.
So I was wondering if there is something I am missing.
I could try using GetDisplaySurfaceData and unless I have mis-understood something then it wouldn't work because I am not always in full-screen mode.
Edit: Could someone let me know how the GetBuffer works in SwapChain for Directx 11. As I have read that antialiasing only occurs on the front buffer and never a backbuffer. Is 0 the first backbuffer? (Microsoft state that you can only use 0 in certain instances.)
Is it possible at all to get the Front Buffer in Directx 11?
Many thanks,
回答1:
You need to use the IDXGISwapChain::GetBuffer
API to retrieve a swap chain surface ( use the uuid ID3D11Texture2D
for the result type ).
Now, the swap chain buffers are not mapable, so you need to copy it to a staging resource.
- Use
ID3D11Texture2D::GetDesc
to retrieve the surface description - Patch it with a
D3D11_USAGE_STAGING
usage and a cpu access flag ofD3D11_CPU_ACCESS_READ
- Create a temporary surface
ID3D11Device::CreateTexture2D
- Copy to the staging surface
ID3D11DeviceContext::CopyResource
You now have a ID3D11Texture2D
with the content of your swap chain buffer that allow you to use the ID3D11DeviceContext::Map
API to read it on the CPU
来源:https://stackoverflow.com/questions/18459004/directx-11-front-buffer