vlc | branch: master | Steve Lhomme <[email protected]> | Wed Jun 26 09:47:37 2019 +0200| [ba5c9bfced5186d13f50154d04ec764d7f9b3dc8] | committer: Steve Lhomme
direct3d9: no need for a HWND at all to create & use a device When presenting the data we use the proper HWND to Present(). When rendering externally it's the host that needs to take care of that, and we render in a texture anyway. The decoder/filters don't seem to need the HWND at all (tested on Win7 and 10). And simplify the calls to D3D9_CreateExternal(). > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ba5c9bfced5186d13f50154d04ec764d7f9b3dc8 --- modules/codec/avcodec/dxva2.c | 6 +++--- modules/video_chroma/d3d9_fmt.c | 19 ++++++++----------- modules/video_chroma/d3d9_fmt.h | 10 ++++------ modules/video_output/win32/direct3d9.c | 4 ++-- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c index 6ee8888131..977bf09309 100644 --- a/modules/codec/avcodec/dxva2.c +++ b/modules/codec/avcodec/dxva2.c @@ -277,8 +277,8 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt, free( sys ); goto error; } - if ( D3D9_CreateExternal(va, &sys->hd3d, device) != VLC_SUCCESS || - FAILED(D3D9_CreateDeviceExternal( device, &sys->hd3d, 0, &sys->d3d_dev)) ) + if ( D3D9_CreateExternal(&sys->hd3d, device) != VLC_SUCCESS || + FAILED(D3D9_CreateDeviceExternal( device, &sys->hd3d, &sys->d3d_dev)) ) { IDirect3DDevice9_Release(device); free( sys ); @@ -359,7 +359,7 @@ static int D3dCreateDevice(vlc_va_t *va) return VLC_SUCCESS; } - HRESULT hr = D3D9_CreateDevice(va, &sys->hd3d, -1, NULL, &sys->d3d_dev); + HRESULT hr = D3D9_CreateDevice(va, &sys->hd3d, -1, &sys->d3d_dev); if (FAILED(hr)) { msg_Err(va, "IDirect3D9_CreateDevice failed"); diff --git a/modules/video_chroma/d3d9_fmt.c b/modules/video_chroma/d3d9_fmt.c index ec23efd565..e7579abf12 100644 --- a/modules/video_chroma/d3d9_fmt.c +++ b/modules/video_chroma/d3d9_fmt.c @@ -31,7 +31,7 @@ typedef picture_sys_d3d9_t VA_PICSYS; #include "../codec/avcodec/va_surface.h" #undef D3D9_CreateDevice -HRESULT D3D9_CreateDevice(vlc_object_t *o, d3d9_handle_t *hd3d, int AdapterToUse, HWND hwnd, +HRESULT D3D9_CreateDevice(vlc_object_t *o, d3d9_handle_t *hd3d, int AdapterToUse, d3d9_device_t *out) { HRESULT hr; @@ -74,7 +74,6 @@ HRESULT D3D9_CreateDevice(vlc_object_t *o, d3d9_handle_t *hd3d, int AdapterToUse } out->adapterId = AdapterToUse; - out->hwnd = hwnd; /* TODO only create a device for the decoder dimensions */ D3DPRESENT_PARAMETERS d3dpp; if (D3D9_FillPresentationParameters(hd3d, out, &d3dpp)) @@ -105,12 +104,12 @@ HRESULT D3D9_CreateDevice(vlc_object_t *o, d3d9_handle_t *hd3d, int AdapterToUse DWORD creationFlags = thread_modes[t] | vertex_modes[v]; if (hd3d->use_ex) hr = IDirect3D9Ex_CreateDeviceEx(hd3d->objex, AdapterToUse, - DeviceType, hwnd, + DeviceType, NULL, creationFlags, &d3dpp, NULL, &out->devex); else hr = IDirect3D9_CreateDevice(hd3d->obj, AdapterToUse, - DeviceType, hwnd, + DeviceType, NULL, creationFlags, &d3dpp, &out->dev); if (SUCCEEDED(hr)) @@ -127,7 +126,7 @@ HRESULT D3D9_CreateDevice(vlc_object_t *o, d3d9_handle_t *hd3d, int AdapterToUse return hr; } -HRESULT D3D9_CreateDeviceExternal(IDirect3DDevice9 *dev, d3d9_handle_t *hd3d, HWND hwnd, +HRESULT D3D9_CreateDeviceExternal(IDirect3DDevice9 *dev, d3d9_handle_t *hd3d, d3d9_device_t *out) { D3DDEVICE_CREATION_PARAMETERS params; @@ -136,7 +135,6 @@ HRESULT D3D9_CreateDeviceExternal(IDirect3DDevice9 *dev, d3d9_handle_t *hd3d, HW return hr; out->dev = dev; out->owner = false; - out->hwnd = hwnd; out->adapterId = params.AdapterOrdinal; ZeroMemory(&out->caps, sizeof(out->caps)); hr = IDirect3D9_GetDeviceCaps(hd3d->obj, out->adapterId, params.DeviceType, &out->caps); @@ -165,7 +163,7 @@ void D3D9_ReleaseDevice(d3d9_device_t *d3d_dev) * from the default adapter. */ int D3D9_FillPresentationParameters(d3d9_handle_t *hd3d, - const d3d9_device_t *out, + const d3d9_device_t *d3ddev, D3DPRESENT_PARAMETERS *d3dpp) { /* @@ -173,7 +171,7 @@ int D3D9_FillPresentationParameters(d3d9_handle_t *hd3d, ** buffer of the same format */ D3DDISPLAYMODE d3ddm; - HRESULT hr = IDirect3D9_GetAdapterDisplayMode(hd3d->obj, out->adapterId, &d3ddm); + HRESULT hr = IDirect3D9_GetAdapterDisplayMode(hd3d->obj, d3ddev->adapterId, &d3ddm); if (FAILED(hr)) return VLC_EGENERIC; @@ -184,7 +182,7 @@ int D3D9_FillPresentationParameters(d3d9_handle_t *hd3d, d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; d3dpp->EnableAutoDepthStencil = FALSE; - d3dpp->hDeviceWindow = out->hwnd; + d3dpp->hDeviceWindow = NULL; d3dpp->SwapEffect = D3DSWAPEFFECT_COPY; d3dpp->BackBufferFormat = d3ddm.Format; d3dpp->BackBufferCount = 1; @@ -256,8 +254,7 @@ error: return VLC_EGENERIC; } -#undef D3D9_CreateExternal -int D3D9_CreateExternal(vlc_object_t *o, d3d9_handle_t *hd3d, IDirect3DDevice9 *d3d9dev) +int D3D9_CreateExternal(d3d9_handle_t *hd3d, IDirect3DDevice9 *d3d9dev) { HRESULT hr = IDirect3DDevice9_GetDirect3D(d3d9dev, &hd3d->obj); if (unlikely(FAILED(hr))) diff --git a/modules/video_chroma/d3d9_fmt.h b/modules/video_chroma/d3d9_fmt.h index 8453d875f6..f35e4414c9 100644 --- a/modules/video_chroma/d3d9_fmt.h +++ b/modules/video_chroma/d3d9_fmt.h @@ -63,7 +63,6 @@ typedef struct /* creation parameters */ D3DFORMAT BufferFormat; UINT adapterId; - HWND hwnd; D3DCAPS9 caps; } d3d9_device_t; @@ -95,17 +94,16 @@ static inline void ReleaseD3D9PictureSys(picture_sys_d3d9_t *p_sys) FreeLibrary(p_sys->dxva2_dll); } -HRESULT D3D9_CreateDevice(vlc_object_t *, d3d9_handle_t *, int, HWND, +HRESULT D3D9_CreateDevice(vlc_object_t *, d3d9_handle_t *, int, d3d9_device_t *out); -#define D3D9_CreateDevice(a,b,c,d,e) D3D9_CreateDevice( VLC_OBJECT(a), b, c, d, e ) -HRESULT D3D9_CreateDeviceExternal(IDirect3DDevice9 *, d3d9_handle_t *, HWND, +#define D3D9_CreateDevice(a,b,c,d) D3D9_CreateDevice( VLC_OBJECT(a), b, c, d ) +HRESULT D3D9_CreateDeviceExternal(IDirect3DDevice9 *, d3d9_handle_t *, d3d9_device_t *out); void D3D9_ReleaseDevice(d3d9_device_t *); int D3D9_Create(vlc_object_t *, d3d9_handle_t *); #define D3D9_Create(a,b) D3D9_Create( VLC_OBJECT(a), b ) -int D3D9_CreateExternal(vlc_object_t *, d3d9_handle_t *, IDirect3DDevice9 *); -#define D3D9_CreateExternal(a,b,c) D3D9_CreateExternal( VLC_OBJECT(a), b, c ) +int D3D9_CreateExternal(d3d9_handle_t *, IDirect3DDevice9 *); void D3D9_CloneExternal(d3d9_handle_t *, IDirect3D9 *); void D3D9_Destroy(d3d9_handle_t *); diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c index 12a65b6964..4fe32fbb6d 100644 --- a/modules/video_output/win32/direct3d9.c +++ b/modules/video_output/win32/direct3d9.c @@ -1699,7 +1699,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg, } IDirect3D9 *d3d9_device = device_setup.device_context; D3D9_CloneExternal( &sys->hd3d, d3d9_device ); - HRESULT hr = D3D9_CreateDevice(vd, &sys->hd3d, device_setup.adapter, NULL, &sys->d3d_dev); + HRESULT hr = D3D9_CreateDevice(vd, &sys->hd3d, device_setup.adapter, &sys->d3d_dev); if (FAILED(hr)) { msg_Err( vd, "D3D9 Creation failed! (hr=0x%lX)", hr); D3D9_Destroy(&sys->hd3d); @@ -1961,7 +1961,7 @@ GLConvOpen(vlc_object_t *obj) goto error; } - if (FAILED(D3D9_CreateDevice(obj, &priv->hd3d, -1, NULL, + if (FAILED(D3D9_CreateDevice(obj, &priv->hd3d, -1, &priv->d3d_dev))) goto error; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
