Skip to content

blitter: model the line micro-programs against vAmiga's SlowBlitter#150

Merged
LinuxJedi merged 2 commits into
mainfrom
fix/line-blit-stalls-and-copvbl
Jul 7, 2026
Merged

blitter: model the line micro-programs against vAmiga's SlowBlitter#150
LinuxJedi merged 2 commits into
mainfrom
fix/line-blit-stalls-and-copvbl

Conversation

@LinuxJedi

@LinuxJedi LinuxJedi commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Was stacked on #149 (fix/unified-write-effect-pipeline); #149 has since
MERGED and this branch is rebased onto main (063af0d). The PR now carries
two commits: the line-blit micro-program model and its docs.

Reconciliation with #149 (write-effect overlap)

The original copvbl commit here made the Denise write-effect delay
source-independent from the live beam position. #149 landed the more complete
model: CPU write effects referenced from the granted chip-bus slot
(cpu_custom_access_slot), with per-class delays (Denise-class +4 cck; Agnus
two-cycle class DMACON/BPLxPT/BPLxMOD/SPRxPT +2 cck, vAmiga
recordRegisterChange(DMA_CYCLES(2))). vAmiga's pokeCustom16 positions
correspond to the granted slot, so #149's reference point is the correct one -
in my copvbl probe runs CL's live-beam positions coincided with vAmiga's
pokes, which is the same +2 bus-cycle tail #149 identifies. The copvbl render
commit and the duplicate COPPERLINE_DIAG_CPU_WRITES probe were therefore
DROPPED in favour of #149's implementations: the write-effect delay is applied
exactly once per event, in record_render_write, under #149's two-class
model. The collision-events raw-landing split from the dropped commit was not
re-added: #149 recalibrated the staged collision tests against the delayed
positions and the suite is green on the stack.

Verified on the stack: this branch adds exactly ZERO delta to Agnus/Copper vs
#149 alone (max per-case delta +0.00); #149 itself nets copvbl 236.9 -> 236.4
and coptim 44.2 -> 42.5 vs the pre-#149 main.

Line-blit micro-programs (this PR's work)

The line engine ran a fixed 4-cycle pixel cadence keyed only on USEC.
vAmiga's SlowBlitter has four line micro-programs indexed by the USEB/USEC
pair; now modelled and trace-verified cycle-for-cycle relative to the BLTSIZE
poke (two-sided COPPERLINE_DIAG_BLT_SLOTS / VAMIGA_BLT_PROBE on
bususage1l BC=00, bususage5l BC=10, bususage15l BC=11), stalls included:

  • USEB lines: 6 cycles/pixel with a B fetch (adds only BLTBMOD to BLTBPT) and
    a bare bus-allocation cycle; their terminal BLTDONE micro-cycle is
    BUSIDLE-class (waits for a free bus).
  • Line WRITE_D allocates the bus even when SING suppresses the store (copy
    mode's lockD-busidle rule does not apply in line mode); suppression only
    locks the store, so the minterm/BZERO still see the full inputs (zero1).
  • Line texture = BLTBDAT rotated by the LIVE BSH each pixel (bsh3/bsh4);
    the write-time BLTBDAT latch applies only to the USEB-off copy hold word
    (undocumented1 unchanged).
  • The Bresenham accumulator advances only with USEA (vAmiga doLine).
  • C DMA fetches load BLTCDAT itself; a later USEC-off blit consumes the last
    fetched C word (zero1 blits 7-12).

STATE_VERSION 26 -> 27 (LineBlitState gained use_a/use_b/bpt and the
LB/LBus phases).

Numbers (summed diff% per bucket; pre-#149 main / #149 alone / this branch)

Agnus/Blitter: 1647.6 / 1578.6 / 1535.8 (marginal vs #149: -42.8)

Agnus/Copper: 949.1 / 930.5 / 930.5 (marginal vs #149: 0.00)

Honest residual

The copvbl b/c variants (+1.5pp each under #149's model) and the small
line-mode bususage/bbusy counter-moves are the previously-characterized
interrupt-recognition/CPU beam-phase class: the copvbl1b two-sided trace shows
both emulators landing the copper MOVE INTREQ at (312,$3c), with vAmiga's
handler phase unchanged vs copvbl1 while Copperline's recognition quantizes
to a different instruction boundary (its poll-boundary grid sits ~2 cck
early). A +1 cck copper-INTREQ latch-delay experiment measured strictly worse
(copvbl 247.6 -> 273.6 under the old model), confirming the offset lives in
the CPU instruction grid, not in a recognition constant.

Gates

@LinuxJedi LinuxJedi force-pushed the fix/line-blit-stalls-and-copvbl branch from be09226 to c30311c Compare July 7, 2026 09:29
@LinuxJedi LinuxJedi changed the title blitter: line micro-programs; render: source-independent Denise write-effect delay blitter: line micro-programs vs vAmiga SlowBlitter (stacked on #149) Jul 7, 2026
LinuxJedi added 2 commits July 7, 2026 10:31
Line blits previously ran a fixed four-cycle pixel cadence keyed only on
USEC. Model the USEB/USEC-indexed micro-programs instead, verified
cycle-for-cycle against VAMIGA_BLT_PROBE traces (bususage1l/5l/15l):

- USEB lines take six cycles per pixel: an LB cycle fetches B (adding
  only BLTBMOD to BLTBPT) and a bare LBus cycle allocates the bus with
  no transfer; their terminal BLTDONE cycle is BUSIDLE-class and waits
  for a free bus.
- With USEC set, the line WRITE_D cycle allocates the bus even when
  SING suppresses the store (copy mode's lockD busidle rule does not
  apply in line mode); the suppression only locks the store, so the A
  shifter, minterm and BZERO update still see the full inputs
  (line/zero1).
- The line texture is BLTBDAT rotated by the LIVE BSH each pixel
  (vAmiga HOLD_B re-runs the shifter); the BLTBDAT write-time latch
  applies only to the USEB-off copy hold word (line/bsh3, bsh4).
- The Bresenham error accumulator (BLTAPT's low word) advances only
  while USEA is enabled (vAmiga doLine).
- C DMA fetches load the BLTCDAT register itself, so a later USEC-off
  blit consumes the last fetched C word (line/zero1 blits 7-12).

vAmigaTS: Agnus/Blitter/line 35.02 -> 0.80 summed diff%, timing -6.8,
worst per-case regression +0.87pp (bususage4l group, bounded by the
CPU-write beam-phase class). STATE_VERSION 27: LineBlitState gained
use_a/use_b/bpt and the LB/LBus phases.
Document the USEB/USEC-indexed line micro-programs (six-cycle USEB
pixels, line WRITE_D bus allocation under SING, live-BSH texture,
USEA-gated accumulator, BLTCDAT C-hold) in docs/internals/timing.md and
the COPPERLINE_DIAG_CPU_WRITES knob in docs/debugger/headless.md.
@LinuxJedi LinuxJedi force-pushed the fix/line-blit-stalls-and-copvbl branch from c30311c to 685bd31 Compare July 7, 2026 09:32
@LinuxJedi LinuxJedi changed the title blitter: line micro-programs vs vAmiga SlowBlitter (stacked on #149) blitter: model the line micro-programs against vAmiga's SlowBlitter Jul 7, 2026
@LinuxJedi LinuxJedi merged commit 714c028 into main Jul 7, 2026
7 checks passed
@LinuxJedi LinuxJedi deleted the fix/line-blit-stalls-and-copvbl branch July 7, 2026 09:45
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