Skip to content

obs-source: Port the async upload parameters - #2342

Merged
rdoupe merged 6 commits into
obs-rust:masterfrom
rdoupe:port/async-upload
Oct 25, 2026
Merged

rdoupe merged 6 commits into
obs-rust:masterfrom
rdoupe:port/async-upload

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2336

What and why

Ports the async video upload decisions of libobs/obs-source.c.h to rust/obs-source, as a new module async_upload next to conversion_plan and frame_copy. Every async source (media, cameras, capture cards, PipeWire) runs these once for each frame it shows:

  • set_async_texture_size(): the five-field compare (width, height, format, full range, transfer) that rebuilds the textures, and whether the rebuild tries a GPU conversion or makes one plain texture;
  • update_async_texrender(): the shader parameters of the conversion draw: width, height, width_d2, height_d2, width_x2_i, height_x2_i, the HLG peak clamp at 1000 (BT.2408), maximum_over_sdr_white_nits (the HLG peak or 10000, over the SDR white level), hdr_lw, and whether the colour range is set (limited range only);
  • update_async_textures(): the linear alpha flag, and the route: the texrender, one plain upload, or neither;
  • check_to_swap_bgrx_bgra(): the format a BGRX or BGRA texture is recreated with;
  • obs_source_update_async_video(): the timing re-anchor rule (!async_decoupled || !async_unbuffered).

The plan's API was split further. The plan sketched uniforms(in) -> Uniforms and a three-way upload_route(). A single uniforms call would need every level before the first set_eparam(), which moves the white level and HDR peak reads ahead of gs_* calls. A three-way route would call get_convert_type() on the texrender route too. So there are fourteen functions, and each read and call stays where it was:

  • obs->video.hdr_nominal_peak_level is still read directly, after height_x2_i is set. obs_get_video_sdr_white_level() is read just before maximum_over_sdr_white_nits, and obs_get_video_hdr_nominal_peak_level() just before hdr_lmax. All three are read only after gs_texrender_begin() succeeds. These are the two different reads the plan names, and both stay.
  • log10f() and the HLG exponent stay C (hlg_exponent from the clamped peak).
  • get_convert_type() is called only off the texrender route, and init_gpu_conversion() only for a convert type that tries it.
  • async_unbuffered is set without a lock, so it is read only for a decoupled source, as the short-circuit did (obs_source_async_upload_reanchor_reads_unbuffered()).

The functions:

  • the compare and rebuild: obs_source_async_upload_texture_changed() and _tries_gpu();
  • the uniforms: _size_uniforms(), _hlg_peak(), _maximum_nits(), _over_sdr_white(), _hdr_lw() and _sets_range();
  • the route: _linear_alpha(), _uses_texrender() and _plain();
  • the swap: _bgr_swap();
  • the re-anchor: _reanchor_reads_unbuffered() and _reanchor().

Two structs (obs_source_async_upload_format, obs_source_async_upload_size) cross by value.

Every gs_* call stays in obs-source.c.h, in its order and under its condition: the context, the texture and texrender destroys and creates, gs_texrender_begin(), each gs_effect_get_param_by_name() and gs_effect_set_*(), gs_draw(), the sRGB and blending state. The frame get and release stay there too.

Floats are bit-equal to the C. Each uniform is one f32 operation, the same IEEE operation in the same order: (float)cx * 0.5f, 0.5f / (float)cx and maximum_nits / sdr_white_level. The size converts as (float)uint32_t does (nearest, ties to even). There is no f64 intermediate, and Rust never contracts into a fused multiply-add. The HLG clamp keeps the C's >, so a NaN is kept with its payload and sign. This is checked on x86_64 and in the Windows MSVC clippy and cross lanes.

MSVC x64: there is no division by a sample rate and no integer division at all. Nothing reaches util_mul_div64()/_udiv128() or INT_MIN / -1, so no input can trap and nothing is guarded.

