Commit Graph

4696 Commits

Author SHA1 Message Date
70d3517889 d3d12_xs: blend state for slot 57 native pipelines from state blob A (RT-SLOT57-BLEND-STATE)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 08:35:47 +01:00
6d66718f3e d3d12: title memory past the window cap names a zeroed scratch window (RT-TITLE-WINDOW-OVERFLOW)
Past LEONIDA_TITLE_WINDOWS_MB, or with no arena room for a window,
resolve_title_memory handed the GPU the title's raw VA. That names
nothing of the device's, and one read of it lost the device at the
world start (#1537). Reserve 16 MiB + 64 KiB of zero-filled arena with
the first window and point such addresses into it instead: the cost is
a wrong result, not the device. The raw VA is kept only when even the
scratch did not fit (logged once).

d3d12_title_window_cap runs d3d12_title_va_test --window-cap with a cap
of 0: two views of the title's memory name the arena, share the
scratch, and a dispatch through one reads zeros.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 00:21:56 -06:00
f0611b752f Remove the title's executable addresses #984 brought in; read them from the environment
#984 (273b3bdf9) put RVAs and file offsets of the retail executable into code, docs and scripts.
The code paths that need one now read it from an environment variable and are off when it is
unset; the docs and examples say the location is measured locally.

- runtime/src/main.cpp: the hang-watchdog kick takes its trap and kick RVAs from
  LEONIDA_TITLE_WATCHDOG_KICK="<trap RVA>,<kick RVA>" (hex), still only when the trap
  instruction is at the first one. Unset, the watchdog stays armed, as before by default;
  LEONIDA_TITLE_WATCHDOG=1 keeps it armed, and LEONIDA_TITLE_WATCHDOG=0 without the RVAs says
  once that it needs them. The LEONIDA_PEEK example uses placeholders.
- runtime/shims/startup_trace.h: the transient-pool dump fires at the int3 that
  LEONIDA_POOL_DIAG_AT names (`<module>+0x<offset>`, as the trace prints it), off when unset.
- scripts/windows-boot/boot.ps1: LEONIDA_PEEK's default comes from LEONIDA_GAME_STATE_RVA and
  LEONIDA_SESSION_STATE_RVA (no peek when unset), and the RESULT digest matches those values;
  the examples and README use placeholders.
- runtime/README.md documents LEONIDA_TITLE_WATCHDOG_KICK and LEONIDA_POOL_DIAG_AT.
- docs/fspx.md, docs/d3d12_vulkan.md, docs/movies.md, docs/embedded_shaders.md and a comment in
  runtime/shims/d3d12_xs_alloc_size.h drop the addresses and offsets.

This follows the same change on the earlier integration branch (#1495).
2026-11-25 01:00:37 -05:00
7f08453da7 runtime: the first-run UI keyboard pad reads keys only with focus (RT-FIRST-RUN-PAD-FOCUS)
gta6rt --first-run-ui defaulted LEONIDA_KEYBOARD_PAD to always, so keys
typed into another program reached the title's consent pages (#1552,
hazard 1). Default to the focused mode 1; scripted presses still run
while the window is unfocused. tiny_game checks the default under
run_tiny_first_run_ui, which now clears the caller's setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 23:54:31 -06:00
970837c753 d3d12_xs: null-resource texture barriers and null-view RTV clears on the console list
List slot 146 (Barrier -> GCL7 80): a texture barrier with no resource, which
the console takes as a global barrier, is forwarded as a D3D12_GLOBAL_BARRIER
with the same sync and access; a mixed texture group is split into runs in
order, in storage that lives for the call. Calls with nothing to convert keep
the title's pointer. A group array that cannot be read safely (null with a
nonzero count, an unknown group type, absurd counts) is refused whole and
logged once per reason.

List slot 52 (ClearRenderTargetView -> PC 48): the device proxy marks the real
handle when CreateRenderTargetView gets no resource (moved by RTV descriptor
copies, cleared by a view made with a resource), and the clear of a marked view
is skipped, as on the console. Other views keep today's path.

Before this, both calls put the PC list in its error state, so Close failed and
ExecuteCommandLists dropped the submission. xs_proxy_mock_test models that
error state in its mock list and covers both paths; the two old slot-146 cases
that passed garbage words now pass valid ones.

