Commit Graph

340 Commits

Author SHA1 Message Date
3430786f75 Merge pull request #1744 from Emirhan Karaca 2026-11-22 09:15:00 -05:00
445e79b2c7 Merge pull request #1743 from romainveurrier 2026-11-22 09:15:00 -05:00
09854b89a5 Merge pull request #1707 from Ash Hopkins 2026-11-22 09:14:52 -05:00
db9b0904f0 Runtime: O(1) LayoutTracker rollback and unlock tracker_mutex before vkQueuePresentKHR in VulkanPresenter 2026-11-22 16:47:54 +03:00
a72cc827e6 Merge remote-tracking branch 'origin/main' into runtime-reserve-fixed-base
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/src/main.cpp
2026-11-22 13:44:03 +00:00
fa2712e2b0 xdxr_build: one-workgroup sort for small builds, 256-element radix tiles
The radix sort's fixed latency dominated small builds (2,000 triangles: 0.81
ms with the sort, 0.08 ms without, on an RTX 2050; the 10k regression
@exhawk measured on #1572). Up to 1,024 keys are now sorted in one
workgroup's shared memory (bitonic, ties by element index: the stable
order; 8 KiB, within the 16 KiB minimum with the radix arrays), and the
radix tiles are 256 elements (4 chunks instead of 32 per workgroup).

RTX 2050: 1,000 triangles 0.24 ms, 2,000 0.28 ms (0.83), 10,000 0.38 ms
(0.81), 100,000 2.3 ms (2.5); 1M 21.9 ms (20.3, the larger scan).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:41:25 +01:00
6e8a1400ee vulkan_replay: name the XDXR build branch's binding apart from the KHR one
Two `const auto* build` in one else-if chain: the second hides the first
and MSVC /W4 warns (C4456) in every file that includes the header
(reported by @zneel on #1667).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:41:25 +01:00
aa5ff92859 Merge pull request #1696 from SHAURYASANYAL3 2026-11-22 08:38:31 -05:00
6bce2fe30f Merge pull request #1691 from totonii 2026-11-22 08:38:29 -05:00
1352cffcda Merge pull request #1684 from Emirhan Karaca 2026-11-22 08:38:23 -05:00
e2af5b7df7 Merge pull request #1674 from Serrambi 2026-11-22 08:38:19 -05:00
3ed19122f1 Merge pull request #1654 from Codex 2026-11-22 08:38:15 -05:00
4296f3d22a Merge pull request #1624 from Flyander 2026-11-22 08:38:10 -05:00
bb0ecfc089 Merge pull request #906 from AlxcBTW 2026-11-22 08:37:59 -05:00
83160a8114 d3d12: handle 4x MSAA and invalid MSAA in tiled allocation queries (D3D-191) 2026-11-22 14:36:05 +01:00
1f71839aa3 runtime: fallback and clamp swapchain extent when surface reports undefined extent (D3D-165) 2026-11-22 18:59:51 +05:30
73311ed04d d3d12: retire queue tickets only after successful idle 2026-11-22 16:22:18 +03:00
32a6f0340d D3D-162: reject footprint conversions before preparation 2026-11-22 14:21:03 +01:00
44288b3033 Merge remote-tracking branch 'origin/main' into w-pso4
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/shaders/check.py
#	runtime/test/vk_test_device.h
#	scripts/run_gpu_tests.py
2026-11-22 14:19:31 +01:00
34a760fc73 fix(vulkan): check vkGetSemaphoreCounterValue VkResult in ScratchBuffers and Depth24Converter collect() 2026-11-22 10:18:43 -03:00
07b5dabec3 Runtime: serialize QueryReplay plan/commit with remove_query_pool and keep pending waits on failed submit 2026-11-22 16:14:35 +03:00
1b1d090e3c Merge pull request #1667 from romainveurrier 2026-11-22 08:08:38 -05:00
ab8f759e44 Merge pull request #1658 from totonii 2026-11-22 08:08:33 -05:00
2c075b19ef Merge pull request #1654 from Codex 2026-11-22 08:08:29 -05:00
53961b7a95 Merge pull request #1624 from Flyander 2026-11-22 08:08:14 -05:00
4364ca6671 Merge pull request #1619 from Emirhan Karaca 2026-11-22 08:08:13 -05:00
a795fb9636 Merge pull request #1572 from romainveurrier 2026-11-22 08:08:07 -05:00
1c58d6cfbc D3D12: BuildRaytracingAccelerationStructure writes XDXR BVH4 records
The game's translated RT shaders read the console's XDXR records, which a
VkAccelerationStructureKHR is not (docs/d3d12_vulkan.md 4.8). The standalone
Vulkan device now builds them with src/xdxr_build.h, unless LEONIDA_RT_AS=khr
keeps #743's KHR builds (the proposal in the maintainer decisions of #1548).

- VulkanDeviceInfo::xdxr_acceleration_structures; the standalone device sets
  it with bufferDeviceAddress and then leaves the KHR extensions off, so
  acceleration-structure buffers keep their console VAs.
- VulkanContext owns an XdxrBuilder; replay checks the inputs while the list
  is prepared (R32G32B32/R32G32 vertices, none/R16/R32 indices, addresses,
  counts) and records the build with heap_base added to every VA and as the
  bias for instance BLAS addresses.
- GetRaytracingAccelerationStructurePrebuildInfo answers from XdxrLayout,
  exactly; an update rebuilds, so it needs the same scratch.
- The geometry's vertex format is mapped per DXGI format (an unknown one is
  refused instead of read as R32G32B32), and its D3D12 flags reach the build.
