forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on ef5832fea151ca30db92b142c8de131c5f43fc49Filtered to crates/engine/src/hw.rsClear filter

2026-08-14

✨ feat(engine): the driver that aborts kills a process nobody was editing inAhmet Kaan Gümüş · c0a1847
✨ feat(engine): the driver that aborts kills a process nobody was editing in

Mesa's radeonsi calls libc abort() from its own C worker thread when the
video ring resets under it -- amdgpu_ctx_set_sw_reset_status, mesa 26.1.6,
vcn_unified_0 hung during an AV1 encode submission on 2026-08-13. A foreign
thread's abort is not an unwind, so every catch_unwind in the plugin was
structurally unable to see it: the editor died with the driver and took the
session's work with it.

So the encoder is not in the editor's address space any more. HwEncoder is a
handle on a `hw-encode-child` process that dlopens the plugin, and its death
-- by abort, by any signal, or by going quiet past VE_HW_TIMEOUT_MS -- comes
back as an error the export answers by writing the file again in software.
A person who picked the GPU by name still gets the refusal in words rather
than an encoder nobody chose.

Isolation that cost the speed would not be worth having, so pictures do not
travel down a pipe: in-memory ones go through a memfd mapped in both
processes, and pictures still on the GPU never move at all -- their
DRM-PRIME descriptors cross as file descriptors over SCM_RIGHTS, so the
zero-copy export path stays zero-copy across the boundary. Measured on this
box at 1080p: 430 fps in-process, 384 isolated, 89% of it, worst case
(every export of an untouched clip takes the descriptor path instead).

The proof does not need a wedged ring, which is the one thing a wedged
machine cannot supply: VE_HW_TEST_FAKE opens a stand-in seat in the child and
VE_HW_TEST_ABORT / VE_HW_TEST_HANG say where it dies or stops, so the
containment paths are exercised on any machine, GPU or no GPU.

Decode is still in the editor's process, where the same abort would still be
fatal; the seam to move it is now the one this built.
✨ feat(app): the seat that writes the picture is picked on the card, not by an env pinAhmet Kaan Gümüş · 50af5b5
✨ feat(app): the seat that writes the picture is picked on the card, not by an env pin

The export card gains an Encoder row: Auto, Hardware or Software, three rows in a
list like every other setting with more than two values -- `e` steps it, a click
opens the list, and the planned line under the rows re-probes and says which seat
it measured.

Auto is what every export did before (the GPU where there is one). Hardware is
the GPU or a refusal in words -- `Enc::open` refuses before the muxer exists, so
nothing is written -- and it is now the only door to the plugin's AV1 seat, which
`VE_HW_AV1=1` used to guard: an env pin nobody exporting a film would ever find.
A person who picks it for AV1 gets a plain row naming what happened on this box's
driver, and the pick still stands.

Software forces the CPU encoder, which also takes the zero-copy path off the
table by construction (`Enc::dma_want` answers only for the two hardware seats).

Kept with the project: `.edith` gains an `encoder` line at v14, written only when
it is not Auto, and a v13 file loads as Auto.

- engine: `ExportSettings::force_sw` -> `seat: EncoderSeat`; `hw_seat` returns the
  refusal instead of falling back; `planned_video` says `NO_HW_SEAT` where it would
- app: `Pick::Encoder`/`Choice::Encoder`, card row, `e` in the card's own keyboard
  and in the keys menu (`FIXED`)
- tests: the backends sweep runs all three seats (the AV1 hardware seat excepted,
  as before), and asserts the refusal is only what a missing seat produces
🐛 fix(engine-hw): the hardware HEVC seat says what its samples meanAhmet Kaan Gümüş · 9fdee6f
🐛 fix(engine-hw): the hardware HEVC seat says what its samples mean

The plugin's HEVC encoder wrote no VUI at all, so libavcodec read the
stream's colour as "unspecified" and rendered a 709 export through the
601 matrix -- the HEVC decoder takes the bitstream's answer and
overwrites the container's with it, which is why the mp4's `colr` box
and the Matroska's Colour element could not cover for it
(`export_color::every_format_signals_its_space_in_the_bitstream`, both
HEVC containers, whenever the plugin is on the path).

The three H.273 code points and the range flag now go in at the open,
from the same `ColorDescription::output` rule the software intra seat's
VUI and both muxers' tags come from, through the vendored `SpsBuilder`'s
own `video_signal_type`/`colour_description`. A symbol of its own,
`vh_enc_hevc_open_colour`, rather than four more arguments under the old
name: a plugin that predates it is then simply missing the seat and the
export falls back to the software encoder, which has always written the
VUI, instead of being called with a signature it does not have.