Six commits:

  1. Move (behaviour-neutral, a1e6a7cd2): the decisions go to libobs/obs-source-async-upload.c.h, declared in the new obs-source-async-upload.h without EXPORT, so they are hidden.

    The move was checked against the original code. A scratch harness (not committed) compiles origin/master's functions and their helpers verbatim, next to this branch's and the moved file:

    • the functions: set_async_texture_size(), update_async_texrender(), update_async_textures(), update_async_texture(), check_to_swap_bgrx_bgra() and obs_source_update_async_video();
    • a script rewrites every field access of the source, the frame and obs->video into a logging accessor that records the value;
    • the log records, in order: every gs_* call and its arguments (the float uniforms as bits), the levels, log10f(), get_convert_type(), init_gpu_conversion(), the conversion plan, the frame get and release, and the asserts;
    • the stubs answer from one seeded stream in call order: texrender begin, texture creation, colour formats, and levels as any bit pattern or 80, 300, 480, 1000, 1001 and 10000;
    • async_decoupled and async_unbuffered return the field, or a new value on each read.

    150,000,000 random states: 50,000,000 each with GCC and Clang at -O2, 20,000,000 each at -O0, and 5,000,000 each under ASan and UBSan (GCC -O0, Clang -O2). All 4,532,576,563 events match, as do the final state and the return value, after one normalization:

    • the field reads inside the compare are dropped (the branch reads all ten, master a prefix);
    • so is frame->format inside the BGR swap (the branch reads it for any texture format);
    • the compare must read each of the ten fields exactly once and make no call or write.

    25 deliberately broken moves were tried; 24 fail the harness:

    • the white level read before gs_texrender_begin();
    • the peak read hoisted above the size uniforms, or read through the getter;
    • hdr_lmax read before hdr_lw;
    • async_unbuffered read for any source;
    • init_gpu_conversion() called before the convert type test;
    • get_convert_type() called before the texrender test;
    • each decision changed.

    The one that passes is equivalent: width_d2 computed through double (halving commutes with rounding).

  2. Characterization (508c339a2): test_async_upload_steps, 16 cases. It compiles the moved file (ASan and UBSan) and calls only its functions. It pins:

    • the enum values and struct layouts;
    • the compare with each field changed alone, in both directions;
    • the routes for every convert type;
    • the size uniforms as float bits for widths 0, 1, 2, 3, 1919, 1920, 16777217 and UINT32_MAX;
    • the HLG clamp at its edges and for NaN and infinities;
    • the chain for the SRGB, PQ and HLG transfers and one outside the enum, at peaks of 100, 1000, 1001 and 10000 and white levels of 80, 300 and 480;
    • hdr_lw for every uint16_t, every flag byte, every BGR swap pair and the four re-anchor cases.

    It is in the test graph, sorted.

  3. RED (9cf54642c): Tier 1 against todo!(). It ports the 16 C cases 1:1 and adds 12 edge tests:

    • the compare for each field alone, by proptest against a model;
    • the size uniforms against f64 models, around every power of two and by proptest over every u32;
    • the clamp and the ratio at every special f32 pattern and by proptest over any bits;
    • every transfer, the routes around the enum, and the BGR swaps from -64 to 64 and at the ends.
  4. GREEN (aebd69fc1): the safe core and fourteen #[no_mangle] shims, in a new libobs.ported-source-async-upload group whose PCH is obs.h, the new header and obs-source-conversion-plan.h.

    • The commit updates source-sets.json, the unity lists, the three export lists and ci/test_ported_sources.py, each in sorted place.
    • It adds test_async_upload_steps_rust, which links libobs_rust-static alone, as test_source_draw_plan_steps_rust does.
  5. Tier 3 (11fda6401): a C oracle of the unchanged file, the parity tests and a mutation check.

  6. Docs (07fce7e1b): the README rows, the crate's description, lib.rs and a port_comparison bench file. docs/rust-port/naming.md already maps libobs/obs-source*.c.h to rust/obs-source. The port changes nothing a user can see, so docs/features.md has no line.

