Commit Graph

5744 Commits

Author SHA1 Message Date
55af930bcc runtime: add public ID3D12GraphicsCommandList8 to the D3D12 proxy
The command list implements the SDK's GCL8 chain (IID ee936ef9-599d-4d28-938e-23c4ad05ce51), so a GCL8 QueryInterface succeeds and slot 81 (byte offset 0x288) is OMSetFrontAndBackStencilRef(UINT, UINT). The method records both values on the list and Reset clears them. Nothing applies them yet: Vulkan's dynamic stencil reference is per face, but only a pipeline that consumes it can, and the layer has no pipeline or draw path. The call is reported once rather than silently dropped.

d3d12_gcl8_test creates only an allocator and a list (no Vulkan device), checks the interface pointer, the raw slot 81 call, both recorded values and the QueryInterface reference count. It runs under CTest.
2026-11-21 20:30:33 +00: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
52e1ac3cd7 Support mipmapped 3D texture transfers on the Vulkan device 2026-11-21 21:24:04 +01:00
2381b53337 Docs: add rest-of-world archive row 2026-11-21 20:21:27 +00:00
d488b0f9e5 Docs: index the new format notes 2026-11-21 20:20:42 +00:00
580aa8e0ff docs/design.md: wave64 emulation row, count on main's skip logic
Without --wave64-emulate the RTX 5070 now skips the wave64 tests (as main
does since 4c75ce5) instead of failing them: 19/37 pass, the rest skip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:19:29 +01:00
1f95634ed4 Docs: measure the audio-config station records and content ids 2026-11-21 20:19:22 +00:00
6ee1904094 Docs: add page-directory, story, audio-station and command-object rows 2026-11-21 20:19:12 +00: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
9fd504ca10 Merge pull request #132 from 0xTehuti 2026-11-21 15:17:51 -05:00
94746381a3 Merge pull request #124 from Kam471
# Conflicts:
#	docs/rpf.md
2026-11-21 15:17:50 -05:00
377a4b9428 Merge pull request #129 from Kam471 2026-11-21 15:17:50 -05:00
3b7c30a75e Merge pull request #133 from Kam471 2026-11-21 15:17:50 -05:00
46a19983fd Merge pull request #134 from Kam471 2026-11-21 15:17:50 -05:00
340f3fa627 Merge pull request #137 from Kam471 2026-11-21 15:17:50 -05:00
9d3743bd47 docs: tighten command-object citations 2026-11-21 20:17:27 +00:00
e4f1d65e93 docs: measured D3D12 command queue/list/fence surface 2026-11-21 20:15:37 +00:00
d2a7fb643b Docs: link the audio-config table from the audio guide 2026-11-21 20:08:08 +00:00
703b344166 Docs: add measured asset rows to the design table 2026-11-21 20:06:19 +00:00
612f1edebd Root signature packer + reconciler + hard-fail (fix the least verifiable part of the layer)
AI-assisted (Muse Spark + explorer fleet).

Implements docs/d3d12_vulkan.md section 3.5 as code: a portable D3D12
root-signature model (1.0/1.1, no d3d12.h) plus a packer that lays root
parameters into the 32 user-SGPR dwords in root-parameter order (constants
take N, views/tables take 2, static samplers take none). Anything that does
not fit - more than 32 user SGPRs (spill layout unknown) or more than the
64-dword D3D12 cost limit - is refused loudly instead of truncated.

tools/root_sig_contract.py reconciles a candidate signature against every
shader's user_sgpr_reads from spirv/index.json (const32 vs constant dwords,
64-bit VAs vs view/table pairs, unpaired-hi detection) and exits nonzero on
the first contradiction; --cluster shows which read-set shapes the game
actually needs.

The RTS0 chunk reader is marked hypothesis until the new Windows oracle
test (synthetic descs serialized by the real d3d12.dll) confirms the layout;
Tier A (model/packer/canonical codec/RTS0 self-consistency/reconciler) runs
everywhere with no game data and no GPU.

