98 Commits

Author SHA1 Message Date
ClydeyEXE 1cc7606807 Hold frames to 800 a second with the frame limit off
The main loop passes the engine the real frame delta but never less than
0.0005 s (docs/HISTORY.md, item 21), so past 2,000 fps game time runs faster
than real time. With the frame limit off, the title screen ran about 1,600 fps
and menus about 1,000. With vsync off, the limiter now also holds frames to at
most 800 a second when the limit is off or set higher; a lower limit applies as
before, and vsync on is unaffected. RECOMP_FPS_CEILING=<fps> changes the ceiling,
0 for none.

- Title screen, scale 3: 1,597-1,659 fps without the ceiling, 799.7 with it, p50
  1.2 ms and p99 1.5 ms.
- 7 bots A/B, 3 runs a side, ceiling off vs on: 325.1 vs 327.6 fps (no
  difference), 1% low 6.99 vs 5.73 ms. The scripted match through the menus
  passes.

Refs #28
2026-11-13 20:25:29 +00:00
ClydeyEXE b493f2d240 Make a pixel shader for each register-combiner setup
The general pixel shader reads the combiner setup from constants and works it
out for every pixel: a loop over up to 8 stages, registers in an array indexed
at run time, and a chain of tests per input mapping. At scale 3 it was most of
the GPU's frame. Each draw's setup (stage count, each stage's input, output and
mapping words, the final combiner, texture modes, dot mapping, alpha test, cube
stages) now gets the same source compiled with those words as literals, so the
compiler folds the tests, unrolls the stages and keeps the registers in
registers. Colours, factors, the alpha reference and texture scales stay
constants. Shaders compile on the vertex programs' thread and are kept in
%LOCALAPPDATA%\xboxrecomp\psh; a draw uses the general shader until its setup's
is ready. RECOMP_GPU_PS_SPECIAL=0 keeps the general shader, RECOMP_GPU_PS_FLIP
alternates them, RECOMP_GPU_PS_DUMP writes the HLSL, and [PSH] reports setups.

- A match through the menus makes about 55 setups; cold, 46 compiled in 962 ms
  in all (longest 42 ms), with no added hitches.
- Frames: on the corridor's still pixels, 21 of about 267,000 differ, by 1/255.
  Consecutive frames with 7 bots, alternating the shaders, are clean.
- A/B at scale 3, 3 runs a side, same exe: corridor 324.7 to 545.3 fps (+68%),
  GPU 2.99 to 0.98 ms a frame, 1% low 5.36 to 3.50 ms; 7 bots 288.1 to 329.4 fps
  (+14%), GPU 3.3 to 1.7-2.2 ms, 1% low 7.10 to 4.99 ms, 0.1% low 14.8 to 8.8 ms.
  Menus 116 to 425 fps. 7 bots are now held by the walker.

Refs #28
2026-11-13 19:34:17 +00:00
ClydeyEXE 95a8faac3e Time the GPU by pass and count device-context calls
RECOMP_GPU_TIMING=1 puts a D3D11 timestamp at each change of pass (draws, draws
with a GPU vertex program, clears, the depth encode and decode passes, feedback
and grow copies, the final blit) and of target, read back several frames late
with no wait. Every 10 s [GPUTIME] gives the GPU ms a frame by kind and by target,
and [GPUCALLS] the device-context calls a frame. Off by default.

At scale 3 the GPU takes 3.2 ms a frame in the corridor and 3.3-3.5 ms with 7
bots, nearly all of it draws (the 1920x1440 scene about 2.5 ms of it); clears,
depth passes, copies and the blit come to about 0.02 ms. A test with a trivial
pixel shader in place of the combiner one took it to 0.7 and 1.5 ms (544 and
384 fps), so the combiner shader is most of the frame.

Refs #28
2026-11-13 18:48:46 +00:00
ClydeyEXE 8b926d9117 Cut the walker's per-draw texture hashing, clock reads and method survey
- A texture of 64 KB or less was hashed at every bind to see whether it had
  changed. It is now hashed once per pushbuffer walk (one per PUT kicked), as
  the title can only rewrite it after D3D's Lock waits for the GPU. With 7 bots:
  about 240 hashes a frame down to 95, over 4-7 walks a frame.
- The NV2A busy-bit clear asked the vblank-ack clock (a performance-counter
  read and a 64-bit divide) for each of six registers on every call: every poll
  pass and every 256 pushbuffer words. It now asks once, and only when a vblank
  bit is up.
- The RECOMP_PB_SCAN method inventory was counted for every pushbuffer word on
  every run, but printed only under RECOMP_PB_SCAN. It now counts only then.
- RECOMP_GPU_STATS reports walks.

Walker profile with 7 bots: hash_span 16% to 6%, clock reads 16% to 4%, the
survey 8% to 1%. A/B, 3 runs a side: corridor 297.5 to 299.2 fps (+0.6%), walker
2.31 to 1.77 ms a frame, 0.1% low 12.5 to 9.3 ms; 7 bots 284.3 to 284.9 fps (no
difference), walker 2.85 to 2.67 ms.

