Commit Graph

167 Commits

Author SHA1 Message Date
340e8a415c Merge pull request #638 from aslan2142/skip-int3-wine
OLD-7824: restore old upstream PR 7824 - startup_trace: LEONIDA_SKIP_INT3 works on title threads and with Wine's breakpoint address
2026-11-25 23:59:09 +01:00
722fee9af6 Merge main into delay-import-thread-order-notes (#643)
#634 rewrote the same runtime/README.md paragraph on the loader. Its text
stays, and its relocation sentence takes this PR's wording: DIR64 and
HIGHLOW relocations, the other types rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 17:54:12 -05:00
21d3662ad8 Merge pull request #634 from aslan2142/loader-rebase-without-reloc-dir
OLD-8847: restore old upstream PR 8847 - pe_loader: move an image with no relocation directory; refuse only on IMAGE_FILE_RELOCS_STRIPPED
2026-11-25 23:53:26 +01:00
2a79af5a81 runtime/README: int3_skipped is per address until the 4096-slot table fills
The dedupe is a fixed table of 4096 addresses; past that a new site is
logged each time it is hit, as startup_trace.h says. Raised in review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:43:53 -05:00
83c1bf2791 Merge commit 'refs/fix2/main' into fix2-638 2026-11-25 16:42:43 -05:00
712714bef2 Merge main into perf/big-compute-budget (#1889)
Brings #1889 up to date with main after #1742 (the pipeline compile unlock),
resolving the five conflicts as described in the guide on the PR:
https://github.com/ubiquitarianism/leonida/pull/1889#issuecomment-7175252290

- vulkan_replay.h: PipelineCompiles::build takes both the large-compile
  budget and main's `prior` compiles; build_pipelines passes the budget,
  and main's check_compiled_pipelines / finish_compiled_pipelines stay.
- vulkan_backend.h: execute_now takes the large-compile demand and passes
  the budget to the pass-0 compile, and pass 1 passes the budget too.
  set_large_compiles locks pipeline_mutex_, since #1742 moved the
  pipeline state under that lock.
- replay_pipeline_compiles_test.cpp: both test blocks kept, and the
  prior_compiles_reuse call passes an empty budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:41:36 -05:00
afea66650c Merge main into delay-import-thread-order-notes
runtime/shims/startup_trace.h: main added the tls_index0 example event
and the exception's region/regs fields to the header comment; keep them,
add this branch's delay_import_unimplemented example and renumber seq.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:38:51 -05:00
da4ce8c273 Merge pull request #1849 from DadaCap/console-fix-no-null
d3d12: changed console heap slots are fixed without a time limit by default, not given to shaders as null (RT-CONSOLE-FIX-BUDGET-NULL)
2026-11-25 18:33:19 +01:00
aa8018b7ff d3d12: large pipelines compile side by side within a memory budget (RT-BIG-COMPUTE-BUDGET)
Compute modules over 128 KiB and graphics pipelines of 1 MiB of SPIR-V or more wait at one gate for the process until their estimates fit the memory that is free, instead of one at a time. PipelineCompiles::build gives a submission as many lanes for them as can be in at once, largest first, and fills the rest with small ones. A thread that waits for its place holds no PSO's lock, and one that has a place waits for none. The warm-up's compiles are speculative. LEONIDA_SERIAL_BIG_COMPILES=1 keeps one at a time, 0 has no limit, LEONIDA_BIG_COMPILE_BUDGET_MB fixes the budget.
2026-11-25 15:11:11 +01:00
c90092b284 d3d12: changed console heap slots are fixed without a time limit by default, not given to shaders as null (RT-CONSOLE-FIX-BUDGET-NULL)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:05:05 +01:00
c68f494160 RT-INPUT-SCRIPT-NO-SDL3: serve LEONIDA_INPUT_SCRIPT without SDL3
A build without SDL3 answered GameInputCreate with no devices and E_NOTIMPL
for every other slot, so the title waited at its first "press A" prompt
forever: no CI artifact or offline build could get past it.

With LEONIDA_INPUT_SCRIPT set, gameinput_no_sdl.cpp now serves one scripted
pad (an Xbox One gamepad) driven by the script alone: device enumeration
through RegisterDeviceCallback (blocking, async, dispatcher), FindDeviceFromId,
and GetCurrentReading/GetNextReading/GetPreviousReading whose gamepad and UI
navigation state follow the script. Readings are taken when the title asks,
so no thread polls. Without the variable it behaves as before.

The parser, the 300 ms timeline, the button names, the press log lines and
the UI navigation mapping move from gameinput.cpp into gameinput_script.h,
which both shims use; nothing in it needs SDL. gameinput.cpp checks the
shared SDL button numbers against SDL_GamepadButton at compile time.

gameinput_no_sdl_test --input-script (CTest gameinput_no_sdl_script) checks
the scripted pad on a fake clock. Docs: runtime/README.md, docs/gameinput.md,
docs/linux_proton.md, docs/README.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 07:39:13 -05:00
6aa5f0b0d4 Merge main (#1723 merged) into #622 (list value writes)
No conflicts. Brings #1723's final form: the README rows for 32
LEONIDA_* variables and indirect_clamp_test's ctest registration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:43:32 -05:00
f005d7ab22 Adapt #622 to #1723: the slot 71-74 rows say who writes and who waits
#622's rows had slots 73 and 74 as no-ops and the GPU-label path as the
only writer of 71 and 72. Under #1723 the list values record all four
for the lists they track (waits included), and LEONIDA_GPU_LABELS=1
writes 71/72 only for the others. The command-object table, the value
write paragraph, §5.5 of the console ABI notes and the README row now
say so, and name the arena and xmem fallbacks (src/value_write_sink.h).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:43:20 -05:00
709d545831 runtime/README: document the 32 LEONIDA_* variables #1723 added
The integration of the post-story-load runtime changes (#1723) reads 32
environment variables that no document named, so tests/test_docs_env_vars.py
failed. Each now has a row in the D3D12 switches table of runtime/README.md
with its default and what its values do, read from the code: the console heap
fix and retry budgets, the per-frame and asynchronous refresh trade-offs, the
title texture fill and view settings, the XMem and queue slot 31 switches,
the hang exit, the thread sampler, the submit-phase line and the Aftermath
extras. Diagnostic-only switches are marked so.

LEONIDA_QUEUE_PAGE_MAPPINGS is read by rt::xmem::queue_page_mappings_enabled(),
which nothing calls; its row says it has no effect at present.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:32:43 -05:00
59c54c1eb0 d3d12_xs: list slots 71/72 have one writer, the list values, when they track the list
Found by the comparison agent, not by a failing test. #1723's console
list slot path still handed slots 71 and 72 to main's GPU-label hook
(record_gpu_label, LEONIDA_GPU_LABELS) when its own list values track
the list (track_values, on by default with LEONIDA_LIST_VALUES). The
--first-run-ui profile sets LEONIDA_GPU_LABELS=1 (runtime/src/main.cpp).
With both on, two threads stored to one title address, one from a
Vulkan command buffer's completion and query, the other from the part's
fence and a D3D12 timestamp query. A late label could rewind a rising
counter or split a begin/end pair. The suite did not catch it:
xbox_gpu_label_completion submits its real list straight to the queue,
so only the label path landed there.

The list values are the right owner. They land slots 71 to 74 in
queue order behind the gates, and they also do the waits the labels
cannot do. Now:
- The label hook runs only for a list the list values do not track
  (LEONIDA_LIST_VALUES=0, bundles). Each handoff is counted in
  ListValueStats::labels_handed.
- The --first-run-ui profile no longer sets LEONIDA_GPU_LABELS.
  runtime/README.md and docs/first_run_ui.md say so.
- xbox_gpu_label_completion runs its label section with the list values
  off, as it always measured the label path alone, and checks that all
  five writes went there. A new section turns both on and records one
  write32 and one write64 on a tracked list, submitted through the queue
  proxy. Each lands exactly once: writes_landed == 2, labels_handed == 0,
  and the values are in memory. With the old condition this section
  fails at line 136 (labels_handed was 2), on llvmpipe and the iGPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:16:46 -05:00
ba626820ec Integrate post-story-load memory, queue and Vulkan runtime changes
Preserve physical window aliases across remaps, order console list values,
and replay bounded indirect graphics with captured draw state. Coordinate
pipeline lifetime, texture refresh and queue teardown. Add synthetic CPU
and GPU coverage for the integrated paths.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
2026-11-25 03:44:43 -06:00
d4ce33ed42 runtime: serve a silent output endpoint when the host has none
The title creates its MMDeviceEnumerator through CoCreateInstance. On a host with no
render endpoint, GetDefaultAudioEndpoint(eRender) is 0x80070490, the title's audio device
start leaves its own output-device lock held, the audio engine never mixes, and the boot
stops on an int3 about 47 s in. A console always has an output.

com_shim's CoCreateInstance now hands that class to shims/silent_audio.cpp. A host
enumerator with a default render endpoint is returned unchanged. Otherwise (no endpoint,
no enumerator, or LEONIDA_AUDIO=silent) render questions get an in-process endpoint:
IMMDevice with a read-only property store, IAudioClient/2/3 at 48 kHz float 7.1, and
IAudioRenderClient, IAudioClock, ISimpleAudioVolume and IAudioStreamVolume. A clock drains
the padding in real time and an event-driven stream's event is signalled every 10 ms.
Every sample is discarded; no host audio device is opened. Capture keeps the host's
answer. One [rt] line names the reason when the silent device is first served.

silent_audio_test covers stand-in hosts with and without an endpoint, no host, a render
stream over a few periods, and the CoCreateInstance hook with LEONIDA_AUDIO=silent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 00:05:32 -05:00
d9674fca8c Device slot 133's stand-in can read its fourth word as a barrier layout: LEONIDA_SLOT133_LAYOUT_WORD=1
The committed stand-in of slot 133 reads the word as a resource state, which is what the story-load boots had wherever the stand-in answered, and stays the default. The placed-at-VA handler of the same slot reads it as a D3D12_BARRIER_LAYOUT, and #939 measured the title passing 6 (SHADER_RESOURCE) for 1x1 targets, which as a state is INDEX_BUFFER | RENDER_TARGET. #939's reading is now behind the switch: CreateCommittedResource3 with the layout as given on a device with ID3D12Device10, else the legacy state of the layout. xs_proxy_mock_slot133_layout runs #939's cases in a process of its own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:27:40 -05:00
7067ec7ced docs: the switches of the merged tree, and the first-run profile without host speech
runtime/README.md gains the twelve variables the merged code reads and no doc named (tests/test_docs_env_vars.py): LEONIDA_PIPELINE_COMPILE, LEONIDA_GRAPHICS_STAGE_LAYOUT, LEONIDA_FRAME_PACING, LEONIDA_GPU_LABELS, LEONIDA_LINEAR_MAP_FIRST, LEONIDA_CONSOLE_D16S8, LEONIDA_RGBA4_COPY_REFUSE, LEONIDA_DESC_MIRROR, LEONIDA_SLOT70_TITLE, LEONIDA_WINDOW, LEONIDA_PRESENT_DUMP and LEONIDA_LOCAL_SPEECH, each with the default the merge gives it. docs/first_run_ui.md no longer lists local speech among what the profile selects: it is off unless LEONIDA_LOCAL_SPEECH is 1.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:01:35 -05:00
71a783e56f main: the title's hang watchdog stays armed unless LEONIDA_TITLE_WATCHDOG=0
The retail title runs its own hang watchdog: when the game's main loop has
not reported for 30 seconds, it ends itself. #984 kept that watchdog from
firing by default, because under the runtime the game thread can wait
longer than that, for example while the driver compiles pipelines on the
first boot after a driver update.

By the maintainer's decision the watchdog now stays armed by default, as on
the console, so a real hang still ends the run. LEONIDA_TITLE_WATCHDOG=0
turns on the runtime thread that keeps it from firing; as before, it only
acts in the build the watchdog was measured in. The README's environment
table and the log line say the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:32:26 -05:00
7e3bfb4e33 PresentX: docs and a test state the one-slot-per-layout rule of the merge
The merged queue proxy recognises PresentX at slot 30 on a queue in the older layout and at slot 32 on a queue detected as the newer one (a fence at slot 16 or 17, or SignalX at 25), which is #984's measured behaviour, with main's LEONIDA_XS_PRESENT_X_SLOT pinning one slot and an attached handler answering first. Only one of the two is PresentX at a time: in the newer layout slot 30 is another method.

docs/d3d12_vulkan.md still had main's row (the queue slots stay refused, gta6rt creates no presentation) and runtime/README.md still said PresentX has an unknown slot. Both describe the merged code now. check_presentation_wiring gains the newer-layout case: before the fence 30 reaches the presenter and 32 does not, after it 32 does and 30 does not.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:56:42 -05:00
d125b369fd Boot diagnostics behind LEONIDA_LOCAL_DIAGNOSTICS, off by default
#984 carries the probes its author followed a frame of the retail title with, marked LOCAL DIAGNOSTIC and in places 'not for upstream'. Several wrote to stderr with no switch from paths that run for every draw: record_draw (a mutex, a set lookup and up to a dozen lines per draw), ClearRenderTargetView, the submission's table dump, PresentX (present_diag and the plane dump), the presenter's path line, the heap and CopyDescriptorsSimple lines of the device proxy, the per-view CBV and SRV lines, the per-pipeline description string and the console-heap census.

They stay, for the next person who has to follow a frame, behind one switch: LEONIDA_LOCAL_DIAGNOSTICS=1 (runtime/src/local_diagnostics.h, a row in runtime/README.md). Unset, none of them runs. Not changed: the diagnostics that already had a switch of their own (LEONIDA_CAPTURE_SOURCE, LEONIDA_MEM_PROBE, LEONIDA_XG_TRACE, --trace) and the replay's unresolved/unsupported lines, which report a dropped draw or list at the 1st, 2nd, 4th... occurrence.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:52:07 -05:00
c334e0a1a5 docs: name the 32 environment variables #984's code reads
tests/test_docs_env_vars.py fails when the runtime reads a LEONIDA_* variable that no document names; #984 brings 32 of them (the test fails on its head too). Each is described in a new table in runtime/README.md, from the code that reads it: the default, what the switch changes, and which ones are diagnostics only. None is removed: every one is behind its own switch already and off, or the default path of the retail boot.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:44:14 -05:00
39879ce0fd Merge main into RT-PROTON-STORY-LOAD (#984)
Merges main at 1154976d4 into the integration branch at 273b3bdf9 (merge base ece4ba5b3). 42 files conflicted;
this commit is the resolution only. Build and test repairs follow in their own commits.

Rule of resolution: where both sides added different things, both stay; where both made the same change in two
forms, main's reviewed form stays and whatever #984's form did in addition is carried into it; where the two
changed the same code for different purposes, both purposes are kept.

Xbox proxy code (runtime/shims/d3d12_xs_device.cpp, d3d12_xs_device.h, d3d12_xs.cpp, d3d12_xs_alloc_size.h,
d3d12_xs_desc_clean.h, registry.cpp):
- d3d12_xs_device.cpp is #984's file with main's differing pieces ported in: env_slot and the configurable device
  routes, XboxQueueSlotRoutes, PresentationHandler / set_presentation_handler, the console caller rule for device
  slots 61 and 74 (#383, #385), route_xbox_device_slot, slot 81 as GetFrameStatisticsX, create_host_device, the
  console-form rule for slots 25 and 56, the console list IID of #359, and the forms of queue slot 18 (#403) and
  list slot 139 (#396).
- Kept from #984: the list proxy with handle translation, queue slots 16/17 as Signal/Wait, the fence's
  completed-value mirror, the shared FrameTokenSource, PresentX through queue_present_x when no handler is
  attached (slot 30, or 32 on a queue detected as the newer layout), slots 27/53/55/57/70/71/133, the wider
  pc_resource_desc, S_OK for queue slots past the PC table.
- Dropped: #984's GetFrameEventsX and LEONIDA_XS_FRAME_EVENTS_SLOT, its second-word rule for slot 61, its
  undetected-layout rule for queue slot 18, its list IID mapping to GraphicsCommandList6; main's copy of the base
  list proxy, its null-view slot 70 and its refusing slot 133.

Proxy tests (runtime/test/xs_proxy_mock_test.cpp, device_proxy_test.cpp, queue_proxy_test.cpp):
- Checks of both sides, each run once; main's forms of the render-target size and layout checks with #984's extra
  cases added; main's --env-slots-74 and #984's --env-slots-70.
- Adapted to the merged code: the queue tail answers S_OK, slot 73 answers an unknown IID with the list proxy,
  the queue slot 18 case installs a console caller. Dropped: #984's slot 81 GetFrameEventsX cases.

D3D12/Vulkan layer (runtime/shims/d3d12_com.cpp, d3d12_vulkan_device.cpp, runtime/src/command_list.h,
frame_pacer.h, shader_library.h, vulkan_backend.h, vulkan_replay.h, runtime/test/command_list_test.cpp,
d3d12_close_parity_test.cpp, d3d12_execute_indirect_validation_test.cpp, replay_texture_barrier_test.cpp,
vk_pipeline_check.cpp, vk_test_device.h):
- Resource::create_texture: #984's title images (deferred placed, pending streamed, title pool) and main's
  ordinary textures (#1413 shared blocks, #1364 staging fallback) are exclusive branches chosen by the texture's
  origin, so both pools run on disjoint sets of textures.
- frame_pacer.h is main's pacer (#402) with #984's FrameTokenSource as the token counter.
- main's forms kept for ExecuteIndirect (#1066, #377), the barrier into LAYOUT_UNDEFINED (#1055), the B4G4R4A4
  stand-in, per-face stencil masks, the unaligned tile staging (#528) and the device-lost flag (#980).
- shader_library.h: main's block inflate; #984's `bulk` parameter now defaults to true so main's callers keep it.
- Dropped: #984's B8G8R8A8 stand-in for B4G4R4A4 targets, its refusal of separate stencil masks, its zero-count
  refusal in ExecuteIndirect, its wider UNDEFINED -> UNDEFINED release and the test case for it.

Other shims (runtime/shims/dstorage.cpp, file_system.cpp, gameinput.cpp, xgameruntime_offline.cpp,
runtime/test/xgameruntime_offline_test.cpp, xmem_test.cpp):
- ReadFile and DirectStorage reads: #984's pinned kernel_writes read, then main's touch_pages retry on
  ERROR_NOACCESS. main's rt::fs::read_file is folded into #984's read_file.
- gameinput: main's strict LEONIDA_INPUT_SCRIPT parser with #984's rsup/rsdown entries.
- Speech synthesis: main's one silent voice and handle checks; #984's accept-anything form dropped.

Build, tools, docs (runtime/CMakeLists.txt, runtime/cmake/translator_deps.cmake, scripts/build_runtime.ps1,
make_game.py, tools/rdna2spirv.py, shader_disasm.py, shader_ir.py, shader_library.py,
runtime/test/shaders/cs_imgload_tfe.asm, cs_imgload_d16_tfe.asm, docs/README.md, boot.md, d3d12_vulkan.md,
runtime/README.md):
- Unions of the test, target and source lists; spirv_loop_guard.py added to translator_deps.cmake.
- rdna2spirv.py: main's DPP compare rule (#957), SMEM vcc base (#647) and widen_wave64_masks (#1021); #984's
  restore_skipped_instructions and restore_dot4_inline_sel. #984's duplicate widen_wave64_valu_masks dropped.
- shader_disasm.py and shader_ir.py: main's structure with #984's one-line-per-dword llvm-mc input and wave flags.
- shader_library.py: main's structure with #984's --compute-hashes and per-state compute variants.

One file that did not conflict is changed here: tools/rdna2_decode.py. Git kept both sides' decoders for a VOPC
compare with a DPP operand, and #984's narrower one shadowed main's; it is main's file again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:38:04 -05:00
6cb16a4fa8 docs: document LEONIDA_TITLE_MEMORY_MB in runtime/README.md 2026-11-24 16:51:43 -05:00
273b3bdf9d [integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD)
One squashed commit of a fork that was developed on a Linux/Proton machine and
tested on two native Windows machines. On all of them the retail 1.0.2.1
package now launches, shows its launch movie, first-run pages and landing
prompt, runs the story load to its end with the loading slideshow drawing its
artwork, and enters the world phase. A first world frame is not verified yet.
docs/linux_proton.md has the setup, a healthy boot's timeline, the machines
and where it stops.

Runtime: frames in the title's own window; DirectStorage pinned reads,
page-list scatter/gather, BCPack and unshuffle with a locally generated
predictor file; pooled, device-local and deferred image backing for streamed
and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table
that degrades instead of refusing a submission; a descriptor hash finalizer
(off until a library carries it); directly indexed heap offsets for compute
dispatches and VS/PS/GS draws; title buffer windows outside a fragmented
arena; opt-in device-local copies of streamed buffer views; write-fault
retries under the tracker lock, shared trackers and write-watched title memory
for native Windows; device-loss, compute-input and memory probes.

Translator: loop bounds at structured exits, the eight FidelityFX programs
that use a packed-dot form the disassembler skips, buffer bounds modes per
view kind, a compaction option, the hash finalizer option.

Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows
boot script, the paired compute translation script.

No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted
by people on the machines named in docs/linux_proton.md.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 11:42:12 -06:00
82d6883bed pe_loader: trace delay imports bound to an unimplemented thunk; note delay-load and thread-attach order
Delay imports are bound eagerly (deliberate: --dry-run shows the whole import surface). A delay-loaded DLL or
function that nothing serves becomes an unimplemented thunk returning 0 at its first call, where Windows'
delay-load helper raises 0xC06D007E / 0xC06D007F, which a title can catch for a fallback. The binding is
unchanged; --trace now writes a delay_import_unimplemented event (module, import) for each such import at load,
so the first boot names them before any image code runs.

docs/runtime_imports.md gets two notes on where the loader differs from Windows: the eager delay binding above,
and that DLL_THREAD_ATTACH reaches TLS callbacks in TLS slot order, which puts the executable before the DLLs it
imports (Windows' order is undocumented). runtime/README.md lists the new trace event and now says the loader
applies DIR64 and HIGHLOW relocations and rejects HIGH, LOW and HIGHADJ (old upstream 761).

startup_trace_test gets a synthetic DLL with one ordinary and two delay imports (one missing, one bound to
kernel32): exactly one delay_import_unimplemented event, naming the missing delay import.

Findings by cynbun in the old upstream coordination issue (old upstream 7231).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 05:46:57 -05:00
60fce7a747 startup_trace: LEONIDA_SKIP_INT3 works on title threads and with Wine's breakpoint address
Spacecer2 measured under Wine 11.22 (old upstream 7599) that LEONIDA_SKIP_INT3 never took
effect: the flag was a block-scope static first read on a title thread, whose
MSVC thread-safe-static guard passed with the object still zero, and the
handler's int3 set and the trace lock had the same shape.

- The flag is read by startup_trace::open(), on the thread that opens the trace,
  into a constant-initialized atomic.
- The trace lock is a constant-initialized SRW lock (no constructor, never
  destroyed), and the logged int3 sites are a constant-initialized table of
  atomics: the handler touches no block-scope static.
- The int3 is found from Rip (Windows) or Rip - 1 (Spacecer2's Wine run), and
  Rip always ends one byte past the 0xCC.
- skip_int3 returns false for a null EXCEPTION_POINTERS, record or context.
- LEONIDA_LOG_GAME_EVENTS and LEONIDA_HDR, read on title threads, are cached in
  namespace-scope atomics instead of block-scope statics.

int3_skip_test runs each case in a child process: real int3s, the Windows and
the Wine breakpoint forms, the null pointers, the flag read at open() and the
flag off. The wine, null and init cases fail on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 05:38:10 -05:00
bb256ebbf3 pe_loader: the relocation-move notes stop citing the old pull request number
The Windows 11 measurement behind this behaviour was posted in a review of pull request 8847 of the original
repository, which went private on 2026-11-23, so its link and the "#8847" references in pe_loader.cpp and
loader_test.cpp lead nowhere now. runtime/README.md keeps the measurement and the open question in its own
words and names where it came from; the code comments point at the README. No behaviour changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 05:00:08 -05:00
ca56a0d5ef pe_loader: a relocation table is applied whatever RELOCS_STRIPPED says (Windows 11 measurement)
Zombins2 measured the Windows 11 (26200) loader with synthetic x64 DLLs in #8847. An image with
IMAGE_FILE_RELOCS_STRIPPED set and a relocation table was moved and fixed up when its base was taken. The
previous commit refused that case, while main relocated it. That is now back to main's behaviour: a moved
image with a table is fixed up whatever the flag says, and the flag refuses a move only when there is no
table. base_reservation::needed is back to main's test (the directory size) and no longer reserves for a
flag-set image with a table.

The core change stays: with the flag clear and no relocation directory, the image is moved with nothing
fixed up and the move is logged. That matches the measurement.

Windows also refused flag-set DLLs without a relocation directory at a free base (error 487), and it is not
known why. The loader keeps main's behaviour there and maps them at their base. runtime/README.md records
this as an open question, and loader_test's check for it no longer claims Windows parity. The flag-with-table
check now expects a move with the DIR64 fix-up applied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 04:58:41 -05:00
0ddf806359 pe_loader: move an image with no relocation directory, refuse only on IMAGE_FILE_RELOCS_STRIPPED
The loader refused any image whose preferred base was taken when it had no relocation directory. Windows'
loader decides on the file header flag instead (LdrRelocateImage, the same in Wine's perform_relocations and
ReactOS's LdrRelocateImageWithBias): IMAGE_FILE_RELOCS_STRIPPED set means the image cannot move and is
refused (STATUS_CONFLICTING_ADDRESSES); with the flag clear and an empty directory the image is moved with
nothing to fix up, as a second copy of such a DLL is.

map_image now does the same, for an EXE and a DLL alike: it refuses to move a flag-set image (also one that
has a relocation table, as Windows does), moves a flag-clear image without a directory and logs one
"[rt] loader: ... moved ... with no relocations" line, so a move without fix-ups shows in traces.
base_reservation::needed keeps reserving the main image's range for both kinds of image without
relocations, and now also for a flag-set image with a table, so the main image keeps its base wherever it
did before. The retail executable and every package DLL have a relocation table and the flag clear, so
neither path applies to them.

loader_test covers a flag-clear image moved when its base is held (it loads elsewhere, nothing is fixed
up, its DllMain runs), the same image with the flag set (refused), the flag at a free base (maps), and the
flag with a relocation table (refused). test_failed_dependency_not_registered's dependency shared its
parent's base and was refused for that; it now fails on its corrupt import table, which is what the test
describes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 04:58:41 -05:00
a8b7ddbd50 Make main's tests green, part 2: docs drift, bvh_slot_check, find_hash_lookup (#10002)
Seven more test files that fail on main at d083a2c, after #9896:

- test_docs_repeated_lines: tests/semantic/README.md's command block is a fenced block, which the check skips;
  its indented form put two lines with the same 40-character opening three lines apart
- test_docs_repo_paths: docs/retail_boot_intel_host.md names #8554's frame-loop notes instead of a path that
  is not in the tree
- test_docs_env_vars: runtime/README.md documents LEONIDA_RNG_SEED (runtime/shims/bcrypt_rng.cpp)
- test_docs_design_rows: docs/README.md gets one row each for strand_grooms.md and ped_catalogues.md (two
  rows each were merged in), and design.md escapes the pipe in `prim_cnt << 12 \| vtx_cnt`
- test_docs_cli_flags: docs/testing.md passes llvm-mc through LLVM_MC, so `brew --prefix` is no longer read as
  a bench_wave64.py flag; pt-PT's quickstart points to the web checker that replaced tools/pc_checker.py
  (5125a01), as README.md does; the spirv-opt passes docs/embedded_shaders.md quotes join FOREIGN
- test_bvh_slot_check: bvh_match.model_geometries() yields six fields since the render bucket was added;
  unpack the two it needs
- test_joaat_agreement (find_hash_lookup's half): hash over the Latin-1 bytes like hashdict.joaat, as #6254 and
  #7820 proposed

Still red, for a separate change: test_joaat_agreement's leonida_mods half (it hashes UTF-8 bytes like
runtime/src/mods.h, so both sides change together), test_f64_conversion and test_f64_output_modifiers (they
expect the output scaling #6314 gated by MODE) and test_bvh_shaders_stage.
2026-11-24 00:28:18 +01:00
887a0e4ef2 Merge remote-tracking branch 'origin/pr/8965' 2026-11-23 17:41:02 -05:00
b05999eb74 Merge remote-tracking branch 'origin/pr/8969' 2026-11-23 17:41:01 -05:00
f7b3afcda9 Merge remote-tracking branch 'origin/pr/9754'
# Conflicts:
#	scripts/build_runtime.ps1
2026-11-23 17:29:12 -05:00
db333b7fa7 Merge PR #9606 2026-11-23 17:09:03 -05:00
9272c0e015 Merge PR #9565 2026-11-23 17:07:54 -05:00
ad6e5d6bbe gta6rt: --init/--run stop with a clear message on a host without AVX
The game runs AVX code from its TLS callbacks on, so a CPU or OS without
AVX (a QEMU qemu64 guest) died with a bare 0xC000001D. Check CPUID.1
AVX/OSXSAVE and XCR0 YMM state first, print one line and exit 4 (3 is
LEONIDA_UNIMPLEMENTED=stop). --dry-run is unchanged and
LEONIDA_SKIP_CPU_CHECK=1 skips the check.

AI-assisted.
2026-11-23 23:07:51 +01:00
6cbcf3c6e0 fix(docs,tools): fix markdown links and pin newline='\n' in text writers 2026-11-23 23:38:26 +02:00
66e46ec9d4 runtime: pe_loader_fuzz, a deterministic mutation fuzzer for Loader::load under ASan (RT-388)
Synthetic PE32+ images built in the test (relocations, imports and delay
imports, exports with forwarders, TLS directory, .pdata/UNWIND_INFO),
field- and byte-level mutations, seeded and reproducible per case, with
--minimize in child processes. LEONIDA_LOADER_FUZZ_ASAN builds it with
/fsanitize=address under MSVC or clang-cl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 22:24:27 +01:00
4ca00caf38 runtime/README: name LEONIDA_TLS_GA_PATCH
runtime/src/pe_loader.cpp reads LEONIDA_TLS_GA_PATCH in ga_tls_patch_enabled()
to switch the /GA slot-0 TLS rewrite (patch_ga_tls_reads) off, and no document
named it: tests/test_docs_env_vars.py failed on current main (5d74c27) with
"read by the code and named in no .md file: LEONIDA_TLS_GA_PATCH
(runtime/src/pe_loader.cpp:519)".

Document it in the PE loader's TLS section, next to the TLS index the loader
assigns: what the rewrite does, when it runs, and that "0" turns it off.

Tested with python -I tests/test_docs_env_vars.py (4/4 pass; the same test
fails on main) on macOS 27.0.1 arm64, Python 3.12.10.
2026-11-23 13:17:12 -08:00
97430d6cbc Register the opt-in guest scene CTest for Wine cross-builds 2026-11-23 19:52:11 +00:00
7fc6fa7285 runtime: opt-in compat-module directory (LEONIDA_COMPAT_DIR)
When LEONIDA_COMPAT_DIR names a folder, an import whose DLL is a file
there binds to that DLL's export. Windows loads it from the full path
(LoadLibraryExW, DLL-load-dir + System32 search, never the game folder),
so it takes no manual static-TLS slot. The step comes before shims,
bundled modules and the host, and the DLL owns all imports of its
module: a missing symbol binds to the unimplemented thunk, not a shim.
Unset or empty: no change.

Measured on the 1.0.2.1 executable: --dry-run goes from 20 unimplemented
imports (AcpHal 9, chad 5, xapu 5, XCRDAPI 1) to 0 with the four
matching omonkeyz/xbox-emulator crates in the folder (and their
TOMBOX_* static initializers turned off; see runtime/README.md).

loader_test: five cases with a synthetic OS-loadable DLL (no game data).

AI-assisted (Claude Code).
2026-11-23 20:51:59 +01:00
e76640014a docs: the AMD driver took 34 minutes on LeafRehydration's dispatch-loop module; the current translation compiles in 3 s (SHADER-995) (#6739)
Squash-merged after diff review of PR #6739
2026-11-23 10:49:09 -06:00
0656b0b200 Loader: W lookups find a mapped image by its non-ASCII name; ANSI lookups ignore case outside ASCII (#6754)
Squash-merged after diff review of PR #6754
2026-11-23 10:47:01 -06:00
042c5f3783 xmem: physical pages, default allocators, XMemIsToolsMemAvailable; XMemVirtualAlloc takes 2 MiB pages and placeholders (#6919)
Squash-merged after diff review of PR #6919
2026-11-23 10:40:07 -06:00
b4adb75081 Startup trace: name failed guest file opens, and LEONIDA_SKIP_INT3 to follow a boot past soft asserts (#6937)
Squash-merged after diff review of PR #6937 - Startup trace: name failed guest file opens, and LEONIDA_SKIP_INT3 to follow a boot past soft asserts
2026-11-23 09:35:20 -06:00
3092fdfc4b runtime: preserve Unicode module basenames (#6287)
Squash-merged after diff review of PR #6287 - BUILD-2035: load mapped images with Unicode basenames
2026-11-23 08:23:32 -06:00
2e52b2f1d7 Docs after round 44: one row per topic, escaped literal pipes, one copy of each repeated line and list item, one i18n row per language
Also: #2490's committed conflict markers in fssm_crosscheck.md resolved to main's text, the SHADER-605 section
moved below the troubleshooting table it split, a header rule for the export-format table, two backticked
paths that name no Leonida file, and the BOM dropped from anim_move.py and its test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:24:16 -05:00
f71851050c Merge pull request #4469 from Pierre-Kookis
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:15:01 -05:00