Commit Graph

5744 Commits

Author SHA1 Message Date
6ea07e1b86 docs: correct re-count baseline and mark unmeasured levels geometry
story000_restofworld already recovered its 3 models at 917e9b9, so its delta is 0 and the 917e9b9 baseline is 350,251 models / 159,486 children; the ten-archive delta is +32,530. The levels.rpf fragments/bone-bound/triangles cells have no manifest or harness fields, so they and the totals derived from them are marked not independently reproduced. Add the measured levels.rpf name-pass coverage to world_names.md.
2026-11-22 14:23:37 +00:00
364d9a465a feature_scan: INVALID is modelled; d3d12_vulkan.md answers open question 16
A literal V# word 3 with FORMAT 0 (an unbound descriptor) reads 0 on the
hardware and in the translator, so it is not listed as a format the
translator lacks. Row 16 gets the counts over the 1.0.2.1 corpus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:23:28 +01:00
088447e117 FSPX programs: translated by the shaders stage, found at run time by their kind-6 bytes (RT-99)
The FidelityFX DLL creates its compute pipelines from FSPX programs (docs/fspx.md): through slot 67 with the bare
kind-6 program, then through slot 62 with the DXBC container whose ACCC part holds the payload. Both ended in
E_INVALIDARG: the layer took only FSSM bytecode, the build never translated the DLL and the index had no key for it.

- make_game.py: the shaders stage unpacks the package's DLL with tools/fspx_unpack.py --disasm into
  <work>/shaders/fspx and translates it into <work>/shaders/spirv/fspx, with the same wave64 mode and fallback
  flags. The step is redone as a whole when the DLL, its tools, llvm-mc or the flags change (fspx_build.json,
  written last) and never makes the game's shaders run again.
- tools/shader_meta.py: an entry of a program without an FSSM blob gets fspx_code_sha256, the SHA-256 of
  fspx/<name>.code.
- runtime/src/shader_library.h: the library also loads <dir>/fspx/index.json and finds entries by
  fspx_code_sha256. compute_program() takes an FSSM program as before, the kind-6 bytes of an ACCC container or of a
  bare FSPX payload, and a bare kind-6 program recognized by its prologue; the directory is parsed with the DLL
  reader's rules and bounds-checked, so a malformed one is refused.
- create_compute: looks the program up by the key of its kind and uses those bytes as the code base.
- Tests: shader_library_test (parsing, malformed directories, lookup, the fspx folder), d3d12_fspx_compute_test
  (PSOs from both forms, a dispatch each, refused inputs) and tests/test_fspx_shaders_stage.py.
- Docs: the lookup in docs/fspx.md; slots 62 and 67 in d3d12_command_objects.md and d3d12_vulkan.md. The size the
  slot-67 description carries at +0x30 is kind 6's own size, read from the DLL's code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:22:54 -05:00
