Can CPU access to BackBuffer used for Render Target?

strong textI'm very new to DirectX11 and start to study. I have seen D3D11_USAGE enumeration in D3D11_BUFFER_DESC structure and searched what each means.

D3D11_DEFAULT refers that GPU can read/write but all accesses from CPU is not allowed. Therefore this option is used for the back buffer used for the render target.

Then, If I generate a swap chain using DXGI_USAGE_RENDER_TARGET_OUTPUT option for usage and get a back-buffer and create a render target from the back-buffer, can CPU access to the backbuffer or render target?

typedef struct DXGI_SWAP_CHAIN_DESC
    {
    DXGI_MODE_DESC BufferDesc;
    DXGI_SAMPLE_DESC SampleDesc;
    DXGI_USAGE BufferUsage;
    UINT BufferCount;
    HWND OutputWindow;
    BOOL Windowed;
    DXGI_SWAP_EFFECT SwapEffect;
    UINT Flags;
    }   DXGI_SWAP_CHAIN_DESC;

Based on MSDC document(In the document, it says "Swap chain's only support the DXGI_CPU_ACCESS_NONE value in the DXGI_CPU_ACCESS_FIELD part of DXGI_USAGE."), CPU can't access but I can't find clear instruction. Am I right?

So, Can CPU access to BackBuffer used for Render Target?


The CPU does not have access to the swap chain buffers, as per the MSDN documentation you cited.

I'm not sure why you would need to read from the back buffer in the first place - the process of reading data generated on the GPU from the CPU is so slow you're better off either doing all of your rendering on the CPU in the first place, or redesigning your algorithm so you don't need to access the data from the CPU. In general, the second is the best option - D3D is designed to push data to the GPU from the CPU, not to read data from the GPU into the CPU.

In fact, if you look at the documentation for D3D11_USAGE, you'll find that the only way to create a resource with direct read access from the CPU is to create it as a staging resource (D3D11_USAGE_STAGING), which doesn't support creating views. Resources created with D3D11_USAGE_DYNAMIC can be written to by the CPU, but not read, resources created with D3D11_USAGE_DEFAULT can be copied into through UpdateSubresource, but otherwise cannot be interacted with by the CPU, and resources created with D3D11_USAGE_IMMUTABLE cannot be modified at all after creation.

A swap chain creates its resources with the DXGI equivalent of D3D11_USAGE_DEFAULT, which denies the CPU access to the data. MSDN is merely telling you that this is the case, and to not put any CPU access flags into the Usage member because they will either be ignored or rejected as erroneous.