The core denies clippy's arithmetic, indexing, as, unwrap, expect, panic, todo, unimplemented and unreachable lints. The two float functions and the size conversion allow only what they need. It keeps no state and takes no lock.

  • Kept, characterized, not endorsed:
  • Intentional differences: none. Every input is a value, so there is no pointer to check.

Bench (x86_64 Linux, GCC, release, not pinned to a core, load average about 4; median per 1024 frames, two runs):

Run Rust C
frame (one shown frame's decisions) 23.2 and 22.6 µs 14.8 and 15.0 µs
texrender (one conversion draw's uniforms) 21.0 and 21.3 µs 12.1 and 12.5 µs

That is about 8 to 9 ns more per frame, beside the frame's texture upload and conversion draw.

RED → GREEN

  • RED commit: 9cf54642c (obs-source: Test the async_upload port; it was ca10cb451 before the rebase onto bd029c837).
    • soldr cargo test -p obs-data --test obs-tests-core source::async_upload: 1 passed (the values), 27 failed, each on a todo!().
    • On that commit, local_gate --lane lint was clean and --test-diff origin/master failed only on those 27 cases.
  • GREEN (aebd69fc1): Tier 1 28/28. test_async_upload_steps passes 16/16 on the C backend, on hybrid libobs and on libobs-c-reference, and test_async_upload_steps_rust passes 16/16. Exported symbols are identical on all three (1766); the fourteen functions are local, and the hybrid's come from the Rust archive (the group's object is built only for libobs-c-reference).
  • Tier 3 (11fda6401) 13/13. Each bool is compared as a byte and each float as bits.
    • Layouts and enum values against the C header.
    • The compare from 480 edge bases.
    • The size uniforms for every size from 0 to 70,000, within 64 of every power of two, and every 65,521st u32.
    • The HLG clamp for every 4,099th f32 pattern and every pattern within 4,096 of 1000.
    • The ratio for every pair of 28 special patterns.
    • hdr_lw for every uint16_t, every flag byte, the routes from -100,000 to 100,000, and every BGR swap pair from -300 to 300.
    • The uniform chain of update_async_texrender() in its order, over every transfer × both ranges × every pair of special levels (401,408 chains).
    • Proptests of 20,000 cases each.
  • Mutation check: 27 mutants (21 in the core, 6 in the shims). Tier 1 kills 19 and Tier 3 kills 25. The 2 survivors are equivalent: the half texel computed as 0.5 / (2x) * 2, and the re-anchor arguments swapped (the rule is symmetric).
  • Checks on 07fce7e1b:
    • local_gate --lane lint, --test-diff origin/master (4015 passed, 6 skipped) and --lane cross all pass;
    • soldr cargo clippy --workspace --target x86_64-pc-windows-msvc --all-targets --locked -- -D warnings is clean;
    • soldr cargo test -p obs-c-oracle --locked --bench port_comparison passes.
  • Full ctest (C backend, hybrid libobs, libobs-c-reference): 100% passed on each: 503/503 (C backend), 529/529 (hybrid), 529/529 (libobs-c-reference), on 9eb1917a2 (the tree before the bench-only clippy fixup squashed into the docs commit), no reruns needed.
  • Real app: not applicable (no UI, protocol or logging change).

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (N/A for docs-only; a focused CI fix may push RED and GREEN together)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): none

Behaviour-neutral extraction before the Rust port. The decisions and
shader parameter values of set_async_texture_size(),
update_async_texrender(), update_async_textures(),
check_to_swap_bgrx_bgra() and obs_source_update_async_video() in
obs-source.c.h move to libobs/obs-source-async-upload.c.h, as fourteen
functions on plain values declared in the new
libobs/obs-source-async-upload.h without EXPORT (hidden, as
-fvisibility=hidden keeps them):

- obs_source_async_upload_texture_changed(): the five-field compare
  (width, height, format, full range, transfer) that rebuilds the
  textures, on two struct obs_source_async_upload_format values;
- obs_source_async_upload_tries_gpu(): whether the rebuild tries
  init_gpu_conversion() (any convert type but NONE);
