Commit Graph

362 Commits

Author SHA1 Message Date
98dc77c4eb Merge pull request #1874 from Serrambi 2026-11-22 09:49:00 -05:00
33507d493d Merge pull request #1863 from jsthope 2026-11-22 09:48:52 -05:00
b566a8652f Merge pull request #1844 from romainveurrier 2026-11-22 09:48:41 -05:00
3b7cd5e4bf Merge pull request #1791 from AlxcBTW 2026-11-22 09:48:16 -05:00
8ec3ab82ae Merge pull request #1707 from Ash Hopkins 2026-11-22 09:48:07 -05:00
bf0ce0d062 Merge pull request #1706 from Ash Hopkins 2026-11-22 09:48:06 -05:00
e608a1b992 d3d12: support typeless and castable RGBA8 RTVs on MSAA textures 2026-11-22 15:44:41 +01:00
9fd1aaed66 XDXR: CopyRaytracingAccelerationStructure (clone, compact) and postbuild sizes
CopyRaytracingAccelerationStructure and EmitRaytracingAccelerationStructure-
PostbuildInfo were not implemented, and the postbuild descs of
BuildRaytracingAccelerationStructure were ignored.

- CLONE and COMPACT copy the structure's bytes (MODE_COPY_AS). XDXR records
  are position-independent: node pointers count from the structure's start
  and a TLAS names its BLASes by address. The size comes from the source
  header, so a copy can follow a build in the same list; the destination
  resource bounds it.
- COMPACTED_SIZE and CURRENT_SIZE (MODE_POSTBUILD) are totalSizeIn64BNodes *
  64: a build is already exactly its layout's size. Written for
  EmitRaytracingAccelerationStructurePostbuildInfo and for each postbuild
  desc of a build, after it.
- New IR commands CopyAccelerationStructure and AccelerationStructurePostbuild.
  Serialization, deserialization and tools visualization are refused at
  replay. With LEONIDA_RT_AS=khr the postbuild descs stay ignored, as before.
- vk_xdxr_build_test: a clone of blas_random, its COMPACTED_SIZE (== layout
  size), a compaction into exactly that size with a guard word after it, and
  a clone of the refitted TLAS.
- d3d12_xdxr_rt_test: EmitRaytracingAccelerationStructurePostbuildInfo for
  both structures and a TLAS rebuild with a CURRENT_SIZE desc (all equal to
  the prebuild sizes), then COMPACT into a buffer of that size, checked as
  d3d12_blas_compacted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:29:57 +01:00
eebf85b60f Merge remote-tracking branch 'origin/main' into runtime-vulkan12-khr
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/vk_test_device.h
2026-11-22 14:21:37 +00:00
2d2eec9a75 M4 review: storage-image init only on shader-running non-copy submissions, ordered for other queues
- The zero-fill/GENERAL init of images with a UAV view no longer drains on a copy
  queue or in a submission that runs no dispatch or draw; every other queue's next
  submission waits on the initializing one's progress semaphore.
- storage_pending_ is a set (UAV descriptors are rewritten every frame).
- write_buffer_uav: FirstElement and element count are checked against
  Width / unit, so the byte range cannot overflow.
- docs: M4 row names the remaining limitation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:21:28 +01:00
1df4c3b0f1 runtime: erasing a bindless descriptor key no longer idles the GPU
DescriptorTable::erase backward-shifted the key's probe cluster, which moved
other live entries, so BindlessSet::erase_key flagged the next flush as
needing idle and every texture release ended in vkDeviceWaitIdle on the next
submit.

The shift is not needed: every lookup, on the CPU and in the translated
shaders (rdna2spirv.py desc_probe), compares all eight probe slots and never
stops at an empty one. Erase now empties only the key's own slot, and inserts
reuse the hole. An erase uploads like an add (one slot, no idle). Replacing a
live key's index, a relocating insert and table growth still require idle.

Tests: descriptor_table_test checks that an erase in the middle of a cluster
leaves every other slot byte-identical and marks one changed slot (it fails
on the old erase); vk_bindless_test now expects no idle after an erase.
2026-11-22 15:19:11 +01:00
ef15a21ba0 Merge pull request #1789 from romainveurrier 2026-11-22 09:15:22 -05:00
959505bae1 Merge pull request #1787 from CowDeV 2026-11-22 09:15:21 -05:00
e66286921e Merge pull request #1765 from Emirhan Karaca 2026-11-22 09:15:11 -05:00
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
427532c70c base_reservation: check SetEnvironmentVariableW and ResumeThread before waiting on the child
Review on #1707: without the marker the child would not use the reservation and could relaunch again, and a
child left suspended would make the infinite wait hang. Both now end the child and return 1, as a failed
reservation already did.

