From 67107e5511ee09896643d0850574ae1485fa44c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Thu, 9 Nov 2023 07:26:23 -0800 Subject: [PATCH] Cleanup. --- src/renderer_d3d11.cpp | 6 +++--- src/renderer_d3d12.cpp | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 9bde033e87..0da9c03c3d 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -874,8 +874,6 @@ namespace bgfx { namespace d3d11 } #endif // USE_D3D11_DYNAMIC_LIB - m_device = (ID3D11Device*)g_platformData.context; - if (!m_dxgi.init(g_caps) ) { goto error; @@ -883,8 +881,10 @@ namespace bgfx { namespace d3d11 errorState = ErrorState::LoadedDXGI; - if (NULL != m_device) + if (NULL != g_platformData.context) { + m_device = (ID3D11Device*)g_platformData.context; + m_device->AddRef(); m_device->GetImmediateContext(&m_deviceCtx); diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index d98137d9b8..e7ee2ec669 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -804,8 +804,6 @@ namespace bgfx { namespace d3d12 } #endif // USE_D3D12_DYNAMIC_LIB - m_device = (ID3D12Device*)g_platformData.context; - #if !BX_PLATFORM_LINUX if (!m_dxgi.init(g_caps) ) { @@ -817,7 +815,14 @@ namespace bgfx { namespace d3d12 HRESULT hr; - if (NULL == m_device) + if (NULL != g_platformData.context) + { + m_device = (ID3D12Device*)g_platformData.context; + + m_device->AddRef(); + hr = S_OK; + } + else { #if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT if (_init.debug @@ -915,12 +920,11 @@ namespace bgfx { namespace d3d12 } #endif // BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT - if (FAILED(hr) ) - { - BX_TRACE("Init error: Unable to create Direct3D12 device."); - goto error; - } - + if (FAILED(hr) ) + { + BX_TRACE("Init error: Unable to create Direct3D12 device."); + goto error; + } } #if !BX_PLATFORM_LINUX