The null-resource barrier and null-view clear behaviour were first reported by luizwidmer/palmetto.
2026-11-25 00:51:27 -05:00
018145b338 runtime: serve the spatial stream on the silent output endpoint
The title activates ISpatialAudioClient on the render device, not IAudioClient (the first
game run with the silent endpoint logged that IID and stopped as before). The silent device
now answers ISpatialAudioClient and ISpatialAudioClient2: a 7.1 static bed, no dynamic
objects, mono 48 kHz float objects, 480 frames a pass. Its ISpatialAudioObjectRenderStream
signals the stream's event every 10 ms while it runs, and its objects write into a
scratch buffer. The periodic event thread is shared with IAudioClient.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 00:20:54 -05:00
de234e185c value writes: carry the console's value writes on the GPU label path
main records the console's value writes (list slots 71 and 72) as GPU completion labels since #939. This widens where a completed label may land: the GPU address arena, and the pages the title maps, which main does not track and whose title view may be PAGE_NOACCESS for the CPU. The recording stays main's; the landing and the default are ours.
2026-11-25 13:17:09 +08: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
26df694ce4 subgroup_size: reject half-zero and invalid subgroup size ranges in decide_subgroup_size 2026-11-25 06:03:55 +01:00
582e14d922 loader: a run-time LoadLibrary takes the LEONIDA_COMPAT_DIR module too
LEONIDA_COMPAT_DIR only applied to static imports: runtime/README.md said "a run-time LoadLibrary of the
same name does not yet". A mapped image's LoadLibrary of a module the folder holds got the shim's
pseudo-handle instead of the drop-in DLL, and GetProcAddress on the compat DLL's real handle looked the
name up in the shim of the same module name first, so one console module could be served half by the
drop-in and half by the shim, which the static step exists to prevent.

Now shims::BundledModuleOps gains compat_module / owns_compat_handle, which rt::Loader answers from the
same compat_handle() its static step (resolve_compat) uses, so both get one HMODULE per module. In
shims/library_loader.cpp:
  - LoadLibrary* checks the compat folder before the shim registry and the bundled package DLLs;
  - GetModuleHandle* answers a compat module's handle once it is loaded and NULL before (never the shim's
    pseudo-handle);
  - GetProcAddress on a compat handle gives only that DLL's exports;
  - FreeLibrary on it returns TRUE and keeps it loaded (it is the Loader's reference, static imports may
    be bound through it; compat modules stay for the process lifetime).
A compat file Windows refuses fails that LoadLibrary with Windows' error (logged) instead of throwing
into the title.

loader_test links library_loader.cpp and gains test_compat_runtime_loads: eight cases with a synthetic
drop-in DLL and the test shim module, no game data.
2026-11-25 01:38:28 -03:00
3cf0a41bc5 d3d12_xs: make a D16S8 depth texture without UAV when the depth provider refuses it
Since #939, slots 76 and 133 hand a depth-stencil texture with unordered access
to the depth provider. On a GPU with D24S8 attachments (every NVIDIA card) the
Vulkan layer's pc_format() makes D16_UNORM_S8_UINT (format 118) as
D24_UNORM_S8_UINT, and Resource::enable_depth_stencil_uav accepts only
R16_TYPELESS, 118 and R32G8X24_TYPELESS, so it answers E_INVALIDARG. Slot 133
passed that on for a 1280x720 format 118 texture with ALLOW_DEPTH_STENCIL |
ALLOW_UNORDERED_ACCESS (all-ones layout), and the boot stopped on an int3.

When the provider refuses (E_INVALIDARG or E_NOTIMPL from the provider call
itself), slot 76 now makes the committed texture without unordered access and
slot 133 goes on to its stand-in (the title-placed texture, else the committed
one), as both did before the provider. The first refusal per slot is logged.
Any other failure is passed on as before: the provider out of memory, the
backing's own CreateCommittedResource, a refused placement or description.
The refused backing is released and no placement range is registered.

