Repository navigation
obs-scene: Port the group content extent - #1922
Merged
Merged
Conversation
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 23, 2026
rdoupe
force-pushed
the
port/scene-extent
branch
2 times, most recently
from
October 23, 2026 10:56
2030806 to
e4f4be9
Compare
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 23, 2026
rdoupe
force-pushed
the
port/scene-extent
branch
from
October 23, 2026 11:58
e4f4be9 to
1bd329d
Compare
zackees
enabled auto-merge
October 23, 2026 12:11
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 23, 2026
The min/max fold over the four corners of each item's box transform and the size step of resize_scene_base now live in obs-scene-extent.c.h, behind obs_scene_extent_init(), obs_scene_extent_add() and obs_scene_extent_size(). They are declared in obs-scene-extent.h without EXPORT. The scene still walks its items, still shifts the children so the content starts at the origin, and resize_scene and resize_group are unchanged. Same behavior. obs_scene_size_from_extent(), the static inline from obs-rust#1840, moves with them into obs-scene-extent.h, which obs-scene.h now includes, so its users see it as before. The new file then needs no core header (not obs-scene.h, whose structs need the pthread types), and a test or the oracle can compile it on its own on every platform. Refs obs-rust#1919
The symbols are not exported, so the test compiles obs-scene-extent.c.h and pins what it does today: one item, several, a rotated one (the corners, not the box), a fractional extent rounded up, the empty fold, NaN, the infinities and out-of-range sizes. The fold starts at M_INFINITE, which is 3.4e38 and not infinity, so an item at +inf or -inf alone is UINT32_MAX wide, and one wholly past 3.4e38 leaves the start value in place. A NaN corner fails both compares and is skipped. A tie keeps the value already there, so -0 and +0 keep the first. No display. Refs obs-rust#1919
Tier 1 mirrors test_group_extent case for case, and adds the size step on its own, a NaN in the y column, an infinite z row, and the ties of -0 and +0 on the min side and on y. The core is still todo, so all 15 cases panic: not yet implemented. Refs obs-rust#1919
The safe core matches obs-scene-extent.c.h: the fold starts at M_INFINITE, takes the four corners of each box transform through vec3_transform's sum order, and keeps the C's strict < and >, so a NaN corner is skipped and a tie keeps the first value. The size is max - min rounded up and saturated as obs_scene_size_from_extent does. The three shims stay hidden. The scene still walks its items, still shifts the children with update_item_transform, and resize_scene and resize_group stay C. The C file moves to libobs.ported-scene-extent with its own PCH. obs-scene gains no dependency. Tier 1 scene::extent is 15/15. Refs obs-rust#1919
The oracle is obs-scene-extent.c.h, unmodified, with its three functions renamed and vec3_transform taken from the graphics oracle. Each run starts the fold, adds every item and sizes it on both sides, and compares min and max after every add bit for bit, then the scale bit for bit and cx and cy. The proptests cover lists of up to 8 matrices with finite, huge, NaN, infinite, M_INFINITE, 2^32 and any-bit entries, box transforms as the scene builds them, matrices of only 0, -0, 1 and -1 (so -0 and +0 corners tie), and the add and size shims from any state. Breaking the core: f32::min/max for the compares, <= on the min, >= on the max, an infinite start, three corners, y compared against x, round for ceil, saturating one step early, a swapped scale and a plain product for the C's dot each fail parity. Dropping the NaN check in the size survives: Rust's `as u32` gives 0 for NaN, the same value. Reverted. No intentional differences. Refs obs-rust#1919
rust/README.md: the obs-scene layout row names
libobs/obs-scene-extent.c.h, and its row of the ported table gives the
swap, what stays in obs-scene.c.h, what C passes in, the compares the
fold keeps, the behavior kept from the characterization and what Tier 3
compares. No intentional differences. The naming.md row
(libobs/obs-scene*.c.h) already covers the file.
port_comparison: scene_extent/fold/{1,16}, shim against oracle, in
benches/port_comparison/scene.rs: start the fold, add 1 or 16 turned
boxes, size it. Pinned to one core, the medians are 10.3 ns (Rust)
against 71.7 ns (C) for one item, and 55.5 ns against 1.02 us for 16.
The C calls vec3_transform out of line for every corner, with its
transpose; the Rust core has the four dots inline. It runs once per
group or scene resize.
Fixes obs-rust#1919
rdoupe
force-pushed
the
port/scene-extent
branch
from
October 23, 2026 12:48
1bd329d to
4acaae6
Compare
This was referenced Oct 23, 2026
Member
|
@rdoupe flaky test from this PR, now on master. This assertion is inside proptest's float range sampler, so it fires for some float range strategies (for example a range that is tiny or close to the f32/f64 limits), whatever the code under test does. A range strategy with sane bounds would avoid it. It ejected #1929 from the queue. |
This was referenced Oct 23, 2026
Closed
Collaborator
Author
MCPVOT
pushed a commit
to MCPVOT/obs-studio
that referenced
this pull request
Oct 30, 2026
…-rust#1997) (obs-rust#2554) * test: require the port_comparison units to be discovered, not listed (obs-rust#1997) RED: the ci test demanded the hand-kept `#[path] mod` lines and the `modules![...]` call in `port_comparison.rs` stay sorted. It now fails if either list exists and requires the two generated includes instead. `uv run -m unittest discover -s ci -p test_sorted_shared_lists.py`: test_port_comparison_units_are_discovered FAILs, assertNotRegex matched `#[path = "port_comparison/audio.rs"]`. * build: Generate the port_comparison unit list from the directory (obs-rust#1997) GREEN: build.rs enumerates benches/port_comparison/*.rs and writes the #[path] module lines and the run_units() call list into OUT_DIR, so a port adds its own file and edits nothing shared. That was the last hand-kept list every port appended to; two ports on one file collided in the merge queue (obs-rust#1922 vs obs-rust#1928, obs-rust#1929 vs obs-rust#1922). The file stem is the module name, so core.rs becomes core_units.rs (a `mod core` at the crate root would make the units' `use core::ffi` paths ambiguous). Absolute #[path] rather than `mod x { include!() }` because the units open with //! inner docs, which include! cannot carry. Verified: `soldr cargo check -p obs-c-oracle --benches` is clean, and a throwaway zzz_probe.rs appeared in the generated run_units() and compiled with no edit to a shared file. ci/test_sorted_shared_lists.py passes.
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 #1919
What and why
This PR ports the content extent of a scene or group, the min/max fold in
resize_scene_base(libobs/obs-scene.c.h), to a newextentmodule ofrust/obs-scene. Every time a group or scene is resized, the fold takes the four corners of each item's box transform and gives the extent that the group's size and its children's shift come from. The saturating size cast it ends with landed first in #1840.What stays C: the item loops in
resize_scene_base, the child shift (it callsupdate_item_transform),resize_sceneandresize_group. The hybrid libobs drops the C fold and links the Rust shims in its place.Move (
libobs: Move the scene content extent out, no behaviour change):libobs/obs-scene-extent.c.h, behindobs_scene_extent_init(),obs_scene_extent_add()(one item'sbox_transform) andobs_scene_extent_size(). They are declared inobs-scene-extent.hwithoutEXPORT.obs_scene_size_from_extent(), the static inline from libobs: Clamp loaded scene item crops and saturate the crop and group size casts #1840, moves with them fromobs-scene.hintoobs-scene-extent.h, andobs-scene.hincludes that header, sotest_scene_crop_stepsand the scene see it as before. Without this move the new file would needobs-scene.h, whose structs usepthread_mutex_t. That compiles on glibc only by accident and not under MSVC, so the C test and the oracle could not build the file on its own.vec3.hand its header, no core header).Characterization (
test_group_extent, 10 cases): one item, several, a rotated item (the extent comes from the corners, not the box), a fractional extent rounded up, the empty fold, NaN, ±inf, items past the start values, out-of-range sizes, and ties.M_INFINITE, which is 3.4e38 and not infinity. So an item at +inf or -inf on its own isUINT32_MAXwide (inf - 3.4e38). An item wholly past 3.4e38 leaves the start value in place. The empty fold is -inf wide, which gives 0. Characterized, not endorsed.0 * NaNis NaN). The<and>compares are false for NaN, so the fold skips the item on that axis. An infinitely wide item isUINT32_MAXwide (its corners are NaN and +inf).test_scene_group_transform. It is registered intest/cmocka/build/test-graph.json(core suite). It uses noassert_in_range, and its helpers avoid the names that cmocka 2.x'sexpect_*macros take.Safe core (
src/extent.rs):init() -> Extent,add(&mut Extent, &Matrix4)(one call per item, so no array is built) andsize(&Extent) -> Size { scale, cx, cy }, plussize_from_extent(f32) -> u32.group_transform::transform_val, which isvec3_transform's sum order and already parity-checked, so this object does not call intoobs-graphics.<and>, notf32::min/f32::max. A NaN corner is skipped, and a ±0 tie keeps the first value. Nounsafe.Shim (
src/ffi/scene_extent.rs): the three functions, with the C signatures. Each reads its inputs, then writes its outputs. C passes&item->box_transform, so no item field is mirrored.obs-scenegains noobs-utilorobs-datadependency (the_rustlink pitfall from obs-scene: Port the scene audio action ramp core #1842).test_scene_bounds_place_ruststill links and passes against the staticlib.C side:
obs-scene-extent.c.his in its own group,libobs.ported-scene-extent, listed underLIBOBS_PORTED_SOURCESinsource-sets.json. Its PCH islibobs-ported-scene-extent.pch.h.ci/test_ported_sources.pychecks the group on Linux, Windows and macOS, and checks thatobs-scene.c.hstays in production.Symbols: the three shims are listed in
rust-hidden.txt, in thelocal:list ofrust-exports.mapand inrust-unexports-macos.txt.nmshows them as local (t) in the hybrid libobs. The exported symbol sets are unchanged: 1766 in all three libraries.Oracle (
oracle/scene_extent.c): the original file, unmodified, with the three functions renamed tooracle_*.vec3_transformcomes from the graphics oracle, as inscene_group_transform.c.Docs:
rust/README.mdrows (crate table and port table) and the crate's Cargodescriptionare updated.docs/rust-port/naming.mdrow (libobs/obs-scene*.c.h) already covers the file.docs/features.mdline: there is no user-visible change.port_comparison:
scene_extent/fold/{1,16}, shim against oracle (start the fold, add 1 or 16 turned boxes, size it). Pinned to one core, the medians are:The C calls
vec3_transformout of line for every corner, with its transpose. The Rust core has the four dots inline. The fold runs once per group or scene resize.No intentional differences. Since #1840, every input has defined C behaviour, so the parity test excludes nothing.
test_group_child_drift(#9298),test_group_empty_bounds(#388/#4245),test_scene_group_transformandtest_scene_dup_group_childrenlinkOBS::libobs. In the hybrid libobs they run the Rust fold through real groups.RED → GREEN
b5449cfc6obs-scene: Add the scene content extent tests. The core istodo!().soldr cargo test -p obs-data --test obs-tests-core scene::extentfails all 15 cases (0 passed, 15 failed, "not yet implemented").tests/scene/extent.rs) mirrorstest_group_extentcase for case, under the same names, with the same matrices and expectations.test_scene_crop_stepspins);0 * inf;obs-tests-core. No new test binary.390b976e5obs-scene: Port the scene content extent.scene::extentpasses 15/15.cfc83bab9obs-scene: Check the scene content extent port against the C(tests/scene/extent_parity.rs).What is compared. Both sides run init, each add, then size. Min and max must be bit-equal after every add (-0 is not +0, and a start value must stay exactly where the C leaves it). Then the scale must be bit-equal, the default NaN of
inf - infincluded, andcxandcyequal.Runs:
f32::MAX), ±0, ±1, NaN, ±inf, ±M_INFINITE, 2^32 and its neighbour below, or any bit pattern;Excluded: only one thing. With both min and max NaN on an axis,
max - minmay carry either NaN's payload (the compiler orders the operands), so that one case compares as "both NaN". The fold itself never stores a NaN.Mutation check (done once, not committed): 10 of 11 mutants fail Tier 3, and most fail Tier 1 too:
f32::min/f32::maxfor the compares;<=on the min;>=on the max;roundforceil;The first run showed that
>=on the max passed both tiers and<=on the min passed Tier 3, because random corners almost never tie at ±0. The 0/±1 proptest and a y-tie Tier 1 case were added for them, and both mutants then fail. The one survivor is equivalent: dropping the NaN check in the size, where Rust'sNaN as u32is 0, the same value.28a561ade:OBS_LIBOBS_BACKEND=C, andHYBRIDwithOBS_BUILD_C_REFERENCE=ON. Headless: private Xvfb with-noreset, private D-Bus, fresh HOME.c65fffd77thenc9a6cce13(obs-core: Port util/source-profiler.c #1887),088d9cff7(obs-output: port the obs-service lifecycle, references and activation (#1920) #1923) and739a3c0f2(obs-media-io: Port media-io/media-remux.c.h #1928, test: fix the source_profiler_parity race (#1930) #1931); the conflicts were only inCargo.lock,rust/README.md, the oracle'sCargo.tomlandbenches/port_comparison.rs. After the rebase,ci/test_build_groups.py,ci/test_ported_sources.py,scene::extent(22/22) and the lint lane were re-run and pass.-R 'scene|group')OBS_LIBOBS_BACKEND=CHYBRID,OBS_BUILD_C_REFERENCE=ONHYBRID,OBS_BUILD_C_REFERENCE=ONtest_scene_bounds_place_rust.test_group_extent10/10,test_group_child_drift,test_group_empty_bounds,test_scene_group_transform,test_scene_dup_group_childrenandtest_scene_crop_stepspass on all three libraries. The move commit on its own also passes them on the C lane.soldr cargo test -p obs-data --test obs-tests-corepasses 933/933, 22 of them new (15 Tier 1, 7 Tier 3).soldr cargo bench -p obs-c-oracle --bench port_comparison -- --test scene_extentpasses.uv run ci/local_gate.py --lane lintpassed, and--lane crosspassed.ci/test_build_groups.py,ci/test_ported_sources.py,ci/test_rust_scope.py,ci/test_ci_scope.pyandci/test_binary_cap.pypass. Theexport_listtests pass.Windows/macOS: not built there. The core and the shim have no host conditional. The new file and its test now need no pthread type.
Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag change)