Refs #28
2026-11-13 18:01:19 +00:00
ClydeyEXE b9e05bb656 Round an x87 result once when it goes straight to a float store
Where the next instruction stores an x87 result as a float and pops it (fmul; fstp dword, faddp st(1);
fstp dword), the lifter now leaves out the PC=24 rounding and stores with RECOMP_FP_STORE_F: one
float conversion, and the 24-bit rounding only where the float comes out subnormal, where the x87
rounds twice. The stored bits match the unfused code over 96.8M values under PC=24, 53 and 64 (a
plain cast would differ 753,010 times, all in the subnormal range). 7,048 of the 26,047 rounding
sites are fused. RECOMP_FUSE_FLOAT_STORES=0 at regenerate turns this off.

7 bots: recomp_fp_round24 falls from 14.1% to 8.5% of the game thread, and game-thread work a frame
(10 s less its [FENCE] waits, over frames, windows 2-6) from 3.29 to 3.19 ms (ab.py medians). Fps is
unchanged: ab.py --direct --bots 7, 3 runs a side, 289.7 to 285.6 (-1.4%, 95% CI -2.8% to +1.8%);
the game thread spends the saving waiting. Frames match, consecutive frames with 7 bots are clean,
the scripted match through the menus passes with only the known cli/sti, the toolkit's tests pass
(855, three of them new; the conformance suite's 33 trig-precision mismatches were there before) and
so does tests/fp_precision, with new checks for the store.

Refs #32
2026-11-13 17:23:12 +00:00
ClydeyEXE 137f7ed2cb Keep the x87 stack in locals inside generated functions that use it
The x87 stack and its top were still reached through a pointer, so every push and pop loaded the top
again after any guest store, and so did every read of a stack slot. Generated functions that use
x87 now copy the top and the eight slots into locals at entry and after each call, and back before
calls and returns, the same points the integer registers use. The slots stay in memory, indexed by
the top, but in the function's own frame, where guest stores cannot reach them. The one function
that calls the FNSAVE/FRSTOR helpers, which work on the per-thread copy, keeps it shared, as do
functions that call setjmp. 1,643 functions take the local stack; the hottest D3DX function went
from 3,483 to 2,494 host instructions.

ab.py --direct, 7 bots, 3 runs a side, two batches against the previous commit: 273.7 to 293.9 fps
(+7.4%, 95% CI +3.0% to +9.9%) and 269.5 to 299.6 fps (+11.2%, CI +6.6% to +19.8%). Game-thread
work a frame (10 s less its [FENCE] waits, over frames, windows 2-6) 3.63 to 3.22 ms in the first
batch. The lows move within noise: 1% low 7.31 to 7.72 ms in the first batch and 7.73 to 7.01 ms in
the second, 0.1% low 11.3 to 12.4 and 12.3 to 13.3 ms with overlapping ranges. Exe 31.8 to 32.4 MB.
Frames match, consecutive frames with 7 bots are clean, the scripted match through the menus passes
with only the known cli/sti, the toolkit's tests pass (852, two of them new; the conformance suite's
33 trig-precision mismatches were there before) and so does tests/fp_precision.

Refs #32
2026-11-13 15:43:31 +00:00
ClydeyEXE efcad27c71 Keep the guest's integer registers in C locals inside generated functions
With the registers reached through a pointer, MSVC still loaded a register again after every guest
store, since the store might have changed it. tools.recomp now maps eax..edi and esp onto locals of
each generated function, loaded at entry and written back only where something else can see them:
before every call (RECOMP_ABI_CALL, which all direct and indirect calls go through, and tail
calls) and at every return, and read again after each call. Each function writes back only the
registers it can change; compiling the generated code with RECOMP_VERIFY_REG_WRITES makes the rest
read-only, and the full game compiles that way, so no write is missed. Interrupts run on a worker
stack and save and restore the per-thread copies, back-edge preemption only hands the guest CPU to
another thread, and device-register traps decode the host instruction, so none of them needs the
locals written back. A function that calls setjmp keeps them volatile. RECOMP_REGISTER_LOCALS=0 at
regenerate turns this off.

ab.py --direct, 7 bots, 3 runs a side, against the previous commit: 212.6 to 262.3 fps (+23%, 95%
CI +19% to +26%), p99 6.0 to 5.0 ms, 1% low 7.8 to 6.2 ms, 0.1% low 12.0 to 13.1 ms (ranges
overlap). Game-thread work a frame (10 s less its [FENCE] waits, over frames, windows 2-6) 4.6 to
3.75 ms. Exe 29.0 to 31.8 MB. Frames match, consecutive frames with 7 bots are clean, the scripted
match through the menus passes with only the known cli/sti, the toolkit's tests pass (850, five of
them new; the conformance suite's 33 trig-precision mismatches were there before) and so does
tests/fp_precision.

Refs #32
2026-11-13 14:45:38 +00:00
ClydeyEXE 6d26c6121d Reach the guest registers through one pointer each per generated function
Generated code kept the guest registers, the x87 stack and the other per-thread guest state in
thread-local variables, and each access looked up this thread's TLS block first. MSVC repeated that
lookup after every guest store, since a store through a guest pointer might have changed it. Each
generated function now takes the addresses once at entry (RECOMP_STATE_PTRS in the runtime header),
and the chunk files map the state's names onto them. The hottest D3DX function went from 5,556 to
3,557 host instructions, one chunk file from 105k to 96k.

