From abdca37be2899ff82efcea0338b0bcf28edc7ee9 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Thu, 19 Jan 2017 11:10:36 +0100 Subject: [PATCH] direct3d11: remove the deprecated USE_DXGI code Signed-off-by: Jean-Baptiste Kempf --- modules/video_output/win32/direct3d11.c | 112 +------------------------------- 1 file changed, 1 insertion(+), 111 deletions(-) diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c index ac0dc001be..18348287d7 100644 --- a/modules/video_output/win32/direct3d11.c +++ b/modules/video_output/win32/direct3d11.c @@ -49,11 +49,7 @@ #include "../../video_chroma/dxgi_fmt.h" #if !VLC_WINSTORE_APP -# if USE_DXGI -# define D3D11CreateDeviceAndSwapChain(args...) sys->OurD3D11CreateDeviceAndSwapChain(args) -# else -# define D3D11CreateDevice(args...) sys->OurD3D11CreateDevice(args) -# endif +# define D3D11CreateDevice(args...) sys->OurD3D11CreateDevice(args) # define D3DCompile(args...) sys->OurD3DCompile(args) #endif @@ -177,14 +173,6 @@ static void UpdateQuadOpacity(vout_display_t *, const d3d_quad_t *, float); static int Control(vout_display_t *vd, int query, va_list args); static void Manage(vout_display_t *vd); -/* All the #if USE_DXGI contain an alternative method to setup dx11 - They both need to be benchmarked to see which performs better */ -#if USE_DXGI -/* I have no idea why MS decided dxgi headers do not define this - As they do have prototypes for d3d11 functions */ -typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); -#endif - /* TODO: Move to a direct3d11_shaders header */ static const char* globVertexShaderFlat = "\ struct VS_INPUT\ @@ -360,15 +348,6 @@ static int OpenHwnd(vout_display_t *vd) return VLC_EGENERIC; } -# if USE_DXGI - HINSTANCE hdxgi_dll = LoadLibrary(TEXT("DXGI.DLL")); - if (!hdxgi_dll) { - msg_Warn(vd, "cannot load dxgi.dll, aborting"); - Direct3D11Destroy(vd); - return VLC_EGENERIC; - } -# endif - vout_display_sys_t *sys = vd->sys = calloc(1, sizeof(vout_display_sys_t)); if (!sys) return VLC_ENOMEM; @@ -383,40 +362,6 @@ static int OpenHwnd(vout_display_t *vd) return VLC_EGENERIC; } -# if USE_DXGI - sys->hdxgi_dll = hdxgi_dll; - - /* TODO : enable all dxgi versions from 1.3 -> 1.1 */ - PFN_CREATE_DXGI_FACTORY OurCreateDXGIFactory = - (void *)GetProcAddress(hdxgi_dll, "CreateDXGIFactory"); - if (!OurCreateDXGIFactory) { - msg_Err(vd, "Cannot locate reference to CreateDXGIFactory in dxgi DLL"); - Direct3D11Destroy(vd); - return VLC_EGENERIC; - } - - UINT i_factory_flags = 0; -#ifndef NDEBUG - i_factory_flags |= DXGI_CREATE_FACTORY_DEBUG; -#endif - - /* TODO : detect the directx version supported and use IID_IDXGIFactory3 or 2 */ - HRESULT hr = OurCreateDXGIFactory(&IID_IDXGIFactory2, (void **)&sys->dxgifactory); - if (FAILED(hr)) { - msg_Err(vd, "Could not create dxgi factory. (hr=0x%lX)", hr); - Direct3D11Destroy(vd); - return VLC_EGENERIC; - } - - sys->OurD3D11CreateDeviceAndSwapChain = - (void *)GetProcAddress(hd3d11_dll, "D3D11CreateDeviceAndSwapChain"); - if (!sys->OurD3D11CreateDeviceAndSwapChain) { - msg_Err(vd, "Cannot locate reference to D3D11CreateDeviceAndSwapChain in d3d11 DLL"); - Direct3D11Destroy(vd); - return VLC_EGENERIC; - } - -# else sys->OurD3D11CreateDevice = (void *)GetProcAddress(hd3d11_dll, "D3D11CreateDevice"); if (!sys->OurD3D11CreateDevice) { @@ -424,7 +369,6 @@ static int OpenHwnd(vout_display_t *vd) Direct3D11Destroy(vd); return VLC_EGENERIC; } -# endif return VLC_SUCCESS; } #else @@ -1128,11 +1072,6 @@ static void Direct3D11Destroy(vout_display_t *vd) #if !VLC_WINSTORE_APP vout_display_sys_t *sys = vd->sys; -# if USE_DXGI - if (sys->hdxgi_dll) - FreeLibrary(sys->hdxgi_dll); -# endif - if (sys->hd3d11_dll) FreeLibrary(sys->hd3d11_dll); if (sys->hd3dcompiler_dll) @@ -1213,53 +1152,6 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt) D3D_FEATURE_LEVEL_9_1, }; -# if USE_DXGI - /* TODO : list adapters for the user to choose from */ - hr = IDXGIFactory2_EnumAdapters(sys->dxgifactory, 0, &dxgiadapter); - if (FAILED(hr)) { - msg_Err(vd, "Could not create find factory. (hr=0x%lX)", hr); - return VLC_EGENERIC; - } - - IDXGIOutput* output; - hr = IDXGIAdapter_EnumOutputs(dxgiadapter, 0, &output); - if (FAILED(hr)) { - msg_Err(vd, "Could not Enumerate DXGI Outputs. (hr=0x%lX)", hr); - IDXGIAdapter_Release(dxgiadapter); - return VLC_EGENERIC; - } - - DXGI_MODE_DESC md; - memset(&md, 0, sizeof(md)); - md.Width = fmt->i_visible_width; - md.Height = fmt->i_visible_height; - md.Format = scd.BufferDesc.Format; - md.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; - - hr = IDXGIOutput_FindClosestMatchingMode(output, &md, &scd.BufferDesc, NULL); - if (FAILED(hr)) { - msg_Err(vd, "Failed to find a supported video mode. (hr=0x%lX)", hr); - IDXGIAdapter_Release(dxgiadapter); - return VLC_EGENERIC; - } - - /* mode desc doesn't carry over the width and height*/ - scd.BufferDesc.Width = fmt->i_visible_width; - scd.BufferDesc.Height = fmt->i_visible_height; - - hr = D3D11CreateDeviceAndSwapChain(dxgiadapter, - D3D_DRIVER_TYPE_UNKNOWN, NULL, creationFlags, - featureLevels, ARRAYSIZE(featureLevels), - D3D11_SDK_VERSION, &scd, &sys->dxgiswapChain, - &sys->d3ddevice, NULL, &sys->d3dcontext); - IDXGIAdapter_Release(dxgiadapter); - if (FAILED(hr)) { - msg_Err(vd, "Could not Create the D3D11 device and SwapChain. (hr=0x%lX)", hr); - return VLC_EGENERIC; - } - -# else - static const D3D_DRIVER_TYPE driverAttempts[] = { D3D_DRIVER_TYPE_HARDWARE, D3D_DRIVER_TYPE_WARP, @@ -1316,8 +1208,6 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt) msg_Err(vd, "Could not create the SwapChain. (hr=0x%lX)", hr); return VLC_EGENERIC; } - -# endif #endif vlc_fourcc_t i_src_chroma = fmt->i_chroma; -- 2.11.4.GIT