Repository navigation
rust: Port graphics/plane.c to obs-graphics - #338
Merged
Merged
Conversation
Pins the seven exports in graphics/plane.c, including a normal transformed as a point, a parallel ray miss that writes *t = 0, and a line miss that leaves *t unchanged. Refs obs-rust#335
test_plane_from_tri_xy fails because Plane::from_tri returns a zero plane: left (0, 0, 0, 0, 0), right (0, 0, 1, 0, 0). 15 of 17 Tier 1 tests fail. The two that pass are the degenerate triangle and the line miss, which are also the empty result. Refs obs-rust#335
Member
|
Verified locally, rebased onto master and stamped.
Merging once CI is green. |
The 17 Tier 1 plane tests pass. Tier 3 plane_parity is bit-exact against the C oracle, including v1 aliased with dst->dir. The layout matches plane.h. Flipping the sign of plane_transform's dist makes plane_matches_c_oracle fail on the shim dist; that break was reverted. ENABLE_RUST_LIBOBS drops graphics/plane.c. Exports are in obs-graphics-plane.txt. Header-inline helpers stay C. Fixes obs-rust#335 Local-Gate: v1 tree=92b294cb9463f61dfde540370a9c3b9769673b57 secs=151 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791791815,"gate":"rust/all/fmt","host":"linux-x86_64","key":"0d56f66fcee0416b2b9db06484a615c7da0f6650cb94f6fd72505d76860ca03c","lane":"lint","parents":["e21514a8f1b7a7d218289b775e370f26e93f21c3"],"secs":53,"stamp":"7083b9bb3085244b851192fe35cfaa24","tree":"92b294cb9463f61dfde540370a9c3b9769673b57","v":1,"via":"run"} Ci-Attestation: {"at":1791791815,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"0d56f66fcee0416b2b9db06484a615c7da0f6650cb94f6fd72505d76860ca03c","lane":"lint","parents":["e21514a8f1b7a7d218289b775e370f26e93f21c3"],"secs":53,"stamp":"aa502dabb1f5f896d98fe180bccb960f","tree":"92b294cb9463f61dfde540370a9c3b9769673b57","v":1,"via":"run"} Ci-Attestation: {"at":1791791815,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"66924d5af7c21fafe7dcbc83ef0c7ccbb8fea7ce312ee6cc8c44945fbe78788c","lane":"rust-test","parents":["e21514a8f1b7a7d218289b775e370f26e93f21c3"],"secs":47,"stamp":"56963e497044759ea98e3fcaf335898e","tree":"92b294cb9463f61dfde540370a9c3b9769673b57","v":1,"via":"run"} Ci-Attestation: {"at":1791791815,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"8c402338d0d763c0a94173e23e59b586bb3834ec187aaa42e7738d2d4a0cff1d","lane":"tier2-linux","parents":["e21514a8f1b7a7d218289b775e370f26e93f21c3"],"secs":51,"stamp":"50ab82b6c2e3dbd0a536a6f2183b7d61","tree":"92b294cb9463f61dfde540370a9c3b9769673b57","v":1,"via":"run"}
Member
|
Correction to my comment above: the gate did not pass on your head. The so CMake configure failed in both builds: |
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 12, 2026
…-extra ports copied Upstream obs-rust#338 (plane) and obs-rust#352 (math-extra) landed after this branch's base, and both ports deliberately copied the C aliasing bugs so they would match it: plane_from_tri detected `v1 == &dst->dir` and set the distance to `dir·dir`, and calc_torque stored the scaled direction and then re-read `v1` through the pointer to add it. Their characterization tests pinned those results, marked "Characterized, not endorsed". With the C fixed, neither emulation is needed. plane_from_tri now reads all three vertices and builds the plane from the copies, like every other shim in the crate, and calc_torque uses the safe core's calc_torque, which already reads v1 before writing. The two characterization tests are updated to the fixed values, and each now also runs the non-aliased call and asserts the aliased result equals it, so the property (not just a constant) is checked. The Rust parity tests do the same against the oracle. Tested by reverting the C and shim fixes to the versions in this merge base and rebuilding: test_graphics_math_alias fails 19/19, test_math_extra fails test_calc_torque_dst_aliases_v1, test_plane fails test_plane_from_tri_v1_aliases_dir, and calc_torque_dst_aliases_v1_matches_c fails against the unfixed oracle. With the fixes in place all pass, in debug and release.
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 12, 2026
…REEN) bounds_move, bounds_scale, bounds_merge_point and bounds_get_center read their vector operand, or b->min, again after writing dst->min, so a caller that passes a destination it also reads from gets a value that depends on the overlap. plane_from_tri reads v1 after writing dst->dir, so a v1 sharing storage with the destination yields a distance taken from the normalized direction instead of the vertex. Each fix is a snapshot of the input that the later read would otherwise re-read: the operand for the four bounds helpers, b->min for the center, and v1 for the plane. No expression, operand or order of operations changes, so non-overlapping results are bit-for-bit unchanged. The Rust port is aligned in the same commit. The bounds shims already read their inputs before writing, so they needed no change; plane_from_tri had copied the C bug on purpose - it detected `v1 == &dst->dir` and set the distance to dir·dir (obs-rust#338) - and that emulation is dropped, so the shim reads all three vertices like every other shim in the crate. The plane characterization test that pinned dir·dir ("Characterized, not endorsed") now asserts the distance of the original vertex and that the aliased call equals a call with a separate destination. GREEN: test_graphics_alias_ordinary 5 passed, 0 failed (exit 0), and the existing test_plane (17) and test_bounds (16) suites pass, in the same Release build as the RED commit's 0-passed/5-failed run.
zackees
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 13, 2026
…REEN) bounds_move, bounds_scale, bounds_merge_point and bounds_get_center read their vector operand, or b->min, again after writing dst->min, so a caller that passes a destination it also reads from gets a value that depends on the overlap. plane_from_tri reads v1 after writing dst->dir, so a v1 sharing storage with the destination yields a distance taken from the normalized direction instead of the vertex. Each fix is a snapshot of the input that the later read would otherwise re-read: the operand for the four bounds helpers, b->min for the center, and v1 for the plane. No expression, operand or order of operations changes, so non-overlapping results are bit-for-bit unchanged. The Rust port is aligned in the same commit. The bounds shims already read their inputs before writing, so they needed no change; plane_from_tri had copied the C bug on purpose - it detected `v1 == &dst->dir` and set the distance to dir·dir (obs-rust#338) - and that emulation is dropped, so the shim reads all three vertices like every other shim in the crate. The plane characterization test that pinned dir·dir ("Characterized, not endorsed") now asserts the distance of the original vertex and that the aliased call equals a call with a separate destination. GREEN: test_graphics_alias_ordinary 5 passed, 0 failed (exit 0), and the existing test_plane (17) and test_bounds (16) suites pass, in the same Release build as the RED commit's 0-passed/5-failed run. Local-Gate: v1 tree=e491b7e0aad43f87b98f9f54ca8b8692c5dbc748 secs=176 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791854742,"gate":"rust/all/fmt","host":"linux-x86_64","key":"80aee80b302f28ff1fe2588d45fee172121d392fe232b8cd6d19ea0a88a01237","lane":"lint","parents":["6161f0666d81c3fd5bf9d8644a44039d58299a38"],"secs":39,"stamp":"c13a375d0f58e6abcbb9dd0201d059f0","tree":"e491b7e0aad43f87b98f9f54ca8b8692c5dbc748","v":1,"via":"run"} Ci-Attestation: {"at":1791854742,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"80aee80b302f28ff1fe2588d45fee172121d392fe232b8cd6d19ea0a88a01237","lane":"lint","parents":["6161f0666d81c3fd5bf9d8644a44039d58299a38"],"secs":39,"stamp":"5b1f1dbec523079acd2b0129aa059db5","tree":"e491b7e0aad43f87b98f9f54ca8b8692c5dbc748","v":1,"via":"run"} Ci-Attestation: {"at":1791854742,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"e0fc8277f27f5efe797856b0956c6e8cac844384103903d31f8fb9d4a48a4819","lane":"rust-test","parents":["6161f0666d81c3fd5bf9d8644a44039d58299a38"],"secs":64,"stamp":"f2fdd9558f3efd1fa3330dd7ce1fe7a9","tree":"e491b7e0aad43f87b98f9f54ca8b8692c5dbc748","v":1,"via":"run"} Ci-Attestation: {"at":1791854742,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"2baf904178cd0711f9792e8a2e6792204bdf510ba3bf5ec4ce186d8a5f120758","lane":"tier2-linux","parents":["6161f0666d81c3fd5bf9d8644a44039d58299a38"],"secs":73,"stamp":"1ec76fb4a267a1895436e7a81eaeb3bc","tree":"e491b7e0aad43f87b98f9f54ca8b8692c5dbc748","v":1,"via":"run"}
zackees
pushed a commit
that referenced
this pull request
Oct 13, 2026
) * test: Fail the graphics math functions on overlapping dst/input (RED) The five libobs/graphics math functions this branch repairs re-read an input after storing an output lane, so a dst overlapping an input depends on the overlap. Three commitments, all failing on master: - test/cmocka/test_graphics_alias_ordinary.c: runs bounds_move, bounds_scale, bounds_merge_point, bounds_get_center and plane_from_tri twice, once on separate storage and once on the arrangement, asserting the results are identical. 0 of 5 pass on master. - rust/obs-graphics/tests/bounds_parity.rs: the same four arrangements on the Rust shims, each comparing the aliased result with the non-aliased one on the Rust side, the C side and between the two. - rust/obs-graphics/tests/plane_parity.rs: the plane arrangement now also compares the aliased result against a call with a separate destination, which the C oracle on master does not satisfy (it returns dir·dir for the distance). The plane comparison is on dir's lanes and dist, not the struct, because struct plane has 12 bytes of tail padding. * graphics: Make five math functions safe when dst overlaps an input (GREEN) bounds_move, bounds_scale, bounds_merge_point and bounds_get_center read their vector operand, or b->min, again after writing dst->min, so a caller that passes a destination it also reads from gets a value that depends on the overlap. plane_from_tri reads v1 after writing dst->dir, so a v1 sharing storage with the destination yields a distance taken from the normalized direction instead of the vertex. Each fix is a snapshot of the input that the later read would otherwise re-read: the operand for the four bounds helpers, b->min for the center, and v1 for the plane. No expression, operand or order of operations changes, so non-overlapping results are bit-for-bit unchanged. The Rust port is aligned in the same commit. The bounds shims already read their inputs before writing, so they needed no change; plane_from_tri had copied the C bug on purpose - it detected `v1 == &dst->dir` and set the distance to dir·dir (#338) - and that emulation is dropped, so the shim reads all three vertices like every other shim in the crate. The plane characterization test that pinned dir·dir ("Characterized, not endorsed") now asserts the distance of the original vertex and that the aliased call equals a call with a separate destination. GREEN: test_graphics_alias_ordinary 5 passed, 0 failed (exit 0), and the existing test_plane (17) and test_bounds (16) suites pass, in the same Release build as the RED commit's 0-passed/5-failed run. Local-Gate: v1 tree=e491b7e0aad43f87b98f9f54ca8b8692c5dbc748 secs=176 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791854742,"gate":"rust/all/fmt","host":"linux-x86_64","key":"80aee80b302f28ff1fe2588d45fee172121d392fe232b8cd6d19ea0a88a01237","lane":"lint","parents":["6161f0666d81c3fd5bf9d8644a44039d58299a38"],"secs":39,"stamp":"c13a375d0f58e6abcbb9dd0201d059f0","tree":"e491b7e0aad43f87b98f9f54ca8b8692c5dbc748","v":1,"via":"run"} Ci-Attestation: {"at":1791854742,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"80aee80b302f28ff1fe2588d45fee172121d392fe232b8cd6d19ea0a88a01237","lane":"lint","parents":["6161f0666d81c3fd5bf9d8644a44039d58299a38"],"secs":39,"stamp":"5b1f1dbec523079acd2b0129aa059db5","tree":"e491b7e0aad43f87b98f9f54ca8b8692c5dbc748","v":1,"via":"run"} Ci-Attestation: {"at":1791854742,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"e0fc8277f27f5efe797856b0956c6e8cac844384103903d31f8fb9d4a48a4819","lane":"rust-test","parents":["6161f0666d81c3fd5bf9d8644a44039d58299a38"],"secs":64,"stamp":"f2fdd9558f3efd1fa3330dd7ce1fe7a9","tree":"e491b7e0aad43f87b98f9f54ca8b8692c5dbc748","v":1,"via":"run"} Ci-Attestation: {"at":1791854742,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"2baf904178cd0711f9792e8a2e6792204bdf510ba3bf5ec4ce186d8a5f120758","lane":"tier2-linux","parents":["6161f0666d81c3fd5bf9d8644a44039d58299a38"],"secs":73,"stamp":"1ec76fb4a267a1895436e7a81eaeb3bc","tree":"e491b7e0aad43f87b98f9f54ca8b8692c5dbc748","v":1,"via":"run"} --------- Co-authored-by: chriscoveries <[email protected]>
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.
Fixes #335.
Ports
libobs/graphics/plane.ctoobs-graphics.ENABLE_RUST_LIBOBSdrops that C file. Header-inline helpers inplane.hstay C. No intentional differences.Commits
a72cb379a: cmockatest_planepins the seven exports, including a normal transformed as a point, a parallel ray miss that writes*t = 0, and a line miss that leaves*tunchanged.e21514a8f: Tier 1 mirrors those cases against an empty plane.test_plane_from_tri_xyfails becausePlane::from_trireturns a zero plane: left(0, 0, 0, 0, 0), right(0, 0, 1, 0, 0). 15 of 17 tests fail.8199c40ab: the safe core, C shims, layout test, and proptest parity.GREEN result
planetests pass. The rest ofobs-graphicspasses.plane_matches_c_oracle(256 cases, any bit pattern) andplane_from_tri_v1_alias_matches_care bit-exact with the C oracle, including thewlane.vec3_crossandvec3_normfollow the header SSE.struct planematches the header.plane_transform'sdistmakesplane_matches_c_oraclefail (transform shimdist724179300000000.0vs C-724179300000000.0). The break was reverted.export_listacceptslibobs/cmake/rust-exports.d/obs-graphics-plane.txt.soldr cargo clippy -p obs-graphics --all-targets -- -D warningsis clean.plane_from_trireads vertices by value, then, whenv1is&dst->dir, setsdisttodir·dir, which is what C does after overwriting that slot.Not run here
Docker is not installed, so Tier 2 cmocka (
test_planeOFF and ON) and the local-gate stamp were not run../lint's clang-format, gersemi, rustfmt, and clippy steps ran; the lane's Python unittest step fails on this machine becausebashandcmakeare not onPATH. Please rebase onto master and stamp if the branch is behind.