Repository navigation
obs-source: port obs_source_render_async_video and its rotate_async_video and obs_source_draw_texture steps to Rust (Fixes #5941) - #5943
Merged
Conversation
…(Refs #5941) Move obs_source_render_async_video() and its two static steps, rotate_async_video() and obs_source_draw_texture(), out of obs-source.c.h into obs-source-async-render.c.h (live group libobs.core-source), unchanged. obs_source_render_async_video() loses its static inline: obs-source.c.h declares it (no EXPORT) for source_render_video() and the obs_source_skip_video_filter() wrapper, as it does obs_source_update_async_video(). No behavior change. The new test_source_async_render_video characterizes them through the real libobs: a tick callback outputs a frame, the source's own tick takes it, and in the next tick the callback renders the source into a texture on the video thread and reads the pixels back. 12 cases: a BGRA frame of four quadrants drawn as it is; flipped (upside down); rotated 90, 180 and 270 (turned and moved back into the box); rotated 180 and flipped; an inactive source (nothing drawn); an NV12 frame (the GPU conversion's texrender drawn); linear sRGB on (the same opaque colours); and white at half alpha with linear sRGB on, with and without OBS_SOURCE_FRAME_LINEAR_ALPHA (non-linear alpha premultiplies in sRGB: red 128 against 188), and with linear sRGB off (128). After each draw linear sRGB and the framebuffer sRGB flag are what they were. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ED (Refs #5941) The safe core's Host trait (the first texture, async_active and async_textures_stale, the profiler bracket, the source's colour space, the default effect, the current space, gs_get_linear_srgb() and gs_set_linear_srgb(), async_linear_alpha, the SDR white level, the technique and param lookups, the float and texture sets, the technique and pass begin and end, async_rotation, async_width and async_height, the matrix and blend stacks, the blend function, the texrender and its texture, the framebuffer sRGB flag, async_flip and the sprite) and todo!() steps, with 19 Tier 1 tests over a recording model: the first texture drawn in the C's order; no texture, inactive and stale stopping at the flag that fails; flipped (GS_FLIP_V); linear sRGB with and without linear alpha (DrawNonlinearAlpha and the ONE / INVSRCALPHA blend, or Draw); an sRGB source into scRGB (the white level read, white / 80); HDR into SDR (tonemapped with linear sRGB); the framebuffer flag restored; rotated 90 (push, the width and height read twice, the translate and the turn, pop) and 180 with non-linear alpha (the blend popped first); through the texrender, and an empty texrender drawing nothing but closing every bracket; the translate of each quarter turn; the radians as one f32 multiply by the f32 nearest pi / 180; and the draw without a texture, preferring the texrender, and with linear sRGB. The model fails a test on a pop or end without its push or begin. All 19 fail on the todo!() core. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… GREEN (Fixes #5941) The safe core in obs-source::async_render: obs_source_render_async_video() draws only when the first texture is set, async_active is true and async_textures_stale is false; inside the profiler bracket it asks obs-source::draw_plan for linear sRGB, non-linear alpha, the technique and the multiplier (the SDR white level read only into or out of scRGB), sets linear sRGB (restored at the end), the technique and the multiplier, begins the technique and pass 0, pushes the matrix and turns the frame with rotate_async_video() for a non-zero rotation, pushes the blend state and sets ONE / INVSRCALPHA for non-linear alpha, draws with obs_source_draw_texture() (the texrender's texture when there is one, the framebuffer sRGB flag set to linear sRGB and restored, GS_FLIP_V when flipped), and pops and ends in reverse. The hidden export is in obs-source::ffi::source_async_render (rust-hidden.d), with one-access adapters for the fields, the profiler, the effect and every graphics call in libobs/obs-source-async-render-fields.c.h (live group libobs.core-source). The extracted original moves to the reference-only group libobs.ported-source-async-render. Tier 3 in obs-c-oracle runs the original C (with the oracle's original draw decisions) against the Rust export over shared stand-ins of the profiler, the default effect, the current space, linear sRGB, the white level, the lookups, the sets, the technique and pass calls, the matrix and blend stacks, the texrender, the framebuffer flag and the sprite, with clobbers that move the source's space, flip async_linear_alpha, async_flip and linear sRGB, set async_rotation, grow the size and repoint the first texture and the texrender mid-call; it compares the call log (floats as bits, with the stack depths and the technique, pass and profiler state), the fields, the graphics state left and every other byte over a grid and a proptest, and rejects twelve mutants. test_source_async_render_video passes 12/12 against the hybrid and the C reference. No intentional differences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Ci-Attestation: {"at":1795967086,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":76,"stamp":"ff2cdf0bbdb0bd0526582573c4a39cac","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967086,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":76,"stamp":"1370387162620da03febc5f3b0015be9","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967086,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":76,"stamp":"f63ef542415d916d50b97a1a00bf5e9a","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967086,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":76,"stamp":"1f3b7ecfe1eff2cf45f33c7e99304052","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967009,"gate":"general/all/client-lint","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"597f017e85a533a16bf84f12b750ab1e","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967086,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":76,"stamp":"e68c1536838a63c3490ee30241f32826","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967010,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"da9284399d53adcda2c4f48e46fa3979","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967010,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"dd2232d038c4e7ce2cc73ae39c364794","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967009,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"48c95eb43ed2f4dc32103964c52564a1","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967010,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"5506190dbd54b10deb5d21ac4524928f","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967009,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"75bd9fb628dc2de75ec5808508a4c8d6","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967009,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"6b29d09476fb8db4bd99548c5fd6a060","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967010,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"23463eb07c2f7e47a3a03bfd67b70984","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967010,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"b959234e468593ec232fc17bf80b6f61","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967009,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"697048a69ed64627e944d8f9dfd367df","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967009,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"2c9e82ffd04e2e2328ae7cfd4817d68a","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967009,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"30656c0c39a84cebb3cf55b836d14e75","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967009,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"58ce80756a9bbe7b8380583d8c0e0ddd0e63165272a1562069c9824c242d1436","lane":"client-lint","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":165,"stamp":"afd99554a046253d3a2f96ab0cc747f2","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Ci-Attestation: {"at":1795967442,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"f8f3e4d4b2903ab6c6babf9f56c08d188ac82a7b3d3f915790918e484966e246","lane":"client-test-x86_64-unknown-linux-gnu","parents":["d375b92274efede69736e68288074d75f1939412"],"secs":355,"stamp":"f0a97d82ed68798d1f86d2992555440a","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5","v":1,"via":"run"} Client-Checks: {"checks":{"base":"14007d10fc3ad2d59da4f390c54f9909fbc27aea","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-async-render+.h.c","libobs/build/ported-source-sets/source-async-render.json","libobs/cmake/rust-hidden.d/obs-source-source_async_render.txt","libobs/obs-source-async-render-fields.c.h","libobs/obs-source-async-render.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_async_render_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-async-render.list","rust/obs-c-oracle/oracle/source_async_render.c","rust/obs-source/src/async_render.rs","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_async_render.rs","rust/obs-source/src/lib.rs","rust/obs-source/tests/source/async_render.rs","rust/obs-source/tests/source/async_render_parity.rs","rust/obs-source/tests/source/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_async_render_video.c","test/cmocka/tests.d/test_source_async_render_video.cmake"],"head":"e542aa3b5891f264afc238e3639ccb5385d1217f","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":"0e2118a244b13ebba629e7e7fe2d3d4e3b5c1b18d324027ea263300fbd2be02c","tree":"eb6d61062b2828f7f5911c46afd9457962df1bd5"}}
rdoupe
force-pushed
the
port/5941-async-render-video
branch
from
November 29, 2026 15:50
f3a6675 to
0c1b9c1
Compare
Member
|
Coordinator: correction. My rebase push was rejected by its lease because Ryan had already rebased this PR onto master ( |
zackees
reviewed
Nov 29, 2026
zackees
left a comment
Member
There was a problem hiding this comment.
Coordinator review: LGTM. It has the usual port shape:
- Commits: a verbatim extraction, then RED, then GREEN.
- Tests: a new Tier 2
test_source_async_render_video.cand Tier 3async_render_parity.rsagainst the oracle. - Export: the hidden export goes through
rust-hidden.d/obs-source-source_async_render.txt. - 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.
zackees
enabled auto-merge
November 29, 2026 15:51
This was referenced Nov 29, 2026
obs-source: port set_async_texture_size and its init_gpu_conversion step to Rust (Fixes #5951)
#5954
Merged
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 #5941. (Rebased onto master after #5940 merged.)
This ports
obs_source_render_async_video(), with itsrotate_async_video()andobs_source_draw_texture()steps, toobs-source, in the shape of #5930, #5935 and #5940.source_render_video()runs it for every async source (media, cameras, capture cards) to draw the frameobs_source_update_async_video()uploaded, andobs_source_skip_video_filter()runs it for a skipped filter's async target. Every decision in it was already Rust (obs-source::draw_plan: linear sRGB, non-linear alpha, the technique, the white level read and the multiplier, the rotation translate). What moves now is the glue: the source's fields, the profiler bracket and the graphics calls, in order.What changes
libobs: extract obs_source_render_async_video and its steps verbatim). The three functions move unchanged intolibobs/obs-source-async-render.c.h(live grouplibobs.core-source); the function bodies are byte for byte the ones removed fromobs-source.c.h.obs_source_render_async_video()loses itsstatic inline;obs-source.c.hdeclares it (noEXPORT) forsource_render_video()and theobs_source_skip_video_filter()wrapper, as it doesobs_source_update_async_video(). Those two are its only callers, and the two steps have no other caller. The new cmockatest_source_async_render_videocharacterizes it through the real libobs: a tick callback outputs a frame, the source's own tick takes it, and in the next tick the callback renders the source into a texture on the video thread and reads the pixels back. 12 cases: a frame of four quadrants drawn as it is; flipped; rotated 90, 180 and 270; rotated 180 and flipped; inactive (nothing drawn); NV12 (the GPU conversion's texrender drawn); linear sRGB on (the same opaque colours); white at half alpha with linear sRGB on, with and withoutOBS_SOURCE_FRAME_LINEAR_ALPHA(non-linear alpha gives red 128, linear alpha 188), and with linear sRGB off (128). After each draw, linear sRGB and the framebuffer sRGB flag are what they were. No existing cmocka test reached the flip, the texrender or non-linear alpha.Hosttrait andtodo!()steps, with 19 Tier 1 tests over a recording model that fails a test on a pop or end without its push or begin.obs-source::async_render, the hidden export inobs-source::ffi::source_async_render(rust-hidden.d), one-access adapters inlibobs/obs-source-async-render-fields.c.h, and the original moved to the reference-only grouplibobs.ported-source-async-render. Tier 3 inobs-c-oracleruns the original C (with the oracle's original draw decisions) against the Rust export over shared stand-ins for the profiler, the default effect, the current space, linear sRGB, the white level, the technique and param lookups, the sets, the technique and pass calls, the matrix and blend stacks, the texrender's texture, the framebuffer flag and the sprite. Clobbers move the source's space, flipasync_linear_alpha,async_flipand linear sRGB, setasync_rotation, grow the size and repoint the first texture and the texrender mid-call. It compares the call log (floats as bits, with the stack depths and the technique, pass and profiler state), the fields, the graphics state left and every other byte over a grid and a proptest, and rejects twelve mutants.No intentional differences from C. The
rust/README.mdrow is added; no user-visible change, so nodocs/features.mdline.Evidence
RED, at the RED commit:
GREEN, at the head:
Tier 2,
test_source_async_render_videobuilt and run in the kept linux-validate build volume (the graphics runtime dir, underxvfb-run -a), against both libraries:Full Tier 2,
OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests test_source_async_render_videoat the head:The extraction run first failed the NV12 case on both libraries (my frame had no colour matrix, so it converted to black); fixed in the test before the commit.
./lintpasses.Test cost
New Rust tests, each run alone (
--exact, one thread): longest 0.21 s (matches_c_over_the_grid, default cases; 0.09 s forrejects_the_mutants), peak RSS 6.2 MB (matches_c_over_the_gridwithOBS_PARITY_CASES=reduced), no threads spawned. The new cmocka test takes about 3 s per library.🤖 Generated with Claude Code