diff --git a/duckstation.sln b/duckstation.sln index 887207f59..ea2341995 100644 --- a/duckstation.sln +++ b/duckstation.sln @@ -218,15 +218,19 @@ Global {933118A9-68C5-47B4-B151-B03C93961623}.ReleaseLTCG|x86.ActiveCfg = Release|Win32 {933118A9-68C5-47B4-B151-B03C93961623}.ReleaseLTCG|x86.Build.0 = Release|Win32 {28F14272-0EC4-41BB-849F-182ADB81AF70}.Debug|x64.ActiveCfg = Debug|x64 + {28F14272-0EC4-41BB-849F-182ADB81AF70}.Debug|x64.Build.0 = Debug|x64 {28F14272-0EC4-41BB-849F-182ADB81AF70}.Debug|x86.ActiveCfg = Debug|Win32 {28F14272-0EC4-41BB-849F-182ADB81AF70}.Debug|x86.Build.0 = Debug|Win32 {28F14272-0EC4-41BB-849F-182ADB81AF70}.DebugFast|x64.ActiveCfg = DebugFast|x64 + {28F14272-0EC4-41BB-849F-182ADB81AF70}.DebugFast|x64.Build.0 = DebugFast|x64 {28F14272-0EC4-41BB-849F-182ADB81AF70}.DebugFast|x86.ActiveCfg = DebugFast|Win32 {28F14272-0EC4-41BB-849F-182ADB81AF70}.DebugFast|x86.Build.0 = DebugFast|Win32 {28F14272-0EC4-41BB-849F-182ADB81AF70}.Release|x64.ActiveCfg = Release|x64 + {28F14272-0EC4-41BB-849F-182ADB81AF70}.Release|x64.Build.0 = Release|x64 {28F14272-0EC4-41BB-849F-182ADB81AF70}.Release|x86.ActiveCfg = Release|Win32 {28F14272-0EC4-41BB-849F-182ADB81AF70}.Release|x86.Build.0 = Release|Win32 {28F14272-0EC4-41BB-849F-182ADB81AF70}.ReleaseLTCG|x64.ActiveCfg = ReleaseLTCG|x64 + {28F14272-0EC4-41BB-849F-182ADB81AF70}.ReleaseLTCG|x64.Build.0 = ReleaseLTCG|x64 {28F14272-0EC4-41BB-849F-182ADB81AF70}.ReleaseLTCG|x86.ActiveCfg = ReleaseLTCG|Win32 {28F14272-0EC4-41BB-849F-182ADB81AF70}.ReleaseLTCG|x86.Build.0 = ReleaseLTCG|Win32 EndGlobalSection diff --git a/src/duckstation-qt/CMakeLists.txt b/src/duckstation-qt/CMakeLists.txt index 7726bb868..c69df1723 100644 --- a/src/duckstation-qt/CMakeLists.txt +++ b/src/duckstation-qt/CMakeLists.txt @@ -46,5 +46,5 @@ if(WIN32) d3d11displaywindow.cpp d3d11displaywindow.h ) - target_link_libraries(duckstation PRIVATE d3d11.lib) + target_link_libraries(duckstation PRIVATE d3d11.lib dxgi.lib) endif() diff --git a/src/duckstation-qt/d3d11displaywindow.cpp b/src/duckstation-qt/d3d11displaywindow.cpp index 38daea050..a03aede2e 100644 --- a/src/duckstation-qt/d3d11displaywindow.cpp +++ b/src/duckstation-qt/d3d11displaywindow.cpp @@ -194,10 +194,27 @@ bool D3D11DisplayWindow::createDeviceContext(QThread* worker_thread) { const bool debug = true; + ComPtr dxgi_factory; + HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf())); + if (FAILED(hr)) + { + Log_ErrorPrintf("Failed to create DXGI factory: 0x%08X", hr); + return false; + } + UINT create_flags = 0; if (debug) create_flags |= D3D11_CREATE_DEVICE_DEBUG; + hr = D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, create_flags, nullptr, 0, D3D11_SDK_VERSION, + m_device.GetAddressOf(), nullptr, m_context.GetAddressOf()); + + if (FAILED(hr)) + { + Log_ErrorPrintf("Failed to create D3D device: 0x%08X", hr); + return false; + } + DXGI_SWAP_CHAIN_DESC swap_chain_desc = {}; swap_chain_desc.BufferDesc.Width = m_window_width; swap_chain_desc.BufferDesc.Height = m_window_height; @@ -209,20 +226,17 @@ bool D3D11DisplayWindow::createDeviceContext(QThread* worker_thread) swap_chain_desc.Windowed = TRUE; swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; - HRESULT hr = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, create_flags, nullptr, 0, - D3D11_SDK_VERSION, &swap_chain_desc, m_swap_chain.GetAddressOf(), - m_device.GetAddressOf(), nullptr, m_context.GetAddressOf()); - + hr = dxgi_factory->CreateSwapChain(m_device.Get(), &swap_chain_desc, m_swap_chain.GetAddressOf()); if (FAILED(hr)) { Log_WarningPrintf("Failed to create a flip-discard swap chain, trying discard."); swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - } - - if (FAILED(hr)) - { - Log_ErrorPrintf("D3D11CreateDeviceAndSwapChain failed: 0x%08X", hr); - return false; + hr = dxgi_factory->CreateSwapChain(m_device.Get(), &swap_chain_desc, m_swap_chain.GetAddressOf()); + if (FAILED(hr)) + { + Log_ErrorPrintf("CreateSwapChain failed: 0x%08X", hr); + return false; + } } #if 1 @@ -366,6 +380,8 @@ void D3D11DisplayWindow::destroyDeviceResources() { QtDisplayWindow::destroyDeviceResources(); + m_display_uniform_buffer.Release(); + m_swap_chain_rtv.Reset(); m_linear_sampler.Reset(); m_point_sampler.Reset(); m_display_pixel_shader.Reset(); @@ -446,5 +462,3 @@ void D3D11DisplayWindow::renderDisplay() m_context->Draw(3, 0); } - - diff --git a/src/duckstation-qt/duckstation-qt.vcxproj b/src/duckstation-qt/duckstation-qt.vcxproj index 8f86201a0..0e1c20aea 100644 --- a/src/duckstation-qt/duckstation-qt.vcxproj +++ b/src/duckstation-qt/duckstation-qt.vcxproj @@ -286,7 +286,7 @@ Console true $(SolutionDir)dep\msvc\lib32-debug;$(SolutionDir)dep\msvc\qt5-x86\lib;%(AdditionalLibraryDirectories) - Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5Multimediad.lib;d3d11.lib;%(AdditionalDependencies) + Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5Multimediad.lib;d3d11.lib;dxgi.lib;%(AdditionalDependencies) @@ -307,7 +307,7 @@ Console true $(SolutionDir)dep\msvc\lib64-debug;$(SolutionDir)dep\msvc\qt5-x64\lib;%(AdditionalLibraryDirectories) - Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5Multimediad.lib;d3d11.lib;%(AdditionalDependencies) + Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5Multimediad.lib;d3d11.lib;dxgi.lib;%(AdditionalDependencies) @@ -330,7 +330,7 @@ Console true $(SolutionDir)dep\msvc\lib32-debug;$(SolutionDir)dep\msvc\qt5-x86\lib;%(AdditionalLibraryDirectories) - Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5Multimediad.lib;d3d11.lib;%(AdditionalDependencies) + Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5Multimediad.lib;d3d11.lib;dxgi.lib;%(AdditionalDependencies) @@ -353,7 +353,7 @@ Console true $(SolutionDir)dep\msvc\lib64-debug;$(SolutionDir)dep\msvc\qt5-x64\lib;%(AdditionalLibraryDirectories) - Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5Multimediad.lib;d3d11.lib;%(AdditionalDependencies) + Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;Qt5Multimediad.lib;d3d11.lib;dxgi.lib;%(AdditionalDependencies) @@ -375,7 +375,7 @@ true true $(SolutionDir)dep\msvc\lib32;$(SolutionDir)dep\msvc\qt5-x86\lib;%(AdditionalLibraryDirectories) - Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5Multimedia.lib;d3d11.lib;%(AdditionalDependencies) + Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5Multimedia.lib;d3d11.lib;dxgi.lib;%(AdditionalDependencies) @@ -398,7 +398,7 @@ true true $(SolutionDir)dep\msvc\lib32;$(SolutionDir)dep\msvc\qt5-x86\lib;%(AdditionalLibraryDirectories) - Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5Multimedia.lib;d3d11.lib;%(AdditionalDependencies) + Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5Multimedia.lib;d3d11.lib;dxgi.lib;%(AdditionalDependencies) UseLinkTimeCodeGeneration @@ -421,7 +421,7 @@ true true $(SolutionDir)dep\msvc\lib64;$(SolutionDir)dep\msvc\qt5-x64\lib;%(AdditionalLibraryDirectories) - Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5Multimedia.lib;d3d11.lib;%(AdditionalDependencies) + Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5Multimedia.lib;d3d11.lib;dxgi.lib;%(AdditionalDependencies) @@ -444,7 +444,7 @@ true true $(SolutionDir)dep\msvc\lib64;$(SolutionDir)dep\msvc\qt5-x64\lib;%(AdditionalLibraryDirectories) - Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5Multimedia.lib;d3d11.lib;%(AdditionalDependencies) + Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5Multimedia.lib;d3d11.lib;dxgi.lib;%(AdditionalDependencies) UseLinkTimeCodeGeneration