AI-assisted. No game files.
2026-11-22 14:14:17 +00:00
c2f39447b6 Merge origin/main into m4-synthetic-gate 2026-11-22 15:13:40 +01:00
967564a20c M4 (synthetic): d3d12_m4_compute_test, UAV table, indirect dispatch, copy queues; buffer UAV views and indirect dispatch state
d3d12_m4_compute_test, through the proxy with D3D12 API only and two
translator-output compute shaders (cs_m4_fill.asm, cs_m4_indirect.asm):
a COPY queue streams an input buffer in, a COMPUTE queue waits on it and runs a
compute PSO over a UAV table (structured buffer, raw buffers, an R32_UINT
RWTexture2D), then ExecuteIndirect of a second PSO from arguments the first
wrote (with a transition to INDIRECT_ARGUMENT and UAV barriers), and a COPY
queue behind a cross-queue fence reads the results back. 1,924 words match the
CPU reference with error 0.

Layer gaps the test found, fixed:
- CreateUnorderedAccessView of a buffer was a stub: structured and raw views are
  now a V# in the slot.
- ExecuteIndirect of a dispatch ran whatever pipeline and root arguments the
  command buffer had bound; the command now carries the list's, as Dispatch does.
- An image created in UNORDERED_ACCESS and first used by a shader was
  zero-filled by the first barrier or copy that named it, losing the shader's
  writes; images with a UAV view are now moved to GENERAL (zeroed) at the next
  submission.
- COMPUTE and COPY command lists no longer log "unimplemented".

Test infrastructure: vk_test_device.h can create more than one VkQueue;
build.py gives a compute shader's FSSM program extra words (fssm-at/fssm-data
from 0x148) so two compute shaders with the same group size get distinct hashes,
and honours LEONIDA_SPIRV_TOOLS (as #1679) so the target builds under the Visual
Studio generator. docs/d3d12_vulkan.md section 6: M4 synthetic part met; M3 row
credits @whattheflop's #1584 measurement of fences in flight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:09:58 +01:00
f6d6121c9c XDXR builds: PERFORM_UPDATE refits instead of rebuilding
An update (same topology, new positions or instance transforms) now keeps the
source's tree and recomputes its boxes: the source is copied to the
destination unless it is the destination (MODE_COPY), the elements are
rewritten at their slots, MODE_LEVEL with arg2 = 1 recomputes each node's
boxes from the children it already points to, and the header gets the new
bounds. No Morton pass, no sort, and the parent table is kept.

RTX 2050: 1,000 triangles 0.07 ms (build 0.19), 100,000 1.02 ms (2.24),
1,000,000 9.8 ms (22.0); Iris Xe 13.1 ms for 1M (47.9).

- XdxrBuilder::record_blas / record_tlas take `update_from`; the Vulkan
  backend passes the source (or the destination, for an in-place update)
  when the D3D12 build has PERFORM_UPDATE.
- vk_xdxr_build_test: a 3,000-triangle BLAS refitted in place (radix-sort
  tree), an R32-indexed grid refitted into another buffer (its untouched
  source is checked too), and the TLAS refitted after its instances move;
  the timing mode also times refits.
- d3d12_xdxr_rt_test: the BLAS is built with ALLOW_UPDATE, its soup moves,
  and a PERFORM_UPDATE in place is checked as d3d12_blas_update.
- tools/xdxr_bvh.py check-build: the case being checked answers reads at its
  address first (an in-place update leaves two dumps at one address).

A sabotaged refit (no box pass) fails every update case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:09:14 +01:00
e2ec3a8448 Runtime: exact minimum-LOD views and full bindless set on Intel Xe-LP (D3D-219)
d3d12_descriptor failed every run on an Intel UHD 770 (101.7092) for two
reasons, both from the driver taking an option the Vulkan spec allows:

- VK_EXT_image_view_min_lod: the driver selects levels with
  minLodInteger = floor(minLod), the spec's "alternative", so a 0.75 or
  1.75 ResourceMinLODClamp read one mip too detailed. On Intel integrated
  GPUs bind_image now passes the clamp rounded to the nearest level,
  which point mip filtering selects exactly.
  LEONIDA_MIN_LOD_INTEGER=1/0 forces it either way.
- The bindless set stayed at its default counts (4096 2D images, 1024
  samplers) because the driver reports maxPerSetDescriptors = 6159 with
  every other limit at 1048576. size_bindings now takes an optional
  layout_supported callback, and past maxPerSetDescriptors the device
  asks vkGetDescriptorSetLayoutSupport about the grown layout.
  bindless::SetLayout describes set 0 once for create_layout and that
  query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:08:32 +01:00
f43ced594f Runtime: zero-initialize committed block-compressed textures on first use (D3D-220) 2026-11-22 16:59:06 +03:00
db9b0904f0 Runtime: O(1) LayoutTracker rollback and unlock tracker_mutex before vkQueuePresentKHR in VulkanPresenter 2026-11-22 16:47:54 +03:00
19b261bb99 Merge remote-tracking branch 'origin/main' into runtime-vulkan12-khr
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/test/vk_test_device.h
2026-11-22 13:45:11 +00: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