[vlc-devel] [PATCH 01/12] d3d11: allow rendering video to DirectComposition surfaces

Pierre Lamot pierre at videolabs.io
Tue May 12 09:41:48 CEST 2020


>> [...]
>> + video_output/win32/common.c video_output/win32/common.h \
>> + video_output/win32/dcomp_wrapper.cpp 
>> video_output/win32/dcomp_wrapper.h
>>   libdirect3d11_plugin_la_LIBADD = libchroma_copy.la 
>> libd3d11_common.la $(LIBCOM) -luuid
>>   if !HAVE_WINSTORE
>>   libdirect3d11_plugin_la_SOURCES += video_output/win32/events.c \
>> diff --git a/modules/video_output/win32/d3d11_swapchain.c 
>> b/modules/video_output/win32/d3d11_swapchain.c
>> index 7114bf57ef..3bfa989982 100644
>> --- a/modules/video_output/win32/d3d11_swapchain.c
>> +++ b/modules/video_output/win32/d3d11_swapchain.c
>> @@ -51,6 +51,7 @@
>>     #include "d3d11_swapchain.h"
>>   #include "d3d11_shaders.h"
>> +#include "dcomp_wrapper.h"
>>     typedef enum video_color_axis {
>>       COLOR_AXIS_RGB,
>> @@ -76,7 +77,10 @@ struct d3d11_local_swapchain
>>       const dxgi_color_space *colorspace;
>>     #if !VLC_WINSTORE_APP
>> +    bool                   useDcomp;
>>       HWND                   swapchainHwnd;
>> +    void*                  dcompDevice;
>> +    void*                  dcompVisual;
> 
> The HWND APIs are not allowed in UWP that's why the swapchainHwnd is
> in the ifdef. But DirectComposition is allowed so these variables
> should not be in the ifdef.
> 
> You could also use a union to differentiate swapchainHwnd from
> dcompDevice+dcompVisual.

OK

>>   #endif /* !VLC_WINSTORE_APP */
>>       IDXGISwapChain1        *dxgiswapChain;   /* DXGI 1.2 swap chain 
>> */
>>       IDXGISwapChain4        *dxgiswapChain4;  /* DXGI 1.5 for HDR 
>> metadata */
>> @@ -278,7 +282,7 @@ static void FillSwapChainDesc(struct 
>> d3d11_local_swapchain *display, UINT width,
>>     static void CreateSwapchain(struct d3d11_local_swapchain *display, 
>> UINT width, UINT height)
>>   {
>> -    if (display->swapchainHwnd == NULL)
>> +    if (!display->useDcomp && display->swapchainHwnd == NULL)
> 
> It may be easier to create another version of the function for
> DirectComposition. It will go outside of the #ifdef too.
> 

OK

>>       {
>>           msg_Err(display->obj, "missing a HWND to create the 
>> swapchain");
>>           return;
>> @@ -301,18 +305,31 @@ static void CreateSwapchain(struct 
>> d3d11_local_swapchain *display, UINT width, U
>>           return;
>>       }
>>   -    hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, 
>> (IUnknown *)display->d3d_dev->d3ddevice,
>> 
>>  [...]
>> 
>> --- /dev/null
>> +++ b/modules/video_output/win32/dcomp_wrapper.h
>> @@ -0,0 +1,42 @@
>> +/*****************************************************************************
>> + * Copyright (c) 2020 VideoLAN
>> + *
>> + * This program is free software; you can redistribute it and/or 
>> modify it
>> + * under the terms of the GNU Lesser General Public License as 
>> published by
>> + * the Free Software Foundation; either version 2.1 of the License, 
>> or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public 
>> License
>> + * along with this program; if not, write to the Free Software 
>> Foundation,
>> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
>> + 
>> *****************************************************************************/
>> +#ifndef VLC_DCOMP_WRAPPER_H_
>> +#define VLC_DCOMP_WRAPPER_H_
>> +
>> +
>> +#ifdef HAVE_CONFIG_H
>> +# include "config.h"
>> +#endif
> 
> Usually the config.h is not included in headers but C/C++ files.
> 
>> +
>> +#include <vlc_common.h>
> 
> You don't use anything from this header.
> 

Yeah sorry, bad habits



More information about the vlc-devel mailing list