2026-08-13

🔀 merge(engine): the stand-in decides one path, and the intra file keeps its marksAhmet Kaan Gümüş · eff035e
🔀 merge(engine): the stand-in decides one path, and the intra file keeps its marks

Lane P's proxy workflow meets a main that had taken S's persistent decode
workers, E's pipelined export and E4's zero-copy encode.

* `start_span` keeps S's reuse door and P's single substitution point at
  once: `picture_path(source)` is resolved *before* the door and handed to
  both halves of it. A worker holding the film is then asked for a span of
  the stand-in, declines on the path it already has (`Worker::reseek`),
  and `set_proxies`' seek becomes a respawn on the other file -- while a
  span that did not change files still costs no thread and no VA-API init.
  Asking the project for the path at the door, as main did, would have
  left every proxied span opening a worker from scratch.
* `Enc::encode_dma` takes P's `intra` flag, which is not symmetry: a proxy
  of a file already small enough is coded at that file's own size
  (`proxy::size_for` -- `wanted` is true for HEVC and AV1 at any size), so
  an intraframe export's decoder and encoder can agree on a surface and
  the buffer goes straight across. Marked `false` there, an all-intra
  stand-in would have carried no sync point at all, which is the exact
  bug `gop_limit` was written against, reached by the other door.
* The five other conflicts were both sides adding a field: `drop_late`
  and `proxies` next to each other, in the struct and in all three opens.
* `enc_depth` is keyed by codec, so the intra seat takes H.264's two. Said
  in its doc rather than left to be re-derived: that seat is the same
  entrypoint with every inter dependency removed, so a picture there is
  finished no later than one on the seat the two was measured on.

`nm -D libengine_hw.so` lists sixteen: P's `vh_enc_open_intra` beside
E4's `vh_next_frame_dma`, `vh_enc_dma_geometry`, `vh_enc_frame_dma` and
main's `vh_seek`. `picture_path` still has exactly one call site outside
the tests, and it is in `playback` -- an export reads the film.

The intra seat and the zero-copy path are read, not run: every test that
would reach either is hardware-gated and the GPU is wedged.
🔀 merge(engine-hw): the encoder that skips the CPU keeps the two it holdsAhmet Kaan Gümüş · 9717151
🔀 merge(engine-hw): the encoder that skips the CPU keeps the two it holds

Lane E4's zero-copy encode path meets lane E's two-picture encoder. Both
touched the same file at the same place and neither knew of the other.

* `vh_seek` and `vh_next_frame_dma` were the textual conflict and nothing
  more: two different symbols added at one spot. Both kept.
* `EncSession::encode_dma` submits a picture like `encode` does, so it
  counts one in `in_flight` -- one session takes both kinds of picture
  (an untouched clip hands buffers over while a graded one or a gap goes
  through the pixel path), and a submission missing from that count is an
  input buffer the pixel path would believe free one picture too early.
* No deferred poll on the dma path, said in a comment where it would go:
  the depth exists to overlap the *next* picture's CPU interleave with
  this one's encode, and a picture arriving on the GPU has no interleave
  to overlap. Draining every call is also what keeps the decoder's own
  hold on the buffer short.
* Per-codec `enc_depth` therefore governs both kinds: the pixel gate is
  the only one there is, and the dma path leaves `in_flight` at its floor.

`nm -D libengine_hw.so` lists both lanes' optional symbols: vh_seek,
vh_next_frame_dma, vh_enc_dma_geometry, vh_enc_frame_dma. The refusal
fallback is untouched -- a buffer the plugin cannot hand over comes back
as pixels, never as a failure.

The dma path itself is read, not run: every test that would exercise it
is hardware-gated and the GPU is wedged.
🐛 fix(engine): the GPU's stand-in was one starting point long, not every frameAhmet Kaan Gümüş · 60ae56c
🐛 fix(engine): the GPU's stand-in was one starting point long, not every frame

A proxy asked the ordinary hardware seat for a key frame on every
picture, which is not the same thing as an intra-only file and does not
make one: cros-codecs' low-delay predictor takes the keyframe branch
with `idr` false for a forced key frame, writes no SPS or PPS with it,
and `fix_slice_nal_headers` -- which reads the parameter sets to know
what a slice is -- then marks it a plain I slice. A 60-picture hardware
proxy came back with **one** frame a decoder could start on, so its
seeks were the film's own seeks and the whole point of it was gone.
Software was right all along (150 of 150), which is what hid it.

