Commit Graph

18350 Commits

Author SHA1 Message Date
b291426966 Merge origin/main (f9f3ec4c6) into the carry of #2031
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: Ilyass Roussi <76879547+IlyassRS3@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:29:22 +01:00
bede3ad0d3 Merge origin/main (f9f3ec4c6) into the carry of #2062
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: Galaxy <23423870+thegalaxydev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:29:20 +01:00
0590fe2777 Merge origin/main (f9f3ec4c6) into the carry of #2173
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: quartz-heron-58 <245169279+quartz-heron-58@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:29:05 +01:00
5b34dc36fd Merge origin/main (f9f3ec4c6) into the carry of #65
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: tiagonogueiraa-bit <360313680+tiagonogueiraa-bit@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:28:57 +01:00
d92dc7a4aa Merge origin/main (f9f3ec4c6) into the carry of #279
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: Zilumz1 <221744236+Zilumz1@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:24 +01:00
af0e265607 Merge origin/main (f9f3ec4c6) into the carry of #282
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: totonii <totonicontato@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:23 +01:00
e7d32a034a Merge origin/main (f9f3ec4c6) into the carry of #1994
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: ShotTechOp <anurag7870977875@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:22 +01:00
c06660c318 Merge origin/main (f9f3ec4c6) into the carry of #1906
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: Jordan <44410206+JordanWebDev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:21 +01:00
5eed9c43d5 Merge origin/main (f9f3ec4c6) into the carry of #1907
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: Jordan <44410206+JordanWebDev@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:21 +01:00
57f3a3c1c5 Merge origin/main (f9f3ec4c6) into the carry of #2093
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: JARVIX <273200855+jarvixaiassistant-glitch@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:20 +01:00
105dd3a37b Merge origin/main (f9f3ec4c6) into the carry of #1406
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: abdoulaahmad <104858675+abdoulaahmad@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:19 +01:00
c3f63575a2 Merge origin/main (f9f3ec4c6) into the carry of #1726
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: TanmaySatyam <lavidivwaker@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:18 +01:00
4bc552caf1 Merge origin/main (f9f3ec4c6) into the carry of #2130
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: d7ommy <abnalstlll@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:17 +01:00
f216975939 Merge origin/main (f9f3ec4c6) into the carry of #1050
Current main after #2566; no new conflicts on top of the earlier carry merge.

Co-authored-by: Gavin Bloom <g4v1nbl00mt4mu29@tamu.edu>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:19:16 +01:00
f9f3ec4c68 README: the RX 6800's frame rates, the indexed heap spans, prompts picked at the start and where shaders still stutter 2026-11-30 07:57:06 -05:00
8b46b96cee Findings: a steady frame's chain on the latest build; the list threads' three switches by turns again
Timelines of run d216: the chain is the title's threads, our list threads' ExecuteIndirect calls and, in other
frames, DirectStorage's inflating and threads waiting for a core. LEONIDA_VIEW_CACHE, LEONIDA_CONTENT_TABLES and
LEONIDA_ALIAS_QUICK by turns (d217, d218): none moves the frame; they stay off.

AI-assisted (Claude). Tested on an RTX 4060 Ti, driver 616.64 (Windows 11), Series X profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 07:54:56 -05:00
497bdd0391 Merge origin/main into next (BC7 and BCn block post-processing, measuring docs) 2026-11-30 07:23:56 -05:00
4f21bdb49b Findings: the texture queue kept by due frame takes 1.2 ms off the textures' part of the list ahead
Runs d214/d215 (the list ahead recorded by one thread, sampled the same way): the textures' part 4.64 -> 3.40 ms a
frame, the walk for due slots 2.6 -> 0.3 % of the thread's samples, the whole list 8.98 -> 7.80 ms.