9dc08d2596 docs(pt-BR): address quickstart review feedback 2026-11-22 11:22:05 -03: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
8cc972b88b Merge remote-tracking branch 'origin/main' into shader-33-vs-inputs
# Conflicts:
#	runtime/test/shaders/check.py
2026-11-22 15:21:22 +01:00
6b5c01da49 Merge remote-tracking branch 'upstream/main' into d16-rounding-probe
# Conflicts:
#	docs/design.md
#	tools/rdna2spirv.py
2026-11-22 15:19:54 +01:00
174ca0ad9c docs: d3d12_vulkan.md describes erase without cluster compaction 2026-11-22 15:19:12 +01:00
7edd7a187d docs: the Opus length check must read decoded frames, not the granule duration 2026-11-22 14:15:48 +00:00
f61946cfe1 Merge pull request #1795 from AimLogin 2026-11-22 09:15:24 -05: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
625a4f72f4 Merge pull request #1786 from dracbat 2026-11-22 09:15:20 -05:00
46b13320e3 Merge pull request #1783 from Leonardo Guimaraes 2026-11-22 09:15:19 -05:00
963359576d Merge pull request #1774 from Shadman PC
# Conflicts:
#	docs/design.md
#	docs/shader_validation.md
2026-11-22 09:15:16 -05:00
8da1ad785f Merge pull request #1769 from S1m0ne1997 2026-11-22 09:15:12 -05:00
23e8f61274 Merge pull request #1763 from SirAmong
# Conflicts:
#	docs/design.md
2026-11-22 09:15:10 -05:00
2dc3ac3447 Merge pull request #1754 from Jan Trencansky 2026-11-22 09:15:06 -05:00
b78819439f Merge pull request #1753 from Serrambi 2026-11-22 09:15:05 -05:00
12e9e7b08f Merge pull request #1750 from shoal-rat
# Conflicts:
#	docs/design.md
2026-11-22 09:15:04 -05:00
d5b68b77dc Merge pull request #1746 from Youssef Rahmouni
# Conflicts:
#	docs/design.md
2026-11-22 09:15:02 -05:00
445e79b2c7 Merge pull request #1743 from romainveurrier 2026-11-22 09:15:00 -05:00
c0c0e8d98d Merge pull request #1741 from Kam471 2026-11-22 09:14:59 -05:00
da574cb90e Merge pull request #1714 from SWAYAM 2026-11-22 09:14:53 -05:00
52dc48074d tools/imhex: ImHex pattern for PSIN containers
psin.hexpat lays out a container as docs/psin.md describes it: the
big-endian first-section offset, the instance-data block table (rows,
the pppppppp end) and its blocks as raw bytes, the section chain, LSCH
struct headers and members and LENM enums and values (header count by
the fill-exact rule psin_index.py uses), the LSNS block table with
opaque 16-byte records, the LRSC 0DRP version and root block, and the
CHKS file size. A section past the end of a truncated stream is shown
as raw bytes.

tests/test_imhex_patterns.py builds a synthetic container from the
invented schema in test_psin_index.py, checks it with psin_index.parse
and psin_data.block_table, and when ImHex is installed compares the
pattern's output with both, plus a container cut inside LENM.
2026-11-22 11:14:51 -03:00
e74cd75d0b Merge pull request #1686 from Shadman PC 2026-11-22 09:14:50 -05:00
2a30f92d29 Merge pull request #1653 from Felix Croasdale
# Conflicts:
#	docs/testing.md
2026-11-22 09:14:49 -05:00
403104124c Merge pull request #1534 from Kam471 2026-11-22 09:14:46 -05:00
be71c447bb Merge pull request #1449 from Kam471 2026-11-22 09:14:44 -05:00
9c326c2cd4 lds_fuzz.py: exercise ds_permute_b32 collisions and negative control (FUZZ-10) 2026-11-22 11:14:40 -03:00
c2f39447b6 Merge origin/main into m4-synthetic-gate 2026-11-22 15:13:40 +01:00
2123a02506 Runtime: Xbox-ABI proxy for the command allocator (device slot 9)
Device slot 9 (CreateCommandAllocator) now returns an allocator proxy,
the fourth command object after the queue and fence (BUILD-231) and the
list (D3D-136): the public chain (9 slots, Reset at 8) is forwarded, a
slot past it up to the end of a 64-slot table is logged and refused with
E_NOTIMPL, and a read past the table faults in its own guard region. The
console allocator's extra methods are not measured and not guessed.

A list takes the title's allocator in CreateCommandList and Reset, so a
proxy is only safe where the list side resolves it. Slot 9 therefore
wraps an allocator only when it answers kLeonidaCommandAllocatorTag (the
Vulkan layer's CommandAllocator, whose from() resolves the proxy for both
calls); a PC runtime allocator is handed out unchanged, logged once,
until a command-list proxy unwraps it at Reset. Allocator proxies are
unwrapped in the residency calls like heap, queue and fence proxies.
Device slot 12 is not touched.

Tests: allocator_proxy_test (WARP, a hardware adapter, the Vulkan device:
forwarding, refused tail, guard region, identity, D3D12's allocator rules,
a list created and Reset on the proxy with GPU copies through the queue
and fence proxies read back), mock cases for allocators with and without
the tag and their failure paths, and device_proxy_test's slot-9
expectations. No game files.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:11:53 +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
60c624ec9b tools/imhex: ImHex patterns for the RPF9 header and RBF0 records
rpf9.hexpat names the measured header fields (magic, data offset at +4;
the u32s at +8 and +12 unnamed) and shows the rest of the header and the
TOC as one opaque range; it decodes nothing there. rbf0.hexpat follows
the grammar in docs/rbf0.md section 3: 1-byte descriptor index and type,
all record types including 0x50, 8- or 4-byte values from the prologue,
and it stops where the root closes, as rbf0_index.parse_rbf0 does.

