1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00
Files
ffmpeg/libavfilter/dnn
Steven Xiao 07ab463f9f avfilter/dnn: implement D3D12 DirectML zero-copy for ONNX Runtime backend
This commit enables the DNN video filter to run entirely on the GPU
for the full D3D12 pipeline (decode, AI inference, and encode)
without ever copying frames back to system memory, making it
significantly faster on D3D12 hardware.

Benchmarked the new zero-copy D3D12/DirectML DNN pipeline against
the existing CPU round-trip pipeline on three major GPU vendors; up
to 10x throughput improvement was measured across every vendor.

Add dnn_onnx_d3d12, a helper that binds the DirectML execution
provider to a D3D12VA input frame's own device and does NV12
texture<->tensor conversion on the GPU (CopyTextureRegion + compute
shaders), avoiding a host round-trip.

dnn_processing negotiates this automatically for D3D12 NV12 input
with device=dml. Software-frame input retains the host I/O path.
D3D12 input requires successful DirectML negotiation; unsupported
hardware-input configurations fail during configuration. Currently
limited to single-channel FLOAT/NCHW models; chroma bypasses the
model and is copied/upscaled on the GPU. At runtime, DirectML.dll
and d3dcompiler_47.dll must be loadable from the application
directory or System32.

Example usage:

  # Zero-copy pipeline
  ffmpeg.exe -y -loglevel info \
    -hwaccel d3d12va -hwaccel_output_format d3d12 \
    -i input-1920x1080.mp4 \
    -vf "dnn_processing=dnn_backend=onnx:device=dml:model=ecbsrnet_y_fused.onnx:input=input:output=output" \
    -c:v h264_d3d12va -bf 0 -c:a copy \
    output_2x_sr_zero_copy.mp4

  # CPU round-trip pipeline
  ffmpeg.exe -y -loglevel info \
    -init_hw_device d3d12va=dev -filter_hw_device dev -hwaccel d3d12va \
    -i input-1920x1080.mp4 \
    -vf "dnn_processing=dnn_backend=onnx:device=dml:model=ecbsrnet_y_fused.onnx:input=input:output=output,hwupload" \
    -c:v h264_d3d12va -bf 0 -c:a copy \
    output_2x_sr_round_trip.mp4

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-10-19 21:08:42 +00:00
..