On a real boot (Windows 11, RTX 4070 SUPER, driver 621.24), on 0bc810504 with
an earlier form of this change that fell back on any failure of the depth path
(the only one that occurred was the provider's): the fallback fires once
(slot 133, format 118, hr=0x80070057), no int3, 6,187 PresentX ok and 0
failed, 69/69 captures non-black, and the boot reaches the first-run pages.
Without it, 3 of 3 boots stopped on the int3 after 182-362 PresentX.

Tests:
- xs_proxy_mock: a mock provider refusing a format 118 texture (E_INVALIDARG,
  E_NOTIMPL) through slots 76 and 133 gets S_OK and the stand-in, with the
  refused backing released; E_OUTOFMEMORY from the provider, a failing backing
  and a refused placement are passed on with no stand-in.
- xbox_d16s8_refused_uav (Vulkan, LEONIDA_CONSOLE_D16S8=d24): slots 76 and 133
  return a depth-stencil texture without unordered access.
Both fail without the change (slot 76 and slot 133 each checked on its own).

Follow-up: teach enable_depth_stencil_uav the D24S8-made form of format 118,
so these textures keep their UAVs on NVIDIA too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
2026-11-24 23:34:00 -05:00
eb39d2765e rdna2spirv: flush v_exp_f32 denormal results 2026-11-25 05:33:06 +01:00
a05f1f3cdb gameinput: queue only events a callback wants, so a later pad's connect is not stuck behind a backlog (RT-GAMEINPUT-LATE-PAD)
A pad connected after the title started was seen by the shim but not by the
title, while pads present at start worked. Pads present at start reach a title
through blocking enumeration, which runs synchronously in RegisterDeviceCallback.
A later pad reaches it only through a queued connect event. queue_event queued
every reading and guide change whether or not any callback listened. With a
dispatcher held, a title that runs one item a frame (Dispatch(0), the pattern
Microsoft's Dispatch page suggests) falls further behind every frame, because a
moving stick or a sensor pad's 125 Hz stream queues items faster. The later
pad's connect event then never comes out of the queue.

queue_event now drops an event no registered callback matches, as GameInput has
no work to dispatch then. The first few RegisterDeviceCallback calls and the
first CreateDispatcher and Dispatch calls are logged, so a retail run shows
whether the title holds a dispatcher (not yet confirmed for the retail title).

Test: test_late_pad_behind_dispatcher. A title with a dispatcher registers its
device callback with no pad, a first pad moves on every poll, and a pad attached
later must reach the callback within ten frames of Dispatch(0). Without the fix
it fails (2 of 371 checks); with it, 371 checks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:29:04 +05:00
f9792cc56d Merge remote-tracking branch 'ubiq/main' into feat/gdk-lifecycle-window-hook
# Conflicts:
#	scripts/build_runtime.ps1
2026-11-25 00:58:58 -03:00
d16eb1ff0a d3d12: give a depth placement inside another one's PC extent its own image
The slot-133 depth/UAV registry recorded each placement's extent as the PC
allocation size and refused, with E_NOTIMPL, any placement that started
inside another live range. On RADV the PC size of a large D16 target is
above the block the title placed it in, so the title's next block starts
inside the previous range: its first depth target was refused, no trace
line showed it, and the title stopped on its own assert and crash reporter
about 30 s into the boot (Game Init, frame 0) on an RDNA2 iGPU.

Overlapping placements at different addresses never shared a backing, so
between two opaque layouts the inner one now gets an image of its own, as
D3D12 leaves an alias's contents undefined until it is reinitialized. A
non-opaque layout is still refused there, and the same-address rules are
unchanged. A refused depth placement is now logged.

d3d12_depth_stencil_uav_test places a texture one alignment step inside
another one: refused for the tiled Xbox layout, its own backing for the
opaque one, and the outer placement still finds its shared backing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:52:55 -05:00
3e1c49e1bd d3d12: compile a submission's pipelines on worker threads (RT-PIPELINE-COMPILE-WORKERS)
prepare() leaves the pipelines that are not built yet to PipelineCompiles, once per pipeline and variant. VulkanQueue::execute_now compiles them together on the device's workers with the resource lock held, places them in the prepared commands and then writes the command buffer, so every draw and dispatch has its own pipeline. A refused compile gives the result prepare() alone would have given. LEONIDA_PIPELINE_THREADS=0 keeps the path of before. Graphics pipelines of 1 MiB of SPIR-V or more and compute pipelines over 128 KiB compile one after another, and LEONIDA_ASYNC_PIPELINES keeps its own worker.
2026-11-25 04:46:33 +01:00
a3980cd437 runtime: a bounded worker pool for pipeline compiles (RT-PIPELINE-COMPILE-WORKERS)
PipelineWorkers::run is a blocking parallel loop: the calling thread works on its own batch beside the workers, so a batch completes with no worker left and nothing outlives the call. CPU test: every job once and before run returns, no workers, exceptions, several callers, stop with jobs queued, and the LEONIDA_PIPELINE_THREADS text.
2026-11-25 04:46:33 +01:00
045bb0fcec gameinput_test: close_pad resets a missed press, pads keep their own, wider slow-reader margin
Review follow-up for the kSlowReaderUs missed-press logic:
- close_pad: a press missed by a slow reader, then an unplug/replug, must
  not come back on the first slow read after reconnecting.
- two pads: a missed press on the Xbox pad and one on the DualSense are
  each reported only on their own pad, once.
- the slow-reader sleeps are now 150 ms (3x kSlowReaderUs) for slow CI.

Tested: ctest -R ^gameinput passes plain and with LEONIDA_VK_VALIDATION=1
(VS 2022, Ninja). Against the pre-fix shim the slow-reader and both
two-pad checks fail (the close_pad check passes trivially there); with the
fix minus close_pad's missed reset, the close_pad check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
2026-11-24 22:40:06 -05:00
6e3a44259c tests: draw the First Light perspective camera through Xbox D3D12 2026-11-25 11:39:12 +08:00
6ed716a99a Merge main into RT-QUEUE-SIGNAL (#430)
Everything below this rung (#414, #416, #427) and the rung's own routing are in
main already, through #984 and #939, in main's form; what is left of #430 is
its test of queue slot 17, ported onto main's layout detection.

Conflicts, all resolved to main's form:
- runtime/shims/d3d12_xs_device.cpp: main's queue slot 16/17 rule (a fence
  there is the newer layout's Signal/Wait, for any caller) replaces the
  rung's caller-gated rule; main's PresentX routing (slot 30, or 32 once the
  newer layout is detected, LEONIDA_XS_PRESENT_X_SLOT) and lazily built
  presenter replace the fixed slot 32 of #414; main's list proxy already
  translates the CPU handles of console list slots 50 to 54 (#416) and
  drops unordered access from a depth-stencil texture at slot 76 (#427).
- runtime/shims/d3d12_xs_device.h, runtime/shims/xbox_present.cpp,
  runtime/shims/xbox_present.h, runtime/src/frame_pacer.h: main's shared
  FrameTokenSource (Logan's piece of #414, as #984 carried it).
- runtime/shims/d3d12_xs_desc_clean.h, runtime/test/device_proxy_test.cpp:
  main's without_depth_stencil_uav and its slot 25/76 test (#427).
- runtime/test/xs_proxy_mock_test.cpp: main's file, which already has
  check_list_cpu_handles (#416's cases and more); the rung's slot 16/17 case
  is ported to main's form at the end of check_xbox_queue_slots: slot 16 and
  17 with a fence reach PC Signal and Wait with the real fence, not the PC
  getters, and the fence proxy's vtable pointer is unchanged. The rung's
  host-caller and no-fence expectations are dropped: under main's rule a
  fence at 16 proves the newer layout, after which those calls answer S_OK.
Auto-merged, then set to main's content:
- runtime/test/queue_proxy_test.cpp: #414's call of queue slot 32 as an
  overridden slot; on main slot 32 is routed only on the newer layout and the
  sweep of the console tail already calls it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:35:34 -05:00
d4d969a1fd make_game, gameinput: controller, keyboard and mouse input out of the box (INPUT-OUT-OF-THE-BOX)
A build made with make_game.py on Windows had no input at all. The runtime
stage ran scripts/build_runtime.ps1 without -FetchSdl3, so on a machine without
an installed SDL3 the GameInput shim was not built. gta6rt then logged "served
without SDL3 (no devices)", and a connected DualSense or Xbox pad did nothing.

- make_game.py: the Windows runtime stage passes -FetchSdl3 (the pinned SDL3
  3.4.20, SHA-256 checked by CMake). --no-sdl3 leaves the download out. The
  docstring's "what it downloads" sentence names it.
- gameinput: LEONIDA_KEYBOARD_PAD defaults to the focused mode, so a player
  without a pad still has the keyboard and mouse. Keys count only while the
  game window has focus. "off" or "0" removes the pad.
- gameinput_test: the other cases set LEONIDA_KEYBOARD_PAD=off, as they count
  only their own virtual pads. The keyboard pad case checks the new default.
- docs/gameinput.md: default and make_game behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 08:31:50 +05:00
bfef489cb6 Merge pull request #1232 from iFeyz/feat/direct-heap-graphics
d3d12: graphics draws supply the directly indexed heaps after their root arguments (RT-DIRECT-HEAP-GRAPHICS)
2026-11-25 04:26:54 +01:00
98efc22ca3 Merge pull request #1064 from Moriz82/split/rt-direct-heap-compute
d3d12: supply directly indexed heaps to compute dispatches (RT-DIRECT-HEAP-COMPUTE)
2026-11-25 04:25:38 +01:00
0bc810504a Merge pull request #1028 from quartz-heron-58/device-fault
vulkan: print the driver's fault report when the device is lost (RT-DEVICE-FAULT-INFO)
2026-11-25 04:19:16 +01:00
3ee0037fd3 Merge main into RT-DIRECT-HEAP-GRAPHICS (#1232)
This merges #1064 as prepared (its head + a merge of main), so it brings #1232 up to date with main and
with #1064. #1232's branch carried #974 (merged into main since) and an older head of #1064 (7c47fd946).

main already supplies the directly indexed heaps to graphics draws (integration #984):
graphics_user_data() on DrawInstanced, DrawIndexedInstanced and DispatchMesh, at
RootArgumentLayout::graphics_arguments_end (pack_stage(Stage::Pixel)'s end_sgpr, set when the console
layout places the signature), LEONIDA_GRAPHICS_DIRECT_HEAPS=0, its notes for a signature on the s0
layout or one that fills s31, and d3d12_graphics_direct_heaps_test (recorded draws and the VS/PS GPU
reads). That form stays. What this pull request adds beyond it is carried onto it: the mesh case.

Conflicts (all taken from #1064's merged branch, then the PR's mesh parts carried over):
- runtime/shims/d3d12_com.cpp: main's graphics_user_data()/with_direct_heaps() and notes. The PR's own
  graphics_user_data(), GetEnvironmentVariableA switch and no-room notes are main's in another form and
  dropped. Carried: the comment says a mesh shader reads push dword d as s(d + 8) through #974's window,
  so it gets the heaps after its arguments from s16 (main's comment still said the mesh stage gets none);
  and DispatchMesh reports once when a heap falls past the mesh window (push dword 24 and up, s32 for the
  mesh shader), the case raised in the review of #1232 (mesh_ok accepts arguments up to push dword 24).
- runtime/shims/d3d12_com.h, runtime/shims/d3d12_vulkan_device.cpp: main's (graphics_arguments_end from
  pixel.end_sgpr; the PR set it from its Spill::block form, which main did not take from #974).
- runtime/test/glsl/cs_user_data.comp: main's (identical direct-indexing mode).
- docs/d3d12_vulkan.md: main's section 3.4 with #1064's compute paragraph; the graphics paragraph's
  "a mesh shader ... is not modelled" replaced by the mesh window position, cited to issue #14 comment
  7143020922 as a report not reproduced here, the window-overflow note and the mesh test.
- runtime/test/d3d12_mesh_test.cpp (no conflict): the PR's recorded-argument checks kept (vertex and mesh
  draw with 4 constants, resource-only rebind, 23 constants, 30 constants); the 30-constant comment now
  says it keeps pack()'s s0 layout on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:13:02 -05:00
5115f08879 Merge main into RT-DIRECT-HEAP-COMPUTE (#1064)
main already supplies the directly indexed heaps to compute dispatches (integration #984, the tree this
pull request was split from): with_direct_heaps()/compute_user_data() on Dispatch and the ExecuteIndirect
dispatch path, RootArgumentLayout::compute_arguments_end (kNoSgpr for a spilled signature),
LEONIDA_COMPUTE_DIRECT_HEAPS=0, and the first form of this test (direct dispatch, indirect after a
resource-only rebind, the GPU read through the heap). That form stays. What this pull request adds beyond
it is carried onto it: the review-round reports, the extra recorded-argument checks, the census tool and
its evidence.

Conflicts:
- runtime/shims/d3d12_com.cpp: main's with_direct_heaps()/compute_user_data() and its one-argument
  note_direct_heap_indexing(). Carried: compute_user_data() makes the note itself, so an ExecuteIndirect
  dispatch with no heap bound is reported too (record_dispatch's own call removed), and a heap with no
  inline dword left is reported once per heap kind ("compute root arguments leave no inline SGPR for the
  resource/sampler heap"); a spilled signature (main: kNoSgpr) gets one note of its own. Dropped: the PR's
  GetEnvironmentVariableA switch (main's direct_heaps_enabled) and its "graphics heap-base SGPR is not
  supplied" notes (main supplies the graphics heaps).
- runtime/shims/d3d12_com.h, runtime/shims/d3d12_vulkan_device.cpp: main's (compute_arguments_end and
  graphics_arguments_end with their comment; compute_arguments_end only when the compute arguments do
  not spill).
- runtime/test/glsl/cs_user_data.comp: main's; its direct-indexing mode (s5 = 0xFFFFFFFC, heap at s9)
  is this pull request's, byte for byte.
- runtime/test/d3d12_compute_test.cpp: the PR's block replaces main's earlier form of it (a superset:
  adds the bundle dispatch that inherits the parent's heaps, an indirect dispatch with only the sampler
  heap, signatures ending at s30 and s31, and the LEONIDA_COMPUTE_DIRECT_HEAPS=0 expectations).
- docs/d3d12_vulkan.md: main's section 3.4 (the BatchCull s7 and PreSkin s9 evidence), with the PR's
  census paragraph (tools/compute_heap_layout_census.py, the seven paired layouts, the heap order as a
  hypothesis) and the no-room and spill reports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:09:38 -05:00
d4f3e0bbc6 Merge main (b07b9ecb0) into radv-import-pins
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:03:51 -05:00
9f82f136f6 d3d12: pin the pages of a live host import
RADV checks the pages of a VK_EXT_external_memory_host import again at
every submission, and once one of them is read-only the kernel rejects
that submission and every later one. The slot-133 shadow trackers and the
geometry watch make copied title pages read-only to see the next write,
and a page can be both under a shadow and under a live import.

A new leonida::kernel_writes::hold pins a range until release() and opens
it. Unlike begin_write it records the pin when no opener is set yet (no
tracker exists), so a tracker made later passes over the pages too;
ShadowPages and the geometry watch already pass over pinned pages. The
slot-133 import (create_host_buffer) and the console descriptor heap
import take the pin before vkAllocateMemory, so no guard lands between
the writability check and the import, and end it on every path that
frees the memory: a declined or failed import and the release.

The finding and the design are NateWeav's (coordination issue #14,
comments 7141859164 and 7142359977); this implements their description.
As in their tree the pin is unconditional; a driver gate is not done.

Tests: kernel_writes_test checks hold and release on the pin set (no
opener, with an opener, alongside a file read's pin). d3d12_title_va_test
in its imports-on mode makes a shadow over pages, checks that its tracker
guards them, then imports the same pages and checks that two submissions
leave them writable, that the pin ends with the import and that the
tracker guards them again afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:03:36 -05:00
599fe9f221 d3d12: free a declined slot-133 import at once
create_host_buffer returned E_NOTIMPL for an import the driver put below
the arena with its memory still allocated. The resource's destructor then
handed that memory to the deferred queue, so it outlived the next
submission while the shadow buffer made instead over the same address
guarded its page read-only. On RADV a read-only page under a live
VK_EXT_external_memory_host import makes the kernel reject that
submission and every later one ("The CS has been rejected", then
VK_ERROR_DEVICE_LOST).

Every return after vkCreateBuffer that declines the import now destroys
the buffer and frees the memory before it returns; nothing was submitted
with them, since the resource is registered only on success. A counter of
live slot-133 imports (rt::d3d12::title_host_imports) lets a test see it.

The finding and the design are NateWeav's (coordination issue #14,
comments 7141859164 and 7142359977); this implements their description.

Test: d3d12_title_va_test in its imports-on mode (d3d12_geometry_views)
places two buffers, at a page start and 4 bytes into a page, submits with
each alive and checks that no import memory outlives a declined import.
On the RDNA2 iGPU under Wine both land below the arena, the path fixed
here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:03:09 -05:00
b07b9ecb09 Merge pull request #974 from iFeyz/feat/d3d448-graphics-root-layout
D3D-448-GRAPHICS: graphics root arguments in the console layout, mesh shaders through a window
2026-11-25 04:00:46 +01:00
99c98749dc runtime/README: AcpHal, chad, xapu and XCRDAPI have shims; DStorage decodes BCPack (DOC-RUNTIME-README-SHIMS)
The compat-modules section still said those four console DLLs have no shim here, and the DirectStorage entry
said BCPack, swizzle and physical-page requests are not done. shims/acphal.cpp, chad.cpp, xapu.cpp and
dstorage.cpp exist, and docs/directstorage.md describes the BCPack decoder, macro-unshuffle and xmem
physical-page resolution. The 867d922 measurement is kept and marked as taken before those shims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 00:00:02 -03:00
0eeb1e663a Merge pull request #1008 from sodove/runtime/wave64-graphics-tier
Use wave64 graphics tiers on fixed 32-wide devices (RT-WAVE64-GRAPHICS-TIER)
2026-11-25 03:59:38 +01:00
427abf2613 vulkan_backend: name only the driver versions the counter loss was seen on
A comment-only change: 621.24 was measured, 617.14 was reported by another tester.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-25 10:52:29 +08:00
cf4f434d23 Merge main (82f033512) into device-fault; keep only the fence-counter loss
Main now has its own device-fault report (LEONIDA_DEVICE_FAULT=1, from #984)
and #980's device-lost line, so this branch's vulkan_device_fault.h, its
report code and vk_device_fault_test are dropped in favour of main's.

What stays is the case main does not cover: a loss the driver shows only as
a timeline counter of UINT64_MAX. VulkanFence::completed() then asks
vkDeviceWaitIdle through observe_result, so main's report runs, and marks
the device lost when that returns VK_ERROR_DEVICE_LOST.
vk_fence_lost_by_counter_test is adapted to main's reporter.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-25 10:50:03 +08:00
c13614e082 runtime: register SKIP_RETURN_CODE 77 for vk_xdxr_postbuild_readback (CI-XDXR-POSTBUILD-SKIP-CODE) 2026-11-24 21:45:34 -05:00
0e5e33bc49 gameinput: report a missed press once to a slow reader (RT-GAMEINPUT-SLOW-READER)
A title that reads a pad with GetCurrentReading once a frame, at a few
frames a second, never sees a press that came and went between two
reads. A pad now keeps the newest reading that pressed a button the last
read did not report; a read more than kSlowReaderUs (50 ms) after the
previous one answers that press once, and the next read the pad's real
state.

Carried from DadaCap's boot-prototype fa497b930, split to the GameInput
part (runtime/shims/gameinput.cpp and its test in
runtime/test/gameinput_test.cpp); the other shims in that commit are not
included. Applied unchanged.

AI-assisted. Run on Windows 11, RTX 5080. No game data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
2026-11-24 21:45:32 -05:00
b8563e949e Merge main into D3D-448-GRAPHICS (#974)
main already lays graphics root arguments out in the console layout (from s8, one dword per table: #939's
graphics-root-layout patch in #984's form, pack_stage(Stage::Pixel), RootArgumentLayout::graphics_console,
graphics_arguments_end, LEONIDA_GRAPHICS_STAGE_LAYOUT=0 for pack()). That form stays. What this pull request adds
beyond it is carried onto it: the mesh-shader root window (translator, index "root_window", mesh_ok, the two
refusals) and its tests. Its own graphics spill handling (Spill::block) and LEONIDA_GRAPHICS_ROOT_LAYOUT=pc are not
carried: main keeps pack()'s s0 layout for a graphics signature past s31, and its switch does what =pc did.

Conflicts:
- runtime/src/root_signature.h, root_signature.cpp: main's pack_stage (compute spill array, spill_dword); the
  Spill enum, first_spilled and spilled_dwords dropped. The header keeps the PR's evidence note, with Stage::Pixel.
- runtime/shims/d3d12_com.h: main's comment and members, with the mesh window described; mesh_ok added (false by
  default, set only for a console-layout signature that Stage::Mesh also places); the PR's second graphics_console
  dropped.
- runtime/shims/d3d12_vulkan_device.cpp (CreateRootSignature): main's pixel/packed form; the PR's Stage::Mesh pack
  and its log line added, mesh_ok = pixel.ok && mesh.ok. The mesh-shader refusal without "root_window" (no
  conflict) stays.
- runtime/shims/d3d12_com.cpp: DispatchMesh keeps main's any_nonempty_viewport() and graphics_user_data() after the
  PR's mesh_ok check; address() keeps main's comment. The PR's kNoSgpr guard in constants()/address() stays,
  reworded: in main a spilled compute parameter has first_sgpr kNoSgpr, and kNoSgpr + offset wrapped round to s0.
- runtime/src/shader_library.h: both (main's wave64_graphics, the PR's root_window).
- runtime/test/d3d12_mesh_test.cpp: main's mesh shader-kind byte on both containers (also the PR's ms_old); the
  PR's two-parameter signature replaces main's 25-dword padding onto the s0 layout; both test blocks kept (the
  PR's window refusals, main's DISPATCH_MESH command signature), each in its own scope. The =pc case is dropped
  (main's switch is read once per process).
- runtime/CMakeLists.txt (no conflict): the mesh test uses ps_draw.spv again; the ps_draw_s0.spv rule is gone.
- runtime/test/glsl/ps_draw.frag, vs_depth.vert, vs_draw.vert, vs_draw_int.vert, ps_depth_write.frag and
  runtime/test/shaders/ps_m15, ps_m2, ps_m2_array, ps_m2_literal, ps_m2_uoff, ps_m3, ps_m3_post, ps_m3_query,
  vs_m15, vs_m3 (.asm): main's (the same s8 rewrite done twice); ps_draw.frag's mesh-test note updated.
- runtime/test/root_signature_test.cpp (no conflict): the Spill::block cases dropped, the window cases kept.
- docs/design.md: main's rows (loop guard, direct resource heap) and the PR's user-data row.
- docs/d3d12_vulkan.md (no conflict): section 3.5 and the CreateRootSignature bullet rewritten for main's form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 21:44:23 -05:00
40b393aeaf Merge main into RT-WAVE64-GRAPHICS-TIER (#1008)
main (273b3bdf9, from #984) already reads index.json `wave64_graphics`
(ShaderEntry::wave64_graphics), decides tier A/B wave64 VS/PS/GS with
graphics_partition_invariant() in subgroup_size.h, and replaces the
width warning for them with a line saying the device's size is exact
(report_subgroup_unavailable), documented in docs/d3d12_vulkan.md. That
is this pull request's change in another form, so main's form stays.

- docs/d3d12_vulkan.md (conflict, subgroup size section): main's text
  kept; it already describes the tier A/B case.
- runtime/src/shader_library.h, runtime/src/subgroup_size.h: main's
  form kept; the pull request's wave64_graphics_halves field and
  graphics_halves outcome dropped as duplicates of
  ShaderEntry::wave64_graphics and graphics_partition_invariant().
- runtime/test/subgroup_size_test.cpp: the pull request's index.json
  block kept and moved to main's API: the tier is read through
  ShaderLibrary, A and B are partition invariant, C, an unknown tier and
  a non-string are not, and the size decision is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 21:39:58 -05:00
5d93aca5e3 Merge pull request #1309 from BadgersMC/fix/lds-wide-fixture
Merging.

**Why merged:** Only lane 0 of the wide-LDS fixture writes, which removes a write race from the test. moffington verified it with GPU-assisted validation.

**Why it's good:** Docs tests pass. It's a fixture-only change.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main b4b7756e8. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests, ctest_registration) gives 578 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main 3ff2a2adc (after #984): no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-24 21:36:38 -05:00
a2de554e56 Merge pull request #1353 from robot00f/fix/rootsig-heap-flags
Merging.

**Why merged:** on Windows 10, the in-box `d3d12.dll` refuses root-signature flags `0xC00` (heap directly indexed) in its serializer, so the title is left with a null program and stops about 15 s in (`exe+0xb5a5f8`, a read of `0x68`); testers on Windows 10 hit this every boot. This retries only after the host has refused, and only when `0xC00` is in the description. It covers both the versioned and the legacy `D3D12SerializeRootSignature`, patches the flags back into `RTS0` after checking the container hash (failing closed), and it's claimed as D3D12-SET-HEAPS-BLOB. It's the better of the two PRs for this. #683 does the same for the versioned path only, by probing each bit through a static that captures the first serializer pointer.

**Why it's good:** on this Windows 11 host the real serializer accepts the flags, so I also checked the refusal path independently with a harness: a fake serializer that refuses `0xC00` and forwards everything else to the real Windows 11 serializer, on the RTX 4070 SUPER's hardware D3D12 device. #1353's wrappers (versioned 1.0 and 1.1, legacy 1.0) return S_OK after exactly one refusal; the flags read back as `0xc01` through the host deserializer; hardware `CreateRootSignature` succeeds; an unrelated failure is passed through; and a host that accepts the flags gets a byte-identical blob, 16/16. root_sig, root_signature, root_signature_oracle, d3d12_set_descriptor_heaps, d3d12_xs_root_signature, d3d12_draw, bundle, device_proxy and xs_proxy_mock* pass 14/14, both plain and with `LEONIDA_VK_VALIDATION=1`. The repository-consistency set gives 578/5/0. It merges cleanly onto main after #984 (neither #984 nor DadaCap's prototype carries this fix). Minor note: it returns S_FALSE ("flags lost") if a blob can't be patched, which is fine.

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-24 21:35:06 -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
3e551e5cf4 registry: classify libHttpClient.GDK.dll HRESULT imports (RT-UNIMPL-LIBHTTPCLIENT-CLASSIFY) 2026-11-25 09:25:50 +07:00
0819cfec80 Merge main (3ff2a2adc) into the #939 merge
Fourteen commits main gained after #968: #413, #1114, #1090 and #1491. Two conflicts, both in the shader check lists: scripts/run_gpu_tests.py imports both sides' cases, and tests/test_shader_checks.py counts eight cases next to COMPUTE (main's cs_w32_salu_ext) and #939's IMAGE_STORE_CASES table in place of main's fixed seven store shaders.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:23:42 -05:00
dc925c9bbd LEONIDA_FRAME_PACING=1 also gives the pacer #939's origin poll
#939 built the device's presentation with current_origin_poll, so a zero-timeout wait for the origin event answers with the newest passed origin; the merge had kept the base's three-argument call for every case. With the switch that hands slots 78 to 81 to the presentation, the pacer is now the one that tree was measured with; without it nothing changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:17:21 -05:00
7ea226e65b Merge main (0aecc5efa: #984 and #968) into the #939 merge
main now holds the #984 merge (18a22c1ae) and #968, queue slot 31 as CopyPageMappingsBatchX. Two conflicts: the include list of d3d12_xs_device.cpp (both includes kept) and the call order in xmem_test.cpp (the two page-mapping tests of #968 run after test_physical_pages, after the early return of #939's file-pools mode). The slot 31 dispatch of #968 stays ahead of the presentation routes, so #939's rule for queue slots 30 to 32 on a device that had a presentation handler does not reach it where xmem is linked.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:09:27 -05:00
2c8f638309 Attribution: d3d12_xs_native_pso.h names its source, licence and what could not be checked
The same header as native_pso.h for the D3D12 part of the slot 57 path: enx/leonida at 5c175db90, GPL-3.0-or-later as a fork of this project, what was changed as #939 describes it, and that the source was unreachable on 2026-11-25. Comment only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:06:16 -05:00
3d59ad3e3f Attribution: native_pso.h names its source, licence and what could not be checked
The slot 57 native pipeline description is adapted from enx/leonida at 5c175db90 on the original author's git mirror. The header now says so with the commit, GPL-3.0-or-later as a fork of this project, what was changed as #939 describes it, and that the server could not be reached on 2026-11-25, so the source and its licence were not read there. Comment only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:06:15 -05:00
4770a7673c Attribution: the VIctory port is GPL-3.0-or-later, translated from Rust and changed
runtime/src/console_texture_layout.h, the second computer in runtime/shims/xg_xs.cpp and its test said GPL-3.0 for Marvisak/VIctory. The project is GPL-3.0-or-later, and the notices now also say that the code was translated from Rust to C++ and changed for Leonida. docs/runtime_imports.md follows. Comments only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:05:22 -05:00
a3d4db807c Attribution: four patches of graphics-runtime-patches at d9a0bc1b (GPL-3.0, smg)
graphics-root-layout, descriptor-table-refresh, descriptor-write-through and sampler-table-refresh of Sigtryggur-Mani-Gudmundsson/graphics-runtime-patches are in #939 almost as published, about 390 lines, and only one sentence of docs/first_run_ui.md said so. That sentence now names the four, their licence and author and the files they are in, and each code region carries a comment naming its patch. Comments and one doc paragraph only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 21:05:02 -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