Maintainer fixes on top of the author's rehydration, carried over from the
reviewed branch onto the rewritten head:
- Scratch: each element of a batch gets a region of its own in one buffer
per call, at D3D12's acceleration-structure alignment, and the command list
holds that buffer until its next Reset (rt::d3d12::hold_until_reset). Before,
every element and every list shared one builder-wide buffer with no barrier
between the builds, and growing it released a buffer that builds already
recorded could still use.
- Fresh builds: a rehydrate always builds from geometry. PERFORM_UPDATE is
cleared together with SourceAccelerationStructureData, so the layer never
refits from the dehydrated stream's bytes.
- The leaf frame compressionParams gives is described as not applied yet,
which is what the code does.
- The test reads back rehydrated builds made without scratch
(ScratchAccelerationStructureData = 0), the shape the title uses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict in scripts/run_gpu_tests.py: the dump-test name list gained
cs_w64x_cmp_sdst on main and cs_w64x_partial_swizzle here; both are kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Fix log_once call signature at line 268 (passes flag, text without format args).
- Do not copy source_data into SourceAccelerationStructureData to avoid unwanted refit
on update paths (d3d12_vulkan_device.cpp:2639).
- Allocate and supply scratch buffer via builder_ensure_scratch when the title passes
ScratchAccelerationStructureData = 0 (docs/xdxr.md §6), avoiding command list poisoning.
- Retain the leaf-frame note (compressionParams, docs/bvh.md §4a) in comments and docs.
- Remove stale deserialize references in test comments and update test coverage.
AI-assisted (Claude Code, Claude Opus 5.5).
Addresses review feedback on #1759 from @aslan2142 and @Tyrannys:
- RehydrateRaytracingAccelerationStructureBatched2X now rebuilds structures
exclusively from geometry (docs/bvh.md §4a).
- Offline console dehydrated streams cannot be directly deserialized by
PC D3D12/Vulkan drivers (docs/bvh.md §4/§4a). When source_data is present
without geometry descs, the shim logs once and refuses with E_NOTIMPL.
- Documented in docs/xdxr.md that the 4th parameter (const UINT64* source_data)
is a hypothesis denoting offline console stream pointers.
- Empty structures (NumDescs == 0 without source) are logged once and skipped.
- Updated runtime/test/xbox_bvh_builder_test.cpp and tests/test_xbox_bvh_builder_rehydrate.py
to verify refusal of source-only streams (E_NOTIMPL) and handling of empty structures.
AI-assisted (Claude Code, Claude Opus 5.5).
Implements XboxBvhBuilder::RehydrateRaytracingAccelerationStructureBatched2X
in runtime/shims/xbox_bvh_builder.cpp. The shim now rebuilds or deserializes
each acceleration structure on the command list via ID3D12GraphicsCommandList4
rather than stubbing out with E_NOTIMPL, resolving the interactive boot stop
reported by timbot103 past story-load texture streaming.
Validates count == 0 (S_OK), null list / descs (E_INVALIDARG), and adds unit
coverage in tests/test_xbox_bvh_builder_rehydrate.py and runtime/test/xbox_bvh_builder_test.cpp.
AI-assisted (Claude Code)
Harden runtime/src/value_write_sink.h:
- Guard arena() against null buffer pointers and non-4/8-byte sizes by immediately returning Landing::refused, preventing null dereference and invalid writes.
- Guard title_pages() against null addresses, null bytes, and zero size by returning false immediately.
- Guard clear_arena() to reject null device pointers.
- Add clear_title_pages() and reset_for_test() to allow clean state resets across tests and teardown.
- Add portable CPU-only CTest unit test runtime/test/value_write_sink_test.cpp verifying initial state, guards, arena and title_pages dispatch, device-matched clearing, and multi-threaded concurrency.
AI-assisted (Claude Code)
The three review points on #1630:
- prepare() refuses two overlapping SO_STATISTICS queries on one stream: two
active indexed queries in one pool break
VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753. Queries on different streams
are fine.
- The transform-feedback pool now also needs the transformFeedbackQueries
property, and a stream at or above maxTransformFeedbackStreams runs nothing
and resolves zero instead of issuing an invalid indexed begin.
- replay_query_predication case 18 fails without both: the overlapping-stream
list is invalid_query and a stream past the pool's stream count fills zeros.
Tested: d3d12_vulkan_device, d3d12_state_map and replay_query_predication pass
plain and with LEONIDA_VK_VALIDATION=1 (RTX 3080 Ti, driver 616.64). AI-assisted.
GPU coverage for the rest of --explicit-lod-bias's forms. vk_sampler_test gains
a mode for a 6-layer cube (images_arr), a 128x128x2 volume (images_3d) and a
D32 texture (0.25 / 0.75 per level) with the S#'s compare function; the 2D
default is unchanged. check.py's SAMPLER_FIXTURES names each shader's mode and
judges ps_ssharp_c as compare results.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Builds on #1144 (RT-XAPU-CONNECT-LAYOUTS): the queue and layouts stay there;
fill() decodes each process packet through a Rust C-ABI crate over BSD-3
opus-pure when cargo builds it, and keeps the table-of-contents silence path
otherwise. Adds xapu_opus_test (a generated 440 Hz stereo packet decoded to
960 frames) and the CMake wiring; xapu_chad_test keeps covering the layouts
and the silent path. No game data.
Both tests carried their own copy of serialize(), which calls the in-box
D3D12SerializeVersionedRootSignature directly. Windows 10's d3d12.dll
(10.0.19041) refuses CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED at root signature
1.0 and 1.1 (E_INVALIDARG, "Unsupported bit-flag set"), so the cases that
set it stopped at an empty blob before reaching the code they test.
d3d12test::serialize_root_signature (d3d12_test_shaders.h) already retries
without the flags and puts them back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A driver can stop adding to a large VkPipelineCache with no error. On NVIDIA 610.88 a 1.23 GB or 1.35 GB cache
came back the same size to the byte after a 2 s compile, so the next run compiles the same pipelines again and
nothing says why. The runtime now takes the cache's size at creation and at each session save, counts the title's
pipeline builds that took at least 200 ms, and logs once when 16 or more compiled while the cache grew less than
64 KiB. pipeline_cache_store_test covers the decision; docs/d3d12_vulkan.md records the measurements.
GPU coverage for the --explicit-lod-bias paths ps_ssharp doesn't run: the Lod
of image_sample_l, the 2^bias Grad scale of image_sample_d and the bias of
image_sample_b. check.py's SAMPLER_FIXTURES runs all three with the same cases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Drain released geometry ranges only in the submit-thread before_execute callback, removing recording-thread drain calls and GeometryViews::should_reclaim().
- Filter geometry_writes::note_released() against monotonic watched_lo/watched_hi bounds and collapse the queue on 65536-entry overflow instead of dropping ranges.
- Bound GeometryViews::retire_range() walks using max_view_bytes_ and an ordered refused_ map with max_refused_bytes_.
- Keep one empty 4 MiB spare block in TitleBufferWindows (dropping it when needed under a cap), remove failed_ reset in free(), and cover all four points in geometry_views_test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ba626820 added the test with a guard in main only: without glslangValidator
CMake leaves LEONIDA_TEST_NULL_DESCRIPTORS_SPV undefined, but run() still
names it, so the file does not compile and the Linux runtime build, which
installs no glslang (runtime.yml linux-gpu-tools), stops there. Compile the
helpers only with the shader, as main already assumes, so the test reports
itself unsupported (77) like the other GLSL-based tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RT-GEOMETRY-VIEW-EVICTION: free GeometryViews entries when their backing
title range is released or unmapped, deferring Vulkan storage reclamation
until in-flight GPU work completes, and retry cap-refused ranges once
budget is freed.
- Queue released title ranges from xmem (XMemFree/Default, VirtualFree
MEM_RELEASE/MEM_DECOMMIT, XMemMapPhysicalPages unmap, CopyPageMappingsBatchX
unmap range) via leonida::geometry_writes::note_released.
- Add coalesced sub-range freeing and empty-block Vulkan destruction to
TitleBufferWindows.
- Retire overlapping views immediately from lookup/find/refresh/watch and
title_va_aliases, and reap their backing storage once
completed_retire_ticket() reaches the view's retire ticket.
- Track free_generation_ per refused key so resolve() short-circuits while
nothing changed and retries once budget is reclaimed.
- Extend geometry_views_test.cpp with small-cap eviction, deferred GPU
retirement, retry, and full block reclamation checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/vk_lod_bias.py clears a two-level R32_SFLOAT image to 0.0 / 1.0 and
samples it at explicit LOD 0 through samplers with mipLodBias 0 and +1, from
Python through ctypes. vk_subgroup_info.py --lod-bias reports the answer as
explicit_lod_bias; lod_bias_probe.py uses it first and draws ps_ssharp only as
a fallback, with the Homebrew llvm-mc hint when llvm-mc is missing (#1774
review). build.py and make_game.py can now measure too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Guard align_up_saturating against zero alignment (to == 0) in runtime/shims/d3d12_xs_alloc_size.h, avoiding division by zero and underflow.
Add standalone CPU-only unit test runtime/test/d3d12_xs_alloc_size_test.cpp covering align_up_saturating, render_target_element_bytes, console_depth_planes, console_render_target_size, console_depth_stencil_size, and console_placement.
Register test executable and CTest in runtime/CMakeLists.txt.
AI-assisted (Claude Code)
Review follow-up for #1565:
- LoadLibraryEx with DONT_RESOLVE_DLL_REFERENCES on a LEONIDA_COMPAT_DIR module fails with ERROR_NOT_SUPPORTED, before loading or returning a loaded handle, as for bundled DLLs.
- A compat DLL that Windows loaded as another compat DLL's dependency is recognised: compat_handle() finds it by its full path, and owns_compat_handle() by its folder (read outside mutex_, since GetModuleFileNameW can take the loader lock), so GetModuleHandle and LoadLibrary return it and GetProcAddress never fills in a missing export from the shim.
- A name with a directory gets the compat DLL only when it is that file; any other path goes on as without the folder.
- Names outside ASCII reach the compat lookup (it runs before the ASCII / wide split).
- The folder's file names are listed once per Loader, so lookups no longer touch the disk.
loader_test: test_compat_runtime_edges adds six cases for the first four points, through LoadLibraryExA/W, LoadLibraryW, GetModuleHandleW and GetProcAddress; all six fail on 582e14d. The listing has no functional test.
queue_copy_page_mappings logs once whether CopyPageMappingsBatchX goes to an
installed batch hook or to the default adapter over xmem's range callback
(copy_page_mappings_fn), so a boot's read-fault reports can be matched to the
implementation the tests cover. Nothing in the runtime installs a hook, so a
retail run takes the default adapter.
d3d12_xmem_placed_test gains queue_remap_default_route, for that route: no
hook, a legacy-paired GPU-only destination, and a GPU-only pool backed only
through its CPU alias. The title maps a page of its own at one CPU twin while
the remap waits behind queue work (deferred with list values, waited for with
LEONIDA_LIST_VALUES=0), so ownership is checked when the remap is applied.
After the copy the GPU-only pages hold the pool's bytes, the other twin follows
them and the title's page keeps its bytes; after an unmap the GPU-only pages
and the mirrored twin are reserved and the title's page still holds its bytes.
On the code before this pull request the title's page check fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>