Skip to content

test(semantic): add cubemap projection suite bundle - #5893

Closed
slopgobblercobbler wants to merge 25 commits into
ProjectLeonida:mainfrom
slopgobblercobbler:test/semantic-valu-cubemap-bundle
Closed

slopgobblercobbler wants to merge 25 commits into
ProjectLeonida:mainfrom
slopgobblercobbler:test/semantic-valu-cubemap-bundle

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Collaborator

What

Adds comprehensive translator-backed regression tests and reference mathematical models for Subsystem Feature Bundle 16: VALU Cubemap Coordinates & Projection Suite in tests/semantic/test_valu_cubemap_bundle.py.

Covers all 4 RDNA2 cubemap coordinate projection operations (24 granular commits):

  1. v_cubeid_f32 - Face index selection (0.0 to 5.0) under |Z| >= |Y| >= |X| priority rules
  2. v_cubesc_f32 - S coordinate projection across all 6 cubemap faces
  3. v_cubetc_f32 - T coordinate projection across all 6 cubemap faces
  4. v_cubema_f32 - Major axis magnitude calculation (2 * major_axis) with hardware +0.0 normalization for ±0.0

Each opcode includes:

  • Reference mathematical oracle matching RDNA2 hardware specification
  • Structural AST coordinate projection typing and register allocation validation
  • Deterministic scalar interpreter
  • Multi-lane SIMD divergence and Wave32 / Wave64 EXEC masking
  • IEEE 754 boundary extremes (signed zeros, tied axis priority, face boundary rays)
  • End-to-end SPIR-V assembly translation through tools/rdna2spirv.py via support.translate_lines and MRT0 output verification

Tested

  • Tested with Python 3.9+ (python -I)
  • python -I tests/test_semantic_translator_use.py (Passes translator reachability check)
  • python -I tests/semantic/test_valu_cubemap_bundle.py (All 24 test suites OK)
  • Standard library Python only (unittest, struct, math)
  • Clean merge against upstream/main
  • Strictly zero game data, binaries, or proprietary keys

@memorypressure

Copy link
Copy Markdown

Verified against main 561b65a: merges cleanly, 26/26 pass (re-run), guard green; 7 translate sites, rest oracle, and main's test_valu_cube.py already covers all four v_cube* mnemonics through the translator — oracle/mutation depth rather than new coverage, same note as #5901/#5898. Mnemonics all real. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@BeegSchmooze

Copy link
Copy Markdown
Contributor

Mutation check of the current head with a generic run (tools/semantic_mutants.py --op v_cubeid_f32, #6548; the branch handles all four cube ops): 15 of 15 mutants caught, so the translated cases pin v_cubeid/v_cubesc/v_cubetc/v_cubema as described. Nothing to flag. Windows 11, Python 3.13.

AI-assisted (Claude Code). No game files.

@OlaiFG7

OlaiFG7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Reviewed 1e79815, code read (CPU), AI-assisted: the translator-backed cases overlap tests/semantic/test_valu_cube.py, and the AST / scalar-interpreter / SIMD-divergence classes (WavefrontSimdState, *ScalarInterpreterTests, *SimdDivergenceTests) only exercise a Python re-implementation of the face selection, never the translator, so they cannot catch a translator regression. Suggest keeping only the cases the existing suite does not cover. Ran python -I tests/semantic/test_valu_cubemap_bundle.py: pass (27).

@mralanbourne

Copy link
Copy Markdown

Second check, CPU, Linux (no game files). Run by an agent (Hermes) on mralanbourne's machine; AI-assisted.

Tested 1e79815f0 on CachyOS Linux (kernel 7.3.5), CPython 3.14.10, CPU only: pass. test(semantic): add cubemap projection suite bundle.

On this head, from a worktree: tests/semantic/test_valu_cubemap_bundle.py: OK (27 tests). Not a code review; the author's reasoning was not re-derived.

@BeetjeMatig

Copy link
Copy Markdown

Tested 1e79815 (applied cleanly on main dfe4e4a) on Windows 11, Python 3.14, spirv-tools + llvm-mc from the project toolchain, CPU only (no GPU run): the new tests pass, with the doubts below.

tests/semantic/test_valu_cubemap_bundle.py: Ran 27, OK, 0.8 s (0 failures, 0 errors, 0 skips). The same file also passes on unmodified main. Mutation check in a throwaway copy of main: I flipped the cubesc +X source in the v_cubesc_f32 lowering of tools/rdna2spirv.py (the z-negation select); the file then fails (9 of 27 fail), so it is sensitive to translator bugs in what it covers.

Overlap: tests/semantic/test_valu_cube.py already covers v_cubeid_f32, v_cubesc_f32, v_cubetc_f32 and v_cubema_f32 (all six faces, axis ties, signed-zero and NaN cubema, VOP3 e64 and source modifiers, output modifiers, SGPR/inline operands, dst aliasing, EXEC-mask preservation, a swapped-axes negative control). The +0.0 rule for v_cubema is already pinned there too. What this file adds that is not already tested is small.

Repo rule (tests run the repository's code, not a model of it): about half of the file does not exercise the translator. CubeInstructionAST/Operand (lines 152-185) only checks that a dataclass stores the numbers it was given. WavefrontSimdState with exec_mask (lines 224-252, 346-363, 450-466, 547-562) is a Python lane model that is compared with itself; only the one run_cube_op line at the end of each of those tests touches the translator, and it runs a single lane, so no EXEC divergence is tested despite the names. Several assertEqual(oracle_*(...), literal) lines test select_cube_face against constants, i.e. the test's own model.

Real checks that do look sound: run_cube_op (line 110) goes through translate_lines/mrt0_words, and the expected constants are right per the RDNA2 table (+X sc=-z, -Z sc=-x, -Y tc=-z, ties (1,1,1)->face 4, (-1,-1,-1)->face 5, cubema(-3,1,1)=-6, (2,2,0.5)->+Y, (0.5,2,2)->+Z). Doubt: test_cubetc_zero_y_axis (line 469) says -0.0 -> 0.0 but assertEqual(-0.0, 0.0) cannot see the sign bit; compare the raw word if the sign matters. The pipeline test (line 614) takes its expected values from the in-file select_cube_face model rather than constants.

Suggestion: drop the AST and SimdState classes and the oracle-vs-literal asserts, keep run_cube_op and the pipeline test, and only add cases that test_valu_cube.py lacks.

AI-assisted (Claude Code): ran the new test file and the mutation check on private copies and read the diff against the translator cube ops. No GPU used, nothing was committed or posted from the test machine.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested 1e79815f on Linux, CPython 3.14, CPU only, merged onto main 867d922f: pass, and the tests do check the translator

  • python -m unittest discover -s tests/semantic -p test_valu_cubemap_bundle.py: OK.
  • Mutation: tools/rdna2spirv.py:7390 changed to for t, s in ((ax, x), (ay, z), (az, z)):. Same command: FAILED (failures=17) .

So a wrong lowering of the instruction this file names turns it red. Mutation checks are spot checks, not full coverage.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting.

@isfcrctfs

Copy link
Copy Markdown

checked: #58931e79815 | with: python3.12 -I tests/semantic/test_valu_cubemap_bundle.py | on: Linux, CPython 3.12.16, CPU only, no GPU, no game files | result: PASS, 27/27 tests OK (0.54 s)

Environment: Linux; no GPU (llvmpipe only), no game copy. The Windows build environment is available and was not needed for a one-file Python test change: clang-cl 23.1.5 + lld-link, xwin SDK 10.0.26100, CMake 4.5.1, RelWithDebInfo + BUILD_TESTING=ON, Wine 11.22-staging.

What I ran, on a fresh checkout of GitHub main 5d74c2723 plus this head (git apply -3: clean):

  • python3.12 -I tests/semantic/test_valu_cubemap_bundle.py -> Ran 27 tests, OK, 0.54 s, exit 0. Green before and after the controls below.
  • python3.12 -I scripts/check_no_game_data.py -> exit 0, no matches. git diff --check -> clean.

Controls (a test-only PR, so the control is a translator mutation):

  • Major-axis tie-break >= -> > on the Z test: 1 failure, test_cubeid_tie_breaking (2.0 != 4.0).
  • v_cubema_f32 factor 2.0 -> 1.5: 16 failures. Restored, 27/27 OK.

One correction to an earlier comment: "the AST / scalar-interpreter / SIMD-divergence classes ... never exercise the translator" does not hold mechanically. Instrumenting translate_lines shows 27 of 27 test methods execute the translator (62 translate calls); each of those classes ends with a run_cube_op / translate_lines cross-check. The fair criticism is narrower: several of them assert on the in-file oracle and use the translator only as a trailing cross-check, and test_cubetc_zero_y_axis compares -0.0 with 0.0, so the sign is not pinned.

Import state: not in the maintainers' forge main (tip 1812e0b). tests/semantic/test_valu_cubemap_bundle.py is absent there, and the 400-commit window (91 imported PRs) contains no Upstream PR #5893.

Not run: Windows binaries, any GPU path, retail data.

AI-assisted.

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.

9 participants