Commit Graph

23 Commits

Author SHA1 Message Date
660872215a Merge branch 'main' of https://github.com/ProjectLeonida/mandy into test/round10
# Conflicts:
#	make_game.py
#	runtime/README.md
#	tools/shader_meta.py
2026-11-28 16:35:38 -05:00
8e353ba863 Merge pull request #2018 from ShotTechOp/fix/shader-meta-operands-lds
shader_meta: handle short v_*_co_ci_u32, SMEM atomics, buffer_load lds, and VGPR swap/rel vscale (SHADER-META-OPERANDS-AND-LDS)
2026-11-28 18:58:39 +01:00
67273351ec rdna2spirv: add coherent VMM, literal sampler SpecId, float image elision, table store, and writes_buffer meta
Emit VulkanMemoryModel NonPrivatePointer/MakePointerVisible/Available for
glc/dlc buffer ops and reads_glc_buffer metadata, specialize literal S#
samplers via OpSpecConstant, elide dead uint/sint image_read_typed paths
when float-only, replace the 77-way buffer_store_format switch with a
compact lookup table, and emit writes_buffer + buffer_write_slots metadata.

AI-assisted: Antigravity (Gemini 4 Neon).
2026-11-27 21:12:04 -05:00
92c174d7b2 shader_meta: fix short v_*_co_ci_u32, SMEM atomics, buffer_load lds, and VGPR swap/rel vscale 2026-11-25 23:44:18 +05:30
e0a8694bef Fold s_min/max_i32, s_bfe_i32, s_sext_i32, and s_pack_* in shader_meta and guard SGPR width 2026-11-25 21:38:59 +08:00
0e776fab62 shader_meta: bound DXBC part offsets and payloads to declared container total 2026-11-23 22:18:32 +01:00
91de0bd7cc Merge pull request #4604 from shdann
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:16:21 -05:00
910c647f35 Merge pull request #4572 from Lucas
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:16:02 -05:00
24f05e5517 Merge pull request #4546 from shdann
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:15:47 -05:00
2b53baf125 shader_meta: reject malformed ISG1 semantic names before publishing inputs 2026-11-22 22:11:32 -05:00
005b230686 shader_meta: fold s_ashr_i32, s_bfm_b32, s_bfe_u32, s_min_u32, s_max_u32 and s_abs_i32 of known constants
_step_state did not fold these scalar operations. Thus a literal S# that
has one dword made with one of them was not in literal_samplers.

The two-source operations fold in _fold_scalar_alu with the values that
the translator computes for immediates: the shift count of s_ashr_i32 is
modulo 32, s_bfm_b32 makes a mask of (width & 31) ones at (offset & 31),
and the field of s_bfe_u32 stops at bit 31. s_abs_i32 of a known constant
is a known constant. A source that is not a known constant gives no
constant, as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 06:05:54 +03:00
d334a939b1 shader_meta: reject incomplete DXBC input signatures 2026-11-22 20:25:23 -06:00
14b51cc7de shader_meta: fold s_not_b32, s_nand_b32, s_nor_b32 and s_xnor_b32 of known constants
_step_state did not fold the inverted scalar logic operations. Thus a
literal S# that has one dword made with one of them (for example
0xFFFFFFFF as s_not_b32 of 0) was not in literal_samplers.

s_not_b32 of a known constant is now a known constant. s_nand_b32,
s_nor_b32 and s_xnor_b32 of two known constants fold together with the
other two-source logic operations. A source that is not a known constant
gives no constant, as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 05:19:25 +03:00
8479d6c0f2 shader_meta: fold s_brev_b32 so a literal S# built with it reaches literal_samplers (SHADER-769) 2026-11-23 01:34:33 +01:00
4c52ce27a6 Seven fixes from an outside contributor (sent as patches, applied without the author's name)
- rdna2spirv: declare each packed vertex input register once; a register whose elements disagree on the component
  type is refused (SHADER-644).
- runtime: a title's VirtualAlloc drops the console's MEM_GRAPHICS / MEM_TITLE type bits the host rejects (RT-217).
- runtime: XPersistentLocalStorageImpl is served from <overlay>\persistent with the package's 2048 MB quota
  (RT-219; layout from the public docs, not measured in a caller).
- runtime: G:\ names the package and T:\ a scratch folder in the overlay; paths under the configured folders and
  every path with no folders configured stay host paths (RT-218).
- winhttp_offline: header blocks and timeouts the host WinHTTP rejects are rejected the same way.
- cfg_structure.run: a limit of zero or less runs no blocks.
- shader_meta: an s_movk_i32 with a register operand and a float immediate beyond float32 are left unknown instead
  of raising.

Each comes with a test that fails on the old code. Conflicts with main resolved here (internal_dir() hides T:'s
folder; both file_system_test blocks kept).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:55:46 -05:00
4c9d224573 shader_meta: classify global_atomic, scalar stores, slist operands, and s_mulk_i32 2026-11-22 14:09:32 -03:00
b75c154b0a Merge pull request #2000 from SweatierKey
# Conflicts:
#	docs/design.md
2026-11-22 10:40:19 -05: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
bda17759e4 rdna2spirv: VCCTuple scalar lists, src_scc, and image_atomic a16 (FSPX) 2026-11-22 16:26:36 +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
1a15a53bf9 shader_meta: classify scalar RMW and v_div_scale dual-dst operands 2026-11-22 12:28:37 +05:30
b7905794d0 shader_ir: preserve VOP3 FP abs/neg modifiers on constant operands
Keep VOP3 FP source modifiers (neg(...), |...|, -|...|, abs(...), and nested combinations) as abs/neg flags on imm and fimm operands instead of applying two's-complement integer negation or folding outer '-' before FAbs, matching LLVM AMDGPUInstPrinter::printOperandAndFPInputMods.

Plain signed numeric literals (-1, -1.0, 0x10) keep their existing dict layout. Also handle -0x... inside modifiers, preserve abs on sext(...), and apply abs then neg in tools/shader_meta.py::_imm_u32.

Verified on CPU with tests/test_shader_ir.py, tests/test_shader_meta.py, tests/test_cpu_ref.py, tools/f32_fuzz.py and the full tests/semantic suite (1,027 tests).
2026-11-22 01:09:48 -04:00
3e6cde78ec Tools: emit D3D12->Vulkan build metadata in spirv/index.json 2026-11-21 15:01:07 -03:00