As part of a video project I'm working on, I have to pass ID3D11Texture2D decoded by CUDA, from one D3D11Device to the other, which handles rendering. I managed to achieve the goal, but it looks like I'm leaking textures. The workflow looks as follows:
Sending side (decoder):
ID3D11Texture2D* pD3D11OutTexture;
if (!createOutputTexture(pD3D11OutTexture))
return false;
IDXGIResource1* pRsrc = nullptr;
pD3D11OutTexture->QueryInterface(__uuidof(IDXGIResource1), reinterpret_cast<void**>(&pRsrc));
auto hr = pRsrc->CreateSharedHandle(
nullptr,
DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE,
nullptr, &frameData->shared_handle);
pRsrc->Release();
Receiving side (renderer):
ID3D11Texture2D* pTex = nullptr;
hres = m_pD3D11Device->OpenSharedResource1(
frameData->shared_handle,
__uuidof(ID3D11Texture2D),
reinterpret_cast<void**>(&pTex));
DrawFrame(pTex);
pTex->Release();
CloseHandle(frameData->shared_handle);
I'm somewhat puzzled by the inner workings of this workflow, namely:
what happens when I create a shared handle? Does this allow me to release texture?
what happens, when I call OpenSharedResource? Does it create separate texture - that is do I have to release both textures after rendering?
Appreciate your help!
↧