Skip to content

fix: AMD AV1 RADV support — layered DPB, converter layout, GOP clamping - #27

Merged
hgaiser merged 1 commit into
hgaiser:mainfrom
schlegp:fix/av1-radv-layered-dpb
Jul 28, 2026
Merged

fix: AMD AV1 RADV support — layered DPB, converter layout, GOP clamping#27
hgaiser merged 1 commit into
hgaiser:mainfrom
schlegp:fix/av1-radv-layered-dpb

Conversation

@schlegp

@schlegp schlegp commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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.


  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 sets GOP size to 0 to signal "manual IDR only"; passing 0 to the driver is undefined and triggers undefined behaviour on some drivers.

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.
@hgaiser

hgaiser commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Thanks! Looks good to me 👍

@hgaiser
hgaiser merged commit a5bfc36 into hgaiser:main Jul 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants