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

Steve Lhomme robux4 at ycbcr.xyz
Fri Jan 18 16:32:19 CET 2019


Instead of our own swapchain.
---
 include/vlc/libvlc_media_player.h | 22 +++++++++++++++++++++-
 lib/media_player.c                |  7 +++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 0ef93062e9..697418e27e 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -457,6 +457,25 @@ void libvlc_video_set_callbacks( libvlc_media_player_t *mp,
  * - D3DTSS_ALPHAOP
  * - D3DTSS_ALPHAARG1
  * - D3DTSS_ALPHAARG2
+ *
+ * For \ref libvlc_video_engine_direct3d11 it must be a ID3D11DeviceContext*.
+ * A reference to this object is held until \the ref cleanup_cb is called.
+ * The ID3D11Device used to create ID3D11DeviceContext must have multithreading enabled.
+ *
+ * Between start_render_cb and end_render_cb of Direct3D11 the following
+ * operations are called on the ID3D11DeviceContext:
+ * - IASetPrimitiveTopology()
+ * - IASetInputLayout()
+ * - IASetVertexBuffers()
+ * - IASetIndexBuffer()
+ * - VSSetConstantBuffers()
+ * - VSSetShader()
+ * - PSSetSamplers()
+ * - PSSetConstantBuffers()
+ * - PSSetShaderResources()
+ * - PSSetShader()
+ * - RSSetViewports()
+ * - DrawIndexed()
  * \version LibVLC 4.0.0 or later
  */
 typedef void *(*libvlc_video_setup_cb)(void* opaque);
@@ -535,6 +554,7 @@ typedef enum libvlc_video_engine_t {
     libvlc_video_engine_opengl,
     libvlc_video_engine_gles2,
     libvlc_video_engine_direct3d9,
+    libvlc_video_engine_direct3d11,
 } libvlc_video_engine_t;
 
 /**
@@ -547,7 +567,7 @@ typedef enum libvlc_video_engine_t {
  *
  * \param mp the media player
  * \param engine the GPU engine to use
- * \param setup_cb callback called to initialize user data (cannot be NULL for \ref libvlc_video_engine_direct3d9)
+ * \param setup_cb callback called to initialize user data (cannot be NULL for \ref libvlc_video_engine_direct3d9 and \ref libvlc_video_engine_direct3d11)
  * \param cleanup_cb callback called to clean up user data
  * \param update_output_cb callback called to get the size of the video
  * \param swap_cb callback called after rendering a video frame (cannot be NULL)
diff --git a/lib/media_player.c b/lib/media_player.c
index 91ae05f0c1..73a4a8b782 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1189,6 +1189,13 @@ int libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
         var_SetString ( mp, "vout", "direct3d9" );
         var_SetString ( mp, "avcodec-hw", "dxva2");
     }
+    else if ( engine == libvlc_video_engine_direct3d11 )
+    {
+        if (setup_cb == NULL)
+            return 0;
+        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