summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends
diff options
context:
space:
mode:
authorJules Blok <jules.blok@gmail.com>2017-06-25 20:57:46 +0200
committerJules Blok <jules.blok@gmail.com>2017-07-05 22:43:39 +0200
commitc399e2bc40b3d6e28a8d1b0152d1dceed4c3a119 (patch)
treed1a54d67f9f885db1388e56901b28b3ab61afafc /Source/Core/VideoBackends
parent421a2c57761d4f51f8bcaf866e17a8c8b38b4cd2 (diff)
D3DBase: Upgrade to DXGI 1.2.
This effectively drops for Vista and Windows 7 without the Platform Update in this backend.
Diffstat (limited to 'Source/Core/VideoBackends')
-rw-r--r--Source/Core/VideoBackends/D3D/D3DBase.cpp97
-rw-r--r--Source/Core/VideoBackends/D3D/D3DBase.h2
2 files changed, 27 insertions, 72 deletions
diff --git a/Source/Core/VideoBackends/D3D/D3DBase.cpp b/Source/Core/VideoBackends/D3D/D3DBase.cpp
index 327fece109..489db6a14a 100644
--- a/Source/Core/VideoBackends/D3D/D3DBase.cpp
+++ b/Source/Core/VideoBackends/D3D/D3DBase.cpp
@@ -26,13 +26,7 @@ CREATEDXGIFACTORY PCreateDXGIFactory = nullptr;
HINSTANCE hDXGIDll = nullptr;
int dxgi_dll_ref = 0;
-typedef HRESULT(WINAPI* D3D11CREATEDEVICEANDSWAPCHAIN)(IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE,
- UINT, CONST D3D_FEATURE_LEVEL*, UINT, UINT,
- CONST DXGI_SWAP_CHAIN_DESC*,
- IDXGISwapChain**, ID3D11Device**,
- D3D_FEATURE_LEVEL*, ID3D11DeviceContext**);
static D3D11CREATEDEVICE PD3D11CreateDevice = nullptr;
-D3D11CREATEDEVICEANDSWAPCHAIN PD3D11CreateDeviceAndSwapChain = nullptr;
HINSTANCE hD3DDll = nullptr;
int d3d_dll_ref = 0;
@@ -40,7 +34,7 @@ namespace D3D
{
ID3D11Device* device = nullptr;
ID3D11DeviceContext* context = nullptr;
-static IDXGISwapChain* swapchain = nullptr;
+static IDXGISwapChain1* swapchain = nullptr;
static ID3D11Debug* debug = nullptr;
D3D_FEATURE_LEVEL featlevel;
D3DTexture2D* backbuf = nullptr;
@@ -99,12 +93,6 @@ HRESULT LoadD3D()
MessageBoxA(nullptr, "GetProcAddress failed for D3D11CreateDevice!", "Critical error",
MB_OK | MB_ICONERROR);
- PD3D11CreateDeviceAndSwapChain =
- (D3D11CREATEDEVICEANDSWAPCHAIN)GetProcAddress(hD3DDll, "D3D11CreateDeviceAndSwapChain");
- if (PD3D11CreateDeviceAndSwapChain == nullptr)
- MessageBoxA(nullptr, "GetProcAddress failed for D3D11CreateDeviceAndSwapChain!",
- "Critical error", MB_OK | MB_ICONERROR);
-
return S_OK;
}
@@ -172,7 +160,6 @@ void UnloadD3D()
FreeLibrary(hD3DDll);
hD3DDll = nullptr;
PD3D11CreateDevice = nullptr;
- PD3D11CreateDeviceAndSwapChain = nullptr;
}
void UnloadD3DCompiler()
@@ -276,14 +263,13 @@ HRESULT Create(HWND wnd)
return hr;
}
- IDXGIFactory* factory;
- IDXGIAdapter* adapter;
- IDXGIOutput* output;
+ IDXGIFactory2* factory;
hr = PCreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory);
if (FAILED(hr))
MessageBox(wnd, _T("Failed to create IDXGIFactory object"), _T("Dolphin Direct3D 11 backend"),
MB_OK | MB_ICONERROR);
+ IDXGIAdapter* adapter;
hr = factory->EnumAdapters(g_ActiveConfig.iAdapter, &adapter);
if (FAILED(hr))
{
@@ -294,25 +280,6 @@ HRESULT Create(HWND wnd)
MB_OK | MB_ICONERROR);
}
- // TODO: Make this configurable
- hr = adapter->EnumOutputs(0, &output);
- if (FAILED(hr))
- {
- // try using the first one
- IDXGIAdapter* firstadapter;
- hr = factory->EnumAdapters(0, &firstadapter);
- if (!FAILED(hr))
- hr = firstadapter->EnumOutputs(0, &output);
- if (FAILED(hr))
- MessageBox(wnd, _T("Failed to enumerate outputs!\n")
- _T("This usually happens when you've set your video adapter to the Nvidia ")
- _T("GPU in an Optimus-equipped system.\n")
- _T("Set Dolphin to use the high-performance graphics in Nvidia's drivers ")
- _T("instead and leave Dolphin's video adapter set to the Intel GPU."),
- _T("Dolphin Direct3D 11 backend"), MB_OK | MB_ICONERROR);
- SAFE_RELEASE(firstadapter);
- }
-
// get supported AA modes
aa_modes = EnumAAModes(adapter);
@@ -324,45 +291,30 @@ HRESULT Create(HWND wnd)
UpdateActiveConfig();
}
- DXGI_SWAP_CHAIN_DESC swap_chain_desc = {};
+ DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {};
swap_chain_desc.BufferCount = 1;
swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
- swap_chain_desc.OutputWindow = wnd;
swap_chain_desc.SampleDesc.Count = 1;
swap_chain_desc.SampleDesc.Quality = 0;
- swap_chain_desc.Windowed =
- !SConfig::GetInstance().bFullscreen || g_ActiveConfig.bBorderlessFullscreen;
-
- DXGI_OUTPUT_DESC out_desc = {};
- output->GetDesc(&out_desc);
-
- DXGI_MODE_DESC mode_desc = {};
- mode_desc.Width = out_desc.DesktopCoordinates.right - out_desc.DesktopCoordinates.left;
- mode_desc.Height = out_desc.DesktopCoordinates.bottom - out_desc.DesktopCoordinates.top;
- mode_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- mode_desc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
- hr = output->FindClosestMatchingMode(&mode_desc, &swap_chain_desc.BufferDesc, nullptr);
- if (FAILED(hr))
- MessageBox(wnd, _T("Failed to find a supported video mode"), _T("Dolphin Direct3D 11 backend"),
- MB_OK | MB_ICONERROR);
-
- if (swap_chain_desc.Windowed)
- {
- // forcing buffer resolution to xres and yres..
- // this is not a problem as long as we're in windowed mode
- swap_chain_desc.BufferDesc.Width = xres;
- swap_chain_desc.BufferDesc.Height = yres;
- }
+ swap_chain_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ swap_chain_desc.Scaling = DXGI_SCALING_STRETCH;
+ swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
+ swap_chain_desc.Width = xres;
+ swap_chain_desc.Height = yres;
#if defined(_DEBUG) || defined(DEBUGFAST)
// Creating debug devices can sometimes fail if the user doesn't have the correct
// version of the DirectX SDK. If it does, simply fallback to a non-debug device.
{
- hr = PD3D11CreateDeviceAndSwapChain(
- adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
- D3D11_CREATE_DEVICE_SINGLETHREADED | D3D11_CREATE_DEVICE_DEBUG, supported_feature_levels,
- NUM_SUPPORTED_FEATURE_LEVELS, D3D11_SDK_VERSION, &swap_chain_desc, &swapchain, &device,
- &featlevel, &context);
+ hr = PD3D11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
+ D3D11_CREATE_DEVICE_SINGLETHREADED | D3D11_CREATE_DEVICE_DEBUG,
+ supported_feature_levels, NUM_SUPPORTED_FEATURE_LEVELS,
+ D3D11_SDK_VERSION, &device, &featlevel, &context);
+
+ if (SUCCEEDED(hr))
+ hr = factory->CreateSwapChainForHwnd(device, hWnd, &swap_chain_desc, nullptr, nullptr,
+ &swapchain);
+
// Debugbreak on D3D error
if (SUCCEEDED(hr) && SUCCEEDED(device->QueryInterface(__uuidof(ID3D11Debug), (void**)&debug)))
{
@@ -386,10 +338,14 @@ HRESULT Create(HWND wnd)
if (FAILED(hr))
#endif
{
- hr = PD3D11CreateDeviceAndSwapChain(
- adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr, D3D11_CREATE_DEVICE_SINGLETHREADED,
- supported_feature_levels, NUM_SUPPORTED_FEATURE_LEVELS, D3D11_SDK_VERSION, &swap_chain_desc,
- &swapchain, &device, &featlevel, &context);
+ hr = PD3D11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
+ D3D11_CREATE_DEVICE_SINGLETHREADED, supported_feature_levels,
+ NUM_SUPPORTED_FEATURE_LEVELS, D3D11_SDK_VERSION, &device, &featlevel,
+ &context);
+
+ if (SUCCEEDED(hr))
+ hr = factory->CreateSwapChainForHwnd(device, hWnd, &swap_chain_desc, nullptr, nullptr,
+ &swapchain);
}
if (FAILED(hr))
@@ -414,7 +370,6 @@ HRESULT Create(HWND wnd)
SetDebugObjectName((ID3D11DeviceChild*)context, "device context");
SAFE_RELEASE(factory);
- SAFE_RELEASE(output);
SAFE_RELEASE(adapter);
ID3D11Texture2D* buf;
diff --git a/Source/Core/VideoBackends/D3D/D3DBase.h b/Source/Core/VideoBackends/D3D/D3DBase.h
index dec8d5206f..288be59a9f 100644
--- a/Source/Core/VideoBackends/D3D/D3DBase.h
+++ b/Source/Core/VideoBackends/D3D/D3DBase.h
@@ -6,7 +6,7 @@
#include <d3d11.h>
#include <d3dcompiler.h>
-#include <dxgi.h>
+#include <dxgi1_2.h>
#include <vector>
#include "Common/Common.h"