[vlc-devel] [PATCH] direct3d9: support rendering of D3D9 surfaces coming out of DXVA2
Steve Lhomme
robux4 at videolabs.io
Wed Apr 29 09:43:07 CEST 2015
Discard this patch, it's missing the visible dimension surface change.
On Wed, Apr 29, 2015 at 9:32 AM, Steve Lhomme <robUx4 at videolabs.io> wrote:
> --
> will be active once dxva2.c outputs VLC_CODEC_D3D9_OPAQUE
>
> use DXA9 as the surface format name
> simplify indentation code
> ---
> modules/video_output/msw/direct3d9.c | 49 ++++++++++++++++++++----------------
> 1 file changed, 28 insertions(+), 21 deletions(-)
>
> diff --git a/modules/video_output/msw/direct3d9.c b/modules/video_output/msw/direct3d9.c
> index db96275..c1ebb21 100644
> --- a/modules/video_output/msw/direct3d9.c
> +++ b/modules/video_output/msw/direct3d9.c
> @@ -50,6 +50,7 @@
>
> #include "common.h"
> #include "builtin_shaders.h"
> +#include "../../src/win32/direct3d9_pool.h"
>
> /*****************************************************************************
> * Module descriptor
> @@ -202,10 +203,10 @@ static int Open(vlc_object_t *object)
>
> /* */
> vout_display_info_t info = vd->info;
> - info.is_slow = true;
> + info.is_slow = fmt.i_chroma != VLC_CODEC_D3D9_OPAQUE;
> info.has_double_click = true;
> info.has_hide_mouse = false;
> - info.has_pictures_invalid = true;
> + info.has_pictures_invalid = fmt.i_chroma != VLC_CODEC_D3D9_OPAQUE;
> info.has_event_thread = true;
> if (var_InheritBool(vd, "direct3d9-hw-blending") &&
> sys->d3dregion_format != D3DFMT_UNKNOWN &&
> @@ -274,7 +275,8 @@ static void Close(vlc_object_t *object)
> /* */
> static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
> {
> - VLC_UNUSED(count);
> + if ( vd->sys->pool == NULL )
> + vd->sys->pool = AllocPoolD3D9Ex( VLC_OBJECT(vd), vd->sys->d3ddev, &vd->fmt, count );
> return vd->sys->pool;
> }
>
> @@ -283,21 +285,18 @@ static void Direct3D9UnlockSurface(picture_t *);
>
> static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
> {
> + VLC_UNUSED(subpicture);
> +
> vout_display_sys_t *sys = vd->sys;
> LPDIRECT3DSURFACE9 surface = picture->p_sys->surface;
> -#if 0
> - picture_Release(picture);
> - VLC_UNUSED(subpicture);
> -#else
> +
> /* FIXME it is a bit ugly, we need the surface to be unlocked for
> * rendering.
> * The clean way would be to release the picture (and ensure that
> * the vout doesn't keep a reference). But because of the vout
> * wrapper, we can't */
> -
> - Direct3D9UnlockSurface(picture);
> - VLC_UNUSED(subpicture);
> -#endif
> + if ( picture->format.i_chroma != VLC_CODEC_D3D9_OPAQUE )
> + Direct3D9UnlockSurface(picture);
>
> /* check if device is still available */
> HRESULT hr = IDirect3DDevice9_TestCooperativeLevel(sys->d3ddev);
> @@ -335,6 +334,8 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
>
> static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
> {
> + VLC_UNUSED(subpicture);
> +
> vout_display_sys_t *sys = vd->sys;
> LPDIRECT3DDEVICE9 d3ddev = sys->d3ddev;
>
> @@ -354,14 +355,10 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
> msg_Dbg(vd, "Failed IDirect3DDevice9_Present: 0x%0lx", hr);
> }
>
> -#if 0
> - VLC_UNUSED(picture);
> - VLC_UNUSED(subpicture);
> -#else
> /* XXX See Prepare() */
> - Direct3D9LockSurface(picture);
> + if ( picture->format.i_chroma != VLC_CODEC_D3D9_OPAQUE )
> + Direct3D9LockSurface(picture);
> picture_Release(picture);
> -#endif
> if (subpicture)
> subpicture_Delete(subpicture);
>
> @@ -860,6 +857,7 @@ static const d3d_format_t d3d_formats[] = {
> { "YV12", MAKEFOURCC('Y','V','1','2'), VLC_CODEC_I420, 0,0,0 },
> { "YV12", MAKEFOURCC('Y','V','1','2'), VLC_CODEC_J420, 0,0,0 },
> { "NV12", MAKEFOURCC('N','V','1','2'), VLC_CODEC_NV12, 0,0,0 },
> + { "DXA9", MAKEFOURCC('N','V','1','2'), VLC_CODEC_D3D9_OPAQUE, 0,0,0 },
> { "UYVY", D3DFMT_UYVY, VLC_CODEC_UYVY, 0,0,0 },
> { "YUY2", D3DFMT_YUY2, VLC_CODEC_YUYV, 0,0,0 },
> { "X8R8G8B8", D3DFMT_X8R8G8B8,VLC_CODEC_RGB32, 0xff0000, 0x00ff00, 0x0000ff },
> @@ -879,8 +877,11 @@ static const d3d_format_t *Direct3DFindFormat(vout_display_t *vd, vlc_fourcc_t c
>
> for (unsigned pass = 0; pass < 2; pass++) {
> const vlc_fourcc_t *list;
> + const vlc_fourcc_t dxva_chroma[] = {chroma, 0};
>
> - if (pass == 0 && sys->allow_hw_yuv && vlc_fourcc_IsYUV(chroma))
> + if (pass == 0 && chroma == VLC_CODEC_D3D9_OPAQUE)
> + list = dxva_chroma;
> + else if (pass == 0 && sys->allow_hw_yuv && vlc_fourcc_IsYUV(chroma))
> list = vlc_fourcc_GetYUVFallback(chroma);
> else if (pass == 1)
> list = vlc_fourcc_GetRGBFallback(chroma);
> @@ -966,6 +967,10 @@ static int Direct3D9CreatePool(vout_display_t *vd, video_format_t *fmt)
> fmt->i_gmask = d3dfmt->gmask;
> fmt->i_bmask = d3dfmt->bmask;
>
> + if ( fmt->i_chroma == VLC_CODEC_D3D9_OPAQUE )
> + /* a DXA9 pool will be created when needed */
> + return VLC_SUCCESS;
> +
> /* We create one picture.
> * It is useless to create more as we can't be used for direct rendering */
>
> @@ -1038,9 +1043,11 @@ static void Direct3D9DestroyPool(vout_display_t *vd)
>
> if (sys->pool) {
> picture_sys_t *picsys = sys->picsys;
> - IDirect3DSurface9_Release(picsys->surface);
> - if (picsys->fallback)
> - picture_Release(picsys->fallback);
> + if ( picsys != NULL ) {
> + IDirect3DSurface9_Release(picsys->surface);
> + if (picsys->fallback)
> + picture_Release(picsys->fallback);
> + }
> picture_pool_Release(sys->pool);
> }
> sys->pool = NULL;
> --
> 2.3.2
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list