Commit Graph

278 Commits

Author SHA1 Message Date
4058dc8970 tests: include gfx1013 encodings in cs_w64x_partial_swizzle disasm fixture 2026-12-01 16:54:10 -06:00
b3cc377020 translator: s_mov copies of EXEC keep the narrowing's tag through SGPR round-trips
Review follow-up on the mask-word gather gate (#1397): `s_mov_b32 s4,
exec_lo` under an unknown EXEC narrowing recorded nothing for s4, so the
later `s_mov_b32 exec_lo, s4` restore minted a fresh ("n", id) tag in
_exec_src_ex. mask_exec_sigs coverage then failed and the read kept this
lane's 0 / ~0 bit, while the equivalent literal `s_mov_b32 exec_lo, -1`
resolved to a constant half-state and gathered — register and literal
restores of the same runtime value disagreed.

_mov_sgpr_vals now returns an ("al", halves) alias for an EXEC source
whose half-state is an unknown narrowing, the same scheme saveexec uses:
exec_lo gives (state, None), exec_hi (None, state), exec gives each half
in its own register for b64 moves. _exec_src_ex already resolves those
aliases, so the restore reproduces the original tag and the gather stays
exact; untracked SGPR sources still mint a fresh narrowing and stay
conservative.

Tests: two semantic cases (wave32 and wave64) assert the register
round-trip gathers OpGroupNonUniformBitwiseOr identically to the literal
-1 restore; cs_exec_copy.asm (+ fixture, check.py/run_gpu_tests.py dump
entries) stores the mask word, exec_lo's own word and the literal-restore
word side by side on real hardware — PASS on RTX 4070 and Radeon
(64-wide), wave64 exec filters 9/9 on AMD.

Co-Authored-By: Devin <noreply@cognition.ai>
2026-11-30 22:22:44 +00:00
f474c74b04 Merge origin/main (f9f3ec4c6) into the carry of #2174
Current main after #2566. New conflict on top of the earlier carry merge:
tools/rdna2spirv.py, _translate (straight-line and CFG paths): main passes
extra=meta_extra to _shader_meta.collect and reads the literal samplers
after it; the PR's g.note_pops_word(insns) runs right after that block,
before fit_shared_memory / needs_barrier_rounds as before.

Co-authored-by: QemmHD <290605352+QemmHD@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:30:43 +01:00
cd5ee11079 rdna2spirv(r9b): unconditional CS/MS LDS bounds, PS EarlyFragmentTests, mesh epilogue & PS quad swizzle
Round 9b translator fixes for rendering correctness and Mandy d3d12/ parity:

1. Unconditional CS & MS LDS OOB bounds (Mandy 21633b328 parity):
   - Record g.lds_declared from PSV0.shared for MS and RSRC2.LDS_SIZE for CS.
   - Whenever g.lds_declared > 0 (opt-out --no-lds-bounds), set
     g.lds_dwords = g.lds_bound = min(g.lds_declared, 16384) so every LDS
     read, write, sub-dword, wide, and atomic op goes through lds_access()
     (OOB reads return 0, OOB writes/atomics dropped instead of wrapping).

2. PS DB_SHADER_CONTROL bit 12 EarlyFragmentTests (Mandy f33940415/bf479a3cd):
   - Add fssm_header.db_shader_control() reading u32 at E + 0x138 (0x24C for
     rec = 0xB0; 3,023/12,101 corpus PS have bit 12 DEPTH_BEFORE_SHADER set).
   - Emit OpExecutionMode %main EarlyFragmentTests (opt-out --no-early-depth)
     and record early_depth in shader_meta when bit 12 is set and the PS does
     not export depth/stencil (no exp mrtz, DB_SHADER_CONTROL & 0x7 == 0, no
     OSG1 SV_Depth*/SV_StencilRef).

3. Defensive mesh epilogue & PS helper-lane quad swizzle:
   - MeshEXT and --mesh-compute epilogues explicitly write CullPrimitiveEXT =
     true (1) and (0, 0, 0) when %mli < %msp and !%ms_has_prim.
   - Lower quad-local ds_swizzle_b32 in PS via OpGroupNonUniformQuadBroadcast /
     OpGroupNonUniformQuadSwap (GroupNonUniformQuad capability) so Vulkan 2x2
     helper invocations participate on AMD RADV while EXEC-masked lanes still
     read 0.

Verified: compileall, check_no_game_data.py, 6,674/6,674 semantic tests (0
failures), 200/200 corpus slice (200/200 spirv-val), plus targeted LDS MS
(5/5), LDS CS (60/60), early-depth PS (120/120), and PS quad-swizzle (50/50)
corpus slices (100% spirv-val). AI-assisted.
2026-11-29 09:25:40 -05:00
173c5d41a6 Merge origin/main into carry/pr-2174
vk_harness: main's has_cap scan of both stages, plus needs_interlock = has_cap(fs_code, 5378) from the PR.

Co-authored-by: QemmHD <290605352+QemmHD@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 13:51:23 +01:00
d88b2deea2 rendering(r5b): promote barrier+write shaders to VulkanMemoryModel with NonPrivatePointer/NonPrivateTexel
Under OpMemoryModel PhysicalStorageBuffer64 GLSL450 (and for plain Aligned PSB loads/stores even under VulkanMemoryModel), OpControlBarrier 0x948 does not invalidate per-CU GL0 vector caches on AMD RADV/ACO (Navi31). Multi-wave workgroups communicating through global buffers across s_barrier (or wave64-emulate ordering barriers) read stale GL0 values across CU0/CU1, corrupting facial-rig compute graph evaluation (collapsing character jaws).

Detect workgroup barriers paired with PhysicalStorageBuffer or storage-image writes+reads (236 shaders, <0.9% of corpus), promote them to VulkanMemoryModel with NonPrivatePointer/NonPrivateTexel and 0x6948 barriers, leave non-writing barrier shaders on GLSL450, document the rule in docs/design.md, and add 9 semantic regression tests.
2026-11-29 06:34:53 -05:00
314b4e73dd Merge upstream ProjectLeonida/mandy main (b589e0fe0) into round10 base
# Conflicts:
#	docs/design.md
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/src/queue_holds.h
#	runtime/src/shader_library.h
#	runtime/src/vulkan_backend.h
#	runtime/src/vulkan_replay.h
#	runtime/test/vk_harness.cpp
#	tests/semantic/test_wave32_lane_select.py
#	tools/lane_masks.py
#	tools/rdna2spirv.py
2026-11-29 06:33:39 -05:00
06e5327291 Merge origin/main into fix/rdna2spirv-f16-interp-computed-ij 2026-11-28 13:59:35 -08:00
66d4723f40 Merge upstream ProjectLeonida/mandy main (d48a957bb) into test/round10
Resolved conflicts in docs/design.md, runtime/CMakeLists.txt, and tests/semantic/spirv_wave_interp.py.
AI-assisted: Antigravity (Gemini 4 Neon).
2026-11-28 07:00:01 -05:00
d48a957bb9 Merge pull request #1692 from GTAVIB4GTAVI/test/fma-nvidia-repro
tests: GPU-free repro of the FMA denormal-product divergence (TEST-FMA-DENORM-PRODUCT)
2026-11-28 12:54:35 +01:00
c8f95e1d0e Merge pull request #762 from whoalin1/test-545-real-oracle
OLD-3011: tests/semantic: run v_div_fixup_f32 through the translator, not a mock oracle (TEST-545)
2026-11-28 12:54:17 +01:00
52b1a73a15 Merge pull request #1761 from potatoe0100/carry/old-9996
OLD-9996: rdna2spirv: lower wide and strided geometry shader LDS accesses
2026-11-28 12:53:25 +01:00
5a59c1e44a Merge pull request #966 from akimfomin/portbridge/paired-lds-data0
rdna2spirv: keep DATA0 for equal paired LDS write offsets (SHADER-LDS-EQUAL-WRITES)
2026-11-28 12:52:12 +01:00
a30e6b101f Merge pull request #338 from NolanCotter/shader-satpk-u8
rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8)
2026-11-28 12:51:16 +01:00
2d62a50a0d tests/semantic: run v_div_fixup_f32 through the translator, not a mock oracle (TEST-545)
tests/semantic/test_valu_div_fixup.py compared a hand-written Python model of the
fixup against itself and never imported tools/rdna2spirv.py, so it passed whatever
the translator did, and its rules had drifted from native RDNA2 (gfx1036) on six
points (NaN priority, the sign of 0/0 and inf/inf, inf(S2), the copysign of the
pass-through, NaN(S0), and the exponent-difference cutoff).

It now translates hand-written listings and asserts what the translator emits: the
pure-integer lowering's op order and classification constants, NaN(S2) above
NaN(S1) read off the dataflow, one word per measured rule through
spirv_mini_interp, and the EXEC-masked and null-destination cases. The f16 model
is gone rather than ported: the translator has no v_div_fixup_f16 lowering yet
(#2477 adds it with its own translator tests).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
2026-11-28 12:03:00 +02:00
25fd8e4776 Merge remote-tracking branch 'origin/main' into fix/rdna2spirv-f16-interp-computed-ij 2026-11-27 23:02:20 -08:00
73fdc2a4c6 rdna2spirv: enable FTZ32/fmulz and per-load NonWritable SMEM with outlined slow paths
Enable DenormFlushToZero 32 alongside DenormPreserve 16 (with --no-ftz32
override and fmulz fusion), add sound per-load NonWritable scalar memory
analysis for descriptor/read-only SMEM loads, and outline wide s_buffer_load
partial-OOB slow paths into shared helper functions.

AI-assisted: Antigravity (Gemini 4 Neon).
2026-11-27 21:13:24 -05:00
de8604c3dc Merge ProjectLeonida/mandy main (431ceba4f) into test/round2
Preserves all Round 1/2/2.1 CPU/GPU runtime optimizations alongside upstream
mandy/main changes, resolves all 10 conflicted files, and fixes arena_window
accounting on retired/dropped title windows.

AI-assisted: Antigravity (Gemini 4 Neon).
2026-11-27 19:57:44 -05:00
00131bb85e main keeps its own runtime, tools and tests; the branch's variants stay on port/d3d12-nvidia
After the merge the tree held this branch's older states of files main maintains. Run against main's code,
tests/test_acphal_abi.py and 11 of the 15 translator tests that differed failed, and the C++ runtime would have
been built from two generations of its sources. So that the merge cannot break what main builds and tests:

- runtime/ is main's, file for file (68 files only this branch had are not carried over);
- every file under tools/, tests/ and docs/ that both sides have is main's (80 files);
- ten translator tests only this branch has, which test rules main's translator does not have, and their
  fixtures are left out.

What main gains: d3d12/ (the Rust D3D12 runtime), its launchers and helpers (Launcher.bat, scripts/play*.ps1,
play-linux.sh, port_ctl.py, smooth-motion.ps1, fetch_vkd3d_proton.py, sync_victory.py), mods/example_lua, eleven
notes under docs/, seven tools and the tests that pass with main's code, the README's sections and credits, and
the "Runtime traps" section of AGENTS.md. Everything left out here is on the branch port/d3d12-nvidia.

Checked: compileall; make_game.py --help; check_no_game_data.py over every file this adds to main; the
line-ending, docs-encoding, CI-registration and docs tests; each test file that differs from main, on its own.
Not run: the whole translator suite, the C++ build, cargo over d3d12/ after the merge (d3d12/ is byte for byte the
branch's), CI.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 17:58:38 -05:00
b87abdef57 Merge mandy's main into port/d3d12-nvidia
Brings the D3D12 runtime branch (d3d12/, its launcher scripts and notes, and the pull requests reviewed and applied
on it) together with mandy's main.

Conflicts (67 files, none under d3d12/): docs/, make_game.py, runtime/, scripts/build_runtime.ps1, tests/ and
tools/. Every one takes main's side: main is where that code is maintained, and this branch's copies were older
states of the same files or the same pull requests in another form. tests/test_fspx_unpack.py is main's too, as it
tests main's tools/fspx_unpack.py. Nothing under d3d12/ is changed by the merge.

Checked before pushing: python -m compileall over make_game.py, tools and tests; make_game.py --help;
scripts/check_no_game_data.py over the files this adds to main; tests/test_text_write_line_endings.py. The
translator suite, the C++ runtime build and CI have not run on the result.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 17:50:37 -05:00
df0c583834 tests: wide scalar loads whose destination is their own V#
A pipeline-library depth reduction loads s_buffer_load_dwordx4 s[20:23], s[20:23]
through a V# read from memory. The wide path loads every dword before it writes a
destination SGPR, and keeps the out-of-range dwords 0 and unread, under every
NUM_RECORDS of both buffers (48 cases), as the translation before the rule does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 08:10:42 -05:00
3d6050b96a Merge pull request #2397 from DadaCap/mesh-prim-index-clamp
rdna2spirv: keep mesh primitive indices below the vertex count (SHADER-MESH-PRIM-INDEX-CLAMP)
2026-11-27 13:10:09 +01:00
74bfb7d070 Merge branch 'test/round2' into tsharp-index 2026-11-27 06:17:53 -05:00
2e54980149 rdna2spirv: multi-dword scalar loads as wide loads with one bound check
s_load_dwordx2/4/8/16 and s_buffer_load_dwordx2/4/8/16 read their dwords as
uvec4 / uvec2 loads instead of one uint each. An s_buffer_load with a
run-time bound checks its last dword once and takes the wide loads; a load
that is partly out of range keeps the per-dword path, so out-of-range dwords
are still 0 and not read. The vectors go through a NonWritable block (SMEM
on RADV) only in modules that write no memory: with the decoration in a
module that stores, RADV ordered the load before the store and
valu_fuzz --family mem read old words in 18 of 600 programs.

Tested: tests/semantic/test_wide_scalar_load.py (new fixture),
SmemHardwareRuleTests, the translator suite, valu_fuzz --family mem on the
Radeon iGPU (600/600, wave32 and wave64), scripts/run_gpu_tests.py on the
iGPU (same results as before), a synthetic GPU program on the RX 7900 XTX
(docs/design.md row).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 05:48:40 -05:00
0513e00b07 rdna2spirv: the 4x8-bit dot products as SPV_KHR_integer_dot_product
v_dot4_i32_i8, v_dot4c_i32_i8, v_dot4_u32_u8 and v_dot4c_u32_u8 become one
OpSDot / OpUDot on the packed bytes plus OpIAdd for the addend, and
OpSDotAccSat / OpUDotAccSat under clamp (both saturate the addend plus the
exact sum, as the hardware does). op_sel halves are put together into one
dword first. RADV did not re-form v_dot4 from the old expansion (four
extracts, multiplies and adds each), which made the FidelityFX upscaler
passes ALU bound.

--integer-dot-fallback keeps the expansion for a device without
shaderIntegerDotProduct (required by Vulkan 1.3): vk_subgroup_info.py
reports integer_dot_product and make_game.py turns the flag on where it is
false. The runtime and vk_pipeline_check enable the feature where the
device has it; the interpreters of the semantic tests run the new ops.

Tested: tests/semantic/test_packed_dot4.py (new fixtures), the translator
suite, tools/dot_diff.py on the four ops, a wave32 GPU program on the
Radeon iGPU (gfx1036) and the RX 7900 XTX against the gfx1036-measured
words, RADV statistics of the upscaler passes (docs/design.md row).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 05:48:33 -05:00
de2ef9e6c7 tests: place VOPC literal in src0 in ps_ij_computed_deriv_fallback.asm for llvm-mc 2026-11-27 02:45:37 -08:00
872a8cf417 descriptors: a heap T# carries its bindless index in dword 6; shaders read it there instead of probing the hash table
On the console a texture access loads the T# and samples. Translated shaders hashed the eight T# words and probed up
to eight slots of the descriptor table for every access: 62 lookups and 19,714 RADV instructions in the tiled-lighting
pixel shader (3,080 in the native program).

The layer now writes the index into dword 6 of every T# in the heaps shaders read, as TAG 0xA [31:28] | storage kind
[27:23] | sampled kind [22:16] | index [15:0] (gfx10_descriptors.h, tsharp_index_word): the console resource heap
copies (fix_console_slot, again whenever the texture at the T#'s address comes, goes or is replaced) and its own
shader-visible heaps (write_image_descriptor, refreshed for bound tables by scan_title_table). The title's bytes and
the T#'s table key keep the title's dword 6.

The translator (tools/descriptor_sources.py, Gen.tsharp_index_sgpr) follows the SGPR dataflow and takes the index from
dword 6, with no lookup, for every T# whose dword 6 it traces to a heap slot (an s_load from a 32-bit descriptor-table
or heap pointer in user data); index 0 unless the word has the tag and dword 3 names an image. Other T#s are looked up
and prefer a tagged word. S#s keep the lookup (sampler heaps are read in place; 40% are literals).

Over the 1.0.2.1 corpus (tools/descriptor_source_census.py) 438,353 of 439,415 T# operands (99.76%) take the word and
17,432 of 17,540 modules keep no T# lookup; no scalar instruction reads dword 5-7 of a heap T#. RADV on an RX 7900 XTX,
lighting shader: instructions 19,714 -> 17,568, latency 73,690 -> 32,458, inverse throughput 16,453 -> 7,468.

Modules record "tsharp_index": "dword6"; the runtime writes the word when the library's modules read it, so packs
translated before keep working as they did. LEONIDA_CONSOLE_HEAP_GPU's pass copies T#s as written, so such a library's
console heaps are fixed on the CPU.

Tests: tests/semantic/test_tsharp_index_word.py (interpreter and dataflow), gfx10_descriptors_test, shader_library_test;
ps_texture_sample and ps_table_fetch now load their T# through a table pointer and vk_texture_test writes the word
(integrated GPU, RADV).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 05:20:52 -05:00
22a8be16cd rdna2spirv: decode only the components a typed load writes; fconst is an OpConstant (SHADER-FORMAT-DECODE-ONE-COMPONENT)
A buffer_load_format_* with a run-time FORMAT called the four per-component
decode functions %fmt_dec_c0..3 at every load, whatever it wrote. One
function %fmt_dec(format, element, component) replaces them, and a load
calls it once per register it writes, with the component that register's
DST_SEL picks: _x makes one call, not four. The function computes the four
components' channel width and offset as before and the parameter selects
one, so the values are the same.

fconst (and tof of a uint constant) emitted a new OpBitcast of the uint
constant at every use; they now give one cached OpConstant %float per bit
pattern, written so spirv-as reads back the same 32 bits (float_literal:
shortest decimal for a finite value, the SPIRV-Tools hex-float spelling for
an infinity or a NaN). The test interpreters read that spelling.

Tests: test_buffer_format_decode_one.py with hand-written fixtures
(calls per load, values for 16 codes, swizzles, out of bounds, _x/_xy
against _xyzw for all 128 codes) and test_fconst_constant.py (exact bits of
+-0, denormals, infinities and NaN payloads).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 08:58:14 +01:00
6f5086f2f8 Merge remote-tracking branch 'origin/main' into fix/rdna2spirv-f16-interp-computed-ij 2026-11-26 15:24:47 -08:00
d48d8b3b0a rdna2spirv: keep mesh primitive indices below the vertex count
A GFX10 mesh epilogue marks a primitive null (bit 31) when an index field
is at or past the vertex count and keeps the field, so a null primitive can
carry indices up to 511. Vulkan leaves such an index undefined even on a
culled primitive. Both mesh finales (MeshEXT and --mesh-compute) now write
index k as null ? 0 : umin(field_k, vertex count - 1), as Mesa clamps them,
and a primitive count of 0 when the vertex count is 0. CullPrimitiveEXT is
unchanged.

Test: test_ms_prim_export.py gains MeshNullPrimitiveClamp with a
hand-written 128-thread wave64 fixture at vertex counts 0, 10, 100 and 128;
it fails on the old translator. docs/design.md moves the Open note into the
mesh primitive export row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr
2026-11-26 20:18:21 +01:00
2d43417d49 Merge pull request #1647 from OreoFR/shader-vopcx-dpp
rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP)
2026-11-26 19:54:03 +01:00
1156672942 rdna2spirv: --address-guard checks every heap_base access against the runtime's page table
Every Gen.host_addr access (buffer, global_, scalar and BVH loads, stores and atomics) calls one
%guard_fn with its sign-extended 48-bit heap offset, kind and span. Below the arena's size it passes
after a compare; elsewhere the 4 KiB pages of its first and last byte are looked up in a two-level
page table (level 1 by offset bits 47..32, level 2 one bit per page). A refused load reads the zero
area, a refused store or atomic the dump area (an atomic returns 0), and the refusal is counted in
the guard header. Without the header's magic every access passes; without the flag the module is
unchanged byte for byte.

tools/address_guard.py is the Python reference of the table and the check. cs_address_guard is the
fixture of the translator test and of scripts/run_address_guard_gpu_test.py, which runs it on a heap
where every address it touches is real memory, so no run can fault.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:07:52 -05:00
a02a5ef7a9 rdna2spirv: no round-loop fallback for single-wave emulated programs
translate() re-translated every emulated wave64 program whose inline
structured form has an OpControlBarrier under a selection or loop as the
round loop (barriers_under_control_flow), for NVIDIA, which hangs on a
barrier only part of the workgroup reaches. A single-wave workgroup
(plan mode inline_all) is one wave: its barriers sit at the top level or
under %pc-only guards, which every invocation takes alike, so the
fallback only applies to multi-wave plans now.

The round form keeps nearly the whole register file live across the
loop and drove RADV/ACO's spiller past 12 GiB (53 GB uncapped) on large
single-wave programs, and made programs with long loops 10-100 times
slower. 666 main-set compute shaders return to the structured form;
translated and spirv-val counts are unchanged.

Restores the single-wave expectations in test_wave64_emulate_opt.py,
test_loop_ballot_barrier.py and test_loop_iteration_guard.py (its round
scheduler check now uses --dispatch-loop), adds
test_wave64_single_wave_barrier.py with a hand-written fixture, and a
docs/design.md contract row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 09:07:28 -05:00
cd8d9aa7a8 rdna2spirv: lower computed I/J barycentrics under --f16-interp-fallback
Lower computed v_interp_p1/p2 (I, J) pairs under --f16-interp-fallback (without --bary-fallback) without PerVertexKHR or a geometry shader by hoisting OpDPdxFine/OpDPdyFine screen-quad barycentric and attribute derivatives into uniform %entry (OpCapability DerivativeControl, guarded by an integer IEEE-754 normal determinant check) and evaluating P_0 + I*P_10 + J*P_20 per site.
2026-11-26 01:57:43 -08:00
2269728203 translator: emulate only tier C wave64 compute and mesh shaders (SHADER-10)
With --wave64-emulate, rdna2spirv.compute_halves now runs tools/wave64_halves.py
on every wave64 CS/MS and keeps the workgroup-memory emulation for tier C. Tiers
A and B run natively, one console half per subgroup:

- the thread index is relabelled from the subgroup (SubgroupId * SubgroupSize +
  SubgroupLocalInvocationId), so a subgroup holds threads 32k..32k+31 whatever
  order the host gives; it feeds v0..v2, a mesh shader's v5 / s3, the lane and
  the mesh export slot;
- an LDS access after a conflicting one of the wave (RAW / WAR / WAW, which the
  console's lockstep ordered with no barrier) and a scalar load after a store
  get a workgroup barrier in front, in blocks every invocation runs;
- with no memory write at all, s_barrier is left out;
- the index entry gets wave64_compute (+ reasons / idioms) and subgroup_size 32.

--wave64-emulate-all keeps the old behaviour (module flag WAVE64_TIERS).

The analysis learns the compute rules (exact lane id, the first lane's wave base
of D + lane, one-half EXEC regions, barrier and memory-order checks, group
size) and, for every stage, forms after VIctory's exact idioms: loads from
uniform addresses, all-or-none masks (s_cselect_b64 exec / 0 and their mixes),
uniform compares under a narrowed EXEC where no running half has it empty,
stale scalars only across a vote edge the read does not depend on, the
s_andn2_wrexec waterfall and loads through the waterfall descriptor.

tests/semantic: test_wave64_compute_tiers.py (fixtures cs_w64_half_local,
cs_w64_lds_swap, ms_w64_skeleton; native modules at 32 and 64 lanes, shuffled
placement, subgroups run one after another; negative controls) and
test_wave64_halves_victory.py; spirv_mini_interp gains OpUDiv / OpUMod and
run_workgroup(subgroup_order=...).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:14:29 -05:00
85fd92001e translator: wave64 VALU lane masks printed in wave32 syntax are SGPR pairs
The corpus listings come from llvm-mc's gfx10 default, wave32, which prints a
wave64 program's VOP3 lane-mask operand as one SGPR: v_cmp_lt_f32_e64 s4, ...
writes s[4:5] on the hardware, the carry-out of v_add_co_u32_e64 s12 likewise,
and v_cndmask_b32_e64 ..., s0 reads s[0:1]. The translator wrote s4 alone, so a
later 64-bit read (s_and_b64 vcc, exec, s[4:5]) gave lanes 32..63 the stale
bits of s5, natively and emulated. 18,439 of the 23,841 wave64 corpus shaders
read such a pair after one of these compares.

widen_wave64_masks turns the SDST of v_cmp*_e64 / v_cmp_class*_e64, the
carry or flag SDST of the VOP3b two-destination ops, the carry-in of the
_co_ci_ forms and the v_cndmask_b32_e64 mask into pairs when the program is
wave64, before the lane-mask analysis reads it.

tests/semantic/test_wave64_mask_pairs.py (fixture wave64_cmp_sgpr_pair.asm):
64 lanes against the ISA's words; 24 lanes are wrong without the rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:08:55 -05:00
15350f6da6 rdna2spirv: seed the POPS collision word so the wait loop ends (SHADER-POPS-COLLISION-SEED)
A pixel shader with an ordered section (POPS) reads the hardware's collision word, which sits in the SGPR after the
user SGPRs and the primitive mask: collision wave id in bits 0-9, this wave's id in bits 16-25, overlap in bit 31.
The program waits until wave_id + ~collision_id is below src_pops_exiting_wave_id + ~collision_id (unsigned). The
translator orders the section with fragment-shader interlock and reads the exiting id as 0, and the word was
whatever the push constants held at that dword, usually 0. With wave id == collision id the test is
0xffffffff < 0xffffffff, never true, so a wave that reached the loop ran it until the loop guard (65,536 rounds).
The overlap test before the loop skips it whenever a lane is on in EXEC, so it is a wave (a host subgroup) with EXEC
all off there; on 32-wide subgroups that is either half of a wave64 program whose lanes are all off.

The SGPR is now the source of the program's wave-id extract (s_bfe_u32 with field 0x000a0010) when the program reads
that SGPR's entry value (shader_meta's user_sgpr_reads), and it is set at entry to 0x00010000 (no overlap, wave id 1,
collision id 0): the loop leaves after one round. A program without that extract keeps the old behaviour.

- tools/rdna2spirv.py: pops_collision_sgpr and the entry store.
- tests/semantic/test_pops_collision_seed.py: subgroups of 64 and 32 lanes, with and without the seed, and the SGPR
  search; the GPU fixture runtime/test/shaders/ps_pops_wait_loop.asm (check.py, run_gpu_tests.py) and its llvm-mc
  listing.
- tests/semantic/spirv_wave_interp.py: the interlock instructions run as no-ops (a run has no other primitive).
- runtime/test/vk_harness.cpp: a fragment shader that needs pixel interlock on a device without it is unsupported
  (77), as for barycentrics.
- docs/design.md, docs/d3d12_vulkan.md: the POPS rows.

GPU: on an RTX 4070 SUPER the fixture gives 4096 of 4096 pixels as expected; with the seed taken out every pixel's
round count is 0x00010000.

Idea from Marvisak/VIctory 7ac1f54, written anew.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
2026-11-25 19:45:31 -05:00
700bb76082 translator: computed EXEC writes (SHADER-1264) and the MIMG tfe status (SHADER-1266)
Four GPU fixtures failed on an RTX 4060 Ti (616.64): the fixtures were in,
the translator half was not.

- A scalar op that reads no lane mask writes a number to exec_lo /
  exec_hi; lane L now takes its bit L mod 32, as a constant does
  (Gen.exec_number_bit). It was tested for non-zero, so s_lshl_b32 /
  s_add_u32 / s_bfm_b32 into exec_lo turned the whole half on:
  cs_w32_exec_computed gave 8192 8192 8192 7682 ..., cs_w64_exec_computed
  8224 8192 16384 16384 .... Bitwise ops that read their operands through
  mask_src are already 0 / ~0 per lane and get no extra code; ops reading a
  lane mask and VALU ops are unchanged. The corpus listings write exec
  halves only with s_mov_b32, s_and/andn2/or/xor_b32 and s_wqm_b32.
- An MIMG read with tfe or lwe returns the fetch status after its data;
  Gen.mimg_status writes 0 there (every texel resident without sparse
  residency), so cs_imgload_tfe and cs_imgload_d16_tfe no longer see the
  1000 they seed it with. No corpus listing uses tfe or lwe.

GPU: all four pass on the RTX 4060 Ti with and without
LEONIDA_W64_EMULATE=1. CPU: tests/semantic/test_exec_computed.py (now with
the wave64 fixture under --wave64-emulate) and the new
tests/semantic/test_mimg_tfe_status.py with the hand-written fixture
image_load_tfe.asm. Contract rows in docs/design.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 18:56:18 -05:00
2edbda73e7 translator: quad reads and helper lanes in pixel shaders, from VIctory
On the console whole-quad mode puts a pixel shader's helper lanes in EXEC.
Vulkan keeps a helper active for quad and derivative operations only;
whether it joins a ballot or a shuffle is the driver's choice. Ported from
VIctory, which runs the title:

- DPP quad_perm, a dpp8 whose every lane reads its own quad, and a
  ds_swizzle that stays in the quad (QUAD_PERM, or masks that keep lane
  bits 2-4) are quad operations in a pixel shader (Gen.quad_read:
  OpGroupNonUniformQuadBroadcast / QuadSwap), the source's EXEC bit too,
  so a helper across a triangle edge is read as on hardware (VIctory
  921d8d3b4). They were subgroup shuffles and a ballot.
- v_readfirstlane_b32 in a pixel shader: an active lane that its own
  ballot leaves out (a helper the driver keeps out) takes its own value,
  so a waterfall loop serves it in the first pass (VIctory 060195536;
  without it such loops spun with only helpers left until DEVICE_HUNG).
  An empty ballot read lane 0 before.
- A pixel's discard keeps the killed lane as a helper for the survivors'
  quad reads (VIctory 77053a0c5): Leonida never ends a lane before the end,
  so this held already; the test pins it.

Vertex, geometry and mesh shaders keep their shuffles (no helpers there,
and quad operations would need quadOperationsInAllStages).

spirv_mini_interp.run_workgroup now runs OpGroupNonUniformQuadBroadcast
and QuadSwap, with `helpers` taking part as Vulkan requires.
test_ds_permute's pixel fixture runs whole quads only (a pixel wave holds
whole quads; a lane missing from its quad is a compute shader's case).

Tests: tests/semantic/test_quad_helper_lanes.py with the hand-written
fixtures quad_helper_reads.asm and discard_keeps_helper.asm, run with
helpers a driver leaves out of ballots, votes and shuffles. Contract rows
in docs/design.md. Not GPU-verified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 18:32:16 -05:00
82489afecf translator: cap loop iterations per entry (--loop-limit), from VIctory
A loop over data the host has not mirrored yet reads zeros and can run
billions of times; VIctory lost the GPU that way and caps every loop at
128 passes in a pixel shader, 256 in a vertex, geometry or mesh shader and
4096 in a compute shader (victory lower.rs LOOP_LIMIT and count_iteration,
commit 15b0091e8; the per-stage values from 570a941e9). Leonida had no cap.

cfg_structure.loop_counters finds the loops of any graph: each strongly
connected region left after the counted edges of the loops around it are
removed, its counted edges the ones into its entries (the back edges of a
natural loop), its resets the blocks outside with an edge in. Every cycle
has a counted edge, so every loop ends. rdna2spirv keeps one Function
variable per loop; every lane of a wave runs the same blocks, so the lanes'
counters agree (one counter per wave). At the cap a branch back takes its
other way out, and a block with no other way leaves the program: %pc = the
end and %done, and a pixel is discarded at the end (%lc_kill, after the
POPS interlock like every exit). A wave that leaves early is counted done
by the barrier rounds and the wave64 emulation rounds, so it holds no
barrier; under --wave64-emulate such blocks count as an early s_endpgm for
plan_structured_emulation and stay out of lane-local folds.

--loop-limit PS,VS,CS sets the limits (or one N; 0 = no cap, and the output
is byte-identical to before: all 102 fixtures, with and without
--wave64-emulate). index.json records loop_limit and capped_loops for every
module with a loop. Contract row "Loop iteration cap" in docs/design.md.

Tests: tests/semantic/test_loop_limit.py with the hand-written fixtures
loop_limit_back.asm, loop_limit_jump.asm and loop_limit_barrier.asm (the
exported count, the discard at the cap, the dispatch-loop form, the vertex
cap, and a two-wave compute shader whose second wave never leaves its loop
while the first passes s_barrier, in native wave32 barrier rounds and under
--wave64-emulate with one and two waves); tests/test_cfg_structure.py
checks loop_counters on 6,000 random graphs. Not GPU-verified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 17:56:20 -05:00
c5f1807515 rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP)
Extend #957's DPP VOPC compare to v_cmpx: the same lane selection, with the
result written to EXEC. v_cmpx prints no destination, so src0 is its first
operand. Only the forms where every lane writes its bit are taken, as for
v_cmp. 78 pipeline-library pixel shaders of 1.0.2.1 were refused for it; all
78 now translate and pass spirv-val.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:36:00 +01:00
d3b67a7040 Merge pull request #711 from aslan2142/semantic-d16-hi-inactive-lane
OLD-7866: restore old upstream PR 7866 - tests/semantic: buffer_load_short_d16_hi keeps both halves in inactive lanes
2026-11-25 23:30:14 +01:00
721a3b85ae Merge main into wave64-partial-wave-zero
Conflict in scripts/run_gpu_tests.py: the dump-test name list gained
cs_w64x_cmp_sdst on main and cs_w64x_partial_swizzle here; both are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:37:20 -05:00
ed94596196 fix: lower wide and strided geometry shader LDS accesses 2026-11-25 11:12:49 +00:00
12f1778678 tests: GPU-free repro of the FMA denormal-product divergence (TEST-FMA-DENORM-PRODUCT)
v_fmamk_f32 with an exact product of -2^-127 and addend 0x00ffffff is 0x00bfffff on RDNA2; an RTX 4070 SUPER
returned the addend (whoalin1, #14 comments 7150696174 (a) and 7152027316 (c)). Nothing pinned that mix:
cs_fma_fused probes rounding on normal products.

tests/semantic/fixtures/ps_fma_denorm_product.asm runs v_fmamk/fmaak/fma/fmac_f32 on push-constant operands.
tests/semantic/test_fma_denorm_product.py (12 tests) pins, per --fma mode:
- glsl: one GLSL.std.450 Fma per op. khr: one OpFmaKHR per op, with FMAKHR and SPV_KHR_fma. exact: no OpFmaKHR,
  every FMul/FAdd/FSub NoContraction (124 for the 4 ops), and its 4 GLSL Fma feed only OpSelect.
- the words under three models of the driver's fused op: fused (0x00bfffff in every mode); flushing a denormal
  product (glsl and khr give the addend, NVIDIA's word; exact keeps 0x00bfffff, also with every f32 denormal
  result flushed); NaN for every finite operand triple (exact unchanged).
Expected words are checked against exact rationals, not against the interpreter. With exact's tiny-product
2^96 scaling disabled in a copy of tools/, 4 subtests fail. spirv-val accepts all three modes.

Semantic suite, same base c7e82e26e, -j 6: A 487 files / 6,279 tests / 0 failed; B 488 / 6,291 / 0 failed.

Test only, no translator change, no game data. The sNaN item of 7152027316 is #1554's. Claim: #1594.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: GTAVIB4GTAVI <GTAVIB4GTAVI@users.noreply.github.com>
2026-11-25 03:22:47 -05:00
2213d5cb8f Merge pull request #1287 from anonymechab-droid/fix/literal-mad-denorm
rdna2spirv: flush literal MAD denormals (SHADER-LITERAL-MAD-DENORM)
2026-11-25 03:38:58 +01:00
5d93aca5e3 Merge pull request #1309 from BadgersMC/fix/lds-wide-fixture
Merging.

**Why merged:** Only lane 0 of the wide-LDS fixture writes, which removes a write race from the test. moffington verified it with GPU-assisted validation.

**Why it's good:** Docs tests pass. It's a fixture-only change.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main b4b7756e8. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests, ctest_registration) gives 578 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main 3ff2a2adc (after #984): no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-24 21:36:38 -05:00
871e4b8b99 Merge pull request #1090 from milk4sale/test-w64-sdst-pair-gpu
tests: a GPU fixture and whole-corpus counts for one-register wave64 mask destinations (TEST-W64-SDST-PAIR-GPU)
2026-11-24 20:50:01 -05:00
39879ce0fd Merge main into RT-PROTON-STORY-LOAD (#984)
Merges main at 1154976d4 into the integration branch at 273b3bdf9 (merge base ece4ba5b3). 42 files conflicted;
this commit is the resolution only. Build and test repairs follow in their own commits.

Rule of resolution: where both sides added different things, both stay; where both made the same change in two
forms, main's reviewed form stays and whatever #984's form did in addition is carried into it; where the two
changed the same code for different purposes, both purposes are kept.

Xbox proxy code (runtime/shims/d3d12_xs_device.cpp, d3d12_xs_device.h, d3d12_xs.cpp, d3d12_xs_alloc_size.h,
d3d12_xs_desc_clean.h, registry.cpp):
- d3d12_xs_device.cpp is #984's file with main's differing pieces ported in: env_slot and the configurable device
  routes, XboxQueueSlotRoutes, PresentationHandler / set_presentation_handler, the console caller rule for device
  slots 61 and 74 (#383, #385), route_xbox_device_slot, slot 81 as GetFrameStatisticsX, create_host_device, the
  console-form rule for slots 25 and 56, the console list IID of #359, and the forms of queue slot 18 (#403) and
  list slot 139 (#396).
- Kept from #984: the list proxy with handle translation, queue slots 16/17 as Signal/Wait, the fence's
  completed-value mirror, the shared FrameTokenSource, PresentX through queue_present_x when no handler is
  attached (slot 30, or 32 on a queue detected as the newer layout), slots 27/53/55/57/70/71/133, the wider
  pc_resource_desc, S_OK for queue slots past the PC table.
- Dropped: #984's GetFrameEventsX and LEONIDA_XS_FRAME_EVENTS_SLOT, its second-word rule for slot 61, its
  undetected-layout rule for queue slot 18, its list IID mapping to GraphicsCommandList6; main's copy of the base
  list proxy, its null-view slot 70 and its refusing slot 133.

Proxy tests (runtime/test/xs_proxy_mock_test.cpp, device_proxy_test.cpp, queue_proxy_test.cpp):
- Checks of both sides, each run once; main's forms of the render-target size and layout checks with #984's extra
  cases added; main's --env-slots-74 and #984's --env-slots-70.
- Adapted to the merged code: the queue tail answers S_OK, slot 73 answers an unknown IID with the list proxy,
  the queue slot 18 case installs a console caller. Dropped: #984's slot 81 GetFrameEventsX cases.

D3D12/Vulkan layer (runtime/shims/d3d12_com.cpp, d3d12_vulkan_device.cpp, runtime/src/command_list.h,
frame_pacer.h, shader_library.h, vulkan_backend.h, vulkan_replay.h, runtime/test/command_list_test.cpp,
d3d12_close_parity_test.cpp, d3d12_execute_indirect_validation_test.cpp, replay_texture_barrier_test.cpp,
vk_pipeline_check.cpp, vk_test_device.h):
- Resource::create_texture: #984's title images (deferred placed, pending streamed, title pool) and main's
  ordinary textures (#1413 shared blocks, #1364 staging fallback) are exclusive branches chosen by the texture's
  origin, so both pools run on disjoint sets of textures.
- frame_pacer.h is main's pacer (#402) with #984's FrameTokenSource as the token counter.
- main's forms kept for ExecuteIndirect (#1066, #377), the barrier into LAYOUT_UNDEFINED (#1055), the B4G4R4A4
  stand-in, per-face stencil masks, the unaligned tile staging (#528) and the device-lost flag (#980).
- shader_library.h: main's block inflate; #984's `bulk` parameter now defaults to true so main's callers keep it.
- Dropped: #984's B8G8R8A8 stand-in for B4G4R4A4 targets, its refusal of separate stencil masks, its zero-count
  refusal in ExecuteIndirect, its wider UNDEFINED -> UNDEFINED release and the test case for it.

Other shims (runtime/shims/dstorage.cpp, file_system.cpp, gameinput.cpp, xgameruntime_offline.cpp,
runtime/test/xgameruntime_offline_test.cpp, xmem_test.cpp):
- ReadFile and DirectStorage reads: #984's pinned kernel_writes read, then main's touch_pages retry on
  ERROR_NOACCESS. main's rt::fs::read_file is folded into #984's read_file.
- gameinput: main's strict LEONIDA_INPUT_SCRIPT parser with #984's rsup/rsdown entries.
- Speech synthesis: main's one silent voice and handle checks; #984's accept-anything form dropped.

Build, tools, docs (runtime/CMakeLists.txt, runtime/cmake/translator_deps.cmake, scripts/build_runtime.ps1,
make_game.py, tools/rdna2spirv.py, shader_disasm.py, shader_ir.py, shader_library.py,
runtime/test/shaders/cs_imgload_tfe.asm, cs_imgload_d16_tfe.asm, docs/README.md, boot.md, d3d12_vulkan.md,
runtime/README.md):
- Unions of the test, target and source lists; spirv_loop_guard.py added to translator_deps.cmake.
- rdna2spirv.py: main's DPP compare rule (#957), SMEM vcc base (#647) and widen_wave64_masks (#1021); #984's
  restore_skipped_instructions and restore_dot4_inline_sel. #984's duplicate widen_wave64_valu_masks dropped.
- shader_disasm.py and shader_ir.py: main's structure with #984's one-line-per-dword llvm-mc input and wave flags.
- shader_library.py: main's structure with #984's --compute-hashes and per-state compute variants.

One file that did not conflict is changed here: tools/rdna2_decode.py. Git kept both sides' decoders for a VOPC
compare with a DPP operand, and #984's narrower one shadowed main's; it is main's file again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 19:38:04 -05:00
89f6c264ed Merge main into test-w64-sdst-pair-gpu
Brings the branch up to date with main 68d1331e5. No conflicts; the merged tree was tested before the push (every standalone
test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since #930).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 16:31:08 -06:00