Exe 39.7 to 29.0 MB. ab.py --direct, 7 bots, 3 runs a side: 149.5 to 221.7 fps (+48%, 95% CI +46%
to +51%), p99 9.1 to 5.8 ms, 1% low 10.2 to 7.2 ms, 0.1% low 13.3 to 11.2 ms. The game thread's
work a frame (10 s less its [FENCE] waits, over frames, windows 2-6) is 6.4 to 4.5 ms. Frames
match, consecutive frames with 7 bots are clean, the scripted match through the menus passes with
only the known cli/sti, and the toolkit's tests are unchanged (845 pass; the conformance suite's 33
trig-precision mismatches were there before).

Refs #32
2026-11-13 14:27:55 +00:00
ClydeyEXE bb57de16f9 Add a per-tick state probe and a frame-rate comparison tool
RECOMP_TICK_PROBE=<file> wraps UGameEngine::Tick (sub_000C91B0) and writes
the frame delta, level time and the player's pawn every tick, plus named
properties found through the classes' reflection data.
tools/tick_rates.py boots straight into a match at several RECOMP_FPS_LIMIT
values, plays a fixed pad sequence and tabulates jump, run, dodge, turn,
fire, projectile and clock measures by rate.

Refs #20
2026-11-12 20:46:07 +00:00
ClydeyEXE 5c1b02ef80 Advance KeTickCount in 1 ms steps from the performance counter
The game calibrates seconds per cycle at boot (sub_00068010) by counting
rdtsc cycles while KeTickCount moves 200 ms. The runtime wrote KeTickCount
from GetTickCount(), which moves in ~15.6 ms steps, so the calibration came
out 0.996-1.002x the emulated 733 MHz clock and the level clock and match
timer ran that far off real time, differently every boot. With KeTickCount
counted from the performance counter the calibration is exact (1.00000x in
8 of 8 runs) and the level clock matches host time at every frame rate.

Refs #20
2026-11-12 20:46:06 +00:00
ClydeyEXE 0a3a26f836 Tell players about RivaTuner's overlay stalls in the README
With RivaTuner Statistics Server hooked into the game, about one frame every 9 s took 230-240 ms, even with its
frame limit off. Point players at its detection level and the game's own limiter.

Refs #28
2026-11-12 19:44:32 +00:00
ClydeyEXE 1371caffdb Present with tearing allowed, report frame-time lows, offer a limit under the refresh
With vsync off the swap chain is now made with DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING where Windows
supports it, kept for ResizeBuffers, and presents with DXGI_PRESENT_ALLOW_TEARING, so a window is no
longer held to the display's refresh. RECOMP_PRESENT_TEARING=0 is the old path. ab.py --direct,
corridor, no bots, 3 runs a side, RivaTuner closed: tearing off 164.8-246.9 fps (two of three runs
held at 165 for most windows), on 239.4-246.2, p99 5.3 against 7.7 ms. 7 bots: 143.6 to 149.2 fps
(+3.9%, 95% CI -1% to +10%), 1% low 10.2 ms both. F11 fullscreen (2560x1440) holds 249 fps, and
six screen grabs show no black or broken frames; vsync on still holds 164.7.

[FRAMES] now ends with the 1% and 0.1% lows: the mean time of the slowest 1% and 0.1% of the
window's frames, at least one each. Presenting to the window, a frame is timed from one Present
call to the next, after the limit's wait, rather than from where the walker reaches present, which
made an even 160 fps limit read p99 7.9 ms; it reads 6.3 now. check_run.py parses both forms.
ab.py reports the lows, and its "walker ms" is now the walker's whole CPU time a frame: "other
walker cpu" alone read about -2.2 with GPU vertex programs, as d3d11 and present are wall times.

The panel's frame limits add one about 3% under the display's refresh (160 at 165 Hz), read when
the presenter starts and when the limit is changed. At 160 the 1% low is 6.5 ms against 6.25.

The walker's time in NtUserEnumDisplayDevices is not the game's: prof.py's new --callers finds
RivaTuner's RTSSHooks64.dll calling NvAPI there, and with RivaTuner running a frame took about
235 ms every 9 s, the walker inside Present. With it closed there are none.

