From 97ff2bf0008bd139a44e70b74ee5a25d82267f08 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 3 Nov 2022 13:12:46 +1000 Subject: [PATCH] Misc: Remove last remnants of UWP --- src/frontend-common/d3d11_host_display.cpp | 45 ------------------- src/frontend-common/d3d12_host_display.cpp | 47 -------------------- src/frontend-common/xaudio2_audio_stream.cpp | 9 +--- src/frontend-common/xaudio2_audio_stream.h | 2 - src/frontend-common/xinput_source.cpp | 10 +---- 5 files changed, 2 insertions(+), 111 deletions(-) diff --git a/src/frontend-common/d3d11_host_display.cpp b/src/frontend-common/d3d11_host_display.cpp index 9c4e83480..962c82fc1 100644 --- a/src/frontend-common/d3d11_host_display.cpp +++ b/src/frontend-common/d3d11_host_display.cpp @@ -204,11 +204,7 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi) create_flags |= D3D11_CREATE_DEVICE_DEBUG; ComPtr temp_dxgi_factory; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(temp_dxgi_factory.GetAddressOf())); -#else - HRESULT hr = CreateDXGIFactory2(0, IID_PPV_ARGS(temp_dxgi_factory.GetAddressOf())); -#endif if (FAILED(hr)) { Log_ErrorPrintf("Failed to create DXGI factory: 0x%08X", hr); @@ -342,7 +338,6 @@ bool D3D11HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) { HRESULT hr; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) if (m_window_info.type != WindowInfo::Type::Win32) return false; @@ -405,42 +400,6 @@ bool D3D11HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) if (FAILED(hr)) Log_WarningPrintf("MakeWindowAssociation() to disable ALT+ENTER failed"); } -#else - if (m_window_info.type != WindowInfo::Type::WinRT) - return false; - - ComPtr factory2; - hr = m_dxgi_factory.As(&factory2); - if (FAILED(hr)) - { - Log_ErrorPrintf("Failed to get DXGI factory: %08X", hr); - return false; - } - - DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {}; - swap_chain_desc.Width = m_window_info.surface_width; - swap_chain_desc.Height = m_window_info.surface_height; - swap_chain_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - swap_chain_desc.SampleDesc.Count = 1; - swap_chain_desc.BufferCount = 3; - swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swap_chain_desc.SwapEffect = m_using_flip_model_swap_chain ? DXGI_SWAP_EFFECT_FLIP_DISCARD : DXGI_SWAP_EFFECT_DISCARD; - - m_using_allow_tearing = (m_allow_tearing_supported && m_using_flip_model_swap_chain && !fullscreen_mode); - if (m_using_allow_tearing) - swap_chain_desc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; - - ComPtr swap_chain1; - hr = factory2->CreateSwapChainForCoreWindow(m_device.Get(), static_cast(m_window_info.window_handle), - &swap_chain_desc, nullptr, swap_chain1.GetAddressOf()); - if (FAILED(hr)) - { - Log_ErrorPrintf("CreateSwapChainForCoreWindow failed: 0x%08X", hr); - return false; - } - - m_swap_chain = swap_chain1; -#endif return CreateSwapChainRTV(); } @@ -882,11 +841,7 @@ void D3D11HostDisplay::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 he HostDisplay::AdapterAndModeList D3D11HostDisplay::StaticGetAdapterAndModeList() { ComPtr dxgi_factory; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf())); -#else - HRESULT hr = CreateDXGIFactory2(0, IID_PPV_ARGS(dxgi_factory.GetAddressOf())); -#endif if (FAILED(hr)) return {}; diff --git a/src/frontend-common/d3d12_host_display.cpp b/src/frontend-common/d3d12_host_display.cpp index 8368bce43..46341c229 100644 --- a/src/frontend-common/d3d12_host_display.cpp +++ b/src/frontend-common/d3d12_host_display.cpp @@ -145,12 +145,7 @@ void D3D12HostDisplay::SetVSync(bool enabled) bool D3D12HostDisplay::CreateRenderDevice(const WindowInfo& wi) { ComPtr temp_dxgi_factory; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(temp_dxgi_factory.GetAddressOf())); -#else - HRESULT hr = CreateDXGIFactory2(0, IID_PPV_ARGS(temp_dxgi_factory.GetAddressOf())); -#endif - if (FAILED(hr)) { Log_ErrorPrintf("Failed to create DXGI factory: 0x%08X", hr); @@ -235,7 +230,6 @@ bool D3D12HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) { HRESULT hr; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) if (m_window_info.type != WindowInfo::Type::Win32) return false; @@ -281,43 +275,6 @@ bool D3D12HostDisplay::CreateSwapChain(const DXGI_MODE_DESC* fullscreen_mode) hr = m_dxgi_factory->MakeWindowAssociation(swap_chain_desc.OutputWindow, DXGI_MWA_NO_WINDOW_CHANGES); if (FAILED(hr)) Log_WarningPrintf("MakeWindowAssociation() to disable ALT+ENTER failed"); -#else - if (m_window_info.type != WindowInfo::Type::WinRT) - return false; - - ComPtr factory2; - hr = m_dxgi_factory.As(&factory2); - if (FAILED(hr)) - { - Log_ErrorPrintf("Failed to get DXGI factory: %08X", hr); - return false; - } - - DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {}; - swap_chain_desc.Width = m_window_info.surface_width; - swap_chain_desc.Height = m_window_info.surface_height; - swap_chain_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - swap_chain_desc.SampleDesc.Count = 1; - swap_chain_desc.BufferCount = 3; - swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; - - m_using_allow_tearing = (m_allow_tearing_supported && !fullscreen_mode); - if (m_using_allow_tearing) - swap_chain_desc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; - - ComPtr swap_chain1; - hr = factory2->CreateSwapChainForCoreWindow(g_d3d12_context->GetCommandQueue(), - static_cast(m_window_info.window_handle), &swap_chain_desc, - nullptr, swap_chain1.GetAddressOf()); - if (FAILED(hr)) - { - Log_ErrorPrintf("CreateSwapChainForCoreWindow failed: 0x%08X", hr); - return false; - } - - m_swap_chain = swap_chain1; -#endif return CreateSwapChainRTV(); } @@ -794,11 +751,7 @@ void D3D12HostDisplay::RenderSoftwareCursor(ID3D12GraphicsCommandList* cmdlist, HostDisplay::AdapterAndModeList D3D12HostDisplay::StaticGetAdapterAndModeList() { ComPtr dxgi_factory; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf())); -#else - HRESULT hr = CreateDXGIFactory2(0, IID_PPV_ARGS(dxgi_factory.GetAddressOf())); -#endif if (FAILED(hr)) return {}; diff --git a/src/frontend-common/xaudio2_audio_stream.cpp b/src/frontend-common/xaudio2_audio_stream.cpp index 138a2487c..00896787f 100644 --- a/src/frontend-common/xaudio2_audio_stream.cpp +++ b/src/frontend-common/xaudio2_audio_stream.cpp @@ -43,17 +43,13 @@ bool XAudio2AudioStream::OpenDevice(u32 latency_ms) { DebugAssert(!IsOpen()); -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) m_xaudio2_library = LoadLibraryW(XAUDIO2_DLL_W); if (!m_xaudio2_library) { Log_ErrorPrintf("Failed to load '%s', make sure you're using Windows 10", XAUDIO2_DLL_A); return false; } -#endif - HRESULT hr; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) using PFNXAUDIO2CREATE = HRESULT(STDAPICALLTYPE*)(IXAudio2 * *ppXAudio2, UINT32 Flags, XAUDIO2_PROCESSOR XAudio2Processor); PFNXAUDIO2CREATE xaudio2_create = @@ -61,7 +57,7 @@ bool XAudio2AudioStream::OpenDevice(u32 latency_ms) if (!xaudio2_create) return false; - hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); + HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); m_com_initialized_by_us = SUCCEEDED(hr); if (FAILED(hr) && hr != RPC_E_CHANGED_MODE && hr != S_FALSE) { @@ -70,9 +66,6 @@ bool XAudio2AudioStream::OpenDevice(u32 latency_ms) } hr = xaudio2_create(m_xaudio.ReleaseAndGetAddressOf(), 0, XAUDIO2_DEFAULT_PROCESSOR); -#else - hr = XAudio2Create(m_xaudio.ReleaseAndGetAddressOf(), 0, XAUDIO2_DEFAULT_PROCESSOR); -#endif if (FAILED(hr)) { Log_ErrorPrintf("XAudio2Create() failed: %08X", hr); diff --git a/src/frontend-common/xaudio2_audio_stream.h b/src/frontend-common/xaudio2_audio_stream.h index 2ee3637a2..75b56008c 100644 --- a/src/frontend-common/xaudio2_audio_stream.h +++ b/src/frontend-common/xaudio2_audio_stream.h @@ -51,8 +51,6 @@ private: u32 m_current_buffer = 0; bool m_buffer_enqueued = false; -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) HMODULE m_xaudio2_library = {}; bool m_com_initialized_by_us = false; -#endif }; diff --git a/src/frontend-common/xinput_source.cpp b/src/frontend-common/xinput_source.cpp index b0d0fa408..57d8a2749 100644 --- a/src/frontend-common/xinput_source.cpp +++ b/src/frontend-common/xinput_source.cpp @@ -82,7 +82,6 @@ XInputSource::~XInputSource() = default; bool XInputSource::Initialize(SettingsInterface& si, std::unique_lock& settings_lock) { -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) // xinput1_3.dll is flawed and obsolete, but it's also commonly used by wrappers. // For this reason, try to load it *only* from the application directory, and not system32. m_xinput_module = LoadLibraryExW(L"xinput1_3", nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR); @@ -109,12 +108,7 @@ bool XInputSource::Initialize(SettingsInterface& si, std::unique_lock(GetProcAddress(m_xinput_module, "XInputSetState")); m_xinput_get_capabilities = reinterpret_cast(GetProcAddress(m_xinput_module, "XInputGetCapabilities")); -#else - m_xinput_get_state = XInputGetState; - m_xinput_set_state = XInputSetState; - m_xinput_get_capabilities = XInputGetCapabilities; - m_xinput_get_extended = nullptr; -#endif + if (!m_xinput_get_state || !m_xinput_set_state || !m_xinput_get_capabilities) { Log_ErrorPrintf("Failed to get XInput function pointers."); @@ -163,13 +157,11 @@ void XInputSource::Shutdown() HandleControllerDisconnection(i); } -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) if (m_xinput_module) { FreeLibrary(m_xinput_module); m_xinput_module = nullptr; } -#endif m_xinput_get_state = nullptr; m_xinput_set_state = nullptr;