[vlc-commits] [Git][videolan/vlc][master] 3 commits: d3d11_player: handle 0 dimensions we report to the app

François Cartegnie (@fcartegnie) gitlab at videolan.org
Thu Jun 2 09:25:21 UTC 2022



François Cartegnie pushed to branch master at VideoLAN / VLC


Commits:
d22c1a2b by Steve Lhomme at 2022-06-02T09:10:37+00:00
d3d11_player: handle 0 dimensions we report to the app

We could avoid sending 0, or we could avoid the rendering if it's 0.
But being a "simple" sample app, let's use the easiest way.

- - - - -
ee28019f by Steve Lhomme at 2022-06-02T09:10:37+00:00
d3d11_player: only read lParam once

- - - - -
2398a5f4 by Steve Lhomme at 2022-06-02T09:10:37+00:00
dxgi_swapchain: handle 0 dimensions swapchains

For now we use the default values it would use otherwise.

DXGI WARNING: IDXGIFactory::CreateSwapChain/IDXGISwapChain::ResizeBuffers: The buffer height inferred from the output window is zero. Taking 8 as a reasonable default instead [ MISCELLANEOUS WARNING #2: ]

- - - - -


2 changed files:

- doc/libvlc/d3d11_player.cpp
- modules/video_output/win32/dxgi_swapchain.cpp


Changes:

=====================================
doc/libvlc/d3d11_player.cpp
=====================================
@@ -390,6 +390,13 @@ static bool UpdateOutput_cb( void *opaque, const libvlc_video_render_cfg_t *cfg,
     texDesc.Width  = cfg->width;
     texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_NTHANDLE;
 
+    // we reported a size of 0, we have to handle it
+    // 0 dimensions are not allowed, a value of 8 is used otherwise
+    if (cfg->width == 0)
+        texDesc.Width = 8;
+    if (cfg->height == 0)
+        texDesc.Height = 8;
+
     hr = ctx->d3device->CreateTexture2D( &texDesc, NULL, &ctx->resized.texture );
     if (FAILED(hr)) return false;
 
@@ -553,8 +560,8 @@ static LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
             }
             ReleaseSRWLockExclusive(&ctx->swapchainLock);
 
-            ctx->width  = unsigned(LOWORD(lParam) * (BORDER_RIGHT - BORDER_LEFT) / 2.0f); // remove the orange part !
-            ctx->height = unsigned(HIWORD(lParam) * (BORDER_TOP - BORDER_BOTTOM) / 2.0f);
+            ctx->width  = unsigned(ctx->client_area.width * (BORDER_RIGHT - BORDER_LEFT) / 2.0f); // remove the orange part !
+            ctx->height = unsigned(ctx->client_area.height * (BORDER_TOP - BORDER_BOTTOM) / 2.0f);
 
             // tell libvlc we want a new rendering size
             // we could also match the source video size and scale in swapchain render


=====================================
modules/video_output/win32/dxgi_swapchain.cpp
=====================================
@@ -456,6 +456,10 @@ bool DXGI_UpdateSwapChain( dxgi_swapchain *display, IDXGIAdapter *dxgiadapter,
                            IUnknown *pFactoryDevice,
                            const d3d_format_t *newPixelFormat, const libvlc_video_render_cfg_t *cfg )
 {
+    // 0 dimensions are not allowed, a value of 8 is used otherwise
+    UINT width = cfg->width ? cfg->width : 8;
+    UINT height = cfg->height ? cfg->height : 8;
+
 #ifndef VLC_WINSTORE_APP
     if (display->dxgiswapChain.Get() && display->pixelFormat != newPixelFormat)
     {
@@ -471,11 +475,11 @@ bool DXGI_UpdateSwapChain( dxgi_swapchain *display, IDXGIAdapter *dxgiadapter,
 #if defined(HAVE_DCOMP_H)
         if (display->swapchainSurfaceType == SWAPCHAIN_SURFACE_DCOMP)
             DXGI_CreateSwapchainDComp(display, dxgiadapter, pFactoryDevice,
-                                      cfg->width, cfg->height);
+                                      width, height);
         else // SWAPCHAIN_TARGET_HWND
 #endif // HAVE_DCOMP_H
             DXGI_CreateSwapchainHwnd(display, dxgiadapter, pFactoryDevice,
-                                     cfg->width, cfg->height);
+                                     width, height);
 
     }
 #else /* VLC_WINSTORE_APP */
@@ -489,7 +493,7 @@ bool DXGI_UpdateSwapChain( dxgi_swapchain *display, IDXGIAdapter *dxgiadapter,
 
     /* TODO detect is the size is the same as the output and switch to fullscreen mode */
     HRESULT hr;
-    hr = display->dxgiswapChain->ResizeBuffers(0, cfg->width, cfg->height,
+    hr = display->dxgiswapChain->ResizeBuffers(0, width, height,
                                         DXGI_FORMAT_UNKNOWN, 0 );
     if ( FAILED( hr ) ) {
         msg_Err( display->obj, "Failed to resize the backbuffer. (hr=0x%lX)", hr );



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1460dde11478212021e03a0a669de50c3289c48f...2398a5f469ad083794bfecf142e480871a8040f6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1460dde11478212021e03a0a669de50c3289c48f...2398a5f469ad083794bfecf142e480871a8040f6
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list