[vlc-commits] direct3d11: fix possibly failing CopySubresourceRegion on odd dimensions

Steve Lhomme git at videolan.org
Fri Aug 4 10:11:43 CEST 2017


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Tue Aug  1 15:01:21 2017 +0200| [433c5ec3ce29bf9ce36fdcccc5012f27b1e7e458] | committer: Jean-Baptiste Kempf

direct3d11: fix possibly failing CopySubresourceRegion on odd dimensions

The texture is created with extra size so we can use more for the copy.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/video_output/win32/direct3d11.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 3ae3f4bdae..6ecad0cb27 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1139,8 +1139,6 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
         if (!is_d3d11_opaque(picture->format.i_chroma))
             Direct3D11UnmapPoolTexture(picture);
         ID3D11Texture2D_GetDesc(sys->stagingSys.texture[0], &texDesc);
-        assert(picture->format.i_x_offset + picture->format.i_visible_width <= texDesc.Width);
-        assert(picture->format.i_y_offset + picture->format.i_visible_height <= texDesc.Height);
         D3D11_BOX box = {
             .top = 0,
             .bottom = picture->format.i_y_offset + picture->format.i_visible_height,
@@ -1148,6 +1146,14 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
             .right = picture->format.i_x_offset + picture->format.i_visible_width,
             .back = 1,
         };
+        if ( sys->picQuadConfig->formatTexture != DXGI_FORMAT_R8G8B8A8_UNORM &&
+             sys->picQuadConfig->formatTexture != DXGI_FORMAT_B5G6R5_UNORM )
+        {
+            box.bottom = (box.bottom + 0x01) & ~0x01;
+            box.right  = (box.right  + 0x01) & ~0x01;
+        }
+        assert(box.right <= texDesc.Width);
+        assert(box.bottom <= texDesc.Height);
         ID3D11DeviceContext_CopySubresourceRegion(sys->d3dcontext,
                                                   sys->stagingSys.resource[KNOWN_DXGI_INDEX],
                                                   0, 0, 0, 0,



More information about the vlc-commits mailing list