avutil/hwcontext_vulkan: declare cuda as a transfer-compatible format

The cuda hwcontext has listed AV_PIX_FMT_VULKAN among its supported
formats since Vulkan interop was first added, so a device's frame
constraints advertise Vulkan as a transfer-compatible ("sw") format.
This is what allows an hwupload targeting a cuda device to accept a
Vulkan frame as input during format negotiation.

The Vulkan hwcontext never made the reciprocal declaration, so an
hwupload targeting a Vulkan device would not accept a cuda frame, and a
cuda -> Vulkan upload could not be configured even though the transfer
itself is supported. Advertise AV_PIX_FMT_CUDA in the Vulkan frame
constraints to ensure we have consistent behaviour in both directions.
This commit is contained in:
Philip Langdale
2026-07-08 16:56:34 -07:00
committed by philipl
parent 0baa71b53c
commit d09d5afc3a

View File

@@ -2215,7 +2215,7 @@ static int vulkan_frames_get_constraints(AVHWDeviceContext *ctx,
NULL, NULL, NULL, NULL, p->disable_multiplane, 1) >= 0;
}
constraints->valid_sw_formats = av_malloc_array(count + 1,
constraints->valid_sw_formats = av_malloc_array(count + 1 + CONFIG_CUDA,
sizeof(enum AVPixelFormat));
if (!constraints->valid_sw_formats)
return AVERROR(ENOMEM);
@@ -2230,6 +2230,10 @@ static int vulkan_frames_get_constraints(AVHWDeviceContext *ctx,
}
}
#if CONFIG_CUDA
constraints->valid_sw_formats[count++] = AV_PIX_FMT_CUDA;
#endif
constraints->valid_sw_formats[count++] = AV_PIX_FMT_NONE;
constraints->min_width = 1;