Expand AMD VA-API Vulkan filtering support to Polaris/gfx8

ROCm OpenCL runtime is not needed anymore when using HDR tone-mapping on Polaris/gfx8.

This change requires jellyfin-ffmpeg5 5.1.3-4 or jellyfin-ffmpeg6 6.0-5
or newer versions.

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
pull/10074/head
nyanmisaka 1 year ago
parent e5dcaa6ed5
commit 5b71cd8af9

@ -37,7 +37,7 @@ namespace MediaBrowser.Controller.MediaEncoding
private readonly IMediaEncoder _mediaEncoder; private readonly IMediaEncoder _mediaEncoder;
private readonly ISubtitleEncoder _subtitleEncoder; private readonly ISubtitleEncoder _subtitleEncoder;
private readonly IConfiguration _config; private readonly IConfiguration _config;
private readonly Version _minKernelVersionAmdVkFmtModifier = new Version(5, 15);
// i915 hang was fixed by linux 6.2 (3f882f2) // i915 hang was fixed by linux 6.2 (3f882f2)
private readonly Version _minKerneli915Hang = new Version(5, 18); private readonly Version _minKerneli915Hang = new Version(5, 18);
private readonly Version _maxKerneli915Hang = new Version(6, 1, 3); private readonly Version _maxKerneli915Hang = new Version(6, 1, 3);
@ -892,8 +892,7 @@ namespace MediaBrowser.Controller.MediaEncoding
else if (_mediaEncoder.IsVaapiDeviceAmd) else if (_mediaEncoder.IsVaapiDeviceAmd)
{ {
if (IsVulkanFullSupported() if (IsVulkanFullSupported()
&& _mediaEncoder.IsVaapiDeviceSupportVulkanFmtModifier && _mediaEncoder.IsVaapiDeviceSupportVulkanDrmInterop)
&& Environment.OSVersion.Version >= _minKernelVersionAmdVkFmtModifier)
{ {
args.Append(GetDrmDeviceArgs(options.VaapiDevice, DrmAlias)); args.Append(GetDrmDeviceArgs(options.VaapiDevice, DrmAlias));
args.Append(GetVaapiDeviceArgs(null, null, null, DrmAlias, VaapiAlias)); args.Append(GetVaapiDeviceArgs(null, null, null, DrmAlias, VaapiAlias));
@ -4205,14 +4204,13 @@ namespace MediaBrowser.Controller.MediaEncoding
// prefered vaapi + vulkan filters pipeline // prefered vaapi + vulkan filters pipeline
if (_mediaEncoder.IsVaapiDeviceAmd if (_mediaEncoder.IsVaapiDeviceAmd
&& isVaapiVkSupported && isVaapiVkSupported
&& _mediaEncoder.IsVaapiDeviceSupportVulkanFmtModifier && _mediaEncoder.IsVaapiDeviceSupportVulkanDrmInterop)
&& Environment.OSVersion.Version >= _minKernelVersionAmdVkFmtModifier)
{ {
// AMD radeonsi path(Vega/gfx9+, kernel>=5.15), with extra vulkan tonemap and overlay support. // AMD radeonsi path(targeting Polaris/gfx8+), with extra vulkan tonemap and overlay support.
return GetAmdVaapiFullVidFiltersPrefered(state, options, vidDecoder, vidEncoder); return GetAmdVaapiFullVidFiltersPrefered(state, options, vidDecoder, vidEncoder);
} }
// Intel i965 and Amd radeonsi/r600 path(Polaris/gfx8-), only featuring scale and deinterlace support. // Intel i965 and Amd legacy driver path, only featuring scale and deinterlace support.
return GetVaapiLimitedVidFiltersPrefered(state, options, vidDecoder, vidEncoder); return GetVaapiLimitedVidFiltersPrefered(state, options, vidDecoder, vidEncoder);
} }
@ -4484,7 +4482,7 @@ namespace MediaBrowser.Controller.MediaEncoding
// INPUT vaapi surface(vram) // INPUT vaapi surface(vram)
if (doVkTonemap || hasSubs) if (doVkTonemap || hasSubs)
{ {
// map from vaapi to vulkan/drm via interop (Vega/gfx9+). // map from vaapi to vulkan/drm via interop (Polaris/gfx8+).
mainFilters.Add("hwmap=derive_device=vulkan"); mainFilters.Add("hwmap=derive_device=vulkan");
mainFilters.Add("format=vulkan"); mainFilters.Add("format=vulkan");
} }
@ -4513,9 +4511,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (doVkTonemap && !hasSubs) if (doVkTonemap && !hasSubs)
{ {
// OUTPUT vaapi(nv12) surface(vram) // OUTPUT vaapi(nv12) surface(vram)
// map from vulkan/drm to vaapi via interop (Vega/gfx9+). // map from vulkan/drm to vaapi via interop (Polaris/gfx8+).
mainFilters.Add("hwmap=derive_device=drm");
mainFilters.Add("format=drm_prime");
mainFilters.Add("hwmap=derive_device=vaapi"); mainFilters.Add("hwmap=derive_device=vaapi");
mainFilters.Add("format=vaapi"); mainFilters.Add("format=vaapi");
@ -4581,9 +4577,7 @@ namespace MediaBrowser.Controller.MediaEncoding
else if (isVaapiEncoder) else if (isVaapiEncoder)
{ {
// OUTPUT vaapi(nv12) surface(vram) // OUTPUT vaapi(nv12) surface(vram)
// map from vulkan/drm to vaapi via interop (Vega/gfx9+). // map from vulkan/drm to vaapi via interop (Polaris/gfx8+).
overlayFilters.Add("hwmap=derive_device=drm");
overlayFilters.Add("format=drm_prime");
overlayFilters.Add("hwmap=derive_device=vaapi"); overlayFilters.Add("hwmap=derive_device=vaapi");
overlayFilters.Add("format=vaapi"); overlayFilters.Add("format=vaapi");

@ -64,8 +64,8 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <summary> /// <summary>
/// Gets a value indicating whether the configured Vaapi device supports vulkan drm format modifier. /// Gets a value indicating whether the configured Vaapi device supports vulkan drm format modifier.
/// </summary> /// </summary>
/// <value><c>true</c> if the Vaapi device supports vulkan drm format modifier, <c>false</c> otherwise.</value> /// <value><c>true</c> if the Vaapi device supports vulkan drm interop, <c>false</c> otherwise.</value>
bool IsVaapiDeviceSupportVulkanFmtModifier { get; } bool IsVaapiDeviceSupportVulkanDrmInterop { get; }
/// <summary> /// <summary>
/// Whether given encoder codec is supported. /// Whether given encoder codec is supported.

@ -76,12 +76,10 @@ namespace MediaBrowser.MediaEncoding.Encoder
private bool _isVaapiDeviceAmd = false; private bool _isVaapiDeviceAmd = false;
private bool _isVaapiDeviceInteliHD = false; private bool _isVaapiDeviceInteliHD = false;
private bool _isVaapiDeviceInteli965 = false; private bool _isVaapiDeviceInteli965 = false;
private bool _isVaapiDeviceSupportVulkanFmtModifier = false; private bool _isVaapiDeviceSupportVulkanDrmInterop = false;
private static string[] _vulkanFmtModifierExts = private static string[] _vulkanExternalMemoryDmaBufExts =
{ {
"VK_KHR_sampler_ycbcr_conversion",
"VK_EXT_image_drm_format_modifier",
"VK_KHR_external_memory_fd", "VK_KHR_external_memory_fd",
"VK_EXT_external_memory_dma_buf", "VK_EXT_external_memory_dma_buf",
"VK_KHR_external_semaphore_fd", "VK_KHR_external_semaphore_fd",
@ -140,7 +138,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
public bool IsVaapiDeviceInteli965 => _isVaapiDeviceInteli965; public bool IsVaapiDeviceInteli965 => _isVaapiDeviceInteli965;
/// <inheritdoc /> /// <inheritdoc />
public bool IsVaapiDeviceSupportVulkanFmtModifier => _isVaapiDeviceSupportVulkanFmtModifier; public bool IsVaapiDeviceSupportVulkanDrmInterop => _isVaapiDeviceSupportVulkanDrmInterop;
[GeneratedRegex(@"[^\/\\]+?(\.[^\/\\\n.]+)?$")] [GeneratedRegex(@"[^\/\\]+?(\.[^\/\\\n.]+)?$")]
private static partial Regex FfprobePathRegex(); private static partial Regex FfprobePathRegex();
@ -204,7 +202,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
_isVaapiDeviceAmd = validator.CheckVaapiDeviceByDriverName("Mesa Gallium driver", options.VaapiDevice); _isVaapiDeviceAmd = validator.CheckVaapiDeviceByDriverName("Mesa Gallium driver", options.VaapiDevice);
_isVaapiDeviceInteliHD = validator.CheckVaapiDeviceByDriverName("Intel iHD driver", options.VaapiDevice); _isVaapiDeviceInteliHD = validator.CheckVaapiDeviceByDriverName("Intel iHD driver", options.VaapiDevice);
_isVaapiDeviceInteli965 = validator.CheckVaapiDeviceByDriverName("Intel i965 driver", options.VaapiDevice); _isVaapiDeviceInteli965 = validator.CheckVaapiDeviceByDriverName("Intel i965 driver", options.VaapiDevice);
_isVaapiDeviceSupportVulkanFmtModifier = validator.CheckVulkanDrmDeviceByExtensionName(options.VaapiDevice, _vulkanFmtModifierExts); _isVaapiDeviceSupportVulkanDrmInterop = validator.CheckVulkanDrmDeviceByExtensionName(options.VaapiDevice, _vulkanExternalMemoryDmaBufExts);
if (_isVaapiDeviceAmd) if (_isVaapiDeviceAmd)
{ {
@ -219,9 +217,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
_logger.LogInformation("VAAPI device {RenderNodePath} is Intel GPU (i965)", options.VaapiDevice); _logger.LogInformation("VAAPI device {RenderNodePath} is Intel GPU (i965)", options.VaapiDevice);
} }
if (_isVaapiDeviceSupportVulkanFmtModifier) if (_isVaapiDeviceSupportVulkanDrmInterop)
{ {
_logger.LogInformation("VAAPI device {RenderNodePath} supports Vulkan DRM format modifier", options.VaapiDevice); _logger.LogInformation("VAAPI device {RenderNodePath} supports Vulkan DRM interop", options.VaapiDevice);
} }
} }
} }

Loading…
Cancel
Save