Skip to content

Accept clipw's second operand without a field, as SCE VCL does. - #2

Open
glampert wants to merge 1 commit into
ps2dev:masterfrom
glampert:fix/clipw-implicit-w
Open

glampert wants to merge 1 commit into
ps2dev:masterfrom
glampert:fix/clipw-implicit-w

Conversation

@glampert

Copy link
Copy Markdown

CLIP/CLIPw/CLIPLw read only the W component of their second operand. Tyra's VU programs use the VCLSML macro library, SCEA's standard macro library for VCL, which uses the bare form clipw.xyz a, b. Testing with SCE's vcl 1.4beta7 (the binary Tyra builds with) confirms that it compiles to the same instruction as clipw.xyz a, b[w] (clipw.xyz VF01xyz,VF01w), and that it also accepts clipw a, b as .xyz. openvcl required the explicit [w] and failed with "Invalid argument", so 9 of Tyra's 15 VU1 programs did not compile. I've confirmed this with vcl 1.4beta7, from Tyra's repo (CI run).

With this change, the wcomp operand modifier now treats a missing field as W, so the bare form emits exactly the same instruction as [w]. Any other field is still rejected; dvp-as refuses those too (with "bad instruction").

  • New test/integration/test_clip_implicit_w.cpp: the bare and [w] forms produce identical output, clipw a, b also works, and [x] is rejected.
  • The full test suite passes. Also tested across 38 other VU programs (all ps2gl VU sources, Quake II and Tyra), the output is byte-identical.

CLIP/CLIPw/CLIPLw read only the W component of their second operand.
VCLSML, SCEA's standard macro library for VCL, uses the bare form
`clipw.xyz a, b` in its PerformClipCheck macro, and 9 of the Tyra
engine's 15 VU1 programs use that macro:
https://github.com/h4570/tyra/blob/c59f406af134713b62656114846ac8d588c6247c/engine/src/renderer/3d/pipeline/shared/vcl_sml.i#L1393-L1398

Testing with SCE's vcl 1.4beta7 (the binary Tyra builds with) confirms
that it compiles the bare form to the same instruction as
`clipw.xyz a, b[w]` (`clipw.xyz VF01xyz,VF01w`), and that it also
accepts `clipw a, b` as `.xyz`. openvcl required the explicit [w] and
failed with "Invalid argument", so those 9 programs did not compile.

The 'wcomp' template modifier now defaults a missing field to W, so the
bare form emits exactly what [w] emits. Any other field is still
rejected, as vcl 1.4beta7 ("instruction and operand have mismatching
field select") and dvp-as ("bad instruction") both reject it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@glampert
glampert force-pushed the fix/clipw-implicit-w branch from 67d3496 to e184e74 Compare October 16, 2026 06:50
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.

1 participant