PR #24115 opened by Kacper Michajłow (kasper93) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24115 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24115.patch
# Summary of changes Briefly describe what this PR does and why. <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> From ee95e369e5fa869555906203638e0153d1a76b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Wed, 12 Aug 2026 17:59:08 +0200 Subject: [PATCH 1/2] avutil/hwcontext_d3d11va: add AVD3D11VAFramesContext.individual_textures Allow the API user to request a pool of separate 2D textures instead of a single array texture. Some format and BindFlags combinations are not valid for array textures (e.g. D3D11_BIND_RENDER_TARGET), and consumers differ in which allocation shape they require, so it cannot be inferred from the flags. Previously this was implicitly controlled by the render target restriction removed in efd484cb2dc3e3aa0eaf1855535186ccde3dc97c. --- doc/APIchanges | 3 +++ libavutil/hwcontext_d3d11va.c | 2 +- libavutil/hwcontext_d3d11va.h | 16 +++++++++++++--- libavutil/version.h | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 61e0d43735..1b5e824b6e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2026-06-23. API changes, most recent first: +2026-08-xx - xxxxxxxxxx - lavu 61.6.100 - hwcontext_d3d11va.h + Add AVD3D11VAFramesContext.individual_textures. + 2026-08-xx - xxxxxxxxxx - lavf 63.6.100 - avformat.h Add AVFMT_FLAG_LEGACY_ID3V2_COMM_KEYS. The deprecated export of id3v2 COMM descriptors as bare metadata tag names is now opt-in through this flag, diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 834c2ce3dd..c4520f9685 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -322,7 +322,7 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx) ctx->initial_pool_size = texDesc2.ArraySize; hwctx->BindFlags = texDesc2.BindFlags; hwctx->MiscFlags = texDesc2.MiscFlags; - } else if (texDesc.ArraySize > 0) { + } else if (texDesc.ArraySize > 0 && !hwctx->individual_textures) { hr = ID3D11Device_CreateTexture2D(device_hwctx->device, &texDesc, NULL, &hwctx->texture); if (FAILED(hr)) { av_log(ctx, AV_LOG_ERROR, "Could not create the texture (%lx)\n", (long)hr); diff --git a/libavutil/hwcontext_d3d11va.h b/libavutil/hwcontext_d3d11va.h index b87b1e8fa2..a3c04c83d4 100644 --- a/libavutil/hwcontext_d3d11va.h +++ b/libavutil/hwcontext_d3d11va.h @@ -24,8 +24,10 @@ * An API-specific header for AV_HWDEVICE_TYPE_D3D11VA. * * The default pool implementation will be fixed-size if initial_pool_size is - * set (and allocate elements from an array texture). Otherwise it will allocate - * individual textures. Be aware that decoding requires a single array texture. + * set (and allocate elements from an array texture, unless + * AVD3D11VAFramesContext.individual_textures is set). Otherwise it will + * allocate individual textures. Be aware that decoding requires a single + * array texture. * * Using sw_format==AV_PIX_FMT_YUV420P has special semantics, and maps to * DXGI_FORMAT_420_OPAQUE. av_hwframe_transfer_data() is not supported for @@ -146,7 +148,7 @@ typedef struct AVD3D11VAFramesContext { /** * The canonical texture used for pool allocation. If this is set to NULL * on init, the hwframes implementation will allocate and set an array - * texture if initial_pool_size > 0. + * texture if initial_pool_size > 0 (unless individual_textures is set). * * The only situation when the API user should set this is: * - the user wants to do manual pool allocation (setting @@ -187,6 +189,14 @@ typedef struct AVD3D11VAFramesContext { * This field is ignored/invalid if a user-allocated texture is provided. */ AVD3D11FrameDescriptor *texture_infos; + + /** + * If set to 1 before calling av_hwframe_ctx_init(), the pool will consist + * of initial_pool_size separate 2D textures instead of a single array + * texture. + * This field is ignored/invalid if a user-allocated texture is provided. + */ + int individual_textures; } AVD3D11VAFramesContext; #endif /* AVUTIL_HWCONTEXT_D3D11VA_H */ diff --git a/libavutil/version.h b/libavutil/version.h index d5bf20cf89..94b5e920b9 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 61 -#define LIBAVUTIL_VERSION_MINOR 5 +#define LIBAVUTIL_VERSION_MINOR 6 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.52.0 From f64833dccacc9f5eaac14ff39ccd8e8dcad2a12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Wed, 12 Aug 2026 17:59:29 +0200 Subject: [PATCH 2/2] avutil/hwcontext_qsv: allocate individual textures for render-target pools Array textures of video formats cannot be created with D3D11_BIND_RENDER_TARGET. Additionally, the MemId setup for render-target pools passes MFX_INFINITE as the subresource index, which is only correct for individual textures and wouldn't work if texture array were to be allocated. Fixes #23835. --- libavutil/hwcontext_qsv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 186576d182..932b10be15 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -594,6 +594,11 @@ static int qsv_init_child_ctx(AVHWFramesContext *ctx) if (hwctx->frame_type & MFX_MEMTYPE_SHARED_RESOURCE) child_frames_hwctx->MiscFlags = D3D11_RESOURCE_MISC_SHARED; child_frames_hwctx->BindFlags = qsv_get_d3d11va_bind_flags(hwctx->frame_type); + /* The MemId setup for render-target pools below assumes individual + * textures (MFX_INFINITE index). Additionally array textures of video + * formats cannot be created with D3D11_BIND_RENDER_TARGET. */ + if (child_frames_hwctx->BindFlags & D3D11_BIND_RENDER_TARGET) + child_frames_hwctx->individual_textures = 1; } #endif #if CONFIG_DXVA2 -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