- test/d3d12_xdxr_rt_test.cpp: a two-geometry BLAS (a soup; an R16-indexed
  grid with stride 16 and a transform) and a TLAS of three instances through
  the D3D12 API; ctest d3d12_xdxr_rt + d3d12_xdxr_rt_check.
- tools/xdxr_bvh.py: check-build compares TLAS hits by (geometry, primitive),
  and skips (77) when the build step wrote no cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:04:34 +01:00
e4de50abfd fix(shader_library): validate DXBC part-table bounds before iterating parts 2026-11-22 09:59:46 -03:00
d820ecfa63 runtime: reserve a relocation-less image's range before arm64 Wine takes it
An EXE without .reloc can only run at its ImageBase (0x140000000 by default; RT-22 asks whether the game's
is one). Under arm64 Wine on macOS (CrossOver's arm64 bottles, x86-64 code under FEX) the process's own
start-up allocations sit at 0x100000000 and up before gta6rt runs, so such an image failed with "preferred
base is taken". gta6rt now starts itself again suspended when the image has no relocations and its range is
not free, reserves [ImageBase, ImageBase + SizeOfImage) in the new process, resumes it and returns its exit
code; the loader commits the image inside that reservation. LEONIDA_BASE_RESERVED tells the new process,
which does not start itself again. Where the range is free at start-up (Windows, x86-64 Wine) nothing
changes.

tiny_game_fixed is the stand-in game linked /FIXED at 0x140000000; run_tiny_game_fixed and
run_tiny_game_fixed_exit_code run it. Arm64 bottle (CrossOver Preview 20260821, M2 Max): it maps at
0x140000000 and both tests pass, --dry-run and --init exit 0; with the relaunch disabled it fails as
before. The Rosetta (x86-64) bottle passes them too. The in-process loader tests that build relocation-less
images (loader, pe_loader_bounds, unimplemented_policy) still fail on arm64.

AI-assisted. No game files.
2026-11-22 12:53:32 +00:00
3e74f988dd D3D-97 follow-up: retire submissions in completion order 2026-11-22 15:52:52 +03:00
51a0281154 xdxr_build: radix sort over the exact element count instead of a bitonic sort
The bitonic sort padded the keys to a power of two and needed O(log^2 n)
dispatches, so one triangle past a power of two doubled its work (2.1 ms ->
5.2 ms at 262,144 -> 262,145 triangles on an RTX 3060, reported on #1572).
It is now a stable LSD radix sort: 8 passes of 4-bit digits over the 30-bit
Morton keys, each a count per 2048-element tile, one exclusive scan and a
scatter; 24 dispatches whatever the count, shared memory only.

- vk_xdxr_build_test: a 5000-triangle case (three sort tiles, the last
  partial); stale cases from an earlier run are removed first, so a failed
  build cannot be checked against old files.
- tools/xdxr_bvh.py: validate reports a leaf reached twice; a case may ask
  check-build for fewer rays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:51:21 +01:00
65e185f7a9 D3D-162: refuse footprint dispatches inside statistics queries 2026-11-22 13:41:02 +01:00
f376f9f748 Runtime: lock LayoutTracker, roll back failed submits, and serialize capture copies in VulkanPresenter 2026-11-22 15:38:29 +03:00
93fb3583b9 Merge pull request #1596 from bobcatchris 2026-11-22 07:38:27 -05:00
83f13ed569 Merge remote-tracking branch 'origin/main' into rt/xdxr-gpu-builder-merge
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-22 13:38:24 +01:00
8c35079690 Merge pull request #1583 from Vonsek 2026-11-22 07:38:22 -05:00
df311d79b8 Merge pull request #1582 from Emirhan Karaca 2026-11-22 07:38:22 -05:00
85520f2a64 Merge pull request #1560 from Instru Control 2026-11-22 07:38:12 -05:00
af665729d2 Merge pull request #1553 from quackottu 2026-11-22 07:38:09 -05:00
41557027b6 Merge pull request #1551 from HQasper 2026-11-22 07:38:08 -05:00
f3e6d5a9b4 Merge pull request #1523 from AlxcBTW 2026-11-22 07:38:02 -05:00
12eab0b570 Merge pull request #1489 from AlxcBTW 2026-11-22 07:38:00 -05:00
d63d9c9a05 Merge origin/main into pso-subgroup-size-v2
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 13:34:03 +01:00
c96a3427f8 shader_library: parse JSON numbers without floating-point from_chars
Apple's libc++ (Xcode Command Line Tools 17) does not provide the floating-point std::from_chars overload, so the runtime does not build on macOS. Parse the token with strtod instead, keeping the full-token and ERANGE checks so malformed or out-of-range JSON numbers are still refused. No game files.

Verified with shader_library_test on Windows/MSVC (1/1 and direct run).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 06:31:04 -06:00
432d9ab1eb fix(runtime): support IBStripCutValue via dynamic primitive restart
CreateGraphicsPipelineState previously logged that index-buffer strip cuts (primitive restart) were not modelled and left primitiveRestartEnable disabled.

Load Vulkan 1.3 vkCmdSetPrimitiveRestartEnable in vulkan_backend.h, declare VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE on graphics pipelines, record IBStripCutValue on GraphicsPipeline, and enable primitive restart during replay only for indexed strip topologies whose index format matches the PSO strip-cut value (0xFFFF with UINT16, 0xFFFFFFFF with UINT32). Add synthetic 16-bit/32-bit triangle-strip cut and no-cut negative-control GPU draw tests in d3d12_draw_test.
2026-11-22 13:25:06 +01:00
eeb873355e Runtime: match GPU->HOST readback stages to depth24, rgb96 and buffer UAV clears 2026-11-22 15:23:54 +03:00
86f7e9f887 Runtime: build XDXR BVH4 acceleration structures on the GPU
The game's translated ray-tracing shaders read the console's BVH records
themselves (docs/d3d12_vulkan.md 4.8), so the layer has to write them. This
adds the GPU builder, checked against tools/xdxr_bvh.py:

- src/xdxr_build.comp: one pipeline, one dispatch per step. Triangle leaves
  (any of R32G32B32/R32G32 vertices, none/R16/R32 indices, a stride, an
  optional 3x4 transform) or 128-byte INSTANCE records with world-to-object
  inverses; Morton keys and a bitonic sort; BOX32 nodes four consecutive
  children at a time, level by level, with the parent table; the header.
  Buffer device addresses as uvec2: needs bufferDeviceAddress, not
  shaderInt64. NaN triangles, mask-0 instances, instances without a BLAS and
  singular transforms get empty boxes.
- src/xdxr_build.h: XdxrLayout (exact result and scratch sizes from the
  element count, for the prebuild info too) and XdxrBuilder (records the
  dispatches). A bias maps the application's 40-bit BLAS addresses to device
  addresses.
- test/vk_xdxr_build_test.cpp: nine synthetic cases built on the GPU and
  dumped; ctest `xdxr_build` + `xdxr_build_check`, which runs
  `tools/xdxr_bvh.py check-build`: validate, then trace 1000 rays per case
  against brute force.
- vk_test_device.h: opt-in bufferDeviceAddress (request_buffer_device_address,
  device_address()).
- tools/xdxr_bvh.py: check-build; trace takes the bias; instances without a
  BLAS and inactive triangles are valid.

Not wired to BuildRaytracingAccelerationStructure yet: that path builds a
VkAccelerationStructureKHR today (#743), and which one the layer uses is a
maintainer decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:19:18 +01:00
b367783da5 Keep the Vulkan swapchain alive until preflight succeeds 2026-11-22 15:42:57 +03:30
a98f9925b0 gta6rt: map GAME: console paths, and send writes to an overlay (RT-97)
A mapped title names its files on the console's drives, but nothing mapped them: the file calls went
straight to the host and --game-dir was only used to find modules, so the first file a title opens at boot
would fail. New shims for CreateFile*, FindFirstFile*/FindNextFile*/FindClose, GetFileAttributes*/
GetFileAttributesEx* and DeleteFile* (kernel32, kernelbase and the api-ms-win-core-file sets) map a GAME:
path under --game-dir, and send every open that can write and every delete to --overlay (default
<game-dir>\overlay), which reads and listings prefer. A write-open copies the package file into the overlay
first, so OPEN_EXISTING keeps its bytes, and a delete of a package file leaves a marker instead of removing
it, so the package is never modified. A path that climbs above GAME: with ".." or names another drive is
refused with ERROR_INVALID_NAME. A path without the prefix is still a host path.

The prefixes and the overlay come from ivall/xcl (GPL-2.0-only), as facts only, no code.

file_system ctest: 43 checks over folders in %TEMP%, covering mapping and case, copy-up and read
preference, a new file in folders the package lacks, delete and re-create, the merged listing, host-path
passthrough, the escape refusal and the narrow variants.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 13:11:57 +01:00