[vlc-commits] direct3d11: use the indirect texture size

Steve Lhomme git at videolan.org
Wed Aug 1 15:16:38 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Aug  1 15:08:22 2018 +0200| [6574ae65da647880a3a2d42caf42e6704e9cb278] | committer: Steve Lhomme

direct3d11: use the indirect texture size

It can have padding for the decoder that is not known to avcodec and we don't
want to show it in vd->fmt to avoid adding a converter.

This padding needs to be taken in account when placing the picture in the display area.

We can get rid of the hackish BEFORE_UPDATE_RECTS/AFTER_UPDATE_RECTS macros.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6574ae65da647880a3a2d42caf42e6704e9cb278
---

 modules/video_output/win32/direct3d11.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index c11005482a..e294dbc453 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -243,6 +243,16 @@ static bool GetRect(const vout_display_sys_win32_t *p_sys, RECT *out)
 }
 #endif
 
+static unsigned int GetPictureWidth(const vout_display_t *vd)
+{
+    return vd->sys->picQuad.i_width;
+}
+
+static unsigned int GetPictureHeight(const vout_display_t *vd)
+{
+    return vd->sys->picQuad.i_height;
+}
+
 static int Open(vlc_object_t *object)
 {
     vout_display_t *vd = (vout_display_t *)object;
@@ -275,6 +285,8 @@ static int Open(vlc_object_t *object)
 #if VLC_WINSTORE_APP
     vd->sys->sys.pf_GetRect = GetRect;
 #endif
+    vd->sys->sys.pf_GetPictureWidth  = GetPictureWidth;
+    vd->sys->sys.pf_GetPictureHeight = GetPictureHeight;
 
     if (Direct3D11Open(vd)) {
         msg_Err(vd, "Direct3D11 could not be opened");
@@ -718,15 +730,6 @@ static inline bool RectEquals(const RECT *r1, const RECT *r2)
            r1->left == r2->left && r1->right == r2->right;
 }
 
-#define BEFORE_UPDATE_RECTS \
-    unsigned int i_outside_width  = vd->fmt.i_width; \
-    unsigned int i_outside_height = vd->fmt.i_height; \
-    vd->fmt.i_width  = vd->sys->picQuad.i_width; \
-    vd->fmt.i_height = vd->sys->picQuad.i_height;
-#define AFTER_UPDATE_RECTS \
-    vd->fmt.i_width  = i_outside_width; \
-    vd->fmt.i_height = i_outside_height;
-
 static int Control(vout_display_t *vd, int query, va_list args)
 {
     vout_display_sys_t *sys = vd->sys;
@@ -734,9 +737,7 @@ static int Control(vout_display_t *vd, int query, va_list args)
     RECT before_dest_clipped = sys->sys.rect_dest_clipped;
     RECT before_dest         = sys->sys.rect_dest;
 
-    BEFORE_UPDATE_RECTS;
     int res = CommonControl( vd, query, args );
-    AFTER_UPDATE_RECTS;
 
     if (query == VOUT_DISPLAY_CHANGE_VIEWPOINT)
     {
@@ -765,9 +766,7 @@ static void Manage(vout_display_t *vd)
     RECT before_dest_clipped = sys->sys.rect_dest_clipped;
     RECT before_dest         = sys->sys.rect_dest;
 
-    BEFORE_UPDATE_RECTS;
     CommonManage(vd);
-    AFTER_UPDATE_RECTS;
 
     if (!RectEquals(&before_src_clipped, &sys->sys.rect_src_clipped) ||
         !RectEquals(&before_dest_clipped, &sys->sys.rect_dest_clipped) ||
@@ -865,9 +864,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
                 sys->picQuad.i_height = texDesc.Height;
                 sys->picQuad.i_width = texDesc.Width;
 
-                BEFORE_UPDATE_RECTS;
                 UpdateRects(vd, NULL, true);
-                AFTER_UPDATE_RECTS;
                 UpdateSize(vd);
             }
         }
@@ -1420,9 +1417,7 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
         sys->picQuad.i_height = (sys->picQuad.i_height + 0x01) & ~0x01;
     }
 
-    BEFORE_UPDATE_RECTS;
     UpdateRects(vd, NULL, true);
-    AFTER_UPDATE_RECTS;
 
 #ifdef HAVE_ID3D11VIDEODECODER
     if (!is_d3d11_opaque(fmt->i_chroma) || sys->legacy_shader)
@@ -1501,6 +1496,8 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
         ID3D11DepthStencilState_Release(pDepthStencilState);
     }
 
+    UpdateRects(vd, NULL, true);
+
     hr = UpdateBackBuffer(vd);
     if (FAILED(hr)) {
        msg_Err(vd, "Could not update the backbuffer. (hr=0x%lX)", hr);



More information about the vlc-commits mailing list