PR #24551 opened by dongnguyenminhanh URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24551 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24551.patch
Wait for previous GPU execution to complete before resetting the command allocator. Without this, the allocator may be reset while the GPU is still executing commands from the previous frame, causing a D3D12 validation error and device removal. Fixes #24483. # Summary of changes Briefly describe what this PR does and why. <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> >From d8091eeb3fec4874aa97345bb6a615b66ca5f18a Mon Sep 17 00:00:00 2001 From: Dong Nguyen <[email protected]> Date: Thu, 17 Sep 2026 10:35:44 -0400 Subject: [PATCH] avfilter/vf_scale_d3d12: fix command allocator sync before reset Wait for previous GPU execution to complete before resetting the command allocator. Without this, the allocator may be reset while the GPU is still executing commands from the previous frame, causing a D3D12 validation error and device removal. --- libavfilter/vf_scale_d3d12.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libavfilter/vf_scale_d3d12.c b/libavfilter/vf_scale_d3d12.c index 03fa92f872..26b6c784b7 100644 --- a/libavfilter/vf_scale_d3d12.c +++ b/libavfilter/vf_scale_d3d12.c @@ -478,6 +478,19 @@ static int scale_d3d12_filter_frame(AVFilterLink *inlink, AVFrame *in) } } + /* Wait for our own previous GPU execution to complete before resetting + * the command allocator, otherwise the allocator may be reset while + * the GPU is still executing commands from the previous frame. */ + if (s->fence_value > 1) { + UINT64 prev_fence = s->fence_value - 1; + UINT64 completed = ID3D12Fence_GetCompletedValue(s->fence); + if (completed < prev_fence) { + hr = ID3D12Fence_SetEventOnCompletion(s->fence, prev_fence, s->fence_event); + if (SUCCEEDED(hr)) + WaitForSingleObject(s->fence_event, INFINITE); + } + } + hr = ID3D12CommandAllocator_Reset(s->command_allocator); if (FAILED(hr)) { av_log(ctx, AV_LOG_ERROR, "Failed to reset command allocator: HRESULT 0x%lX\n", hr); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