Refs #28
2026-11-12 19:43:38 +00:00
ClydeyEXE 2e9ea22dbd Read the guest memory base once per generated function
Every guest memory access adds g_xbox_mem_offset, and as a global it was loaded again after every
guest store: any store might have changed it as far as MSVC could tell. Declaring it const for
generated code changed nothing, and neither did /volatile:iso. tools.recomp now opens each function
with a const local copy, and the chunk files point XBOX_PTR at it after their includes (the runtime
header's inline helpers keep the global). In one chunk file the loads went from 19,235 to 397 and
the host code from 288k to 270k instructions.

Exe 43.7 to 39.7 MB, full build 529 to 488 s. No fps difference measurable: ab.py --direct, 7 bots,
3 runs a side, 137.5 to 146.9 fps (+6.9%, 95% CI -7.7% to +20.8%); the first windows reach the
display's 164 Hz. The game thread's work a frame (10 s less its [FENCE] waits, over frames) is 6.75
to 6.67 ms, median of 13-15 windows a side. Frames match; scripted match through the menus passes.

Refs #3
2026-11-12 17:45:41 +00:00
ClydeyEXE c39c5cd2bf Optimize the generated code's largest functions
MSVC stops optimizing a function past a size limit (C4883, a warning that is off at the default level)
and compiles it as if with /Od: every guest register and flag kept on the stack, the TLS block looked
up again on every register access. 34 generated functions were past it, 19.7 of the exe's 48.7 MB of
code (sub_000FF840: 7.3 KB of guest code, 413 KB of host code). Several are among the game thread's
hottest: sub_000FF840, sub_0014B0C0, sub_00188300, sub_0016D320, sub_001481B0, about a fifth of its
samples with 7 bots.

The game now builds with /d2OptimizeHugeFunctions, which lifts the limit. Alone it made the full build
62 minutes, all of it one file: sub_001BBD30 (26,666 instructions) and sub_001E6070 (14,248) take most
of an hour to optimize. tools.recomp now wraps functions of more than 10,000 instructions in #pragma
optimize("", off), which leaves just those two as they were, and writes RECOMP_UNOPTIMIZED_INSNS into
recomp_funcs.h. CMakeLists.txt adds the flag only when it finds that line, so code generated before
this keeps building in the old time until it is regenerated. Full build 389 to 529 s; exe 53.4 to
43.7 MB.

ab.py --direct, 7 bots, 3 runs a side, against the same code without the flag:
- All 34 optimized: 120.5 to 144.1 fps median (+19.5%, 95% CI +7.3% to +28.1%), p99 11.3 to 10.2 ms.
- The two largest left out (this commit): 112.9 to 143.8 fps (+27.3%, CI +6.3% to +31.6%), p99 11.8
  to 9.4 ms. First 10 s windows 142/125/123 to 148/152/160 fps.
The 166-171 ms game-thread frames these runs had (in sub_000FF840, called from sub_00188150) became
103-107 ms. Frames from the measured view match. Scripted match through the menus: check_run passes.

Refs #3
2026-11-12 17:20:40 +00:00
ClydeyEXE 1d9402e738 Name the game's unnamed functions in profiles, and count exceptions with RECOMP_EXC_STATS
The game's sources had no /Zi, so the PDB named only public functions and an address in a static one took
the name of the public before it. The 5-8% "sscanf" (earlier "printf") of game-thread profiles was
recomp_fp_round24, the x87 PC=24 rounding helper, of which every generated file has its own copy. The game
target now builds with /Zi: full rebuild 381 to 389 s, PDB 4.9 to 32 MB, same code.

tools/prof.py places each address in its function by the exe's .pdata first (a chunk MSVC split off a
function counts as that function), so an address in a function with no name of its own reads
"symbol+0xOFF?" instead of a wrong name. It reads the thread list once a second instead of every sweep:
415 sweeps in 40 s became 1,735. --lines sets how many functions it lists per thread.

RECOMP_EXC_STATS=1 counts every exception from 15 s after start and logs an [EXC] line every 10 s by code,
thread, host address and guest address. With 7 bots: 12,000-19,000 a second, all access violations on
trapped device registers. Most are on the game thread in DirectSound's voice-processor command routine
(sub_002FBDD2, DSOUND section): a free-count poll at 0xFE820010, then about 20 register writes at
0xFE820160 and 0xFE820400-0xFE82043C per call, 5,000-7,600 faults a second. Two guest USB threads fault
on the OHCI registers at 0xFED00000 about 1,500 times a second between them (and the game thread
140); guest threads share the game thread's host core. A bare trapped access costs about 1 us here
before any handler runs.

Refs #3
2026-11-12 15:38:23 +00:00
ClydeyEXE 90777fb579 Run vertex programs on the GPU by default
RECOMP_GPU_VSH=0 keeps them on the CPU. Frames at one spot with the two paths alternating match (mean
difference across paths 0.91 vs 0.75 within one in the corridor, 0.57 vs 0.53 at another spawn, 0.90 vs
0.76 with 7 bots), and bots, projectiles, shields, torches, the fogged sky, the HUD and every menu of the
route look the same on both. In the match every program batch runs on the GPU: there are no
fixed-function batches and no programs that write constants.

ab.py --direct, 3 runs a side, same build, RECOMP_GPU_VSH=0 against 1:
- corridor: 103.0 to 159.2 fps median (+54.6%, 95% CI +53.7% to +55.5%), p99 12.1 to 8.6 ms; the game
  thread's [FENCE] wait for the walker 5.1 to 1.7 ms a frame. The GPU side is held near the 164 Hz display
  (windowed flip model presents at refresh even with vsync off), so the gain is a floor.
- 7 bots: 99.6 to 129.9 fps (+30.4%, CI +20.3% to +35.6%), p99 12.6 to 11.0 ms, [FENCE] wait 2.3 to
  0.02 ms a frame.

