mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-04-26 16:46:28 +00:00
[host] fallback to IDXGIOutput1 if IDXGIOutput5 is not available
This commit is contained in:
parent
473e4716fc
commit
18634fa805
@ -208,25 +208,16 @@ bool DXGI::Initialize(CaptureOptions * options)
|
|||||||
IDXGIAdapter1Ptr adapter;
|
IDXGIAdapter1Ptr adapter;
|
||||||
for (int i = 0; m_dxgiFactory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND; i++)
|
for (int i = 0; m_dxgiFactory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND; i++)
|
||||||
{
|
{
|
||||||
IDXGIOutputPtr output;
|
for (int i = 0; adapter->EnumOutputs(i, &m_output) != DXGI_ERROR_NOT_FOUND; i++)
|
||||||
for (int i = 0; adapter->EnumOutputs(i, &output) != DXGI_ERROR_NOT_FOUND; i++)
|
|
||||||
{
|
{
|
||||||
DXGI_OUTPUT_DESC outputDesc;
|
DXGI_OUTPUT_DESC outputDesc;
|
||||||
output->GetDesc(&outputDesc);
|
m_output->GetDesc(&outputDesc);
|
||||||
if (!outputDesc.AttachedToDesktop)
|
if (!outputDesc.AttachedToDesktop)
|
||||||
{
|
{
|
||||||
output = NULL;
|
m_output = NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_output = output;
|
|
||||||
if (!m_output)
|
|
||||||
{
|
|
||||||
DEBUG_ERROR("Failed to get IDXGIOutput1");
|
|
||||||
DeInitialize();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DXGI_ADAPTER_DESC1 adapterDesc;
|
DXGI_ADAPTER_DESC1 adapterDesc;
|
||||||
adapter->GetDesc1(&adapterDesc);
|
adapter->GetDesc1(&adapterDesc);
|
||||||
DEBUG_INFO("Device Descripion: %ls" , adapterDesc.Description);
|
DEBUG_INFO("Device Descripion: %ls" , adapterDesc.Description);
|
||||||
@ -308,6 +299,10 @@ bool DXGI::Initialize(CaptureOptions * options)
|
|||||||
|
|
||||||
dxgi->SetGPUThreadPriority(7);
|
dxgi->SetGPUThreadPriority(7);
|
||||||
|
|
||||||
|
// first try to use the newer API
|
||||||
|
IDXGIOutput5Ptr output5 = m_output;
|
||||||
|
if (output5)
|
||||||
|
{
|
||||||
// we try this twice in case we still get an error on re-initialization
|
// we try this twice in case we still get an error on re-initialization
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
@ -317,7 +312,7 @@ bool DXGI::Initialize(CaptureOptions * options)
|
|||||||
DXGI_FORMAT_R10G10B10A2_UNORM
|
DXGI_FORMAT_R10G10B10A2_UNORM
|
||||||
};
|
};
|
||||||
|
|
||||||
status = m_output->DuplicateOutput1(m_device, 0, _countof(supportedFormats), supportedFormats, &m_dup);
|
status = output5->DuplicateOutput1(m_device, 0, _countof(supportedFormats), supportedFormats, &m_dup);
|
||||||
if (SUCCEEDED(status))
|
if (SUCCEEDED(status))
|
||||||
break;
|
break;
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
@ -329,6 +324,31 @@ bool DXGI::Initialize(CaptureOptions * options)
|
|||||||
DeInitialize();
|
DeInitialize();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG_WARN("IDXGIOutput5 is not available, please update windows for improved performance!");
|
||||||
|
DEBUG_WARN("Falling back to IDXIGOutput1");
|
||||||
|
IDXGIOutput1Ptr output1 = m_output;
|
||||||
|
if (!output1)
|
||||||
|
{
|
||||||
|
// we try this twice in case we still get an error on re-initialization
|
||||||
|
for (int i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
status = output1->DuplicateOutput(m_device, &m_dup);
|
||||||
|
if (SUCCEEDED(status))
|
||||||
|
break;
|
||||||
|
Sleep(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FAILED(status))
|
||||||
|
{
|
||||||
|
DEBUG_WINERROR("DuplicateOutput Failed", status);
|
||||||
|
DeInitialize();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DXGI_OUTDUPL_DESC dupDesc;
|
DXGI_OUTDUPL_DESC dupDesc;
|
||||||
m_dup->GetDesc(&dupDesc);
|
m_dup->GetDesc(&dupDesc);
|
||||||
|
@ -93,7 +93,7 @@ namespace Capture
|
|||||||
ID3D11DevicePtr m_device;
|
ID3D11DevicePtr m_device;
|
||||||
D3D_FEATURE_LEVEL m_featureLevel;
|
D3D_FEATURE_LEVEL m_featureLevel;
|
||||||
ID3D11DeviceContextPtr m_deviceContext;
|
ID3D11DeviceContextPtr m_deviceContext;
|
||||||
IDXGIOutput5Ptr m_output;
|
IDXGIOutputPtr m_output;
|
||||||
IDXGIOutputDuplicationPtr m_dup;
|
IDXGIOutputDuplicationPtr m_dup;
|
||||||
bool m_releaseFrame;
|
bool m_releaseFrame;
|
||||||
ID3D11Texture2DPtr m_texture[3];
|
ID3D11Texture2DPtr m_texture[3];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user