[Linux][Vulkan Video] Decoded video is green with direct-export on GPUs that report a distinct DPB
Categories
(Core :: Audio/Video: Playback, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox160 | --- | fixed |
People
(Reporter: tboiko, Assigned: tboiko)
References
(Blocks 2 open bugs)
Details
Attachments
(3 external files, 1 obsolete file)
Direct export maps the Vulkan decode image to a dma-buf and the compositor samples it. FFmpegVideoDecoder::ChooseVulkanPixelFormatFromContext always adds VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR to that image.
Seen on AMD Radeon RX 9070 GRE (RADV GFX1201, radeonsi). vkCreateImage reports VUID-VkImageCreateInfo-pNext-06811 for an image with VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT, flags 0, and usage TRANSFER_SRC | TRANSFER_DST | VIDEO_DECODE_DST | VIDEO_DECODE_DPB.
Steps to reproduce:
Linux, a GPU whose Vulkan decode caps include VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR (AMD Radeon RX 9000 series + RADV does, RX 7600 and higher may be an option to).
Set media.hardware-video-decoding-vulkan.enabled, media.hardware-video-decoding-vulkan.force-enabled and media.hardware-video-decoding-vulkan.direct-export.enabled to true.
Play any video.
Actual: a green frame.
Expected: the picture.
Comment 1•28 days ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Audio/Video: Playback' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
| Assignee | ||
Comment 2•28 days ago
|
||
Direct export was forcing VIDEO_DECODE_DPB onto every decode image. Drivers that report DPB_AND_OUTPUT_DISTINCT keep references on a second image; that extra usage made the compositor sample a DPB surface. Keep the bit only when get_hw_frames_parameters already set it.
Updated•28 days ago
|
| Assignee | ||
Comment 3•28 days ago
|
||
Direct export was forcing VIDEO_DECODE_DPB onto every decode image. Drivers that report DPB_AND_OUTPUT_DISTINCT keep references on a second image; that extra usage made the compositor sample a DPB surface. Keep the bit only when get_hw_frames_parameters already set it.
Updated•28 days ago
|
Comment 4•28 days ago
|
||
Direct export still doesn't work on my RDNA3 GPU btw. And in last FF versions it is even blocklisted from Vulkan decoding completely, unless I set media.hardware-video-decoding-vulkan.force-enabled.
| Assignee | ||
Comment 5•28 days ago
•
|
||
[:hanabishi], have you tried this patch? - It should fix it, at least for RDNA4
Comment 6•28 days ago
|
||
No, can't build Firefox myself / can't test until it lands in nightly.
| Assignee | ||
Comment 8•28 days ago
•
|
||
Hi Martin,
Thank you for landing these changes. They are correct for the lavc version in ffvpx, but I will need to make a small change for compatibility with older versions, plus perform some minor refactoring and add a warining log. I will follow-up an additional commit.
Comment 9•28 days ago
|
||
| gecko-triage | ||
The diagnosis in comment 0 is correct. The fix from this bug is on autoland now.
Analysis
With media.hardware-video-decoding-vulkan.direct-export.enabled, FFmpegVideoDecoder::ChooseVulkanPixelFormatFromContext always adds VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR to the decode image (FFmpegVideoDecoder.cpp). FFmpeg keeps that bit off the output image when the driver reports DPB_AND_OUTPUT_DISTINCT (vulkan_decode.c). On RADV with RDNA4, image creation then fails validation, and the frame is green. The bundled ffvpx also gets this path when the pref is on, so the problem is not only with system FFmpeg.
The autoland change adds the bit only when FFmpeg already set it. Drivers that share one image for the DPB and the output, such as NVIDIA and Intel, still get the bit. The follow-up for older lavc versions in comment 8 is still open.
The RDNA3 report in comment 4 can have a different cause. A Nightly build with this fix will show if it does.
This bug blocks bug 2053144 (Vulkan video decoding on Linux) and bug 1766429 (Linux playback). Bug 2077880 is a related direct-export problem on NVIDIA, with a different cause.
To give feedback on this comment, add a thumbs-up or thumbs-down reaction.
| Assignee | ||
Comment 10•28 days ago
•
|
||
Bug 2077880 is a related direct-export problem on NVIDIA, with a different cause.
No, the bug reported by [:media-triaging-bot] in #c9 is not related to this one. The only thing they have in common is the green output.
Comment 11•27 days ago
|
||
| bugherder | ||
| Assignee | ||
Comment 12•27 days ago
•
|
||
Let's keep this open for a while, I will follow-up and additional patch for the older FFmpeg builds. After that we can close the bug.
Updated•27 days ago
|
| Assignee | ||
Comment 13•27 days ago
|
||
Refactor so CheckDecodeCapabilities runs the video-caps query. Use VulkanProbeFormat instead of H264VulkanProbeFormat, preserving previous behavior (bug 2063809: VulkanCanDecodeFormat only applies the FFmpeg < n7.1 COINCIDE-without-SEPARATE_REFERENCE_IMAGES skip). This allows other functions to use the decode caps.
| Assignee | ||
Comment 14•27 days ago
|
||
libavcodec before 63.8.101 uses dedicated_dpb = !COINCIDE, so VIDEO_DECODE_DPB is on the output whenever COINCIDE is advertised, including when DISTINCT is also set. From 63.8.101 libavcodec uses dedicated_dpb = DISTINCT. Copy hwfc->usage on new lavc; on older lavc set DPB only if the driver does not report DISTINCT.
Comment 15•27 days ago
|
||
(In reply to Tymur Boiko from comment #5)
[:hanabishi], have you tried this patch? - It should fix it, at least for RDNA4
Tested nightly with the patch: no difference for RDNA3, direct export doesn't work.
| Assignee | ||
Comment 16•27 days ago
•
|
||
What exactly are you observing: image artifacts or a fallback to VAAPI? Could you provide logs? What RADV version are you using? Could you try running it with the MOZ_DISABLE_RDD_SANDBOX=1 - does that help?
With the 1st patch only landed you should try AV1 or VP9 (so that it uses ffvpx (make sure media.hardware-video-decoding-vulkan.prefer-system-ffmpeg=false, however it should be false by default), or use latest FFmpeg master for other codecs)
Comment 17•27 days ago
|
||
With the 1st patch only landed you should try AV1 or VP9 (so that it uses ffvpx, or use latest FFmpeg master for other codecs)
Oh, that's the culprit. I tested H264 which uses system ffmpeg 9.0.2.
But yeah, direct export works now for VP9/AV1 using built in ffvpx.
Comment 18•26 days ago
|
||
(In reply to Tymur Boiko from comment #16)
What exactly are you observing: image artifacts or a fallback to VAAPI?
With Vulkan decode on we don't fallback to VA-API but to SW decode directly.
| Assignee | ||
Comment 19•26 days ago
|
||
With Vulkan decode on we don't fallback to VA-API but to SW decode directly.
In the attached patches, I did not change any fallback behavior
| Assignee | ||
Comment 20•26 days ago
•
|
||
Hi Martin, could you please land the rest (your comments were resolved)?
Comment 21•25 days ago
|
||
Comment 22•25 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/e9aaabf9364a
https://hg.mozilla.org/mozilla-central/rev/e3569715c160
Description
•