Repository navigation
shader_diff: keep integer operands clean when all scratch registers are float-tainted - #3189
frnandoooo wants to merge 1 commit into
Conversation
|
Sound, approve after a trivial rebase.
One conflict: Approve. AI-assisted review, no game files, no GPU. |
|
Rebased onto current main, keeping the upstream parametrized determinism/scalar-observability tests and adding our taint regressions alongside them. The obsolete determinism test is removed. Validation: tests/test_shader_diff.py 20 passed; shader_diff --self-test canaries pass; git diff --check clean. Thanks for the independent review. |
05382a7 to
ef8ddab
Compare
generate_program(random.Random(3179), 150)emitsv_add_nc_u32 v13, v9, v10at body line 70 after all eight scratch registers have been written by floating-point operations. The empty-clean-pool fallback then selects potentially oracle-specific NaN payload bits as integer operands, violating the harness's documented invariant and permitting false differential mismatches.When an integer operation has no clean sources, emit a literal-zero move to its destination before selecting its operands. Float operations retain their existing source selection. The last-writer report still points to the actual generated operation. This adds one move only at the exhausted-pool boundary; generated programs that reach that boundary can change.
Tests check that no integer instruction reads a float-tainted value, seed 3179 actually exercises recovery, last-writer indices remain correct, and generation is deterministic. Seeds 1 and 99 provide additional invariant coverage.
Claim: #3047 (comment) (new TEST item; ID pending).
Separate from open #2412, which makes the scalar copy observable; this PR changes operand selection earlier in the generator and does not depend on that PR.
Validation on Windows, Python 3.14, pytest 9.2.0:
python -m pytest tests/test_shader_diff.py -q: 15 passed.tools/shader_diff.py: seed 3179 fails at the unsafe integer add; seeds 1 and 99 pass. Restoring the fix passes all three.python -I tools/shader_diff.py --self-test: canaries pass.python -m unittest discover -s tests/semantic -q: 4,142 tests run, OK (4 skipped), 464 seconds.python -I make_game.py --help, andgit diff --check: pass.No game files, LLVM, or GPU used. This is a test-generator fix, not a translator semantic change. The reproduced evidence is an operand-taint invariant violation; we do not claim to have measured a real GPU false mismatch.
AI-assisted with Codex (reproduction, implementation, tests) and Claude Code (independent static patch review). Claude found no blockers; its test-comment clarification was incorporated. Its review did not execute tests and is not maintainer approval.