tests/test_docs_env_vars.py failed: LEONIDA_TEXTURE_REFRESH_ASYNC, LEONIDA_SUBMIT_ASYNC, the LEONIDA_CONSOLE_HEAP_GPU
family, the shadow GPU copies and the diagnostics this branch reads were in no document. One row each in "Switches of
the D3D12 layer for a retail boot", from the comments at the code that reads them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move per-pipeline f16 halves linking into a shared helper PipelineState::link_f16_halves
called by both eager create_graphics() and lazy stage_words() paths, always passing
device_.f16_half_top_location. Previously, stage_words() omitted top_location, causing
it to default to 29 and relocate outputs beyond the device limit on hardware where
maxVertexOutputComponents < 124 (e.g. top_location = 14 on 64-component limits).
Add f16_half_top_location to VulkanDeviceInfo (0 = read from device limits; non-zero =
override for testing low-limit devices).
Expose rt::d3d12::pipeline_stage_words() to allow inspecting linked lazy pipeline SPIR-V.
In runtime/test/d3d12_f16_halves_test.cpp, add low top_location = 14 tests verifying that
out-of-budget pipelines are rejected at CreateGraphicsPipelineState, in-budget pipelines
relocate within location 14 and execute correctly through the lazy path on first draw, and
explicitly verify that the linked SPIR-V stage modules' highest Location does not exceed 14.
Keep unit check #11 in runtime/test/spirv_f16_halves_test.cpp.
Tested:
- spirv_f16_halves_test (passed)
- python -I scripts/check_no_game_data.py runtime/shims/d3d12_com.h runtime/shims/d3d12_vulkan_device.cpp runtime/test/d3d12_f16_halves_test.cpp (clean)
No retail game data or keys.
AI-assisted (Claude Code, Claude Opus 5.5).
Found building #2098 with clang-cl (Make generator); each also fails on the pull request's own head:
- dxgi_swapchain_count_test: VulkanSwapchain takes a SubmitMutex& now; the test passed a std::mutex.
- vk_store_test: kind_sampled_bit/kind_storage_bit come from descriptor_table.h, which it did not include.
- d3d12_compute_journal_test listed gta6rt_indirect_count_shader's output among its sources, so Make had two rules
for cs_indirect_dispatch_count.spv and the two glslangValidator runs raced ("Failed to open file"). It depends on
that target now, and the second shader has a target of its own.
- tests/semantic/test_tsharp_dimension.py began with a UTF-8 BOM, which test_ci_registration's ast.parse refuses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main d3b8251bc brings #1889 (large compiles within a memory budget), #1987 (unbound T# reasons), #1759, #1860
and others under this branch. Conflicts:
- d3d12_vulkan_device.cpp, includes: both (pipeline_cache_journal.h and large_module_gate.h).
- d3d12_vulkan_device.cpp, fix_console_slot's T# branch: main's form (counts refused_reasons, #1987), with this
branch's comment on why a slot that is no T# is nulled. The same reason count is added to console_tsharp_check,
the GPU console-heap path's T# registration, so its log line has the reasons too.
- d3d12_vulkan_device.cpp, the heap log: both blocks (the release filter / GPU heap lines and main's "unbound T#s by
reason" line).
- d3d12_vulkan_device.cpp, PipelineState::build_compute: this branch's body (build_compute_pipeline, journal, compile
helper) behind main's entry: the `Work` argument and enter_build, so a large module takes its place at
big_compile_gate() before variants_mutex_, as #1889 requires (a thread that waits for memory holds no PSO lock).
build_compute_pipeline's own big_compile mutex now follows main's BigCompiles: taken only with
LEONIDA_SERIAL_BIG_COMPILES=1 (it was on by default here), so the default is main's budget, not one at a time.
- d3d12_vulkan_device.cpp, queue_locked: this branch's Build-state jobs (claim, defer, finish). main's
`requested_`/`publication` mechanism they replace is not kept. build_variant passes Work::speculative for a
"warmup" build and Work::demand otherwise, as main's queue_build did.
- vulkan_replay.h, ComputePipeline: main's comment on `large`, and this branch's `await`.
- vulkan_backend.h: this branch's LEONIDA_SUBMIT_ASYNC block, with main's lock order in the state_mutex_ comment
(state_mutex_ -> pipeline_mutex_ -> resource_mutex_ -> tracker_mutex_ -> submit_mutex_).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A second Vulkan instance in the process no longer overwrites the messenger
handle (the first one was left alive past its instance): it is refused, and
enable_device only enables the extension for the instance that owns the
messenger. install/uninstall are under a lock.
- `on` is set only when a messenger records the device, and is atomic. With
LEONIDA_ADDRESS_BINDINGS=1 and nothing recording, the fault report says the
bindings were not recorded instead of reading as "no object there".
- An object that only shares the reported page with the fault address is
labelled "on the page" (unbound: "held the page"), not "containing".
- Tests: exact end and start of an object, page vs byte precision, unbind
matching by handle and size, the kept_unbound cap, recording from several
threads while a report reads, and the two-instance messenger cases. The test
builds on Linux too (setenv in place of _putenv_s).
Changes made by Claude Code (AI-assisted).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
Review of RT-HEAVY-PIPELINE-CACHE:
- The writer thread marked a generation written even when the save failed, so the
cache stayed unsaved until teardown. A failed save now keeps the cache dirty and
is retried after a bounded backoff (5 s, doubling, capped at 2 min), so a write
that keeps failing does not spin. WriteSchedule::failed() holds that decision and
heavy_pipeline_cache_test checks it.
- save_heavy_pipeline_cache accepted VK_INCOMPLETE and published the truncated blob
over a complete file. It now requires VK_SUCCESS, like the session cache, and
keeps the previous file; the next try queries a fresh size.
Changes made by Claude Code (AI-assisted).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753 forbids two active
transform-feedback queries with the same index anywhere in the command
buffer, whatever their pools. prepare() tracked the active ones by heap
and stream, so two heaps beginning stream 0 together still issued two
active indexed queries. It now keeps one bit per stream for the list.
replay_query_predication case 18 adds a second heap: overlapping queries
on one stream in two heaps are refused, and queries that take turns on
that stream are fine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A window of the title's memory is a read-side mirror refreshed before every
submission, so a UAV or raw write into one landed in the copy and the title
never saw it. At the world start that is the WRITE_INVALID device loss of
#1537 (QemmHD, 160 s into the load, past the cap): the culling compute writes
through addresses that name title memory, and nothing ever reads the result
back into the pages.
The layer now keeps every title range a submission's bindings reach (the
resolve path, so root views, table V#s and created views alike) and copies
those ranges from the copy to the title's pages at the start of the next
refresh, before the forward copy. A page the title wrote in between takes the
title's newer bytes and its GPU result is dropped; the tracker already knows
those pages (guarded, hot and clean). Caps: 8,192 ranges and 64 MiB a
submission, logged once; LEONIDA_TITLE_WRITEBACK=0 turns it off.
Test: d3d12_title_window_write_back, a dispatch through a root UAV at the
title's pages: the written words reach the pages, hold across two
submissions, and a title write survives the next forward copy. No game files.
Item: RT-TITLE-WINDOW-WRITE-BACK (claimed in #1608)
Wine against llvmpipe.
The title HUD (#1922, LEONIDA_TITLE_HUD=1) read VRAM from DXGI's
QueryVideoMemoryInfo on the host dxgi.dll and private memory from
PROCESS_MEMORY_COUNTERS_EX::PrivateUsage. Under Wine both read 0.
- VRAM: the runtime's device enables VK_EXT_memory_budget when the GPU
has it (VulkanDeviceInfo::memory_budget), and
rt::d3d12::vulkan_vram_budget sums heapUsage and heapBudget over the
DEVICE_LOCAL heaps (other heaps' usage shown as shared), from
src/vulkan_memory_budget.h. The HUD calls it once per refresh on its
own thread. Without the extension it falls back to DXGI, and where
that has no figure either it shows "VRAM n/a" rather than 0.
- Private memory: Wine's GetProcessMemoryInfo fills only the
PROCESS_MEMORY_COUNTERS part and leaves PrivateUsage 0; PagefileUsage
is the same commit-charge figure on Windows 8 and later, so the HUD
takes the larger of the two.
Tests: title_hud_test checks the sums, the DXGI fallback, the "n/a"
text and the private-bytes choice with made-up values, and that a VRAM
source reaches the title at most once per refresh. The new
d3d12_vram_budget_test checks that the device enables the extension
exactly when the GPU has it and reads a non-zero budget, and skips
(77) without it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch's check expected pack_stage(Compute) to refuse 64 constants
as an unmodelled spill. main's pack_stage now spills trailing compute
parameters behind s[0:1], so compute takes them (cost 64, one spilled
parameter of 64 dwords). The "refused only as a spill, not for cost"
check moves to a pixel shader, where a spill is still refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dedupe is a fixed table of 4096 addresses; past that a new site is
logged each time it is hit, as startup_trace.h says. Raised in review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
int3_from tried the byte at Rip first and only then checked
ExceptionAddress against it. With Rip one past the 0xCC and
ExceptionAddress on it (a mixed form), a second 0xCC at Rip (int3
padding) was taken first and then refused by the address check, so that
int3 was not skipped. Each candidate (Rip, then Rip - 1) now has to agree
with ExceptionAddress before it is taken. Main did not skip it either,
so this closes a gap rather than a regression. int3_skip_test gets a
"padding" case for it.
The std::set the old dedupe used is gone, so its include goes too; the
candidate loop needs <initializer_list>. Both raised in review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #1353 the shims' serializers (versioned and legacy) serialize a
description the host refuses for CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED or
SAMPLER_HEAP_DIRECTLY_INDEXED (Windows 10's in-box d3d12.dll): they call
the host again without the two bits and put them back into RTS0. The
three host-parity checks failed on Windows 10 for that, as reported in
review.
Where the host refuses such flags but takes the description without
them, the shim now has to return S_OK with that blob byte for byte,
except the RTS0 flags dword, which must hold all the flags, and a valid
container hash. Byte-for-byte parity stays wherever the host accepts,
and the shim still has to refuse whatever else the host refuses. The doc
bullet says the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's d3d12_xs.cpp now calls into d3d12_xs_pso_stream.cpp, and main
added that file to root_sig_test's sources; this target lists the same
shim files and needs it too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings #1889 up to date with main after #1742 (the pipeline compile unlock),
resolving the five conflicts as described in the guide on the PR:
https://github.com/ubiquitarianism/leonida/pull/1889#issuecomment-7175252290
- vulkan_replay.h: PipelineCompiles::build takes both the large-compile
budget and main's `prior` compiles; build_pipelines passes the budget,
and main's check_compiled_pipelines / finish_compiled_pipelines stay.
- vulkan_backend.h: execute_now takes the large-compile demand and passes
the budget to the pass-0 compile, and pass 1 passes the budget too.
set_large_compiles locks pipeline_mutex_, since #1742 moved the
pipeline state under that lock.
- replay_pipeline_compiles_test.cpp: both test blocks kept, and the
prior_compiles_reuse call passes an empty budget.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's pack_stage now spills trailing compute parameters into the array
behind s[0:1] and refuses an unknown parameter type. Keep both; drop only
the zero-value constant refusal, as this branch does. A zero-value
constant takes no SGPRs and no spill dwords, and a new case checks the
spill offsets around one. The old "32-SGPR budget refuses before the
cost limit" comment no longer holds with spilling and goes; main's
over-cost case replaces it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runtime/shims/startup_trace.h: main added the tls_index0 example event
and the exception's region/regs fields to the header comment; keep them,
add this branch's delay_import_unimplemented example and renumber seq.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/boot.md: main added LEONIDA_WRITE_DIR / LEONIDA_SAVE_DIR to the
--overlay bullet and a new "Under Wine on Linux" section; keep both and
the T: paragraph of this branch after main's sentences.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/run_gpu_tests.py: main added cs_w32_wrxchg2_ext and
cs_w32_wrxchg2st64 to the same name list; keep main's list and add
cs_w64x_partial_swizzle to it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A queue with auto-submit on submits itself once the entries enqueued
since the last submit reach half its capacity. A request whose
destination is a physical page list names its pages through
DestinationPageArray, a pointer into the title's own page-number table,
and the worker reads that table only when the request runs
(page_transfer). The title fills the page table just before Submit. So a
read started by the self-submit found page 0 (the entry failed) or the
number the slot held before (the data landed in a page that now belongs
to something else, with no error).
A self-submit now stops at the first read into physical pages. That read
and every entry behind it wait for the title's Submit, in order, so a
status entry, fence or event behind a held read still comes after it. A
full queue submits the held entries too, since the title cannot call
Submit while it waits in an enqueue. Close submits everything, as
before. A hold also ends after LEONIDA_DSTORAGE_HOLD_MS (2000 ms unless
set; 0 means no limit), so a path that never calls Submit cannot stall
for good. LEONIDA_DSTORAGE_HOLD_PAGES=0 restores the old self-submit of
everything.
"[rt] ds-hold" counts self-submits, held reads, full-queue and timed
releases, and destination lists that named page 0 when written. It is
printed at each power of two of the counter that moved
(runtime/src/dstorage_hold.h).
The idea is from Marvisak/VIctory eddde73; it also appears in
fxceless/victory-fork 79cfdd9. Written anew for this queue.
Test: dstorage_test, test_page_reads_wait_for_submit: a list changed
between the self-submit and Submit, a list still empty at the
self-submit, a full queue, the default and an explicit time limit, no
limit, the switch, and the page-0 counter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
leonida::geometry_writes previously kept one process-wide release queue, so when two devices held GeometryViews over the same title range, the first device to call drain_released() emptied the queue and the second kept its view and charged bytes forever.
Give each GeometryViews its own ReleaseQueue subscribed to leonida::geometry_writes on construction and unsubscribed on destruction. note_released() delivers each released range to every subscriber's queue under subscribers_mutex -> queue.mutex (keeping the 65536-entry collapse per queue), and take_released() drains only the caller's queue under queue.mutex.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEONIDA_TITLE_EVERY_BUDGET_US (0, the default: unchanged) limits how long one pass of refresh_title_textures
spends on the textures it visits every pass (mapped by the title, or known stale). The visits resume from a cursor
of their own, so every marked texture gets its turn; the texture that crosses the limit is finished. A mapped
texture never filled yet is visited first whatever the limit, so a video plane is not left empty until its turn.
The pass stays synchronous, before the submission, as today.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record which title image formats have no bindable host-transfer memory type. Document the three formats observed on the GTX 1050 Ti by qhukz13.
Suggested-by: qhukz13 (PR #1894)
AI-assisted-by: OpenAI Codex (gpt-6.2-astra)
Each refresh now clears written_ and written_vas_ together at the start, so an exception from a read or a guarded copy cannot leave addresses the next refresh indexes past written_. Adjacent-tile runs are capped at 1 MiB (16 tiles), so a long contiguous write cannot force one large scratch resize.
- Move UnboundTsharpTracker and unbound_tsharp_tracker() to namespace scope
so the free functions in rt::d3d12 that call it compile correctly.
- Add non-const Device::state() overload for test_bind_title_image().
- Remove nonexistent rt::d3d12_xs::resource_proxy_real_resource() call;
resource_image_address() now casts the ID3D12Resource pointer directly.
- Fix cube layer check in bind_title_image to verify texture layer count.
- Add D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET to test MSAA texture desc.
- All 35 checks in d3d12_unbound_tsharp_rules_test pass cleanly.
AI-assisted (Claude Code)
In runtime/shims/d3d12_vulkan_device.cpp, extend note_refused_tsharp to record
both overall distinct slots and per-reason distinct slots and total refusal
counts across console descriptor heaps, matching the title texture diagnostic
breakdown in refresh_console_heaps.
Expose inspection helpers in runtime/shims/d3d12_com.h and add synthetic tests
in runtime/test/d3d12_unbound_tsharp_rules_test.cpp covering:
- 1D rule: dimension and layer count compatibility ("T# type or samples do not fit the texture")
- Array rule: layer bounds ("T# names layers the texture lacks")
- Cube rule: minimum layer requirements ("cube T# on fewer than six layers")
- MSAA rule: sample count matching ("T# type or samples do not fit the texture")
- Tracking: distinct slot and total refusal counts by reason
AI-assisted (Claude Code)
create_placed turns a console D16S8 (format 118) description into its PC
format before committed_resource_refusal, but left the clear value as
118, so the clear format's family no longer matched the resource's and
every placed format-118 depth texture with a clear value was refused
("clear value"), with D24S8 backing. The clear value now goes through
pc_format() too, as the description does. Found by
xbox_d16s8_d24_storage's CreatePlacedResource case on a GTX 1050 Ti.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The status paragraph said buffer SRVs, CreatePipelineState streams and mesh
shaders were missing; the device writes buffer V#s, parses streams and reports
MeshShaderTier 1 where the GPU has VK_EXT_mesh_shader. WriteBufferImmediate was
described as refused because no buffer had a GPU VA; buffers have VAs and the
device test writes through a placed buffer's. Section 4.6's "Not implemented
yet" contradicted the D3D-399 paragraph above it and listed mesh statistics
twice. The device test's comment on the unresolved write gets the real reason.
Fall back to a dedicated buffer allocation when the shared arena fills.
Update console descriptors and resource backing, preserve pipeline cache
entries, and replay mesh records using bounded indirect arguments. Keep
scripted input available until read and cover the runtime and translator
paths with synthetic tests.
Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
Check the host-transfer memory requirements before selecting the backing for a CPU-fillable title texture. Exercise the mapped linear R8 plane with a driver shim that returns no compatible memory types for the host-transfer image.
Reported-by: qhukz13 (PR #1894)
AI-assisted-by: OpenAI Codex (gpt-6.2-astra)