Hello,
I have DX9 IDirect3DSurface9 that is a back buffer with the rendered content. I need to convert it to DX11 ID3D11Texture2D. How can I do that? If I read MSDN correctly, there's some level of interopability between various DX versions.
I found example how to convert render surface to texture in DX9, but I can't figure out how to do it across APIs. StretchRect is removed in DX11 and CopyResource requires ID3D11Resource*.
To clarify what I am doing - I am adding a VR support to an old DX9 game.
Cheers!
EDIT: I was able to copy bytes of DX9 surface to DX11 texture, not sure if there's better way though: There has been a lot of dance above that code to get rid of MSAA
D3DLOCKED_RECT lrSrc{};
RETURN_IF_D3D_FAILED(bbsfCopy->LockRect(&lrSrc, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)); {
auto onExit = Utils::MakeScopeGuard([&]() { RETURN_IF_D3D_FAILED(bbsfCopy->UnlockRect()); });
D3D11_MAPPED_SUBRESOURCE mappedDst{};
auto& dstTexture = mCurrEye == vr::Eye_Left ? mLeftTexture11 : mRightTexture11;
RETURN_IF_D3D_FAILED(mDeviceContext11->Map(mLeftTexture11, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedDst));
memcpy(mappedDst.pData, lrSrc.pBits, desc.Width * desc.Height * 4);