summaryrefslogtreecommitdiffstats
path: root/libavutil/hwcontext_d3d12va.c
diff options
context:
space:
mode:
authorDmitrii Ovchinnikov <[email protected]>2025-07-23 14:10:06 +0200
committerjianhuaw <[email protected]>2025-09-08 15:44:47 +0000
commit1b97966199f797deee62cd3938feef93098005b2 (patch)
treeab6f2495959509b8a13c28779ac5cf9ee83636c7 /libavutil/hwcontext_d3d12va.c
parentfbbb2996d573844a2f4c901b704d8361a384766b (diff)
avutil/hwcontext_d3d12va: added resource and heap flags to DeviceContext
Diffstat (limited to 'libavutil/hwcontext_d3d12va.c')
-rw-r--r--libavutil/hwcontext_d3d12va.c20
1 files changed, 17 insertions, 3 deletions
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;
}