- obs_source_async_upload_size_uniforms(): width, height, width_d2,
  height_d2, width_x2_i and height_x2_i, the same float operations in
  the same order ((float)cx * 0.5f, 0.5f / (float)cx);
- obs_source_async_upload_hlg_peak(): the BT.2408 clamp at 1000;
- obs_source_async_upload_maximum_nits() and _over_sdr_white(): the
  HLG peak or 10000, then one float division by the white level;
- obs_source_async_upload_hdr_lw() and _sets_range();
- obs_source_async_upload_linear_alpha(), _uses_texrender() and
  _plain(): update_async_textures()'s flag and route;
- obs_source_async_upload_bgr_swap(): the format the texture is
  recreated with, or GS_UNKNOWN to keep it;
- obs_source_async_upload_reanchor_reads_unbuffered() and _reanchor():
  the timing re-anchor rule (!async_decoupled || !async_unbuffered).

Split where a read or call would otherwise move: every gs_* call stays
in obs-source.c.h in its order and under its condition, and the
uniforms are computed piecewise so no level is read earlier than
before. obs->video.hdr_nominal_peak_level is still read directly after
height_x2_i is set, obs_get_video_sdr_white_level() just before
maximum_over_sdr_white_nits, obs_get_video_hdr_nominal_peak_level()
just before hdr_lmax, all after gs_texrender_begin() succeeds.
log10f() and the HLG exponent stay C. get_convert_type() is called
only off the texrender route, as before; init_gpu_conversion() only
for a convert type that tries it. async_unbuffered, set without a
lock, is read only for a decoupled source, as the short-circuit did.

The new file joins libobs.core-source with libobs.pch.h, which
includes the new header; source-sets.json lists it.
docs/rust-port/naming.md already maps libobs/obs-source*.c.h to
rust/obs-source.

Checked in a scratch harness (not committed) that compiles
origin/master's set_async_texture_size(), update_async_texrender(),
update_async_textures(), update_async_texture(),
check_to_swap_bgrx_bgra(), obs_source_update_async_video() and their
helpers verbatim next to this branch's and the moved file, on a
stand-in source and frame whose every field read and write is logged
with its value (a script rewrites each access into a logging
accessor), with every gs_* call and its arguments (the float uniforms
as bits), the levels, log10f(), get_convert_type(),
init_gpu_conversion(), the conversion plan, the frame get and release
and the asserts logged in order. The stubs answer from one seeded
stream in call order (texrender begin, texture creation, colour
formats, levels as any bit pattern or 80, 300, 480, 1000, 1001,
10000), and async_decoupled and async_unbuffered return the field or
a new value per read. 150,000,000 random states: 50,000,000 each with
GCC and Clang at -O2, 20,000,000 each at -O0, 5,000,000 each under
ASan and UBSan (GCC -O0, Clang -O2), sizes at 0, 1, 2^24 + 1,
2^31, UINT32_MAX and random, each texture field changed alone or not,
formats and transfers outside their enums. Over 4,500,000,000 events
are equal, with the final state and the return value, after the one
normalization the move needs: the field reads inside the compare (the
branch reads all ten, master a prefix) and frame->format inside the
BGR swap (the branch reads it for any texture format) are dropped;
the compare must read each of the ten fields exactly once and make no
call or write. Twenty-four of twenty-five deliberately broken moves
fail it (the white level read before gs_texrender_begin(), the peak
read hoisted above the size uniforms or through the getter, hdr_lmax
read before hdr_lw, async_unbuffered read for any source,
init_gpu_conversion() before the convert type test, get_convert_type()
before the texrender test, and each decision changed); the one that
passes is equivalent (width_d2 through double: halving commutes with
rounding).

Refs obs-rust#2336
test_async_upload_steps compiles libobs/obs-source-async-upload.c.h
into itself (ASan and UBSan) and calls only its hidden functions,
through its header. 16 cases pin:

- the enum values the port relies on (GS_UNKNOWN, GS_BGRX, GS_BGRA,
  the _UNORM pair, VIDEO_FORMAT_BGRA and BGRX, the transfers,
  OBS_SOURCE_FRAME_LINEAR_ALPHA, OBS_SOURCE_CONVERT_NONE) and the two
  structs' sizes, alignments and offsets;
