* [FFmpeg-devel] [PATCH] avutil/hwcontext_d3d12va: added resource and heap flags to DeviceContext (PR #20437)
@ 2025-09-04 14:44 jianhuaw via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: jianhuaw via ffmpeg-devel @ 2025-09-04 14:44 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: jianhuaw
PR #20437 opened by jianhuaw
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20437
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20437.patch
>From mailing list: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20250723121006.1047-1-ovchinnikov.dmitrii@gmail.com/
Added some changes for APIChange.
>From 9c7b425b4344209e43bc06b5bccf4c2e3533a493 Mon Sep 17 00:00:00 2001
From: Dmitrii Ovchinnikov <ovchinnikov.dmitrii@gmail.com>
Date: Wed, 23 Jul 2025 14:10:06 +0200
Subject: [PATCH] avutil/hwcontext_d3d12va: added resource and heap flags to
DeviceContext
---
doc/APIchanges | 4 ++++
libavutil/hwcontext_d3d12va.c | 17 +++++++++++++++--
libavutil/hwcontext_d3d12va.h | 28 ++++++++++++++++++++++++++++
libavutil/version.h | 2 +-
4 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index d69aaf2215..5f5e8df933 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first:
+2025-09-xx - xxxxxxxxxx - lavu 60.13.100 - hwcontext_d3d12va.h
+ Add resource_flags and heap_flags to AVD3D12VADeviceContext
+ Add heap_flags to AVD3D12VAFramesContext
+
2025-09-xx - xxxxxxxxxx - lavu 60.12.100 - hwcontext_d3d12va.h
Add support for texture array mode AVD3D12VAFrame.subresource_index,
AVD3D12VAFramesContext.texture_array
diff --git a/libavutil/hwcontext_d3d12va.c b/libavutil/hwcontext_d3d12va.c
index 9368341d6d..cde0a736c3 100644
--- a/libavutil/hwcontext_d3d12va.c
+++ b/libavutil/hwcontext_d3d12va.c
@@ -301,7 +301,7 @@ static AVBufferRef *d3d12va_pool_alloc(void *opaque, size_t size)
if (!frame)
return NULL;
- if (FAILED(ID3D12Device_CreateCommittedResource(device_hwctx->device, &props, D3D12_HEAP_FLAG_NONE, &desc,
+ if (FAILED(ID3D12Device_CreateCommittedResource(device_hwctx->device, &props, hwctx->heap_flags, &desc,
D3D12_RESOURCE_STATE_COMMON, NULL, &IID_ID3D12Resource, (void **)&frame->texture))) {
av_log(ctx, AV_LOG_ERROR, "Could not create the texture\n");
goto fail;
@@ -355,7 +355,8 @@ static int d3d12va_texture_array_init(AVHWFramesContext *ctx)
static int d3d12va_frames_init(AVHWFramesContext *ctx)
{
- AVD3D12VAFramesContext *hwctx = ctx->hwctx;
+ AVD3D12VAFramesContext *hwctx = ctx->hwctx;
+ AVD3D12VADeviceContext *device_hwctx = ctx->device_ctx->hwctx;
int i;
for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) {
@@ -379,6 +380,9 @@ static int d3d12va_frames_init(AVHWFramesContext *ctx)
return err;
}
+ hwctx->resource_flags |= device_hwctx->resource_flags;
+ hwctx->heap_flags |= device_hwctx->heap_flags;
+
ffhwframesctx(ctx)->pool_internal = av_buffer_pool_init2(sizeof(AVD3D12VAFrame),
ctx, d3d12va_pool_alloc, NULL);
@@ -754,6 +758,15 @@ static int d3d12va_device_create(AVHWDeviceContext *hwdev, const char *device,
}
}
+ if (av_dict_get(opts, "UAV", NULL, 0))
+ ctx->resource_flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
+
+ if (av_dict_get(opts, "RTV", NULL, 0))
+ ctx->resource_flags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
+
+ if (av_dict_get(opts, "SHARED", NULL, 0))
+ ctx->heap_flags |= D3D12_HEAP_FLAG_SHARED;
+
return 0;
}
diff --git a/libavutil/hwcontext_d3d12va.h b/libavutil/hwcontext_d3d12va.h
index 1530de8b3c..adbec88173 100644
--- a/libavutil/hwcontext_d3d12va.h
+++ b/libavutil/hwcontext_d3d12va.h
@@ -75,6 +75,26 @@ typedef struct AVD3D12VADeviceContext {
void (*lock)(void *lock_ctx);
void (*unlock)(void *lock_ctx);
void *lock_ctx;
+
+ /**
+ * Resource flags to be applied to D3D12 resources allocated
+ * for frames using this device context.
+ *
+ * If unset, this will be D3D12_RESOURCE_FLAG_NONE.
+ *
+ * It applies globally to all AVD3D12VAFramesContext allocated from this device context.
+ */
+ D3D12_RESOURCE_FLAGS resource_flags;
+
+ /**
+ * Heap flags to be applied to D3D12 resources allocated
+ * for frames using this device context.
+ *
+ * If unset, this will be D3D12_HEAP_FLAG_NONE.
+ *
+ * It applies globally to all AVD3D12VAFramesContext allocated from this device context.
+ */
+ D3D12_HEAP_FLAGS heap_flags;
} AVD3D12VADeviceContext;
/**
@@ -164,6 +184,14 @@ typedef struct AVD3D12VAFramesContext {
*/
D3D12_RESOURCE_FLAGS resource_flags;
+ /**
+ * Options for working with heaps allocation when creating resources.
+ * If unset, this will be D3D12_HEAP_FLAG_NONE.
+ *
+ * @see https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_heap_flags
+ */
+ D3D12_HEAP_FLAGS heap_flags;
+
/**
* In texture array mode, the D3D12 uses the same texture array (resource)for all
* pictures.
diff --git a/libavutil/version.h b/libavutil/version.h
index 99ca75bb16..1099715076 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 60
-#define LIBAVUTIL_VERSION_MINOR 12
+#define LIBAVUTIL_VERSION_MINOR 13
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-04 14:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-04 14:44 [FFmpeg-devel] [PATCH] avutil/hwcontext_d3d12va: added resource and heap flags to DeviceContext (PR #20437) jianhuaw via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git