AI-assisted (Claude). Tested on an RTX 4060 Ti, driver 616.64 (Windows 11), Series X profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 07:23:46 -05:00
22cd4ae248 Merge branch 'main' into d3d12-bar-windows-warning 2026-11-30 13:22:26 +01:00
97a7ae7f34 Merge pull request #2715 from bobcatchris/perf/d3d12-formats-bcn-post
D3D12-FORMATS-BCN-POST-SWAR: eight-byte-wide BC1/BC3/BC4/BC5 block loop after the BCPack lanes (1.1-1.3x)
2026-11-30 13:21:51 +01:00
df151972cc Merge pull request #2714 from bobcatchris/perf/d3d12-formats-bc7-post-luts
D3D12-FORMATS-BC7-POST-LUTS: 2.4x faster BCPack BC7 block loop (index tables, one put per field)
2026-11-30 13:21:38 +01:00
6619d92942 Merge branch 'main' into d3d12-pool-grow-unlocked 2026-11-30 13:21:12 +01:00
ba3ea1e06c Merge branch 'main' into d3d12-land-pool-limit 2026-11-30 13:21:07 +01:00
8421f9b95c Merge pull request #2711 from MoonEyes/docs/measuring-ab-values
docs: a switch with a value needs it beside LEONIDA_AB (DOCS-D3D12-MEASURING)
2026-11-30 13:17:50 +01:00
716fc15d79 The texture queue keeps its slots by the frame they fall due: a pass takes those without a walk over all
A heap keeps some 25,000 slots waiting for their memory in the queue of textures picked by index, of which 100 to
470 fall due a frame, and every pass walked all of them twice under the queue's lock (the due ones, then the census
for the frame line): 2.6 % of the thread that records the list ahead of each frame, more than any other function of
its textures' part (profile ahead-d214, the merged build). The queue now keeps a set by due frame with every change
of a slot's due frame, and the counts of slots waiting for their memory and uploaded in part with every change of
what a slot waits as; the order a pass serves them in is the writes' as before.

AI-assisted (Claude). Tested on an RTX 4060 Ti, driver 616.64 (Windows 11): descriptor::host::tests (49) and the
queue tests pass; the pass's time is read in a standing run next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 07:14:11 -05:00
6a206d82c4 Merge main (d367675c7) into fix/safecopy-guard-rearm 2026-11-30 13:08:27 +01:00
ec1d858463 Findings: main's indexed heap spans take 1.6 ms off the frame here; what ends the indirect batches now
LEONIDA_INDEX_HEAP_SPANS by turns on the merged build (d212, d213): the frame's median -1.64 and -1.61 ms. With
LEONIDA_BATCH_WHY=1 (d211): 785-841 of 926-988 batches a frame end for programs that store through views they pick
from the heap, the culling passes that write the records first.

AI-assisted (Claude). Tested on an RTX 4060 Ti, driver 616.64 (Windows 11), Series X profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 07:02:52 -05:00
f536b3d508 leonida-formats: eight-byte-wide BC1/BC3/BC4/BC5 block post-processing (D3D12-FORMATS-BCN-POST-SWAR)
After the rANS lanes the plain formats' block loop did its arithmetic a
byte at a time: a per-element wrapping add and width mask for each of 8
endpoints and 32 indices, 16 scattered byte stores per quad/pair
residual, a table lookup and shift per index to build the BC1/BC4 code
words, and two 4-step folds per interleave().

- Widths holds the masks of the elements' bits (a word for the
  endpoints, four for the indices); endpoints and indices are summed
  with their references eight bytes at a time (top bits added apart for
  the 8-bit endpoints, masked sums for the at most 7-bit indices).
- quads() takes a 256-entry const table and fills the four 4-pixel rows
  as words; pairs() builds eight pixels at a time.
- BC1 and BC4 index codes are computed for eight indices at once
  (bc1_codes, bc4_codes) and packed by shifts (pack2, pack3).
- interleave() reads a 16-entry const table.

Output is unchanged: a copy of the previous loop is kept in the tests as
the reference, and plain_blocks_match_the_reference compares the two
byte for byte for BC1, 3, 4 and 5 on the shipped tables and on tables
whose ranks and dictionaries hold any byte (history wrapping).
index_codes_are_the_tables and index_codes_pack_by_position check the
new code words and packers against the code tables for every byte.

