Commit Graph

5744 Commits

Author SHA1 Message Date
9e62523578 docs: depth textures with unordered access, through colour twins
d3d12_vulkan.md 4.2 has the twins (formats, who gets them, views, sync
points, copies, what is left out from VIctory and the test); the contract
table in design.md a row for the UAV T#s of such a texture; port_status.md
marks the item done, to be checked on a title run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:20:51 -05:00
7c2de8a936 pso_code_base_pairs: count PSOs by code-base stage (SHADER-CODEBASE-PAIRS)
docs/d3d12_vulkan.md §5.2 leaves the push-constant shape open and says to decide after measuring how many
real PSOs have two code-base stages; row 14 of the docs/boot.md checklist asks the same thing, and
tools/feature_scan.py's header says the pairing is in the executable, not in shaders.rpf. It is in shaders.rpf:
the pipeline library names a program per stage slot, and a stage's resource-layout blob ends with the HASH
digest of the container its code came from, so a stage joins to that program's `uses_code_base` in the
translation index through the container shader_carve.py carved.

The new tool reads the library, as an archive or as a saved library, joins
PSO -> stage slot -> program -> digest -> carved container -> spirv/index.json row, and prints counts only:
graphics PSOs by the number of code-base stages, those stages, the stage slots, the per-stage program counts
and the records it could not resolve. --out writes the same counts as JSON and refuses to name one of its own
inputs.

Measured on Xbox 1.0.2.1 (library 0x65F41EDD 930.048.020, 25,471 graphics records): no PSO has two code-base
stages. 25,027 have none and 444 exactly one - 343 MS, 60 PS, 41 VS - in a corpus of 13,383 VS+PS, 10,726
MS+PS, 1,336 MS, 24 VS and 2 VS+PS+slot 6; 21 records stay unknown because a stage's program is not in the
carve output. Its per-stage program counts (38 VS, 46 PS, 260 MS, 263 CS) are lower than the corpus's own
54 / 93 / 266 / 263: the library holds a second compiled form of 6,522 carved shaders and a program can serve
two slots.

So one 144-byte block with one code base at dwords 34-35 is enough for this package, and the runtime's refusal
of a pair where both stages read it can stand. docs/d3d12_vulkan.md §5.2 and its question 14, docs/boot.md
row 14 and docs/shader_library.md §4 and §6 say so; the stale pairing line in feature_scan.py's header is
corrected, and shader_library.py's header now says slot 6 is used by the 2 records that also have VS and PS.

tests/test_pso_code_base_pairs.py builds the library, the carve folder and both translation-index shapes from
bytes: 9 tests, no game data. The tool's __main__ block sets errors="replace" on stdout like every other tool,
which tests/test_tool_stdout_encoding.py checks. Also run: compileall, scripts/check_no_game_data.py,
test_shader_library.py (21) and test_text_write_line_endings.py (3). Whole-suite comparison, `python -I
scripts/run_semantic_tests.py tests -j 4` on Windows 11: plain 89d7dfcf5 reports 522 files, 8,099 tests, 42 files
failed; with this commit 523 files, 8,108 tests, 42 files failed - the two lists differ only by
test_run_wine_tests and test_build_batch_launch, which both pass alone on this machine and fail under -j 4 on a
loaded box. Those 42 are unchanged by this commit: 30 are pytest-based files that `python -I` cannot import and 6
more are script-style files the runner collects nothing from (ci.yml:87 runs both kinds elsewhere), plus the
Windows-only failures in test_world_names, test_bink_names, test_opus_tags, test_ci_registration and
test_mesh_alloc_single_writer. All of them are filed as findings on #14.

