Skip to content

Export decoder surfaces before the first decode - #123

Open
c4software wants to merge 1 commit into
omacom:mainfrom
c4software:decode-export-before-first-decode
Open

c4software wants to merge 1 commit into
omacom:mainfrom
c4software:decode-export-before-first-decode

Conversation

@c4software

Copy link
Copy Markdown

The client exported its VA-API decode surfaces to Vulkan only after the first decode of a stream. On libva-v4l2-request (Apple AVD on Asahi, libva-v4l2_request-avd), the first decode fixes how the CAPTURE queue is backed: MMAP when the surface has not been exported yet. Every surface exported afterwards gets its own standalone dma-buf, and the driver then refuses to decode into it:

libva-v4l2request: cannot decode into the already-exported surface layout

This happened from the second frame of every stream, so it repeated on each --headless resize, on both the main and aux streams.

H264Decoder now exports every surface when it opens a stream, before any decode, and keeps the descriptors. DecodeStream imports those instead of exporting after the fact. The driver supports this order: it switches the queue to DMABUF mode and decodes into the exported memory (the same order Chromium uses). On AMD and Intel the same dma-buf is exported, just earlier.

Testing

  • scripts/check.sh passes.
  • Asahi (MacBook, libva-v4l2_request-avd 1.3.r11, kernel 7.2.11) as the client, --headless against an AMD server: the errors are gone. The driver logs surface ... was exported before its first decode; decoding into client-exported dma-bufs, and resizing the window reopens the stream at each new size (1920x1088, 768x832, 960x1120, ...).
  • scripts/e2e.sh has not been run.

@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes appear safe to merge; no actionable code issues were found.

Summary

The decoder now exports every VA-API surface when it opens a stream, before submitting any decode.

  • VA-API surfaces are exported before each stream's first decode.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Open stream] --> B[Allocate VA-API surfaces]
  B --> C[Export and keep descriptors]
  C --> D[Submit first decode]
  D --> E[Import saved descriptors into Vulkan]
  E --> F[Wait for decode and recombine]
Loading

Reviews (1) · Last reviewed commit: "Export decoder surfaces before the first..." · Reviewed by Greptile

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.

1 participant