Skip to content

rust: port graphics/quat.c to obs-graphics - #172

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

zackees merged 2 commits into
obs-rust:masterfrom
nathan-v:port/quat

Conversation

@nathan-v

Copy link
Copy Markdown
Contributor

Fixes #148

What and why

Ports libobs/graphics/quat.c into obs-graphics. The eleven exported functions move behind ENABLE_RUST_LIBOBS. Header-inline helpers in quat.h stay C. quat_get_dir computes the Z axis of matrix3_from_quat (that file stays C). quat_from_matrix3 reads the matrix as a matrix4, including each axis w lane, as the C cast does. quat_mul stores the vector before reading the scalar weights, so a destination that aliases an input matches C.

No intentional differences from C.

RED → GREEN

  • RED commit: 5a3a59639. soldr cargo test -p obs-graphics --test quat — 0 passed, 13 failed (todo!()).
  • GREEN: soldr cargo test --workspace --locked passed (Tiers 1–3). soldr cargo clippy --workspace --all-targets --locked -- -D warnings passed. ./lint (clang-format, gersemi, rustfmt, clippy) passed.
  • Mutation check: changing the product scalar from a difference to a sum fails mul_matches_c_oracle.
  • Tier 2 (rust/tools/linux-validate/run.sh, OFF and ON) was not run here. This machine has no Docker.

Checklist

  • Base is master
  • Claimed in a comment on rust: Port graphics/quat.c to obs-graphics #148. This account cannot add the claimed label.
  • Characterization test, then RED, then GREEN commits
  • Local gate passed and the pushed head is stamped (lint and the Rust test lane passed; the Linux Tier 2 lane and the stamp need Docker)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

Refs #45

The existing cmocka test only covered the header-inline setters. Pin the
exported quat.c functions, and add the matching Rust tests against todo!()
cores. soldr cargo test -p obs-graphics --test quat: 0 passed, 13 failed.
The safe core follows quat.c, including the SSE quat_dot order and the
matrix3-as-matrix4 cast. quat_mul stores the vector before reading the
scalar weights, so an aliased destination matches C. Header-inline
helpers stay in quat.h.

Tier 1, layout, and Tier 3 parity pass. Flipping the product scalar's
sign fails mul_matches_c_oracle. No intentional differences from C.
@nathan-v
nathan-v requested a review from zackees as a code owner October 11, 2026 00:17
@zackees

zackees commented Oct 11, 2026

Copy link
Copy Markdown
Member

Verified locally (soldr cache disabled):

  • RED at 5a3a596: obs-graphics --test quat fails 13/13 on the stubs.
  • GREEN: the full Rust suite passes. Tier 2 48/48 with the Rust port OFF and ON, exports IDENTICAL (1752). validate.sh's derived check now covers 29 ported objects, including graphics/quat.c.
  • Characterization: test_quat.c only gains cases for the exported functions; no existing assertion changed. The libm link for test_quat is needed for them.

Will merge once CI is green. Thanks for claiming on #148 first.

@zackees
zackees merged commit 8325758 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: Port graphics/quat.c to obs-graphics

2 participants