Fixes #2
2026-11-12 10:47:34 +00:00
ClydeyEXE 68c487cbbb Compile GPU vertex programs off the walker, per input format, and keep them on disk
A new program no longer stalls the frame it appears in. Shaders compile on a thread of their own at below
normal priority, and until a program's shader is ready its batches take the CPU path. Compiled shaders are
kept in %LOCALAPPDATA%\xboxrecomp\vsh, named by a hash of their whole source, so the next run loads them
at once and a change to the generator makes new names.

The attribute fetch is now written per input format (an aligned float3 is one Load3) instead of one fetch
that decoded every format, so a shader is keyed by its program and its inputs' formats. That took shaders
from 20-30 KB to about 4 KB and FXC from 70-120 ms to 15-20 ms a program.

Corridor, RECOMP_GPU_VSH=1: 49 shaders in 1.6 s of compile thread (was 7 s on the walker); 1,601 batches
went to the CPU while they compiled. The worst frame in the first 10 s is 58 ms, as with the switch off
(57); it was 4.9 s. A second run loaded all 49 from disk. The match ran at 159 fps, p99 8.2 ms.

Refs #2
2026-11-12 10:24:15 +00:00
ClydeyEXE aeb19804f4 Run vertex programs on the GPU behind RECOMP_GPU_VSH=1, and clamp fog per pixel
With RECOMP_GPU_VSH=1 the walker no longer runs vertex programs, clips or culls: it hands the D3D11 back end
the program, its 192 constants, the attribute bytes the batch reads and a triangle list, and the back end
draws it with a vertex shader made from the program. The translator prints the decoded program as plain
HLSL (no D3D-only features, so DXC can take it to SPIR-V later); a prelude fetches attributes from a raw
buffer as fetch_attr does, and an epilogue does what the CPU did before the hand-over (oPos.w 0 reads 1,
the anti-aliasing scale, colour clamps, the fog unit). Clipping is the GPU's: w >= 1e-3 and the near plane
at c[59].z become clip distances, and the rest is the hardware clipper, which interpolates in clip space as
the CPU's clip did. Culling moves to the rasterizer state. Fixed-function and screen-space batches, and
programs that write constants, stay on the CPU; the switch is off by default for now.

The paths disagreed on UC2's sky dome: a far vertex's fog factor of 0 and a behind-the-eye vertex's clamped
1 met in the middle of each clipped triangle on the GPU, while the CPU worked the factor out at the clipped
vertex (sky 113 vs 77 grey). The executor now hands back ends the factor unclamped and the pixel shader
clamps it, as xemu does; with linear fog both orders give the same value. The CPU path's sky is a little
lighter than before (86).

RECOMP_GPU_VSH_FLIP alternates the paths, _SEL bisects by program hash, _CHECK compares attribute reads and
_DUMP writes the HLSL (docs/DEVELOPING.md). Corridor, frames at one spot with the paths alternating every
1.5 s: mean difference 0.91 across paths, 0.75 within one. The match ran at about 158 fps against 104 with
the switch off, but FXC takes about 150 ms a program (45-49 programs, 7 s in all), so a new program still
stalls a frame.

Refs #2
2026-11-12 10:18:34 +00:00
ClydeyEXE c58293f8c5 Stop the bench driver pressing A into the spawn, and look up the spawn hook's caller by function
A quarter to a half of ab.py --direct runs looked like a spawn one start along the corridor (scene 5.3).
It was the same start every time: the rating draws, the PlayerStart and the settled position matched
in hits and misses. A on the "press fire" scoreboard starts a 3-4 s countdown, and A is also jump. The
driver pressed every 2.5 s, so its second press landed on the spawn, and when it came just after it the
player jumped and landed in another pose with the camera set differently for the rest of the run
(31 of 33 misses had a press after the spawn). drive_match.py now presses again only after 6 s, and not
at all once the game logs the spawn rating.

The FRand/Rand hook no longer walks the script stack on every call until the spawn: it reads the
calling UFunction from the FFrame and looks it up in a small cache, and only a RandRange call walks one
frame up (49 walks with 7 bots, 0.34 ms each, was about 270 at 2.1 ms).

Seed 1 corridor view: 31 of 56 runs with no bots and 13 of 14 with 7 before; 12 of 12 and 12 of 12
after, and 6 of 6 in an A/A of 3 a side (100.5-102.2 fps, B/A +0.8%).
2026-11-12 09:16:14 +00:00
ClydeyEXE e4d954dfe0 Log how long the game waits for the walker, and read the APU trace switch once
[FENCE] lines every 10 s give the time the title's main thread spends in D3D's fence wait, by return
address. The wait spins, so a profile shows the main thread as busy while it waits; in the corridor it is
5.7 ms a frame of a ~10 ms frame, mostly present waiting for the frame before last. The APU register-fault
handler read RECOMP_APU_TRACE with getenv on every DirectSound register access (1.6% of the main thread
with bots); it is read once now.
2026-11-12 00:41:52 +00:00
ClydeyEXE 0e2063ae9f Share transform jobs in claimed chunks, and draw each vertex once with an index list
The pool round trip cost the walker as much as the work it spread: it woke every worker and slept until
the last one finished. Now whoever is running, the walker included, claims 16-vertex chunks from a counter;
when none is left the walker closes the job and waits only for workers that got in, and wakes fan out as a
tree. Fewer workers (RECOMP_RASTER_THREADS=8) lost 12.8%, and spinning workers lost about 6%, so neither is
kept. The D3D11 back end now gets each transformed vertex once per draw plus a 32-bit index list
(RECOMP_NO_INDEXED=1 turns it off).

