Repository navigation
rust: Port graphics/axisang.c to obs-graphics - #83
Merged
Merged
Conversation
6 tasks done
Pins axisang_from_quat before the Rust port: the axis is normalized and the angle is 2 * acos(w); a vector part whose squared length is within EPSILON of zero gives all zeros. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tier 1, Tier 2 layout (axisang, quat) and Tier 3 parity tests for libobs/graphics/axisang.c against a todo!() core. struct axisang has no __m128 member, so it is 4-byte aligned, unlike struct quat. Co-Authored-By: Claude Opus 5.5 <[email protected]>
axisang_from_quat moves to Rust. With ENABLE_RUST_LIBOBS=ON libobs builds without graphics/axisang.c. The squared length is summed as (x*x + y*y) + z*z, as the C expression is, and the angle uses the C library's acosf through f32::acos, so results are bit-identical. A NaN length is not close to zero, so it normalizes to NaN, as in C. No intentional differences. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=1ec95d494545de856ed4a99615078347f578c97c secs=17 lanes=lint:reused@3e15177ddaf7,rust-test:reused@5dba1872e1bb,tier2-linux:run Ci-Attestation: {"at":1791649972,"gate":"rust/all/fmt","host":"linux-x86_64","key":"3e15177ddaf7972fe0e08e5449bc5e70dfa6c28844ea2af6b38c7e0b5244ab82","lane":"lint","parents":["824625616c5979e95b35bbdf804752de4852ed38"],"secs":null,"stamp":"15302c301fede4acd226ce8b4e881819","tree":"1ec95d494545de856ed4a99615078347f578c97c","v":1,"via":"reused"} Ci-Attestation: {"at":1791649972,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"3e15177ddaf7972fe0e08e5449bc5e70dfa6c28844ea2af6b38c7e0b5244ab82","lane":"lint","parents":["824625616c5979e95b35bbdf804752de4852ed38"],"secs":null,"stamp":"25434e1f438534d1fb218c3dceab8a28","tree":"1ec95d494545de856ed4a99615078347f578c97c","v":1,"via":"reused"} Ci-Attestation: {"at":1791649972,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"5dba1872e1bb5df24f3a71cb5300f72a6d37d7403ffe558b8c7c35846e339c47","lane":"rust-test","parents":["824625616c5979e95b35bbdf804752de4852ed38"],"secs":null,"stamp":"1987ea63ffb5578a918eab1c842ab469","tree":"1ec95d494545de856ed4a99615078347f578c97c","v":1,"via":"reused"} Ci-Attestation: {"at":1791650919,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"926fb95d3a022eb6f602366a7c16920b5dde90e6416a42d866173261b35b6da0","lane":"tier2-linux","parents":["824625616c5979e95b35bbdf804752de4852ed38"],"secs":17,"stamp":"dd3bb8f4ea07156298856aec7c1be338","tree":"1ec95d494545de856ed4a99615078347f578c97c","v":1,"via":"run"}
zackees
marked this pull request as ready for review
October 10, 2026 16:48
Member
|
Rebased onto current master (after #75 vec3, #73 vec4, #86 quat_set fix, #89 obs-nal). Replaced the merge-heavy history with the three port commits only (characterization test, RED shim/tests/oracle, GREEN). test_axisang.c uses quat_set, consistent with the fixed component order from #86; the field-by-field workaround and its revert were dropped as a net no-op. RED: at the RED commit |
zackees
added a commit
that referenced
this pull request
Oct 10, 2026
…43) Phase 3 ports of libobs/util into the obs-util crate, each with a safe core, a C ABI shim, Tier 1 tests, a layout test where a struct crosses the ABI, and a proptest parity suite against the original C built as an oracle. ENABLE_RUST_LIBOBS=ON drops the matching C sources from libobs. - utf8: hidden and non-Windows only (Windows keeps the C utf8.c). - lexer.c: follows master's C, including the #48 strref ordering. - text-lookup: no longer crashes on an opening quote at end of line; the shim returns false for a NULL lookup. - dstr: follows master's #46/#47 fixes; strlist_split takes a NUL separator. Wide-char and printf helpers stay in dstr-libc.c. - bmem: Windows _aligned_* branch and the allocation counter. The oracle vendors uthash 2.3.0 (BSD-1-Clause) for text-lookup.c, since the Rust test runners have no uthash package. Refs #43 Rebased onto master after #61 (base), #66 (file-serializer) and #85 (real utf8.c in the oracle): the oracle's utf8.c/platform_conv_host.c now use oracle_* utf8 names so they no longer clash with the Rust shims; the dstr-conversion oracle test moved to obs-util and calls oracle_dstr_*; duplicate bcrash/os_fopen/bmemdup/os_*_ptr stand-ins were dropped in favour of master's base-variadic.c, file_serializer_host.c and platform_conv_host.c; utf8 shims are listed in rust-hidden.txt; the vendored uthash is excluded from clang-format. Rebased again onto master after #82/#83/#87/#97/#89: oracle build.rs keeps video_fourcc.c/task.c and drops the direct util/utf8.c (oracle/utf8.c already compiles it under oracle_* names, which platform_conv_host.c and #82's file_serializer_host.c use). Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=21926a8ffae3e3de7be0daaa6a529723f7497869 secs=50 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791654631,"gate":"rust/all/fmt","host":"linux-x86_64","key":"6277551b1197bae61a0a3563f9047b17c1e6d651b5cab860d7def119d1cbc569","lane":"lint","parents":["5502191074629b7f2e51dda6d89fa601ce22a01d"],"secs":12,"stamp":"92e0f34f8074164ecb0208cbd6f8ab26","tree":"21926a8ffae3e3de7be0daaa6a529723f7497869","v":1,"via":"run"} Ci-Attestation: {"at":1791654631,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"6277551b1197bae61a0a3563f9047b17c1e6d651b5cab860d7def119d1cbc569","lane":"lint","parents":["5502191074629b7f2e51dda6d89fa601ce22a01d"],"secs":12,"stamp":"4d3ace010dbaab4ed252006d22ec59aa","tree":"21926a8ffae3e3de7be0daaa6a529723f7497869","v":1,"via":"run"} Ci-Attestation: {"at":1791654631,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"c6b1b608fc16817859a28490ada2b38a926103a0094ec23e3bb7d594979793d7","lane":"rust-test","parents":["5502191074629b7f2e51dda6d89fa601ce22a01d"],"secs":18,"stamp":"d73d3c14d2d133a677293234ca581902","tree":"21926a8ffae3e3de7be0daaa6a529723f7497869","v":1,"via":"run"} Ci-Attestation: {"at":1791654631,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"d05a3c8a53e501ee21ca4d301b5ba053c0dccd6b86b39d46af0486606d1d851e","lane":"tier2-linux","parents":["5502191074629b7f2e51dda6d89fa601ce22a01d"],"secs":20,"stamp":"7dedfefe7e32a22a666716a1fd3efcb5","tree":"21926a8ffae3e3de7be0daaa6a529723f7497869","v":1,"via":"run"}
This was referenced Oct 10, 2026
zackees
added a commit
that referenced
this pull request
Oct 10, 2026
…43) Phase 3 ports of libobs/util into the obs-util crate, each with a safe core, a C ABI shim, Tier 1 tests, a layout test where a struct crosses the ABI, and a proptest parity suite against the original C built as an oracle. ENABLE_RUST_LIBOBS=ON drops the matching C sources from libobs. - utf8: hidden and non-Windows only (Windows keeps the C utf8.c). - lexer.c: follows master's C, including the #48 strref ordering. - text-lookup: no longer crashes on an opening quote at end of line; the shim returns false for a NULL lookup. - dstr: follows master's #46/#47 fixes; strlist_split takes a NUL separator. Wide-char and printf helpers stay in dstr-libc.c. - bmem: Windows _aligned_* branch and the allocation counter. The oracle vendors uthash 2.3.0 (BSD-1-Clause) for text-lookup.c, since the Rust test runners have no uthash package. Refs #43 Rebased onto master after #61 (base), #66 (file-serializer) and #85 (real utf8.c in the oracle): the oracle's utf8.c/platform_conv_host.c now use oracle_* utf8 names so they no longer clash with the Rust shims; the dstr-conversion oracle test moved to obs-util and calls oracle_dstr_*; duplicate bcrash/os_fopen/bmemdup/os_*_ptr stand-ins were dropped in favour of master's base-variadic.c, file_serializer_host.c and platform_conv_host.c; utf8 shims are listed in rust-hidden.txt; the vendored uthash is excluded from clang-format. Rebased again onto master after #82/#83/#87/#97/#89/#98: oracle build.rs keeps video_fourcc.c/task.c and drops the direct util/utf8.c (oracle/utf8.c already compiles it under oracle_* names, which platform_conv_host.c and #82's file_serializer_host.c use). Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=1b426910df018155f8be2a2ed4dc5fd8b42d68a0 secs=17 lanes=lint:reused@12a747713c0b,rust-test:reused@8f0383f521c9,tier2-linux:run Ci-Attestation: {"at":1791655075,"gate":"rust/all/fmt","host":"linux-x86_64","key":"12a747713c0b7b727bbfb48e33e2c7c1aa431a3c77062fee88a56e5821c8b6c5","lane":"lint","parents":["84c80bce3c20e772d563e2c85b32ed5ac51020b4"],"secs":null,"stamp":"58719f015cf7d13d7f971c86c36023dd","tree":"1b426910df018155f8be2a2ed4dc5fd8b42d68a0","v":1,"via":"reused"} Ci-Attestation: {"at":1791655075,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"12a747713c0b7b727bbfb48e33e2c7c1aa431a3c77062fee88a56e5821c8b6c5","lane":"lint","parents":["84c80bce3c20e772d563e2c85b32ed5ac51020b4"],"secs":null,"stamp":"42c3a2e402903d1da67f91e332763625","tree":"1b426910df018155f8be2a2ed4dc5fd8b42d68a0","v":1,"via":"reused"} Ci-Attestation: {"at":1791655075,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"8f0383f521c9857941f5429d53f8403e48869775747f8ce4edeee1af4e935da8","lane":"rust-test","parents":["84c80bce3c20e772d563e2c85b32ed5ac51020b4"],"secs":null,"stamp":"814d385ae14911c99b750eff7d8faa6a","tree":"1b426910df018155f8be2a2ed4dc5fd8b42d68a0","v":1,"via":"reused"} Ci-Attestation: {"at":1791655401,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"2e94b41fc041e0c98bd1709f7ab30cb7f5b5b835b799b4c3abb2c5414d4b62ec","lane":"tier2-linux","parents":["84c80bce3c20e772d563e2c85b32ed5ac51020b4"],"secs":17,"stamp":"e6e3337d94f8a4dbafc4a9892b369084","tree":"1b426910df018155f8be2a2ed4dc5fd8b42d68a0","v":1,"via":"run"}
zackees
added a commit
that referenced
this pull request
Oct 10, 2026
…43) Phase 3 ports of libobs/util into the obs-util crate, each with a safe core, a C ABI shim, Tier 1 tests, a layout test where a struct crosses the ABI, and a proptest parity suite against the original C built as an oracle. ENABLE_RUST_LIBOBS=ON drops the matching C sources from libobs. - utf8: hidden and non-Windows only (Windows keeps the C utf8.c). - lexer.c: follows master's C, including the #48 strref ordering. - text-lookup: no longer crashes on an opening quote at end of line; the shim returns false for a NULL lookup. - dstr: follows master's #46/#47 fixes; strlist_split takes a NUL separator. Wide-char and printf helpers stay in dstr-libc.c. - bmem: Windows _aligned_* branch and the allocation counter. The oracle vendors uthash 2.3.0 (BSD-1-Clause) for text-lookup.c, since the Rust test runners have no uthash package. Refs #43 Rebased onto master after #61 (base), #66 (file-serializer) and #85 (real utf8.c in the oracle): the oracle's utf8.c/platform_conv_host.c now use oracle_* utf8 names so they no longer clash with the Rust shims; the dstr-conversion oracle test moved to obs-util and calls oracle_dstr_*; duplicate bcrash/os_fopen/bmemdup/os_*_ptr stand-ins were dropped in favour of master's base-variadic.c, file_serializer_host.c and platform_conv_host.c; utf8 shims are listed in rust-hidden.txt; the vendored uthash is excluded from clang-format. Rebased again onto master after #82/#83/#87/#97/#89/#98/#88: oracle build.rs keeps video_fourcc.c/task.c and drops the direct util/utf8.c (oracle/utf8.c already compiles it under oracle_* names, which platform_conv_host.c and #82's file_serializer_host.c use). Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=44ac22e2f9bf9093f2a87bc1c0860393942c7f05 secs=31 lanes=lint:reused@9b0282a9e1c3,rust-test:reused@e3680ff66806,tier2-linux:run Ci-Attestation: {"at":1791656844,"gate":"rust/all/fmt","host":"linux-x86_64","key":"9b0282a9e1c35c80eae0d4f0c7540b1c3b1c9f193daad522570bc7b20e609cdc","lane":"lint","parents":["07223a5abc85d40d9b7c016092ce37a672aca501"],"secs":null,"stamp":"ed3cee40895adfa7780a781e7ead1f4d","tree":"44ac22e2f9bf9093f2a87bc1c0860393942c7f05","v":1,"via":"reused"} Ci-Attestation: {"at":1791656844,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"9b0282a9e1c35c80eae0d4f0c7540b1c3b1c9f193daad522570bc7b20e609cdc","lane":"lint","parents":["07223a5abc85d40d9b7c016092ce37a672aca501"],"secs":null,"stamp":"9bde047cbb6c054fa18fa8143826c0c7","tree":"44ac22e2f9bf9093f2a87bc1c0860393942c7f05","v":1,"via":"reused"} Ci-Attestation: {"at":1791656844,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"e3680ff66806191a1385606c7996530d1becc162ef5a3444eeefce614a7d0c02","lane":"rust-test","parents":["07223a5abc85d40d9b7c016092ce37a672aca501"],"secs":null,"stamp":"46cf777b2d672af2f62536e2d4132bf2","tree":"44ac22e2f9bf9093f2a87bc1c0860393942c7f05","v":1,"via":"reused"} Ci-Attestation: {"at":1791657116,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"99939507781ddefb1aa7855e1a0c9b4af9092524f38999d7db36a74a20f1ccce","lane":"tier2-linux","parents":["07223a5abc85d40d9b7c016092ce37a672aca501"],"secs":31,"stamp":"8164638665d4208fabc4b0a768fbc870","tree":"44ac22e2f9bf9093f2a87bc1c0860393942c7f05","v":1,"via":"run"}
zackees
added a commit
that referenced
this pull request
Oct 10, 2026
…43) Phase 3 ports of libobs/util into the obs-util crate, each with a safe core, a C ABI shim, Tier 1 tests, a layout test where a struct crosses the ABI, and a proptest parity suite against the original C built as an oracle. ENABLE_RUST_LIBOBS=ON drops the matching C sources from libobs. - utf8: hidden and non-Windows only (Windows keeps the C utf8.c). - lexer.c: follows master's C, including the #48 strref ordering. - text-lookup: no longer crashes on an opening quote at end of line; the shim returns false for a NULL lookup. - dstr: follows master's #46/#47 fixes; strlist_split takes a NUL separator. Wide-char and printf helpers stay in dstr-libc.c. - bmem: Windows _aligned_* branch and the allocation counter. The oracle vendors uthash 2.3.0 (BSD-1-Clause) for text-lookup.c, since the Rust test runners have no uthash package. Refs #43 Rebased onto master after #61 (base), #66 (file-serializer) and #85 (real utf8.c in the oracle): the oracle's utf8.c/platform_conv_host.c now use oracle_* utf8 names so they no longer clash with the Rust shims; the dstr-conversion oracle test moved to obs-util and calls oracle_dstr_*; duplicate bcrash/os_fopen/bmemdup/os_*_ptr stand-ins were dropped in favour of master's base-variadic.c, file_serializer_host.c and platform_conv_host.c; utf8 shims are listed in rust-hidden.txt; the vendored uthash is excluded from clang-format. Rebased again onto master after #82/#83/#87/#97/#89/#98/#88/#105: oracle build.rs keeps video_fourcc.c/task.c and drops the direct util/utf8.c (oracle/utf8.c already compiles it under oracle_* names, which platform_conv_host.c and #82's file_serializer_host.c use). Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=58f2156a689831720a1e6ad9004041e400917579 secs=135 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791658556,"gate":"rust/all/fmt","host":"linux-x86_64","key":"e533312cff231c50944045005e90c2b48ce1920b317c9037a705bfda5b49ef4c","lane":"lint","parents":["930903b5e8c0cac6cec54edd05abeaacb825637c"],"secs":17,"stamp":"a33efc3cd6c98f3fbd2fa57e9a61a281","tree":"58f2156a689831720a1e6ad9004041e400917579","v":1,"via":"run"} Ci-Attestation: {"at":1791658556,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"e533312cff231c50944045005e90c2b48ce1920b317c9037a705bfda5b49ef4c","lane":"lint","parents":["930903b5e8c0cac6cec54edd05abeaacb825637c"],"secs":17,"stamp":"fb2d0a58bcefb05085a4b512fc916740","tree":"58f2156a689831720a1e6ad9004041e400917579","v":1,"via":"run"} Ci-Attestation: {"at":1791658556,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"1a00cb7a8eb7b67b33a108e748711133d604e544b254813435cc1ca5ea24cd26","lane":"rust-test","parents":["930903b5e8c0cac6cec54edd05abeaacb825637c"],"secs":22,"stamp":"d80b75173a27c995da2676193fa36904","tree":"58f2156a689831720a1e6ad9004041e400917579","v":1,"via":"run"} Ci-Attestation: {"at":1791658556,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"a950373231b455174e5c031fe578e1e48c61e04f0387195a7ddc0e265e371e15","lane":"tier2-linux","parents":["930903b5e8c0cac6cec54edd05abeaacb825637c"],"secs":96,"stamp":"f1c2d81609277e26492a5a3f3553cd9c","tree":"58f2156a689831720a1e6ad9004041e400917579","v":1,"via":"run"}
10 of 22 tasks
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/axisang.c(axisang_from_quat) toobs-graphics. WithENABLE_RUST_LIBOBS=ONlibobs builds withoutgraphics/axisang.c. The header-inline helpers inaxisang.hstay C.AxisAng::from_quatfollows the C expression order for the squared length,(x*x + y*y) + z*z. It uses the C library'sacosfthroughf32::acos, so results are bit-identical. A NaN length is not "close to zero" (fabsf(NaN) <= EPSILONis false), so it takes the normalizing branch and yields NaN, as in C. No intentional differences.Also adds a
struct quatmirror (ffi::quat), with only what this port needs.struct axisanghas no__m128member, so it is 4-byte aligned, unlikequatand the vectors. The layout test pins that.Motivation and Context
Next item from the graphics math list in #45, after vec4 (#73) and vec3 (#75).
Refs #45
How Has This Been Tested?
Windows 11, MSVC 14.44, soldr 0.9.31.
test/cmocka/test_axisang.c(C characterization), then RED (todo!()core: Tier 1 fails 6/6, layout passes 2/2), then GREEN.EPSILONcutoff. Plus the boundary itself (<=) and thetest_axisang.ccases against the oracle.<=→<, angle not doubled, sum orderx*x + (y*y + z*z),1/leninstead of1/sqrt(len),EPSILON1e-5, y/z swapped.python ci/local_gate.py --lane lint,soldr cargo test --workspace(40 binaries), andcargo clippy -p obs-graphics -p libobs-rust --lib -- -D warningsfor x86_64/aarch64 Linux and aarch64 macOS.f32::acosand Cacosfagree bit for bit with MSVC here. Linux and macOS are first checked by this CI run. On those platforms both sides call the same libmacosf.Found on the way:
quat_setstored quaternions reversed, which made the first Tier 2 run oftest_axisang.cfail with the original C. It was fixed separately in #86. This branch includes it from master, andtest_axisang.cusesquat_setagain.Types of changes
Checklist:
🤖 Generated with Claude Code