Repository navigation
obs-source: port obs_source_main_render and obs_source_render_filters to Rust (Fixes #5972) - #5974
Merged
Merged
Conversation
…verbatim (Refs #5972) Move obs_source_render_filters() and obs_source_main_render(), the two static draws obs_source_video_render() makes, and their hidden wrappers obs_source_video_render_render_filters() and obs_source_video_render_main_render() (no EXPORT) unchanged out of obs-source.c.h into obs-source-video-render-draws.c.h (live group libobs.core-source). source_render() stays static in obs-source.c.h and is reached through its existing hidden wrapper obs_source_default_render_source_render(), mapped onto its original name for this file, as obs-source-default-render.c.h does. The other caller of obs_source_main_render(), obs-source.c.h's hidden wrapper for obs_source_skip_video_filter(), now calls obs_source_video_render_main_render(). The video render registration test finds the two wrappers in the new file. No behavior change. The new cmocka test_source_video_render_draws characterizes them through the real libobs, rendering on the test thread inside the graphics context and inside a technique of the solid effect: a plain source draws through obs_source_default_render() with the default effect and the linear sRGB flag cleared, restored afterwards; an sRGB-aware source keeps the flag either way; a custom draw source gets NULL; a filter draws with the current effect, holding one more reference than the chain's, with rendering_filter set on its parent; a source with filters reached as a filter target gets the current effect, not the default one; and a custom draw source without data, reached through a skipped filter, draws nothing and the flag is restored. 6/6 against hybrid and the C reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ilters, RED (Refs #5972) The safe core's Host trait (filter_mutex, filters.array[0], obs_source_get_ref() and obs_source_release(), rendering_filter, obs_source_video_render(), info.output_flags, filter_parent, filters.num, gs_get_linear_srgb() and gs_set_linear_srgb(), obs_source_default_render(), context.data, gs_get_effect() and source_render()) and todo!() steps, with 22 Tier 1 tests over a recording model whose hooks change the source and the graphics state from inside a call. render_filters: the first filter read and referenced under the lock, then drawn with rendering_filter set and the lock free, then released; the reference held while it draws; a filter being destroyed and a NULL first filter passed on as NULL; the first filter read once (a reorder after the unlock changes nothing); rendering_filter cleared after the draw; no other field read. main_render: a plain source through the default render with the flag cleared and restored; an sRGB-aware source leaves the flag alone; a custom draw gets NULL and never asks for the effect; a source with filters gets the current effect (NULL passed on); a filter never reads its filter count; without data nothing is drawn; the default render reads no data; the output flags read once; the route decided before the flag is saved; the data read after the flag is cleared; the effect read right before the draw; the saved flag set back whatever the draw did; and over 64 states at most one draw and the flag restored. soldr cargo test -p obs-data --test obs-tests-core source::video_render_draws test result: FAILED. 0 passed; 22 failed (not yet implemented: obs_source_main_render / obs_source_render_filters) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… to Rust, GREEN (Fixes #5972) The safe core in obs-source::video_render_draws, the two hidden exports obs_source_video_render_render_filters() and obs_source_video_render_main_render() in obs-source::ffi::source_video_render_draws (rust-hidden.d; neither has EXPORT), one-access adapters in libobs/obs-source-video-render-draws-fields.c.h (live group libobs.core-source), and the original moved to the reference-only group libobs.ported-source-video-render-draws. obs_source_skip_video_filter()'s main draw reaches the same export through obs-source.c.h's wrapper. Every decision is obs-source::render_route; filter_mutex, the fields, the references and every call (obs_source_video_render(), obs_source_default_render(), gs_get_linear_srgb(), gs_set_linear_srgb(), gs_get_effect() and source_render(), through its hidden wrapper obs_source_default_render_source_render()) stay C. The first filter is read and referenced under the lock, rendering_filter is set only around its draw, the output flags are read once, filters.num only for a source that is not a filter, context.data only off the default route, and the saved linear sRGB flag is set back. Tier 3 in obs-c-oracle (oracle/source_video_render_draws.c) runs the original C, with the oracle's original route, against the Rust exports on three noise-filled real-layout sources over shared stand-ins of the lock, the reference, the draws, the flag and the effect. Clobbers move another filter to the front from the lock and the unlock, flip rendering_filter from the filter's draw, flip the output flags, filter_parent and filters.num once the flag is read, flip context.data once the flag is cleared or the effect is read, and flip the flag and the output flags from the draws. It compares the log (with the references held and rendering_filter), the references and the flag left and every byte over a grid and a proptest, pins the order from the C's log, checks that every clobber that can reach the C does, and rejects twelve mutants. No intentional differences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Ci-Attestation: {"at":1795999252,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":76,"stamp":"9229610565a589ef4e7afd5a943a1095","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999252,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":76,"stamp":"d9558aca80a6ff2c5908e4d4cb28b9dd","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999252,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":76,"stamp":"2c5bab7fefa9141c12543a7dde711f0b","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999252,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":76,"stamp":"2ae0c207a24d19d6df28ea6c1da34ab6","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"general/all/client-lint","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"dbee3930f58ea9d88826cfb9c6ce6080","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999252,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":76,"stamp":"025b393faba4bd576be302a5043972a6","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"85e9ec1dafa7eeb0420a5ed6be592a23","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"2357adbf2cc4ae56ae78abc3850a4ff9","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"cae5925532b3ca0e672cd5c755e9598b","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"e565d59f6d2be0b10cb84b952415e92c","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"3636f3552e510faefa2d2489c0a8c218","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"2a48e451e7821a9d85bd66dbdb00fcef","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"cdc4b486d54fe9c46118122b41adab30","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"d81b7dfbe6d98dbf4619397e78922522","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"73b655ea8b20cce24ba2eb885a951b34","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"03073ae71a53d7fce98d63051b0eed78","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"aeea27f40cc5bf53059fd9332f0f1389","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999175,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"4b55d162408623736e38873182d606f08e6648f5b3a559167f0748d69bf4425f","lane":"client-lint","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":92,"stamp":"c6236233426780832c96b5013a53f0e0","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Ci-Attestation: {"at":1795999558,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"6d29c2f1963cb57b273f31a1c1997dfe5eba29b3a6f4f44815acffffc6760272","lane":"client-test-x86_64-unknown-linux-gnu","parents":["c0eaecdf0759e2caa969e6e883b5d31e19fca747"],"secs":305,"stamp":"b72c3c81d49f78ffc8850c8413cac2ae","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f","v":1,"via":"run"} Client-Checks: {"checks":{"base":"68c8fae54d6f75f5ba28b4e93419b8762cffe241","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-video-render-draws+.h.c","libobs/build/ported-source-sets/source-video-render-draws.json","libobs/cmake/rust-hidden.d/obs-source-source_video_render_draws.txt","libobs/obs-source-video-render-draws-fields.c.h","libobs/obs-source-video-render-draws.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_video_render_draws_swap_is_registered.rs","rust/obs-build/tests/native/registration/canonical_source_video_render_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-video-render-draws.list","rust/obs-c-oracle/oracle/source_video_render_draws.c","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_video_render_draws.rs","rust/obs-source/src/lib.rs","rust/obs-source/src/video_render_draws.rs","rust/obs-source/tests/source/main.rs","rust/obs-source/tests/source/video_render_draws.rs","rust/obs-source/tests/source/video_render_draws_parity.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_video_render_draws.c","test/cmocka/tests.d/test_source_video_render_draws.cmake"],"head":"cc6c2c54863d3530e4e4417d440ef8711c79f1c6","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":"308f5d4425ce0b6ef038d1353bd53b16d0f53433494803f559c21e0248dd700e","tree":"2e2f14a56f2be5a83767618229d8380c21c2cc3f"}}
zackees
reviewed
Nov 30, 2026
zackees
left a comment
Member
There was a problem hiding this comment.
Coordinator review: LGTM. It has the usual port shape:
- Base: three commits on master: a verbatim extraction, then RED, then GREEN.
- Tests: a new Tier 2
test_source_video_render_draws.cand Tier 3video_render_draws_parity.rsagainst the oracle. - Export: neither function is declared in
obs.h, so therust-hidden.dfragment is right. - Rules: a Test cost line, and no existing C test or public header edited.
- Windows (#5919): no
util_mul_div64and no wideusizeinputs. - Status: auto-merge on.
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 #5972.
This ports
obs_source_render_filters()andobs_source_main_render()toobs-source, in the shape of #5940, #5963 and #5968. They are the two drawsobs_source_video_render()(Rust since #5963) makes, andobs_source_main_render()is also the main draw ofobs_source_skip_video_filter(). Every decision was already Rust (obs-source::render_route, #2208); what moves now is the lock, the field reads in their order, the references and the calls.What changes
libobs: extract obs_source_main_render and obs_source_render_filters verbatim). Both functions and their hidden wrappersobs_source_video_render_render_filters()andobs_source_video_render_main_render()move unchanged intolibobs/obs-source-video-render-draws.c.h(live grouplibobs.core-source).source_render()stays static inobs-source.c.hand is reached through its existing hidden wrapperobs_source_default_render_source_render(), asobs-source-default-render.c.hdoes. The skip filter's wrapper inobs-source.c.hnow callsobs_source_video_render_main_render(). The new cmockatest_source_video_render_drawscharacterizes the routestest_source_video_renderdid not reach, rendering on the test thread inside a technique of the solid effect: a plain source drawn throughobs_source_default_render()with the default effect and the linear sRGB flag cleared, then restored; an sRGB-aware source keeping the flag either way; a custom draw source getting NULL; a filter, and a source with filters reached as a filter target, getting the current effect, not the default one; the filter held with one more reference andrendering_filterset on its parent; and a custom draw source without data, reached through a skipped filter, drawing nothing with the flag restored.Hosttrait andtodo!()steps, with 22 Tier 1 tests over a recording model whose hooks change the source and the graphics state from inside a call.obs-source::video_render_draws, the two hidden exports inobs-source::ffi::source_video_render_draws(rust-hidden.d; neither hasEXPORT), one-access adapters inlibobs/obs-source-video-render-draws-fields.c.h, and the original moved to the reference-only grouplibobs.ported-source-video-render-draws. Tier 3 inobs-c-oracle(oracle/source_video_render_draws.c) runs the original C, with the oracle's original route, against the Rust exports on three noise-filled real-layout sources over shared stand-ins of the lock, the reference, the draws, the flag and the effect. Clobbers move another filter to the front from the lock and the unlock, fliprendering_filterfrom the filter's draw, flip the output flags,filter_parentandfilters.numonce the flag is read, flipcontext.dataonce the flag is cleared or the effect is read, and flip the flag and the output flags from the draws. It compares the log (with the references held andrendering_filter), the references and the flag left and every byte over a grid and a proptest, pins the order from the C's log, checks that each clobber that can reach the C does, and rejects twelve mutants.Consumers checked before the GREEN design:
obs_source_render_filters()had one caller (its wrapper, called by the Rustobs_source_video_render()throughobs-source-video-render-fields.c.h);obs_source_main_render()had two (its wrapper, andobs_source_skip_video_filter_main_render()inobs-source.c.h, which now calls the export). The video render oracle maps both wrappers to its own stand-ins, so it is unchanged.Pinned in Tier 1 and Tier 3:
filter_mutex, and read once (the_first_filter_is_read_once_under_the_lock; theRefAfterUnlockandReleaseRereadsmutants).rendering_filteris set only around the filter's draw (the_filter_draws_with_rendering_filter_set_and_the_lock_free;NoRenderingFilter,RenderingFilterLeftSet), and the reference given back (NoRelease).info.output_flagsis read once (the_output_flags_are_read_once;FlagsReadTwice);filters.numonly for a source that is not a filter, before the flag is saved (a_filter_never_reads_its_filter_count,the_default_route_is_decided_before_the_flag_is_saved;FiltersLate,DefaultIgnoresFilters).context.datais read only off the default route, after the flag is cleared (the_default_render_reads_no_data,the_data_is_read_after_the_flag_is_cleared;DataUnchecked); a custom draw never asks for the effect (EffectForCustom).the_flag_is_set_back_to_what_it_was_before_the_draw,an_srgb_aware_source_leaves_the_flag_alone;RestoresTrue,SrgbIgnored).No intentional differences. The
rust/README.mdrow is added; no user-visible change, so nodocs/features.mdline. No public header, C test or obs-websocket change.Evidence
RED, at the RED commit:
GREEN, at the head:
Tier 2, in the linux-validate build volume (
xvfb-run -a, from the runtime directory), against both libraries:test_source_video_render_draws(new)test_source_video_rendertest_filter_skip_removedtest_filter_color_spacetest_scroll_filter_wide_sourcetest_color_correction_16ftest_darken_transparenttest_scene_rotated_scale_filtertest_texture_rendertest_source_default_renderA mutant of the Rust core (a custom draw given the current effect,
rendering_filternever set) fails 2 of the new test's 6 cases on the hybrid library (custom_draw_source_gets_no_effect,filters_draw_with_the_current_effect) and none on the C reference, so the hybrid runs the Rust exports.OBS_CMOCKA_LINK=false uv run --no-project ci/windows_link_check.pylinks every test binary../lintpasses.Test cost
new tests: longest 0.12 s (the Tier 3 grid at the default level; 0.10 s for the mutant test with
OBS_PARITY_CASES=reduced, debug, filtered binary; all 28 in 0.21 s on one thread), peak RSS 20 MB over 25 runs (the whole test process), no own threads. The new cmocka test takes a few seconds per library.🤖 Generated with Claude Code