Skip to content

obs-source: port update_async_textures and its update_async_texrender and upload_raw_frame steps to Rust (Fixes #5948) - #5950

Merged
zackees merged 3 commits into
masterfrom
port/5948-async-textures
Nov 29, 2026
Merged

zackees merged 3 commits into
masterfrom
port/5948-async-textures

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #5948.

This ports update_async_textures() and update_async_texture(), with their steps update_async_texrender(), upload_raw_frame(), select_conversion_technique(), need_linear_output() and set_eparam(), to obs-source, in the shape of #5940 and #5943. obs_source_update_async_video() runs it to upload each async frame (media, cameras, capture cards) into the source's textures, through the GPU conversion texrender when the format needs one; the deinterlace path runs it for its previous frame. Every decision was already Rust (obs-source::async_upload, obs-source::conversion_plan). What moves now is the glue: the source's fields, the frame's planes and colour data and the graphics calls, in order.

What changes

  1. Extraction, no behavior change (libobs: extract update_async_textures and its steps verbatim). The functions move unchanged into libobs/obs-source-async-textures.c.h (live group libobs.core-source). get_convert_type() and enum convert_type stay in obs-source.c.h for set_async_texture_size() and init_gpu_conversion(), later in the group; the new file has a file-local copy spelled with the equal obs-source-conversion-plan.h values, so the moved bodies are byte for byte the removed ones. The new cmocka test_source_async_textures characterizes the upload through the real libobs, one video tick at a time: a plain BGRA frame (no texrender), its flip and linear alpha stored, I420, NV12, Y800 and I010 through the texrender, a limited-range NV12 frame and the range's clamp (Cr 255 drawn as Cr 240; without the range set it draws 228, not 201).
  2. Tier 1, RED: the safe core's Host trait and todo!() steps, with 16 Tier 1 tests over a recording model that fails a test on an end without its begin, a set or draw outside the pass, and a bracket left open.
  3. GREEN: the safe core in obs-source::async_textures, the hidden exports in obs-source::ffi::source_async_textures (rust-hidden.d), one-access adapters in libobs/obs-source-async-textures-fields.c.h, and the original moved to the reference-only group libobs.ported-source-async-textures. The C's two asserts are compiled out of release builds; the Rust does what those builds do. Tier 3 in obs-c-oracle (oracle/source_async_textures.c) runs the original C as release builds compile it against the Rust exports over shared stand-ins for the image upload, debug marker, texrender reset/begin/end, lookups, framebuffer flag, blending, technique and pass calls, sets, levels and draw. Clobbers grow the size, change the frame's format, transfer, range, max_luminance, matrix, flip and flags, flip async_gpu_conversion, repoint textures 1 to 3 and raise the peak level mid-call. It compares the return, the call log, the fields, the frame and every other byte over a grid and a proptest, and rejects fourteen mutants. oracle/source_deinterlace_links.c drops its do-nothing update_async_textures(): the deinterlace shims now reach the Rust export.

No intentional differences from C. The rust/README.md row is added; no user-visible change, so no docs/features.md line.

Evidence

RED, at the RED commit:

soldr cargo test -p obs-data --test obs-tests-core -- async_textures
test result: FAILED. 0 passed; 16 failed; 0 ignored; 0 measured; 7364 filtered out

GREEN, at the head (rebased on master after #5943 merged):

soldr cargo test -p obs-data --test obs-tests-core -- async_textures
test result: ok. 21 passed; 0 failed   (16 Tier 1, 5 Tier 3 incl. grid, proptest, call log, 14 mutants rejected)

soldr cargo test -p obs-studio-rust --test obs-tests-app source_async_textures
test canonical_source_async_textures_swap_is_registered ... ok

Tier 2, test_source_async_textures built and run at the head in the kept linux-validate build volume (graphics runtime dir, xvfb-run -a), against both libraries:

== hybrid libobs   [  PASSED  ] 9 test(s).
== C reference     [  PASSED  ] 9 test(s).

./lint passes.

Test cost

The new Rust tests with OBS_PARITY_CASES=reduced in debug, 20 runs of the filtered binary: longest 56 ms, peak RSS 39 MB; no threads spawned. The new cmocka test takes a few seconds per library.

🤖 Generated with Claude Code

rdoupe and others added 3 commits November 29, 2026 12:20
)

Move update_async_textures(), update_async_texture() and their steps
update_async_texrender(), upload_raw_frame(),
select_conversion_technique(), need_linear_output() and set_eparam()
unchanged out of obs-source.c.h into obs-source-async-textures.c.h (live
group libobs.core-source). get_convert_type() and enum convert_type stay
in obs-source.c.h for set_async_texture_size() and init_gpu_conversion(),
which come later in the group: the new file has a file-local copy of the
function and spells the enum's tag and names as the equal
obs-source-conversion-plan.h values, so the moved bodies are byte for byte
the removed ones.

New cmocka test_source_async_textures characterizes the upload through
the real libobs, one video tick at a time: a plain BGRA frame (no
texrender), its flip and linear alpha stored, I420, NV12, Y800 and I010
through the texrender, a limited range NV12 frame and the range's clamp
(Cr 255 drawn as Cr 240; without the range set it draws 228, not 201).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…5948)

