libobs-d3d11: Use discrete function to get shared handle

Allows us to reacquire the shared handle if the texture is rebuilt.
This commit is contained in:
jp9000 2019-03-03 08:41:23 -08:00
parent 492f50ee87
commit 8f3ea18276
2 changed files with 16 additions and 8 deletions

View File

@ -369,6 +369,7 @@ struct gs_texture_2d : gs_texture {
void InitResourceView();
void InitRenderTargets();
void BackupTexture(const uint8_t **data);
void GetSharedHandle(IDXGIResource *dxgi_res);
void RebuildSharedTextureFallback();
void Rebuild(ID3D11Device *dev);

View File

@ -71,6 +71,20 @@ void gs_texture_2d::BackupTexture(const uint8_t **data)
}
}
void gs_texture_2d::GetSharedHandle(IDXGIResource *dxgi_res)
{
HANDLE handle;
HRESULT hr;
hr = dxgi_res->GetSharedHandle(&handle);
if (FAILED(hr)) {
blog(LOG_WARNING, "GetSharedHandle: Failed to "
"get shared handle: %08lX", hr);
} else {
sharedHandle = (uint32_t)(uintptr_t)handle;
}
}
void gs_texture_2d::InitTexture(const uint8_t **data)
{
HRESULT hr;
@ -129,14 +143,7 @@ void gs_texture_2d::InitTexture(const uint8_t **data)
blog(LOG_WARNING, "InitTexture: Failed to query "
"interface: %08lX", hr);
} else {
HANDLE handle;
hr = dxgi_res->GetSharedHandle(&handle);
if (FAILED(hr)) {
blog(LOG_WARNING, "InitTexture: Failed to "
"get shared handle: %08lX", hr);
} else {
sharedHandle = (uint32_t)(uintptr_t)handle;
}
GetSharedHandle(dxgi_res);
if (flags & GS_SHARED_KM_TEX) {
ComPtr<IDXGIKeyedMutex> km;