Claimed in the coordination issue as SHADER-CODEBASE-PAIRS (issue #14, comment 7146787349). AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:04:41 -05:00
20667abc24 gpu-test-results: RTX 2080 Ti (Turing) record at 5a5df8e0b
265 fixtures translated and spirv-val clean in both modes; 204/256 passed, 52 skipped
native and 236/256 passed, 20 skipped under LEONIDA_W64_EMULATE=1, 0 failed either way.
First Turing row in the table: mesh fixtures run (VK_EXT_mesh_shader is present with
driver 572.83) and cs_imgload_tfe / cs_imgload_d16_tfe (#31) pass, which the RTX 2060
SUPER note at d42773d07 did not see.
2026-11-26 00:04:34 -05:00
fbbf6abeeb docs/testing: de-duplicate the fused multiply-add section (DOC-TESTING-FMA-DEDUP)
Two copies of the cs_fma_fused paragraph were interleaved by a repeated merge: the RADV
sentence twice (2426df3d5 and its em-dash revision 53bc2c494), "operands taken from user
SGPRs" twice, Intel UHD Xe-LP and LEONIDA_FMA=exact each described twice. Keep one of each.

No number, driver version or device changes. The kept wording matches check.py's
judge_fma_fused: under --fma glsl each f32 word may be fused or split, so the older copy's
"failing cs_fma_fused with glsl" is now "give the split value". Dropped only the superseded
draft clause "(reusing the live a * a product in v3)", which its own author revised away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: coolpilot904 <andrewjsottile@icloud.com>
2026-11-26 00:04:14 -05:00
6d1b27b3a0 docs/shader_validation: one copy of the SHADER-302 and ps_oracle sections (DOC-SHADER-VALIDATION-DEDUP)
Repeated merges left "Packed 16-bit integer operations on RDNA2 (SHADER-302)" in the file four
times and "Pixel-shader ISA on the hardware" twice: 2d3369a4c (a merge of origin/main into
main) tripled SHADER-302 as SHADER-681's helper-lanes subsection came in, af1b3c96d merged
#3061 a second time, and #3499's --format table then landed in only one ps_oracle copy. One
SHADER-302 copy went in as a bare heading and its bullets in the middle of the RADV paragraphs.

Keep one of each, in the order a66a71ffd had them before the repeats, with the two real
additions in place: #3499's --format paragraph and table (0d58747e0) and SHADER-681's helper
lanes (58bc80c33). Every kept line is main's own text; the only line dropped that is in no
remaining copy is the "Limits: ... mrt0 as RGBA32F only" line that 0d58747e0 itself replaced.
Deletions only, so #1037 and #1039 (which insert after the first SHADER-302 copy) still merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: coolpilot904 <andrewjsottile@icloud.com>
2026-11-26 00:04:12 -05:00
85bf99395b Vulkan: sparse title memory behind LEONIDA_TITLE_MEMORY=sparse
The console maps a GPU VA to a physical page and reads zero where none is
mapped. With LEONIDA_TITLE_MEMORY=sparse the layer does the same:

- Sparse buffers (windows) over the title's two GPU address windows at
  the capture-replay address heap_base + VA: one for [1 GiB, 4 GiB), pieces
  of up to 64 GiB for [64 GiB, 448 GiB), made before any import.
- xmem tells physical pages apart (GraphicsListener mapped and pool): each
  XMemAllocatePhysicalPages section's own view is imported once, in 256 MiB
  pieces when first needed, and mapping, remapping or unmapping a page is a
  sparse bind of the VA page to it, or to nothing.
- The title's other GPU memory is imported once per range and bound at its
  own address; freeing or decommitting releases it.
- Binds are queued per page and go to the GPU in one vkQueueBindSparse on
  the graphics queue when any queue next submits (execute_now), signalling a
  timeline that submission and every later one wait for. Memory given up is
  freed after its unbinds.
- buffer_at, resource_at and host_at fall back to the windows for VAs no
  indexed buffer holds; slot 133 and committed buffers on title memory are
  spans of a window. Shaders and descriptors are unchanged.
- A startup self-test binds a host page, reads and writes it from the GPU,
  unbinds it and reads zero; the path runs only when it passes. One stderr
  line says which path is active and why. Imports stay the default and the
  fallback, unchanged (xmem reports physical pages as before without the
  variable).

On NVIDIA the bind is outside the Vulkan spec
(VUID-VkSparseMemoryBind-memory-01096: host imports are types 2/3, sparse
buffers list type 1); title_memory.h and docs/d3d12_vulkan.md say so.
d3d12_title_memory_sparse runs the whole title-memory test on this path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:02:53 -05:00
1ce60558c7 gameinput: the SDL keyboard pad honours a scripted hold too
#2098 gave the SDL path its own loop (held 300 ms, then until the title
has read the pads six times, at most 5 s), which ignored button@seconds:hold.
A press now lasts its own hold, then the read latch, and never past 5 s or
its hold if longer. The long-script test checks both: X kept past 300 ms
until six reads, Y kept for its 0.6 s after them. It fails on the old loop.

Found by AndreiKocherzhinskiiA on #1608.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 04:58:19 +00:00
f0e79141a4 gameinput: a scripted press can be held longer (button@seconds:hold)
At world-start frame rates the retail title reads its pad every few seconds,
so a 0.3 s scripted press falls between two reads and never arrives. An
entry may now give its own hold time; without one the press stays 0.3 s.
Holds of 0 or less, over 600 s or that are not a number reject the entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 04:58:19 +00:00
07bb65111b d3d12: A8_UNORM render targets through their R8 image, the alpha splatted
An A8 texture is an R8 image, and its RTVs were left null, so whatever the
title drew into one was lost. Now a pipeline with an A8 target uses an R8
attachment.
- At build, the pixel shader's output at that Location is stored as .wwww
  (src/spirv_output_splat.h, on the translator's whole-vector OpStore), so the
  one channel holds SV_Target.a.
- The channel blends with the alpha factors and op, the destination alpha
  read as the stored red.
- The alpha write bit writes it.
- RTVs of an A8 texture in A8 or UNKNOWN are made in the image's own format.

spirv_output_splat_test covers it on hand-built SPIR-V. It passes, as do
d3d12_draw, d3d12_rect_list and spirv_stores (RTX 4060 Ti, 616.64).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:38:55 -05:00
568ff3a851 docs: port status: the slot-86 refusals are not tessellation (none in the corpus)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:35:40 -05:00
b560d9480e docs: port status after the Vulkan boot fixes, the device loss and what is next
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:32:53 -05:00
9e4b0bab96 Fix metadata export tests and public-only scope 2026-11-26 08:32:29 +04:00
349be34699 FSPX: capture the title's untranslated slot-67 programs and translate them in the build
The title's compute pipelines arrive at slot 67 as FSPX payloads built from its own data (2,680 distinct in the first 25 s of a boot), and the build only unpacked the FidelityFX DLL's 29. The runtime now saves each untranslated payload once into <work>/shaders/captured (LEONIDA_CAPTURE_PROGRAMS, 0 off). make_game.py's shaders stage unpacks and translates that folder into spirv/fspx-captured, and the shader library loads it beside fspx/ and bvh/. fspx_unpack.py takes a folder of .fspx payloads. Documented in docs/fspx.md, Captured programs.

Tests: tests/test_fspx_unpack.py (35, a new folder case), test_fspx_unpack_out.py and test_fspx_shaders_stage.py pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:32:05 -05:00
c49fe8676d Merge port/rect-lists: rectangle lists through a generated geometry stage 2026-11-25 23:09:44 -05:00
e763de6da2 Merge port/wave64-tiers: wave64 emulation only for tier C shaders, lane-mask fix 2026-11-25 23:09:41 -05:00
4c7e7e4dad Merge port/pipelines (rest): refused streams get a pipeline object, compile-time notes
Conflicts kept both sides: slot 61 sampler and page mapper handlers beside the refused-pipeline handler, and the per-type descriptor increment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:09:39 -05:00
790b4f4364 image_fuzz: image_load_pck / image_load_pck_sgn on the hardware oracle, measured on RDNA2 (HW-IMAGE-LOAD-PCK)
design.md had no measured rule for the no-format-conversion image loads.
Measured natively on an RDNA2 iGPU (gfx1036) through tools/hw_oracle: the
texel's bytes form little-endian dwords selected by dmask (0 past the last),
a texel under 4 bytes is zero-extended (pck) or sign-extended from its top
bit (pck_sgn), and the FORMAT's numeric type does not matter.

image_fuzz.py gets --op image_load_pck|image_load_pck_sgn for the hw oracle,
the pck_oracle CPU model, sub-4-byte texel formats, a pck_sgn_zero_extend
perturbation and a wrong-FORMAT control that changes the texel size;
tests/test_image_fuzz_hw.py pins the measured words. The translator does not
translate these ops yet; this is the measured model it needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP
2026-11-25 22:55:38 -05:00
cbdc74fde5 docs: monolithic, pipeline-library and shader-object compile times of translated pixel shaders
vk_pipeline_paths over 31 pixel shaders on the RTX 4060 Ti (616.64): the fragment library and the
shader object cost what the monolithic pipeline costs (mean ~4.0-4.2 s, median ~0.6 s); only the
link is fast. So the pipelines stay monolithic, made off the title's thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:41:55 -05:00
c59ae5ed63 docs(cpu_features): record baseline instruction counts and AVX1/SSE4.2 host delta
Record the baseline instruction counts measured by tools/cpu_feature_scan.py
(at 0b11d86b) on the 1.0.2.1 executable (AVX, FMA, AVX2, BMI1, BMI2, F16C,
AES, ADX, PCLMULQDQ, POPCNT, MOVBE, LZCNT, CX16, PREFETCHW, and the absent
RDRAND/RDSEED/FSGSBASE/CLFLUSHOPT sets), including the 32,101 register-source
vbroadcastss/vbroadcastsd sites counted under AVX that require AVX2 and the zero
vgather*/vpgather* count.

Add a subsection on AVX1 + SSE4.2 hosts (Intel Sandy Bridge and Ivy Bridge)
separating the Haswell/ABM delta that faults with #UD from legacy LZCNT/TZCNT
(F3 0F BD / F3 0F BC), which execute silently as BSR/BSF without #UD while 988
.pdata tzcnt sites immediately feed a CF consumer and 149 .pdata lzcnt sites
are 4-byte encodings.

Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7181466437
AI-assisted: yes (Antigravity, Gemini 4 Carbon)
2026-11-26 00:37:35 -03:00
a73a57e133 Merge pull request #2187 from aslan2142/device-markers-amd
device-fault: AMD buffer-marker breadcrumbs name the dispatch that hung (RT-DEVICE-MARKERS-AMD)
2026-11-26 04:35:46 +01:00
0d1ad7d67e docs: slot 86's never-made pipelines; how far the title gets with pipelines off its thread
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:31:11 -05:00
e418c1e4b6 vulkan: AMD breadcrumbs name the dispatch that hung (LEONIDA_DEVICE_MARKERS)
On RADV a GPU hang ends in VK_ERROR_DEVICE_LOST with no checkpoints, so the
device-fault report lists the 64 dispatches in flight but cannot say which
one stopped the queue.

LEONIDA_DEVICE_MARKERS=1 (with LEONIDA_DEVICE_FAULT=1 or 2) enables
VK_AMD_buffer_marker where the device has it. Every dispatch the report
numbers writes its seq into its queue's slot of one persistent host-visible,
coherent buffer: at top of pipe before the dispatch (started) and at bottom
of pipe after it (finished), with vkCmdWriteBufferMarker2AMD. On a loss or a
stall report each queue's last finished and started seq are printed, and
the oldest started, unfinished dispatch is reported as the likely hang and
marked in the submitted-dispatch list. A history of the last 16,384
dispatches names it when it has left that list. The values are best-effort
after a loss, and the report says so.

The seq is now handed out when a dispatch is recorded, so the marker and
the list share one numbering; it counts every recorded dispatch, and the
list can show gaps where a submission recorded more than 64.

Cost with the switch on: two marker writes per dispatch and one history
entry; with it off nothing changes. Without the extension, or without
LEONIDA_DEVICE_FAULT, one "device-markers: unavailable" line is logged.

Tests: vulkan_device_markers (portable: numbering, marker writes, ring,
likely-hang verdicts, the 32-bit wrap) and vk_device_markers (a real device:
after the wait the started and finished markers equal the last seq; SKIP
without the extension).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:29:35 -05:00
1e7b057ef2 runtime: rectangle lists (topology type 19) through a generated geometry stage
The title draws its full-screen passes and tiled lighting as D3D12.X rectangle
lists (pipeline topology type 19, list topology 17), which the Vulkan layer
refused, so those draws were lost. Ported from VIctory (GPL-3.0-or-later,
Marvisak and contributors, DexNom fork; victory-shader emit/rect.rs, 683ad7a99):

- src/rect_list_gs.h/.cpp read the vertex shader's SPIR-V output interface
  (Location outputs of 32-bit float/int/uint, Position, clip/cull distances when
  the shader declares their capability; separate built-ins or glslang's
  gl_PerVertex block, mirrored) and emit a SPIR-V 1.0 geometry shader, cached
  per output signature. VIctory's rule: the corner is the vertex sharing x with
  one other and y with the other; the fourth vertex is a + b - corner for every
  float output (exactly b or a where a or b has the corner's bits), integer
  outputs keep vertex 0's; unequal or non-positive w, coincident vertices or no
  corner stay a triangle. Two triangles, both led by vertex 0 (the provoking
  vertex for flat inputs) and turned as the title's; the primitive ID is passed.
- d3d12_vulkan_device.cpp: a type-19 PSO appends that stage and takes triangle
  lists; every other topology is unchanged. No geometryShader, or a VS the stage
  cannot be made for (no Position, Layer/ViewportIndex), is E_NOTIMPL with a log.
- tests/test_rect_list_gs.py runs the generator through rect_list_gs_tool on
  assembled vertex shaders and interprets the stage on the CPU (corner orders
  TL/BL/BR, TL/BL/TR and the third, unequal w, cache, refusals, spirv-val);
  d3d12_rect_list_test draws three rectangle orders plus a triangle control on
  the GPU (RTX 4060 Ti, 616.64, also under the validation layer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:14:54 -05:00
2269728203 translator: emulate only tier C wave64 compute and mesh shaders (SHADER-10)
With --wave64-emulate, rdna2spirv.compute_halves now runs tools/wave64_halves.py
on every wave64 CS/MS and keeps the workgroup-memory emulation for tier C. Tiers
A and B run natively, one console half per subgroup:

- the thread index is relabelled from the subgroup (SubgroupId * SubgroupSize +
  SubgroupLocalInvocationId), so a subgroup holds threads 32k..32k+31 whatever
  order the host gives; it feeds v0..v2, a mesh shader's v5 / s3, the lane and
  the mesh export slot;
- an LDS access after a conflicting one of the wave (RAW / WAR / WAW, which the
  console's lockstep ordered with no barrier) and a scalar load after a store
  get a workgroup barrier in front, in blocks every invocation runs;
- with no memory write at all, s_barrier is left out;
- the index entry gets wave64_compute (+ reasons / idioms) and subgroup_size 32.

--wave64-emulate-all keeps the old behaviour (module flag WAVE64_TIERS).

The analysis learns the compute rules (exact lane id, the first lane's wave base
of D + lane, one-half EXEC regions, barrier and memory-order checks, group
size) and, for every stage, forms after VIctory's exact idioms: loads from
uniform addresses, all-or-none masks (s_cselect_b64 exec / 0 and their mixes),
uniform compares under a narrowed EXEC where no running half has it empty,
stale scalars only across a vote edge the read does not depend on, the
s_andn2_wrexec waterfall and loads through the waterfall descriptor.

tests/semantic: test_wave64_compute_tiers.py (fixtures cs_w64_half_local,
cs_w64_lds_swap, ms_w64_skeleton; native modules at 32 and 64 lanes, shuffled
placement, subgroups run one after another; negative controls) and
test_wave64_halves_victory.py; spirv_mini_interp gains OpUDiv / OpUMod and
run_workgroup(subgroup_order=...).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:14:29 -05:00
eac411eeb2 Merge port/pipelines (in progress, at af4210269): PSOs on worker threads, per-frame wait budget, early list
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/shims/d3d12_xs_slots.h
#	runtime/test/xs_proxy_mock_test.cpp
2026-11-25 22:13:15 -05:00
34d4726873 Merge port/frame-timing: the title's time step follows real time from 1 to 3000 fps
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/port_status.md
#	runtime/src/main.cpp
2026-11-25 22:05:29 -05:00
8681c690e5 Merge port/d3d12-slots2: CreateSamplerX and sampler stride, WaitValue holds, page mappings, texture layouts, GPU timestamps
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/port_status.md
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/shims/xmem.cpp
#	runtime/test/d3d12_title_memory_test.cpp
2026-11-25 22:04:38 -05:00
1c06996a08 leonida_mods gui: on macOS, the missing-Tkinter hint names Homebrew's python-tk@<version>
Homebrew's Python ships without Tkinter, so ./Mods.sh on a Mac stopped with the Debian hint (sudo apt install
python3-tk). The hint now names the formula for the running version; docs/modding.md says it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 04:04:16 +01:00
b3e541b224 d3d12_xs: drop the null-RTV marks of a descriptor heap when it is released
The null-view marks (#1504, by ubiquitarianism) are kept by the real CPU
handle. They were moved by descriptor copies and cleared by a view made
with a resource, but never dropped when the heap went away, so an RTV heap
made later at the same address inherited stale marks and its clears were
skipped. The heap proxy now records an RTV heap's real CPU range and
heap_release drops the marks in it. The barrier conversion keeps no state
across calls, so it needs nothing here.

xs_proxy_mock_test: an RTV heap's marked view is skipped while the heap
lives and cleared after it is released; a mark outside it stays; a second
heap at the same address starts unmarked and marks again. docs/d3d12_vulkan.md
says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:03:00 -05:00
2694497e81 runtime: step the title by the measured frame time at any frame rate
The title's timer steps its time sets by the measured QueryPerformanceCounter
delta, but held to at least the nominal frame time (1 / its 30 fps target)
and at most a 1/15 s constant (+0x2226040, and the camera's set in
+0x22264d0). The step is real only between 15 and 30 fps: above 30 the
world runs fps/30 too fast (the console's doubled speed when a glitch
doubles the frame rate), below 15 at fps/15 of real time (0.10-0.15 in
VIctory's 1.5 fps world).

src/frame_step.h moves the floor's two loads to the timer's own minimum
step (1/3000 s) and the cap's two loads to its 1.0 constant, after checking
all four loads and both targets hold the 1.0.2.1 bytes; main.cpp applies it
before any title code runs. LEONIDA_TIME_STEP=stock keeps the title's step.
The same patch written into VIctory's running title gave game time at 1.000
of real time at 30 and 70 fps and over every world frame under 1 s.

frame_step_test checks the plan, the step it gives from 1 to 1000 fps,
refusals on other bytes, the switch, and apply_to_image on a mapped stand-in
whose loads share a page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:02:40 -05:00
a4275b1571 d3d12: Write64 timestamps when the GPU gets there; docs for the slot ports
Ported from VIctory (GPL-3.0-or-later, Marvisak and contributors, DexNom fork),
victory-gpu queue.rs:697-731 (Written::GpuTimestamp, SystemTimestamp) and
list.rs:1964-1983.

- List slot 72 flag 1, the GPU timestamp: a timestamp query of the device's
  own heap (COPY_QUEUE_TIMESTAMP for copy lists) ended where the list is and
  resolved into the title address, so the GPU writes its clock there when it
  reaches it, in the queue's ticks (GetTimestampFrequency,
  GetClockCalibration). An address that is not 8-byte aligned, or a device
  without timestamp queries, keeps the CPU clock at recording (logged).
- Flag 2, the system timestamp: QueryPerformanceCounter once the submission
  has run, as VIctory stores it. The console queue signals a fence of its own
  behind an ExecuteX whose lists asked for one; a thread-pool wait writes the
  counter at each address when it completes.
- docs/port_plan.md and docs/port_status.md: what port/d3d12-slots2 does.

Tests: xs_proxy_mock_test (flag 2 stored after the submission, the queue's
fence made once, a reset forgets the stamps), d3d12_title_memory_test on the
RTX 4060 Ti (the GPU timestamp lies between calibrations taken after
recording and after completion; the system timestamp likewise).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:01:13 -05:00
5af6cd3d69 Merge remote-tracking branch 'origin/main' into gpu-results-m3
# Conflicts:
#	docs/gpu_test_results.md
2026-11-26 04:01:08 +01:00
8d25334d12 runtime: PSOs made on worker threads, a per-frame wait budget, the early list
Ported from VIctory's pipeline/make.rs and pipeline/library.rs (GPL-3.0-or-later, Marvisak and
contributors, DexNom fork). The title creates ~60,000 PSOs in its first 20 s; compiled at creation,
its first CreateComputePipelineState held the main thread until the title's 30 s hang detector fired.

- Creation checks the description and the translator's index (program hash and entry, bindless,
  mesh limits, code base, workgroup memory, the module file) and returns. The module, the layout and
  the pipeline are made by a worker (src/pipeline_queue.h: half the logical processors, 2 to 8,
  below normal priority). The SPIR-V is read at creation only where a check on it could refuse the
  PSO on this device; the game's index lists the capabilities, so on the RTX 4060 Ti no module is
  read at creation.
- SetPipelineState starts the build and waits while the frame's budget lasts
  (LEONIDA_PIPELINE_WAIT_MS, 500 per frame and kind, one window the threads share, never for a
  pipeline held over 3 s / 10 s). A draw, mesh draw, dispatch or indirect dispatch recorded without
  a made pipeline is dropped and counted, logged once a second; the list stays valid. Frames are the
  console frame clock's (slot 80); the title's device is bounded from its creation. A device of no
  title (PC interface, tests) waits for the build until a frame begins, so nothing drops there.
- The early list: keys of the PSOs a run bound, in early-pipelines.txt beside pipeline_cache.bin
  (or LEONIDA_EARLY_PIPELINES), started at creation on the next run, depth-only first.
- The title's device reads the 57 MB index on a thread from its creation (about 3.5 s).

Tests: pipeline_queue_test (no GPU: the frame window, queue order, a retired job, drops, the early
list's file) and d3d12_async_pipeline_test (RTX 4060 Ti: 192 PSOs created in ~15 ms, all draws
dropped and counted while held, all drawn once made; the early list written and read back; console
slot 86 makes the stream PSO). vk_pipeline_paths measures monolithic, pipeline-library and
shader-object compiles of translated pixel shaders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:55:47 -05:00
7b1fe62850 Keep main's watchdog switch and say where the peek default went
f0611b752 took the executable's addresses out of the code. Two behaviours
changed with it; the removal stays, the changes are now explicit:

- runtime/src/main.cpp: the watchdog kick runs again only with
  LEONIDA_TITLE_WATCHDOG=0, as on main; LEONIDA_TITLE_WATCHDOG_KICK only
  supplies the two RVAs it needs. Either variable alone leaves the
  watchdog armed and the loader says so once (before this commit the kick
  ran whenever LEONIDA_TITLE_WATCHDOG_KICK was set).
- scripts/windows-boot/boot.ps1 no longer has the game- and
  session-state RVAs built in, so LEONIDA_PEEK has no default and the
  RESULT states read "?" unless LEONIDA_GAME_STATE_RVA and
  LEONIDA_SESSION_STATE_RVA are set. The script now warns when they are
  not, and runtime/README.md (LEONIDA_PEEK, LEONIDA_TITLE_WATCHDOG and
  _KICK rows), scripts/windows-boot/README.md and docs/first_run_ui.md
  say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:55:15 -05:00
d09286f624 rdna2spirv: translate only the measured dot4 op_sel forms; keep restore_dot4_inline_sel
The general rule from #1495 (dot4_op_sel_fields / restore_dot4_op_sel,
ported from luizwidmer/palmetto) took the stored op_sel/op_sel_hi of any
v_dot4_i32_i8 that llvm-mc printed with the defaults. That translated
op_sel 0 / op_sel_hi 5 with a VGPR second source, a word #1317's
test_fspx_dot4_op_sel_disasm.py (case (0, 5)) requires to stay refused:
only op_sel 2 / op_sel_hi 5 was measured on gfx1036. The translator suite
failed there.

Resolve it on the measured side:
- drop dot4_op_sel_fields and restore_dot4_op_sel;
- keep main's restore_dot4_inline_sel (#984) and its three call sites:
  the clean-listing check, the forward re-anchor search, and the exact
  re-anchor window #1662 added today. The general rule does not cover
  only those cases, so it cannot replace them;
- tests/semantic/test_dot4_printed_op_sel.py now checks that the
  inline-integer form is restored in a clean listing and on re-anchoring,
  and that op_sel_hi 5 with a VGPR S1, op_sel 1 / op_sel_hi 6,
  op_sel_hi 4 and a non-default S2 half stay refused;
- docs/design.md "Signed-byte dot products" states how each form was
  confirmed (hardware for op_sel 2 / op_sel_hi 5, a corpus count for the
  inline-integer form, refused otherwise); docs/fspx.md follows.

This also settles the #1662 / #1862 overlap: #1662's call site stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:53:14 -05:00
95d1878dc3 fspx_unpack: keep main's literal-form check for the 24-byte prologue (#583 head)
The copy of #583 in this branch replaced main's check that both short
prologue words are literal-bearing VOP3 opcode-0x180 words
(words[k+1] & 0xFFFE0100 == 0x03FE0100, the shape fspx_prologue_probe.py
checks) with a looser SRC2 == 0xff test. Keep main's check, as #583's head
(3af97a1ec, by Tyrannys) does, with this branch's named constants, and take
that head's test_short_prologue (the stricter check refuses 0x03FF0000)
and its docs/fspx.md paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:51:22 -05:00
8d686309b0 Merge main into integration/boot-combined (RT-BOOT-COMBINED)
Conflict in runtime/shims/d3d12_xs_device.cpp, proxy_copy_descriptors_simple:
keep this branch's copy_null_rtv_marks call and main's fsdraw::enabled()
gate for the descriptor-copy diagnostic.

tools/rdna2spirv.py merged without a textual conflict, but #1662 on main
calls restore_dot4_inline_sel in the exact re-anchoring path, which this
branch had deleted. The merge puts main's function back so that call
resolves; the next commits reconcile it with the dot4 op_sel rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:49:53 -05:00
43f98a6dd8 docs: the title now runs 36 s; its first compute pipeline blocks until the hang detector fires
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:35:55 -05:00
a61274951b Merge port/xmem-hooks: XMemAlloc through the title's hooks; committed resources from the title's allocator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/port_status.md
#	runtime/src/main.cpp
2026-11-25 21:33:41 -05:00
69e62ee790 runtime: committed resources from the title's allocator (__XMemAllocationHooks__)
Ported from VIctory (GPL-3.0-or-later, Marvisak and contributors, DexNom
fork): victory-hle xmem.rs (hooks, XMemAlloc/XMemFree, XMemAllocDefault)
and victory-gpu resource.rs (use_allocator, Memory::for_resource,
resource_attributes).

- xmem: once the title is mapped, gta6rt reads the exe's export
  __XMemAllocationHooks__ (two routine pointers, read at every call).
  XMemAlloc/XMemFree call them; the Default variants never do. An
  XMemAlloc/XMemFree made from inside the routines takes the default
  allocator, and no lock is held across a hook call (the title's handlers
  call XMemAllocDefault, which announces GPU blocks to the D3D12 layer).
- XMemAllocDefault decodes the attribute word (title_memory.h): CPU blocks
  at the asked alignment; graphics memory types and 32-bit addresses get
  pages of their own in the GPU window, made visible to the D3D12 layer and
  taken off it before they are freed (stale visible ranges under a new
  block are dropped first).
- D3D12 layer (rt::d3d12::set_title_allocator): the title's committed
  resources (CreateCommittedResource*, console slots 76/127 through the
  proxy) take GetResourceAllocationInfo's size from the allocator with
  VIctory's attributes (graphics allocator 128, page size, alignment,
  memory type 1/3), zeroed. Buffers are bound to that memory's import, so
  their GPU virtual address is the title address; textures report it and
  keep their own image memory. Released resources go back through the free
  routine (a buffer after the GPU retired the work submitted so far).
  Without hooks nothing changes.
- Tests: xmem_test (hook routing with a stand-in export, re-entrancy,
  rewritten and null table entries, GPU blocks); d3d12_title_memory_test
  (a slot-127 texture and committed buffers at the allocator's addresses,
  a GPU copy landing in the title's pages, frees through the hook).

Retail title: its hook takes a 64 MiB render-target pool from
XMemAllocDefault (attributes 0x30808000) and hands both back buffers out of
it; the pool check passes. Next: XboxBvhBuilder.dll throws a C++ exception
right after the first slot 62 pipeline finds no translated shaders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:26:28 -05:00
85fd92001e translator: wave64 VALU lane masks printed in wave32 syntax are SGPR pairs
The corpus listings come from llvm-mc's gfx10 default, wave32, which prints a
wave64 program's VOP3 lane-mask operand as one SGPR: v_cmp_lt_f32_e64 s4, ...
writes s[4:5] on the hardware, the carry-out of v_add_co_u32_e64 s12 likewise,
and v_cndmask_b32_e64 ..., s0 reads s[0:1]. The translator wrote s4 alone, so a
later 64-bit read (s_and_b64 vcc, exec, s[4:5]) gave lanes 32..63 the stale
bits of s5, natively and emulated. 18,439 of the 23,841 wave64 corpus shaders
read such a pair after one of these compares.

widen_wave64_masks turns the SDST of v_cmp*_e64 / v_cmp_class*_e64, the
carry or flag SDST of the VOP3b two-destination ops, the carry-in of the
_co_ci_ forms and the v_cndmask_b32_e64 mask into pairs when the program is
wave64, before the lane-mask analysis reads it.

tests/semantic/test_wave64_mask_pairs.py (fixture wave64_cmp_sgpr_pair.asm):
64 lanes against the ISA's words; 24 lanes are wrong without the rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:08:55 -05:00
88b290fcbd Merge pull request #1662 from Tyrannys/dot4-sel-exact-anchor
rdna2spirv: the exact re-anchor keeps a signed-byte dot's stored op_sel_hi (SHADER-DOT4-SEL-EXACT-ANCHOR)
2026-11-26 02:57:34 +01:00
ad6045b806 d3d12_xs: say so when LEONIDA_D3D12=vulkan is asked of a runtime built without the Vulkan device (RT-VULKAN-REQUESTED-NOT-BUILT)
A gta6rt configured without Vulkan headers is built without
LEONIDA_VULKAN_DEVICE. D3D12XboxCreateDevice then ignored
LEONIDA_D3D12=vulkan without a word and wrapped the host's D3D12 device,
so a run stopped somewhere else and read like a boot result.

It now prints one [rt] d3d12_xs line naming the cause and the configure
options. Which device is created does not change. The reading of the
variable moves to shims/d3d12_backend.h, used by both builds; new CPU-only
test d3d12_backend, registered outside the Vulkan-headers block.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 09:53:41 +08:00
ef34931860 Merge pull request #2123 from qhukz13/cont/d16s8-d24-uav
d3d12: depth-stencil UAVs for console D16S8 (format 118) made as D24S8
2026-11-26 02:52:29 +01:00
66e96ccea6 d3d12: the session cache limit counts what a session adds to an offline seed; exit wait sized from measurements
Review of #1886: the seed the driver hands back with the session's builds no longer counts against
LEONIDA_PIPELINE_CACHE_BYTES (pipeline_cache_store::over_save_limit, with a unit test), the stale 512 MiB
checkpoint sentence is gone from docs/d3d12_vulkan.md, and kExitCacheWriteMs is 6 s with the measured
write times (1.87 GB in 1.4 s, 2.9 GB in 1.3-1.6 s; about 2.2 s at the 4 GiB default).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwRYcpySx4P4ncQ3wD5
2026-11-26 02:36:38 +01:00
543ba68176 gpu results: RTX 3090 Windows 621.40 2026-11-25 20:29:46 -05:00
a88bb83e06 Merge remote-tracking branch 'origin/main' into fix/explicit-lod-bias-moltenvk 2026-11-26 02:29:04 +01:00
10b01d207e Merge remote-tracking branch 'origin/main' into session-cache-limit 2026-11-26 02:28:52 +01:00
f6dd162511 Merge port/present: title window and Vulkan present, frame clock, 1440p display profile, frame captures
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/port_status.md
2026-11-25 20:26:04 -05:00
7c81b8eef6 docs: presentation, frame clock and display profile on port/present
d3d12_vulkan.md 4.5 describes the wiring (title window, presenting queue,
device clock, screenshots), and its device-slot row now names VIctory's
clock and LEONIDA_XS_FRAME_STATISTICS_SLOT. runtime_imports.md lists the
title's window imports and what sizes its frames (measured: the DXGI mode
does not, the executable's SDR mode does). port_plan.md and port_status.md
give the state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 20:25:21 -05:00