The safe core's Host trait (the frame's flip, flags, format, range,
transfer, max_luminance and colour matrix rows, async_flip,
async_linear_alpha, async_gpu_conversion, async_width and async_height,
the caller's texture array, the image upload, the debug marker, the
texrender reset, begin and end, the conversion effect and its technique
and param lookups, the framebuffer sRGB flag, blending, the technique and
pass calls, the texture, float, vec4 and range sets, the HDR levels, the
HLG exponent and the draw) and todo!() steps, with 16 Tier 1 tests over a
recording model: a plain frame sets the first texture from plane 0 (NULL
included); flip and linear alpha stored first; a converted frame without
a GPU conversion uploads nothing; a GPU conversion without a texrender
takes the plain route; NV12 through the texrender in the C's exact order;
planes 0, 2, 3 and 7 uploaded and only the first four set as images; a
limited range frame setting the range after the vectors; I010's linear
output with the flag restored; the HLG peak clamp and the transfer's
maximum nits; a texrender that does not begin; full-range RGB with no
technique and no upload; the size read after the upload; upload_raw_frame
for no conversion and for planes 0, 1 and 5; and the single-texture
wrapper. The model fails a test on an end without its begin, a set or draw
outside the pass, and a bracket left open. All 16 fail on the todo!()
core.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ixes #5948)

The safe core in obs-source::async_textures, the hidden exports
update_async_textures() and update_async_texture() in
obs-source::ffi::source_async_textures (rust-hidden.d), one-access
adapters in libobs/obs-source-async-textures-fields.c.h (live group
libobs.core-source), and the original moved to the reference-only group
libobs.ported-source-async-textures. Every decision is
obs-source::async_upload and obs-source::conversion_plan; the fields, the
frame's planes and colour data, the effect, the HLG exponent (log10f() in
the C's float operations) and every graphics call stay C. The C's two
asserts are compiled out of release builds; the Rust does what those do.

