Skip to content

Commit a05bb57

Browse files
committed
xrRenderR3-R4: Implemented GetDeviceState() for DX10-DX11
1 parent aa02792 commit a05bb57

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/Layers/xrRender/r__dsgraph_build.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -995,22 +995,31 @@ void D3DXRenderBase::ResourcesDumpMemoryUsage() { Resources->_DumpMemoryUsage();
995995
DeviceState D3DXRenderBase::GetDeviceState()
996996
{
997997
HW.Validate();
998-
#if defined(USE_DX10) || defined(USE_DX11) || defined(USE_OGL)
999-
// TODO: DX10: Implement GetDeviceState
1000-
// TODO: DX10: Implement DXGI_PRESENT_TEST testing
1001-
// VERIFY(!"D3DXRenderBase::overdrawBegin not implemented.");
1002-
#else // USE_DX10
1003-
HRESULT _hr = HW.pDevice->TestCooperativeLevel();
1004-
if (FAILED(_hr))
998+
#ifdef USE_OGL
999+
// TODO: OGL: Implement GetDeviceState
1000+
#elif !defined(USE_DX9)
1001+
const auto result = HW.m_pSwapChain->Present(0, DXGI_PRESENT_TEST);
1002+
1003+
switch (result)
10051004
{
1006-
// If the device was lost, do not render until we get it back
1007-
if (D3DERR_DEVICELOST == _hr)
1008-
return DeviceState::Lost;
1009-
// Check if the device is ready to be reset
1010-
if (D3DERR_DEVICENOTRESET == _hr)
1011-
return DeviceState::NeedReset;
1005+
// Check if the device is ready to be reset
1006+
case DXGI_ERROR_DEVICE_RESET:
1007+
return DeviceState::NeedReset;
10121008
}
1013-
#endif // USE_DX10
1009+
#else
1010+
const auto result = HW.pDevice->TestCooperativeLevel();
1011+
1012+
switch (result)
1013+
{
1014+
// If the device was lost, do not render until we get it back
1015+
case D3DERR_DEVICELOST:
1016+
return DeviceState::Lost;
1017+
1018+
// Check if the device is ready to be reset
1019+
case D3DERR_DEVICENOTRESET:
1020+
return DeviceState::NeedReset;
1021+
}
1022+
#endif
10141023
return DeviceState::Normal;
10151024
}
10161025

0 commit comments

Comments
 (0)