[vlc-commits] direct3d11: fix the legacy winstore swapchain size change detection
Steve Lhomme
git at videolan.org
Wed Apr 8 14:53:56 CEST 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Apr 7 15:49:39 2020 +0200| [540a1c00b65e1c0dbc307c6f849d58efcd8bda10] | committer: Steve Lhomme
direct3d11: fix the legacy winstore swapchain size change detection
Call a custom callback before calling StartEndRendering, rather than doing it
inside StartEndRendering.
Once we remove this legacy hack we can remove the callback.
Plus some winstore compilation fixes.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=540a1c00b65e1c0dbc307c6f849d58efcd8bda10
---
modules/video_output/win32/d3d11_swapchain.c | 47 ++++++++++++++--------------
modules/video_output/win32/d3d11_swapchain.h | 1 +
modules/video_output/win32/direct3d11.c | 13 ++++++++
3 files changed, 38 insertions(+), 23 deletions(-)
diff --git a/modules/video_output/win32/d3d11_swapchain.c b/modules/video_output/win32/d3d11_swapchain.c
index 894032db1a..7114bf57ef 100644
--- a/modules/video_output/win32/d3d11_swapchain.c
+++ b/modules/video_output/win32/d3d11_swapchain.c
@@ -353,11 +353,11 @@ static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const libvlc
const d3d_format_t *newPixelFormat = NULL;
#if VLC_WINSTORE_APP
- display->dxgiswapChain = var_InheritInteger(display->obj, "winrt-swapchain");
+ display->dxgiswapChain = (void*)(uintptr_t)var_InheritInteger(display->obj, "winrt-swapchain");
if (display->dxgiswapChain != NULL)
{
DXGI_SWAP_CHAIN_DESC1 scd;
- if (SUCCEEDED(IDXGISwapChain1_GetDesc(display->dxgiswapChain, &scd)))
+ if (SUCCEEDED(IDXGISwapChain1_GetDesc1(display->dxgiswapChain, &scd)))
{
for (const d3d_format_t *output_format = GetRenderFormatList();
output_format->name != NULL; ++output_format)
@@ -486,32 +486,31 @@ bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_render_cfg_t *
return true;
}
+bool LocalSwapchainWinstoreSize( void *opaque, uint32_t *width, uint32_t *height )
+{
+#if VLC_WINSTORE_APP
+ struct d3d11_local_swapchain *display = opaque;
+ /* legacy UWP mode, the width/height was set in GUID_SWAPCHAIN_WIDTH/HEIGHT */
+ UINT dataSize = sizeof(*width);
+ HRESULT hr = IDXGISwapChain_GetPrivateData(display->dxgiswapChain, &GUID_SWAPCHAIN_WIDTH, &dataSize, width);
+ if (SUCCEEDED(hr)) {
+ dataSize = sizeof(*height);
+ hr = IDXGISwapChain_GetPrivateData(display->dxgiswapChain, &GUID_SWAPCHAIN_HEIGHT, &dataSize, height);
+ return SUCCEEDED(hr);
+ }
+#else
+ VLC_UNUSED(opaque); VLC_UNUSED(width); VLC_UNUSED(height);
+#endif
+ return false;
+}
+
bool LocalSwapchainStartEndRendering( void *opaque, bool enter )
{
struct d3d11_local_swapchain *display = opaque;
if ( enter )
- {
-#if VLC_WINSTORE_APP
- /* legacy UWP mode, the width/height was set in GUID_SWAPCHAIN_WIDTH/HEIGHT */
- uint32_t i_width;
- uint32_t i_height;
- UINT dataSize = sizeof(i_width);
- HRESULT hr = IDXGISwapChain_GetPrivateData(display->dxgiswapChain, &GUID_SWAPCHAIN_WIDTH, &dataSize, &i_width);
- if (SUCCEEDED(hr)) {
- dataSize = sizeof(i_height);
- hr = IDXGISwapChain_GetPrivateData(display->dxgiswapChain, &GUID_SWAPCHAIN_HEIGHT, &dataSize, &i_height);
- if (SUCCEEDED(hr)) {
- if (i_width != sys->area.vdcfg.display.width || i_height != sys->area.vdcfg.display.height)
- {
- vout_display_SetSize(vd, i_width, i_height);
- }
- }
- }
-#endif
-
D3D11_ClearRenderTargets( display->d3d_dev, display->pixelFormat, display->swapchainTargetView );
- }
+
return true;
}
@@ -565,7 +564,9 @@ void *CreateLocalSwapchainHandle(vlc_object_t *o, HWND hwnd, d3d11_device_t *d3d
display->obj = o;
#if !VLC_WINSTORE_APP
display->swapchainHwnd = hwnd;
-#endif /* !VLC_WINSTORE_APP */
+#else // VLC_WINSTORE_APP
+ VLC_UNUSED(hwnd);
+#endif // VLC_WINSTORE_APP
display->d3d_dev = d3d_dev;
return display;
diff --git a/modules/video_output/win32/d3d11_swapchain.h b/modules/video_output/win32/d3d11_swapchain.h
index c754f10ec8..a5bfeac3c3 100644
--- a/modules/video_output/win32/d3d11_swapchain.h
+++ b/modules/video_output/win32/d3d11_swapchain.h
@@ -36,5 +36,6 @@ bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_render_cfg_t *
bool LocalSwapchainStartEndRendering( void *opaque, bool enter );
void LocalSwapchainSetMetadata( void *opaque, libvlc_video_metadata_type_t, const void * );
bool LocalSwapchainSelectPlane( void *opaque, size_t plane );
+bool LocalSwapchainWinstoreSize( void *opaque, uint32_t *, uint32_t * );
#endif /* VLC_D3D11_SWAPCHAIN_H */
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index dd815124e5..1939b185ec 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -672,6 +672,19 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
VLC_UNUSED(date);
d3d11_device_lock( sys->d3d_dev );
+#if VLC_WINSTORE_APP
+ if ( sys->swapCb == LocalSwapchainSwap )
+ {
+ /* legacy UWP mode, the width/height was set in GUID_SWAPCHAIN_WIDTH/HEIGHT */
+ uint32_t i_width;
+ uint32_t i_height;
+ if (LocalSwapchainWinstoreSize( sys->outside_opaque, &i_width, &i_height ))
+ {
+ if (i_width != sys->area.vdcfg.display.width || i_height != sys->area.vdcfg.display.height)
+ vout_display_SetSize(vd, i_width, i_height);
+ }
+ }
+#endif
if ( sys->startEndRenderingCb( sys->outside_opaque, true ))
{
if ( sys->sendMetadataCb && picture->format.mastering.max_luminance )
More information about the vlc-commits
mailing list