Repository navigation
rust: Port graphics/vec4.c to obs-graphics - #73
Merged
Merged
Conversation
Pins the exported functions of graphics/vec4.c before the Rust port: vec4_from_vec3 sets w to 1 whatever the vec3 w lane holds, and vec4_transform is a row vector times the matrix, including when dst and v are the same vector. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tier 1, Tier 2 layout and Tier 3 parity tests for libobs/graphics/vec4.c against a todo!() core. The C files of the graphics math cluster (vec3, vec4, matrix3, matrix4, quat, plane, bounds, axisang, math-extra) call each other, so the oracle compiles all of them, renamed to oracle_* by graphics_math_names.h. Later ports of those files reuse it. libobs/util/sse-intrin.h takes SSE from SIMDe outside MSVC, and the Rust test jobs do not install SIMDe. The oracle gets a stand-in <simde/x86/sse2.h>: the native SSE header on x86, and elsewhere scalar versions of the 15 intrinsics the math headers use, lane by lane as SSE defines them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
vec4_from_vec3 and vec4_transform move to Rust. With ENABLE_RUST_LIBOBS=ON libobs builds without graphics/vec4.c, and vec3_transform and the other C callers link the Rust shims. Vec4::dot adds the four products as (w + y) + (z + x), the order the SSE shuffles in vec4_dot produce, so transform results are bit-identical to C. No intentional differences. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # rust/README.md # rust/obs-c-oracle/build.rs
This was referenced Oct 10, 2026
# Conflicts: # rust/README.md # rust/obs-c-oracle/src/lib.rs
6 tasks done
This was referenced Oct 10, 2026
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/vec4.c(vec4_from_vec3,vec4_transform) toobs-graphics. WithENABLE_RUST_LIBOBS=ONlibobs builds withoutgraphics/vec4.c;vec3_transformand the other C callers link the Rust shims. The header-inline helpers invec4.hstay C.vec4_dotsums the products through SSE shuffles as(w + y) + (z + x).Vec4::dotadds them in that order, so transforms are bit-identical to C. No intentional differences.Oracle for the graphics math cluster. vec3, vec4, matrix3, matrix4, quat, plane, bounds, axisang and math-extra call each other (
vec4_transformneedsmatrix4_transpose, which pulls in quat, and so on). The oracle compiles all nine files, renamed tooracle_*byoracle/graphics_math_names.h, so later ports of those files reuse it as is.SIMDe stand-in (needs your call).
util/sse-intrin.htakes SSE from<simde/x86/sse2.h>everywhere except MSVC/MinGW on x86, and the Rust test jobs and./unittestdo not install SIMDe. Instead of adding SIMDe to CI, the oracle getsoracle/sse-shim/simde/x86/sse2.h, on the include path for non-MSVC only:<emmintrin.h>, which is what SIMDe maps to there;minps/maxps.If you would rather install SIMDe in the Rust jobs, the shim can go.
Motivation and Context
Issue #45 lists the graphics math ports, and nobody has claimed them yet. This PR does vec4 only, the smallest file, plus the oracle the rest of the list needs.
Refs #45
How Has This Been Tested?
Windows 11, MSVC 14.44, Rust via soldr 0.9.31.
test/cmocka/test_vec4.c(C characterization), then RED (todo!()core: Tier 1 and parity fail, layout passes), then GREEN.soldr cargo test -p obs-graphics: Tier 1, Tier 2 layout (vec4,vec3,matrix4incl. theptr/munion members), Tier 3 proptest parity on arbitrary bit patterns and on finite values where the summation order decides the last bits, plus in-placedst == v.test_vec4.ccases also run against the oracle incmocka_cases_match_c_oracle. I have no cmocka on Windows, so the cmocka test itself first runs in Tier 2 CI.sse-intrin.hforced onto the shim's scalar branch compiled all nine oracle files with MSVC.oracle_vec4_transformmatchedVec4::transformover 1M cases.wto 0, skipping the transpose and a wrong transpose lane are each caught by the parity tests. Swapping the two halves of the final add survives. It changes NaN payloads only, which the tests treat as equal.cargo clippy -p obs-graphics -p libobs-rust --lib -- -D warningsfor x86_64/aarch64 Linux and aarch64 macOS;python ci/local_gate.py --lane lint.Note: since #61 landed,
obs-c-oracleno longer builds with MSVC on master:oracle/base.c→threading.h→<pthread.h>, the same failure as on #68. I verified this branch locally withdeps/w32-pthreadsadded to the oracle include path, without committing that. With it,base_parity'sdefault_handler_output_matches_oracleanddefault_handler_truncates_like_cstill fail on Windows (capture worker exits non-zero); everything else passes. So expect Rust Tests (windows) to fail here for that reason until master is fixed.Types of changes
Checklist:
🤖 Generated with Claude Code