- Zero ResourceDesc padding words [1,2,3,13], compare non-format words + compatible formats in title_texture_matches(), preserve layout-equal slot-133 textures & mirror_hash_valid on unmap
- Guard refresh_title_texture() touch() against unreadable pending_stream textures while preserving deferred backing & publish_streamed_texture
- Zero-syscall already-armed Cell::restore[] check + table-page backed skip + PAGE_READONLY region cache in TitleTextureCells::arm_batch(); sync_tile_peers() skip in examine_batch()
- Snapshot geometry_writes serial before refresh_page_mirror() to skip redundant page_mirror_check_batch() dirtying on both CPU and GPU views; parallelize Pass 3 range_sum() >= 8 MiB
- Decouple GPU-mirror batching (512 jobs / 128 MiB) from CPU 64-slot limit, single-call vkAllocateDescriptorSets per sub-batch, kMaxScratchSlots=64, 4-part examine_ns telemetry
AI-assisted: Antigravity (Gemini 4 Neon).
Routes page_mirror_check_batch() uploads through note_readback_pieces_uploaded_locked() and console-heap page invalidations through note_readback_frame_invalidated_locked() so unrelated pages never poison readback_invalidated; renames a shadowed parameter in title_texture_watch_test.
AI-assisted: Antigravity (Gemini 4 Neon).
Eliminates false CPU-staged re-uploads, per-texture page_mirror.mutex churn, and unbatched tile re-arming:
- d3d12_vulkan_device.cpp: replaces per-texture page_mirror_texture_chunk/page_mirror_tiles_unchanged with a single-lock page_mirror_check_batch() snapshotting pending xmem remaps under shared feed_lock (rejecting only overlapping textures) and running one batched parallel TitleMirror::upload(); adds TitleJob::previous_mirror_hash check in hash_title_job() so GPU-uploaded textures falling back to CPU skip unchanged re-uploads; separates lock_wait_ns from collect_ns.
- title_texture_watch.h / title_texture_refresh.h: adds examine_batch() + TitleTextureCells::arm_batch() coalescing pins and contiguous VirtualProtect runs, uses direct Tile*/Texture* pointers in watch indices, and merges write/map ranges before iteration.
AI-assisted: Antigravity (Gemini 4 Neon).
Eliminates the async readback page_mirror.mutex convoy and serial fallback, and reduces page-mirror refresh cost:
- title_mirror.h / d3d12_vulkan_device.cpp: lifts WorkerPool for lock-free Phase 1 prehash_readback_slice() outside page_mirror.mutex and single-call Phase 2 write_back_prehashed() under lock (256-page slice: 0.11 ms unlocked, 0.03 ms locked), eliminating the 256x serial single-page fallback and merge_ranges() storm.
- Scopes readback invalidation to readback_slice_frames with per-frame 256-bit readback_slice_skip_masks populated from TitleMirror::upload(on_changed), preventing hot-page retry loops while preserving CPU-wins conflict semantics.
- Coalesces contiguous GPU write-back runs, batches deferred map() initial fills in parallel upload(), and replaces fed_now unordered_set with a flat sorted vector.
- title_mirror_hot_cold.h: consolidates CellGuard maps into a single TrackedCell map and adds a changes_since()-invalidated known_protect cache to halve cold re-arm VirtualQuery syscalls.
AI-assisted: Antigravity (Gemini 4 Neon).
Cuts per-submission texture refresh overhead and prevents passive write-back accumulation across overlapping queues:
- title_texture_refresh.h: adds shadow_keep::sum_of-backed mirror_range_sum helpers and PassiveWriteBackTracker with retire_id watermarking so overlapping direct/compute queues promote each passive V# range without re-promoting stale ranges indefinitely.
- title_texture_watch.h: skips hot_tiles() rescans when hot_generation() is unchanged and tracks non_hot_arms to reuse synced shared hot tiles per pass.
- d3d12_title_image_upload.h: reuses detile scratch buffers across sub-batches and skips detile setup when unused.
- d3d12_vulkan_device.cpp: extends TitleMirror range_sum() skip to all 256B-aligned and partially mirrored textures, filters dirty chunk syncs by title_written_ (guarded by !t.stale), caches can_gpu_upload(), pools TitleJob buffers, runs inline single-item reads/hashes, and defers t.pieces commits until upload success.
AI-assisted: Antigravity (Gemini 4 Neon).
Tauwni measured it in the review of #1724 (Apple M3, Mesa 26.3.1, 20 of 20 runs): with
run-time operands the f16 multiply-add comes out as if the product were rounded first, one
step from 0x7351. With literal operands the constant was folded exactly, so the fixture
passed there before. MoltenVK 1.4.2 and llvmpipe give 0x7351 on the same machine.
A Known problems row and a line in the fixture's header; no instruction changes.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The fixture reads the operands of its f32 multiply-adds from s4..s7 so that a driver has to
compute them at run time. The three operands of its v_fma_f16 were literals, which made the
whole f16 multiply-add a compile-time constant. MoltenVK 1.4.2 gives the wrong constant: word
7 read 0x0000 on an Apple M5 (0x3c00 in the docs' row) where 0x7351 is expected, the
cs_fma_fused failure listed in docs/testing.md and in the macOS job's EXPECTED_FAILURES. The
same translation with any one of the three operands taken at run time gives 0x7351.
The triple is now the s4 word XOR a literal each, so the test checks the translator's
round-to-odd sequence as the GPU runs it. The translator is not changed.
tests/semantic/test_fma_fused_fixture.py runs the fixture in the interpreter against the eight
words of its header and checks that no multiply-add in it reads a register only literals fed.
The Known problems row says what is left: an f16 multiply-add with only constant operands.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
run_gpu_tests.py and make_game.py translate with --f16-interp-fallback by
themselves where tools/vk_subgroup_info.py reports per_vertex_inputs
false (MoltenVK). build.py and check.py only did so with
LEONIDA_F16_INTERP_FALLBACK=1, so the two-step form on a Mac built
ps_ij_computed and ps_interp_f16_high for PerVertexKHR inputs and
check.py reported both as failed.
Both scripts now ask the device when the variable is unset, the way they
already do for the barycentric fallback, and take 1/0 (true/false, yes/no,
on/off) as run_gpu_tests.py does. On an Apple M5 (MoltenVK 1.4.2) check.py
goes from 175 of 220 pass, 39 skipped, 6 failed to 176 pass, 40 skipped,
4 failed: ps_interp_f16_high passes and ps_ij_computed is a SKIP.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Under Wine, loading a wsock32.dll by path gives Wine's builtin wsock32, not the
fixture copy, so the same-base checks failed (Tauwni, Wine 11 on macOS, #2525).
CTest now runs the test with WINEDLLOVERRIDES=wsock32=n,b, which Windows ignores
and scripts/run_wine_tests.py keeps, and the test checks by path that the module
it loaded is its own copy, saying why when it is not.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Threads that fault on the same CLWB site together lost the race: a #UD handled
after another thread rewrote the site decoded CLFLUSHOPT (or the NOP), did not
know it and returned EXCEPTION_CONTINUE_SEARCH, which ends the title.
- The handler continues at a site that already holds the form written on this
host (or the NOP's halfway state): the CPU runs it.
- One lock around unprotect, re-check, write and protect again, so two threads
never interleave on a page; a site found rewritten under it is not written.
- The NOP is written opcode first (66 0F 1F /6 in between is a NOP too).
- The sites counter counts each site once, by the thread that wrote it.
cpu_emulation_test calls the handler with a made-up #UD, so it runs on hosts
with CLWB: first #UD, a second one on the rewritten site, and 16 threads on
2048 fresh execute-read sites. Before the fix 27958 of 32768 concurrent #UDs
were passed on, 4810 rewrites were counted for 2048 sites and pages were left
writable; with it all checks pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Promoting 1x/frame pages to unguarded hot caused HotColdTracking to copy
~5,000+ pages on every submission (~50 GiB/10 s) and dirtied all textures
sharing those tiles (~119 ms/sub). Restore the submission-hot (6/8)
policy where unguarded copies beat fault+copy cost, and accumulate actual
CPU+wait time in AsyncReadback::cpu_ms instead of async wall-clock span.
AI-assisted: Antigravity (Gemini 4 Neon).
Retain staging for shared BC images on devices without host copies and keep the per-image fallback for formats without usable host-transfer backing.
AI-assisted-by: OpenAI Codex (GPT-6)
Cache bound pipelines, descriptor sets, dynamic graphics state, and dirty
push-constant sub-ranges across command lists in emit_commands() (with
invalidation across internal compute helpers and rendering boundaries),
and restore the two-tier submission-hot + presented-frame-hot policy in
TitleWritePolicy/HotColdTracking wired to present_serial.
AI-assisted: Antigravity (Gemini 4 Neon).
Guard GeometryViews retirement with command_list_epochs, defer TitleMirror
freed-home ticket stamping until flush + note_mirror_bind under submit_mutex_
(including TitleImageUpload submits), fix queue lock ordering and lock-free
wait_submitted, remove dead helpers and process labels, and scrub game shader
identifiers from docs/design.md.
AI-assisted: Antigravity (Gemini 4 Neon).
IGameInputForceFeedbackEffect::SetParams updates the parameters of the
effect's own kind; another kind is refused and the effect keeps what it
had (timbot103's review on #2497). SetParams checked only that the motor
reports the new kind, so a constant effect could become a sine. It now
refuses any params->kind other than the effect's.
An effect's SDL type therefore never changes, and the destroy-and-
recreate path this PR added to sync() for a kind change is unreachable,
so it is removed again.
gameinput_test: SetParams refuses both a kind the motor lacks and one it
reports, leaves the parameters and the SDL effect alone, and the sine
and spring checks run on effects of their own made with
CreateForceFeedbackEffect.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From timbot103's review of #2498.
A mapped real range is the Vulkan device's live arena: shaders of lists
already submitted read it, and the queue rewrites the slots it pulls there
in place (title buffer addresses rebased) when it submits. local_mirror_table
copied the title's raw slots into it while a list was being recorded
(SetGraphicsRootDescriptorTable / SetComputeRootDescriptorTable), which could
overwrite a translated slot an earlier submission was still reading. The
first commit of this PR made that happen on Wine as well; on Windows, where
VirtualQuery reports the arena as accessible, main already did it.
local_mirror_table now leaves a mapped range alone. The queue pulls the
title's slots of every bound table itself at submission
(pull_title_descriptors through title_va_aliases), which needs no
VirtualQuery of the arena, so Wine loses nothing.
xs_proxy_mock_test, check_descriptor_mirror case 2: with a translated value
in the real slot, binding a table over it (graphics and compute) leaves the
slot as it was, and the submission-time pull then takes the title's slot.
The previous commit fails the first of these checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dropping the HMODULE -> name entry in free_library() after FreeLibrary
left a window (timbot103's review on #2525): between FreeLibrary and the
erase, another thread can load a different DLL at the freed base and
call GetProcAddress, which then found the old name and served the old
module's shims. Holding loader_mutex across FreeLibrary would invite a
lock-order inversion with the loader lock.
So there is no cache any more: host_module_name() calls
GetModuleFileNameW each time, which always answers for the module mapped
at that base now, and free_library() is a plain FreeLibrary again.
library_loader_names_test gains the window itself: the host's
FreeLibrary is called directly, so the shim never sees the unload, and
the plain copy loaded at the same base must not be served the shim. It
fails with the cache-and-erase version and passes now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From timbot103's review of #2533.
- The ConnectEx and WSASendMsg lookups no longer complete the caller's
overlapped themselves (complete_now). That posted no packet for a socket on
an I/O completion port, so a caller waiting in GetQueuedCompletionStatus
hung, and it signalled an overlapped a socket without WSA_FLAG_OVERLAPPED
must ignore; its APC record also leaked if the thread never waited
alertably. The host's WSAIoctl now gets the caller's overlapped and
completion routine again, so the completion is reported as Winsock reports
it, but writes its own pointer and byte count into storage of the shim's
(wrap_extension_lookup): freed when the call completed, kept if the host
reports it pending. The caller's buffer holds the wrapper before the host
is called, so a packet another thread dequeues already finds it, and gets
its old contents back on failure.
- With AI_NUMERICHOST, "localhost" is passed on as the name, so the host
refuses it with EAI_NONAME instead of the shim answering with a literal.
ws2_offline_test: a completion-port socket gets its packet with the wrapped
pointer; on a socket without WSA_FLAG_OVERLAPPED the overlapped ends as the
host's own WSAIoctl leaves it; getaddrinfo(localhost, AI_NUMERICHOST) is
EAI_NONAME. The event and routine cases follow what Windows 11 does for this
lookup (measured: event set, routine run once, packet posted, 0 bytes in the
OVERLAPPED). The previous commit fails these 3 checks; 87/87 pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CopyFile2Trap left itself unarmed when kernel32 exports no CopyFile2,
and Case E then failed on Wine 9, the host this PR is for (timbot103's
review on #2532). A missing export is now told apart from a patch that
failed: with no CopyFile2 there is nothing that could be called, so the
overwrite and rollback checks run against the real host, and only an
export that exists but cannot be patched fails the check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>