[FFmpeg-devel] [PATCH] avutil/hwcontext_d3d12va: wait the texture is used before to free it.

Renan Lavarec rlavarec at gopro.com
Mon Apr 8 18:27:20 EEST 2024


From: Renan Lavarec 124602499+rlavarec-gpsw at users.noreply.github.com<mailto:124602499+rlavarec-gpsw at users.noreply.github.com>
Date: Mon, 8 Apr 2024 14:38:10 +0200
Subject: [PATCH] avutil/hwcontext_d3d12va: wait the texture is used inside the
GPU before to free it.

fix: ID3D12Resource2::<final-release>: CORRUPTION: An ID3D12Resource object (0x00000222D58B5450:'Unnamed Object') is referenced by GPU operations in-flight on Command Queue (0x00000222EEC87090:'Unnamed ID3D12CommandQueue Object').
     It is not safe to final-release objects that may have GPU operations pending.  This can result in application instability. [ EXECUTION ERROR #921: OBJECT_DELETED_WHILE_STILL_IN_USE]
---
libavutil/hwcontext_d3d12va.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/libavutil/hwcontext_d3d12va.c b/libavutil/hwcontext_d3d12va.c
index cfc016315d..621a79d257 100644
--- a/libavutil/hwcontext_d3d12va.c
+++ b/libavutil/hwcontext_d3d12va.c
@@ -220,6 +220,9 @@ static void free_texture(void *opaque, uint8_t *data)
{
     AVD3D12VAFrame *frame = (AVD3D12VAFrame *)data;

+    // Wait texture to be available
+    d3d12va_fence_completion(&frame->sync_ctx);
+
     D3D12_OBJECT_RELEASE(frame->texture);
     D3D12_OBJECT_RELEASE(frame->sync_ctx.fence);
     if (frame->sync_ctx.event)
--
2.44.0.windows.1


More information about the ffmpeg-devel mailing list