tests/test_imhex_patterns.py builds synthetic wide and narrow RBF0
streams and RPF9 headers, checks them with parse_rbf0, and when ImHex
is installed runs each pattern through `imhex --pl format -f json` and
compares the result with the parser's.
2026-11-22 11:07:12 -03:00
6684d836ff Runtime: serve the game's command line and ExitProcess under every import name
The UCRT's _get_narrow_winmain_command_line and _get_wide_winmain_command_line
were not shimmed, so a /MD WinMain executable got gta6rt's own command line as
lpCmdLine. GetCommandLineA/W and ExitProcess were shimmed under kernel32.dll
only, and the loader matches DLL names exactly. Imported from kernelbase.dll, or
from the API sets the umbrella libraries bind them to
(api-ms-win-core-processenvironment-l1-1-0, api-ms-win-core-processthreads-l1-1-0),
they went to the host. The package's vcomp140.dll imports ExitProcess from the
latter.

process_cmdline_test checks every name and the WinMain line.
docs/runtime_imports.md: the dry-run table regenerated at this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:05:53 +00:00
1f32be4f4b Merge remote-tracking branch 'origin/main' into shader-33-vs-inputs
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/test_shader_checks.py
2026-11-22 15:04:48 +01:00
af236e196b d3d12_xs: route slot 67 compute pipeline from native code to CreateComputePipelineState (RT-99)
Xbox device slot 67 takes (desc, riid, out) with IID_ID3D12PipelineState and a console-only
descriptor with the root signature at +0x00 and code blob pointer/size at +0x28/+0x30.
Previously it logged and returned E_NOTIMPL.

Route it to CreateComputePipelineState on the PC device (slot 11) like slot 62, mapping the
console descriptor to D3D12_COMPUTE_PIPELINE_STATE_DESC. On the Vulkan device this resolves
through the translator via fssm_program and ShaderLibrary.

- Implement proxy_create_compute_pipeline_from_native_code in d3d12_xs_device.cpp
- Update device_proxy_test to verify slot 67 thunk, compute PSO creation over WARP, and argument checks
- Update d3d12_compute_test to verify slot 67 compute PSO creation on the Vulkan device
- Update documentation in d3d12_command_objects.md and d3d12_vulkan.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:34:10 +05:30
383c68bb64 fix(translator): round v_fma_mixlo/hi_f16 once to f16 (SHADER-297)
Hardware measurement on RDNA2 (gfx1036, finding 7079901079) confirms that
v_fma_mixlo_f16 / v_fma_mixhi_f16 round the exact fma once, straight to
f16, across all rounding modes (7 of 7 discriminating cases in
tools/fma_mix_probe.py match single rounding). The translator previously
double-rounded in nearest-even mode (f32 Fma then f16 narrow).

Change v_fma_mixlo_f16 / v_fma_mixhi_f16 to use Gen.fma_mix_odd across all
modes, which rounds to odd at f32 so that narrowing to f16 gives the
exact single-rounded result in both nearest-even and toward-zero modes.

Update tests/test_fma_mix_probe.py and docs/shader_validation.md to reflect
the RDNA2 hardware measurement, and add discriminating semantic tests in
tests/semantic/test_valu_fma_mix.py.

