fix: AMD AV1 RADV support — layered DPB, converter layout, GOP clamping - #27
Merged
Merged
Conversation
Three fixes required for correct AV1 encoding on AMD RADV (and generally correct Vulkan usage): 1. Converter target image barrier always used UNDEFINED as the old layout, but the encoder's clear_input_image() already transitions the image to VIDEO_ENCODE_SRC_KHR during init. Correct the old layout and source access mask so the barrier is spec-compliant on every frame. 2. Allow the AV1 encoder to use a layered DPB image when the driver does not advertise VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES. AMD RADV requires this; without it the encode command faults the GPU (GCVM_L2_PROTECTION_FAULT / VK_ERROR_DEVICE_LOST). 3. Clamp gop_frame_count and key_frame_period to at least 1 in the AV1 rate-control info. Moonshine (and other users) set GOP size to 0 to signal "manual IDR only"; passing 0 to the driver is undefined and triggers undefined behaviour on some drivers.
Owner
|
Thanks! Looks good to me 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AV1 streaming was broken on my 7900XTX. I traced it down to the single line fix in av1/init.rs.
On the way there I picked up some Vulkan correctness fixes, especially ".old_layout(vk::ImageLayout::VIDEO_ENCODE_SRC_KHR)" was needed to get to the bottom of this.
Converter target image barrier always used UNDEFINED as the old layout, but the encoder's clear_input_image() already transitions the image to VIDEO_ENCODE_SRC_KHR during init. Correct the old layout and source access mask so the barrier is spec-compliant on every frame.
Allow the AV1 encoder to use a layered DPB image when the driver does not advertise VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES. AMD RADV requires this; without it the encode command faults the GPU (GCVM_L2_PROTECTION_FAULT / VK_ERROR_DEVICE_LOST).
Clamp gop_frame_count and key_frame_period to at least 1 in the AV1 rate-control info. Moonshine sets GOP size to 0 to signal "manual IDR only"; passing 0 to the driver is undefined and triggers undefined behaviour on some drivers.