summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-02-02 12:44:09 +0100
committerwm4 <wm4@nowhere>2017-02-02 12:58:04 +0100
commitce23dfa2fab75756bb051df112cf3ab9ad61e802 (patch)
treeedf6b163fb9c0518f2e83acf5e7a72f773068d6e /video/decode
parent644e23a0f58cd3cb16a07854ab1dde3d9bcb7ad3 (diff)
downloadmpv-ce23dfa2fab75756bb051df112cf3ab9ad61e802.tar.bz2
mpv-ce23dfa2fab75756bb051df112cf3ab9ad61e802.tar.xz
hw_dxva2: create a IDirect3D9Ex device
This should allow us to create the device in situations when Direct3DCreate9 normally fails, for example if no user is logged in. While the later use-case is not very interesting, I hope it to work in some other situations as well, for example while certain drivers are in exclusive full screen mode. This is available since Windows 7, so I'm removing the old call completely.
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/hw_dxva2.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/video/decode/hw_dxva2.c b/video/decode/hw_dxva2.c
index c6a34a2e70..7b1a6b4bc7 100644
--- a/video/decode/hw_dxva2.c
+++ b/video/decode/hw_dxva2.c
@@ -357,44 +357,53 @@ static bool create_device(struct lavc_ctx *s)
return false;
}
- IDirect3D9* (WINAPI *Direct3DCreate9)(UINT) =
- (void *)GetProcAddress(d3d9_dll, "Direct3DCreate9");
- if (!Direct3DCreate9) {
- MP_ERR(p, "Failed to locate Direct3DCreate9\n");
+ HRESULT (WINAPI *Direct3DCreate9Ex)(UINT, IDirect3D9Ex **) =
+ (void *)GetProcAddress(d3d9_dll, "Direct3DCreate9Ex");
+ if (!Direct3DCreate9Ex) {
+ MP_ERR(p, "Failed to locate Direct3DCreate9Ex\n");
return false;
}
- p->d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
- if (!p->d3d9) {
- MP_ERR(p, "Failed to create IDirect3D object\n");
+ IDirect3D9Ex *d3d9ex = NULL;
+ HRESULT hr = Direct3DCreate9Ex(D3D_SDK_VERSION, &d3d9ex);
+ if (FAILED(hr)) {
+ MP_ERR(p, "Failed to create IDirect3D9Ex object\n");
return false;
}
UINT adapter = D3DADAPTER_DEFAULT;
- D3DDISPLAYMODE display_mode;
- IDirect3D9_GetAdapterDisplayMode(p->d3d9, adapter, &display_mode);
+ D3DDISPLAYMODEEX modeex = {0};
+ IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, adapter, &modeex, NULL);
+
D3DPRESENT_PARAMETERS present_params = {
.Windowed = TRUE,
.BackBufferWidth = 640,
.BackBufferHeight = 480,
.BackBufferCount = 0,
- .BackBufferFormat = display_mode.Format,
+ .BackBufferFormat = modeex.Format,
.SwapEffect = D3DSWAPEFFECT_DISCARD,
.Flags = D3DPRESENTFLAG_VIDEO,
};
- HRESULT hr = IDirect3D9_CreateDevice(p->d3d9, adapter,
- D3DDEVTYPE_HAL,
- GetShellWindow(),
- D3DCREATE_SOFTWARE_VERTEXPROCESSING |
- D3DCREATE_MULTITHREADED |
- D3DCREATE_FPU_PRESERVE,
- &present_params,
- &p->device);
+
+ IDirect3DDevice9Ex *exdev = NULL;
+ hr = IDirect3D9Ex_CreateDeviceEx(d3d9ex, adapter,
+ D3DDEVTYPE_HAL,
+ GetShellWindow(),
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING |
+ D3DCREATE_MULTITHREADED |
+ D3DCREATE_FPU_PRESERVE,
+ &present_params,
+ NULL,
+ &exdev);
if (FAILED(hr)) {
MP_ERR(p, "Failed to create Direct3D device: %s\n",
mp_HRESULT_to_str(hr));
+ IDirect3D9_Release(d3d9ex);
return false;
}
+
+ p->d3d9 = (IDirect3D9 *)d3d9ex;
+ p->device = (IDirect3DDevice9 *)exdev;
return true;
}