Skip to content

obs-source: Port the source size query routing - #2171

Merged
zackees merged 7 commits into
obs-rust:masterfrom
rdoupe:port/source-size
Oct 24, 2026
Merged

zackees merged 7 commits into
obs-rust:masterfrom
rdoupe:port/source-size

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2149

What and why

Ports the size query routing of libobs/obs-source.c.h to rust/obs-source, as a new module size_route, next to color_space (#1990) and conversion_plan (#2113). Every scene item asks obs_source_get_width() and obs_source_get_height() for its source every frame, and the render, filter processing and obs_source_get_base_width()/_height() go through the same get_base_width()/get_base_height(). A wrong route gives a 0-size item (it vanishes) or the wrong axis for a rotated camera, so the characterization pins every route for every combination of inputs and Tier 3 compares them exhaustively. The design is #1990's: C reads the fields into a struct, the core decides, C follows.

Six commits:

  1. Move (behaviour-neutral): the decisions of get_async_width()/_height(), get_base_width()/_height(), get_recurse_width()/_height() and obs_source_get_width()/_height() go to libobs/obs-source-size.c.h, behind two functions declared in the new obs-source-size.h without EXPORT (hidden):

    • obs_source_size_route(struct obs_source_size_node) gives where the base size comes from: TRANSITION, CALLBACK, ASK_TARGET, ASYNC, ASYNC_SWAPPED or ZERO. The node holds info.type, context.data != NULL, the size callback of the axis asked for != NULL, filter_parent != NULL, enabled, async_active and the long async_rotation.
    • obs_source_size_entry(int type, bool has_filters) gives where obs_source_get_width() starts: SELF or FIRST_FILTER.
    • One route serves both axes: get_base_width() reads info.get_width into the node and get_base_height() reads info.get_height. The swapped async route gives async_height for the width and async_width for the height.
    • The rules keep their order and every condition the history added (git log -L on each function): filters count (3510e69), 0 before the first async frame (506e30d), a disabled filter does not answer (f04ef23), transitions (6839ff7), a filter is a source with a filter parent (8a1486d), no callback without data (f1aa71b), the rotation swap (b9d6675), a filter asks itself (ed8998e). The swap keeps the long and C's %. libobs: Keep an async rotation in 0-359 #2136 now keeps the stored rotation in 0-359, but the route takes any long.
    • obs-source.c.h keeps data_valid(), filter_mutex, the recursion, the callbacks and the field each route reads (transition_actual_cx/cy, async_width/height). obs_source_get_width() still takes no lock for a filter, and any other source still holds its filter_mutex while it reads filters.num, asks the start and reads the first filter. get_base_*, get_recurse_* and obs_source_get_width/height keep their names and signatures, so the other callers (the colour space texrender in source_render(), obs_source_process_filter_begin_with_color_space() and obs_source_get_base_width/height()) are unchanged.
    • obs-source.c.h checks at compile time that the header's filter and transition types match obs-source.h and that enum obs_source_type is int-sized.
    • Checked against the unchanged functions. A scratch harness (not committed) compiles origin/master's functions verbatim and the moved ones against a stand-in struct obs_source that logs every data_valid(), lock, unlock and callback in order. 22,528 single sources (8 types × data × both callbacks × a filter parent × enabled × async active × 22 rotations, including the ends of long and of int, with and without one filter) and 2,000,000 random chains (0-4 filters, detached filters, filters with filters of their own, a source that is itself a filter, random 64-bit rotations): 24,096,452 calls of obs_source_get_width/height and get_base_width/height, with the same results and the same event logs. The harness itself reports differences for a swap on % 90, a filter that takes its lock, and a disabled filter that answers.

    The file stays in libobs.core-source for this commit. Exports are unchanged (1766).

  2. Characterization: test_source_size_route_steps, 11 cases. It compiles the moved file (ASan and UBSan) and calls only the two functions:

    • a 128-row table: every combination of the type (input, filter, transition, scene), data, a callback, a filter parent, enabled and async active, at rotation 0, and the same rows at 90 (only the async route turns into the swapped one);
    • the filter type, scenes, -1, 4, INT_MIN and INT_MAX route as an input; a transition gives its actual size while enabled and 0 while not, with any other inputs;
    • the filter chains of test_filter_color_space and test_scene_rotated_scale_filter;
    • the swap for 0, 90, -90, 180, -180, 270, -270, 45 and 360, the rest of 0-359 (1, 179, 181, 359) and raw values (-360, 540, -1); LONG_MIN and LONG_MAX swap on both widths (% 180 is -128 and 127 for a 32-bit long, -8 and 7 for a 64-bit one), and the multiples of 180 next to them do not;
    • the rotation changes no other route;
    • the entry for a filter (with and without filters), an input with and without filters, a transition, a scene and types outside the enum.

    In the native test graph in name order, with libm except on MSVC; messages through fprintf() + fail() (cmocka 1.x and 2.x).

  3. RED: Tier 1 in the crate, against todo!().

  4. GREEN: the safe core and the #[no_mangle] shims, in a new libobs.ported-source-size group whose PCH is the header alone. The export lists, source-sets.json, the unity lists and ci/test_ported_sources.py are updated, and a _rust variant of the characterization is added.

  5. Tier 3: a C oracle (and a second one with a 32-bit long) and parity tests, with the mutation check.

  6. Docs: the README rows, the crate's description and lib.rs, and a port_comparison bench file. docs/rust-port/naming.md already maps libobs/obs-source*.c.h to rust/obs-source.

Kept, characterized, not endorsed:

  • A filter is a source with a filter parent (8a1486d), not one of OBS_SOURCE_TYPE_FILTER. A filter that is not in a chain asks its callback even while disabled, and without one reports its async frame or 0 instead of asking a target. An input with a filter parent routes as a filter.
  • A source with a size callback but no data does not ask it, and reports its async frame or 0. obs_source_get_width() checks data_valid() first, so libobs gets there only through a target or a first filter whose data is gone.

Notes:

  • long. The rotation is c_long in Rust (64 bits on Linux and macOS, 32 on Windows), and the swap is rotation.wrapping_rem(180) != 0. wrapping_rem wraps only for a divisor of -1, so it is % for every rotation. Its sign follows the rotation as C99's % does, but only "is it 0" counts. Tier 1 runs the swap over any i32 (what a Windows long holds) and any i64 that fits c_long. Tier 3 has a second oracle, oracle/source_size_long32.c, that builds the unchanged C file with long remapped to int after the standard headers, as MSVC builds it (clang's -Wkeyword-macro is turned off for that one #define; --lane cross caught it under -Wpedantic). Rotations that fit 32 bits are compared against it too.
  • The _rust variant links the archive alone. test_source_size_route_steps_rust builds the unchanged test source against libobs_rust-static, with libm except on MSVC. The test calls only the two functions and includes only obs-source-size.h, which needs no SIMDe or obsconfig.h, so it needs no libobs include directories. This variant runs the shims and the node's layout.
  • Exported symbols: 1766 on the C backend, the hybrid and libobs-c-reference, with identical sets. obs_source_size_route and obs_source_size_entry are local (t) in all three. In the hybrid they come from the Rust archive, and in the C backend and libobs-c-reference from libobs.ported-source-size+.h.c.
  • Performance (port_comparison, x86_64 Linux, GCC, not pinned, a loaded machine; median per 1024 calls): route 9.21 µs Rust, 10.14 µs C (0.91x); entry 1.59 µs Rust, 1.53 µs C (1.04x). About 9 ns a route either way, within the noise of the run.
  • No intentional differences from C. No user-visible change, so no docs/features.md line.
  • No open PR touches these functions in obs-source.c.h.

Observed, not changed: a filter with a filter parent but no filter target makes get_base_width() recurse into NULL on the ASK_TARGET route. A filter in a source's list has both or neither, but two writers change them outside filter_mutex, and obs_source_get_width() on a filter takes no lock:

  • obs_source_restore_filters() (0fd1238, upstream since 2021) sets each restored filter's filter_parent one iteration before the next one sets its filter_target, outside filter_mutex;
  • obs_source_filter_remove_refless() clears filter_parent and then filter_target after it drops the lock.

A concurrent obs_source_get_width(filter) on a filter that is disabled or has no size callback could read a parent and then a NULL target. Found by reading the code, not reproduced. The port keeps the route as it is: the recursion stays C, and obs_source_process_filter_begin_with_color_space() already checks for a missing target. A fix belongs in its own issue.

RED → GREEN

  • RED commit: f04a52c5c. The same commit was run before the rebases, at 7ff8e67ae and f483b316c, with this result each time. soldr cargo test -p obs-data --test obs-tests-core source::size_route fails 18 of 18, each with "not yet implemented": the 11 ported steps_* cases and the 7 edge_* cases, five of them proptests.
  • GREEN: fda466406. Tier 1 passes 18/18; with Tier 3 (de7e9136d), 24/24, and 10 runs in a row with fresh seeds. Tier 2 ran under a private Xvfb -noreset with dbus-run-session, a fresh HOME, ulimit -c 0 and TMPDIR unset. libobs-c-reference was built with ninja libobs-c-reference before each c-ref run and is newer than the hybrid libobs.
Test C backend hybrid libobs-c-reference
test_source_size_route_steps 11/11 11/11 11/11
test_source_size_route_steps_rust (not built: needs the Rust archive) 11/11 11/11
test_async_rotation_normalize pass pass pass
test_slideshow_size pass pass pass
test_filter_color_space pass pass pass
test_scene_item_crop (and _load; _rust on the hybrid tree) pass pass pass
test_scene_rotated_scale_filter pass pass pass
transition and scene size tests: test_transition_scale_type, test_scene_dup_group_children, test_item_transition_empty_source, test_transition_recursive_destination, test_transition_swap, test_group_recursion, test_group_empty_bounds, test_scroll_filter_wide_source, test_scene_duplicate_scale_ref, test_xshm_resolution_change pass pass pass
focus set total 17/17 19/19 19/19
full ctest 448/448, 0 skipped 463/463, 0 skipped —

Where each run was:

  • Characterization commit (103e060b5, before the rebase): the focus set on the C backend, 17/17, with the C exports at 1766; hybrid and c-ref built at that commit, exports 1766 on all three.
  • GREEN (54aeb5ac2, before the rebase): the focus set on all three, 17/17, 19/19 and 19/19.
  • Head before the rebase (826e82dd0, based on af31b65c9): the full ctest on the C backend (448/448) and the hybrid (463/463), ctest -j8, 0 skipped by ctest, and the focus set again on all three. test_deinterlace_2x_field_order (test_deinterlace_2x_field_order is timing-sensitive (yadif 2x 60i into 60): startup underrun and load-induced hold #456) passed on both lanes the first time.
  • After the first rebase (15c075ba8, based on fe7593249): all three rebuilt, exports 1766 on each, the focus set on all three (17/17, 19/19, 19/19), --lane lint, --lane cross and --test-diff origin/master.
  • After the second rebase (27e4ac735, based on 187d815b3, with obs-output: Port the encoder size and info choices #2148's encoder size port in the shared lists): the same again, all passing; --test-diff ran 3436 tests, 3436 passed and 4 skipped by nextest's own filters.
  • Head (ea5e6ca0f, based on 98fe5f423): obs-c-oracle: Free what port_comparison's fixtures allocate #2159 changed only port_comparison and the oracle's bmem fixtures, with no libobs or crate code, so the builds above stand. On the head: the ci/ checks, clippy on the benches, Tier 1 and 3, --lane lint and --test-diff origin/master (3436 passed, 4 skipped). With obs-c-oracle: Free what port_comparison's fixtures allocate #2159 the port_comparison run gets through every module's fixtures; filtered to source_size, it passes the per-module allocation check and gives route 9.22 µs Rust and 9.19 µs C, entry 1.50 µs Rust and 1.41 µs C, the same as the numbers in the bench file.

The move harness was re-run against the second base (origin/master's obs-source.c.h is unchanged by every commit since the first base): the same 24,096,452 calls, no difference.

  • Real app: N/A. No UI, protocol output or logging change; the real-libobs size tests above cover the caller.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): not applicable, none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): none

Rebased onto master after #2153 and #2157 merged (head d71b90a58). The only conflicts were the obs-source crate lists in rust/README.md, rust/obs-source/Cargo.toml and lib.rs, merged by keeping both entries. After the rebase, soldr cargo test -p obs-data --test obs-tests-core source:: and soldr cargo test -p obs-c-oracle --locked --bench port_comparison (370 benches) pass. The earlier runs above are on the pre-rebase SHAs.

@zackees

zackees commented Oct 24, 2026

Copy link
Copy Markdown
Member

Coordinator fixup (5e3073a): the Windows Rust Tests job failed on clippy, not on a test. On Windows c_long is i32, so i32::try_from(rotation) in check_route (size_route_parity.rs:155) hits useless_conversion and irrefutable_let_patterns. I added a function-level #[allow] with a comment. Linux clippy and fmt pass. Please queue it once Windows is green, or I will.

rdoupe and others added 7 commits October 24, 2026 11:34
Behaviour-neutral extraction before the Rust port. The size query routing
of obs-source.c.h moves to libobs/obs-source-size.c.h, declared in the new
libobs/obs-source-size.h without EXPORT (hidden, as -fvisibility=hidden
keeps it), behind two functions:

- obs_source_size_route() takes the fields of a source in
  struct obs_source_size_node (the type, context.data != NULL, the size
  callback of the axis asked for != NULL, filter_parent != NULL, enabled,
  async_active and the long async_rotation) and gives where
  get_base_width() and get_base_height() take the size from: the
  transition's actual size while enabled, the callback (a filter only
  while enabled), the filter target, the async frame (ASYNC, or
  ASYNC_SWAPPED unless rotation % 180 == 0: get_async_width() and
  get_async_height()) or 0.
- obs_source_size_entry() takes the type and filters.num != 0 and gives
  where obs_source_get_width() and obs_source_get_height() start: a filter
  at itself, any other source at its first filter if it has filters
  (get_recurse_width()), else at itself.

One route serves both axes: obs-source.c.h reads the callback of the axis
into the node and applies the route to the width or the height, the
swapped async route giving async_height for the width and async_width for
the height. The rules keep their order and every condition the history
added: filters count (3510e69), 0 before the first async frame (506e30d),
a disabled filter does not answer (f04ef23), transitions (6839ff7), a
filter is a source with a filter parent (8a1486d), no callback without
data (f1aa71b), the rotation swap (b9d6675), and a filter asks itself
(ed8998e). The swap keeps the long and C's %.

obs-source.c.h keeps data_valid(), filter_mutex (obs_source_get_width()
still takes no lock for a filter and holds a source's filter_mutex while it
reads the filters and asks the start), the recursion into the target and
the first filter, the get_width and get_height callbacks, and the field
each route reads (transition_actual_cx/cy, async_width/height). get_base_*,
get_recurse_* and obs_source_get_width/height keep their names and
signatures, so their other callers (the colour space texrender,
obs_source_process_filter_begin_with_color_space() and
obs_source_get_base_width/height()) are unchanged. obs-source.c.h checks at
compile time that the header's filter and transition types match
obs-source.h and that enum obs_source_type is int-sized.

Checked against the unchanged functions of origin/master (outside the
tree, not committed): both versions compiled against a stand-in struct
obs_source that logs every data_valid(), lock, unlock and callback in
order. 22,528 single sources (8 types, data, both callbacks, a filter
parent, enabled, async active, 22 rotations including the ends of long and
of int, with and without one filter) and 2,000,000 random chains (0-4
filters, detached filters, filters with filters, a source that is itself a
filter, random rotations), 24,096,452 calls of obs_source_get_width/height
and get_base_width/height: the same results and the same event logs. The
harness reports a difference for a swap on % 90, for a filter that takes
its lock and for a disabled filter that answers.

The new file joins libobs.core-source with libobs.pch.h, which includes
the new header. The exported symbol sets are unchanged (1766).

Refs obs-rust#2149
test_source_size_route_steps compiles libobs/obs-source-size.c.h (ASan
and UBSan) and calls only obs_source_size_route() and
obs_source_size_entry(). 11 cases:

- route_every_combination: a 128-row table, every combination of the type
  (an input, a filter, a transition, a scene), data, a size callback, a
  filter parent, enabled and async active, at rotation 0;
  route_every_combination_rotated, the same rows at 90, where only the
  async route turns into the swapped one;
- route_other_types_as_inputs: the filter type, scenes, -1, 4, INT_MIN and
  INT_MAX route as an input (only the transition type has a route of its
  own; a filter is a source with a filter parent);
- route_transition: the actual size while enabled and 0 while not, with
  any data, callback, parent or async;
- route_filter_chains: a filter with a size callback asks it only while
  enabled, a filter without one or without data asks its target, the input
  below asks its callback enabled or not, an async input reports its frame
  (0 before the first one), and a callback wins over the async frame;
- swap_rotations: 0, 90, -90, 180, -180, 270, -270, 45 and 360, the rest of
  0-359 (1, 179, 181, 359) and raw values the setter no longer stores (-360,
  540, -1). The setter normalizes since obs-rust#2136; the route takes any long;
- swap_long_extremes: LONG_MIN and LONG_MAX swap (% 180 is -128 and 127 for
  a 32-bit long, -8 and 7 for a 64-bit one), the multiples of 180 next to
  them do not, and on a 64-bit long the ends of int as well;
- swap_only_when_async: the rotation changes no other route;
- entry_points: a filter starts at itself with or without filters; an
  input, a transition, a scene and types outside the enum start at their
  first filter if they have filters, else at themselves.

Characterized, not endorsed:
- a filter that is not in a chain (no filter parent) asks its callback
  even while disabled, and without one reports its async frame or 0
  instead of asking a target; an input with a filter parent routes as a
  filter (8a1486d made the parent, not the type, the test);
- a source with a callback but no data does not ask it and reports its
  async frame or 0 (obs_source_get_width() checks data_valid() first, so
  libobs gets here only through a target or a first filter whose data is
  gone).

The test is in the native test graph in name order, with libm except on
MSVC, and uses fprintf() and fail() for its messages (cmocka 1.x and 2.x).
On the C backend it passes 11 of 11.

Refs obs-rust#2149
Tests for the port of libobs/obs-source-size.c.h to the size_route module
of rust/obs-source, next to color_space and conversion_plan. The safe core
is a stub (todo!()):

- route(), obs_source_size_route() on plain values: a Node (the type as
  the C's int, data, the size callback of the axis, a filter parent,
  enabled, async active and the rotation as c_long) gives a Route:
  Transition, Callback, AskTarget, Async { swap } or Zero;
- entry(), obs_source_size_entry(): the type and whether the source has
  filters give an Entry, Itself (the C's SELF) or FirstFilter;
- swaps(), the C's rotation % 180 != 0 on its long;
- TYPE_FILTER and TYPE_TRANSITION, the enum obs_source_type values.

tests/source/size_route.rs ports test_source_size_route_steps 1:1: its 11
cases under the same names (steps_*), in the same order, with the same
inputs and expectations, the 128-row table copied unchanged.

Edge cases (edge_*): each route has what it needs over every row, five
types and eight rotations, and the async route's swap is swaps() of the
rotation; the swap is periodic in 180 and matches rem_euclid from -1000 to
1000. Proptests (4000 cases each): the route against a model written as
one match, over any type, any flags and any c_long rotation (half of them
in -720..=720); only the transition type has a route of its own; the entry
against its model; the swap over any i32 (what a 32-bit long, as on
Windows, holds: i32's % and i64's % agree) and any i64 that fits c_long.

soldr cargo test -p obs-data --test obs-tests-core source::size_route
fails 18 of 18 with "not yet implemented".

Refs obs-rust#2149
Ports libobs/obs-source-size.c.h, the size query routing of
obs_source_get_width() and obs_source_get_height(), to the size_route
module of rust/obs-source. obs-source.c.h stays C: data_valid(),
filter_mutex (a filter takes no lock; any other source holds its
filter_mutex while it reads its filters and asks the start), the
recursion into the filter target and the first filter, the get_width and
get_height callbacks, and the fields each route reads. The hybrid libobs
drops the C file and links the Rust shims in its place.

Safe core (src/size_route.rs):
- route(): the C's rules in the C's order. A transition is Transition
  while enabled, else Zero; data and a callback give Callback unless the
  source is a disabled filter (a filter is a source with a filter
  parent); a filter otherwise asks its target; an active async source is
  Async { swap }; anything else is Zero.
- swaps(): rotation.wrapping_rem(180) != 0 on c_long, the C's % on its
  long (wrapping_rem wraps only for a divisor of -1, so it is % for every
  rotation, LONG_MIN and LONG_MAX included).
- entry(): Itself for the filter type, else FirstFilter with filters and
  Itself without.
All three are const fns. The module denies clippy's arithmetic, indexing,
as, unwrap, expect, panic, unimplemented and unreachable lints, keeps no
state and takes no lock.

Shim (src/ffi/source_size.rs): obs_source_size_route() takes
struct obs_source_size_node by value (mirrored, #[repr(C)], the rotation
as c_long) and returns the C's enum, Async { swap } as ASYNC or
ASYNC_SWAPPED; obs_source_size_entry() takes the type and the filters
flag. No intentional differences.

C side: the file leaves libobs.core-source for its own group,
libobs.ported-source-size (LIBOBS_PORTED_SOURCES), whose PCH is the
header alone. libobs.pch.h keeps the header for obs-source.c. The
functions are not EXPORT, so the shims are hidden: rust-hidden.txt, the
local: list of rust-exports.map and rust-unexports-macos.txt. libobs-rust
already links the crate's ffi. The exported symbol sets are unchanged and
equal: 1766 on the C backend, the hybrid and libobs-c-reference; both
functions are local in all three, and the hybrid's come from the Rust
archive. ci/test_ported_sources.py checks the group on every host.

test_source_size_route_steps still compiles the C file into itself,
unchanged. The new test_source_size_route_steps_rust builds the same test
source against libobs_rust-static (and libm except on MSVC): the test
calls only the two functions and includes only their header, which needs
no SIMDe, so this variant runs the shims and the node's layout.
test_async_rotation_normalize, test_slideshow_size,
test_filter_color_space, test_scene_item_crop,
test_scene_rotated_scale_filter and the transition and scene size tests
see the swap through the hybrid.

Tier 1 source::size_route passes 18/18.

Refs obs-rust#2149
Oracle (oracle/source_size.c): the original obs-source-size.c.h,
unmodified, with its two functions renamed to oracle_*, plus the node's
layout (size, alignment, the seven offsets), the enum sizes and every
value the port uses (the six routes, the two starts, the filter and
transition types, sizeof(long) and sizeof(int)). The node is mirrored on
the Rust side.

A second oracle (oracle/source_size_long32.c) builds the same unchanged
file with a 32-bit long, as MSVC builds it: long is remapped to int after
the standard headers and the functions are renamed to oracle32_*. On a
host whose long is 64 bits it shows how the C routes every value a
Windows long holds; on Windows it is the same build as the first.

Tier 3 (tests/source/size_route_parity.rs, 5 tests): both sides take the
same fields through the C ABI and the routes and starts are compared as
integers:
- the layout and the values against the C header, and the 32-bit node's
  size and rotation offset;
- every combination of data, a callback, a filter parent, enabled and
  async active, with 8 types (every enum obs_source_type, -1, 4 and the
  ends of i32) and 46 rotations (the multiples of 45 from -720 to 720, 1,
  -1, 179, 181, 359, the ends of c_long and of i32 and the multiples of
  180 next to them): 11,776 nodes against the C's long, and those whose
  rotation fits 32 bits against the 32-bit build as well;
- the swap of an active async input for every rotation from -100,000 to
  100,000, on both builds (1,111 multiples of 180 not swapped);
- the entry for the 8 types with and without filters, on both builds;
- proptests (20,000 cases each): any node with any c_long rotation
  against the C's long, and any node with any i32 rotation against the
  32-bit build, a fifth of the rotations rounded to a multiple of 180.

Tier 1 and the parity module passed 10 runs in a row with fresh seeds. No
regression file came up.

Mutation check (once, not committed): 26 mutants of the core and the
shim, Tier 1 (18 tests) and Tier 3 (5), failures per mutant. All are
killed but one equivalent mutant.

| Mutant | Tier 1 | Tier 3 |
|---|---|---|
| transition: enabled ignored / rule dropped / after the callback | 5 / 6 / 5 | 3 / 3 / 3 |
| callback without data / without a callback | 7 / 10 | 3 / 4 |
| disabled filter answers / enabled inverted for filters | 7 / 7 | 3 / 3 |
| disabled input does not answer | 6 | 3 |
| filter by type, not by parent | 7 | 3 |
| ask target dropped / async_active ignored | 8 / 9 | 3 / 3 |
| swap on % 90 / % 360 / inverted | 8 / 5 / 12 | 4 / 4 / 4 |
| swap on the low 32 bits of the long | 3 | 2 |
| swap only for 90 and 270 | 6 | 4 |
| swap with rem_euclid (equivalent: only == 0 counts) | 0 | 0 |
| entry: filter type ignored / filters flag inverted | 2 / 2 | 1 / 1 |
| entry: a transition starts at itself | 2 | 1 |
| shim: ASYNC and ASYNC_SWAPPED swapped | 0 | 4 |
| shim: callback read from data / enabled read from async | 0 / 0 | 4 / 3 |
| shim: rotation dropped / ZERO off by one | 0 / 0 | 4 / 4 |
| shim: entry values swapped | 0 | 1 |

Tier 1 does not reach the shim; test_source_size_route_steps_rust does.
The C characterization fails on seven mutants of the C file too (swap on
% 90, a disabled filter answers, the transition ignores enabled,
async_active ignored, the entry ignores the type, a callback without data,
a filter by type).

Refs obs-rust#2149
The rust/README.md crate table now lists libobs/obs-source-size.c.h among
the rust/obs-source units, and its port table has a row for it: the two
functions and their rules, each with the commit that added it, what
stays C (data_valid(), filter_mutex and when it is held, the recursion,
the callbacks and the fields each route reads), the node passed by value,
the rotation as c_long with the C's %, the compile-time checks, what is
kept and characterized (a detached filter answers while disabled; a
callback without data is not asked), the _rust variant of the
characterization, the real-libobs tests and what Tier 3 compares,
including the 32-bit long oracle. The crate's description and lib.rs say
what it holds. docs/rust-port/naming.md already maps
libobs/obs-source*.c.h to rust/obs-source.

port_comparison gets its own bench file,
benches/port_comparison/source_size.rs: 1024 routes (every combination
of the five flags for an input, a filter, a transition and a scene at
eight rotations, the ends of long among them) and 1024 starts, each
folded into a checksum both sides must match. On x86_64 Linux (GCC, not
pinned, a loaded machine; median per 1024 calls): route 9.21 us Rust and
10.14 us C (0.91x), entry 1.59 us Rust and 1.53 us C (1.04x), about 9 ns
a route either way. obs_source_get_width() and obs_source_get_height()
ask about one route per source and filter in the chain for every scene
item every frame.

Fixes obs-rust#2149
@rdoupe
rdoupe added this pull request to the merge queue Oct 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 24, 2026
@zackees

zackees commented Oct 24, 2026

Copy link
Copy Markdown
Member

Coordinator: the queue ejected this for a master breakage, not for this PR. macOS Tier 2 fails to build frontend/utility/obs-main-macos.hpp, which came in with #2170 (reported there). I'll re-queue this once master is fixed.

@zackees
zackees added this pull request to the merge queue Oct 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 24, 2026
@zackees
zackees added this pull request to the merge queue Oct 24, 2026
Merged via the queue into obs-rust:master with commit 3bcdba6 Oct 24, 2026
37 checks passed
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 the source size query routing in obs-source.c to obs-source

2 participants