[FFmpeg-devel] [PATCH] avutil/hwcontext_d3d11va: enable D3D11_RESOURCE_MISC_SHARED for texture

Tong Wu tong1.wu at intel.com
Wed Apr 20 07:10:29 EEST 2022


Add D3D11_RESOURCE_MISC_SHARED flag for texture to make it shareable.
This can fix the green frames issue when mapping from d3d11va to opencl.
Sample command line: ffmpeg.exe -hwaccel d3d11va -hwaccel_output_format
d3d11 -i input.264 -vf
"hwmap=derive_device=opencl,format=opencl,hwdownload,format=nv12" -c:v
libx264 output.mp4

Signed-off-by: Tong Wu <tong1.wu at intel.com>
---
 libavutil/hwcontext_d3d11va.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 8ab96bad25..c7227a13b4 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -199,7 +199,7 @@ static AVBufferRef *d3d11va_alloc_single(AVHWFramesContext *ctx)
         .ArraySize  = 1,
         .Usage      = D3D11_USAGE_DEFAULT,
         .BindFlags  = hwctx->BindFlags,
-        .MiscFlags  = hwctx->MiscFlags,
+        .MiscFlags  = hwctx->MiscFlags | D3D11_RESOURCE_MISC_SHARED,
     };
 
     hr = ID3D11Device_CreateTexture2D(device_hwctx->device, &texDesc, NULL, &tex);
@@ -263,7 +263,7 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx)
         .ArraySize  = ctx->initial_pool_size,
         .Usage      = D3D11_USAGE_DEFAULT,
         .BindFlags  = hwctx->BindFlags,
-        .MiscFlags  = hwctx->MiscFlags,
+        .MiscFlags  = hwctx->MiscFlags | D3D11_RESOURCE_MISC_SHARED,
     };
 
     if (hwctx->texture) {
-- 
2.35.3.windows.1



More information about the ffmpeg-devel mailing list