Skip to content

rust: Port the canvas texture draw and display clear decisions to obs-core #2240

Closed

Description

@rdoupe

Unit

Port two small draw-decision tables to rust/obs-core, as a new module canvas_draw:

  • obs_render_canvas_texture_internal (libobs/obs.c.h):
    • the early return (no mix, or texture not rendered);
    • the technique and multiplier for each pair of source and current colour spaces (Draw, DrawTonemap for 709-extended into sRGB, DrawMultiply with sdr_white_level / 80 into scRGB).
  • render_display_begin (libobs/obs-display.c.h):
    • the clear colour conversion: always sRGB when the host says so, linear for an sRGB canvas, sRGB otherwise;
    • the clear flags: colour only without the clear workaround;
    • whether to draw the solid-colour workaround.

These stay in C: every gs_* call in its order, the effect and param lookups, the blend state, obs_get_video_sdr_white_level() and the host query (C passes in their values), the swapchain, the resize and the viewport.

Plan (one PR, separate commits)

  1. A behaviour-neutral move into libobs/obs-canvas-draw.c.h, as hidden functions. C asks each decision where it used to, so no gs_* call or getter is hoisted.
  2. Characterization in test_canvas_draw_steps. It covers:
    • every pair of the four colour spaces, plus one value outside the enum;
    • SDR white levels of 80, 300 and 0;
    • both early returns;
    • every combination of the clear-colour and workaround flags.
  3. RED, then GREEN: the safe Rust core plus shims, in a libobs.ported-canvas-draw group. Exported symbols are unchanged.
  4. Tier 3 parity against the original C, exhaustive over spaces and flags, plus a proptest over f32 white levels taken as bit patterns. Also a deliberate-break check and port_comparison numbers.

These real-libobs tests must stay green on every lane: the canvas and multi-canvas render tests, the projector and display tests, and the HDR/SDR render tests. Grep test/cmocka for canvas, display, sdr_white.

Activity

  1. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2240.

    1. Move the two decision tables into hidden functions in libobs/obs-canvas-draw.c.h (no EXPORT), with C still asking each decision where it used to, so no gs_* call or getter is hoisted.
    2. Characterization in test_canvas_draw_steps (sorted into test-graph.json).
    3. RED: Tier 1 tests against todo!() in rust/obs-core::canvas_draw.
    4. GREEN: the safe core plus shims in a libobs.ported-canvas-draw group. Exports stay at 1766 on the C, hybrid and c-ref builds.
    5. Tier 3: an oracle over the unchanged C, exhaustive over spaces and flags, a proptest over f32 white-level bit patterns, a mutation table, and port_comparison numbers.
    6. Docs: README rows, crate description, lib.rs docs.

    The technique names mirror obs-source::draw_technique (#2206); obs-core can't depend on obs-source, so only the names this unit needs are mirrored. PR expected within a day.

  2. added
    claimedAn agent or person has claimed this; check the claim comment before starting
    on Oct 24, 2026
  3. rdoupe commented on Oct 25, 2026

    @rdoupe
    CollaboratorAuthor

    Fixed by #2259 (merge commit 8349bb6): the canvas texture draw decisions (early return, technique, multiplier) and the display clear decisions (colour space, flags, solid-colour workaround) now live in rust/obs-core::canvas_draw, with C shims in the libobs.ported-canvas-draw group and Tier 1, 2 and 3 coverage.

    Left: nothing from this unit. The gs_* calls, effect and param lookups, blend state, swapchain, resize and viewport stay in C as the issue planned, so there is no follow-up issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimedAn agent or person has claimed this; check the claim comment before starting

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions