Skip to content

rust: port source_render (the color-space conversion draw) to obs-source #5976

Done

Description

@rdoupe

source_render() in libobs/obs-source.c.h (~574-650 on master, c8f086c) is still C. It is the draw behind both obs_source_default_render() (Rust, reached through the hidden adapter obs_source_default_render_source_render()) and obs_source_main_render() (being ported in #5974). Every decision in it is already Rust: obs_source_draw_plan_convert, _technique, _reads_white_level and _multiplier (obs-source source_draw_plan), the profiler begin/end (obs-core source_profiler) and obs_source_base_width/_height. What is left is the field reads, the texrender cache and the graphics calls.

Behavior the port keeps, read for read and call for call:

  • Profiler: source_profiler_source_render_begin() before anything, source_profiler_source_render_end() last, on both routes.
  • Read gs_get_color_space() once, ask obs_source_get_color_space(source, 1, &current), and take the format from gs_get_format_from_space().
  • No conversion: info.video_render(context.data, effect) and nothing else.
  • Conversion: drop color_space_texrender when its format differs, create it (GS_ZS_NONE) when missing, reset it, and only when gs_texrender_begin_with_color_space() succeeds at the base size: blending off, clear to zero, ortho, video_render, blending on, end; then draw the texture with the default effect's technique, image as sRGB, multiplier read from the SDR white level only when the plan says so, framebuffer sRGB on and restored, blend ONE/INVSRCALPHA pushed and popped, one sprite per pass.

Plan, one PR into obs-source (the shape of #5943 and #5974):

  1. Extract source_render() verbatim into its own live core-source file, the adapter calling it unchanged. No behavior change.
  2. Tier 1 RED in obs-source's existing category binary against a todo!() core over a trait for the fields, the texrender cache and the graphics calls.
  3. GREEN: safe core in obs-source, the adapter as a hidden C ABI export in ffi/, a one-access field adapter, the extracted file moved to a reference-only ported group.
  4. Tier 3 parity against the original C in obs-c-oracle: the same source states through both (no conversion, conversion with a cached texrender of the same and of a different format, a failed begin, a white-level read and none), comparing recorded calls and their order.
  5. Tier 2: the existing cmocka cases that reach it through obs_source_video_render() and obs_source_default_render() against the hybrid libobs and the C reference, plus a characterization of the conversion route if none reaches it.

No public header, C test or obs-websocket change.

Activity

  1. added
    port
    on Nov 30, 2026
  2. rdoupe commented on Nov 30, 2026

    @rdoupe
    CollaboratorAuthor

    /ready

  3. rdoupe commented on Nov 30, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #5976 port of source_render (extract, Tier 1 RED, GREEN, Tier 3 parity, Tier 2), the step after obs_source_main_render (#5974). I'll start once #5974 is merged, since both touch the same part of obs-source.c.h.

  4. added
    ready
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

portready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions