Skip to content

libobs: GS_FLIP_U draws a texture upside down instead of mirrored (PipeWire flipped capture) #2124

Closed

Description

@rdoupe

Bug

gs_draw_sprite() and gs_draw_quadf() with GS_FLIP_U draw a 2D texture upside down instead of mirroring it left to right.

  • Since upstream 7b8b51b ("libobs/graphics: Improve sprite drawing perf"), a 2D texture is drawn from one of two static vertex buffers: plain or flipped on v. The choice is flip ? flipped_sprite_buffer : sprite_buffer, so any flip bit selects the v-flipped buffer.
    • GS_FLIP_V draws correctly.
    • GS_FLIP_U alone draws flipped on v (upside down) and not on u.
    • GS_FLIP_U | GS_FLIP_V draws flipped on v only.
  • Before that commit, the sprite was built per draw and each axis followed its own bit. Rectangle textures and partial subregions still do that, so the same flip draws differently depending on the texture type and the crop.
  • obs-graphics: Port the sprite and texture upload geometry #2107 ported this geometry to Rust as-is and pinned it in test_sprite_geometry_steps ("characterized, not endorsed").

Who sees it: PipeWire screen and window capture (plugins/linux-pipewire). For a stream with the Flipped or Flipped180 transform, get_buffer_flip() passes GS_FLIP_U.

  • With no effective crop, the capture is drawn upside down instead of mirrored.
  • With a crop, gs_draw_sprite_subregion() builds the sprite per draw, and it is correct.
  • A full-size subregion takes the gs_draw_sprite() shortcut, so it is wrong too.

Upstream has the same code.

Plan

  1. RED: a real-libobs render test that draws a 2D texture with distinct corner colours through gs_draw_sprite() with each of the four flip values, plus a full-size and a partial gs_draw_sprite_subregion(). It reads back the corners. Update the pinned rows in test_sprite_geometry_steps and the Rust quad_flipped_buffer tests, marked for maintainer sign-off.
  2. GREEN: pick the static buffer by both bits (plain, u, v, uv), so each axis follows its own bit again. The plain and GS_FLIP_V draws stay exactly as they are; only GS_FLIP_U and GS_FLIP_U | GS_FLIP_V change, back to what they drew before 7b8b51b.

Activity

  1. zackees commented on Oct 24, 2026

    @zackees
    Member

    Claiming: this issue. Following the plan above (four static buffers chosen by both bits).

  2. added
    claimed
    on Oct 24, 2026
  3. zackees commented on Oct 24, 2026

    @zackees
    Member

    Decision needed: may this fix change the pinned rows of the existing C test test/cmocka/test_sprite_geometry_steps.c (from #2107, marked "characterized, not endorsed")? AGENTS.md says never to edit existing C tests to make a port pass. Recommendation: yes for a deliberate fix of upstream behavior, if (1) only the not-endorsed rows change and the PR lists each one, (2) a new render test proves the corrected output on its own, and (3) the C oracle copy stays upstream's, with the differential test recording the divergence as intended.

  4. added
    decision-needed
    claim-blocked
    on Oct 24, 2026
  5. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Yes from our side, with your three conditions. Those rows were pinned only to make the port exact ("characterized, not endorsed"), and the plan above already called for changing them with a sign-off note. The rows that should change are only the GS_FLIP_U and GS_FLIP_U | GS_FLIP_V cases of the flipped-buffer choice (and anything derived from it). The plain and GS_FLIP_V rows, the rectangle-texture rows and the subregion rows should stay exactly as they are.

  6. zackees commented on Oct 24, 2026

    @zackees
    Member

    Decided: yes, the fix may change those rows, under zackees's three conditions and rdoupe's scope.

    AGENTS.md forbids editing C tests to make a port pass. That isn't what this is. test_sprite_geometry_steps.c is our own characterization test from #2107, not an upstream test, and its rows say "characterized, not endorsed". This is a deliberate fix of an upstream bug, like the ones under Fixed upstream bugs in docs/features.md.

    The conditions:

    1. Change only the GS_FLIP_U and GS_FLIP_U | GS_FLIP_V flipped-buffer rows and anything derived from them, and list each one in the PR. The plain, GS_FLIP_V, rectangle-texture and subregion rows stay as they are.
    2. The new render test proves the corrected corners on its own: RED before the fix, GREEN after.
    3. The C oracle stays upstream's code, and the differential test records the divergence as intended.

    Also add the features-ledger line under Fixed upstream bugs. (Coordinator decision.)

  7. removed
    decision-needed
    on Oct 24, 2026
  8. zackees commented on Oct 24, 2026

    @zackees
    Member

    it appears that claim-blocked was not removed.

    Coordinator please file an issue then admin merge correction to the rule to handle this

  9. removed
    claim-blocked
    on Oct 24, 2026
  10. zackees commented on Oct 24, 2026

    @zackees
    Member

    Decision needed: #2135 fixes this, but it edits an existing C test, test/cmocka/test_sprite_geometry_steps.c. That test pinned the upstream "any flip bit selects the v-flipped buffer" behaviour ("characterized, not endorsed"). AGENTS.md says never edit existing C tests to make a port pass. Here the edit records a deliberate upstream-bug fix, not a port, and the issue's plan asked for it. I've turned auto-merge off on #2135 until this is signed off.

    Options:

    1. Accept the edit (recommended): the pinned rows were characterization only, and the new test_sprite_flip_render checks real pixels.
    2. Keep the old test unchanged: then the fix can't land, because the old test asserts the bug.
  11. added
    decision-needed
    on Oct 24, 2026
  12. added
    claim-blocked
    on Oct 24, 2026
  13. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    For the record: this was already settled earlier in this thread. The Decided: comment said yes to editing those pinned rows, under the three conditions and limited to the GS_FLIP_U and GS_FLIP_U | GS_FLIP_V flipped-buffer rows. As the issue author, option 1 is fine with us, as long as #2135 changes only those rows.

  14. zackees commented on Oct 24, 2026

    @zackees
    Member

    Decided: option 1. Accept the edit in #2135. This was already decided earlier in this thread; this records it again for the new question.

    I checked #2135's diff to test_sprite_geometry_steps.c. The changed assertions are only the flipped-buffer choice, now quad_buffer, and new build cases for the FLIP_U and FLIP_U | FLIP_V buffers. The existing plain and v-flipped build rows are untouched. Each changed spot cites #2124. That is inside the agreed scope. I've turned auto-merge back on for #2135. (Coordinator decision.)

  15. removed
    decision-needed
    on Oct 24, 2026
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

    claim-blockedclaimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions