Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

What to release and when, while passing shared texture between two D3D11 devices

$
0
0
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!

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>