Skip to content

rust: port graphics/matrix3.c to obs-graphics - #177

Merged
zackees merged 3 commits into
obs-rust:masterfrom
nathan-v:port/matrix3
Oct 11, 2026
Merged

zackees merged 3 commits into
obs-rust:masterfrom
nathan-v:port/matrix3

Conversation

@nathan-v

Copy link
Copy Markdown
Contributor

Fixes #149

What and why

Ports the 11 exported functions in libobs/graphics/matrix3.c to obs-graphics. Header-inline helpers stay in the C header. matrix3_inv follows matrix4_inv's cofactor inverse, including the 0.0005 determinant cutoff: a rejected determinant leaves dst unchanged except t.w = 0. matrix4.c itself stays C. matrix3_transpose matches the SSE shuffles, so every axis w lane becomes the source z.w.

No intentional numeric differences.

Issue #149 asks for the characterization as its own PR. That work is the first commit (01837125a) and contains no Rust. The port commits follow it in this PR so the new cmocka test and the ENABLE_RUST_LIBOBS swap are reviewed together.

RED → GREEN

  • Characterization: 01837125a adds test/cmocka/test_matrix3.c only.
  • RED commit: 62969abfa. soldr cargo test -p obs-graphics --test matrix3 failed 13/13, each with not yet implemented from the todo!() core.
  • GREEN: 22c094a7a. soldr cargo test --workspace --locked passed, including the Tier 1 mirror of the cmocka tests, the layout test, Tier 3 parity (256 random bit patterns, plus mul with dst == m2 and aliased inv), and export_list. soldr cargo clippy -p obs-graphics -p obs-util --all-targets --locked -- -D warnings passed.
  • Mutation check: storing x.w from the source x.w in Matrix3::transpose failed matrix3_matches_c_oracle. Reverted. The proptest regression file was not committed.
  • Tier 2 (rust/tools/linux-validate/run.sh) did not run: Docker is not installed, so this head is not stamped. The claimed label could not be applied (AddLabelsToLabelable is denied). The claim comment is on the issue.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • Local gate passed and the pushed head is stamped
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

@nathan-v
nathan-v requested a review from zackees as a code owner October 11, 2026 00:45
Local-Gate: v1 tree=12181cd5c0c6a7e8760df475d2ed59d402965a3e secs=422 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791680648,"gate":"rust/all/fmt","host":"linux-x86_64","key":"7c749e9aca4da4806c2200f2129ff08f55d3849dec1cb4462a12e862f35560a3","lane":"lint","parents":["ab5fbfda14e6b50c9f8907d967bed01ad0671956"],"secs":157,"stamp":"6dba9556acdb54e34a4a0feefc8717b5","tree":"12181cd5c0c6a7e8760df475d2ed59d402965a3e","v":1,"via":"run"}
Ci-Attestation: {"at":1791680648,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"7c749e9aca4da4806c2200f2129ff08f55d3849dec1cb4462a12e862f35560a3","lane":"lint","parents":["ab5fbfda14e6b50c9f8907d967bed01ad0671956"],"secs":157,"stamp":"a84b07d1dab7c308420ad277cdcd2784","tree":"12181cd5c0c6a7e8760df475d2ed59d402965a3e","v":1,"via":"run"}
Ci-Attestation: {"at":1791680648,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"9f87de8caad7a109e98a513cebbc6a4e2c2912591653222741fb64245d3a8d2a","lane":"rust-test","parents":["ab5fbfda14e6b50c9f8907d967bed01ad0671956"],"secs":96,"stamp":"fa4c91516e133bfb159952d0748cd87b","tree":"12181cd5c0c6a7e8760df475d2ed59d402965a3e","v":1,"via":"run"}
Ci-Attestation: {"at":1791680648,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"5830cfad62c7b86d246e7ce107b2da26837de63e50f2dec08f244fa8acb865c9","lane":"tier2-linux","parents":["ab5fbfda14e6b50c9f8907d967bed01ad0671956"],"secs":168,"stamp":"d092b5074bcc09793bd2d91a82f49571","tree":"12181cd5c0c6a7e8760df475d2ed59d402965a3e","v":1,"via":"run"}
@zackees

zackees commented Oct 11, 2026

Copy link
Copy Markdown
Member

Rebased onto master after #172 (quat) merged (old head 22c094a, replaced with --force-with-lease):

  • quat.rs conflict: this PR added its own Quat::dot because quat wasn't ported yet. Master's quat port already has dot with the same SSE order ((w + y) + (z + x)), so I kept master's and dropped the duplicate.
  • Test fragment: per infra: Split shared registration lists into per-unit fragments #168, test_matrix3 now lives in test/cmocka/tests.d/test_matrix3.cmake (folded into your characterization commit) instead of CMakeLists.txt.

Verified with soldr's cache disabled. RED: matrix3 fails 13/13 at the stubs commit. GREEN: the full suite passes; Tier 2 51/51 with the Rust port OFF and ON. The derived check now covers 30 ported objects, including matrix3.c. The local gate passes and is stamped. I'll merge once CI is green.

@zackees
zackees merged commit 1536faa into obs-rust:master Oct 11, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

rust: Characterize and port graphics/matrix3.c

2 participants