title: D3D11 SwapChain Buffer is NULL
body: <p>Whenever I run this code, the data that is pointed (member <code>pData</code>) to within the _TextureData struct is all 0 (like 300 bytes of just 0). The <code>HRESULT result</code> that it returns is always <code>S_OK</code>, and the row and column depths are accurate. I am sure that something is being rendered to the buffer because there are things being displayed on the window that I am rendering to. I have tried both getting the buffer's data before and after presenting, and either way, the data is still null.</p>
  
  <pre><code>D3D11_TEXTURE2D_DESC desc { };
  ID3D11Texture2D * pCopy = nullptr;
  ID3D11Texture2D * pBackBufferTexture = nullptr;
  desc.Width = 800;
  desc.Height = 800;
  desc.MipLevels = 1;
  desc.ArraySize = 1;
  desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
  desc.SampleDesc.Count = 1;
  desc.Usage = D3D11_USAGE_STAGING;
  desc.BindFlags = 0;
  desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
  desc.MiscFlags = 0;
  
  assert( SUCCEEDED( pSwapChain-&gt;Present( 0,
                                          0 ) ) );
  pDevice-&gt;CreateTexture2D( &amp;desc, nullptr, &amp;pCopy );
  pSwapChain-&gt;GetBuffer( 0,
                         __uuidof( ID3D11Texture2D ),
                         reinterpret_cast&lt; void ** &gt;( &amp;pBackBufferTexture ) );
  pContext-&gt;CopyResource( pCopy, pBackBufferTexture );
  D3D11_MAPPED_SUBRESOURCE _TextureData { };
  auto result = pContext-&gt;Map( pCopy, 0, D3D11_MAP_READ, 0, &amp;_TextureData );
  pContext-&gt;Unmap( pCopy, 0 );
  pCopy-&gt;Release( );
  </code></pre>