Skip to content

obs-source: port obs_source_set_texcoords_centered to Rust (Fixes #5599) - #5600

Merged
rdoupe merged 4 commits into
masterfrom
port/5599-texcoords-centered-setter
Nov 25, 2026
Merged

rdoupe merged 4 commits into
masterfrom
port/5599-texcoords-centered-setter

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #5599

What changes

obs_source_set_texcoords_centered moves out of libobs/obs-source.c.h into the obs-source crate. It joins obs-source::boolean_queries, next to obs_source_get_texcoords_centered, which is already Rust.

Commits, in order:

  1. 086174ae6 libobs: the body moves verbatim into libobs/obs-source-texcoords-centered-setter.c.h. The file stays in the live libobs.core-source group, so this commit changes no behavior and adds no Rust. The extraction comes before the characterization because the setter is hidden (see below), so the test has to compile this file.
  2. a0f2b1565 test: new cmocka characterization test/cmocka/test_source_texcoords_centered_setter.c on a test-owned struct obs_source.
    • The setter stores centered into texcoords_centered and changes no other byte, whatever the other bytes and the field held before. It never logs.
    • The real libobs getter then answers what was stored and writes nothing.
  3. e39280a87 test: RED. The Tier 1 mirrors run against a todo!() core.
  4. c710c39ae obs-source: GREEN.
    • The safe core is boolean_queries::set_texcoords_centered. The C ABI shim stores a plain bool, without a lock, as the C did. It goes through the texcoords_centered address of the existing obs_source_boolean_query_fields adapter. There is no new adapter symbol, so the standalone link stubs (source-boolean-query-link-stubs.c) need no change.
    • The extracted file moves into the getter's reference-only group, libobs.ported-source-boolean-queries. No new group.
    • A registration test is added in obs-build, and the rust/README row is updated.
    • obs-internal.h (private) gets a comment only.

Hidden, not exported. The issue said to list the name in rust-exports.d/obs-source-source_boolean_queries.txt, but the C setter is declared in obs-internal.h without EXPORT, so neither libobs build exports it. Its name goes into a new libobs/cmake/rust-hidden.d/obs-source-source_boolean_queries.txt instead, and the exports list keeps only the two public getters. The exported-symbol diff of linux-validate is clean. For the same reason, the new cmocka test cannot call the swapped symbol through libobs. It characterizes the C source only, as test_deinterlace_texture_allocation does, and reads back through the exported getter, which is the Rust one in hybrid. The swap itself runs in hybrid through its only caller, render_item() in obs-scene.c.h, which the scene-rendering tests reach.

NULL. The C has no NULL check, so NULL is outside the contract and is not tested. The shim returns before the adapter on NULL, storing and logging nothing. This matches the getter shim and obs_source_set_hidden.

Callers checked before the swap. The only callers are the two render_item() paths in libobs/obs-scene.c.h. No plugin or frontend calls the setter; the win-capture plugins and obs-browser use the getter only. No --wrap= entry, cmocka link-support file or oracle stand-in defines the name, and no test target compiles obs-scene.c.h or obs-source.c.h into itself. Nothing needed a refit.

No public header, existing C test or WebSocket change. No intentional differences. Tier 4 does not apply.

Tests

  • Tier 1 (rust/obs-source/tests/source/boolean_queries.rs):
    • A store sequence from both initial values that leaves the neighbouring fields alone.
    • The getter answering what the setter stored, with the hidden flag holding the opposite value.
  • Tier 2: the new test_source_texcoords_centered_setter, test_source_boolean_queries, and the scene-rendering callers (test_scene_rotated_scale_filter, test_group_empty_bounds, test_main_mix_before_video, test_scene_render_plan_steps[_rust]), on the C reference and on hybrid libobs.
  • Tier 3 (boolean_queries_parity.rs), the original C against the Rust export:
    • Store sequences on twin fixtures with the real layout, every byte filled with 0x00, 0xff or 0x5a. After each store only the centered byte differs from the snapshot, the two fixtures are equal byte for byte, and both getters answer the stored value.
    • The adapter's field address sits at C's offsetof(struct obs_source, texcoords_centered).
    • A proptest over fill, initial flags and store sequences of up to 15 stores.
    • Mutation check: a core that always stores true, and a shim that stores into hidden instead, each fail parity. Both were reverted.
  • export_list (soldr cargo test -p obs-util --lib -- export_list) passes with the new hidden fragment.

Test cost: all boolean_queries modules take 0.02 s together (reduced parity level, debug build). Peak RSS is 21 MB over 20 runs. The tests start no threads of their own.

Evidence

RED (e39280a87):

soldr cargo test -p obs-data --test obs-tests-core -- source::boolean_queries::
test source::boolean_queries::mirrors_c_independent_fields ... ok
test source::boolean_queries::getter_answers_what_was_stored ... FAILED
test source::boolean_queries::set_texcoords_centered_stores_only_the_flag ... FAILED
panicked at rust/obs-source/src/boolean_queries.rs:14:5: not yet implemented: #5599
test result: FAILED. 1 passed; 2 failed; 0 ignored; 0 measured; 6675 filtered out

GREEN (c710c39ae):

soldr cargo test -p obs-data --test obs-tests-core -- source::boolean_queries
test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 6672 filtered out

soldr cargo test -p obs-studio-rust --test obs-tests-app -- canonical_source_texcoords_centered_setter_swap_is_registered canonical_source_boolean_queries_is_registered
test result: ok. 2 passed; 0 failed

soldr cargo test -p obs-util --lib -- export_list
test result: ok. 4 passed; 0 failed

./lint
== lane lint: ok

OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests '^(test_source_texcoords_centered_setter|test_source_boolean_queries|test_scene_rotated_scale_filter|test_group_empty_bounds|test_main_mix_before_video|test_scene_render_plan_steps|test_scene_render_plan_steps_rust)$'
== libobs exported symbols, C vs Rust
== [OFF] ctest: 100% tests passed, 0 tests failed out of 1100
== [OFF] repeat: 100% tests passed, 0 tests failed out of 7
== [ON] ctest: 100% tests passed, 0 tests failed out of 1100
== [ON] repeat: 100% tests passed, 0 tests failed out of 7

./push ran the client lint and host test lanes, and both passed (the optional Swift lane exited 75 and attested nothing). The final commit is not signed, so the PR runs the ordinary selected CI.

🤖 Generated with Claude Code

rdoupe and others added 4 commits November 24, 2026 19:33
Move the body unchanged out of obs-source.c.h into
obs-source-texcoords-centered-setter.c.h, still compiled in the live
core-source group. The setter is hidden (obs-internal.h, no EXPORT), so
the characterization that follows compiles this file into itself. No
Rust, no behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New cmocka test on a test-owned struct obs_source: the setter stores
texcoords_centered and no other byte, whatever the other bytes and the
field held, and logs nothing; the real libobs getter then answers what
was stored and writes nothing. The setter is hidden in libobs, so the
test compiles its extracted C file into itself (C source only, like
test_deinterlace_texture_allocation). NULL is outside the C contract and
is not tested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tier 1 mirrors of test_source_texcoords_centered_setter.c against a
todo!() stub: boolean_queries::set_texcoords_centered.
`soldr cargo test -p obs-data --test obs-tests-core -- source::boolean_queries::`
fails the two new cases with "not yet implemented".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The setter joins boolean_queries beside its already-ported getter. The
shim rejects NULL before the field adapter (storing nothing and logging
nothing) and stores a plain bool through the texcoords address of the
existing obs_source_boolean_query_fields seam, without a lock, as the C
did. No new adapter symbol. The extracted C file moves into the getter's
reference-only group libobs.ported-source-boolean-queries.

The C setter is hidden (obs-internal.h, no EXPORT), so its name goes
into a new rust-hidden.d fragment for the module rather than the
module's rust-exports.d list, which keeps only the two public getters.

Tier 1 passes; Tier 3 compares store sequences on twin filled fixtures
(only the centered byte changes, both fixtures equal, both getters
answer the stored value), the adapter's field offset against the real
header, and proptests, with the original C in the oracle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1795568838,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":94,"stamp":"0636819f5c90f0720c96387354ac9234","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568838,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":94,"stamp":"3636199cf5699c19c2ec364f78f3db30","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568838,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":94,"stamp":"7807830b6982cc8c137b984cee24976f","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568838,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":94,"stamp":"c1186aa0acc2f85015e1c961b38cba04","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"general/all/client-lint","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"357910bf7d9f02aef4a1abcf9d073b50","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568838,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":94,"stamp":"03eaba481d70f6bde84d490774a374a2","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"afb7174c7c1a8362438c24c72aaa5122","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"871852b05989610828dd2dcbcad8be54","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"0927ecc2bbe548a59ac7cf23c4ae4cb9","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"065b74fa5663d7e8a0b8ce91eb2655a2","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"f0580619393b0808385e78b2ae197db7","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"b05775fe90f533763a19061ef6ca3c53","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"8d62f00cc0c60a27c9e948a37c3c7f74","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"a37f801216c0c54f4c5d1da0e058dfca","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"e629e8851dbd93983ff0128f52903803","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"c8a8784cbd9be1015f9bbb09407ed649","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"7b21c7c86be80f902db0edd9cf90ac44","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795568743,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"f789ffbfc648c28d2272b93db0e962e8b093942e9550fb45c6b73e81114f19c4","lane":"client-lint","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":97,"stamp":"52a8af311de5affa760f00392316f365","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}
Ci-Attestation: {"at":1795569031,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"2aad387d9726b508687b83101defae87fe2349e0f34e8d5d08a905f2fc8431c8","lane":"client-test-x86_64-unknown-linux-gnu","parents":["e39280a870411241060528ff7f8883cdf00d185d"],"secs":192,"stamp":"ba017ecfcc0343c1a113a03b87b8cf93","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"4c10a6b5925b1fa6537a218873b5ea10e7fba5b1","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.ported-source-boolean-queries+.h.c","libobs/cmake/rust-hidden.d/obs-source-source_boolean_queries.txt","libobs/obs-internal.h","libobs/obs-source-texcoords-centered-setter.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_texcoords_centered_setter_swap_is_registered.rs","rust/obs-c-oracle/oracle/source_boolean_queries.c","rust/obs-source/src/boolean_queries.rs","rust/obs-source/src/ffi/source_boolean_queries.rs","rust/obs-source/tests/source/boolean_queries.rs","rust/obs-source/tests/source/boolean_queries_parity.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_texcoords_centered_setter.c","test/cmocka/tests.d/test_source_texcoords_centered_setter.cmake"],"head":"0c3af797962a9274f911548d85f128e718a1f422","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504-GITv2.15.4\n   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"9f132feebf96e788d6fe5b1c2a52a297a57cabaea1bc5d0d44cf506a8e99c0f9","tree":"ec1b10c55e15b1ad6c7d954b62539cdcf849d09c"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 25, 2026 01:10
@rdoupe
rdoupe marked this pull request as draft November 25, 2026 01:11
@rdoupe
rdoupe marked this pull request as ready for review November 25, 2026 02:59
@rdoupe
rdoupe added this pull request to the merge queue Nov 25, 2026
@rdoupe
rdoupe removed this pull request from the merge queue due to a manual request Nov 25, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 25, 2026
Merged via the queue into master with commit 966d967 Nov 25, 2026
88 of 90 checks passed
@rdoupe
rdoupe deleted the port/5599-texcoords-centered-setter branch November 25, 2026 06:07
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.

rust: Port obs_source_set_texcoords_centered to obs-source

1 participant