- the five-field compare: equal values keep the textures, each field
  changed alone rebuilds them in both directions, and all at once;
  characterized, not endorsed: a 0 x 0 first frame of the zero values
  keeps the (absent) textures; the ends of every field;
- the GPU conversion and plain routes for every convert type and
  values outside the enum;
- the size uniforms as float bits for 0, 1, 2, 3, 1919, 1920,
  16777217 and UINT32_MAX on each axis (characterized, not endorsed:
  a size of 0 gives an infinite half texel; sizes past 2^24 round);
- the HLG clamp at 1000 for 100, 999, 1000, the next float, 1001,
  10000, infinities, zeros, a subnormal, a negative and NaNs
  (characterized, not endorsed: a NaN stays a NaN);
- the maximum nits for HLG, DEFAULT, SRGB, PQ and values outside the
  enum; the chain obs-source.c runs (the HLG peak, the maximum nits,
  the ratio) for SRGB, PQ, HLG and 4 at peaks of 100, 1000, 1001 and
  10000 and white levels of 80, 300 and 480;
- the ratio at its edges (characterized, not endorsed: a white level of
  0 gives +inf; obs-rust#2209 keeps the level above 0);
- hdr_lw for every uint16_t, the colour range, the linear alpha flag
  for every flag byte, the texrender route;
- every BGR swap pair of texture and frame formats around both enums;
- the four re-anchor cases and when async_unbuffered is read.

The test is in the test graph, sorted. test_async_conversion_plan,
test_pipewire_cursor_hdr, test_media_format_change and
test_filter_color_space cover the callers through the real libobs.

Refs obs-rust#2336
Adds the async_upload module to rust/obs-source with its API and every
function as todo!(): FRAME_LINEAR_ALPHA, CONVERT_NONE, the Format and
SizeUniforms values, the conversion plan's video_format, video_trc and
gs_color_format values, texture_changed(), tries_gpu(),
size_uniforms(), hlg_peak(), maximum_nits(), over_sdr_white(),
hdr_lw(), sets_range(), linear_alpha(), uses_texrender(), plain(),
bgr_swap() and reanchor_reads_unbuffered() with reanchor().

tests/source/async_upload.rs ports test_async_upload_steps 1:1
(steps_*: the same 16 cases, inputs and expectations, the floats as
bits) and adds edge cases (edge_*):

- the compare with each field changed alone from bases at the ends of
  every field, and by proptest (20,000 cases) against a model of the
  five fields;
- the size uniforms against models in f64 (exact for one-operation
  results) for every size around each power of two and by proptest
  over every u32; each axis reads only its own size;
- the HLG clamp for every special f32 bit pattern (zeros, subnormals,
  the ends of the normals, infinities, quiet and signalling NaNs of
  both signs) and every float within 256 of 1000; the ratio for every
  pair of special patterns against the f64 division; the maximum nits
  for every transfer; all of it by proptest over any bits;
- the routes for convert types from -1000 to 1000 and the ends of i32;
  every BGR swap pair from -64 to 64 and the ends; the flags and the
  re-anchor by proptest.

RED: soldr cargo test -p obs-data --test obs-tests-core
source::async_upload: 1 passed (the values), 27 failed, each on a
todo!() (obs_source_async_upload_texture_changed, _size_uniforms,
_hlg_peak, _over_sdr_white and _bgr_swap among the first reached).

Refs obs-rust#2336
Ports libobs/obs-source-async-upload.c.h, the async video upload
decisions of set_async_texture_size(), update_async_texrender(),
update_async_textures(), check_to_swap_bgrx_bgra() and
obs_source_update_async_video(), to the async_upload module of
rust/obs-source. obs-source.c.h stays C around it: every gs_* call in
its order and under its condition, get_convert_type(),
init_gpu_conversion(), log10f() and the HLG exponent, the direct read
of obs->video.hdr_nominal_peak_level, obs_get_video_sdr_white_level()
and obs_get_video_hdr_nominal_peak_level() (each read where it was,
after gs_texrender_begin() succeeds), the source's and frame's fields,
the frame get and release. The hybrid libobs drops the C file and
links the Rust shims in its place.

Safe core (src/async_upload.rs):
- texture_changed(Format, Format) and tries_gpu();
- size_uniforms() -> SizeUniforms { width, height, width_d2, height_d2,
  width_x2_i, height_x2_i }, with (float)u32 as `as f32` (nearest,
  ties to even), then one f32 multiply or divide each, as the C;
- hlg_peak() (the C's >, so a NaN is kept with its payload),
  maximum_nits(), over_sdr_white() (one f32 division), hdr_lw()
  (f32::from(u16), exact) and sets_range();
- linear_alpha(), uses_texrender(), plain();
- bgr_swap() -> Option<i32>;
- reanchor_reads_unbuffered() and reanchor().
Every float is the same single IEEE operation as the C's, in the same
order: no f64 intermediate, and Rust never contracts into a fused
multiply-add. Nothing divides an integer, so no MSVC trap is possible.
The module denies clippy's arithmetic, indexing, as, unwrap, expect,
panic, todo, unimplemented and unreachable lints (the two float
functions and the size conversion allow only what they need), keeps
no state and takes no lock.

Shims (src/ffi/source_async_upload.rs): the fourteen functions keep
the C signatures; struct obs_source_async_upload_format and
struct obs_source_async_upload_size cross by value as #[repr(C)]
mirrors, the enums as int, the transfer as uint8_t. bgr_swap()'s None
goes back as GS_UNKNOWN. No intentional differences: there is no
pointer.

C side: the file leaves libobs.core-source for its own group,
libobs.ported-source-async-upload (LIBOBS_PORTED_SOURCES), whose PCH is
obs.h, obs-source-async-upload.h and obs-source-conversion-plan.h;
libobs.pch.h keeps the header for obs-source.c. The functions are not
EXPORT, so the shims are hidden: rust-hidden.txt, the local: list of
rust-exports.map and rust-unexports-macos.txt. libobs-rust already
links the crate's ffi. ci/test_ported_sources.py checks the group on
every host.

test_async_upload_steps still compiles the C file into itself,
unchanged, and test_async_upload_steps_rust runs the same test source
against libobs_rust-static alone: the obs-source member links on its
own, as for test_source_draw_plan_steps_rust.

Tier 1 obs_source::async_upload passes 28/28.

Refs obs-rust#2336
Adds the C oracle of the unchanged libobs/obs-source-async-upload.c.h
(rust/obs-c-oracle, oracle/source_async_upload.c, its fourteen
functions renamed to oracle_*, with a table of the structs' layouts,
the enum values and the type sizes) and
tests/source/async_upload_parity.rs, which gives every input to the
oracle and the shims and compares the bytes the C returns: each bool
as the byte (0 or 1, and equal), the format as its int, every float as
its bits, NaN payloads and signs included.

- the two structs' sizes, alignments and offsets, the enum values and
  type sizes against the C header;
- the compare with each field changed alone and all at once, from 480
  bases at the ends of every field;
- the size uniforms for every size from 0 to 70,000, within 64 of
  every power of two, every 65,521st u32 and the ends;
- the HLG clamp for every 4,099th f32 bit pattern, every pattern within
  4,096 of 1000 and 28 special patterns (zeros, subnormals, the ends of
  the normals, the levels, infinities, quiet and signalling NaNs of
  both signs); the maximum nits for every transfer at each; the ratio
  for every pair of them;
- hdr_lw for every uint16_t; the linear alpha flag for every flag byte
  with every texrender, re-anchor and range input; the routes for every
  convert type from -100,000 to 100,000 and the ends of int; every BGR
  swap pair from -300 to 300 and the ends;
- the uniforms of update_async_texrender() in its order (the size
  uniforms, the HLG peak, the maximum nits, the ratio, hdr_lw, the
  range), one chain on each side, exhaustive over every transfer, both
  ranges and every pair of special levels (401,408 chains);
- proptests (20,000 cases each): the compare, the size uniforms, the
  levels (any bit pattern, or drawn from finite, subnormal, NaN and
  user-set levels), the whole uniform chain, and every decision.

Float parity: every uniform is one f32 operation on each side, the
same IEEE operation in the same order, so the bits match on x86_64
(SSE) and aarch64; no f64 intermediate, and the Rust side cannot
contract into a fused multiply-add. MSVC x64: nothing divides an
integer or reaches util_mul_div64()/_udiv128(), so no input needs a
guard. No intentional differences.

Mutation check (not committed): 27 mutants, each run against Tier 1
(28 tests) and Tier 3 (13).

| Area | Mutants | Tier 1 kills | Tier 3 kills | Survivors |
|---|---|---|---|---|
| compare (trc or width skipped, tries_gpu inverted) | 3 | 3 | 3 | 0 |
| size uniforms (height_d2 from width, width_x2_i from height, the conversion truncated to 24 bits, the half texel as 0.5 / (2x) * 2) | 4 | 3 | 3 | 1, equivalent: scaling by 2 commutes with rounding |
| levels (the clamp through f32::min, at 1001, the maximum for PQ, the ratio through the reciprocal or through f64 nudged by 1e-12, hdr_lw off at 65535, the range for full range) | 7 | 6 | 7 | 0 |
| routes and swap (linear alpha from bit 1, a texrender without one, plain for negative types, BGRA both ways, BGRX_UNORM swapping) | 5 | 5 | 5 | 0 |
| re-anchor (and for or, unbuffered read for any source) | 2 | 2 | 2 | 0 |
| shims (none as -1, the compare against itself, size axes swapped, halves swapped in the mirror, the format dropped, the re-anchor arguments swapped) | 6 | 0 | 5 | 1, equivalent: the rule is symmetric |

Tier 1 28/28 and Tier 3 13/13 pass.

Refs obs-rust#2336
- rust/README.md: the obs-source crate row lists
  libobs/obs-source-async-upload.c.h, and a new row for it in the
  ported file table: the fourteen functions, why the uniforms are split
  (each level read stays after gs_texrender_begin(), where it was; the
  unlocked async_unbuffered is read only for a decoupled source), what
  stays C, the float rule, the characterized and not endorsed cases
  and the tests;
- rust/obs-source: the crate description and the lib.rs docs name the
  new file and the async_upload module;
- rust/obs-c-oracle: a port_comparison bench file,
  port_comparison/source_async_upload.rs, in the sorted modules![...]
  list: 1024 frames through the decisions of one shown frame (the BGR
  swap, the re-anchor, the compare, the GPU route, the linear alpha
  flag and the upload route) and through the uniforms of one
  conversion draw, checked equal by a checksum first. Measured (x86_64
  Linux, GCC, release, not pinned to a core, load average about 4;
  median per 1024 frames, two runs): frame Rust 23.2 and 22.6 us, C
  14.8 and 15.0 us; texrender Rust 21.0 and 21.3 us, C 12.1 and
  12.5 us, about 8 to 9 ns more per frame, beside the frame's texture
  upload and draw. Its fixtures are plain vectors and allocate nothing
  through bmem, so the bench's free check holds.

docs/rust-port/naming.md already maps libobs/obs-source*.c.h to
rust/obs-source, so it needs no new row. The port changes no behaviour
a user can see, so docs/features.md has no line for it.

Fixes obs-rust#2336
@rdoupe
rdoupe force-pushed the port/async-upload branch from ca10cb4 to 07fce7e Compare October 25, 2026 05:08
@rdoupe
rdoupe marked this pull request as ready for review October 25, 2026 05:09
@rdoupe
rdoupe requested a review from zackees as a code owner October 25, 2026 05:09
@rdoupe
rdoupe added this pull request to the merge queue Oct 25, 2026
Merged via the queue into obs-rust:master with commit e1fb585 Oct 25, 2026
35 checks passed
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 the async upload parameters in obs-source.c to obs-source

1 participant