PR #25453 opened by JuliusBairaktaris URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25453 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25453.patch
d3d11va_device_create() passes no feature levels, so D3D11CreateDevice() creates a feature level 11_0 device even on hardware with 11_1. Components that need 11_1, such as the DX11 engine of frc_amf, then fail on FFmpeg's own devices. The review of #25150 asked for this change to be separate. - `avutil/hwcontext_d3d11va: request feature level 11_1`: requests 11_1 first and falls back to the previous list if the runtime does not know 11_1 (E_INVALIDARG). d3d11va decoding of 2160p H.264 gives the same framemd5 as before. `frc_amf=engine_type=dx11` on `-init_hw_device d3d11va` now initializes; Init() failed with AMF_DIRECTX_FAILED before. With #25150, frc_amf picks the DX11 engine there by default: 600 output frames of 1080p H.264 take 0.33 s instead of 0.48 s with the DX12 engine (median of 3). Tested on Windows 11, RX 9070 XT, driver 32.0.32015.7029. Written with Claude Opus 5.5 in Claude Code; `Assisted-by` trailer on the commit. >From 0296bcd8454383cb1286a3bb0e59d145af3e052a Mon Sep 17 00:00:00 2001 From: Julius Bairaktaris <[email protected]> Date: Sat, 17 Oct 2026 13:09:38 +0200 Subject: [PATCH] avutil/hwcontext_d3d11va: request feature level 11_1 d3d11va_device_create() passes no feature levels, so D3D11CreateDevice() creates at most a feature level 11_0 device, even on hardware that supports 11_1. Components that need 11_1, such as the AMF FRC DX11 engine, then fail on FFmpeg's own devices. Request 11_1 first, and fall back to the default list when the runtime does not know 11_1 and returns E_INVALIDARG. Tested on Windows 11, RX 9070 XT, driver 32.0.32015.7029: the device is created at feature level 11_1, d3d11va decoding gives the same framemd5 as before, and frc_amf=engine_type=dx11 on such a device now initializes instead of failing Init() with AMF_DIRECTX_FAILED. Assisted-by: Claude Opus 5.5 Signed-off-by: Julius Bairaktaris <[email protected]> --- libavutil/hwcontext_d3d11va.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index be0523b05b2..748e71317ea 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -51,6 +51,12 @@ static AVOnce functions_loaded = AV_ONCE_INIT; static PFN_CREATE_DXGI_FACTORY mCreateDXGIFactory; static PFN_D3D11_CREATE_DEVICE mD3D11CreateDevice; +static const D3D_FEATURE_LEVEL feature_levels[] = { + D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2, + D3D_FEATURE_LEVEL_9_1, +}; + static av_cold void load_functions(void) { #if !HAVE_UWP @@ -678,8 +684,13 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, } } - hr = mD3D11CreateDevice(pAdapter, pAdapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, NULL, creationFlags, NULL, 0, - D3D11_SDK_VERSION, &device_hwctx->device, NULL, NULL); + hr = mD3D11CreateDevice(pAdapter, pAdapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, NULL, creationFlags, + feature_levels, FF_ARRAY_ELEMS(feature_levels), + D3D11_SDK_VERSION, &device_hwctx->device, NULL, NULL); + if (hr == E_INVALIDARG) + hr = mD3D11CreateDevice(pAdapter, pAdapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, NULL, creationFlags, + feature_levels + 1, FF_ARRAY_ELEMS(feature_levels) - 1, + D3D11_SDK_VERSION, &device_hwctx->device, NULL, NULL); if (pAdapter) IDXGIAdapter_Release(pAdapter); if (FAILED(hr)) { -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
