diff --git a/Source/Core/VideoBackends/D3DCommon/Common.cpp b/Source/Core/VideoBackends/D3DCommon/Common.cpp index 5c0f16b144..1046cc8cb0 100644 --- a/Source/Core/VideoBackends/D3DCommon/Common.cpp +++ b/Source/Core/VideoBackends/D3DCommon/Common.cpp @@ -72,20 +72,20 @@ void UnloadLibraries() s_libraries_loaded = false; } -IDXGIFactory* CreateDXGIFactory(bool debug_device) +Microsoft::WRL::ComPtr CreateDXGIFactory(bool debug_device) { - IDXGIFactory* factory; + Microsoft::WRL::ComPtr factory; // Use Win8.1 version if available. if (create_dxgi_factory2 && SUCCEEDED(create_dxgi_factory2(debug_device ? DXGI_CREATE_FACTORY_DEBUG : 0, - IID_PPV_ARGS(&factory)))) + IID_PPV_ARGS(factory.GetAddressOf())))) { return factory; } // Fallback to original version, without debug support. - HRESULT hr = create_dxgi_factory(IID_PPV_ARGS(&factory)); + HRESULT hr = create_dxgi_factory(IID_PPV_ARGS(factory.ReleaseAndGetAddressOf())); if (FAILED(hr)) { PanicAlert("CreateDXGIFactory() failed with HRESULT %08X", hr); @@ -98,14 +98,14 @@ IDXGIFactory* CreateDXGIFactory(bool debug_device) std::vector GetAdapterNames() { Microsoft::WRL::ComPtr factory; - HRESULT hr = create_dxgi_factory(IID_PPV_ARGS(&factory)); - if (!SUCCEEDED(hr)) + HRESULT hr = create_dxgi_factory(IID_PPV_ARGS(factory.GetAddressOf())); + if (FAILED(hr)) return {}; std::vector adapters; - IDXGIAdapter* adapter; - while (factory->EnumAdapters(static_cast(adapters.size()), &adapter) != - DXGI_ERROR_NOT_FOUND) + Microsoft::WRL::ComPtr adapter; + while (factory->EnumAdapters(static_cast(adapters.size()), + adapter.ReleaseAndGetAddressOf()) != DXGI_ERROR_NOT_FOUND) { std::string name; DXGI_ADAPTER_DESC desc; diff --git a/Source/Core/VideoBackends/D3DCommon/Common.h b/Source/Core/VideoBackends/D3DCommon/Common.h index e98edbbc94..df8ea613b3 100644 --- a/Source/Core/VideoBackends/D3DCommon/Common.h +++ b/Source/Core/VideoBackends/D3DCommon/Common.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "Common/CommonTypes.h" @@ -25,7 +26,7 @@ void UnloadLibraries(); std::vector GetAdapterNames(); // Helper function which creates a DXGI factory. -IDXGIFactory* CreateDXGIFactory(bool debug_device); +Microsoft::WRL::ComPtr CreateDXGIFactory(bool debug_device); // Globally-accessible D3DCompiler function. extern pD3DCompile d3d_compile;