Skip to content

feat(graphics): port vec2 math to Rust obs-graphics crate (#8) - #39

Merged
zackees merged 3 commits into
grind/meta-4-9b41from
grind/8-phase5-graphics-vec2
Oct 9, 2026
Merged

zackees merged 3 commits into
grind/meta-4-9b41from
grind/8-phase5-graphics-vec2

Conversation

@zackees

@zackees zackees commented Oct 9, 2026

Copy link
Copy Markdown
Member

Refs #8

Phase 5 (graphics math), vec2 slice.

  • New rust/obs-graphics crate: safe Vec2 core (abs/floor/ceil/len/close/norm) plus #[unsafe(no_mangle)] vec2_* C ABI shims. Each shim reads its input before writing dst, so aliasing dst and src works.
  • libobs/CMakeLists.txt: graphics/vec2.c is compiled only when ENABLE_RUST_LIBOBS is OFF. The five symbols are added to rust-exports.txt, and export_list now scans every rust/*/src/ffi.
  • C oracle oracle/vec2.c is the unmodified graphics/vec2.c with its symbols renamed. It is built with -ffp-contract=off on non-MSVC compilers so clang/aarch64 FMA fusion cannot break bit-exact parity.
  • Tests: Tier 1 tests/vec2.rs, Tier 2 tests/vec2_layout.rs and cmocka test/cmocka/test_vec2.c, Tier 3 tests/vec2_parity.rs (proptest plus a deterministic close epsilon-boundary case).

Verification (local):

  • soldr cargo test -p obs-graphics, soldr cargo test -p obs-util --test export_list, soldr cargo build -p obs-c-oracle: pass.
  • Mutation check: norm forced to Some(self) makes norm_matches_c_oracle fail. <= changed to < in close makes close_boundary_matches_c_oracle fail. Both reverted.
  • ./lint (rustfmt, clippy -D warnings, clang-format, gersemi): ok.
  • ./unittest: rust-test ok. tier2-linux ran test_vec2 with ENABLE_RUST_LIBOBS OFF and ON, and the libobs exported symbols are identical OFF vs ON (1752).
  • macOS arm64 parity with -ffp-contract=off is checked by the Rust Tests (macos-26) CI job; it was not run locally.

Adds the obs-graphics crate with Vec2 abs/floor/ceil/len/close/norm,
no_mangle vec2_* shims swapped in under ENABLE_RUST_LIBOBS, a C oracle
for bit-exact parity, a cmocka test_vec2 characterization test, and
export-list coverage of every crate.

Refs #8
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.

1 participant