Tier 3 in obs-c-oracle (oracle/source_async_textures.c) runs the original
C, with the oracle's original upload decisions and conversion plan, as the
release builds compile it, against the Rust exports over shared stand-ins
for the image upload, the debug marker, the texrender reset, begin and
end, the lookups, the framebuffer flag, blending, the technique and pass
calls, the sets, the levels and the draw, over a stand-in core. Clobbers
grow the size, change the frame's format, transfer, range,
max_luminance, matrix, flip and flags, flip async_gpu_conversion,
repoint the source's textures 1 to 3 and raise the peak level 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 fourteen mutants. oracle/source_deinterlace_links.c drops its
do-nothing update_async_textures(): the deinterlace shims now reach the
Rust export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795973492,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":77,"stamp":"5c3e9a7e0cb5e827e401fdd9315e7d1c","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973492,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":77,"stamp":"7996ea90e0532045ad996e645395cd20","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973492,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":77,"stamp":"fcd937b7348afe4f6e3a48e11db0a909","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973492,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":77,"stamp":"7da68f7e74292e8a762a9db6087acc45","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"general/all/client-lint","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"a840d948e57298637673f4a44fdaaaa1","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973492,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":77,"stamp":"4d3c56327427e9ed33406a59ab2b3619","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"707c11f98abaa769851c0789add86c7d","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"3e2c457ec40f8fd4531e8ecb33c41f69","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"a909ed65c4b4dac87afbfe29a9bab1d1","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"3e1891ea05d7d450091aedf5e2a33e78","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"893ec8fd14bfc004bf207833f7ad3ef8","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"65614bb65a066516452094841b914e8f","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"e6595738844db58785794aa07ab13e9e","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"b2342cffd6aa77edee16ff5d49e34ed8","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"948ff34bcf591696b12a251129fc32a7","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"100821e1febd5f29d9b68a315733781d","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"231172fae04124e343063bee8a4a827c","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973414,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"949c89b4a3bed93ba5f644dc23c53aa389c4d14a363baa374de00b71a4773cb4","lane":"client-lint","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":72,"stamp":"8f1c172c44e58fe90546de4713b48021","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}
Ci-Attestation: {"at":1795973827,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"c5c513e49219414ee46f63728bc5e443a9d5950bca2664eb21fa7a975d4a238a","lane":"client-test-x86_64-unknown-linux-gnu","parents":["e1d0021b8ea8b91447e935ba5ff15787278c652e"],"secs":333,"stamp":"58c57b69f91d002d7258d1c312dd6a55","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"38102b21b99733f54f615b896093dee3d43d2d7d","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-async-textures+.h.c","libobs/build/ported-source-sets/source-async-textures.json","libobs/cmake/rust-hidden.d/obs-source-source_async_textures.txt","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_textures_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-async-textures.list","rust/obs-c-oracle/oracle/source_async_textures.c","rust/obs-c-oracle/oracle/source_deinterlace_links.c","rust/obs-source/src/async_textures.rs","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_async_textures.rs","rust/obs-source/src/lib.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_textures.c","test/cmocka/tests.d/test_source_async_textures.cmake"],"head":"f249ed0fd1fd174df36ac16b86f914ee56ee1d09","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":"3610e805d4c42f357b823dc82f998dbf044e3f07bbc9e364923b8d38b0f697f1","tree":"6fb5ee2c2eb3f9a66c6fcc7e37beff0248819364"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 29, 2026 17:37
@rdoupe rdoupe changed the title obs-source: port update_async_textures and its steps to Rust, GREEN (Fixes #5948) obs-source: port update_async_textures and its update_async_texrender and upload_raw_frame steps to Rust (Fixes #5948) Nov 29, 2026

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: LGTM. It has the usual port shape:

  • Base: three commits directly on master (not stacked): a verbatim extraction, then RED, then GREEN.
  • Tests: a new Tier 2 test_source_async_textures.c and Tier 3 async_textures_parity.rs against the oracle.
  • Export: the hidden export goes through rust-hidden.d/obs-source-source_async_textures.txt.
  • Rules: a Test cost line, and no existing C test or public header edited.
  • Windows (#5919): no util_mul_div64 and no wide usize inputs.
  • Status: auto-merge on.

@zackees
zackees enabled auto-merge November 29, 2026 17:50
@zackees
zackees added this pull request to the merge queue Nov 29, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this to In merge queue in obs-rust Multiview Nov 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 29, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 29, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 29, 2026
@zackees
zackees removed this pull request from the merge queue due to a manual request Nov 29, 2026
@zackees
zackees added this pull request to the merge queue Nov 29, 2026
Merged via the queue into master with commit 6c72090 Nov 29, 2026
53 checks passed
@zackees
zackees deleted the port/5948-async-textures branch November 29, 2026 20:41
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In merge queue to Done in obs-rust Multiview Nov 30, 2026
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 update_async_textures and its update_async_texrender and upload_raw_frame steps to obs-source

2 participants