diff --git a/doc/libvlc/d3d11_player.cpp b/doc/libvlc/d3d11_player.cpp index 4cfdce4d51bad00441f75295f1316076697dc26e..7989846bfddc6ba793472b71c4c0a85c286252dd 100644 --- a/doc/libvlc/d3d11_player.cpp +++ b/doc/libvlc/d3d11_player.cpp @@ -463,11 +463,14 @@ static bool StartRendering_cb( void *opaque, bool enter ) return true; } -static bool SelectPlane_cb( void *opaque, size_t plane ) +static bool SelectPlane_cb( void *opaque, size_t plane, void *out ) { + ID3D11RenderTargetView **output = static_cast<ID3D11RenderTargetView**>( out ); struct render_context *ctx = static_cast<struct render_context *>( opaque ); if ( plane != 0 ) // we only support one packed RGBA plane (DXGI_FORMAT_R8G8B8A8_UNORM) return false; + // we don't really need to return it as we already do the OMSetRenderTargets(). + *output = ctx->resized.textureRenderTarget; return true; } diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h index 1af9996709d32742410492e1432718ffd4a8ea09..aaf1e90ffcbc4eb917e775ece0ce15482cb816b6 100644 --- a/include/vlc/libvlc_media_player.h +++ b/include/vlc/libvlc_media_player.h @@ -710,14 +710,17 @@ typedef void( *libvlc_video_output_set_resize_cb )( void *opaque, * * \param opaque private pointer set on the opaque parameter of @a libvlc_video_output_setup_cb() [IN] * \param plane number of the rendering plane to select + * \param output handle of the rendering output for the given plane * \return true on success * \version LibVLC 4.0.0 or later * * \note This is only used with \ref libvlc_video_engine_d3d11. * - * The host should call OMSetRenderTargets for Direct3D11. If this callback is - * not used (set to NULL in @a libvlc_video_set_output_callbacks()) OMSetRenderTargets - * has to be set during the @a libvlc_video_makeCurrent_cb() + * The output parameter receives the ID3D11RenderTargetView* to use for rendering + * the plane. + * + * If this callback is not used (set to NULL in @a libvlc_video_set_output_callbacks()) + * OMSetRenderTargets has to be set during the @a libvlc_video_makeCurrent_cb() * entering call. * * The number of planes depend on the DXGI_FORMAT returned during the @@ -727,7 +730,7 @@ typedef void( *libvlc_video_output_set_resize_cb )( void *opaque, * This callback is called between libvlc_video_makeCurrent_cb current/not-current * calls. */ -typedef bool( *libvlc_video_output_select_plane_cb )( void *opaque, size_t plane ); +typedef bool( *libvlc_video_output_select_plane_cb )( void *opaque, size_t plane, void *output ); /** * Set callbacks and data to render decoded video to a custom texture diff --git a/modules/video_output/win32/d3d11_quad.c b/modules/video_output/win32/d3d11_quad.c index b8948b16daa50815196455c18a30e4941a388289..aba095467c14de282412017bc7254fa2be2e5a3d 100644 --- a/modules/video_output/win32/d3d11_quad.c +++ b/modules/video_output/win32/d3d11_quad.c @@ -70,9 +70,13 @@ void D3D11_RenderQuad(d3d11_device_t *d3d_dev, d3d11_quad_t *quad, d3d11_vertex_ if (!quad->d3dpixelShader[i]) break; - if (unlikely(!selectPlane(selectOpaque, i))) + ID3D11RenderTargetView *renderView = NULL; + if (unlikely(!selectPlane(selectOpaque, i, &renderView))) continue; + if (renderView != NULL) + ID3D11DeviceContext_OMSetRenderTargets(d3d_dev->d3dcontext, 1, &renderView, NULL); + ID3D11DeviceContext_PSSetShader(d3d_dev->d3dcontext, quad->d3dpixelShader[i], NULL, 0); ID3D11DeviceContext_RSSetViewports(d3d_dev->d3dcontext, 1, &quad->cropViewport[i]); diff --git a/modules/video_output/win32/d3d11_quad.h b/modules/video_output/win32/d3d11_quad.h index 01ffca82fd991b9aa6c5c0cd6cd13a5b01282592..07c3a0c9d9aaf659657b6dca28f2ab8b3faf62b7 100644 --- a/modules/video_output/win32/d3d11_quad.h +++ b/modules/video_output/win32/d3d11_quad.h @@ -29,7 +29,7 @@ #define PS_CONST_LUMI_BOUNDS 0 #define VS_CONST_VIEWPOINT 1 -typedef bool (*d3d11_select_plane_t)(void *opaque, size_t plane_index); +typedef bool (*d3d11_select_plane_t)(void *opaque, size_t plane_index, ID3D11RenderTargetView **); void D3D11_RenderQuad(d3d11_device_t *, d3d11_quad_t *, d3d11_vertex_shader_t *, ID3D11ShaderResourceView *resourceViews[DXGI_MAX_SHADER_VIEW], diff --git a/modules/video_output/win32/d3d11_swapchain.c b/modules/video_output/win32/d3d11_swapchain.c index 4b67ec4655d6e237c7b39dc23f81edcb234bdbcf..f48fc0a4670d643d6c9751181c05c7cf62e24618 100644 --- a/modules/video_output/win32/d3d11_swapchain.c +++ b/modules/video_output/win32/d3d11_swapchain.c @@ -236,13 +236,13 @@ bool D3D11_LocalSwapchainStartEndRendering( void *opaque, bool enter ) return true; } -bool D3D11_LocalSwapchainSelectPlane( void *opaque, size_t plane ) +bool D3D11_LocalSwapchainSelectPlane( void *opaque, size_t plane, void *out ) { struct d3d11_local_swapchain *display = opaque; if (!display->swapchainTargetView[plane]) return false; - ID3D11DeviceContext_OMSetRenderTargets(display->d3d_dev->d3dcontext, 1, - &display->swapchainTargetView[plane], NULL); + ID3D11RenderTargetView **output = out; + *output = display->swapchainTargetView[plane]; return true; } diff --git a/modules/video_output/win32/d3d11_swapchain.h b/modules/video_output/win32/d3d11_swapchain.h index f5dd4c4cf47baeed9872ab82db979b025d319db8..3d373713405b8e2c8b5ec68337802386324792b0 100644 --- a/modules/video_output/win32/d3d11_swapchain.h +++ b/modules/video_output/win32/d3d11_swapchain.h @@ -36,7 +36,7 @@ void *D3D11_CreateLocalSwapchainHandleDComp(vlc_object_t *, void* dcompDevice, v void D3D11_LocalSwapchainCleanupDevice( void *opaque ); bool D3D11_LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_render_cfg_t *cfg, libvlc_video_output_cfg_t *out ); bool D3D11_LocalSwapchainStartEndRendering( void *opaque, bool enter ); -bool D3D11_LocalSwapchainSelectPlane( void *opaque, size_t plane ); +bool D3D11_LocalSwapchainSelectPlane( void *opaque, size_t plane, void *output ); bool D3D11_LocalSwapchainWinstoreSize( void *opaque, uint32_t *, uint32_t * ); void D3D11_LocalSwapchainSwap( void *opaque ); void D3D11_LocalSwapchainSetMetadata( void *opaque, libvlc_video_metadata_type_t, const void * ); diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c index 22e4b2a155ec63a42e7876505afa4c741dc15a80..db921eb7321f3a1ebc7f8999756048231499e83d 100644 --- a/modules/video_output/win32/direct3d11.c +++ b/modules/video_output/win32/direct3d11.c @@ -471,12 +471,15 @@ static int Control(vout_display_t *vd, int query) return res; } -static bool SelectRenderPlane(void *opaque, size_t plane) +static bool SelectRenderPlane(void *opaque, size_t plane, ID3D11RenderTargetView **targetView) { vout_display_sys_t *sys = opaque; if (!sys->selectPlaneCb) + { + *targetView = NULL; return plane == 0; // we only support one packed RGBA plane by default - return sys->selectPlaneCb(sys->outside_opaque, plane); + } + return sys->selectPlaneCb(sys->outside_opaque, plane, (void*)targetView); } static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture,