Certain components require ID3D11/ID3D12 textures to be created with
additional BindFlags or MiscFlags. FFmpeg currently provides no
mechanism to configure these flags externally, leaving no way to
satisfy such components without patching the library.

This patch adds private device options that can be passed through
  shader_resource=1        adds D3D11_BIND_SHADER_RESOURCE
  uav_resource=1           adds D3D11_BIND_UNORDERED_ACCESS
  render_target_resource=1 adds D3D11_BIND_RENDER_TARGET
  shared_resource=1        adds D3D11_RESOURCE_MISC_SHARED
---
 libavutil/hwcontext_d3d11va.c | 17 +++++++++++++++++
 libavutil/hwcontext_d3d11va.h |  5 +++++
 2 files changed, 22 insertions(+)

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 1a047ce57b..fba9597392 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -288,6 +288,9 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx)
         return AVERROR(EINVAL);
     }
 
+    hwctx->BindFlags |= device_hwctx->BindFlags;
+    hwctx->MiscFlags |= device_hwctx->MiscFlags;
+
     texDesc = (D3D11_TEXTURE2D_DESC){
         .Width      = ctx->width,
         .Height     = ctx->height,
@@ -705,6 +708,20 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, 
const char *device,
         }
     }
 #endif
+    device_hwctx->BindFlags = 0;
+    device_hwctx->MiscFlags = 0;
+
+    if (av_dict_get(opts, "shader_resouce", NULL, 0))
+        device_hwctx->BindFlags |= D3D11_BIND_SHADER_RESOURCE;
+
+    if (av_dict_get(opts, "uav_resource", NULL, 0))
+        device_hwctx->BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
+
+    if (av_dict_get(opts, "render_target_resource", NULL, 0))
+        device_hwctx->BindFlags |= D3D11_BIND_RENDER_TARGET;
+
+    if (av_dict_get(opts, "shared_resource", NULL, 0))
+        device_hwctx->MiscFlags |= D3D11_RESOURCE_MISC_SHARED;
 
     return 0;
 }
diff --git a/libavutil/hwcontext_d3d11va.h b/libavutil/hwcontext_d3d11va.h
index 77d2d72f1b..e4e1f1095d 100644
--- a/libavutil/hwcontext_d3d11va.h
+++ b/libavutil/hwcontext_d3d11va.h
@@ -94,6 +94,11 @@ typedef struct AVD3D11VADeviceContext {
     void (*lock)(void *lock_ctx);
     void (*unlock)(void *lock_ctx);
     void *lock_ctx;
+    /**
+     * Need to pass value to frames context from command line
+    */
+    UINT BindFlags;
+    UINT MiscFlags;
 } AVD3D11VADeviceContext;
 
 /**
-- 
2.47.1.windows.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to