AI-assisted.
2026-11-22 20:03:17 +06:00
af0453281d d3d12: support multisampled placed textures (D3D-222) 2026-11-22 15:02:35 +01:00
4763e0f7fc anim_rigs: read the four RIG dictionaries in anim.rpf and resolve the RBF0 rig entries (ASSET-20)
The rig dictionaries share the clip dictionary root; each map value points at +0x20 to a RIG block of
{kind, size, count, word} tables. Their names are the RBF0 sources, and all 6,677 rig-set entries resolve
to a key there. docs/animation.md gets the layout, the counts and the clip-to-skeleton measurement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:59:03 +01:00
689ef6e4b9 Translator: v_fma_mix* reads denormal f32 operands as zero under denorm_mode_32 = 0 (SHADER-298)
Measured on gfx1036 by @Sanonymous01: 0x00000001, 0x807fffff and the integer
inline constants 1 and 64 used as f32 operands read as a zero of their sign.
The operand read in fma_mix_srcs now goes through flush_f32; f16 operands are
unchanged. Six CPU tests (fail without the change). The result flush is not
measured and stays as is.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 08:55:33 -05:00
9fa652f7a2 d16 typed buffer loads round the exact UNORM/SNORM quotient once, as RDNA2 does (BUILD-161)
docs/design.md narrowed the f16 of a typed d16 buffer load from the f32 decode with round to nearest even, and
called that rounding inferred, not measured. tools/d16_format_probe.py measures it through tools/hw_oracle: every
UNORM8, SNORM8, UNORM10, UNORM16 and SNORM16 value through buffer_load_format_d16_x, tbuffer_load_format_d16_x
and buffer_load_format_x, in wave32 and wave64, against several candidate rules, with a 16_FLOAT load, the kept
high half of d16_x and the staged inputs as controls.

On an RX 6700 (gfx1031) the hardware rounds the exact quotient once, straight to f16. Rounding to f32 first is
1 ulp high on exactly four values (UNORM16 0xffaf and 0xffef, SNORM16 0x7ff7 and 0x8009); over every width up to
16 bits only two f32 quotients land on an f16 halfway point (0x3f7ff000, 0x3f7fb000). Gen.d16_norm_f16 takes the
f16 below for those two, for normalized formats only. The f32 (non-d16) result was already right.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:50:45 +01:00
912a6aaf50 rdna2spirv: keep --f16-interp-fallback halves at location 29 and below (SHADER-291)
MoltenVK reports maxVertexOutputComponents = 124 because Metal counts
gl_Position in its 128 vertex-output scalars, and the validation layer
counts it too. With param 0's high halves at location 30, every VS that
exports a param under --f16-interp-fallback (on by default on MoltenVK)
failed VUID-RuntimeSpirv-Location-06272. Move the halves down one
location so the top one is 29 ((29 + 1) * 4 + 4 = 124).

Update the design.md contract row and the semantic test, which now also
checks the boundary (param27 keeps param 0's halves, param28 drops them)
and that no VS output goes above location 29.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:50:07 +08:00
15359fba38 SHADER-137: RDNA2 hardware integer probe and gfx1035 measurements (wave32 & wave64) 2026-11-22 14:47:29 +01:00
17b36d7604 docs: attribute the 26,503 shader result to dcd8ecf, not the 26,501 run 2026-11-22 13:46:18 +00:00
f5b198404e docs/testing.md: one overlay-layer row, with the elevated-terminal cause (TEST-228 follow-up)
#1653's first commit and #1656 both landed, leaving the Known-problems
table with the implicit-layer row twice and two overlapping overlay
rows, and the validation paragraph saying the overlays ignore
VK_LOADER_LAYERS_DISABLE=~implicit~. Per @Rainmaker33's loader log, they
only stay in when the terminal is elevated: the loader ignores
VK_LOADER_LAYERS_DISABLE with administrator rights, while each layer's
disable_environment switch still works, and RTSS adds the STORAGE usage
only while RivaTuner Statistics Server runs. Keep one implicit-layer row
and one overlay row that say so, and correct the paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 07:43:49 -06:00
7ffe3a93b4 Translator: v_dot4_i32_i8 and v_dot4c_i32_i8, confirmed on RDNA2 hardware
The 29 FSPX programs of the upscaler DLL use the two signed-byte dot products 27,271 times, all in 13 programs,
and the translator had neither. The rule: the sum of the four products of the sign-extended bytes of two dwords,
plus the third source (v_dot4_i32_i8) or the destination's old value (v_dot4c_i32_i8), modulo 2^32.

Confirmed on gfx1036 with raw kernels through tools/hw_oracle: 10 operand sets, both instructions, both source
orders of the accumulating one. Two modifiers were measured and are refused: clamp saturates to a signed 32-bit
value, and op_sel 2 with op_sel_hi 5 (the 89 words llvm-mc does not decode) exchanges the 16-bit halves of the
second source. The measured words are the tables of tests/semantic/test_alu_dot4_i8.py.

With tools/fspx_unpack.py on version 1.0.2.1: 17 of the 29 programs translate and pass spirv-val, 13 before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 08:41:38 -05: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