The branch, master has been updated
       via  1b97966199f797deee62cd3938feef93098005b2 (commit)
      from  fbbb2996d573844a2f4c901b704d8361a384766b (commit)


- Log -----------------------------------------------------------------
commit 1b97966199f797deee62cd3938feef93098005b2
Author:     Dmitrii Ovchinnikov <[email protected]>
AuthorDate: Wed Jul 23 14:10:06 2025 +0200
Commit:     jianhuaw <[email protected]>
CommitDate: Mon Sep 8 15:44:47 2025 +0000

    avutil/hwcontext_d3d12va: added resource and heap flags to DeviceContext

diff --git a/doc/APIchanges b/doc/APIchanges
index 5b07848c0a..9d629f766f 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 - xxxxxxxx - lavf 62.5.100 - avformat.h
   Add AV_FRAME_FILENAME_FLAGS_IGNORE_TRUNCATION
 
diff --git a/libavutil/hwcontext_d3d12va.c b/libavutil/hwcontext_d3d12va.c
index 9368341d6d..f6e7bc88b1 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;
@@ -345,7 +345,7 @@ static int d3d12va_texture_array_init(AVHWFramesContext 
*ctx)
         .Flags            = hwctx->resource_flags,
     };
 
-    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 
**)&hwctx->texture_array))) {
         av_log(ctx, AV_LOG_ERROR, "Could not create the texture array\n");
         return AVERROR(EINVAL);
@@ -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++) {
@@ -367,12 +368,16 @@ static int d3d12va_frames_init(AVHWFramesContext *ctx)
             break;
         }
     }
+
     if (i == FF_ARRAY_ELEMS(supported_formats)) {
         av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n",
                av_get_pix_fmt_name(ctx->sw_format));
         return AVERROR(EINVAL);
     }
 
+    hwctx->resource_flags |= device_hwctx->resource_flags;
+    hwctx->heap_flags     |= device_hwctx->heap_flags;
+
     if (ctx->initial_pool_size > 0 && hwctx->flags & 
AV_D3D12VA_FRAME_FLAG_TEXTURE_ARRAY) {
         int err = d3d12va_texture_array_init(ctx);
         if (err < 0)
@@ -754,6 +759,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, \

-----------------------------------------------------------------------

Summary of changes:
 doc/APIchanges                |  4 ++++
 libavutil/hwcontext_d3d12va.c | 20 +++++++++++++++++---
 libavutil/hwcontext_d3d12va.h | 28 ++++++++++++++++++++++++++++
 libavutil/version.h           |  2 +-
 4 files changed, 50 insertions(+), 4 deletions(-)


hooks/post-receive
-- 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to