Tested: python -m pytest tests/test_root_sig_contract.py (12 passed);
full suite 651 passed, 20 skipped, 1 xfailed; compileall + make_game --help;
portable C++ test 17/17 PASS under g++ -Wall -Wextra -Wpedantic -Werror with
ASan+UBSan; turing atlas on RTX 2060 SUPER (subgroup 32, mesh/bary/m8/heap
true): compute32/ballot64/f16_input/maintenance8 valid, broken_negative
correctly invalid. Windows-only Tier B (oracle + MSVC build) runs in CI.
2026-11-21 17:04:28 -03:00
78af668e01 Tools: report PSIN LRSC and CHKS fields 2026-11-21 20:02:19 +00:00
a9da38faa3 docs: clarify levels sampling fraction 2026-11-21 20:02:00 +00:00
93481aeb47 Docs: add a documentation index 2026-11-21 20:00:03 +00:00
43459b99df docs: extend levels map inventory with second bounded pass 2026-11-21 19:59:23 +00:00
22514404b7 Translator: implement s_ashr_i64, s_bitcmp0/1, s_bcnt0, and s_ff0 with semantic tests 2026-11-21 20:58:23 +01:00
79b3542d1f rdna2spirv: emit ClipDistance/CullDistance (and VS misc) from pos1..pos3 2026-11-21 16:57:01 -03:00
950e599577 Docs: decode the RPF9 0DRP page directory
Measure the 0x60-byte header, the +0x38 table of {hash,size,pointer} resource records, and continuation streams. Correct the +0x60 key claim: it is payload on 29,297 of 29,298 pages. Add a stdlib page indexer with synthetic tests.
2026-11-21 19:56:46 +00:00
0412c8c794 story: avoid implying the flat carve groups nested archives 2026-11-21 19:52:06 +00:00
40a3c595e1 story: state the bounded run stop accurately 2026-11-21 19:50:28 +00:00
cfb5f9a329 story: tighten PSIN header handling and measured field wording
Use the PSIN +4 first-section offset when it points at a known tag, keep the LSCH fallback, and test the header path. Label the RSC8 +8 field as a u32 rather than a proven size, and state that no RSC7 header was found instead of claiming absence.
2026-11-21 19:49:55 +00:00
ec1dbca94f Docs: measure story and minigame archive composition
Index story000, shared_minigame000, and their script/restofworld/bvh4 companions with the fixed carver. Record the measured PSIN section chain, 0DRP page headers, RSC8 v8001 headers, nested RPF9 sub-archives, Bink 2 video and the bounded story000 layout. Add a stdlib story_index.py and synthetic-header tests; no game payload or name is committed.
2026-11-21 19:46:43 +00:00
6dfc0ce82b Merge pull request #119 from Ryx
# Conflicts:
#	README.md
#	runtime/README.md
2026-11-21 14:40:30 -05:00
d3bc937e60 Merge pull request #117 from Kam471 2026-11-21 14:40:14 -05:00
db17179b81 Merge pull request #111 from Kam471 2026-11-21 14:40:14 -05:00
f23605ce73 Merge pull request #110 from Kam471 2026-11-21 14:40:14 -05:00
499606e316 Merge pull request #109 from Kam471 2026-11-21 14:40:14 -05:00
c76aa5cf9a Merge pull request #105 from Kam471 2026-11-21 14:40:14 -05:00
d696ffd7bf Merge pull request #99 from Kam471 2026-11-21 14:40:14 -05:00
8a1d1b1713 Merge pull request #98 from Kam471 2026-11-21 14:40:14 -05:00
59654ca5b7 Merge pull request #97 from Kam471 2026-11-21 14:40:13 -05:00
fb0dfda9c3 Merge pull request #96 from Kam471 2026-11-21 14:40:13 -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
f1dd3c61c5 docs: measure world placement and streaming composition 2026-11-21 19:27:46 +00:00
03a9973f8d Docs: FSSM/RDNA2 cross-check against SCARAB
Adds a fact-level comparison of SCARAB's FSSM, rDNA2 classification and XBSC notes with Leonida's tools, plus a synthetic repro for the duplicate tag-0x0D XBCH loss.
2026-11-21 19:25:36 +00:00
ffd26b0a9f Docs: record the completed s2 shard (10/12, 22,092 modules) 2026-11-21 19:23:35 +00:00
a87d11cacd Tools: index the PSIN metadata container 2026-11-21 19:22:22 +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
83316689c9 docs: note the BVH family is 99.95% of inflated bytes 2026-11-21 19:21:25 +00:00
1681676f5a Docs: measured BVH archive composition
Index the three *_bvh4 RPF9 packs with the fixed carver and record the measured stream/byte composition. Add tools/bvh_index.py for the 0x81020006 header family (tag + 0x140 + 64*n == end), with synthetic tests. No game data, keys or carved payloads are included.
2026-11-21 19:19:53 +00:00