Commit Graph

4696 Commits

Author SHA1 Message Date
b986d274bf d3d12: a mesh PSO with conservative rasterization needs no topology type (RT-MESH-PSO-CONSERVATIVE-TOPOLOGY)
Finding by Undefined3301 in #1608.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:20:01 +01:00
05699d303c d3d12: restrict D24S8 castable widening to format 118 and mark the placed path
Follow-up review fixes for D24S8-made Xbox D16S8 (format 118) depth UAVs:
- Pass the console origin (recorded before pc_format()) into
  castable_view_formats() instead of widening on format.d24, so a plain PC
  D24_UNORM_S8_UINT texture keeps main's castable-format rules and refuses
  the R16/R8/118-120 depth-UAV views.
- Set mark_console_d16s8() in create_placed() as well as
  create_committed(). CreateReservedResource refuses format 118 before it
  makes anything (a stencil format has no tile shape), so it needs no mark.
- Extend xbox_d16s8_d24_storage to cover slot 127, incompatible castable
  views, plain PC D24S8 castable/UAV refusal, CreateCommittedResource2,
  CreatePlacedResource/2, and the CreateReservedResource refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:09:28 +02:00
9a375a064e d3d12: support depth-stencil UAVs for D24S8-made Xbox D16S8 (format 118)
On GPUs with native VK_FORMAT_D24_UNORM_S8_UINT attachments (NVIDIA),
pc_format() maps Xbox format 118 (D16_UNORM_S8_UINT) to
DXGI_FORMAT_D24_UNORM_S8_UINT before Resource construction. Previously,
Resource::enable_depth_stencil_uav only accepted R16_TYPELESS, 118, and
R32G8X24_TYPELESS, returning E_INVALIDARG so slots 76 and 133 fell back
to creating the texture without unordered access (#1558).

Track console format 118 origin on Resource before pc_format(), extend
enable_depth_stencil_uav and CreateUnorderedAccessView to serve D24S8-made
118 through the existing widened R16_TYPELESS (R16_UINT/R16_UNORM views)
plus R8_UINT storage planes and R32_FLOAT conversion image, and convert
plane-0 D24 depth words in transfer scratch to/from R32_SFLOAT via the
existing Depth24Converter compute pass in copy_depth_uav. Add
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT to copy scratch, accept D16S8/D24S8
castable lists in castable_view_formats, and keep #1558's refusal fallback
in d3d12_xs_device.cpp for any other provider refusal.

Replace xbox_d16s8_refused_uav with xbox_d16s8_d24_storage covering slot 76
6-layer round-trips, slot 133 1280x720 placement, CreateCommittedResource3
castable formats, R16_UNORM/R16_UINT/R8_UINT UAV clears, and direct D24S8
parent attachment readback.

Verified on Windows 10 19045 / GeForce GTX 1050 Ti (NVIDIA 582.66):
17/17 related CTests pass plain and with LEONIDA_VK_VALIDATION=1 (0
validation errors).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:08:38 +02:00
285801f0ac vk_image_fuzz: enable shaderDrawParameters for the translated vertex shader
Every translated VS declares the SPIR-V DrawParameters capability (BaseVertex /
BaseInstance for the zero-based v0 / v3), but the harness never enabled
VkPhysicalDeviceVulkan11Features::shaderDrawParameters. Under
LEONIDA_VK_VALIDATION=1, vkCreateShaderModule fails with
VUID-VkShaderModuleCreateInfo-pCode-08740 on every case, on both AMD and
NVIDIA, silently zeroing an image_fuzz campaign; drivers tolerate it without
validation.

Query Vulkan11 features on their own vkGetPhysicalDeviceFeatures2 call and
chain enable11 under the Vulkan12 features at device creation, as
vk_sampler_test and vk_bindless_test already do for their queries.

Verified: image_fuzz seed 1 (60 programs) and seed 2 (30 programs) match on
AMD Radeon Graphics and NVIDIA RTX 4070 SUPER with LEONIDA_VK_VALIDATION=1,
0 validation errors; before the fix the first case of each GPU failed with
the VUID. vk_bindless_test and vk_sampler_test run clean under validation on
both GPUs, so their chained Vulkan11-under-Vulkan12 queries needed no change.

Co-Authored-By: Devin <noreply@cognition.ai>
2026-11-25 22:07:34 +02:00
c182b7ad31 gfx10_descriptors: clamp sampler maxLod >= minLod and guard DERIV_ADJUST_EN integer border (VK-SAMPLER-LOD-ORDER-AND-DERIV-ADJUST) 2026-11-25 20:56:03 +01:00
6921a278fd Keep current frame token statistics at or before the poll 2026-11-25 13:54:48 -06:00
6c6a8cd47d vk_pipeline_check: a large module that must wait frees its worker (VK-PIPELINE-CHECK-LARGE-ADMISSION)
A worker took the next index and only then waited in the large-module gate,
so with the memory budget full the modules behind a large one sat untaken
while spare workers blocked, and the pool ran below --jobs.

LargeModuleQueue (large_module_gate.h) now hands out the indices. A large
module the gate can't admit yet is put back and the worker takes the next
one. The oldest module put back goes first as soon as the gate admits it and
no later large module passes it; once every index is out, a worker waits for
it. Nothing is put back while the gate admits each large module as it comes,
so with one worker or room under the budget the order is unchanged, and
--large-parallel 1 and --large-module-bytes 0 never ask the queue to admit.

large_module_gate_test: the waiting module frees its worker (fails with the
old claim-then-admit order), oldest-first and no double entry, the unchanged
order, and every module once under 8 threads.

AI-assisted (Claude Code).
2026-11-25 20:53:43 +01:00
361c3abe61 Reset mouse delta baseline when the cursor source changes 2026-11-25 13:51:01 -06:00
194265665c d3d12: one guarded copy per run of adjacent written geometry tiles (RT-GEOMETRY-READBACK-RUN-MERGE)
A GeometryViews refresh reads each written 64 KiB tile with its own
readability probe and guarded copy, even when the title wrote a run of
adjacent tiles across tile boundaries. Group the written tiles (already in
address order) into maximal runs whose addresses differ by one tile and read
each run a ready view needs as one guarded copy; the per-tile pass then reuses
those bytes through read_tile(). A run that cannot be read whole falls back to
the per-tile read, so an uncommitted page still zeroes only what it did before.

Same behaviour as DexNom/VIctory's copy_fetch_runs
(crates/victory-gpu/src/host.rs, GPL-3.0-or-later, commit 570a941),
re-implemented for this header; no identifiers or code copied.

Tested: geometry_views_test 14/14, including the new case (two adjacent written
tiles are one 128 KiB copy); gta6rt_d3d12_com builds. Synthetic only, no game
files or GPU. AI-assisted.
2026-11-25 14:50:17 -05:00
deac3f6ab1 Gate the title HUD test on Vulkan headers 2026-11-25 13:47:58 -06:00
8b3db052e4 Keep virtual gamepad mouse deltas in range 2026-11-25 13:46:10 -06:00
5a418b50cd feat(runtime): add input validation guards and unit test suite for d3d12_pipeline_checkpoint
Add input validation guards to CacheStagingFile in runtime/shims/d3d12_pipeline_checkpoint.h for empty destination and zero bytes, and add is_direct_session_cache_enabled helper. Add a unit test suite in runtime/test/d3d12_pipeline_checkpoint_test.cpp and register it in runtime/CMakeLists.txt.

Claimed in #1608: RT-PIPELINE-CHECKPOINT-GUARDS-AND-TESTS.

AI-assisted (Claude Code)
2026-11-25 22:42:01 +03:00
16b5b540c0 Merge main into test1700-rdna3-repacking
Conflict in docs/design.md: main added the "Per-lane descriptor selection"
row right above the SHADER-10 row this PR rewords. Both are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:40:04 -05:00
5da72d19f0 Merge pull request #1922 from kawaii-shakal/title-bar-hud
d3d12_xs: LEONIDA_TITLE_HUD shows frame rate, memory and pipeline compiles in the window's title bar (RT-TITLE-HUD)
2026-11-25 20:39:34 +01:00
631a538320 ps_ssharp_o: the S# mip fields on image_sample_lz_o / image_sample_o under the texel-offset fallback (SHADER-EXPLICIT-LOD-BIAS-MVK)
The last --explicit-lod-bias path without GPU coverage: with
LEONIDA_TEXOFF_FALLBACK=1 the implicit offset sample is a Grad sample whose
derivatives the flag scales. A SKIP without the fallback, since vk_sampler_test
enables no VK_KHR_maintenance8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 20:38:26 +01:00
ef205eec98 xbox_bvh_builder: review fixes for batched rehydration (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
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>
2026-11-25 14:37:34 -05:00
721a3b85ae Merge main into wave64-partial-wave-zero
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>
2026-11-25 14:37:20 -05:00
2f7ec7c58c docs: drop ProcessPrng from bcrypt.dll shim note in runtime/README.md 2026-11-26 02:36:48 +07:00
65235f36ad test: update rehydration test comment to specify geometry rebuild (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
AI-assisted (Claude Code, Claude Opus 5.5)
2026-11-25 22:30:44 +03:00
b352aa9be9 xbox_bvh_builder: supply scratch buffer and address review feedback (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
- 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).
2026-11-25 22:30:44 +03:00
cb1cb86e92 xbox_bvh_builder: rebuild from geometry and refuse source-only rehydration (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
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).
2026-11-25 22:30:44 +03:00
07e89b1935 xbox_bvh_builder: implement RehydrateRaytracingAccelerationStructureBatched2X (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
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)
2026-11-25 22:30:44 +03:00
e18b59a5b7 Merge pull request #1612 from Tyrannys/first-run-pad-focus
runtime: the first-run UI keyboard pad reads keys only with focus (RT-FIRST-RUN-PAD-FOCUS)
2026-11-25 20:30:08 +01:00
804f97479f runtime: guard null and invalid sizes in value_write_sink and add unit tests (RT-VALUE-WRITE-SINK-GUARDS-AND-TESTS)
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)
2026-11-25 22:29:11 +03:00
cee965560c Merge pull request #1814 from timbot103/d3d-clear-uav-3d-slice
D3D-CLEAR-UAV-3D-SLICE: clear selected 3D UAV slices and rectangles
2026-11-25 20:29:08 +01:00
2355e60885 Decode generated shader fixture paths as UTF-8 2026-11-25 13:28:58 -06:00
75a41f5dc2 Merge pull request #1896 from IlyassRS3/fix/rt-indirect-topologies-and-stats
runtime: support dynamic topologies in indirect draws and report per-reason skip counts (RT-INDIRECT-TOPOLOGIES-AND-STATS)
2026-11-25 20:28:13 +01:00
b904919ab4 Merge pull request #1832 from IlyassRS3/fix/rt-indirect-clamp-sharing-and-safety
runtime: share indirect clamp buffers across queue families and fix safety bugs
2026-11-25 20:27:08 +01:00
369bb1c753 d3d12: gate SO_STATISTICS pools and refuse per-stream overlap (D3D-302)
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.
2026-11-25 14:24:41 -05:00
ff2e459123 vk_sampler_test --cube/--3d/--dref; ps_ssharp_cube, ps_ssharp_3d, ps_ssharp_c: the S# mip fields on cube, 3D and depth-compare samples (SHADER-EXPLICIT-LOD-BIAS-MVK)
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>
2026-11-25 20:21:58 +01:00
c3b0e86491 Find the standalone glslang compiler in runtime CMake 2026-11-25 13:21:06 -06:00
205bda4a4a Merge pull request #1941 from abnalstlll-byte/feat/rt-texture-tiles-host-adapter
test: respect LEONIDA_HOST_ADAPTER and layer LUID in d3d12_texture_tiles (RT-TEXTURE-TILES-HOST-ADAPTER)
2026-11-25 20:20:30 +01:00
e380a69a60 Merge pull request #1950 from kurrutako/rt/session-cache-at-exit
d3d12: write the session pipeline cache when the run ends with the device alive (RT-SESSION-CACHE-AT-EXIT)
2026-11-25 20:15:15 +01:00
ca0c72f810 runtime: guard empty destination and null data in write_pipeline_cache_file and add tests (RT-PIPELINE-CACHE-FILE-GUARDS-AND-TESTS)
Claimed in Issue #1608 as RT-PIPELINE-CACHE-FILE-GUARDS-AND-TESTS.

AI-assisted (Claude Code)
2026-11-25 22:14:24 +03:00
0bba07bf12 runtime: guard stack region wrap/underflow and null inputs in thread_stacks 2026-11-25 20:12:08 +01:00
4cfbdfc0b2 Merge remote-tracking branch 'origin/main' into rt-xapu-opus-on-1144 2026-11-25 14:12:01 -05:00
a5dd540bcc xapu: decode Opus packets through runtime/opus_decoder (RT-XAPU-OPUS-DECODE)
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.
2026-11-25 14:11:53 -05:00
14e1a352c4 runtime: guard null bind callbacks, add owner accessor and unit test suite for DeferredImageBinding (RT-DEFERRED-IMAGE-BINDING-GUARDS-AND-TESTS)
Claimed in Issue #1608 as RT-DEFERRED-IMAGE-BINDING-GUARDS-AND-TESTS.

AI-assisted (Claude Code)
2026-11-25 22:09:19 +03:00
9fc1862fad runtime: free unused thunk on zero redirects and harden code_hooks bounds 2026-11-25 20:09:18 +01:00
c37374180b Merge pull request #1887 from IlyassRS3/rt-console-heap-vsharp-bitset
d3d12: track live console-heap V# slots in a host-RAM bitset (RT-CONSOLE-HEAP-VSHARP-BITSET)
2026-11-25 20:06:41 +01:00
892f627082 runtime: guard window-fit zero dimensions, signed overflow, and OOM in lifecycle shim 2026-11-25 20:06:10 +01:00
f2e3a77fea d3d12_title_va_test, d3d12_compute_test: serialize root signatures through the shared helper, so the heap-directly-indexed cases run on Windows 10
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>
2026-11-25 21:06:10 +02:00
e6f34ed080 d3d12: say when the driver's pipeline cache stops keeping new pipelines (RT-PIPELINE-CACHE-GROWTH-STALL)
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.
2026-11-25 13:04:29 -06:00
09014c5e6f Normalize file byte order in the SPIR-V reader 2026-11-25 13:02:25 -06:00
f29ca7baca cmake: vk_null_descriptor_test's rule creates generated/ before glslangValidator writes into it
On a fresh macOS or Linux build tree nothing has made generated/ when this
rule runs, so glslangValidator stops with "Failed to open file" and the build
of vk_null_descriptor_test fails (and every test after it in ctest).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:59:16 +01:00
98b22aee0b ps_ssharp_ld, ps_ssharp_b: the S# mip fields on image_sample_l, _d and _b, judged by SAMPLER_CASES (SHADER-EXPLICIT-LOD-BIAS-MVK)
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>
2026-11-25 19:58:22 +01:00
0233a9ec73 runtime: guard null out pointers, add inspection helpers and unit tests for PlacedDepthTextures (RT-XS-PLACED-DEPTH-GUARDS-AND-TESTS)
Claimed in Issue #1608 as RT-XS-PLACED-DEPTH-GUARDS-AND-TESTS.

AI-assisted (Claude Code)
2026-11-25 21:56:23 +03:00
c09ee75c0e d3d12: geometry views drain on the submit thread, bound the release queue, keep one empty block
- 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>
2026-11-25 20:54:56 +02:00
6198879899 Use UTF-8 for shader library module filenames 2026-11-25 12:54:09 -06:00
2e8a92d72a runtime: guard base_reservation parsing and VirtualQuery loop overflow 2026-11-25 19:47:42 +01:00