Skip to content

mem_diff: give tbuffer programs a bound V# (the instruction's FORMAT), as 2dfd8d47 requires - #1491

Closed
etcetera-yt wants to merge 1 commit into
ItsNotRexed:mainfrom
etcetera-yt:mem-diff-tbuffer-vsharp-format
Closed

etcetera-yt wants to merge 1 commit into
ItsNotRexed:mainfrom
etcetera-yt:mem-diff-tbuffer-vsharp-format

Conversation

@etcetera-yt

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: new TEST item (claim). No ID assigned yet.

What and why

tests/test_mem_diff.py (CI's stdlib check job runs it directly) fails on main bb2e184:

FAIL: test_every_family_runs_clean (family='buffer_format')
AssertionError: 32 != 0 : ps_mem_00000 (seed 20261122 program 0): export word 0: expected 0x3f2aaaab, translated 0x00000000
	tbuffer_load_format_x v4, v2, s[0:3], 0 format:[BUF_FMT_2_10_10_10_UNORM] offen      (V# word3 0x30000fac)

The first bad commit is 2dfd8d4 (@Vonsek, "suppress MTBUF loads from unbound descriptors", in #1396): c2967a5 OK, 2dfd8d47 FAILED, bb2e184 FAILED. That change is right and measured: on gfx1036, a V# with FORMAT=INVALID reads zeros even for tbuffer_load_format, which takes its format from the instruction.

The stale side is tools/mem_diff.py's generator. Its buffer_format family built every tbuffer V# with only the identity swizzle in word3 (FORMAT 0), so since 2dfd8d4 every tbuffer program reads as unbound (zeros), while the reference still decodes it.

  • tools/mem_diff.py (gen_buffer_format): a tbuffer program's V# word3 now also carries the instruction's format code, as a descriptor bound to that data would have. The reference still decodes from the instruction's format (unchanged), and no RNG draw is added, so seeds pick the same programs.
  • The mem_diff.py docstring and docs/shader_validation.md (the buffer_format paragraph) say why the tbuffer V# carries a format.

What's left: nothing for this failure. Separate, pre-existing (not from 2dfd8d4, not fixed here): with other seeds, a few tbuffer programs that read a channel the format lacks (e.g. tbuffer_load_format_xyzw on 16_16_SNORM, word 2) still differ: the reference repeats the channel (c mod n), the translator gives 0. --seed 7 --programs 300 shows 3 such mismatches on c2967a5, on bb2e184 with this change, and among the 27 on bb2e184 without it. The doc already lists tbuffer's DST_SEL handling as unmeasured. I'll post it as a finding.

Tested

Windows 10 19045, Python 3.14.7 (CPU only; no llvm-mc needed, the fuzzer uses the translator and the semantic interpreter). The machine's GPU is an NVIDIA GeForce RTX 5060 Ti, driver 621.14.

python -I tests/test_mem_diff.py
python -I tools/mem_diff.py --self-test
python -I tools/mem_diff.py --programs 300 --seed 7
c2967a5 main bb2e184 this branch
tests/test_mem_diff.py OK FAILED (32 mismatches, buffer_format) OK (13 tests)
mem_diff.py --programs 300 --seed 7 3 mismatches (pre-existing, above) 27 mismatches 3 mismatches (the same pre-existing ones)
mem_diff.py --self-test canaries: match ok, mismatch detected
  • Negative control: with main's tools/mem_diff.py put back, test_mem_diff.py fails again with the same 32 != 0.
  • The bisect ran tests/test_mem_diff.py on worktrees of 2dfd8d47^ (=c2967a5), 2dfd8d47 and bb2e184.

Not tested: a GPU run of the generated tbuffer programs (that needs llvm-mc, not installed here).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator change.)

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…, as 2dfd8d4 requires

2dfd8d4 (measured on gfx1036) made a V# with FORMAT=INVALID read zeros
even for tbuffer_load_format, which takes its format from the
instruction. mem_diff's buffer_format family built every tbuffer V# with
only the identity swizzle in word3 (FORMAT 0), so all of them now read as
unbound while its reference still decoded them: test_mem_diff.py failed
on main with 32 mismatches. Put the instruction's format in the V# too,
as a descriptor bound to that data would have; the reference keeps
decoding from the instruction's format, and no RNG draw is added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@evilclanker9000

Copy link
Copy Markdown
Contributor

@etcetera-yt, I applied the #1396 differential reference tests to an archive of your head 63a054f, leaving your generator and model unchanged. The 60-case CI seed passed. Two hand-made controls still failed: the reference returned 0x3f2aaaab where an INVALID descriptor returned 0 on hardware, and a bound 32_UINT MTBUF xyzw with zero V# selectors returned [0,0,0,0] instead of [42,0,0,0]. Both pass on #1396 at 95da3ff.

The remaining two-file fix in #1396 covers both the generator and these reference cases. Its bound descriptor deliberately has a different format from the instruction, so confusing those sources is observable. Your docs pointer is helpful; I will update that same paragraph on #1396 with the native channel-order result.

AI-assisted.

@etcetera-yt

Copy link
Copy Markdown
Contributor Author

Thanks @Vonsek, that's a clear check. You're right: my change only fixed the generator, so the reference still decodes an INVALID descriptor and still misses the zero-selector case, both of which your controls catch. #1396 fixes both sides, and its bound descriptor deliberately differs from the instruction's format, which is the better test. I'm closing this in favour of #1396. AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants