Repository navigation
tests/semantic: fix three mini SPIR-V interpreter correctness bugs - #4802
NethminaYasas wants to merge 7 commits into
Conversation
…e in the mini interpreter GLSL.std.450 UMin/UMax/UClamp take integer vectors and compute per component. The interpreter compared whole tuples, so e.g. UMin((0xffffffff,1),(1,0xffffffff)) returned 0xffffffff in component 1 instead of 1. Signed variants are deliberately left for a follow-up.
OpLoad's result type is the type of the loaded object. A %float PushConstant word was returned as a raw int, so OpFMul rejected it. Decode 32-bit floats while leaving integer loads unchanged.
SPIR-V OpSelect allows a vector of bool conditions; each component selects from the corresponding operand. The interpreter rejected it outright. Scalar behaviour and its error message are unchanged.
|
Tested All 45 tests in I ran the same 45 tests with the interpreter from merge base I also loaded three float push constants and immediately bitcast each one back to an unsigned word. The results exactly match the inputs: AI-assisted. |
|
Tested Command: Result: 45/45 tests OK, including the six new tests ( Red control: AI-assisted (Devin); no game files. |
|
Verified on current main: merges cleanly; tests/semantic/test_interp.py passes 45/45 via unittest discover, and the full semantic sweep (6,251 tests) shows no change versus a main baseline run in the same session — the only reds are the five pre-existing test_loop_ballot_barrier emulate-mode failures, which I re-confirmed on plain main. Vector-bool OpSelect, typed push-constant loads and component-wise UMin/UMax/UClamp all match spec with scalar-path guards included. No supersession — main has not touched the mini interpreter since your base. Checks pending; the sweep above is the CPU verdict. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
thanks @shdann @Atomic258 @memorypressure |
OpConstantComposite vectors are lists in the interpreter. Normalize list or tuple operands in the unsigned vector branch so UMin/UMax/UClamp compute per component for constant vectors and mixed list/tuple operands; the result is a tuple. Scalars and signed variants are unchanged.
OpConstantComposite vectors are lists in the interpreter. Normalize condition and operands with the same helper used by unsigned min/max/clamp, so vector OpSelect works with constant vectors and mixed list/tuple operands. Scalar bool conditions, their checks and error messages are unchanged.
HEADER declares %vout as an Output variable. Include it in OpEntryPoint's interface so the synthetic module is valid for SPIR-V 1.4+; update the exact-string replace in test_inputs_and_push_constants_can_be_seeded and assert the replacement happened.
|
Tested
|
Resolved the OpExtInst hunk by keeping both the unsigned vector branch and upstream's signed integer width validation.
|
Tested
No game files. AI-assisted (Claude Code). |
|
Tested eff6158 merged with main 8575d36 on Linux (WSL2) Python 3.12.16 (-I): pass |
|
thanks @JRamos1993 @kapitche @Atomic258 |
|
Tested
Beyond the PR's own tests, the agent ran a differential harness against an exact reference (Python integers and Two notes from the same agent. A vector ordered comparison used as the select condition ( 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. |
Claimed in the coordination issue as: new TEST item, #4571 (comment)
What and why
Three correctness fixes in the mini SPIR-V interpreter (
tests/semantic/spirv_mini_interp.py), plus one test-header interface correction. They are six separate commits, in the exact order below, so any one can be split out on request:tests/semantic: GLSL unsigned min/max/clamp vectors are component-wise in the mini interpretertests/semantic: typed PushConstant loads in the mini interpretertests/semantic: vector-bool OpSelect in the mini interpretertests/semantic: unsigned vector min/max/clamp accept constant compositestests/semantic: OpSelect accepts constant-composite vector conditionstests/semantic: list the vector output in the test entry-point interfaceThe three fixes are:
UMin((0xffffffff,1), (1,0xffffffff))returned component 1 =0xffffffffinstead of1. A localvector()helper also normalizesOpConstantCompositevectors (stored as lists) and mixed list/tuple operands, and the result is a tuple; CodeRabbit found the constant-composite gap, which is fixed in commit 4. WhenminVal > maxVal, both the vector and scalar branches raiseUnsupportedConstruct(the vector message carries aGLSL.std.450prefix), matching the spec's undefined case — verified by execution. The signed variants and their scalar paths are untouched.OpLoad— a%floatPushConstant word is decoded withbits_f32instead of being returned as a raw int (OpFMulused to reject it); integer loads and f16/f64 loads are unchanged.OpSelect— a vector-of-bool condition selects each component from the matching operand, including constant-composite conditions and operands (CodeRabbit's other finding, fixed in commit 5). Scalar bool conditions still take the scalar branch with unchanged checks and error messages; the only difference on that path is that a list-valued operand is normalized to a tuple before selection. Commit 6 lists the test header's%voutOutput variable in theOpEntryPointinterface so the synthetic module is valid for SPIR-V 1.4+.Tested
CPU-only, hand-written SPIR-V; no GPU or driver, no game files. Based directly on upstream/main
98fa503f, not stacked, noDepends on:. Upstream has since moved to3faac557without touching any file in this PR.python -B -m unittest test_interp -v(fromtests/semantic/): 49 tests OK (41 before this work; four new tests).python -B -m unittest discover -s tests/semantic, same runner for both: upstream/main98fa503f6245 tests, 3 failures, 3 errors, 16 skipped, 1 xfailed; this branch 6255 tests (+10), 3 failures, 3 errors, 16 skipped, 1 xfailed. The failure/error/skip counts are pre-existing and unchanged by this PR. The remaining failures are unrelated to these files:test_nested_divergent_loops_emulate,test_bug4b_loop_carried_split_sgpr_pair_ballot,test_spirv_val_compliance, and threetest_divergent_loop_wave64_emulate_and_native_cscases.python -m pytest tests/test_semantic_translator_use.py -q: 3 passed (no allowlist change).python -m compileall -q make_game.py tools tests: exit 0.OpSelectmakes only that test fail. Restoring the unsigned branch's tuple-only guard fails only the two constant-composite unsigned tests; revertingOpSelectnormalization fails only the two constant-vector select tests. All mutations were restored and none was committed.829af7fdon 2026-11-23; its current heada25e265conflicts inspirv_mini_interp.py(merge aborted). This PR touches the same area as tests/semantic: OpBitCount and the signed GLSL ops at the width of a 64-bit type in both interpreters (TEST-700) #3508; whichever lands second needs a trivial rebase. NoDepends on:line is needed.test_inputs_and_push_constants_can_be_seedednow asserts the entry-point line contains%in, and the test still checks the seeded result0x3FC00100.Out of scope / follow-ups: signed
SMin/SMax/SClampper-component is a follow-up after #3508. Mixed scalar/vector operands and mismatched-length vectors raise raw PythonTypeError/IndexError; they are invalid SPIR-V (GLSL.std.450 requires equal component counts and widths) and out of scope. Older interpreter vector paths (NMin/NMax,FMax/FClamp,Fma) still use tuple-only checks and have the same constant-composite (list) limitation; that broader cleanup is a known follow-up, out of scope here.AI-assisted: yes (OpenCode)
Checklist
docs/design.md, with how it was confirmed. (N/A — no translator rule changed.)