Commit Graph

1240 Commits

Author SHA1 Message Date
cd413b45c5 Merge pull request #2056 from IlyassRS3/rt/code-hooks-thunk-leak-and-granularity-guards
runtime: free unused thunk on zero redirects and harden code_hooks bounds
2026-11-28 19:13:40 +01:00
57c0596158 Merge pull request #2058 from IlyassRS3/rt/thread-stacks-bounds-and-wrap-guards
runtime: guard stack region wrap/underflow and null inputs in thread_stacks
2026-11-28 19:13:17 +01:00
5155410dba Merge pull request #2061 from abnalstlll-byte/feat/rt-pipeline-cache-file-guards-and-tests
runtime: guard empty destination and null data in write_pipeline_cache_file and add tests (RT-PIPELINE-CACHE-FILE-GUARDS-AND-TESTS)
2026-11-28 19:12:54 +01:00
dc93dd3c18 Merge pull request #2087 from alexandersato0830/codex/frame-pacer-early-origin
Keep current frame-token statistics at or before the poll (FRAME-PACER-EARLY-ORIGIN)
2026-11-28 19:11:47 +01:00
4b9ab72960 Merge pull request #2290 from narekshaghoyandev/ubiq-buffer-va-index-signed-max-id
buffer_va_index: use numeric_limits<Id>::max() in max_id() for signed Id types
2026-11-28 19:11:25 +01:00
c075067c31 Merge pull request #2307 from narekshaghoyandev/ubiq-pipeline-journal-null-and-kind
pipeline_cache_journal: guard null bytes/kind and avoid entry_path truncation
2026-11-28 19:11:02 +01:00
44c11a550f Merge pull request #2327 from narekshaghoyandev/ubiq-dev-overlay-phase-for
dev_overlay: avoid float-to-int overflow UB when formatting phase_for
2026-11-28 19:10:40 +01:00
7daa4a4a51 Merge pull request #664 from sodove/perf/pe-block-reads
runtime: read PE files in blocks (RT-PE-BLOCK-READ)
2026-11-28 18:59:07 +01:00
2bf1a934b6 Merge pull request #1651 from Tortoche/old-9881
OLD-9881: subgroup_size: reject half-zero and invalid subgroup size ranges
2026-11-28 18:57:57 +01:00
3b19f8a72a Merge pull request #1715 from kawaii-shakal/bcpack-bc7-partial
dstorage: rebuild a BC6H/BC7 request with a few lost blocks instead of failing it (BCPACK-LOST-BLOCK-LIMIT)
2026-11-28 18:57:33 +01:00
6d7e215f1b Merge pull request #1821 from IlyassRS3/fix/rt-pipeline-workers-oom-uaf
runtime: fix PipelineWorkers stack use-after-free on OOM in start() (RT-PIPELINE-WORKERS-OOM-UAF)
2026-11-28 18:57:12 +01:00
2d7ce9c882 Merge pull request #1961 from IlyassRS3/fix/rt-dual-source-fragment-perf-and-dup-loc
runtime: refuse duplicate Location 1 outputs and avoid full-body RB-tree scan in dual_source_fragment
2026-11-28 18:56:50 +01:00
3f2090f5ef Merge pull request #1975 from IlyassRS3/fix/rt-image-memory-unlock-alloc-and-overflow
runtime: unlock ImageMemoryPool across driver allocations/frees and fix BlockRanges alignment overflow
2026-11-28 18:56:28 +01:00
e308f5cb5d Merge pull request #1982 from IlyassRS3/perf/rt-conservative-raster-preamble-stop
runtime: stop inner_coverage_requirements scan at SPIR-V preamble boundary (RT-CONSERVATIVE-RASTER-PREAMBLE-STOP)
2026-11-28 18:55:48 +01:00
98f829dd40 Merge pull request #1992 from lgr123/lgr123/frame-interval-pending-vblank
Rebase pending flips when the frame interval changes
2026-11-28 18:55:26 +01:00
6b3d76df28 Merge pull request #2002 from IlyassRS3/fix/rt-xdxr-build-layout-empty-and-dispatch-guards
runtime: guard XdxrBuilder empty dispatches, layout failure reset, and pipeline cleanup (RT-XDXR-BUILD-LAYOUT-EMPTY-AND-DISPATCH-GUARDS)
2026-11-28 18:55:05 +01:00
bfbd6af341 Merge pull request #2025 from IlyassRS3/perf/rt-retire-tickets-early-break-and-sem-cache
runtime: early-exit pending_through and cache semaphore completions in RetireTickets
2026-11-28 18:54:20 +01:00
3107c8a2a8 Merge pull request #2035 from IlyassRS3/fix/rt-cpu-emulation-clzero-region-and-bounds
runtime: step try_clzero_loop by VirtualQuery regions and guard wraparound in cpu_emulation
2026-11-28 18:53:57 +01:00
f139d7690a Merge pull request #2036 from IlyassRS3/fix/rt-clzero-patch-rel32-and-protect-guards
runtime: guard rel32 range, stub_page arithmetic, and VirtualProtect failure in clzero_patch
2026-11-28 18:53:35 +01:00
3408969a72 Merge pull request #2041 from IlyassRS3/fix/rt-base-reservation-overflow-and-parse-guards
runtime: guard base_reservation parsing and VirtualQuery loop overflow
2026-11-28 18:52:49 +01:00
6321c250b4 Merge pull request #2473 from Tyrannys/rt-state-depth-raster-backface-mask
native_pso: a single-sided stencil PSO keeps its depth/stencil/raster state (RT-STATE-DEPTH-RASTER-BACKFACE-MASK)
2026-11-28 18:52:26 +01:00
cd124a402e Merge pull request #2499 from Tyrannys/rt-loader-runtime-scope-and-tls-slot
loader: wide run-time loads are dynamic; set tls_ga_slot before publishing (RT-LOADER-RUNTIME-SCOPE-AND-TLS-SLOT)
2026-11-28 18:51:52 +01:00
0f71e76707 Merge upstream main into PR #1715 2026-11-28 13:59:13 +00:00
5d677b7ba2 cpu_emulation: a CLWB #UD on a site another thread rewrote continues at it (RT-CLWB-PATCH)
Threads that fault on the same CLWB site together lost the race: a #UD handled
after another thread rewrote the site decoded CLFLUSHOPT (or the NOP), did not
know it and returned EXCEPTION_CONTINUE_SEARCH, which ends the title.

