Repository navigation
rust: Port graphics/vec3.c to obs-graphics - #75
Merged
Merged
Conversation
Pins the exported functions of graphics/vec3.c before the Rust port: plane distance, rotation by a matrix3's axes, the 3x4 transform that subtracts the translation first, the matrix4 point transform, both mirrors, and vec3_rand repeating after the same srand seed. Every result has w cleared. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tier 1, Tier 2 layout (vec3, plane, matrix3) and Tier 3 parity tests for libobs/graphics/vec3.c against a todo!() core. vec3_rand calls libobs rand_float, which stays C in math-extra.c, so the Rust shim calls it too. Test binaries have no libobs, so the oracle hosts an unrenamed rand_float backed by its math-extra copy; the parity test seeds the C library's rand the same way for both sides. Co-Authored-By: Claude Opus 5.5 <[email protected]>
vec3_from_vec4, vec3_plane_dist, vec3_rotate, vec3_transform, vec3_transform3x4, vec3_mirror, vec3_mirrorv and vec3_rand move to Rust. With ENABLE_RUST_LIBOBS=ON libobs builds without graphics/vec3.c. struct vec3 has an SSE w lane, and vec3_dot multiplies it, so a caller's nonzero or NaN w changes the result. Vec3 keeps w, and dot adds the products as (w + y) + (z + x), the SSE order. No intentional differences. Co-Authored-By: Claude Opus 5.5 <[email protected]>
6 tasks done
b7216309-jpg
marked this pull request as ready for review
October 10, 2026 08:28
This was referenced Oct 10, 2026
This was referenced Oct 10, 2026
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Ports
libobs/graphics/vec3.ctoobs-graphics:vec3_from_vec4,vec3_plane_dist,vec3_rotate,vec3_transform,vec3_transform3x4,vec3_mirror,vec3_mirrorvandvec3_rand. WithENABLE_RUST_LIBOBS=ONlibobs builds withoutgraphics/vec3.c. The header-inline helpers invec3.hstay C.The
wlane.struct vec3is a union with__m128, so it has a fourth float. The C code clearswin its results, butvec3_dotmultiplies all four lanes, so a nonzero or NaNwfrom a caller changes plane distances, rotations and mirrors.Vec3therefore keepsw, andVec3::dotadds the products as(w + y) + (z + x), the SSE shuffle order. No intentional differences.vec3_rand. It calls libobsrand_float, which stays C inmath-extra.c, so the Rust shim calls it too. Test binaries have no libobs, so the oracle hosts an unrenamedrand_floatbacked by itsmath-extra.ccopy, in the same way astest_bmem.candbase-variadic.c. Remove it whenmath-extra.cis ported.Also adds
struct planeandstruct matrix3mirrors (ffi::plane,ffi::matrix3), with only what this port needs.libcbecomes a dev-dependency ofobs-graphics, forsrandin the parity test.Motivation and Context
The next item from the graphics math list in #45, after vec4 (#73).
Refs #45
How Has This Been Tested?
Windows 11, MSVC 14.44, soldr 0.9.31.
test/cmocka/test_vec3.c(C characterization), then RED (todo!()core: Tier 1 fails 10/10, the parity binary aborts on the first shim call, layout passes 3/3), then GREEN.vec3incl. theptr/munion members,plane,matrix3), and Tier 3 proptest parity:wis mostly 0 but sometimes any value;vec3_mirrorvwithdstaliasing the direction;vec3_randis compared after the samesrandseed for both sides.test_vec3.cexpectations also run against the oracle (cmocka_cases_match_c_oracle). There is no cmocka on Windows, so the cmocka test itself first runs in Tier 2 CI.w, naive sum order,subkeepsw, rotate usest, 3x4 skips the translation, mirror factor 1, rand order z/y/x,from_vec4keepsw, plane distance sign, and transform as a direction (w= 0). Two equivalent mutants survive. Swapping the halves of the final add changes NaN payloads only.mulfclearingwmakes no difference, because the followingsubalways clears it.python ci/local_gate.py --lane lint, andcargo clippy -p obs-graphics -p libobs-rust --lib -- -D warningsfor x86_64/aarch64 Linux and aarch64 macOS.Updated from master after #73, #74 and #85 landed.
soldr cargo test --workspace(38 binaries) and lint pass with no local changes. The CI run before that update was all green on Linux, macOS (arm64, first use of the scalar SSE stand-in) and Windows, Tier 2 included.Types of changes
Checklist:
🤖 Generated with Claude Code