[vlc-devel] [PATCH 7/8] libvlc: add callbacks to render to an external D3D11 surface

Steve Lhomme robux4 at ycbcr.xyz
Mon Jan 21 17:38:50 CET 2019


Instead of our own swapchain.
---
 include/vlc/libvlc_media_player.h | 21 +++++++++++++++++++++
 lib/media_player.c                |  5 +++++
 2 files changed, 26 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index aa44f761e7..c35d2f53e7 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -467,6 +467,8 @@ typedef enum libvlc_video_engine_t {
     libvlc_video_engine_gles2,
     /** Direct3D9 rendering engine */
     libvlc_video_engine_direct3d9,
+    /** Direct3D11 rendering engine */
+    libvlc_video_engine_direct3d11,
 } libvlc_video_engine_t;
 
 typedef struct
@@ -487,6 +489,10 @@ typedef enum libvlc_video_callback_control_t {
      * For \ref libvlc_video_engine_direct3d9 the output must be a IDirect3DDevice9*.
      * A reference to this object is held until the \ref LIBVLC_VIDEO_CLEANUP is called.
      * the device must be created with D3DPRESENT_PARAMETERS.hDeviceWindow set to 0.
+     *
+     * For \ref libvlc_video_engine_direct3d11 the output must be a ID3D11DeviceContext*.
+     * A reference to this object is held until the \ref LIBVLC_VIDEO_CLEANUP is called.
+     * The ID3D11Device used to create ID3D11DeviceContext must have multithreading enabled.
      */
     LIBVLC_VIDEO_SETUP,
 
@@ -558,6 +564,21 @@ typedef enum libvlc_video_callback_control_t {
      * - D3DTSS_ALPHAOP
      * - D3DTSS_ALPHAARG1
      * - D3DTSS_ALPHAARG2
+     *
+     * Between \ref LIBVLC_VIDEO_START_RENDER and \ref LIBVLC_VIDEO_FINISHED_RENDERING
+     * of Direct3D11 the following may change on the provided ID3D11DeviceContext*:
+     * - IASetPrimitiveTopology()
+     * - IASetInputLayout()
+     * - IASetVertexBuffers()
+     * - IASetIndexBuffer()
+     * - VSSetConstantBuffers()
+     * - VSSetShader()
+     * - PSSetSamplers()
+     * - PSSetConstantBuffers()
+     * - PSSetShaderResources()
+     * - PSSetShader()
+     * - RSSetViewports()
+     * - DrawIndexed()
      */
     LIBVLC_VIDEO_START_RENDER,
 
diff --git a/lib/media_player.c b/lib/media_player.c
index 96f4cb7455..15eb7f3e12 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1173,6 +1173,11 @@ int libvlc_video_set_surface_callbacks( libvlc_media_player_t *mp,
         var_SetString ( mp, "vout", "direct3d9" );
         var_SetString ( mp, "avcodec-hw", "dxva2");
     }
+    else if ( engine == libvlc_video_engine_direct3d11 )
+    {
+        var_SetString ( mp, "vout", "direct3d11" );
+        var_SetString ( mp, "avcodec-hw", "d3d11va");
+    }
     else
 #endif
     if( engine == libvlc_video_engine_gles2 )
-- 
2.17.1



More information about the vlc-devel mailing list