- The handler continues at a site that already holds the form written on this
  host (or the NOP's halfway state): the CPU runs it.
- One lock around unprotect, re-check, write and protect again, so two threads
  never interleave on a page; a site found rewritten under it is not written.
- The NOP is written opcode first (66 0F 1F /6 in between is a NOP too).
- The sites counter counts each site once, by the thread that wrote it.

cpu_emulation_test calls the handler with a made-up #UD, so it runs on hosts
with CLWB: first #UD, a second one on the rewritten site, and 16 threads on
2048 fresh execute-read sites. Before the fix 27958 of 32768 concurrent #UDs
were passed on, 4810 rewrites were counted for 2048 sites and pages were left
writable; with it all checks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 05:28:00 +01:00
63a73515d1 Merge remote-tracking branch 'origin/main' into fix/clwb-patch-race 2026-11-28 05:22:21 +01:00
f77359c5b4 Merge pull request #1565 from Mike7581/rt-compat-dir-runtime-loads
loader: a run-time LoadLibrary takes the LEONIDA_COMPAT_DIR module too (RT-COMPAT-DIR-RUNTIME-LOADS)
2026-11-28 00:48:31 -03:00
725d223757 Merge pull request #1549 from Mike7581/mvp-gpu-04-stub-pipeline
d3d12: LEONIDA_STUB_PIPELINES builds a real graphics pipeline from built-in stages (MVP-GPU-04)
2026-11-28 00:48:22 -03:00
00131bb85e main keeps its own runtime, tools and tests; the branch's variants stay on port/d3d12-nvidia
After the merge the tree held this branch's older states of files main maintains. Run against main's code,
tests/test_acphal_abi.py and 11 of the 15 translator tests that differed failed, and the C++ runtime would have
been built from two generations of its sources. So that the merge cannot break what main builds and tests:

- runtime/ is main's, file for file (68 files only this branch had are not carried over);
- every file under tools/, tests/ and docs/ that both sides have is main's (80 files);
- ten translator tests only this branch has, which test rules main's translator does not have, and their
  fixtures are left out.

What main gains: d3d12/ (the Rust D3D12 runtime), its launchers and helpers (Launcher.bat, scripts/play*.ps1,
play-linux.sh, port_ctl.py, smooth-motion.ps1, fetch_vkd3d_proton.py, sync_victory.py), mods/example_lua, eleven
notes under docs/, seven tools and the tests that pass with main's code, the README's sections and credits, and
the "Runtime traps" section of AGENTS.md. Everything left out here is on the branch port/d3d12-nvidia.

Checked: compileall; make_game.py --help; check_no_game_data.py over every file this adds to main; the
line-ending, docs-encoding, CI-registration and docs tests; each test file that differs from main, on its own.
Not run: the whole translator suite, the C++ build, cargo over d3d12/ after the merge (d3d12/ is byte for byte the
branch's), CI.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 17:58:38 -05:00
b87abdef57 Merge mandy's main into port/d3d12-nvidia
Brings the D3D12 runtime branch (d3d12/, its launcher scripts and notes, and the pull requests reviewed and applied
on it) together with mandy's main.

Conflicts (67 files, none under d3d12/): docs/, make_game.py, runtime/, scripts/build_runtime.ps1, tests/ and
tools/. Every one takes main's side: main is where that code is maintained, and this branch's copies were older
states of the same files or the same pull requests in another form. tests/test_fspx_unpack.py is main's too, as it
tests main's tools/fspx_unpack.py. Nothing under d3d12/ is changed by the merge.

Checked before pushing: python -m compileall over make_game.py, tools and tests; make_game.py --help;
scripts/check_no_game_data.py over the files this adds to main; tests/test_text_write_line_endings.py. The
translator suite, the C++ runtime build and CI have not run on the result.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 17:50:37 -05:00
e65692ad63 Merge #407 into consolidate/eight-gb-world
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
2026-11-27 22:17:05 +01:00
bab63563a8 Merge #2012 into consolidate/eight-gb-world
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-27 22:16:46 +01:00
048eeed509 Merge #2465 into consolidate/eight-gb-world 2026-11-27 22:16:28 +01:00
6014cb1c84 Merge #1851 into consolidate/eight-gb-world 2026-11-27 22:16:27 +01:00
00f317f0c7 Merge #2166 into consolidate/eight-gb-world 2026-11-27 22:16:26 +01:00
1a49f13757 loader: wide run-time loads are dynamic; set tls_ga_slot before publishing (RT-LOADER-RUNTIME-SCOPE-AND-TLS-SLOT)
Loader::load_runtime_module_w (LoadLibraryW / LoadLibraryExW of a
bundled DLL) did not open a RuntimeLoadScope, unlike the narrow path and
resolve_module_export. The module was mapped as a static load, so its
DllMain(DLL_PROCESS_ATTACH) got a non-NULL lpvReserved. It now opens the
scope too.

Loader::initialize_tls patched an executable's /GA TLS reads and wrote
m.tls_ga_slot after it had published the slot owner and released
ExclusiveTlsLock, while a thread starting then reads m.tls_ga_slot in
install_thread_block under SharedTlsLock. The patch and the write now
happen before the owner is published.

loader_test checks the wide path's lpvReserved (fails on main);
loader_tls_index0_test checks that the noreserve executable gets its
/GA slot.

Found by kevincommits on #1608.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 13:40:23 -06:00
5e8d3349c8 Merge origin/main into window-retire-on-1920
submit_write keeps main's second root UAV (va2) and our wait flag: (s, va, va2 = 0, wait = true); the two callers that only execute pass va2 = 0 explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwSKP7weM2P7sk5skto
2026-11-27 19:25:41 +01:00
8aaea30c77 native_pso: a single-sided stencil PSO keeps its depth/stencil/raster state (RT-STATE-DEPTH-RASTER-BACKFACE-MASK)
np::d3d12_depth_raster refused any stencil state whose DB_STENCILREFMASK_BF
masks differ from DB_STENCILREFMASK, even with DB_DEPTH_CONTROL.BACKFACE_ENABLE
clear, where RDNA2 ignores the _BF register and the back face uses the front
one (as the function already did for the back face's ops and function). The
empty result made fill_depth_raster_state fall back to its defaults for the
whole PSO: depth ALWAYS with writes, no culling, stencil off. Found by
kevincommits in #1608 (RT-STATE-AUDIT-PIPELINE, item 1).

The masks are now compared only when BACKFACE_ENABLE is set. Two-sided stencil
with differing masks is still refused, since D3D12_DEPTH_STENCIL_DESC has one
pair.

native_pso_depth_test: a single-sided stencil state with
DB_STENCILREFMASK_BF = 0, and one with a differing back write mask, are built
with their depth, cull and front stencil state. Both checks fail on main.

AI-assisted (Claude Code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 09:40:25 -06:00
e1f82510a0 d3d12: a pool cover replaces only the windows it planned to (RT-TITLE-WINDOW-RETIRE)
cover_pool_request planned its cover (title_pool_cover) under short
shared locks of the alias table, then made the mapping and entered it
with replace_twin, which erased every range in the span unconditionally.
A slot-133 buffer is entered (Resource::alias_title_va) without
title_window_mutex, so one placed in either view of the span in between
was erased with the windows. And replace_twin's result was ignored: the
cover was recorded in pool_spans and returned as made either way.

replace_twin now takes the caller's predicate and, under the same
unique lock as the replacement, refuses with nothing changed when a
range it would erase is not one the caller planned to replace. The
cover passes the windows its plan found. On refusal the window it made
is dropped at once (drop_title_window: nothing answered from it, so no
submission names it) and the request falls back to the zero-size view
as before. The same drop now follows add_twin's refusal in
resolve_pool_memory, which left its new window charged to the budget
and refreshed with nothing answering from it.

title_window_plan_test: a non-window range entered in the cover's span
(CPU view, then twin view) between title_pool_cover and replace_twin is
refused and left intact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
2026-11-27 16:38:40 +01:00
b8754f630f title_window_plan: bound the twin view without modular arithmetic (RT-TITLE-WINDOW-RETIRE)
title_pool_cover translated a mapping found in the pool's other view back
with `x - (twin - va)` modulo 2^64. A window that starts below the twin
view (m.title_va < twin - va) wrapped to near UINT64_MAX, passed the
pool bounds check, and replace_twin then erased it whole, leaving the
part of it outside the cover unanswered. A twin view that does not fit
in 64 bits (twin < va - pool_lo, or pool_hi - va > UINT64_MAX - twin)
made the twin-view query wrap into an empty range, so a range in the way
was not seen at all.

The twin view's bounds [twin_lo, twin_hi) are now checked up front,
queried in non-wrapping coordinates, and a hit outside the view it was
found in refuses the cover like one outside the pool.

title_window_plan_test: check_pool_cover_bounds with the review's
example (pool [0x100000, 0x500000), va 0x120000, twin 0x420000, window
[0x200000, 0x440000)) and the two overflow cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
2026-11-27 16:38:40 +01:00
d42c37335b d3d12: LEONIDA_ASYNC_MIN_BYTES_GRAPHICS, a separate async threshold for graphics (RT-ASYNC-MIN-BYTES-GRAPHICS)
With LEONIDA_ASYNC_PIPELINES=1, graphics and mesh pipelines (all their stages) now take
LEONIDA_ASYNC_MIN_BYTES_GRAPHICS when it is set, and LEONIDA_ASYNC_MIN_BYTES otherwise, so
nothing changes while it is unset. Compute keeps LEONIDA_ASYNC_MIN_BYTES. 0 makes every graphics
pipeline asynchronous. One startup line states both thresholds; text that is not a number is
ignored with a log line.

Thread dumps from a retail run showed the draw thread building lazy graphics variants under the
1 MiB threshold in place, 2.5-11 s each, back to back, with no present for about 100 s. A skipped
draw costs one draw. The image needs the small lighting and post compute programs, and those
are still built in place.

Tests: async_pipeline_size_test covers the per-kind decision and the unset fallback;
d3d12_pipeline_workers_test --async-graphics-zero / --async-graphics-unset (new ctests) hold
the compile worker with compute over its threshold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 14:24:29 +01:00
d483077913 Merge main into claude/pipeline-prewarm-order
Resolve runtime/README.md conflict after #2220 and #2233 landed on main.
2026-11-27 08:11:54 -05:00
e31f50bbcc compile gate calibration: keep no unclear verdict, drain a timed-out fence
Review of #2462:
- An unclear calibration (a slow submission the create does not explain) is no
  longer written to compile_gate_calibration.txt, and an unclear line an
  earlier build wrote is not read as a cached verdict: the next launch measures
  again instead of staying classic until the driver changes
  (compile_gate_policy::cache_verdict, tested in compile_gate_policy_test).
- After a fence wait that fails, the fence and command pool are destroyed only
  once the pending submission's fence signals (up to 60 s); on a lost device or
  if it still has not, they are left alive. The verdict stays classic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 13:49:07 +01:00
6af3b1dac6 Merge remote-tracking branch 'origin/main' into rt-compile-gate-auto 2026-11-27 13:43:49 +01:00
690dea5193 Merge pull request #2220 from MoonEyes/feat/pipeline-order-recorder
runtime: record the order of first pipeline requests (LEONIDA_PIPELINE_ORDER_LOG=1, RT-PIPELINE-PREWARM-ORDER phase 1)
2026-11-27 13:43:04 +01:00
1d7c662b4b compile gate: auto default, calibrated at device creation
With LEONIDA_COMPILE_GATE unset or `auto`, the device measures the driver once
before the VulkanContext exists: a worker creates a synthetic compute pipeline
(SPIR-V written in code, new specialization seed each run, no pipeline cache)
while the queue gets empty submissions waited on a fence. Quick submissions with
the create still in the driver give the adaptive gate; a held one, a create too
fast to tell, an unexplained slow submission or any failure give classic. The
verdict is cached per vendor/device/driver/pipelineCacheUUID in
compile_gate_calibration.txt beside the pipeline cache;
LEONIDA_COMPILE_GATE_RECALIBRATE=1 measures again. Only the title process
calibrates; build hosts and tests keep classic. `classic`, `adaptive`, `1`, `0`
still force a mode.

Tests: compile_gate_policy_test (no GPU: settings, NVIDIA version decode,
verdicts, cache file, SPIR-V shape) and vk_compile_gate_calibration_test (GPU:
a verdict within 20 s, adaptive on NVIDIA 621.40).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 13:24:49 +01:00
ebdc991627 compile gate: the held check on every pass of the wait, and presents never use the probe budget
Second review on #2412:
- enter_submit no longer switches to the held limit for good once it sees a create of a kind that holds
  submissions: each pass checks held_blocking(). With one in the driver the held limit applies on its own (also when
  it is under the plain limit) and the budget is off; without, the plain limit and budget apply, so a submission
  goes ahead at the plain limit once the holding create left while a create of a kind with no verdict stays. The
  "reached the limit, but ..." notice comes once per wait, and the wait wakes when a holding create leaves.
- SubmitTurn passes `probe` into enter_submit: a present or wait never goes ahead at the probe budget, only at the
  limit.
- VulkanPresenter::submit's turn does not probe (it covers the startup frame's fence wait and the present); the
  nested queue_submit turn still probes the vkQueueSubmit alone.
- submit_mutex_test: gate_second_review covers the four cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 12:46:36 +01:00
16245b98b2 Merge remote-tracking branch 'upstream/main' into claude/pipeline-prewarm-order
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-27 05:20:16 -06:00
ee81c0e4a0 compile gate: builds outside MSVC, and the classic gate stays the default
- CreateKind, CreateInfo and GateAhead move out of SubmitMutex to namespace scope (CompileGateKind,
  CompileGateCreate, CompileGateAhead), with using aliases so SubmitMutex::CreateInfo and the rest still work:
  clang and GCC reject a `= {}` default argument of a nested class with default member initializers inside the
  enclosing class (review on #2412).
- LEONIDA_COMPILE_GATE unset is the classic gate again, as on main: compute creates only, no limit, no probes;
  graphics creates do not pass it. The adaptive gate is LEONIDA_COMPILE_GATE=adaptive: on a driver that holds
  submissions (630.20) its first probe of a kind enters the driver after the 2.5 s probe budget and loses the
  device if that create stays 10 s more, which the classic gate waits out. `1` and `0` are unchanged.
- submit_mutex_test: a classic-gate case (a graphics create holds nothing back, a 3 s compute create is waited out
  with no verdict), the adaptive cases opt into graphics gating; passes unset, with `adaptive` and with `1`.
- README rows and docs/d3d12_vulkan.md say so; the "held verdict 2 s into the probe" wording is corrected (it comes
  when the probe returns, and the probe holds the submit lock until then).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 12:20:11 +01:00
916868ebe0 Merge remote-tracking branch 'origin/main' into window-retire-on-1920
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/test/d3d12_title_va_test.cpp
2026-11-27 12:11:50 +01:00
c4261506b3 Merge remote-tracking branch 'upstream/pr2220' into claude/pipeline-prewarm-order
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-27 05:11:17 -06:00