[FFmpeg-devel] [PATCH] avutil/hwcontext_d3d12va: added resource and heap flags to DeviceContext (PR #20437)

2025-09-04 Thread jianhuaw via ffmpeg-devel
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.dmit...@gmail.com/

Added some changes for APIChange.


>From 9c7b425b4344209e43bc06b5bccf4c2e3533a493 Mon Sep 17 00:00:00 2001
From: Dmitrii Ovchinnikov 
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 - xx - lavu 60.13.100 - hwcontext_d3d12va.h
+  Add resource_flags and heap_flags to AVD3D12VADeviceContext
+  Add heap_flags to AVD3D12VAFramesContext
+
 2025-09-xx - xx - 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/libavut

[FFmpeg-devel] [PATCH] avutil/version: bump minor after recent change (PR #20418)

2025-09-03 Thread jianhuaw via ffmpeg-devel
PR #20418 opened by jianhuaw
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20418
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20418.patch

Signed-off-by: Wu Jianhua 


>From 6bbf94f0913d23f40822bd5a0db777c23b8fdb32 Mon Sep 17 00:00:00 2001
From: Wu Jianhua 
Date: Thu, 4 Sep 2025 01:03:12 +0800
Subject: [PATCH] avutil/version: bump minor after recent change

See c2ce387385996c4e6824116931930b08cfcaecc9

Signed-off-by: Wu Jianhua 
---
 libavutil/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/version.h b/libavutil/version.h
index a1707d3f4e..99ca75bb16 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  60
-#define LIBAVUTIL_VERSION_MINOR  11
+#define LIBAVUTIL_VERSION_MINOR  12
 #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-le...@ffmpeg.org