Commit Graph

38 Commits

Author SHA1 Message Date
3fae38a7a1 GPU tests: ms_v5_workgroup expects #209's v5 (group * NumThreads + lane); run_gpu_tests runs #167's ps_texture_sample
#219's checker was written for the older workgroup-index model; on an RTX 4060 Ti lanes 0/1/31 of every
group read 32g, 32g+1, 32g+31, which is #209's model (the game's mesh entry shifts v5 right by 7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:51:24 -05:00
8b4d2f781e Merge pull request #212 from Ayinaki
# Conflicts:
#	tests/test_shader_checks.py
2026-11-21 16:38:46 -05:00
a81bcb8284 Merge pull request #207 from LouisRiverstone
# Conflicts:
#	runtime/test/vk_harness.cpp
2026-11-21 16:38:32 -05:00
e9cb0b0e68 Merge pull request #203 from Ayinaki
# Conflicts:
#	tests/test_shader_checks.py
2026-11-21 16:38:18 -05:00
e8a0b11ada Test mesh v5 against all 24 coordinates of a 3D draw 2026-11-21 22:33:25 +01:00
cdc67e4d20 GPU tests: report gs_tri/ms_tri as SKIP without geometry or mesh shaders (TEST-18)
vk_harness exits 77, the code vk_compute_test and vk_store_test already use for a
device that cannot run a test, when VKH_GS is set and the device has no
geometryShader, or VKH_MESH is set and it has no VK_EXT_mesh_shader. Before, a
missing mesh extension exited 1 and a missing geometryShader failed in
vkCreateDevice with VK_ERROR_FEATURE_NOT_PRESENT (MoltenVK, #166).

run_gpu_tests.py (gs_tri, ms_tri, ms_w64x_ballot, ms_clip) and check.py
(ms_w64x_ballot) turn that exit code into SKIP, quoting the harness's reason.
2026-11-21 18:29:45 -03:00
24115f1450 check.py and run_gpu_tests: run cs_bounds (num_records bounds check) 2026-11-21 21:29:30 +00:00
4e390e0871 run_gpu_tests: --filter ps_flat also builds vs_ids, which ps_flat is drawn with (fixes #192)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:19:54 -05:00
f348eb9be0 GPU tests: skip pixel tests without barycentrics and narrow subgroups 2026-11-21 21:17:07 +00:00
f238f66a97 Merge pull request #186 from imnotdiesel
# Conflicts:
#	runtime/test/shaders/build.py
#	scripts/run_gpu_tests.py
2026-11-21 16:08:57 -05:00
f3da088e56 Merge pull request #171 from shelbykb2
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/test_shader_checks.py
2026-11-21 16:08:48 -05:00
1261c082e8 Merge pull request #167 from 0xTehuti 2026-11-21 16:08:09 -05:00
5026d36f9c Merge pull request #184 from Mokbul Miah 2026-11-21 16:08:07 -05:00
a0611c9fef Merge pull request #177 from simonbronk 2026-11-21 16:08:07 -05:00
ce2cf75785 Merge main and share compute fixture header overrides 2026-11-21 22:04:18 +01:00
5b3bbad6e6 Test compute workgroup Y/Z registers on a 3D Vulkan dispatch 2026-11-21 22:00:38 +01:00
66a410edf0 Accept LLVM_MC as a whole command in the tests and GPU tools
LLVM_MC may be one executable or a command line such as the WSL llvm-mc documented for Windows. shader_disasm.py already split it, but the tests, runtime/test/shaders/build.py and scripts/run_gpu_tests.py treated it as a single executable, so the documented setup skipped translator tests, and build.py passed a Windows path to WSL. Share the splitter in tools/mc_command.py and feed assembly on stdin.
2026-11-21 21:00:03 +00:00
95b2c091c8 Build a native Windows llvm-mc with the AMDGPU target, no WSL needed
scripts/build_llvm_mc.ps1 sparse-clones the LLVM sources llvm-mc needs,
builds it alone with LLVM_TARGETS_TO_BUILD=AMDGPU, static CRT and the DIA
SDK off (its headers need ATL, which the C++ build tools don't always
include), checks it disassembles an s_endpgm for gfx1013, keeps only
llvm-mc.exe and sets LLVM_MC for the user. README, docs/design.md and the
make_game.py / shader_disasm.py hints mention it next to the WSL route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:50:01 +01:00
16d285e7bc Merge pull request #152 from AlxcBTW
# Conflicts:
#	scripts/run_gpu_tests.py
#	tests/test_shader_checks.py
2026-11-21 15:47:57 -05:00
89ca8c85e5 Merge pull request #149 from eIBart0 2026-11-21 15:47:57 -05:00
0f85eec343 Merge pull request #154 from crastinator 2026-11-21 15:47:56 -05:00
82a1e229c9 Runtime: implement FNV-1a descriptor hash table for shader contract (set 0, binding 2) 2026-11-21 21:37:24 +01:00
49dd92d41d translator: SMEM loads with soffset and imm add both (the imm was dropped)
What was wrong
An RDNA2 SMEM load can carry a register offset and an immediate at once.
llvm-mc prints that form as "s_buffer_load_dword s12, s[24:27], s40 offset:0x4".
shader_ir.parse_line puts "offset:0x4" in mods, and Gen.scalar_load only read
the third operand, so the immediate was dropped without a diagnostic: the line
translated to the same SPIR-V with and without the modifier, and spirv-val
accepted both.

Evidence
Measured on an AMD Radeon RX 6800 (gfx1030) by running the instructions as a
raw compute kernel: for s_buffer_load_dword/x2/x4/x8 the address is
base + soffset + imm + 4*i, e.g. soffset 8 + imm 4 reads the dword at +12.
s_load_dword* with both offsets was not measured; it shares the SMEM encoding
(soffset_en + imm), so giving it the same rule is an inference.

Change
- scalar_load adds the immediate when the third operand is a register and mods
  has offset:N. The no-modifier forms emit the same code as before.
- Forms llvm-mc does not accept (immediate operand plus offset:, two offset:
  modifiers, a fourth operand, an unparseable offset) raise Unsupported.
- Not changed, and listed in docs/design.md as known differences: the hardware
  truncates base, soffset and imm each to a multiple of 4 and s_buffer_load
  returns 0 past NUM_RECORDS; the translator does neither. A negative s_load
  immediate is still zero-extended from 32 bits, in both forms (not measured).

Tests
- tests/semantic/test_scalar_mem_smem.py: SmemSoffsetImmTranslatorTests runs
  the code scalar_load emits against concrete SGPRs and memory and asserts the
  addresses and values read (9 tests; 7 fail on main, where the loads read +8
  instead of +12, and the imm-only / soffset-only regression cases pass).
- runtime/test/shaders/cs_smem_soffset_imm.asm, wired into check.py and
  scripts/run_gpu_tests.py. Not run on a GPU in this change.
- unittest discover -s tests/semantic: 335 -> 344, all pass.
- pytest tests (--capture=sys, llvm-mc through WSL): 883 -> 893 passed, the
  same 6 test_rtti_scan failures before and after (pefile not installed).
- The 27 hand-written GPU shaders: 27 translated, 27 pass spirv-val before and
  after, output byte-identical.

AI-assisted.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 13:28:03 -07:00
dcf5f44879 Translator: decide VOP3 for 16-bit integer ops from the encoding size, not the _e64 suffix
LLVM 21 prints the VOP3 form of v_lshlrev_b16, v_add_u16 etc. without _e64. All of them in the game's
shaders are 8-byte VOP3 encodings, so they were translated as VOP2 writes and lost the high half that
the hardware keeps (about 340 shaders). Found by #78's ps_ops5 on the GPU. Both runners now check
ps_ops5/ps_ops6, run_gpu_tests skips the interpreter-only ps_vcc_x2 (it lost the device), and
test_shader_checks derives its total from check.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 15:27:02 -05:00
725052d731 GPU tests: say which test programs are missing instead of a traceback
check.py and run_gpu_tests.py both died with a FileNotFoundError traceback when vk_compute_test, vk_store_test
or vk_harness was not built, which on Linux happens whenever CMake does not find the Vulkan headers. They now
name the missing programs, how to build them, and the "Vulkan SDK not found" hint, and exit 1.
run_gpu_tests.py checks before translating; check.py checks in run(), which the unit tests mock.
2026-11-21 22:19:13 +02:00
ab35e9a64f Translator: exact wave64 compute and mesh shaders on any subgroup size
Add --wave64-emulate to tools/rdna2spirv.py. A wave64 compute or mesh
shader then uses no subgroup operation: everything a lane needs from the
rest of its wave (votes for s_cbranch_*/SCC, whole-mask words for
s_bcnt1/s_ff1/v_mbcnt, v_readlane, v_readfirstlane, ds_bpermute,
ds_swizzle, v_permlane16/x16) goes through a Workgroup buffer. The
program runs in rounds that end at one OpControlBarrier in uniform
control flow; a cross-lane op cuts its basic block, and the rest runs one
round later, when all 64 lanes have written. s_barrier becomes a
scheduler state, and conflicting memory accesses in one segment are
ordered by a round. This answers #94 and #101 for compute and mesh
shaders: on 32-wide subgroups (NVIDIA) they are now exact, not
approximate.

Two fixes that apply without the flag:
- v_writelane_b32 in cs/ms selects the lane by the wave lane. On a
  32-wide subgroup writes to lanes 32-63 were lost.
- ds_bpermute_b32 in wave64 runs as two wave32s (RDNA ISA 10.4.4): on a
  64-wide subgroup lanes 32-63 read the low half, and an inactive source
  lane now reads 0.

New hand-written GPU tests cs_w64x_* and ms_w64x_ballot pin down the
cross-half semantics. LEONIDA_W64_EMULATE=1 makes build.py,
run_gpu_tests.py and check.py use the flag. Other translator output is
byte-identical.

Tested on NVIDIA GeForce RTX 5070 Laptop (driver 617.42, subgroup 32) and
AMD Radeon 880M (driver 26.11.2 LLPC, subgroup 64):
run_gpu_tests.py 37/37 on both with the flag (RTX 5070 without it: 21/37;
880M without it: 37/37, was 36/37 before the bpermute fix).

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:18:05 +01:00
50efbdb3b5 run_gpu_tests.py: run cs_wavemask like check.py
cs_wavemask had no branch in run_gpu_tests.py, so it was silently left
out. Run it in wavemask mode with --require-wave64 and skip it where the
device has no 64-wide compute subgroup, as check.py and the wave64 dump
tests do since 4c75ce5.

Checked on RTX 5090 (subgroup 32..32): 19/25 passed, 6 skipped, exit 0.
Not checked on a 64-wide (AMD) GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:57:59 +01:00
12ddbc68f3 tests: add ms_clip GPU test and enable shaderClipDistance/shaderCullDistance in vk_harness 2026-11-21 16:57:03 -03:00
4c75ce537a run_gpu_tests: skip the wave64 mask dumps on devices without 64-wide compute subgroups, as check.py does
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 14:51:37 -05: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
4a513f3db2 Merge pull request #62 from Kam471
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-21 13:47:02 -05: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
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
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
e72e13ecfe Vulkan tests: fix AMD vk_store_test bindings, add subgroupSizeControl, add GPU test runner 2026-11-21 10:55:05 -03:00
250e9ffd77 Build: GPU test tools and vk_pipeline_check in CMake; make_game pipelines stage saves a driver pipeline cache
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 22:20:53 -05:00
4f1ff7d85b Replace local drive paths with placeholders
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 15:59:05 -05:00
db0dc8bd5e Initial commit: Leonida, build-it-yourself PC port groundwork
Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V),
asset export via rpf9-explorer's Core (submodule), PE loader and shim
skeleton, and make_game.py, which builds from the user's own copy of the game.
No game data, keys or executables are included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 15:22:16 -05:00