Commit 7d0abd46 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

d3d11_fmt: introduce d3d11_handle_t to keep a handle on the DLL

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent bc346168
......@@ -428,7 +428,8 @@ static int D3dCreateDevice(vlc_va_t *va)
/* */
d3d11_device_t d3d_dev;
hr = D3D11_CreateDevice(VLC_OBJECT(va), dx_sys->hdecoder_dll, true, &d3d_dev);
d3d11_handle_t hd3d = { .hdll = dx_sys->hdecoder_dll };
hr = D3D11_CreateDevice(va, &hd3d, true, &d3d_dev);
if (FAILED(hr)) {
msg_Err(va, "D3D11CreateDevice failed. (hr=0x%lX)", hr);
return VLC_EGENERIC;
......
......@@ -130,14 +130,14 @@ int AllocateShaderView(vlc_object_t *obj, ID3D11Device *d3ddevice,
return VLC_SUCCESS;
}
HRESULT D3D11_CreateDevice(vlc_object_t *obj, HINSTANCE hdecoder_dll,
HRESULT D3D11_CreateDevice(vlc_object_t *obj, d3d11_handle_t *hd3d,
bool hw_decoding, d3d11_device_t *out)
{
#if !VLC_WINSTORE_APP
# define D3D11CreateDevice(args...) pf_CreateDevice(args)
/* */
PFN_D3D11_CREATE_DEVICE pf_CreateDevice;
pf_CreateDevice = (void *)GetProcAddress(hdecoder_dll, "D3D11CreateDevice");
pf_CreateDevice = (void *)GetProcAddress(hd3d->hdll, "D3D11CreateDevice");
if (!pf_CreateDevice) {
msg_Err(obj, "Cannot locate reference to D3D11CreateDevice ABI in DLL");
return E_NOINTERFACE;
......
......@@ -35,6 +35,13 @@ typedef struct
ID3D11DeviceContext *d3dcontext; /* D3D context */
} d3d11_device_t;
typedef struct
{
#if !VLC_WINSTORE_APP
HINSTANCE hdll; /* handle of the opened d3d11 dll */
#endif
} d3d11_handle_t;
/* owned by the vout for VLC_CODEC_D3D11_OPAQUE */
struct picture_sys_t
{
......@@ -75,7 +82,7 @@ int AllocateShaderView(vlc_object_t *obj, ID3D11Device *d3ddevice,
ID3D11Texture2D *p_texture[D3D11_MAX_SHADER_VIEW], UINT slice_index,
ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW]);
HRESULT D3D11_CreateDevice(vlc_object_t *obj, HINSTANCE hdecoder_dll,
HRESULT D3D11_CreateDevice(vlc_object_t *obj, d3d11_handle_t *,
bool hw_decoding, d3d11_device_t *out);
bool isXboxHardware(ID3D11Device *d3ddev);
......
......@@ -137,7 +137,7 @@ struct vout_display_sys_t
#if !VLC_WINSTORE_APP
HINSTANCE hdxgi_dll; /* handle of the opened dxgi dll */
HINSTANCE hd3d11_dll; /* handle of the opened d3d11 dll */
d3d11_handle_t hd3d;
HINSTANCE hd3dcompiler_dll; /* handle of the opened d3dcompiler dll */
/* We should find a better way to store this or atleast a shorter name */
PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN OurD3D11CreateDeviceAndSwapChain;
......@@ -418,8 +418,8 @@ static int OpenHwnd(vout_display_t *vd)
if (!sys)
return VLC_ENOMEM;
sys->hd3d11_dll = LoadLibrary(TEXT("D3D11.DLL"));
if (!sys->hd3d11_dll) {
sys->hd3d.hdll = LoadLibrary(TEXT("D3D11.DLL"));
if (!sys->hd3d.hdll) {
msg_Warn(vd, "cannot load d3d11.dll, aborting");
return VLC_EGENERIC;
}
......@@ -439,7 +439,7 @@ static int OpenHwnd(vout_display_t *vd)
}
sys->OurD3D11CreateDevice =
(void *)GetProcAddress(sys->hd3d11_dll, "D3D11CreateDevice");
(void *)GetProcAddress(sys->hd3d.hdll, "D3D11CreateDevice");
if (!sys->OurD3D11CreateDevice) {
msg_Err(vd, "Cannot locate reference to D3D11CreateDevice in d3d11 DLL");
Direct3D11Destroy(vd);
......@@ -1242,8 +1242,8 @@ static void Direct3D11Destroy(vout_display_t *vd)
#if !VLC_WINSTORE_APP
vout_display_sys_t *sys = vd->sys;
if (sys->hd3d11_dll)
FreeLibrary(sys->hd3d11_dll);
if (sys->hd3d.hdll)
FreeLibrary(sys->hd3d.hdll);
if (sys->hd3dcompiler_dll)
FreeLibrary(sys->hd3dcompiler_dll);
......@@ -1251,7 +1251,7 @@ static void Direct3D11Destroy(vout_display_t *vd)
sys->OurD3D11CreateDeviceAndSwapChain = NULL;
sys->OurD3DCompile = NULL;
sys->hdxgi_dll = NULL;
sys->hd3d11_dll = NULL;
sys->hd3d.hdll = NULL;
sys->hd3dcompiler_dll = NULL;
#else
VLC_UNUSED(vd);
......@@ -1476,7 +1476,7 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
//scd.Flags = 512; // DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO;
scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
hr = D3D11_CreateDevice(VLC_OBJECT(vd), sys->hd3d11_dll,
hr = D3D11_CreateDevice(VLC_OBJECT(vd), &sys->hd3d,
is_d3d11_opaque(fmt->i_chroma),
&sys->d3d_dev);
if (FAILED(hr)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment