Commit Graph

4163 Commits

Author SHA1 Message Date
c9924321f2 Merge pull request #113 from eIBart0
# Conflicts:
#	runtime/test/vk_pipeline_check.cpp
2026-11-21 14:42:19 -05:00
6dfc0ce82b Merge pull request #119 from Ryx
# Conflicts:
#	README.md
#	runtime/README.md
2026-11-21 14:40:30 -05:00
8bf99edc7a Merge pull request #95 from Ayinaki 2026-11-21 14:40:15 -05:00
fae7c56571 Merge pull request #114 from Kam471 2026-11-21 14:40:14 -05:00
828cca7729 Merge pull request #108 from Kam471 2026-11-21 14:40:13 -05:00
Ryx
99336386d1 Runtime: D3D12 copies on Vulkan (buffers, textures, uploads, BC) and GetCopyableFootprints
- IR: CopyBufferRegion, CopyTextureRegion (subresource or placed footprint,
  optional box) and CopyResource, with D3D12's call rules (512-byte footprint
  offsets, 256-byte pitches, non-empty boxes).
- Replay: vkCmdCopyBuffer / CopyBufferToImage / CopyImageToBuffer / CopyImage.
  Footprint pitch becomes bufferRowLength; BC extents stop at the mip edge;
  every range and buffer bound is checked before anything is written. Copies
  run in TRANSFER_SRC/DST, or in place in GENERAL for a COMMON texture
  (implicit promotion). 2D only.
- Device: buffers expose their VkBuffer; BC1-7 formats; textureCompressionBC
  enabled when present; GetCopyableFootprints for buffers and 2D textures.
  Compared with the PC runtime over 13 descriptions, which showed planar
  depth-stencil rows are padded to 512 bytes.
- Each submission ends with a barrier to the host so readback buffers hold the
  GPU's writes after the fence wait. BC textures are not zero-filled on first
  use (Vulkan cannot clear them; the validation layer caught the first try).

Tests: d3d12_vulkan_device_test now reads results back through D3D12
(CopyTextureRegion into a readback heap, Map) and adds an upload list: a
pattern into a texture, CopyResource into a COMMON texture, a boxed copy, a BC1
round trip and CopyBufferRegion. command_list_test covers the copy rules. All
GPU tests are clean under the Khronos validation layer; 6/6 ctest.
2026-11-21 20:33:34 +01:00
ba191bd6ce Runtime: fail cleanly on malformed JSON in vk_pipeline_check JsonParser 2026-11-21 19:30:29 +00:00
8cfbdc21cc Runtime: wake vk_pipeline_check watchdog via condition_variable on completion 2026-11-21 19:29:37 +00:00
c2080b5d2d runtime: add optional Bink Audio track extraction test 2026-11-21 19:26:26 +00:00
Ryx
40f6399088 Runtime: Vulkan-backed ID3D12Device behind the Xbox-ABI proxy
- d3d12_vulkan_device.cpp: an ID3D12Device11 (PC ABI) the device proxy
  forwards to. Creates queues, allocators, command lists (incl.
  CreateCommandList1), fences, descriptor heaps (32-byte slots; RTV/DSV hold
  TargetViews), render-target and depth-stencil views, committed buffers
  (upload/readback mapped and zeroed) and 2D textures in the common formats,
  and answers feature-level and architecture queries. Everything else is a
  generated stub that logs once.
- First use of a new texture zero-fills it and moves it to the layout the
  command expects (vulkan_replay.h initialize), as D3D12 committed resources
  start zeroed; no submission at creation. CREATE_NOT_ZEROED skips the fill.
- Children hold the proxy, so GetDevice returns the Xbox-ABI object; COM base
  classes moved to d3d12_com_object.h. D3D12 queues share one VkQueue behind a
  submit lock.
- D3D12XboxCreateDevice: LEONIDA_D3D12=vulkan creates the Vulkan device on its
  own instance and wraps it in the same proxy (gta6rt built with the Vulkan
  SDK and Python 3); the host PC device stays the default.

Tests: d3d12_vulkan_device_test calls everything through the proxy (heaps via
slot 14 with RAX start handles, a render target via slot 76 with the Xbox
layout word) and reads colour, depth, stencil and a never-written texture
back; it also runs the standalone device. Clean under the Khronos validation
layer with the other GPU tests; all 6 ctest tests pass.
2026-11-21 20:22:20 +01:00
428e250b84 Runtime: compile real graphics pipelines (ps/vs/ms/gs) in vk_pipeline_check
- Pair ps/vs/ms/gs shaders with partner stubs from <spirv>/stubs/ and compile
  real pipelines via vkCreateGraphicsPipelines with Vulkan 1.3 dynamic
  rendering (color attachments from outputs, depth attachment when writes_depth,
  VK_EXT_mesh_shader for ms, vertex input bindings for vs).
