Skip to content

feat(video): host-DMA double-buffer for U64 bitmap scenes with text overlays#43

Merged
kfox merged 1 commit into
mainfrom
feat/hostdma-doublebuffer-u64-overlays
Jun 24, 2026
Merged

feat(video): host-DMA double-buffer for U64 bitmap scenes with text overlays#43
kfox merged 1 commit into
mainfrom
feat/hostdma-doublebuffer-u64-overlays

Conversation

@kfox

@kfox kfox commented Jun 24, 2026

Copy link
Copy Markdown
Owner

What

Extends [video].double_buffer = "auto" to enable the host-DMA page-flip for a bitmap scene with a text overlay on a REU backend (the U64) — not just on no-REU backends (TeensyROM), as before.

Why

resolve_use_reu_staged already turns the REU bank-swap off for bitmap + text overlays (the REU swap's mid-frame $DD00 flip shimmers fine high-contrast glyphs in the bottom rows). That left those scenes on single-buffer host-DMA, which tears on scene cuts — the original mhires whole-screen-flash problem — with no tear-free path available on the U64.

The host-DMA double-buffer (shipped for the TR in #42) is exactly the fix: its swap IRQ does no in-IRQ DMA, so the $DD00 flip lands cleanly in vblank (no shimmer), and text glyphs live in banked screen RAM so they swap atomically with the bitmap. This PR just lets auto pick it for the one case where the REU path can't help.

Behavior changes are surgical:

  • Overlay-free bitmap video on a REU backend is untouched (stays on the REU path — the better tear-free option there).
  • Gated off when the REU mic pump is active (it owns $0314 too, with no merged dispatcher for this pair). Never reached on a no-REU backend, where use_reu_pump is coerced off.
  • TR behavior unchanged.

Changes

  • config.resolve_double_buffer: new has_buffer_overlays + audio_reu_pump_active params; auto enables when (not backend_supports_reu) or has_buffer_overlays, gated off under the REU mic pump. Threaded at the build_scene call site (both values already computed there).
  • Tests: new resolve_double_buffer cases (text-overlay-on-REU enables; char modes still excluded; reu-pump gates off; explicit true + pump gated).
  • Docs: CLAUDE.md, c64cast.example.toml, regenerated c64cast.schema.json.
  • New reusable diag: scripts/diags/doublebuffer_tear_ab.py (single- vs double-buffer tear A/B on the U64).

HW verification (U64 @ Cam Link, mhires video + marquee)

Ran the new A/B harness — single-buffer vs the new auto (double-buffer on):

single-buffer double-buffer (new)
host-DMA double-buffer armed (log) @ $C500
top/bottom tear rate 1.3% (6/479) 0.2% (1/479)
host writes 21/s, 50 KiB/s 61/s, 104 KiB/s (well under the ~200/s ceiling)
  • Single-buffer captured the expected structural 3-band raster-split tear on cuts.
  • Double-buffer frames are coherent whole frames; the marquee text is crisp — and stays crisp even across the one residual seam.
  • The 0.2% residual is the documented $D800 percell color-RAM seam (color RAM isn't VIC-banked) — identical to the REU path, and unchanged behavior. hires and static-palette mhires (cheap/grayscale) are fully tear-free.

…verlays

resolve_double_buffer "auto" now enables the host-DMA page-flip not only on
no-REU backends (TeensyROM) but also for a bitmap scene with a buffer-painting
text overlay on a REU backend (the U64). resolve_use_reu_staged already turns
the REU bank-swap OFF for bitmap+text (to dodge the swap shimmer), which left
those scenes on single-buffer host-DMA that tears on scene cuts. The host-DMA
double-buffer (already shipped for the TR) gives them tear-free frames AND
crisp text: its swap IRQ does no in-IRQ DMA, so the $DD00 flip lands in vblank
with no shimmer, and text glyphs live in banked screen RAM so they swap with
the bitmap.

Overlay-free bitmap video on a REU backend stays on the REU path (the better
tear-free option there). Gated off when the REU mic pump is active (it owns
$0314 too, with no merged dispatcher for this pair); never reached on a no-REU
backend, where use_reu_pump is coerced off.

HW-verified on U64 (mhires video + marquee, Cam Link A/B via the new
scripts/diags/doublebuffer_tear_ab.py): the path arms on U64, structural
top/bottom tear rate drops 1.3% -> 0.2% (the residual is the documented $D800
percell color-RAM seam, same as the REU path), and the marquee stays crisp
even across that seam.
@kfox kfox merged commit 1ad2588 into main Jun 24, 2026
6 checks passed
@kfox kfox deleted the feat/hostdma-doublebuffer-u64-overlays branch June 24, 2026 18:44
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.68%. Comparing base (9368258) to head (eda396e).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #43   +/-   ##
=======================================
  Coverage   79.68%   79.68%           
=======================================
  Files          68       68           
  Lines       12941    12943    +2     
  Branches     1909     1910    +1     
=======================================
+ Hits        10312    10314    +2     
  Misses       2190     2190           
  Partials      439      439           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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