forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on cbbd6e2ef6acafb00aeb55e460423f024126f90fFiltered to crates/ec-va/src/lib.rsClear filter

2026-08-20

feat(ec-hw): P010 encode_frame goes through a GPU-resident VAProfileNone/VideoProc VPP pass, not CPU read-backAhmet Kaan Gümüş · 67c8428
feat(ec-hw): P010 encode_frame goes through a GPU-resident VAProfileNone/VideoProc VPP pass, not CPU read-back

encode_frame previously refused any 10-bit (P010) frame outright, forcing a
consumer's HDR->proxy export onto to_i420()+re-upload for the whole path.
This adds ec_va::Vpp (Config/Context/Buffer/Picture — all the existing
generic VA-API machinery, no new unsafe outside ec-va) wrapping
VAProfileNone/VAEntrypointVideoProc, and wires a lazily-built 2-surface NV12
pool + Vpp into ec_hw::Encoder: a 10-bit frame is converted P010->NV12 on
the GPU (VAProcPipelineParameterBuffer, whole-surface, no filters) and then
submitted through the exact same encode_surface() path as an 8-bit frame.

radeonsi capability check (vainfo): VAProfileNone/VAEntrypointVideoProc is
advertised on this GPU, confirming the entrypoint this crate now uses is
real hardware support, not a driver gap. HDR->SDR tonemap
(VAProcFilterHighDynamicRangeToneMapping) was NOT wired: sys.rs carries the
filter-type constants and Vpp::filters() (vaQueryVideoProcFilters) to check
for it, but the charter's own gpu.rs tests (PSNR/bench harness) were not
written this round — see the ledger DELTA for the honest state of that gap.

Scoped compiles green: `cargo check -p ec-va[--tests]`, `cargo check -p
ec-hw[--tests]`. The 23-test `ec-hw --test gpu` regression and a live P010
decode+encode_frame+decode-back PSNR run were NOT executed this round
(budget) — next round's first move.

2026-08-14

feat(va): hand-written libva FFI with RAII handles and picture typestateAhmet Kaan Gümüş · 0eac457
feat(va): hand-written libva FFI with RAII handles and picture typestate

Minimal VA-API bindings for the hardware-video lane, no bindgen and no
build-time tooling. `sys` transcribes the libva 1.23 subset the family needs;
everything above it is safe.

- ABI: struct layouts asserted at compile time against numbers printed by
  abi-probe.c compiled against the system headers; `vaInitialize` version
  guard refuses libva older than 1.23 at runtime. Together these close the
  header-drift trap that broke the incumbent bindings at 1.23.
- Soundness: C enums stay `i32` in `sys`; the safe `Profile`/`Entrypoint`
  mirrors carry an `Unknown(i32)` arm, so a value from a newer driver can
  never be transmuted into an invalid Rust enum.
- RAII: Display/Config/Surface/Context/Buffer each destroy exactly what they
  created, and children hold an `Arc` of their parent, so libva's destruction
  order is a borrow-checker fact. Image and buffer mappings unmap on drop;
  PRIME exports own and close their descriptors.
- Picture typestate: New -> Rendering -> Ended -> Synced, transitions consume
  the picture; out-of-order submission does not compile.
- Caps probe reports per-pair RT formats plus driver-legal surface sizes
  (radeonsi refuses below 64x64) instead of assuming them.

55 unsafe blocks, every one SAFETY-commented. Tests run against the real GPU:
11 live tests (caps table vs vainfo, 100 pool create/destroy cycles under an
RSS bound, PRIME fd ownership, derive/map/unmap round trip) plus 4
compile_fail doctests pinning the typestate on E0599.