After a wait, wait_in read the clock once, before taking the lock of the
frame's count and that of the pipeline's own count, and told both ends
that time. A thread stopped between the read and the lock had its end
told after events with later times, and Waited took the order it was
told as the order of the times (review of pull request 3000):
- andrew-ai: A waits 0-20 ms, B 10-85 ms; with A's end told after B's,
a wait at 86 ms was left 80 ms of 100 instead of 15, and a pipeline
both waited for was charged 20 ms instead of 85;
- merzleckeier: A waits 0-10 ms, B 40-50; with A's end, read at 10,
told after B began, B was left 60 ms instead of 90, the frame had 50
left instead of 80, and the pipeline was charged 50 instead of 20.
Each begin and end is now timed under the lock of the count it goes
into, through a seam (trait Waiting: the clock and the wait; Real in
the title), so a count is told them in the order of their times. Waited
keeps the latest time it has seen and takes an older one as that: an end
gives back nothing, a begin counts nothing twice. The frame's end is
timed right after the pipeline's, before the log lines.
A wait still counts until its end is timed: a thread stopped after its
wait and before it reads the time counts as waiting meanwhile (test
a_wait_counts_until_its_end_is_timed).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shadow lookup and refresh asked for count * max(stride, 24) bytes, past the last box
(two boxes at 0 and 64: 128 bytes where 88 are used). aabb_span takes (count - 1) * stride + 24
with checked arithmetic; a test covers the last box ending at a buffer's end and overflow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- One gate for both halves: supported() also asks for shader model 6.6, and the translator is
told inline ray tracing runs (set_host_inline_rt) only once the DXR manager is made.
- AABB geometries take stride 0 (packed 24-byte boxes) and multiples of 8 of 24 or more, as
DXR does; others are refused.
- A TLAS of instances by pointer (ARRAY_OF_POINTERS) is not built: the remap reads 64-byte
instances in a row.
- Structure copies other than clone and compact are not done (said once).
- A TLAS clone points the heap slots that view the destination at the shared structure.
- The points not fixed here are listed in fork-ray-tracing.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- rq_op: 187 is CandidateWorldToObject3x4 and 188 CommittedObjectToWorld3x4 (they were
swapped; checked against dxc 10.0.26100). the_ray_query_opcodes_are_dxils pins all 35.
- Hardware ray tracing runs only where it can: hwrt::active() (asked for, and a DXR 1.1
manager made) gates the HLE module, the left-out passes, the copy-back rule and the counters;
the translator lifts loops only when the host says it runs inline ray tracing
(set_host_inline_rt, in host_settings and so in the shader cache's key). Elsewhere the title
keeps its own XboxBvhBuilder.dll and the software walk.
- No env write: builder_allowed() is LEONIDA_BVH_BUILDER=1 and not hwrt::active().
- dxr.rs removed (nothing bound its wrappers); TLAS views are kept out of the list views only
with the path on; the off16 diagnostics and the xmem log lines are gone.
- as_sizes split out of alloc_or_reuse_as, with a test; the known gaps are in
fork-ray-tracing.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared frame budget was a reservation: the first recording thread to
wait in a frame took all that was left of it, and every other thread of
that frame (and any thread still on an older frame) got nothing, so its
draw went out without a wait and was dropped as not made. On first starts
(no pipeline book) 400 to 3,600 draws, dispatches and indirect executions
a frame were dropped at the arrival in the world, and the character's
head, drawn by a pass the title runs once, stayed missing for the run.
- The frame's waits are counted once over the threads that wait at the
same time: what passed while at least one thread waited. A thread that
begins to wait while others do is left what is left at that count, so
waits that overlap still cost the frame its budget once; the time a
thread records between two waits is not counted; a thread on an older
frame joins the current frame's waits and opens no budget of its own
(#2601). On by default; LEONIDA_PIPELINE_WAIT_DEADLINE=0 reserves the
frame's budget as before (no effect with LEONIDA_PIPELINE_WAIT_SHARED=0);
LEONIDA_AB can turn it while the title runs.
- A pipeline's own budget (LEONIDA_PIPELINE_WAIT_ONCE) is charged the same
way, the real time once, not the threads' times added up, whatever the
sharing of the frame's budget (LEONIDA_PIPELINE_WAIT_ONCE=0 turns that
budget off).
- The queue a wait moves its pipeline forward in and the budget a
pipeline's waits count against are passed in, so that tests cover them;
one line tells the rules in use at the first wait.
AI-assisted: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In place of -RayTracing (the title's structure builder and software traversal as translated
shaders): the title's XboxBvhBuilder calls become host DXR 1.1 bottom and top levels, and the
traversal loops of its trace programs become inline ray queries.
Ported from trustno1-coder/VIctory-NVIDIA (its #3706; from Leslie-d-a/VIctory-NVIDIA-HWRT 61e389e0
and 5f55bca8, original by dakisback2 ecc49d5b and 72f8316a), GPL-3.0, and fitted to this tree:
- leonida-shader: emit/rayquery.rs wired into lower.rs (the plan, the handles, TLAS root SRVs
t230..t241, the analyses that leave the lifted loops out). A program in the paired form is not
lifted. With LEONIDA_HW_RT=1 the node test of a loop left unlifted misses every node
(emit/intersect.rs bvh_miss): the console structures are never written then.
- leonida-gpu: hwrt.rs (and dxr.rs for its records); list::external with a LEONIDA_THIN op for the
structure work at its place in a title list; the TLAS views in the descriptor heaps;
Deferred::held; the ray queries in the shader cache's entries; counters in the frame log.
- leonida-hle: modules/xboxbvh.rs replaces the exports of the title's XboxBvhBuilder.dll when on.
- With it on the light stand-in stands aside and the passes left out without structures run.
Shader writes are not all copied back as VIctory-NVIDIA does (LEONIDA_HW_RT_COPY_BACK=1 asks for
it): here that stretched and flickered textures and cost 30 to 45 ms a frame.
- F1: HARDWARE RAY TRACING (TRIAL); play scripts: -HardwareRT (frame generation left off with it,
as with -RayTracing); launcher: a checkbox. Docs: fork-ray-tracing.md, README.md, switches.md.
One PC (RTX 4070 12 GB, driver 621.40, Series X profile, no frame generation): 22 to 25 frames a
second against 6 with -RayTracing; the run ended after six minutes with the card's memory full.
Co-authored-by: dakisback2 <90546900+dakisback2@users.noreply.github.com>
Co-authored-by: Leslie-d-a <70692092+Leslie-d-a@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review of 8677729c9 (KelboLive):
- resolution_levers, the loader's only entry to the levers (windows.rs), was not pinned: replacing its apply_levers
call with nothing still passed. A test now calls it with the environment set under a lock and put back, with a
hash that starts as the 1.0.2.1 build's and with another one, and with no lever set.
- A lowest scale with neither a pinned scale nor LEONIDA_OWN_UPSCALER (F1's LOWEST SCALE alone) still took the
lowest as the ceiling. The title's own dynamic resolution rises to max(lowest, 1.0) on Series S whichever way it
is reached, so a lowest scale now has a ceiling of 1.0 too.
Both shown to fail without the fix: dropping the apply_levers call fails the new entry test; the old ceiling fails the
lowest-alone case. cargo test --locked -p leonida-loader --lib with LEONIDA_GAME_DIR: 88 passed; clippy -D warnings
clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of de550f7cb (imShangLi):
- The comment called the pool "the third" of the row at 0x6186250, while the patch is 0x18 further on, which reads as
the fourth. Each row is an 8-byte header followed by its nine sizes from +8 (the copy reads [row + 0x8]), so
0x6186268 is the third size. The comment says so now.
- The README said "above 2/3"; the code wants more than 2/3 + 0.001, so that Series S' own 2/3 (0.6667) keeps the
console's budgets. The README says that now.
No code change. cargo test -p leonida-loader --lib hooks: 15 passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of 0cbc9e93a (KelboLive):
- The budgets followed the lowest scale, so -Lowest 720 on Series S (LEONIDA_RENDER_SCALE_MIN=0.6667) got none.
The title's own upscaler stores its minimum at 0x28f1e78 and its maximum at 0x28f1e87 as max(minimum, f()). f() at
0x1fb4300 is 1.0 on Series S and 2/3 elsewhere. So with that upscaler forced and no pinned scale, Series S may
render up to 1.0 whatever the lowest. The budgets now follow the ceiling:
- a pinned scale is its own ceiling;
- the own upscaler with no pinned scale has a ceiling of 1.0, as with -Lowest or the F1 menu's OWN UPSCALER;
- with neither, the ceiling is the lowest asked for.
- The call sites are covered now. resolution_levers reads the environment (Levers::from_env), checks the build and
calls apply_levers. the_levers_give_series_s_its_budgets_for_the_highest_scale_it_can_reach runs apply_levers on
an image buffer for -Resolution 1080, -Lowest 1080, -Lowest 720, the own upscaler alone, pinned 2/3, a pinned
scale over a lowest one, and FSR alone. It fails when the budgets are dropped from apply_levers, and with the old
floor rule.
cargo test -p leonida-loader --lib: 87 passed. cargo clippy -p leonida-loader --all-targets -- -D warnings: clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The light pass already drops magenta from what the title's probe resolve
left (LEONIDA_AMBIENT_MAGENTA, on). LEONIDA_AMBIENT_GREEN=1 drops a green
far above red and blue, LEONIDA_AMBIENT_BLUE=1 a blue far above green and
above red, with the thresholds of lobomfz/VIctory-xmem 5a60834 (from
coastingVI via dfmbrollins/victory-linux-nvidia, GPL-3.0).
Both are off by default: the garbage was seen on Linux with RADV, not yet
on a Windows driver, and a strongly green or blue light that is real would
be dropped too. A new test compiles the part with every drop on and off;
it fails when a define the shader reads is missing.
On an RX 6800 (Windows 11, driver 32.0.21030.2001) with both on, a
save loaded into the world: the light passes were made with the drops
compiled in, and the picture showed nothing wrong over about 4 minutes.
No frame was compared with them off.
Review of 29016670a (KelboLive):
- The budgets were applied only for a pinned LEONIDA_RENDER_SCALE. -Lowest 1080 on Series S sets
LEONIDA_RENDER_SCALE_MIN to 1.0, and the title renders at or above it. The minimum path now applies them too.
- They are written by series_s_budgets through apply_all, so a build where one place differs keeps the console's
own pair instead of a raised pool alone.
- the_series_s_budgets_are_written_both_or_neither writes them into an image buffer:
- both are written at 1.0 and at 0.75, and neither at 2/3 or 0.5;
- neither is written when the heap's place holds other bytes.
With the helper made to write nothing, it fails.
- The game-step test has its doc comment back. The threshold test is named for both budgets.
- The README says -Lowest is covered.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEONIDA_SKIP_BINK=1 skips the movies that play once (logos, the intro);
=all skips the looping ones too (menu backgrounds, which then stay dark).
Unset, nothing changes and no import is bound anew.
The title's Bink DLL still opens every movie. The exports a player loop
calls on an open movie (BinkWait, BinkDoFrame*, BinkNextFrame, BinkGoto,
BinkShouldSkip, BinkClose) are bound to wrappers that put a skipped movie
on its last frame and keep it from reaching the DLL, so the title's own
end-of-movie check closes it. The executable's imports and those of DLLs
the title loads later go through the wrapper; GetProcAddress does not.
The technique is from fxceless/victory-fork (pull request 613, by
C-GDev), as carried by trustno1-coder/VIctory-NVIDIA and
lobomfz/VIctory-xmem 0a4aadf (GPL-3.0); written anew for this loader.
Checked on an RX 6800 (Windows 11, driver 32.0.21030.2001): with =1 all
eight wrapped exports the executable imports from Bink2Scarlett.dll are
bound to the wrappers. Booting with no save and pressing Enter, the first
movie (3840x2160, 450 frames, not looping) was skipped and the title went
on to its setup screen. The unit test fails when the wrappers are not
bound.
Series S at render scale 1.0 (1080p, `-SeriesS -Resolution 1080`, `play-S-1080p.ps1`) stopped the title at its own
breakpoint as soon as it started. The README listed it as "does not work yet". The title sizes two memory budgets per
console, both for Series S' own 2/3 scale, and at 1.0 each in turn is too small:
- The render-target pool, the third of nine pool sizes in the per-console table in .rdata: 1277 MiB on Series S,
2199 MiB on the others. Its allocator treats a failed allocation as fatal, and a 1 MiB one failed.
- A heap counted in 64 KiB pages, `mov eax, 0x1290` then `cmovne` with 0x2c60: 297 MiB on Series S, 710 MiB on the
others. A check compares a 432 MiB resource with it and stops at a breakpoint.
With a pinned render scale above 2/3, resolution_levers now writes the other consoles' sizes into both places. Only
Series S' row and its immediate change; the other consoles already hold such a scale. The retail-bytes test checks
both places and the other consoles' pool size.
RTX 3060, driver 621.40: Series S at 1080p ran five minutes into the world, rendering 1920x1080, at 11-22 fps, with
no crash. Before, it stopped about 8 s in, once at each budget.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- shadow.rs: wc_subrange_no_back (f85d1790a, by hardly-relevant) is on
unless LEONIDA_WC_SUBRANGE_NO_BACK=0. The copy the compares behind
submissions go over most, 147 MB of the 32-bit graphics heap four times a
frame, spans its 47 MB write-combined part (0x2404) and its 100 MB cached
one; the whole-copy rule (LEONIDA_WC_NO_BACK) never took it.
- findings.md: the measurements.
Standing at the waterside save, Series X, 1,080 to 1,440 lines, no
generated frames, by turns of 4 s (run d317, 55 phases): the card busy
-0.99 +-0.40 ms a frame, the submitting thread -0.99 +-0.40, the frame's
median -0.68 +-0.61, means -0.48 +-0.68. Recorded tour (d318, 581 frames):
49 frames with one-frame cells, 79 cells, all where the camera swings, as in
the tours before; nothing torn.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: the runs
above; cargo check with diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- shadow.rs: window_mapped_for stopped making windows in card memory the
CPU maps at 80 hundredths of the card's budget, a fixed line. On this PC,
where other programs held 4.4 GB of the 16 GB card, the line kept 1.7 GB of
windows in the PC's memory with a 6 GB cap (run d314).
LEONIDA_WINDOWS_BAR_LINE sets it (50 to 97), to measure what those windows
cost read over the bus. Nothing changes without it.
- findings.md: windows up to 6 GB (d314: 39 more windows there, the line
stopped the rest; PCIe 3.9 GB/s received and 5.1 sent at the median), and
the paired form for 16 of the heaviest single compute passes (d312 against
d316: no clear gain, not taken).
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: the runs
named; cargo check with and without diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- draw.rs: LEONIDA_BATCH_HEAP_READS is on unless set to 0. stores_bound
already says no of every store through a picked view, so the extra rule
only kept batches from staying open past programs that read through
picked views: the 934 CS_RaytracingResolve dispatches a frame (and the
meshlet culling passes, which store their records through views their
binds declare and now end a batch for those records alone).
- findings.md: the measurements; switches.md regenerated (with the
switches of the main commits merged before).
Standing at the waterside save, Series X, 1,080 to 1,440 lines, no
generated frames: 175 to 186 batch passes a frame against 928 (run d311
against d275, LEONIDA_BATCH_WHY), 8 of them ended for stores not declared
(793 before). By turns of 4 s (run d310, 53 phases): the frame's median
-2.11 +-0.69 ms, means -1.86 +-0.86, the card busy -3.67 +-0.43, the
submitting thread +0.48 +-0.73. Timing run (d312): the card's timed work
60.5 ms a frame against 63.2. Recorded tour (d313, 520 frames): 37 frames
with one-frame cells, 67 cells, all in fast turns, at the low end of the
tours before; terrain, foliage, the house and the player drawn.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: the runs
above; the batched clamp's WARP tests; cargo check with and without
diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>