Repository navigation
libobs: GS_FLIP_U mirrors a sprite instead of drawing it upside down (#2124) - #2135
Merged
Merged
Conversation
zackees
added a commit
that referenced
this pull request
Oct 24, 2026
zackees
enabled auto-merge
October 24, 2026 11:38
zackees
disabled auto-merge
October 24, 2026 11:39
zackees
enabled auto-merge
October 24, 2026 11:42
Member
Author
|
Holding this PR against the
I'll also rerun the RED as committed. Auto-merge stays off until these are done. |
zackees
disabled auto-merge
October 24, 2026 11:42
Member
Author
|
Coordinator, FYI for the rework: the Linux Tier 2 (tests ON) failure is the new test. In run 40090743951, |
Member
Author
|
Rework done; checked against the
The empty first draw after obs_reset_video isn't root-caused: it's a startup window that closes with time. The test now waits for three good plain draws, up to 3 s, before running the cases. Re-enabling auto-merge; PR CI runs the full suite on this head. |
zackees
enabled auto-merge
October 24, 2026 12:46
zackees
force-pushed
the
fix/sprite-flip-u
branch
from
October 24, 2026 12:54
b294408 to
abc7241
Compare
zackees
added a commit
that referenced
this pull request
Oct 24, 2026
6 of 7 tasks
Adds test_sprite_flip_render: a real-libobs render of a 4x4 texture with gs_draw_sprite() and gs_draw_sprite_subregion() (whole and partial) for each flip, read back pixel by pixel. Renames gs_sprite_quad_flipped_buffer() to gs_sprite_quad_buffer(), returning which static buffer to draw (the flip bits of its coordinates), still with the upstream choice, and updates the pinned characterization rows in test_sprite_geometry_steps and the Rust step tests to each axis following its own bit (maintainer sign-off).
graphics_init_sprite_vbs() builds four static 1x1 sprites (plain, flipped on u, on v, on both) and gs_draw_quadf() draws the one gs_sprite_quad_buffer() names, flip & (GS_FLIP_U | GS_FLIP_V), in the C and the Rust port alike. GS_FLIP_U now mirrors a 2D texture instead of drawing it upside down; the plain and GS_FLIP_V buffers are built and drawn as before.
…tream's choice (#2124) gs_sprite_quad_buffer() changes only the GS_FLIP_U and GS_FLIP_U | GS_FLIP_V choices: a flip of only unknown bits picks the v-flipped buffer again, as upstream. The C oracle keeps upstream's selection as oracle_gs_sprite_quad_flipped_buffer() (any bit: flipped on v), and the differential test compares every flip against it except those with GS_FLIP_U set, the intended divergence, checked on the shim alone.
…m-up draw (#2124) Right after obs_reset_video() draws can read back an empty target for a few draws (seen with four warm-up draws in 1 of 12 runs under llvmpipe and Xvfb). Probe until three plain draws in a row read back, for up to 3 s; 40 of 40 runs then pass.
zackees
force-pushed
the
fix/sprite-flip-u
branch
from
October 24, 2026 13:12
abc7241 to
0e1ec50
Compare
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2124
What
gs_draw_quadf()drew every flipped 2D texture from the one static buffer flipped on v (flip ? flipped_sprite_buffer : sprite_buffer, since upstream 7b8b51b), soGS_FLIP_Udrew a texture upside down instead of mirroring it. That hit PipeWire capture of Flipped/Flipped180 streams, and a full-sizegs_draw_sprite_subregion().graphics_init_sprite_vbs()now builds four static 1x1 sprites (plain, u, v, uv) ingraphics_subsystem.sprite_buffers[4](graphics-internal.h, not a public header).gs_sprite_quad_flipped_buffer()(bool) is renamedgs_sprite_quad_buffer()(uint32_t, the index of the buffer to draw).GS_FLIP_Uset picksflip & (GS_FLIP_U|GS_FLIP_V): u or uv.GS_FLIP_Vor for a flip made only of unknown bits.graphics-sprite.c.h) and in the Rust port (obs-graphics::sprite, the one the hybrid build links).rust-exports.map,rust-hidden.txt,rust-unexports-macos.txt) are renamed in place. The function is still hidden and not EXPORT. Its only consumer isgraphics.c.h.gs_sprite_uv_norm(0)/gs_sprite_uv_norm(GS_FLIP_V)as before and are chosen for exactly the same flips. Only theGS_FLIP_UandGS_FLIP_U|GS_FLIP_V(with or without unknown bits) draws change.Changed pinned rows (signed off on #2124 under the
Decided:conditions)test/cmocka/test_sprite_geometry_steps.c(an existing C test; edit approved on #2124):quad_flipped_bufferbecomesquad_buffer. Rows that stay as upstream had them: 0 → none, and every flip withoutGS_FLIP_U→ the v buffer (FLIP_V,1<<2,FLIP_V|1<<31,0xfffffffc). Changed rows, theGS_FLIP_Uones:FLIP_U→ u (was v),FLIP_U|FLIP_V→ uv (was v),FLIP_U|1<<2→ u (was v),FLIP_U|FLIP_V|0xfffffff0→ uv (was v),UINT32_MAX→ uv (was v).static_sprite_buffers: new build rows for theFLIP_UandFLIP_U|FLIP_Vbuffers. The plain and v rows are untouched.rust/obs-graphics/tests/render/sprite.rs: the same rows insteps_quad_bufferand in theedge_quad_rulesproptest, plus the u and uv rows insteps_static_sprite_buffers.Tier 3: the oracle keeps upstream's code
rust/obs-c-oracle/oracle/graphics_sprite.cnow carries upstream's selection asoracle_gs_sprite_quad_flipped_buffer()(return flip != 0;, any bit picks the v buffer). The Rust binding uses that function. The tree's fixedgs_sprite_quad_buffer()is still compiled into the oracle under itsoracle_rename, so the symbol cannot clash with the Rust shim, but nothing binds it.sprite_parity.rscheck_quad_bufferruns every flip of the low 16 bits with four high halves, plus a proptest:GS_FLIP_Umust match the oracle exactly. That covers plain and V.GS_FLIP_Uis the intended divergence, recorded in the module docs and in a comment citing libobs: GS_FLIP_U draws a texture upside down instead of mirrored (PipeWire flipped capture) #2124. It asserts that the oracle picked the v buffer and that the shim picksflip & (U|V).Evidence
RED, rerun on the RED commit exactly as pushed (
8391102bf, full Tier 2rust/tools/linux-validate/run.sh):Rust RED:
steps_quad_buffer ... FAILED,edge_quad_rules ... FAILED.GREEN:
137efc261:100% tests passed, 0 tests failed out of 442, in both modes.2227b6c60,b294408f4):ctest -R spritein the same Tier 2 build tree passed 3 of 3 (test_sprite_flip_render,test_sprite_geometry_steps,test_sprite_geometry_steps_rust).soldr cargo test -p obs-graphics: 306 passed, 0 failed../lint: rc 0.Empty draws right after obs_reset_video()
The first RED run had
sprite_plainread back an all-zero target. I put a diagnostic build in the Tier 2 container (Mesa llvmpipe, Xvfb) and ran the binary on its own:obs_reset_video()read back all zeros every time (about 10 ms, no GL error logged).So it is a startup window: it closes with time, not after some number of draws. Not root-caused. The graphics thread starts rendering frames on the same device at that time, and my guess is something in how the device or EGL context settles on llvmpipe, but I could not confirm it. The test now polls before running any case: it draws until three plain draws in a row read back, for up to 3 s, and fails setup if they never do. With that, 40 of 40 standalone runs passed. The case assertions are unchanged.