can not copyResource

mc 5,426 Reputation points
2025-06-21T03:55:49.5066667+00:00

I want to copy texture (format DXGI_B8G8R8A8) to swapChain

there is error:

CopyResource: First parameter does not match device. [ MISCELLANEOUS CORRUPTION #13: CORRUPTED_PARAMETER1]

ctx->CopyResource(x_buffer, texture1);

x_buffer is the buffer that I get : swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&x_buffer);

if copy to the buffer then I h3 = swapChain->Present1(1, 0, &param); right?

Windows development Windows API - Win32
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,521 Reputation points
    2025-06-22T08:17:32.67+00:00

    How do you create the texture ?

    For example, this works for me :

    ID3D11Texture2D* backBuffer;
    ID3D11Texture2D* pTexture2D;
    // then
    m_pDXGISwapChain1->GetBuffer(0, IID_PPV_ARGS(&backBuffer));
    D3D11_TEXTURE2D_DESC texDesc = {};
    backBuffer->GetDesc(&texDesc);
    texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    texDesc.MiscFlags = 0;
    
    texDesc.Usage = D3D11_USAGE_DEFAULT;
    texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
    
    // Format = DXGI_FORMAT_B8G8R8A8_UNORM (87)
    m_pD3D11Device->CreateTexture2D(&texDesc, nullptr, &pTexture2D);
    SafeRelease(&backBuffer);
    

    Then, for testing, I can call pTexture2D->QueryInterface to get IDXGISurface then CreateBitmapFromDxgiSurface to draw things inside the texture,

    then finally CopyResource to copy the texture to the SwapChain :

    m_pDXGISwapChain1->GetBuffer(0, IID_PPV_ARGS(&backBuffer));
    m_pD3D11DeviceContext->CopyResource(backBuffer, pTexture2D);
    SafeRelease(&backBuffer);
    
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.