The thing that decides this is the predictor's group limit, and a group
of one picture is what an intra seat is: the counter is then pinned at
zero, every picture takes the keyframe branch as an IDR, and every
access unit carries its own parameter sets. That is the HEVC seat's own
mechanism, now the H.264 one's as well.

Its own plugin symbol (`vh_enc_open_intra`) rather than a flag on the
existing one, matching the AV1 and HEVC seats: a plugin built before it
exists has no intra seat, and the caller then takes the software encoder
-- which codes one frame a GOP and writes what was asked for -- instead
of being handed a long-GOP file under a name that promises otherwise.
`intra_only` on anything but the mp4 pair is now refused by name.

Checked without a GPU: the group limit and the IDR-marking rule are both
unit tests in the plugin. The hardware end-to-end twin (`sync_points`
== frame count) is written and `#[ignore]`d, for a machine whose GPU is
not wedged.
⚡ perf(export): the picture the GPU decoded is the picture it encodesAhmet Kaan Gümüş · 366171b
⚡ perf(export): the picture the GPU decoded is the picture it encodes

An untouched clip's frames never leave the card: the decode session hands
its DRM-PRIME buffer over and the encoder imports it, so an export of a
clip with no grade, no tone map, no matrix remap and no canvas to place
on costs neither the `vaGetImage` read-back nor the NV12 interleave back
up -- both of which used to run once per frame, per side.

Three optional plugin symbols carry it (`vh_next_frame_dma`,
`vh_enc_dma_geometry`, `vh_enc_frame_dma`), so an older `libengine_hw.so`
reads back exactly as it did, and any refusal at all -- another coded
size, another fourcc, a driver whose export the plugin will not take, a
software decoder on the other end -- hands the pixels over instead of
failing. The decode session keeps six pictures out of its pool while
they are outstanding, and reserves six extra buffers the moment a caller
asks, so a decoder is never robbed of its own.

Measured on the film, 60s span, hardware H.264 both ways: 94.58 -> 276.46
fps median, 46.9s -> 15.6s wall, and 37.6s -> 0.5s of user CPU. SSIM
against the source frames is 0.964490 where the read-back path scores
0.964506 -- the same picture, coded by the same encoder.
⚡ perf(decode): the worker that decoded a span stays for the next oneAhmet Kaan Gümüş · bbdd4d6
⚡ perf(decode): the worker that decoded a span stays for the next one

A seek used to cost a thread, a container parse and a VA-API
initialisation (98 ms measured worst case) before it could decode a
single picture, because every span opened a decoder of its own and threw
it away again. The worker now outlives its span: it parks on a command
channel, and a seek onto the file it already has open reaches it through
Worker::reseek -- a demuxer seek and a decoder flush, 1-4 ms measured
against a 28-37 ms open of the same file warm.

The plugin learns the same trick from the other side: vh_seek
repositions an open session exactly as vh_open_at positions a new one,
and it is an optional symbol, so a plugin built before it still decodes
and its caller simply opens a session per seek as it always did.

