[vlc-devel] [PATCH 7/9] direct3d11: handle external callbacks to render into an external surface
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jan 18 14:59:03 CET 2019
Instead of a swapchain we create.
---
modules/video_output/win32/direct3d11.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 2dc41eabfc..90d3fbde0c 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -384,10 +384,10 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
if (ret != VLC_SUCCESS)
return ret;
- ID3D11DeviceContext *d3d11_ctx = NULL;
+ ID3D11DeviceContext *d3d11_ctx = var_InheritAddress(vd, "vout-engine-ctx");
#if VLC_WINSTORE_APP
if (d3d11_ctx == NULL)
- d3d11_ctx = var_InheritInteger(vd, "winrt-d3dcontext");
+ d3d11_ctx = var_InheritInteger(vd, "winrt-d3dcontext"); /* LEGACY */
#endif
if (CommonInit(vd, d3d11_ctx != NULL, cfg))
goto error;
@@ -398,6 +398,12 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
sys->sys.pf_GetPictureWidth = GetPictureWidth;
sys->sys.pf_GetPictureHeight = GetPictureHeight;
+ sys->outside_opaque = var_InheritAddress(vd, "vout-cb-opaque");
+ sys->swapCb = var_InheritAddress(vd, "vout-cb-swap");
+ sys->starRenderCb = var_InheritAddress(vd, "vout-cb-start-render");
+ sys->endRenderCb = var_InheritAddress(vd, "vout-cb-end-render");
+ sys->resizeCb = var_InheritAddress(vd, "vout-cb-update-output");
+
if (!sys->swapCb || !sys->starRenderCb || !sys->endRenderCb || !sys->resizeCb)
{
sys->outside_opaque = vd;
@@ -890,7 +896,7 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
{
D3D11_UpdateQuadLuminanceScale(vd, &sys->d3d_dev, &sys->picQuad, GetFormatLuminance(VLC_OBJECT(vd), &picture->format) / (float)sys->display.luminance_peak);
- if (sys->dxgiswapChain4)
+ if (sys->dxgiswapChain4) /* TODO pass the HDR metadata through a callback in windowless mode */
{
DXGI_HDR_METADATA_HDR10 hdr10 = {0};
hdr10.GreenPrimary[0] = picture->format.mastering.primaries[0];
@@ -1193,10 +1199,10 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp)
DXGI_SWAP_CHAIN_DESC1 scd;
DXGI_FORMAT windowlessFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
- ID3D11DeviceContext *d3d11_ctx = NULL;
+ ID3D11DeviceContext *d3d11_ctx = var_InheritAddress(vd, "vout-engine-ctx");
#if VLC_WINSTORE_APP
if (d3d11_ctx == NULL)
- d3d11_ctx = var_InheritInteger(vd, "winrt-d3dcontext");
+ d3d11_ctx = var_InheritInteger(vd, "winrt-d3dcontext"); /* LEGACY */
if (d3d11_ctx == NULL)
return VLC_EGENERIC;
#endif /* VLC_WINSTORE_APP */
@@ -1234,6 +1240,7 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp)
#endif /* VLC_WINSTORE_APP */
if (sys->sys.b_windowless)
{
+ /* TODO query the output format using callbacks */
for (const d3d_format_t *output_format = GetRenderFormatList();
output_format->name != NULL; ++output_format)
{
@@ -1298,10 +1305,16 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp)
msg_Err(vd, "Could not create the SwapChain. (hr=0x%lX)", hr);
return VLC_EGENERIC;
}
+ }
+#endif /* !VLC_WINSTORE_APP */
+ if (sys->dxgiswapChain)
+ {
+ /* we still handle a swapchain in the legacy winrt mode even though
+ * we don't have a window
+ */
IDXGISwapChain_QueryInterface( sys->dxgiswapChain, &IID_IDXGISwapChain4, (void **)&sys->dxgiswapChain4);
}
-#endif /* !VLC_WINSTORE_APP */
D3D11SetColorSpace(vd);
--
2.17.1
More information about the vlc-devel
mailing list