Commit Graph

38 Commits

Author SHA1 Message Date
eb1cf5e96e rendering(r3): fix Blob A CB_TARGET_MASK (+0xcc), depth bias, T# bugs 1A-1D, OMSetDepthBounds replay, and stage-link polish 2026-11-29 06:34:13 -05:00
d09286f624 rdna2spirv: translate only the measured dot4 op_sel forms; keep restore_dot4_inline_sel
The general rule from #1495 (dot4_op_sel_fields / restore_dot4_op_sel,
ported from luizwidmer/palmetto) took the stored op_sel/op_sel_hi of any
v_dot4_i32_i8 that llvm-mc printed with the defaults. That translated
op_sel 0 / op_sel_hi 5 with a VGPR second source, a word #1317's
test_fspx_dot4_op_sel_disasm.py (case (0, 5)) requires to stay refused:
only op_sel 2 / op_sel_hi 5 was measured on gfx1036. The translator suite
failed there.

Resolve it on the measured side:
- drop dot4_op_sel_fields and restore_dot4_op_sel;
- keep main's restore_dot4_inline_sel (#984) and its three call sites:
  the clean-listing check, the forward re-anchor search, and the exact
  re-anchor window #1662 added today. The general rule does not cover
  only those cases, so it cannot replace them;
- tests/semantic/test_dot4_printed_op_sel.py now checks that the
  inline-integer form is restored in a clean listing and on re-anchoring,
  and that op_sel_hi 5 with a VGPR S1, op_sel 1 / op_sel_hi 6,
  op_sel_hi 4 and a non-default S2 half stay refused;
- docs/design.md "Signed-byte dot products" states how each form was
  confirmed (hardware for op_sel 2 / op_sel_hi 5, a corpus count for the
  inline-integer form, refused otherwise); docs/fspx.md follows.

