Repository navigation
obs-source: port set_async_texture_size and its init_gpu_conversion step to Rust (Fixes #5951) - #5954
Conversation
zackees
left a comment
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_texture_size.cand Tier 3async_texture_size_parity.rsagainst the oracle. - Export: the hidden export goes through
rust-hidden.d/obs-source-source_async_texture_size.txt. - Rules: a Test cost line, and no existing C test or public header edited.
- Windows (#5919): no
util_mul_div64and no wideusizeinputs.
It's stacked on #5950 (base port/5948-async-textures), so I won't queue it yet. Once #5950 lands I'll rebase its three own commits (from f8295eae1) onto master, retarget it, and queue it.
…ep verbatim (Refs #5951) Move set_async_texture_size() and its step init_gpu_conversion() unchanged out of obs-source.c.h into obs-source-async-texture-size.c.h (live group libobs.core-source), with get_convert_type(), enum convert_type and the conversion plan's static asserts: nothing left in obs-source.c.h uses them (the other callers have file-local copies). deinterlacing_enabled() is obs-source.c.h's, which comes later in the group: the new file has a file-local copy under the original name, so the moved bodies are byte for byte the removed ones. The #5948 registration test now finds get_convert_type() in the new file. New cmocka test_source_async_texture_size characterizes the rebuild through the real libobs, one video tick at a time on an unbuffered source, reading the fields, the textures' sizes and formats and async_update_texture on the video thread: a plain BGRA frame (one texture), I420 and NV12 converted on the GPU (a texrender and a texture per plane at the plan's size and format), an unchanged frame keeping the textures, a format, size or transfer change rebuilding them (a texture planted in an unused slot destroyed and left NULL), deinterlacing on (the previous textures and texrender), and a texture too wide to make (the result false). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sion step, RED (Refs #5951) The safe core's Host trait (the frame's size, format, range and transfer, the source's async_width, async_height, async_format, async_full_range and async_trc and their stores, the graphics context, the textures and previous textures, both texrenders, the destroys and creates, convert_video_format(), the converted sizes and formats, the channel count, async_gpu_conversion, deinterlacing_enabled() and set_deinterlace_texture_size()) and todo!() steps, with 14 Tier 1 tests over a recording model: an unchanged frame returns true with only the compare's reads; each of the five values changed alone rebuilds; a plain BGRA frame in the C's exact order (stores, context, every slot and both texrenders destroyed and NULLed, one dynamic texture); I420 and NV12 converted on the GPU (the plan stored, a texrender and a texture per plane); deinterlacing sizing the previous textures inside the context; the result as the first texture's; a texrender that is not made; the channel count read before each texture; the transfer's colour format; NULL slots destroyed as NULL; init_gpu_conversion() alone for a plain frame and a four-plane one; and a frame whose second plan needs no conversion taking the plain route. The model fails a test on a create or destroy outside the graphics context and a context left open. All 14 fail on the todo!() core. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tep to Rust, GREEN (Fixes #5951) The safe core in obs-source::async_texture_size, the hidden export set_async_texture_size() in obs-source::ffi::source_async_texture_size (rust-hidden.d), one-access adapters in libobs/obs-source-async-texture-size-fields.c.h (live group libobs.core-source), and the original moved to the reference-only group libobs.ported-source-async-texture-size. Every decision is obs-source::async_upload and obs-source::conversion_plan; the fields, the frame, the graphics context, convert_video_format(), deinterlacing_enabled(), set_deinterlace_texture_size() and every graphics call stay C. The C's assert is compiled out of release builds; the Rust does what those do. Intentional difference: a channel count above MAX_AV_PLANES (never stored: the plan has at most four) stops the texture loop at the last slot, where the C would write past the arrays. Tier 3 in obs-c-oracle (oracle/source_async_texture_size.c) runs the original C, with the oracle's original upload decisions and conversion plan, as the release builds compile it, against the Rust export over shared stand-ins for the context's enter and leave, the texture and texrender destroys and creates and the deinterlace texture size, over a stand-in core. Clobbers switch the frame's format, grow it, move its transfer and range, move the converted sizes, formats and channel count, toggle the deinterlace mode and repoint or clear the first texture mid-call. It compares the return, the log, the fields, the frame and every other byte over a grid and a proptest, checks one log call for call, and rejects thirteen mutants. oracle/source_deinterlace_links.c drops its do-nothing set_async_texture_size(): the deinterlace shims now reach the Rust export. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Ci-Attestation: {"at":1795977305,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":75,"stamp":"26ff45b380c42ba2e985e39b88eb81dc","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977305,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":75,"stamp":"0f3fdea3bf69b84aaf3886faa98fa3b7","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977305,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":75,"stamp":"68e89ddf63f916e87da495ee1333ab23","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977305,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":75,"stamp":"a7becf73c216fbbc35d401520b215ec1","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977228,"gate":"general/all/client-lint","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"b5a8fdc126b2dbdfb18f0556765ab3dc","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977305,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":75,"stamp":"9e0ec9002689fe6ea1f5b5a06588e1cc","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977229,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"a0b5b60208cbf9549dfb8bb30d639742","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977229,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"1e8d174d619a83e8c325d76678411883","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977228,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"07b80f7c13565cccde95667b0098db77","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977229,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"7cfb8aec8c0050c7e4a5940f3497369d","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977228,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"27867790f5fa4eebc1408ac5e27685e2","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977228,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"947c5049844fb7433cd9c589e531acd9","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977229,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"96498d1a3f1dff84257557524935a9e0","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977229,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"3199cfd105fc0d411eacec610fb2b11d","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977228,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"51f219826991877b0e6512c78f46ae18","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977228,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"d94392d62a65432a4b9eaeaf5a1ca15e","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977228,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"2ffdba55ad73cf39c27c7fa85d3b377a","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977228,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"ae1a1a6aa7b149e87f8e5aa640926ec36af3d65a8e8e09ec8bcd35ece0406870","lane":"client-lint","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":124,"stamp":"16dfcf8a489350908f7cfa16520ebb08","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Ci-Attestation: {"at":1795977627,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"08a5068a41379b7d8c6d09edb6c6f165d39c064f92a6055e6f20a2a15a754e10","lane":"client-test-x86_64-unknown-linux-gnu","parents":["4b6e7b0cc4d7845e56a39cdeb7d529a724815b34"],"secs":321,"stamp":"cc6c924048afbe615998849c8c385157","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3","v":1,"via":"run"} Client-Checks: {"checks":{"base":"a173a79dba3875e332612d951e8a9b7a6f14bb48","coverage":"all-tracked-applicable-files","diff":["docs/features.md","docs/source-profiler.md","frontend/build/frontend-utility-source-profiler-vendor.pch.h","frontend/build/frontend-widgets.pch.hpp","frontend/build/frontend.utility-source-profiler-vendor+.h.c","frontend/build/source-sets.json","frontend/utility/source-profiler-vendor.c.h","frontend/utility/source-profiler-vendor.h","frontend/widgets/OBSBasic.cpp.hpp","libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-async-texture-size+.h.c","libobs/build/libobs.ported-source-async-textures+.h.c","libobs/build/ported-source-sets/source-async-texture-size.json","libobs/build/ported-source-sets/source-async-textures.json","libobs/cmake/rust-hidden.d/obs-source-source_async_texture_size.txt","libobs/cmake/rust-hidden.d/obs-source-source_async_textures.txt","libobs/obs-source-async-texture-size-fields.c.h","libobs/obs-source-async-texture-size.c.h","libobs/obs-source-async-textures-fields.c.h","libobs/obs-source-async-textures.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_texture_size_swap_is_registered.rs","rust/obs-build/tests/native/registration/canonical_source_async_textures_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-async-texture-size.list","rust/obs-c-oracle/oracle.d/source-async-textures.list","rust/obs-c-oracle/oracle/source_async_texture_size.c","rust/obs-c-oracle/oracle/source_async_textures.c","rust/obs-c-oracle/oracle/source_deinterlace_links.c","rust/obs-source/src/async_texture_size.rs","rust/obs-source/src/async_textures.rs","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_async_texture_size.rs","rust/obs-source/src/ffi/source_async_textures.rs","rust/obs-source/src/lib.rs","rust/obs-source/tests/source/async_texture_size.rs","rust/obs-source/tests/source/async_texture_size_parity.rs","rust/obs-source/tests/source/async_textures.rs","rust/obs-source/tests/source/async_textures_parity.rs","rust/obs-source/tests/source/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_async_texture_size.c","test/cmocka/test_source_async_textures.c","test/cmocka/test_source_profiler_vendor.c","test/cmocka/tests.d/test_source_async_texture_size.cmake","test/cmocka/tests.d/test_source_async_textures.cmake","test/websocket-tier4/README.md","test/websocket-tier4/run_tier4.py"],"head":"74bd3c0e4cc1d02856b4d84ca7ee67289f7fb6ce","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":"376cf517dccbd654bf49107f0723884548cbe1a0fa9fcd0cc34b0b31c9dbc0fe","tree":"3a976cb777c196eff5afaa9ea844dc12604cc5c3"}}
00d7e84 to
e62ed8c
Compare
|
Coordinator rebase: #5950 landed squashed, and GitHub retargeted this to master, so it was DIRTY. I rebased only its own three commits (extraction, RED and GREEN, from |
Fixes #5951.
Stacked on #5950 (the previous unit,
update_async_textures()); the base switches to master once that merges.This ports
set_async_texture_size()and its static stepinit_gpu_conversion()toobs-source, in the shape of #5943 and #5950.async_tick(), the deinterlace update,obs_source_set_video_frame_internal()andobs_source_show_preloaded_video()run it to decide whether an async frame (media, cameras, capture cards) needs new textures, and rebuild them: one plain texture, or the GPU conversion's texrender and a texture per converted plane. Every decision was already Rust (obs-source::async_upload:texture_changed,tries_gpu;obs-source::conversion_plan: the convert type, the plane sizes and formats). What moves now is the glue: the source's fields and the graphics calls, in order.What changes
libobs: extract set_async_texture_size and its init_gpu_conversion step verbatim). The functions move unchanged intolibobs/obs-source-async-texture-size.c.h(live grouplibobs.core-source), withget_convert_type(),enum convert_typeand the conversion plan's static asserts: nothing left inobs-source.c.huses them (the other callers have file-local copies).deinterlacing_enabled()comes later in the group, so the new file has a file-local copy under the original name and the moved bodies are byte for byte the removed ones. The rust: port update_async_textures and its update_async_texrender and upload_raw_frame steps to obs-source #5948 registration test now looks forget_convert_type()in the new file. The new cmockatest_source_async_texture_sizecharacterizes the rebuild through the real libobs, one video tick at a time on an unbuffered source, reading the fields, the textures' sizes and formats andasync_update_textureon the video thread: a plain BGRA frame (one texture), I420 and NV12 converted on the GPU (a texrender and a texture per plane at the plan's size and format), an unchanged frame keeping the textures, a format, size or transfer change rebuilding them (a texture planted in an unused slot is destroyed and left NULL), deinterlacing on (the previous textures and texrender, plain and converted), and a texture too wide to make (the result false).Hosttrait andtodo!()steps, with 14 Tier 1 tests over a recording model that fails a test on a create or destroy outside the graphics context and a context left open.obs-source::async_texture_size, the hidden export inobs-source::ffi::source_async_texture_size(rust-hidden.d), one-access adapters inlibobs/obs-source-async-texture-size-fields.c.h, and the original moved to the reference-only grouplibobs.ported-source-async-texture-size. The C's assert is compiled out of release builds; the Rust does what those builds do. Tier 3 inobs-c-oracle(oracle/source_async_texture_size.c) runs the original C as release builds compile it against the Rust export over shared stand-ins for the context's enter and leave, the texture and texrender destroys and creates and the deinterlace texture size. Clobbers switch the frame's format, grow it, move its transfer and range, move the converted sizes, formats and channel count, toggle the deinterlace mode and repoint or clear the first texture mid-call. It compares the return, the call log, the fields, the frame and every other byte over a grid and a proptest, checks one log call for call, and rejects thirteen mutants.oracle/source_deinterlace_links.cdrops its do-nothingset_async_texture_size(): the deinterlace shims now reach the Rust export.One intentional difference from C: a channel count above
MAX_AV_PLANES(never stored: the plan has at most four) stops the texture loop at the last slot, where the C would write past the source's arrays. Therust/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_texture_sizebuilt and run in the kept linux-validate build volume (graphics runtime dir,xvfb-run -a), against both libraries, at the extraction commit and again at the head:At the head the hybrid
libobs.soholds the Rust core (obs_source::async_texture_sizesymbols, none in the reference), and the reference'sset_async_texture_sizecalls the C plan and compare.ci/windows_link_check.py(category binaries,OBS_CMOCKA_LINK=false) links, and the wholeobs-tests-corebinary passes, including the obs-source-seam deinterlace tests that now reach the Rust export../lintpasses.Test cost
new tests: longest 0.07 s wall for all 20 together (
OBS_PARITY_CASES=reduced, debug, filtered binary), peak RSS 28 MB over 20 runs, no own threads. The new cmocka test takes a few seconds per library.🤖 Generated with Claude Code