I creat a texture from a angle device, and I want to get a shared handle. This is not feasible. This is why? And how to debug it?
EGLDeviceEXT eglDevice;
eglQueryDisplayAttribEXT(eglDisplay, EGL_DEVICE_EXT, (EGLAttrib*)&eglDevice);
ID3D11Device* device;
eglQueryDeviceAttribEXT(eglDevice, EGL_D3D11_DEVICE_ANGLE, (EGLAttrib*)&device);
// Create the NV12 D3D11 texture
D3D11_TEXTURE2D_DESC desc;
desc.Width = width_nv12;
desc.Height = height_nv12;
desc.Format = DXGI_FORMAT_NV12;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
desc.MiscFlags = 0;
(void)device->CreateTexture2D(&desc, nullptr, &texture_nv12);
/* ASSERT_NE(nullptr, texture);*/
{
IDXGIResource* otherResource(NULL);
HRESULT hr = texture_nv12->QueryInterface(__uuidof(IDXGIResource), (void**)&otherResource);
if FAILED(hr)
{
// error handling code
std::cout << "hr:" << hr << std::endl;
}
// obtain handle to IDXGIResource object.
hr = otherResource->GetSharedHandle(&shareHandle_nv12);
if FAILED(hr)
{
// error handling code
std::cout << "hr:" << hr << std::endl;
}
else {
std::cout << "hr:" << hr << std::endl;
std::cout << "handle:" << shareHandle_nv12 << std::endl;
}
otherResource->Release();
if (!shareHandle_nv12)
return ;
}
Thank you.