ab.py --direct, corridor: 86.1 to 100.7 fps median (+16.9%, 95% CI +16.4% to +19.2%), p99 14.8 to 12.5 ms;
with 7 bots 80.4 to 95.6 fps (+18.9%). Corridor frames match the old build's.
2026-11-11 23:44:12 +00:00
ClydeyEXE de9996b22c Boot A/B runs straight into the corridor spawn, with no menus or rerolls
ab.py and drive_match.py take --direct: the game boots from RECOMP_CMDLINE into a CTF-Aqueduct match with
no bots and no limits, A skips the logos, and RECOMP_BENCH_SPAWN fixes the spawn. That is a hook on the script
FRand and Rand natives which, only while RatePlayerStart runs, answers from a private seeded sequence, and
turns itself off once the spawn is chosen. Seed 1 is the corridor view in every run so far. A run takes
83-85 s with --secs 60 (about 4 minutes through the menus), and the A/A spread is 1.0% a run (was 3.5%),
so 3 a side detects about 3%. Bench runs force 4:3, so they no longer depend on the saved video settings,
and --bots N gives real load.
2026-11-11 23:02:02 +00:00
ClydeyEXE 3118c84aa0 Update the toolkit to xboxrecomp v0.17.0
Our patches are rebased onto it. Where upstream now does what a patch did, upstream's version is kept: the
DirectSound sequencer-restart hold, and vertex programs decoded once per upload (with our nv2a_vsh_prepare kept
on top, so the transform pool doesn't race the first decode). The lifter fixes cut untranslated instructions
from 83 to 8, and the corridor view runs 10% faster (69.3 to 76.3 fps median, walker 9.45 to 8.21 ms a frame).

Fixes #30
2026-11-11 21:21:47 +00:00
ClydeyEXE ac909ef462 Say that skipping the boot waits applies from the next start 2026-11-07 00:47:03 +00:00
ClydeyEXE b132f77b16 Say which release of the game setup needs 2026-11-07 00:37:42 +00:00
ClydeyEXE 3cd898c44d Keep v0.2.0's release notes with the others v0.3.0 2026-11-07 00:25:19 +00:00
ClydeyEXE 2ad59a3c58 Add v0.3.0's release notes 2026-11-07 00:24:47 +00:00
ClydeyEXE 6858dac851 Stretch the loading screen in widescreen, and bars reach the bottom in every mode
A 16:9 widescreen frame is now shown 4:3 only while a full-screen movie
decodes: the last .xmv opened was from \Movies (attract loop, cutscenes), or
the boot code's player (0x2EE97) is decoding, since the boot logos play after
the loading movie has been opened. "No canvas means a movie" is gone, so the
loading screen (\Textures\Movies\UI_LoadingMovie.xmv) is stretched, as the
owner asked.

The game's bars on the screen's edges stop at y 479, a row a TV's overscan
hid. They now reach the bottom row in 4:3 and 16:9 (stretched) too, at the
owner's request.

Checked on frames: loading screen full width, boot logos and attract movie
4:3, the bottom bar in 4:3 and widescreen. The owner checked a story cutscene
and the pause menu. drive_match passes in 4:3 and 16:9 widescreen.

Fixes #9
2026-11-06 23:59:48 +00:00
ClydeyEXE bf03ec1b43 Show story cutscenes 4:3 in widescreen, with their bars and subtitles in place
Story cutscenes are movies (\Movies\04a_AscPre5.xmv and the like), but the
game draws letterbox bars and typed-out subtitles on a canvas over them, so
"no canvas means a movie" missed them and they were stretched. The game's
CreateFile (sub_00262187) now says whether the last .xmv opened came from
\Movies (full screen: boot logos, attract loop, cutscenes) or
\Textures\Movies (shown in menus), and the decoder (sub_00030570) says one is
playing; both decode from the same callers. While a full-screen one plays,
the picture is pillarboxed and the canvas is not widened, so its bars and
subtitles sit where the 4:3 picture puts them. The canvas time is now noted
on every canvas update, widened or not.

Checked on frames: boot logos and the attract movie 4:3, title screen wide.
drive_match passes in 4:3 and 16:9 widescreen.

Part of #9.
2026-11-06 23:05:34 +00:00
ClydeyEXE 4bddccc7dc Put widescreen kill messages on the right edge, and bars down to the bottom
From the owner's played session: kill messages are right-aligned to x 586
in the 640 layout, and moved to the middle or the right edge by their length.
A line of text (40 pixels high at most) ending at x 582-600 now goes to the
right edge. The game's full-width bars stop at y 479, a row above the bottom
that a TV's overscan hides; in widescreen they now reach it.

Part of #9.
2026-11-06 22:29:44 +00:00
ClydeyEXE 7d14bca0e5 Centre widescreen menus, keep movies 4:3, and fix the crosshair and pop-ups
From a played session with RECOMP_WIDE_LOG=1 (new: logs each flush's
widgets, where they sit and how far they moved):

- Menus (the flush returning to 0x135340) move to the middle whole, at their
  shape, and the HUD's flush is treated the same while a menu is drawn. Their
  background and bars fill the width: vertices at x 639-640 now reach the new
  edge, and pieces on the left edge stay.
- The canvas is no longer reported to the script as 853 wide, only drawn that
  wide. The Begin Match? pop-up is placed from ClipX and the rest in fixed
  pixels, so a wider ClipX pulled it apart.
- The first-person crosshair comes from its own flush (0x9A173), now spread
  with the HUD. Widgets between the top and bottom HUD strips stay with the
  middle (the combo wheel by the crosshair) unless wholly in an outer third.
- Full-screen movies are drawn without the canvas, so a 16:9 widescreen frame
  with no canvas for 250 ms is shown 4:3 with black side bars (boot logos).

drive_match compares menus in the middle 3/4 and the match HUD with its thirds
put back together. It passes in 4:3 and 16:9 widescreen.

Part of #9.
2026-11-06 22:09:42 +00:00
ClydeyEXE cb59439f38 Spread the widescreen HUD to the screen's edges, and open the window 16:9
The Aspect row's third choice is now "16:9 (widescreen)", and the HUD row is
gone. Squeezing the HUD into the middle 4:3 is replaced by a canvas 853 wide:

- The canvas's per-frame update (sub_00099350) makes a 640x480 canvas 480 x
  16/9 wide and maps it onto the whole picture. UC2's HUD and menu script
  place everything in fixed 640x480 pixels, so they keep their shape and lay
  out from the left.
- The canvas flush (sub_00142960) moves vertices on the old right edge
  (x = 640) to the new one, so full-width bars, fades and tints fill the
  screen. For the match HUD only (the flush returning to 0x135302; menus come
  from 0x135340), quads that touch are grouped into widgets, and each stays
  left, moves to the middle or to the right edge by which third its middle is
  in. The crosshair is centred, the radar and scores sit on the right, and the
  scoreboard, wider than 400 pixels, is centred whole.

A plain window now takes the picture's shape when it opens and when Aspect
changes, instead of opening 4:3 and letterboxing 16:9.

Checked on frames from CTF-Aqueduct: main menu, pre-match scoreboard, match
HUD. drive_match passes in 4:3 and 16:9 widescreen.

Part of #9.
2026-11-06 21:25:48 +00:00
ClydeyEXE 1e30b68128 Change the HUD row only in the wider view, and call its other choice stretched
The owner found the HUD stretched in the wider view: the HUD row, right under
Aspect, had been flipped to "full width" (hud_4_3=0 in the settings file),
which is the 4:3 HUD stretched across 16:9. Left/Right on that row changed it
even while it read "with the picture", so it was easy to flip unseen. It now
changes only in the wider view, the choice is named "stretched", and the
settings line in the log says which HUD is on.

Part of #9.
2026-11-06 20:26:46 +00:00
ClydeyEXE fac0f5e8a2 Add a wider 16:9 view, with the HUD kept 4:3 in the middle
The settings panel's Aspect row gains "16:9 (wider view)": the picture is
stretched to 16:9 as before, and the game's scene projection is narrowed by
3/4 across (sub_001379C0, its only caller being the scene set-up), so the
horizontal field of view widens and the vertical one stays. The game inverts
that matrix itself, so its own culling follows. Only 4:3 views are changed;
a square 16.5-degree view is left alone.

A new HUD row keeps the canvas (HUD, menus, scoreboard) in the middle 4:3 by
squeezing the canvas-to-screen matrix for each flush (sub_00142960), or leaves
it full width. 4:3 and "16:9 (stretched)" are unchanged; the default is 4:3.

drive_match.py now saves frames as shown and compares only the middle 4:3
when the HUD is kept there; sheet.py reads its PNG frames.

Part of #9.
2026-11-06 20:04:22 +00:00
ClydeyEXE 4386fb6c71 Copy fewer vertices per triangle in the pushbuffer walker
The near-plane test in raster_xf_clipped copied all three 160-byte vertex
outputs before looking at them, for every triangle, though almost none need
clipping; it now reads them in place and copies only to clip. And each index
of a deduplicated batch no longer copies its vertex back out of the unique
table: the batch keeps pointers instead.

Corridor view on CTF-Aqueduct (tools/ab.py, 3 runs a side): 64.7 to 72.8 fps
median, +12.5% (95% CI +7% to +13%), walker cpu 10.8 to 9.7 ms a frame.
Frames from the view look the same. Part of #1.
2026-11-06 19:43:19 +00:00
ClydeyEXE 68720920a8 Compare two settings or builds over interleaved runs in a fixed heavy view
An idle match's fps depends on where the player spawns: 65 to 158 fps on
CTF-Aqueduct, from at least seven spawn points. tools/ab.py forfeits and
re-enters until the player spawns looking down the long corridor (the heavy
view in #1), measures only windows with nothing moving in view, and reports
each side's median and spread, a bootstrap 95% interval and a Mann-Whitney p.

In that view runs vary by about 3.5%, against about 30% with any spawn. A
same-settings test showed no difference (95% CI -4% to +7%, 3 a side); a
50 fps frame limit on B came out 26% slower (CI 26-28%).

drive_match.py gains the forfeit-and-re-enter step and an optional exe
path; its behaviour for existing callers is unchanged.
2026-11-05 23:19:11 +00:00
ClydeyEXE 8453fdd9d4 Refuse to build while the game is running, as the exe is locked 2026-11-05 20:53:57 +00:00
ClydeyEXE cf20549b85 Record that the driver's window grabs cost the game no measurable fps 2026-11-05 00:13:03 +00:00
ClydeyEXE a76e7d8586 Drive scripted matches by screen state, and check runs from their logs
tools/drive_match.py presses each button only once the screen it is meant
for is up, read from file opens in the log or the game window matched
against local reference frames, and backs out of a wrong menu to retry.
It reached the CTF-Aqueduct match in 6 of 6 final runs at about 49 s,
against about 127 s for the timed route.

tools/check_run.py reads a log and says whether the run worked: match
reached, crash, watchdog as timer or hang, menu and match fps, hitches
and failed opens, with an exit code.

run_match.ps1 no longer sets RECOMP_FLIP_PACING, which skewed match fps.

Fixes #13
2026-11-04 23:10:50 +00:00
ClydeyEXE e29be9332f Suggest an unzip folder named after UC2 2026-11-03 19:46:17 +00:00
ClydeyEXE 9f0d8e03a5 Follow the repository's rename to uc2-recomp
UC2 is the game's usual short name. GitHub redirects the old links; these
now point at the new name, and the log and settings menu name it too. The
exe and the settings file keep their names, so players' settings carry over.
2026-11-03 19:44:36 +00:00
Clydey 2856ebd4b8 Update README.md v0.2.0 2026-11-03 17:28:33 +00:00
Clydey bfb273f00f Update README.md 2026-11-03 17:27:22 +00:00
ClydeyEXE 00982e9ffd Set the version apart at the foot of the settings menu
It sat right under the key hints and read as part of them. It now has a blank line above it, is drawn dimmer, and
reads like the log's first line (ucc2-recomp <version>).
2026-11-03 17:14:40 +00:00
ClydeyEXE 7924f1c182 Add a bug report form
It asks for the version (from the log's first line or the settings menu), the GPU, the settings and the end of
play_log.txt, and repeats that game files are not wanted. Reports get the bug and needs-verification labels.
2026-11-03 16:51:22 +00:00
ClydeyEXE 0580698a1e Add forced anisotropic filtering to the settings menu
A new F1 row, Anisotropic (off, 2x, 4x, 8x, 16x), saved as [video] anisotropy, or RECOMP_ANISOTROPY for one run.
It applies only to samplers the game filters smoothly across mip levels, so the HUD and fonts are unchanged; changing
it remakes the sampler cache on the drawing thread. Off by default, which keeps the game's own filtering.

The menu's bottom line now shows the build's version too.
2026-11-03 16:51:22 +00:00
ClydeyEXE c99226dc81 Stamp the build's version into the log
The first line of play_log.txt is now the version, so a bug report says which build it came from. It is
`git describe` at build time, with "-modified" when tracked files have changes (the toolkit, which always shows as
changed, is left out). A GitHub source zip has no history, so tools/version.txt is filled in by git as the zip is
made (export-subst). The update notice in #22 needs this.
2026-11-03 16:51:22 +00:00
ClydeyEXE eaeda32ce6 Play short sounds from the streaming wave bank, such as the match countdown
The countdown tick (A_Gameplay.Countdown) has its wave in A_Weapon.xwb, the
one streaming wave bank. It fits one packet, so XACT reaches the end of the
data right after issuing its only read and asks whether anything is in flight.
The runtime completes reads before they return, so the packet counted as done
and the stream was ended empty. At that call a packet read but not yet handed
to DirectSound now counts as in flight, as it would be on the Xbox.

Fixes #19
2026-11-03 16:50:02 +00:00
ClydeyEXE b52bf017f3 Say that leaked source and prototype builds aren't used
Refs #24
2026-11-03 16:40:20 +00:00
ClydeyEXE f75674cc20 Carry depth between depth buffers and colour surfaces at one address
Distortion effects (the barrier on Sovereign, cloaked players, explosions)
showed through walls. The game copies its Z24S8 depth buffer, read as an
A8R8G8B8 texture, into a half-size colour surface, then draws the effect's
sprites with that surface as their depth buffer. Here depth lived only in
D3D11 depth buffers, so the read found nothing and the sprites tested against
an empty depth buffer.

Depth buffers are now sampleable. zeta_encode writes a depth buffer into a
render target at its address, in the console's byte layout, when a draw
samples that address; zeta_decode fills a depth buffer from the colour surface
at its address when that was written more recently. RECOMP_ZETA_COPY=0 turns
both off. The draw log now gives each draw's depth buffer and how many pixels
passed its tests.

Confirmed on Sovereign by playing. In a scripted CTF-Aqueduct match the frame
rate is unchanged (44-57 fps against 45-56) with about one depth copy a frame.

Fixes #18
2026-11-03 15:35:00 +00:00