AI-assisted: Claude Sonnet 5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-30 06:01:21 -06:00
e5f9f3b47a leonida-formats: table-driven BC7 index residuals and packing (D3D12-FORMATS-BC7-POST-LUTS)
The BC7 block loop of the BCPack decoder took 100-155 ns a block on top
of the rANS lanes: every index residual was rebuilt bit by bit (two
4-iteration folds per byte), each index went through an add_index with
per-element branches, endpoint residuals were done a column at a time and
bc7_pack made about 45 Bits::put calls on a u128.

- nibbles() reads a 256-entry table (also used by BC6H).
- The sixteen indices of a set are added to the reference's in one pass
  with the shifts hoisted out of the loop (bc7_indices).
- Endpoint residuals of a row go through one multiply-by-precision per
  column instead of a masked shift per column.
- bc7_pack puts each channel's endpoints, the p-bits and each index set
  with one put, taking an anchor's top bit out of the fixed-width fields
  afterwards.

Output is unchanged: a copy of the previous block loop is kept in the
tests as the reference, and bc7_blocks_match_the_reference compares the
two byte for byte on the shipped tables and on tables with arbitrary
control words, dictionaries and reference widths (history wrapping), and
on the error of an unused control code.

AI-assisted: Claude Sonnet 5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-30 05:44:42 -06:00
61945356f4 Merge main (d367675c7) into fix/wave-sections-unmatched-saveexec 2026-11-30 12:41:44 +01:00
cac02673d0 Merge origin/main into next (indexed heap buffer spans, the runtime's commit storms, measuring docs, tools)
draw.rs: heap_buffer_pass takes main's snapshot of the spans (SweepState with the indexed backend, d367675c7);
this branch's change to the legacy backend's parts (a slot that shows each copy, 2a1e66b15) stays under it.
heap_range_tests and heap_sweep_tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 06:35:20 -05:00
1271b2433b Merge remote-tracking branch 'origin/main' into tests/lds-src2-mc-stdin
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 12:34:19 +01:00
8a2736fe6a Merge remote-tracking branch 'origin/main' into tools/chain-check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 12:33:59 +01:00
e187014f7c Merge remote-tracking branch 'origin/main' into feat/picture-metrics
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 12:33:46 +01:00
47cbe15d9c Merge remote-tracking branch 'origin/main' into port/nv-vram-target-reserve-settle
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 12:33:07 +01:00
a2219a9374 Findings: night tours with and without the card's steps, the list threads and the heap pass sampled again
Runs d204/d205 (the standard tour at 23:00): no torn frames either way; the card's steps stay. Profile list-d207:
ExecuteIndirect is binding, and over half the list threads' contended waits were the placed textures' one lock;
LEONIDA_PLACED_SHARDS by turns (d209, d210): the frame does not move. Profile ahead-d208 against ahead-d201: the
spans' holds were not the pass's cost; the walk over the parts' slots is.

AI-assisted (Claude). Tested on an RTX 4060 Ti, driver 616.64 (Windows 11), Series X profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 06:32:48 -05:00
be3f75821a Merge current main to recheck launcher CI
Bring the launcher change onto the current base, including the F16 reference test fix from #2633.
2026-11-30 12:24:34 +01:00
45d09e2d90 d3d12: align back_piece scalar benchmark arm with main
AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:18:21 -06:00
04d40581da d3d12: add AVX2 fast paths for shadow merge_piece, back_piece, and changed_runs
AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:18:21 -06:00
7305728f5b leonida-gpu: reuse thread-local before snapshot buffer in texback::write (D3D12-GPU-TEXBACK-REUSE-BEFORE)
texback::write() already kept a thread-local TILED buffer (capped at 32 MiB)
to avoid per-landing heap allocations, but still allocated and freed a fresh
`let mut before = Vec::new()` on every LEONIDA_COPY_BACK read-back (~22/frame
in gameplay) to diff 4 KiB pages.

Pair `before` with `tiled` in a single thread-local SCRATCH `(Vec<u8>, Vec<u8>)`
(both capped at KEPT = 32 MiB) so copy read-backs reuse their snapshot buffer
without repeated multi-MB allocations/page faults.

AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:18:20 -06:00
74fdec2bf0 d3d12-formats: use stack buffer for small texture chunk_offsets
AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:18:19 -06:00
af46ed20c8 leonida-formats: pre-divided u32 chunk offsets & bounds-hoisted copy in Layout::walk (D3D12-FORMATS-TEXTURE-FAST-WALK)
Speed up Layout::detile and Layout::tile (hot on texture refreshes and
async texture read-backs) by:
- Pre-dividing uniform chunk offsets into a compact Vec<u32> (4 B vs 24 B
  per run, 6x less L1 cache traffic per row).
- Checking `base + max_chunk_off < tiled.len()` once per row so the inner
  loop copies without per-chunk bounds checks or per-chunk divisions.
- Specializing 4-byte and 64-byte chunk sizes alongside 8, 16, and 32.

Measured --release A/B on Ryzen 7 7800X3D across 8 64KB_S/64KB_D layouts:
detile +21.6% to +74.3% (1.22x-1.74x), tile +5.8% to +62.7% (1.06x-1.63x),
with zero regressions and 41/41 leonida-formats tests passing.

AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:18:19 -06:00
782c93512f leonida-formats: add branchless AVX2 model lookup for BCPack rANS lanes (D3D12-FORMATS-BCPACK-FAST-LANES)
DirectStorage texture streaming runs BCPack decompression on the frame's
streaming critical path (d3d12/docs/findings.md). Previously, every
decoded rANS symbol performed four separate 2-D table lookups (freq,
start, 256-entry bucket window, recip), a while-loop bucket scan, an
if b == 0 branch, and a Result<(), Error> check even though Lane::step
is infallible.

Pack per-model decode parameters into a 64-byte-aligned Model struct
with pre-adjusted b == 0 entries (eliminating the if b == 0 branch),
add a runtime-detected AVX2 single-register vpcmpgtd + movemask +
count_ones bucket lookup (dispatched once per lanes() call), and remove
the unused Result wrapper from Lane::step.

Verified exhaustively across all 3 x 128 x 65,536 = 25,165,824
(table, model, slot) pairs against the reference scan and across all 6
BC lane layouts.

Measured --release bcpack_throughput (Ryzen 7 7800X3D, 16,384 blocks x 40):
- BC1: 86.3 -> 94.7 MB out/s (92.7 -> 84.4 ns/block, +9.7%)
- BC4: 83.0 -> 93.8 MB out/s (96.4 -> 85.3 ns/block, +13.0%)
- BC7: 49.7 -> 53.3 MB out/s (322.0 -> 300.3 ns/block, +7.2%)

AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:18:16 -06:00
08a1cc4a02 leonida-gpu: add AVX2 fast path for 32-byte descriptor changed_records (D3D12-GPU-CHANGED-RECORDS-AVX2)
changed_records() scans ~400,000 32-byte descriptor slots per frame
(mirroring ~40,000, d3d12/docs/findings.md). Previously, any dirty
512-byte chunk ran memcmp on the 16-record block and then ran 16
individual memcmp + memcpy calls.

Add a runtime-detected AVX2 fast path for step == 32 that loads four
32-byte records (128 bytes) into ymm registers, checks all four with a
single combined vpcmpeqb + vpand + vpmovmskb branch, and on mismatch
stores the already-loaded new ymm vectors directly with
_mm256_storeu_si256 (avoiding the double-scan and memcpy calls).

Measured in --release on Ryzen 7 7800X3D (400k x 32-byte slots, 50
rounds, bit-exact parity verified):
- 0% dirty:   325.9 -> 309.8 us/frame (1.05x)
- 10% dirty:  432.5 -> 325.9 us/frame (1.33x)
- 100% dirty: 611.3 -> 485.1 us/frame (1.26x)

AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:18:03 -06:00
0f8f57b6a0 leonida-shader: hoist uniform createHandleFromHeap out of branches and loops (D3D12-SHADER-OPT-HOIST-HEAP-HANDLES)
Addresses the d3d12/docs/findings.md item ("descriptors made again in
every branch of a program (createHandleFromHeap of an index that is a
root constant plus an offset, behind a branch on a load)").

Adds Module::hoist_handles() under REUSE: marks uniform (nonuniform =
false) dx.op.createHandleFromHeap calls, their wrapping annotateHandle
calls, and their pure, non-trapping index/clamp operands
(cbufferLoadLegacy, integer non-div/rem arithmetic, casts, extracts,
dx.op.binary.i32 clamp), and hoists each in RPO order to the deepest
dominating block defining its operands. REUSE then collapses duplicate
handles across sibling branches and loops into a single descriptor
handle.

Nonuniform handles and handles whose index depends on branch-local
memory loads remain in their original blocks.

AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:18:00 -06:00
903e3731ec leonida-shader: skip wave_base entry ticket barrier and LDS atomic for 1-D groups (D3D12-SHADER-1D-WAVE-BASE-NO-TICKET)
Addresses the d3d12/docs/findings.md item ("the entry ticket of every
console wave64 program with lane code (a group barrier and an LDS
atomic, also for groups of one dimension, where the host's waves are
runs of consecutive ids)").

For 1-D host groups (threads[1] == 1 && threads[2] == 1, including all
multi-wave paired groups which are lowered as [32 * waves, 1, 1]), each
host wave already receives a consecutive run of flat thread IDs. Derive
each wave's console thread base directly from
waveReadLaneFirst(flattenedThreadIdInGroup) & !(wave - 1) (shifted left
by 1 for paired groups) instead of allocating an LDS counter dword and
emitting an entry group_sync + atomicrmw add.

2-D and 3-D groups keep the LDS counter path unchanged.

AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:17:59 -06:00
bb68c6e198 leonida-shader: gate LOADS key() on Reads|Lanes and make diamond test SSA-valid
AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:17:58 -06:00
87d528fe9a leonida-shader: propagate LOADS across dominating write-free blocks (D3D12-SHADER-OPT-CROSS-BLOCK-LOADS)
Addresses the d3d12/docs/findings.md item ("reads of read-only views
repeated in blocks that follow one another").

Previously, merge() cleared the LOADS map at every basic-block boundary,
preventing reuse of Effect::Reads across sequential blocks,
single-predecessor branch targets, and write-free diamonds or loops.

Extend merge() to maintain dominator-scoped dom_reads for Effect::Reads
while keeping Effect::Lanes (wave/quad operations) strictly block-local:
- Single-predecessor blocks inherit dom_reads directly from their
  immediate dominator (O(1)).
- Multi-predecessor blocks (merges and loop headers) run a reverse walk
  back to the immediate dominator and preserve dom_reads only when no
  block on any path (including loop back-edges) executes Effect::Writes.
- Any Effect::Writes instruction clears dom_reads for the rest of its
  block and dominator subtree, restoring the pre-block map on Leave so
  siblings remain unaffected.

Verified with 3 new Red -> Green unit tests (write-free diamond,
branch-write invalidation + sibling reuse, loop back-edge write vs
write-free loop), the 400-seed randomized differential interpreter suite,
and 370/370 leonida-shader --lib tests on native Windows 11 + AMD Radeon
RX 7900 XTX.

AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:17:58 -06:00
24b7bf5f97 D3D12-HLE-APU-HANDLE-LIFETIME-AND-ALIGNMENT: track live APU handles and use unaligned FFI access 2026-11-30 05:17:52 -06:00
d29dfbc494 leonida-loader: tolerate Windows AccessDenied in publish::write_if_changed when destination already matches
On Windows, renaming a staging file over a destination already opened or
mapped by a peer runner (without FILE_SHARE_DELETE) fails with
ERROR_ACCESS_DENIED (os error 5). When the destination already holds the
exact bytes being published, remove the staging file and return Ok(()),
while continuing to propagate errors when the destination is missing or
holds different bytes.

Includes deterministic Windows unit tests for both matching and
non-matching locked destinations.

AI-assisted: Antigravity (Gemini 4 Neon)
2026-11-30 05:17:51 -06:00