- Enable only optional extensions needed by the selected shaders; report
  shaders missing required device features or stubs as skipped rather than failed.
- Add --stage all|cs|graphics (--compute-only / --graphics-only), per-stage
  module/pipeline/skip/timing reporting, and guard VK_KHR_maintenance8 for
  older Vulkan headers. Preserves PR #28 --jobs, cache, --start/--count, and SLOW.
2026-11-21 16:18:02 -03:00
7837080454 Tools: add pure-Python SPIR-V stub generator and graphics metadata fields
- Add tools/spirv_stubs.py to emit minimal deduplicated SPIR-V 1.0 VS/PS
  partner stubs into <spirv>/stubs/ using only the standard library.
- Record writes_depth, gs_input_locations, and gs_output_locations in
  shader_meta() (keeping all existing fields intact and avoiding overlap
  with PR #76 / PR #83 fields).
- Generate stubs automatically when rdna2spirv.py or build.py writes index.json.
2026-11-21 16:18:01 -03:00
352300704d Runtime: skip oversized modules in vk_pipeline_check, and record the corpus pass 2026-11-21 19:17:43 +00:00
c2e3d811a8 tests: skip cs_imgload where image reads need a format
vk_store_test requested shaderStorageImageReadWithoutFormat for both
modes, so vkCreateDevice failed on GPUs without it (Intel Gen9) and
cs_imgstore failed too, though only image_load needs the feature.
Request it in load mode only, exit 77 when it is missing, and have
check.py list that as skipped instead of failed.
2026-11-21 16:16:27 -03:00
d51bddc84e GPU tests: skip what the device can't run instead of failing (fixes #88 points 2-3)
vk_store_test exits 77 when the GPU lacks format-less storage image read/write (Intel Gen9), and check.py
reports it as SKIP. run_gpu_tests.py catches up with check.py: ps_flat (drawn with vs_ids), ps_legacy_mul,
and ps_bitmask_perm judged on lanes 0-31 only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 14:16:04 -05:00
126062ae4a Runtime: initialise a loaded module's TLS and DllMain
Mapping an image never ran anything. TLS callbacks and DllMain were documented as the caller's, and
nothing called them, so a module that needs either could not be brought up at all.

Loader::initialise() now allocates the module's TLS slot, copies the template and SizeOfZeroFill into
it, writes the slot index into the image, runs the TLS callbacks with DLL_PROCESS_ATTACH, then calls
the entry point of a DLL as DllMain. Every address it follows is bounded like the rest of the loader:
the directory, the template, the index, the callback table and each callback, with a 1 MiB ceiling on
the block. Only DLLs get DllMain; an EXE's entry point has a different signature and stays the
caller's to run, and --dry-run still runs nothing.

The tests build an image whose TLS callback and DllMain are real machine-code stubs that store a
sentinel, so they check the code actually executed rather than merely being parsed.
2026-11-21 19:00:06 +00:00
71d17d05dd Merge pull request #35 from Zmirzz
# Conflicts:
#	runtime/test/shaders/check.py
#	runtime/test/shaders/cs_wave64_ballot.asm
2026-11-21 13:59:47 -05:00
4732779175 Merge pull request #32 from Kam471
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-21 13:59:19 -05:00
f9176e5176 Merge pull request #84 from Kam471
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-21 13:47:02 -05:00
917e821067 Merge pull request #79 from Ryx
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-21 13:47:02 -05:00
4a513f3db2 Merge pull request #62 from Kam471
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-21 13:47:02 -05:00
36555f1d33 Merge pull request #72 from Kam471
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-21 13:46:53 -05:00
6c9085acd5 Merge pull request #73 from eIBart0
# Conflicts:
#	docs/design.md
#	runtime/test/shaders/check.py
#	tools/rdna2spirv.py
2026-11-21 13:46:45 -05:00
fd7f083c93 Merge pull request #65 from slopgobblercobbler 2026-11-21 13:45:51 -05:00
acddb5eefc Merge pull request #77 from andretuta 2026-11-21 13:45:48 -05:00
52d61377ac Merge pull request #47 from Ayinaki 2026-11-21 13:45:46 -05:00
862372c576 tests: drop llvm-mc directives in shaders/build.py
llvm-mc -show-encoding prints a ".text" line first, and rdna2spirv.py
rejects every shader on it, so build.py produced no SPIR-V with LLVM 19.
run_gpu_tests.py already drops these lines. See #88.
2026-11-21 15:41:28 -03:00
47dec11677 Runtime: bound every RVA the PE loader follows, and test it
The loader trusted the image it was handed: e_lfanew was dereferenced without
checking it against the file size, section copies were bounded by the file but
not by SizeOfImage, and the relocation, export and import walks put no limit on
where an image's own RVAs sent them. A truncated or corrupt image could read or
write outside the mapping the loader had just allocated, and a PE32 image was
read through a PE32+ header instead of being rejected.

Every RVA is now checked first, and a bad one fails with the file's name and
what did not fit. loader_test builds its own images, so ctest covers the good
and the corrupt cases without needing any game files.
2026-11-21 18:32:22 +00:00
70e240ba45 runtime: add optional Bink 2 decode test through loader/xmem 2026-11-21 18:27:47 +00:00
9015a62748 Runtime: Xbox-ABI device proxy (slots 9/10/62/76)
- Wrap the PC ID3D12Device in a copied-vtable proxy: per-slot thunks swap `this` to the PC device, with IUnknown refcounting/QueryInterface, per-slot hit counters and XS_TRACE=1 first-call logging.
- Override Xbox slot 62 to the PC CreateComputePipelineState (PC slot 62 is CreateStateObject) and Xbox slot 76 to CreateCommittedResource (PC slot 27). The 56-byte description prefix is copied and its 0x101/0x1 layout word replaced by ROW_MAJOR for buffers and UNKNOWN for textures.
- Slot 14 wraps the created descriptor heap. On the measured PC runtime the heap getters take the hidden return pointer in RDX, while the Xbox ABI expects the 8-byte handle in RAX; heap slots 9/10 convert between them. Device slots 9/10 stay CreateCommandAllocator/CreateGraphicsPipelineState, because the measured handle getters are ID3D12DescriptorHeap methods.
- Heap slot 7 GetDevice returns the device proxy, not the raw PC device. The heap holds a device-proxy reference, so GetDevice cannot dangle; the device proxy does not reference heap proxies, so there is no cycle.
- Add device_proxy_test (WARP, no game executable): shim-created proxy, QI/refcount, slot 14 heap, heap GetDevice/refcount, raw RAX handles vs the PC hidden-pointer result, slot 9/16/30/43 forwarding, slot 76 buffer and texture, slot 62 compute PSO, and counter checks. Register it with ctest.
- Wire both CMake and scripts/build_runtime.ps1.

Verified against Windows SDK 10.0.26100 d3d12.h (slot counts through ID3D12Device14; no Device15/16 exists there) and a live WARP device. Still unknown: PresentX, queue/fence/command-list extensions, Xbox vtable order beyond the measured slots, and struct returns other than the heap handles.

Clean-room: implemented from the measured ABI-facts spec; no americas-recomp or AnyPS5 source was read or copied.
2026-11-21 18:26:19 +00:00
Ryx
6052bf0bd5 Runtime: rectangle clears, layout tracking, enhanced barriers, COM list/queue/fence
Closes the gaps left by the barrier/clear slice:

- Rectangle clears: ClearRenderTargetView/ClearDepthStencilView rects are
  recorded and replayed with vkCmdClearAttachments in a dynamic-rendering
  scope, clipped to the mip.
- LayoutTracker: the current Vulkan layout per image subresource, so barriers
  start from the real layout. This honours implicit promotion and decay
  (COMMON is GENERAL; simultaneous-access textures stay GENERAL) and, with
  separateDepthStencilLayouts, lets one depth/stencil plane be cleared or
  transitioned while the other stays in another state.
- Enhanced barriers (global, buffer, texture, split, discard) mapped to
  vkCmdPipelineBarrier2.
- vulkan_backend.h: VulkanContext, VulkanQueue (ExecuteCommandLists checks
  every list before writing any; Wait is attached to the next submission),
  VulkanFence on timeline semaphores.
- d3d12_com.cpp: ID3D12GraphicsCommandList7, ID3D12CommandQueue,
  ID3D12CommandAllocator and ID3D12Fence1. Unimplemented methods are stubs
  generated at build time from the SDK's d3d12.h (tools/gen_d3d12_stubs.py),
  so vtables follow the SDK order and nothing SDK-derived is checked in.

Tests: command_list_test and d3d12_state_map_test (every copied D3D12
constant checked against d3d12.h) in ctest; vk_command_replay_test and the new
d3d12_com_test on the GPU, clean under the Khronos validation layer.
2026-11-21 19:19:31 +01:00
1a7ca71f97 Tests: add per-file mattr directive, restore wave64 cs_wave64_ballot, register in run_gpu_tests.py
- Support '; mattr: ...' header directives in runtime/test/shaders/build.py,
  scripts/run_gpu_tests.py, and tests/conftest.py.
- Restore runtime/test/shaders/cs_wave64_ballot.asm to wave64 v_cmp_*_e64
  s[4:5] / s[6:7] / s[10:11] form using '; mattr: +wavefrontsize64,-wavefrontsize32'.
- Register cs_wave64_ballot and cs_wm_* in scripts/run_gpu_tests.py.
2026-11-21 18:11:52 +00:00
caa31b5fd2 Runtime: tests for the native PE loader (fixtures, imports, relocations) 2026-11-21 18:08:39 +00:00
0631f8e721 Tests: fix cs_wave64_ballot.asm for wave32 llvm-mc and add cs_wm_* wave64 tests 2026-11-21 15:08:29 -03:00
5f3007f393 tests/semantic: cover ps_ops2, ps_ops3, ps_ops4 and ps_legacy_mul (+ check.py) 2026-11-21 15:05:54 -03:00
428f4610af test(runtime): verify D3D12 and XMem ABI type alignment and structure sizes 2026-11-21 19:05:17 +01:00
Ryx
7f6e8f059d Runtime: D3D12 barriers and depth-stencil clears in the command-list IR
The IR (command_list.h, was clear_commands.h) now records transition, UAV and
aliasing barriers (split barriers record their end half) and full-view
ClearDepthStencilView next to ClearRenderTargetView.

vulkan_replay.h (was vulkan_clear.h) maps D3D12 resource states to Vulkan
layout/access/stage (section 4.3 table), decodes subresource indices including
depth/stencil planes, validates the whole list before emitting anything, and
wraps clears in a layout round trip so images stay in their D3D12 state. The
caller no longer manages layouts by hand.

Tests: command_list_test (recording rules), d3d12_state_map_test (state table,
subresource decoding, constants checked against d3d12.h; needs Vulkan headers
only) and vk_command_replay_test (GPU readback of colour, depth and stencil;
LEONIDA_VK_VALIDATION=1 runs it under the Khronos validation layer).
2026-11-21 18:58:48 +01:00
6582fa2dcb Make Vulkan shader checks aware of wave64 support 2026-11-21 19:46:32 +02:00
ad7691790b Runtime: tests for the measured xmem shim ABI 2026-11-21 17:42:40 +00:00
f20ea6dde8 Merge pull request #28 from Eremia Brinzoi Razvan Andrei 2026-11-21 12:26:30 -05:00
0a9dc48d72 Merge pull request #27 from Kam471 2026-11-21 12:26:30 -05:00
34d2e63c65 Runtime: match the measured Xbox xmem/d3d12_xs ABI
- xmem: XMemVirtualQuery(process, address, out64) fills the known MEMORY_BASIC_INFORMATION prefix and zeroes the rest; the working-set size goes at +8 with a TRUE return; allocator alignment and size-0 behaviour are documented.
- d3d12_xs: copy root-signature descriptors and clear the Xbox high flag byte (0x03000000) before forwarding to the PC serializer; add the legacy serializer; keep the deserializer.
- d3d12_xs: add D3D12XboxCreateDevice, create a PC device and log the 24-word params block. The Xbox ABI proxy is not implemented; measured slot overrides are documented as TODO and logged at runtime.
- test: root_sig_test serializes synthetic flags=0x03000000 descriptors through the PC d3d12.dll, checks the untouched copy is rejected and the cleared copy is accepted, and exercises the registered shim.

Clean-room: implemented from an ABI-facts spec derived from public write-ups; no source from americas-recomp or AnyPS5 was read or copied.
2026-11-21 17:23:05 +00:00
770c496630 Record full-view color clears and replay them on Vulkan 2026-11-21 19:20:39 +02:00
0aa9840021 vk_pipeline_check: compile on --jobs threads, name compiles stuck past 60 s, resume from the cache (saved every 10 min), --start/--count, line-buffered failures
A full-corpus run stalled for hours inside one compute pipeline with its failure lines stuck in stdout's buffer and no cache written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 12:12:27 -05:00
4b251d1cb6 Merge pull request #15 from Mulkku
# Conflicts:
#	runtime/test/vk_store_test.cpp
#	runtime/test/vk_texture_test.cpp
#	runtime/test/vulkan_loader.h
#	tools/rdna2spirv.py
2026-11-21 11:47:52 -05:00
f967ab8959 Merge pull request #18 from ttd0x
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-21 11:47:07 -05:00
53d903930a Merge pull request #14 from eIBart0 2026-11-21 11:46:54 -05:00
6f486f75d3 Merge pull request #13 from eIBart0 2026-11-21 11:46:54 -05:00
ab0cf03016 fix(runtime): type D3D12 root signature forwarding 2026-11-21 18:03:59 +02:00
987e8471ee Fix RDNA2 wave masks and flat inputs
Preserve whole-wave mask operations, saved EXEC values and flat
pixel inputs when generating SPIR-V. Keep a dispatch-loop fallback
alongside structured control flow and share the descriptor probe.

Add reproducible GPU fixtures for these cases and exercise the
control-flow and mask analyses in CI.
2026-11-21 16:56:54 +02:00