[vlc-commits] d3d11_swapchain: reuse the d3d11_device_t from the display module
Steve Lhomme
git at videolan.org
Fri Feb 7 15:58:49 CET 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Feb 5 09:40:28 2020 +0100| [42c09fa6125627d32aa979162722f033015204de] | committer: Steve Lhomme
d3d11_swapchain: reuse the d3d11_device_t from the display module
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=42c09fa6125627d32aa979162722f033015204de
---
modules/video_output/win32/d3d11_swapchain.c | 26 +++++++++++++-------------
modules/video_output/win32/d3d11_swapchain.h | 2 +-
modules/video_output/win32/direct3d11.c | 2 +-
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/modules/video_output/win32/d3d11_swapchain.c b/modules/video_output/win32/d3d11_swapchain.c
index 71112e876b..409bd1f70d 100644
--- a/modules/video_output/win32/d3d11_swapchain.c
+++ b/modules/video_output/win32/d3d11_swapchain.c
@@ -70,7 +70,7 @@ typedef struct {
struct d3d11_local_swapchain
{
vlc_object_t *obj;
- d3d11_device_t d3d_dev;
+ d3d11_device_t *d3d_dev;
const d3d_format_t *pixelFormat;
const dxgi_color_space *colorspace;
@@ -282,7 +282,7 @@ static void CreateSwapchain(struct d3d11_local_swapchain *display, UINT width, U
DXGI_SWAP_CHAIN_DESC1 scd;
FillSwapChainDesc(display, width, height, &scd);
- IDXGIAdapter *dxgiadapter = D3D11DeviceAdapter(display->d3d_dev.d3ddevice);
+ IDXGIAdapter *dxgiadapter = D3D11DeviceAdapter(display->d3d_dev->d3ddevice);
if (unlikely(dxgiadapter==NULL)) {
msg_Err(display->obj, "Could not get the DXGI Adapter");
return;
@@ -296,14 +296,14 @@ static void CreateSwapchain(struct d3d11_local_swapchain *display, UINT width, U
return;
}
- hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, (IUnknown *)display->d3d_dev.d3ddevice,
+ hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, (IUnknown *)display->d3d_dev->d3ddevice,
display->swapchainHwnd, &scd,
NULL, NULL, &display->dxgiswapChain);
if (hr == DXGI_ERROR_INVALID_CALL && scd.Format == DXGI_FORMAT_R10G10B10A2_UNORM)
{
msg_Warn(display->obj, "10 bits swapchain failed, try 8 bits");
scd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, (IUnknown *)display->d3d_dev.d3ddevice,
+ hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, (IUnknown *)display->d3d_dev->d3ddevice,
display->swapchainHwnd, &scd,
NULL, NULL, &display->dxgiswapChain);
}
@@ -368,12 +368,12 @@ static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const libvlc
}
#else /* !VLC_WINSTORE_APP */
/* favor RGB formats first */
- newPixelFormat = FindD3D11Format( display->obj, &display->d3d_dev, 0, D3D11_RGB_FORMAT,
+ newPixelFormat = FindD3D11Format( display->obj, display->d3d_dev, 0, D3D11_RGB_FORMAT,
cfg->bitdepth > 8 ? 10 : 8,
0, 0,
D3D11_CHROMA_CPU, D3D11_FORMAT_SUPPORT_DISPLAY );
if (unlikely(newPixelFormat == NULL))
- newPixelFormat = FindD3D11Format( display->obj, &display->d3d_dev, 0, D3D11_YUV_FORMAT,
+ newPixelFormat = FindD3D11Format( display->obj, display->d3d_dev, 0, D3D11_YUV_FORMAT,
cfg->bitdepth > 8 ? 10 : 8,
0, 0,
D3D11_CHROMA_CPU, D3D11_FORMAT_SUPPORT_DISPLAY );
@@ -418,7 +418,7 @@ static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const libvlc
return false;
}
- hr = D3D11_CreateRenderTargets( &display->d3d_dev, (ID3D11Resource *) pBackBuffer,
+ hr = D3D11_CreateRenderTargets( display->d3d_dev, (ID3D11Resource *) pBackBuffer,
display->pixelFormat, display->swapchainTargetView );
ID3D11Texture2D_Release( pBackBuffer );
if ( FAILED( hr ) ) {
@@ -426,7 +426,7 @@ static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const libvlc
return false;
}
- D3D11_ClearRenderTargets( &display->d3d_dev, display->pixelFormat, display->swapchainTargetView );
+ D3D11_ClearRenderTargets( display->d3d_dev, display->pixelFormat, display->swapchainTargetView );
SelectSwapchainColorspace(display, cfg);
@@ -454,7 +454,7 @@ void LocalSwapchainCleanupDevice( void *opaque )
display->dxgiswapChain = NULL;
}
- D3D11_ReleaseDevice( &display->d3d_dev );
+ D3D11_ReleaseDevice( display->d3d_dev );
}
void LocalSwapchainSwap( void *opaque )
@@ -525,7 +525,7 @@ bool LocalSwapchainStartEndRendering( void *opaque, bool enter, const libvlc_vid
IDXGISwapChain4_SetHDRMetaData( display->dxgiswapChain4, DXGI_HDR_METADATA_TYPE_HDR10, sizeof( hdr10 ), &hdr10 );
}
- D3D11_ClearRenderTargets( &display->d3d_dev, display->pixelFormat, display->swapchainTargetView );
+ D3D11_ClearRenderTargets( display->d3d_dev, display->pixelFormat, display->swapchainTargetView );
}
return true;
}
@@ -535,12 +535,12 @@ bool LocalSwapchainSelectPlane( void *opaque, size_t plane )
struct d3d11_local_swapchain *display = opaque;
if (!display->swapchainTargetView[plane])
return false;
- ID3D11DeviceContext_OMSetRenderTargets(display->d3d_dev.d3dcontext, 1,
+ ID3D11DeviceContext_OMSetRenderTargets(display->d3d_dev->d3dcontext, 1,
&display->swapchainTargetView[plane], NULL);
return true;
}
-void *CreateLocalSwapchainHandle(vlc_object_t *o, HWND hwnd, ID3D11DeviceContext *d3d11_ctx)
+void *CreateLocalSwapchainHandle(vlc_object_t *o, HWND hwnd, d3d11_device_t *d3d_dev)
{
struct d3d11_local_swapchain *display = vlc_obj_calloc(o, 1, sizeof(*display));
if (unlikely(display == NULL))
@@ -550,7 +550,7 @@ void *CreateLocalSwapchainHandle(vlc_object_t *o, HWND hwnd, ID3D11DeviceContext
#if !VLC_WINSTORE_APP
display->swapchainHwnd = hwnd;
#endif /* !VLC_WINSTORE_APP */
- D3D11_CreateDeviceExternal( o, d3d11_ctx, false /* is_d3d11_opaque(vd->source.i_chroma) */, &display->d3d_dev);
+ 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 6a4bbae5ea..9c1969ac77 100644
--- a/modules/video_output/win32/d3d11_swapchain.h
+++ b/modules/video_output/win32/d3d11_swapchain.h
@@ -28,7 +28,7 @@
#include <vlc_codec.h>
#include "../../video_chroma/d3d11_fmt.h"
-void *CreateLocalSwapchainHandle(vlc_object_t *, HWND, ID3D11DeviceContext *);
+void *CreateLocalSwapchainHandle(vlc_object_t *, HWND, d3d11_device_t *d3d_dev);
void LocalSwapchainCleanupDevice( void *opaque );
void LocalSwapchainSwap( void *opaque );
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index c5f6a63fcd..01ccedabb0 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -344,7 +344,7 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
#endif /* !VLC_WINSTORE_APP */
/* use our internal swapchain callbacks */
- sys->outside_opaque = CreateLocalSwapchainHandle(VLC_OBJECT(vd), sys->sys.hvideownd, sys->d3d_dev.d3dcontext);
+ sys->outside_opaque = CreateLocalSwapchainHandle(VLC_OBJECT(vd), sys->sys.hvideownd, &sys->d3d_dev);
if (unlikely(sys->outside_opaque == NULL))
goto error;
sys->updateOutputCb = LocalSwapchainUpdateOutput;
More information about the vlc-commits
mailing list