Cancelling and abandoning become two different things: a seek abandons
the span (the thread, the file and the decoder stay), a replacement
cancels the worker (the thread ends, and the command channel goes with
it, so nothing parks in recv past the session that owns it and no VA-API
session meets Mesa's atexit).
✨ feat(export): the GPU takes the HEVC export, and it is the same fileAhmet Kaan Gümüş · bacbe9f
✨ feat(export): the GPU takes the HEVC export, and it is the same file

`HwEncoder::open_hevc` on the plugin's new symbol, and `hw_seat`'s HEVC
arm goes from a flat `None` -- "the plugin has no HEVC encoder" was true
and is not any more -- to a real probe. Unlike the AV1 seat it is **not**
behind an opt-in, and what makes that safe is that both HEVC seats code
intra-only: preferring the GPU changes how long an export takes and not
what comes out of it, which is the whole reason AV1's `VE_HW_AV1` exists
and does not apply here.

`Enc::HevcHw` beside `Enc::Hevc`, and every unit it hands back is marked
a sync point, because that is this encoder's configuration rather than a
driver's choice. Falling back is silent and covers all of it: no
entrypoint, a plugin too old to carry the symbol, a picture under the
driver's 384x384 floor, `VE_SW_ENC=1`, or the export card's own "software
only" -- `hw_seat` answers `None` before it probes for the last two, as
it always has.

The caps line stops saying HEVC is decode-only on this GPU.

Measured on this box, both against the software seat's 4.30 fps at 1080p:
1440p at 74 fps, 1080p at 117 fps, output decoding frame for frame.

2026-08-11

✨ feat(caps): the card says what this machine and this build can really doAhmet Kaan Gümüş · 0f37a18
✨ feat(caps): the card says what this machine and this build can really do

The hardware half was never asked for: the plugin decoded what it was
handed and the front-end had nothing to show before a file arrived. Now
an optional `vh_caps` symbol asks the driver -- profiles, entrypoints and
whether a P010 image exists for a 10-bit read-back -- and intersects that
with the codecs the plugin actually implements, so a GPU with an HEVC
encode entrypoint is not reported as an HEVC encoder edith can reach.

Optional exactly as `vh_enc_av1_open` is: a plugin built before this
still loads and still decodes, and the listing degrades to "none" for it,
for a missing plugin and for a machine with no driver alike.

The software half is a table -- what this build was compiled with is a
question the manifest already answered -- and both halves land at the
foot of the export card, where a user asks them.

2026-08-10

✨ feat(export): AV1 comes back out, in a Matroska file this editor reopensAhmet Kaan Gümüş · dd3a2a8
✨ feat(export): AV1 comes back out, in a Matroska file this editor reopens

The export card's second picture format. AV1 already *arrives* here as
Matroska (`mp4 0.14` has no `av01` sample entry at all, so `demux` walks
the EBML by hand); it now leaves the same way, through an `MkvMuxer`
written beside the mp4 one -- EBML header, `Info`, one `V_AV1` track whose
`CodecPrivate` is a real `av1C` record built from the first keyframe's
sequence header OBU, then clusters that open on every keyframe. The
segment size and the duration are the only two fields patched at `finish`.
Matroska rather than AV1-in-mp4 because the reader for it already exists:
the round trip closes against this project's own `Demuxer`.

Picture only, and said so on the row before a destination is picked ("AV1
picture in .mkv — no sound: export WAV or FLAC for that"). Matroska
carries no sound this project can *write* -- no AAC or Opus encoder here
-- and an AAC track copied in would be one this engine's own reader leaves
silent (`AudioSession::open` refuses Matroska audio). A silent track
written anyway is the one failure a user would not notice.

The encoder pair mirrors H.264's: `rav1e` in software, the plugin's new
`vh_enc_av1_open` on the GPU. The hardware seat is wired, tested and
**opt-in** (`VE_HW_AV1=1`): the vendored cros-codecs AV1 encoder took the
radeonsi box this was written on into an amdgpu hard recovery, and a
driver reset is not an export. `rav1e` is not a new dependency at all --
`ravif` already locks the same 0.8.1 -- and is built with `asm` off (no
`nasm` in this build) and `threading` on: 39 s for the 5 s 720p fixture,
progress reported the whole way.

HEVC and VP9 are rows too, refused by name: no encoder in this stack and
patent-encumbered, and superseded by the AV1 row above.
✨ feat(engine): HEVC import via the VA-API pluginAhmet Kaan Gümüş · 85c152d
✨ feat(engine): HEVC import via the VA-API plugin

The demuxer takes a hev1 track alongside avc1 and vp09. Its parameter sets are
read out of the file by hand: mp4 0.14 reads one byte of hvcC and skips the
rest, so the VPS, SPS and PPS an HEVC decoder cannot start without are
unreachable through the crate. A small ISO-BMFF walk finds the track's hvcC and
the record gives both the parameter sets and the NAL length prefix width -- the
avcC one is now read the same way instead of assumed to be four bytes, which is
one hardcoded guess less on the H.264 path too.

Samples are repacked to Annex-B exactly as H.264's are, parameter sets ahead of
every sync sample, because a hardware decoder that joins the stream at a seek
has nothing else to configure itself from.

Main 10 is refused at open by name: the plugin's NV12 pool and its vaGetImage
read-back are 8-bit, and a 10-bit stream decoded into them would be garbage
shown as a picture rather than an honest no. Same reasoning as the software
refusal, which is now one message shared by every codec that has no software
decoder at all.

The C ABI is unchanged again: the plugin demuxes the file it is given, so an
older libengine_hw.so still loads, still decodes H.264, and simply returns null
for an HEVC path.
✨ feat(engine): VP9 import via the VA-API pluginAhmet Kaan Gümüş · 03a34d3
✨ feat(engine): VP9 import via the VA-API plugin

The demuxer takes a vp09 track alongside avc1 and hands its samples through
untouched -- an mp4 VP9 sample is a self-contained superframe, so there is no
avcC repack and no parameter sets to re-inject. VideoMeta carries the codec,
and the plugin picks its cros-codecs decoder from it.

The C ABI is unchanged on purpose: the plugin demuxes the file it is given,
so the codec is a property of the container rather than of the call, and a
libengine_hw.so built before this still loads and still decodes H.264 -- it
simply returns null for a VP9 path, the same no it gives for an unsupported
profile.

There is no software VP9 decoder to fall back to, so a VP9 file the plugin
will not take is refused at open, by name, where the front-end can show it --
never a black screen, and never VP9 bytes fed to rusty_h264. One timeline
stays one codec, and export re-encodes to H.264 as before; only audio is
ever copied packet for packet.

2026-08-09

✨ feat(engine-hw): vh_enc_* — VA-API H.264 encode with Mesa slice-header fixupAhmet Kaan Gümüş · b75c83e
✨ feat(engine-hw): vh_enc_* — VA-API H.264 encode with Mesa slice-header fixup

The plugin grows an encode half beside the decode one:
vh_enc_open/vh_enc_frame/vh_enc_drain/vh_enc_close, and engine::hw
gains HwEncoder behind a SEPARATE symbol table. That separation is the
point -- a libengine_hw.so predating this commit must keep decoding, so
the four new symbols must not join the decode Plugin struct where a
missing one would take decode down with them. Absent symbols just mean
HwEncoder::open returns None and the caller falls back to the
rusty_h264 software encoder.

Measured on radeonsi (Mesa 26.1.5): 3.98 ms/frame at
1280x720 CBR 4 Mbps including the I420->NV12 upload, against 25.6
ms/frame for rusty_h264 Fast at the same size -- 6.4x. Profile Main,
level 4, LowDelay so there are no B-frames and coded order is display
order; radeonsi exposes no VAEntrypointEncSliceLP for H.264 so
low_power stays off. One reusable DMA-BUF frame carries every picture
because BlockingMode::Blocking plus a poll() in each entry point syncs
the coded and recon promises before returning. Non-16-aligned sizes
allocate aligned surfaces, carry the true size in the SPS crop, and
replicate the edge pixel into the padding rather than shipping gbm
garbage there.

The one ugly part is fix_slice_nal_headers. cros-codecs supplies no
VAEncPackedHeaderH264_Slice, and Mesa fills forbidden_zero_bit /
nal_ref_idc / nal_unit_type only from a packed slice header, so every
slice NAL leaves the encoder with a 0x00 header byte and both ffmpeg
and rusty_h264 refuse the stream. Patching that single byte per slice
makes both decode it fully. An all-zero header byte is never valid
H.264, so the rewrite is a no-op on drivers that write it properly
(Intel iHD, which cros-codecs was built against). Marked ponytail; the
real fix is a packed slice header in vendor/cros-codecs.
✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_atAhmet Kaan Gümüş · 96ae365
✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_at

Lane 1 of the seek slice; PlaybackSession orchestration comes next.

- demux/decode: stss sync lookup, DecodeSession::open_at decodes from
  the keyframe and discards to the target; Frame.index stays absolute.
  HW plugin ABI: vh_open renamed vh_open_at(path, target) — discards
  skip the vaGetImage readback; measured seek cost 65ms HW / 222ms SW
- engine-audio: ao_flush drains the ring consumer-side in the RT
  callback (one-shot atomic), stale PCM unplayable even when paused;
  played-position atomics untouched so clock math survives
- audio: open_at walks stts, 2-packet AAC pre-roll (MDCT overlap
  reconstructed exactly — verified 0-diff before the first PNS band),
  sample-exact trim; priming skip and seek discard unified. AAC seek
  is deliberately not bit-exact: symphonia's PNS noise LCG state
  depends on packet history; bounded <1e-3 by test instead
🎉 feat: MVP decode pipeline — mp4 → H.264 → gpui previewAhmet Kaan Gümüş · 0acbf8d
🎉 feat: MVP decode pipeline — mp4 → H.264 → gpui preview

- engine: mp4 demux → Annex-B, rusty_h264 software decode, BT.601
  I420→BGRA; decode on worker thread behind a bounded channel
- engine-hw: optional VA-API decode plugin (cros-codecs) behind a
  C ABI, dlopen'd at runtime with silent software fallback; the app
  binary keeps zero libva/gbm/drm linkage so it runs on any distro
- app: gpui window, per-frame RenderImage swap + drop_image
- vendor/: cros-libva + cros-codecs with 3 LOCAL PATCH fixes (libva
  1.23 struct init, radeonsi 64x64 min context, pub surface()) —
  upstream is dormant, so vendor/ is adopted code, not a temp fork
- fixtures are gitignored; scripts/gen_fixtures.sh regenerates them