This also settles the #1662 / #1862 overlap: #1662's call site stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:53:14 -05:00
95d1878dc3 fspx_unpack: keep main's literal-form check for the 24-byte prologue (#583 head)
The copy of #583 in this branch replaced main's check that both short
prologue words are literal-bearing VOP3 opcode-0x180 words
(words[k+1] & 0xFFFE0100 == 0x03FE0100, the shape fspx_prologue_probe.py
checks) with a looser SRC2 == 0xff test. Keep main's check, as #583's head
(3af97a1ec, by Tyrannys) does, with this branch's named constants, and take
that head's test_short_prologue (the stricter check refuses 0x03FF0000)
and its docs/fspx.md paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:51:22 -05:00
1c5aa29a36 Merge branch 'integration/translator-fixes' into local/boot-combined
# Conflicts:
#	runtime/src/main.cpp
2026-11-25 16:06:19 -05:00
71a769d7d8 Merge pull request #1691 from OreoFR/rt-slot57-depth-raster
d3d12_xs: depth, stencil and raster state for slot 57 native pipelines from state blob A (RT-SLOT57-DEPTH-RASTER)
2026-11-25 14:55:52 +01:00
b19b00e88a Merge branch 'rt-slot57-blend-state' into rt-dual-source-blend
# Conflicts:
#	docs/fspx.md
2026-11-25 13:01:26 +01:00
7a769396d9 Merge branch 'rt-slot57-blend-state' into rt-slot57-depth-raster
# Conflicts:
#	runtime/CMakeLists.txt
2026-11-25 13:01:25 +01:00
668d65b4b9 d3d12_xs: slot 57 retries only a pipeline that blends a B4G4R4A4 stand-in (RT-SLOT57-BLEND-STATE review)
adrianmjim's review: the blend fallback ran on any E_NOTIMPL, which also stands for
refusals unrelated to blending (stream_unsupported, mesh limits, FullyCovered, and
#1703's dual-source refusal). Such a pipeline was retried with blending off, logged as
a blend refusal, and, if the retry succeeded, drew without the blend the title asked for.

Now only a pipeline with a blended B4G4R4A4 target is retried, with blending off on
those targets alone (without_stand_in_blend, its own header), and the line is printed
only when that retry succeeds. The "every target" step is gone: no real boot used it
(RTX 4070 Laptop and kawaii-shakal's RTX 5070 Ti only ever logged the B4G4R4A4 step).
native_pso_fallback_test covers the decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 13:00:57 +01:00
f0e776adfb docs: STENCILTESTVAL and depth-bias counts for RT-SLOT57-DEPTH-RASTER (review)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 11:08:31 +01:00
d763845349 d3d12: dual-source blending reads SV_Target1 at Location 0, Index 1 (RT-DUAL-SOURCE-BLEND)
A PSO whose blend state uses a SRC1 factor gets its fragment module's Location 1
colour output moved to Location 0 with Index 1, as Vulkan takes the second
source. Slot 57 native PSOs now map the SRC1 factors of state blob A.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:37:42 +01:00
69ddea6803 docs: state blob A's depth, stencil and raster registers (RT-SLOT57-DEPTH-RASTER)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:19:16 +01:00
81f33de1cd docs: the stand-in-target fallback of RT-SLOT57-BLEND-STATE
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:19:00 +01:00
4e7b764dbc d3d12_xs: integer render targets keep blending off in slot 57 native PSOs (RT-SLOT57-BLEND-STATE)
A library pipeline enables MAX on an R8_UINT target; the colour block bypasses
blending there, and D3D12 refuses the PSO.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:02:38 +01:00
2f44380590 docs: state blob A's colour-target registers, measured over the library (RT-SLOT57-BLEND-STATE)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 08:41:48 +01:00
f0611b752f Remove the title's executable addresses #984 brought in; read them from the environment
#984 (273b3bdf9) put RVAs and file offsets of the retail executable into code, docs and scripts.
The code paths that need one now read it from an environment variable and are off when it is
unset; the docs and examples say the location is measured locally.

- runtime/src/main.cpp: the hang-watchdog kick takes its trap and kick RVAs from
  LEONIDA_TITLE_WATCHDOG_KICK="<trap RVA>,<kick RVA>" (hex), still only when the trap
  instruction is at the first one. Unset, the watchdog stays armed, as before by default;
  LEONIDA_TITLE_WATCHDOG=1 keeps it armed, and LEONIDA_TITLE_WATCHDOG=0 without the RVAs says
  once that it needs them. The LEONIDA_PEEK example uses placeholders.
- runtime/shims/startup_trace.h: the transient-pool dump fires at the int3 that
  LEONIDA_POOL_DIAG_AT names (`<module>+0x<offset>`, as the trace prints it), off when unset.
- scripts/windows-boot/boot.ps1: LEONIDA_PEEK's default comes from LEONIDA_GAME_STATE_RVA and
  LEONIDA_SESSION_STATE_RVA (no peek when unset), and the RESULT digest matches those values;
  the examples and README use placeholders.
- runtime/README.md documents LEONIDA_TITLE_WATCHDOG_KICK and LEONIDA_POOL_DIAG_AT.
- docs/fspx.md, docs/d3d12_vulkan.md, docs/movies.md, docs/embedded_shaders.md and a comment in
  runtime/shims/d3d12_xs_alloc_size.h drop the addresses and offsets.

This follows the same change on the earlier integration branch (#1495).
2026-11-25 01:00:37 -05:00
62d8f38ae9 rdna2spirv: a v_dot4_i32_i8 printed with default op_sel takes the stored fields
llvm-mc decodes a VOP3P v_dot4_i32_i8 whose op_sel_hi is not [1,1,1] (op_sel bit 1 clear) but
prints and re-encodes it with op_sel 0 / op_sel_hi 7, so translate() refused it as a dropped
field. When those two fields are the only difference between the stored and the printed bytes,
they are now read from the blob, in check_printed_encodings and in both re-anchoring paths, and
the v_dot4_i32_i8 rule applies them as measured on gfx1036 (a non-default S2 half stays
refused). Any other difference is still refused.

This replaces #984's restore_dot4_inline_sel, which took one case of the same form (op_sel_hi
[1,0,1] with an inline integer S1); that case is covered by the general check. The words llvm-mc
rejects (op_sel 2 / op_sel_hi 5) are printed by shader_disasm.py (#1317) and recovered from the
blob by skipped_form. The approach comes from luizwidmer/palmetto (GPL-3.0).

Test: tests/semantic/test_dot4_printed_op_sel.py, hand-built words; design.md contract row and
docs/fspx.md updated.
2026-11-25 00:51:57 -05:00
f7b4aa7ee2 Merge #1317 (print the v_dot4_i32_i8 op_sel words llvm-mc rejects)
# Conflicts:
#	docs/fspx.md
#	tests/semantic/test_alu_dot4_i8.py
2026-11-25 00:44:37 -05:00
156a056b85 Merge #583 (FSPX short prologue)
# Conflicts:
#	tools/fspx_unpack.py
#	tools/shader_library.py
2026-11-25 00:43:28 -05:00
4e1ca11a65 fix: shader_disasm prints the v_dot4_i32_i8 op_sel 2 / op_sel_hi 5 words llvm-mc rejects, so the FSR4 FSPX programs translate
The FidelityFX upscaler programs hold 89 such words in 8 programs (docs/fspx.md); the translator already models the form but the listing could not carry it, so the programs were refused as a fall-through into undecodable words.
2026-11-24 16:47:02 -05:00
273b3bdf9d [integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD)
One squashed commit of a fork that was developed on a Linux/Proton machine and
tested on two native Windows machines. On all of them the retail 1.0.2.1
package now launches, shows its launch movie, first-run pages and landing
prompt, runs the story load to its end with the loading slideshow drawing its
artwork, and enters the world phase. A first world frame is not verified yet.
docs/linux_proton.md has the setup, a healthy boot's timeline, the machines
and where it stops.

Runtime: frames in the title's own window; DirectStorage pinned reads,
page-list scatter/gather, BCPack and unshuffle with a locally generated
predictor file; pooled, device-local and deferred image backing for streamed
and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table
that degrades instead of refusing a submission; a descriptor hash finalizer
(off until a library carries it); directly indexed heap offsets for compute
dispatches and VS/PS/GS draws; title buffer windows outside a fragmented
arena; opt-in device-local copies of streamed buffer views; write-fault
retries under the tracker lock, shared trackers and write-watched title memory
for native Windows; device-loss, compute-input and memory probes.

Translator: loop bounds at structured exits, the eight FidelityFX programs
that use a packed-dot form the disassembler skips, buffer bounds modes per
view kind, a compaction option, the hash finalizer option.

Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows
boot script, the paired compute translation script.

No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted
by people on the machines named in docs/linux_proton.md.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 11:42:12 -06:00
4b9a89124a fspx_unpack: code_range takes the 24-byte prologue of some pipeline-library programs
50 of the 2,684 library programs in shaders.rpf (1.0.2.1) start with two VOP3
opcode-0x180 words (words 0 and 3) instead of three, and their code starts at
word 6. code_range only knew the 36-byte form, so it disassembled them from
word 0 and they never decoded: 1 of the 50 translated. With the 24-byte form
all 50 disassemble with 0 invalid words and 49 translate and pass spirv-val.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 03:08:08 -06:00
ee2b087b66 shaders: add library_shaders build stage and guard NONE compute states
Add the build-side pipeline-library translation stage to make_game.py on top of the .state emission already merged in tools/shader_library.py, and fix a TypeError when a compute pipeline record has a NONE (0xFFFFFFFF) state index.

- tools/shader_library.py: filter NONE program/state indices when building cs_state so records without a state blob do not crash with TypeError.
- make_game.py: add LIBRARY_ARCHIVE, LIBRARY_TOOLS, library_settings(), and library_shaders() to the shaders() stage (unpacking cs programs with --disasm and --carve, translating via rdna2spirv.py, validating fspx_key_clash against non-dict/unreadable indexes, cleaning stale unpacked artifacts, and writing library_build.json).
- docs/fspx.md, docs/shader_library.md: document library_shaders(), .state emission, and runtime loading of library/index.json.
- tests/test_shader_library.py, tests/test_library_shaders_stage.py: add NONE-state cleanup and shared-code/distinct-state regression tests plus full stage reuse, invalidation, stale-artifact cleanup, clash, malformed-index, and real-tool tests.
2026-11-23 20:38:06 -05:00
b08703f7a8 Merge pull request #4595 from tedin7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/design.md
2026-11-22 23:16:15 -05:00
c222ed991f Merge pull request #4044 from Jan Trencansky
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/fspx.md
2026-11-22 23:10:45 -05:00
2e3fd36d79 Merge pull request #3951 from Jan Trencansky
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-22 23:09:52 -05:00
5b82eba5bd Merge pull request #3884 from justr4mzi
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:12 -05:00
18f0b74a6a rdna2spirv: the code ends at the range the listing header declares, so undecodable words after the last printed instruction are caught too (review: Flyander); fspx.md: measured 20/29 2026-11-23 04:22:44 +01:00
3468d024d1 docs: a fall-through into undecodable words is refused (SHADER-813) 2026-11-23 03:54:38 +01:00
a6f9bc4b24 slot 67: the description pinned from the DLL's code, a test built the DLL's way, every failed call logged
A tester on #3951 saw a slot-67 lookup miss with the real FidelityFX DLL where the base build had none, and read it as
the proxy taking one program's kind 6 with another program's kind 0.

Pinned from the DLL's code and run on all 29 payloads: its FSPX reader (0x1a20) and the same loop inline for a
container store kinds 0, 1, 6 and 7 in four pairs from one payload, and the pipeline function copies them to +0x08,
+0x18, +0x28 (the kind-6 copy, with kind 6's own size at +0x30) and +0x38 of the description. That is the layout the
proxy reads, and code and state of one call always come from the same program. A harness that maps the DLL without
running it, calls its reader on each payload and builds the description that way resolves every translated program
to its own entry through slot 67 on the Vulkan device (26 of 29 on main aa2988cc; the other 3 are refused), on
llvmpipe, the integrated GPU and the RX 7900 XTX.

So the proxy does not mix programs. What fits the report: with slot 11 answered, the DLL goes on to its next pipeline,
which that translation (20 of 29) does not have; only the first call of a slot is announced, so the miss read as the
first call's.

- d3d12_xs_device.cpp: every failed slot-67 call is logged with its number and the four sizes.
- d3d12_fspx_compute_test: dll_slot67 builds the description from a container's own directory the way the DLL does
  (reader pair order, pointers into the payload, kind 6 copied into a 256-rounded buffer padded with 0xcc); each
  program resolves to its own translation with its own state. A proxy that read kind 0 from +0x18 or kind 6 with
  the rounded size fails the test.
- docs/fspx.md, d3d12_command_objects.md, d3d12_vulkan.md: how the layout was pinned, and what happens when a later
  program is not translated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:54:26 -05:00
108e07fce4 rdna2spirv: an FSPX program's wave size comes from its dispatch state
A program with no FSSM sidecar got its wave size from the code heuristic, which also counts any _b64 op on vcc or
exec as wave64. The FidelityFX DLL's wave32 programs move vcc as an ordinary SGPR pair with s_mov_b64, so three of
them were translated as wave64, and one wave64 program with no marker as wave32 (4 of the 26 translated on main
aa2988cc).

- The wave size of an FSPX program is now the `wave32` field fspx_unpack.py writes from kind 0 word 4 bit 20, as the
  FSSM header's flag is for the game's shaders. Only the strict markers contradict it (WAVE64_RE against wave32,
  WAVE32_RE against wave64) and refuse the translation; without the field the heuristic stays. Nothing changes for
  a shader with an FSSM sidecar.
- Evidence for the bit, over the 29 programs: strict markers never contradict it, the RSRC1 VGPR granule fits it in
  all 21 programs that decode cleanly, and PSV0's lane counts agree in all 5 that state one (docs/fspx.md).
- tests/semantic/test_fspx_wave_size.py: the rule and its refusals with hand-written listings, and a
  v_readlane_b32 whose result differs between the two wave sizes.
- docs/fspx.md (kind 0 word 4, the evidence, translation status) and the wave-size row of docs/design.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:43:14 -05:00
34c130c36c docs: slot 67 passes the dispatch state on; what pipeline slot 11 does with 0, measured (RT-99)
- d3d12_command_objects.md section 3.5a: slot 67 now passes all four pairs; for slot 11, what the DLL does on failure
  and with 0 (measured in its code), the object's shape, why no program needs a scratch size (measured over the 29),
  what is implemented and what stays open.
- fspx.md: the slot-67 payload and its checks, and slot 11.
- d3d12_vulkan.md and runtime/README.md: the new parts of d3d12_fspx_compute_test; the DLL's own dispatch was not run
  here (fsr_dispatch_test needs MSVC structured exception handling).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:26:34 -05:00
b7b4ec7cbc docs: fspx.md translation status on current main, 27 of 29
Measured on main aa2988cc with the v_fma_mix literal repair: 27 of the 29 programs
translate and pass spirv-val (26 without it), and the other 2 stop at the
v_dot4_i32_i8 word llvm-mc does not decode.
2026-11-22 23:16:52 +01:00
bf166316ab fspx: verify 36-byte prologue is a hardware no-op on RDNA2 (TEST-849) 2026-11-22 23:15:24 +01:00
6a16ac1436 FSPX lookup: a kind-0 state key next to the code key; ambiguous programs are refused (RT-99 review)
Review on #1911: two containers with the same kind-6 program and different kind-0 entries (32x1x1 and 64x1x1)
translate to different modules but got the same fspx_code_sha256, so both resolved to the same pipeline.

- tools/fspx_unpack.py writes the kind-0 entry as fspx/<name>.state; tools/shader_meta.py records its SHA-256 as
  fspx_state_sha256 next to fspx_code_sha256.
- make_game.py: entries with the same code and state keys must have identical modules, otherwise the FSPX step fails
  naming both programs and drops the index. The same code key with other state keys is allowed.
- runtime: a container or bare payload (kinds 0 and 6 present) matches the code key and then the state key; no match
  is E_INVALIDARG. A bare kind-6 program (slot 67, no kind 0) takes the code key's entries when their modules are
  identical, and is refused with E_INVALIDARG and an "ambiguous" log line when they differ.
- Tests: the review case in tests/test_fspx_shaders_stage.py, shader_library_test and d3d12_fspx_compute_test.
- docs/fspx.md: the two keys and the ambiguous case.

On 1.0.2.1 the 29 kind-6 programs are distinct, so nothing resolved wrongly before: 17 translated entries, 17
distinct code keys, 17 distinct (code, state) pairs, all 17 found from the container and from the bare program.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:28:07 -05:00
7886972a6b Merge upstream main
# Conflicts:
#	docs/d3d12_command_objects.md
2026-11-22 09:48:41 -05: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
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
07918ddae6 docs: fspx.md, the FSPX format and what translates
The directory as the DLL's reader (RVA 0x1a20) and pipeline function
(RVA 0x4aa0) use it, with device slot 67's descriptor; kind 0 field by
field, each with how far it was checked (thread-group size measured
against PSV0 in 29/29; wave size, RSRC1 and RSRC2 inferred from the code);
the 36-byte prologue carrying kind 7's hash (29/29); why --mcpu gfx1030;
the 89 VOP3P words llvm-mc rejects; and the per-program translation
status: 13 of 29 translate and pass spirv-val, the 13 that use dot4 do not.
2026-11-22 13:42:04 +01:00