Repository navigation
libobs: Draw Darken sources over white so transparency keeps the background - #1406
Merged
Merged
Conversation
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 18, 2026
A source set to Darken blending draws black where it is transparent, and its alpha punches a hole through the scene, instead of leaving the background as it is (obsproject/obs-studio#6591, reported by SuslikV). test_darken_transparent puts an opaque light grey background on the program and over it a box that is transparent in its left half and an opaque darker grey in its right half, runs a raw video encoder on the program and compares the mean luma of each half with Darken and with Normal blending. Where the box is opaque it is darker than the background, so the two modes must agree. Fails 1 of 2: darken_keeps_background_where_transparent (left half luma 16, black, with Darken; 180 with Normal). The Normal control passes. Needs core video, so it runs under xvfb-run on Linux and skips without a display. Refs obs-rust#1404.
…ground Darken draws the item's texture with GS_BLEND_OP_MIN, and Direct3D and OpenGL ignore the blend factors for MIN and MAX: each channel becomes min(source, destination) on premultiplied colour. A transparent source pixel is (0, 0, 0, 0), so it always won: black in colour and 0 in alpha, which also cut a hole through the scene (obsproject/obs-studio#6591). Darken items always render through their item texture first. That texture is now cleared to opaque white instead of transparent black for them, so the source is drawn over white: a transparent pixel becomes white with alpha 1, and the minimum keeps the background's colour and alpha; an opaque pixel is the same as before. A partly transparent pixel is darkened as the source over white would be, which is the workaround users were given (export the image on white). Other blend modes are unchanged. test_darken_transparent: 2 of 2 (three runs). In the app, a half- transparent PNG set to Darken over a grey background now shows the background (209, 209, 209, alpha 1) in its transparent half instead of (0, 0, 0, 0). Fixes obs-rust#1404.
rdoupe
force-pushed
the
fix/darken-transparent
branch
from
October 18, 2026 16:08
4f105bc to
e34bbce
Compare
zackees
enabled auto-merge
October 18, 2026 16:13
This was referenced Oct 18, 2026
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 20, 2026
…ust#1521) Behavior-neutral extraction before the Rust port: obs_blend_mode_params, the table that maps each blend mode to the blend factors and operation render_item_texture() passes to gs_blend_function_separate() and gs_blend_op(), moves verbatim from libobs/obs-scene.c.h into libobs/obs-scene-blend.c.h. It stays static and unchanged, and joins libobs.core-source just before obs-scene.c.h, so it is in the same translation unit as its only user. No signature, header or exported symbol changes. The Darken clear colour (obs-rust#1406) and the effect technique choice are not moved: neither is a function of its own (the clear colour is an if in render_item(), the technique depends on scaling and color spaces, not on the blend mode), so moving them would mean new code, not a move. New characterization test test_scene_blend (all platforms, plus the Cargo C-test manifest). It compiles the table's file, so it needs no graphics device and no libobs core: the blend mode values as row numbers, one row per mode and no more, every mode's four factors and operation. Characterized, not endorsed: the lookup is an unchecked index and obs_sceneitem_set_blending_mode() stores any value; alpha goes through the same operation as color, so Subtract gives dst_a - src_a and Darken min(src_a, dst_a); Multiply's alpha is dst_a. Refs obs-rust#1520
This was referenced Oct 23, 2026
rdoupe
added a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 24, 2026
test_scene_render_plan_steps compiles libobs/obs-scene-render-plan.c.h (ASan and UBSan, no libobs core) and calls only its hidden functions, so it runs on every platform. 16 cases: - obs_scene_render_texture_enabled(): no trigger (a group, a scene that is a group, nothing set), and each trigger alone: every side of the crop and the bounds crop at 1, -1, INT_MAX and INT_MIN; every scale filter but Disable, values outside the enum included; sRGB off (and not another blend method outside the enum); every blend mode but Normal, values outside the enum included; a nested scene. - obs_scene_render_texrender_action(): all 8 rows of has / wanted / format matches. - obs_scene_render_size_empty() (obs-rust#573) and obs_scene_render_clear_white() (obs-rust#1406: Darken only). - obs_scene_render_child(): visible or hidden x show active x hide active (8 rows), and obs_scene_render_linear_srgb(). - obs_scene_texcoords_centered(): the identity and whole translations, any other entry moved, fractional translations (the next float above 3, the smallest subnormal), -0.0 and NaN. - obs_scene_render_effect(): each scale filter at scale 1, up, down a little, one axis 1, one up and one down, and below 0.5 (with and without Area's upscale); 0.5 and the floats on either side; 1 +/- EPSILON (both round away from 1 as floats and are not close; the next floats towards 1 are); NaN of either sign and payload, and +/-inf. - obs_scene_render_multiplier() for the 4 x 4 colour space pairs at SDR white levels of 80, 300 and 0, the values written out, and spaces outside the enum (1). - obs_scene_render_technique() for the 4 x 4 pairs, with and without upscale, and spaces outside the enum (Draw or DrawUpscale). Characterized, not endorsed: - a white level of 0 gives 80.f / 0, +inf (and -0 gives -inf); - a NaN output scale is never close to 1 and never below 0.5, so the filter's own effect is used, and Area does not upscale; a negative scale is below 0.5; - memcmp: -0.0 anywhere but the translation is not centred, while a quiet NaN or infinite translation is (floorf gives it back as it is); - the texrender and child rows libobs never passes (format_matches without a texrender, or the other transition active). It is in the native test graph, in the core suite. It builds with -Werror against cmocka 2.0.2 and 1.1.7 and uses no assert_in_range. The real-libobs scene tests are unchanged. Refs obs-rust#2003
rdoupe
added a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 24, 2026
Ports libobs/obs-scene-render-plan.c.h, the per-item render decisions of render_item() and render_item_texture(), to the render_plan module of rust/obs-scene. render_item() and render_item_texture() stay C in obs-scene.c.h: every gs_* call, obs_source_video_render(), the texrender objects, obs_get_video_sdr_white_level() (passed as a value), the blend table lookup (obs-rust#1521), calc_cx/calc_cy (obs-rust#1947), and the mapping of the effect and technique values to obs->video.* and the technique names. The hybrid libobs drops the C file and links the Rust shims in its place. Safe core (src/render_plan.rs), one function per hidden C function: - texture_enabled(): any crop or bounds crop side non-zero, a scale filter other than Disable, sRGB off, a blend type other than Normal, or a nested scene that is not a group; - texrender_action(): destroy when there and either not wanted or not in the format, then create when wanted and none is left (None, Keep, Destroy, Create, Recreate); - size_empty() (obs-rust#573), clear_white() (obs-rust#1406: Darken), child() (Show for a visible item with a running show transition, Hide for a hidden one with a running hide transition, else Source) and linear_srgb(); - texcoords_centered(): over obs-graphics' Matrix4, every entry compared by its bits against the identity with the x and y translation replaced by their floor(), as the C's memcmp, so -0.0 and NaN payloads behave as in C; - effect(): Disable draws as it is, Point sets the point sampler, and any other filter at an output scale not within EPSILON of 1 on both axes sets the base dimension and picks the low-resolution bilinear effect below 0.5 on either axis, else Bicubic, Lanczos or Area (which upscales at 1 and over on both axes), else the default effect. fabsf(f - 1) <= EPSILON is written the same way in f32, so NaN is never close; - multiplier(): white / 80 for SDR or extended into scRGB, 80 / white for scRGB into SDR or extended (+inf for a white level of 0, as in C), else 1; - technique(): the eight techniques, with values outside enum gs_color_space drawing as Draw or DrawUpscale. Values from the item and the colour spaces are i32 and compared as they are. The module denies clippy's arithmetic, indexing, as, unwrap, expect, panic, unimplemented and unreachable lints, keeps no state and takes no lock. Shim (src/ffi/scene_render_plan.rs): the ten functions with the C signatures. struct obs_scene_render_triggers and struct obs_scene_render_effect_plan are mirrored (#[repr(C)]); the triggers and the matrix (obs-graphics' ffi matrix4) are read through their pointers and the effect plan written through its pointer. The enums are returned as the C's values. No item or source pointer crosses. C side: the file leaves libobs.core-source for its own group, libobs.ported-scene-render-plan (LIBOBS_PORTED_SOURCES), whose PCH has only math.h, string.h, graphics/math-defs.h and obs-scene-render-plan.h; libobs.pch.h keeps the header for obs-scene.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. The exported symbol sets are unchanged and equal (1766 on the C backend, the hybrid and libobs-c-reference). test_scene_render_plan_steps still compiles the C file into itself, unchanged. The new test_scene_render_plan_steps_rust builds the same test source against libobs_rust-static instead, as test_source_color_space_steps_rust does: the test calls the hidden functions directly, so this variant runs the shims, the structs passed from C included. The real-libobs scene tests see the swap through the hybrid. Tier 1 scene::render_plan passes 24/24. Refs obs-rust#2003
rdoupe
added a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 24, 2026
Oracle (oracle/scene_render_plan.c): the original obs-scene-render-plan.c.h, unmodified, with its ten functions renamed to oracle_*, plus the layouts of struct obs_scene_render_triggers, struct obs_scene_render_effect_plan and struct matrix4, the sizes and values of the four enums and the mirrored constants (59 values). The moved texcoords check initializes struct matrix4 with flat lists, which libobs builds with -Wno-missing-braces; the oracle turns that warning off around the include, as image_file.c does for its own. Tier 3 (tests/scene/render_plan_parity.rs, 11 tests), comparing every output field by field, bit for bit (the bools, the enum values as integers, the multiplier as f32 bits), with floats and matrices drawn from bit patterns (obs-rust#1951), so -0.0 and quiet and signalling NaNs of either sign and payload are covered: - the layouts and constants against the C header; - exhaustive: the texrender action and the child (8 rows each); the triggers over every zero/non-zero pattern of the eight crops x 11 scale filters x 6 blend methods x 11 blend types x the two flags (743,424 calls); the size check over the u32 edges; the clear colour and linear sRGB over every value from -2 to 9 and the ends of i32; the technique and the multiplier over every pair of 11 spaces (-2 to 6 and the ends of i32) with 26 white levels; the effect over 15 filters and every pair of 86 scales from around 0.5, 1 - EPSILON, 1, 1 + EPSILON, 0, the infinities and the NaNs (110,940 calls); the centred check with each of the 16 entries set to 30 special values, and every pair of them as the translation; - proptests (10,000 cases each) over full i32 triggers, any i32 filter with any-bit scales biased to the edges, any spaces with any-bit white levels, and matrices whose entries are the identity's, whole or fractional, or any bits. The module passed 10 runs in a row with fresh seeds. Rust's f32::floor and the C's floorf agree on every NaN tried, the signalling ones included (both quiet them). Mutation check (done once, not committed): 48 mutants, 40 in the core and 8 in the shim; 43 fail. 35 of the 40 core mutants fail both Tier 1 (1 to 4 of 24) and Tier 3 (1 or 2 of 11), among them obs-rust#1406 reverted (never white), the group rule dropped, the format ignored and the low-resolution edge moved; "round for floor" in the centred check differs only on a signalling NaN translation and fails Tier 3 alone. 7 of the 8 shim mutants fail Tier 3; Tier 1 does not reach the shims. Five survive and are equivalent: trunc for floor in the centred check (both equal x exactly when x is whole), < for <= against EPSILON and the close-to-1 test in f64 (f - 1 is exact near 1 and never exactly 1e-4f), the 80 / white division in f64 (double rounding from 53 to 24 bits is innocuous for division), and the two scale axes swapped in the shim (the effect is symmetric in x and y). The proptest regression files keep the seeds the mutants failed on. Refs obs-rust#2003
rdoupe
added a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 24, 2026
* libobs: Move the scene item render decisions into obs-scene-render-plan.c Behaviour-neutral extraction before the Rust port. The per-item render decisions of render_item() and render_item_texture() in obs-scene.c.h move to libobs/obs-scene-render-plan.c.h as pure functions, declared in the new libobs/obs-scene-render-plan.h without EXPORT (hidden, as -fvisibility=hidden keeps them): - obs_scene_render_texture_enabled(): draw through the texrender, from struct obs_scene_render_triggers (the crop and bounds crop, the scale filter, the blend method and type, and whether the item is a nested scene and a group). It replaces item_texture_enabled()'s helpers. - obs_scene_render_texrender_action(): keep, destroy, create or recreate the texrender. - obs_scene_render_size_empty(): the source has no size, the gate of the empty-source rule (obs-rust#573). - obs_scene_render_clear_white(): white for Darken (obs-rust#1406). The obs-rust#1406 comment moves with it. - obs_scene_render_child(): the show transition, the hide transition or the source. - obs_scene_render_linear_srgb(). - obs_scene_texcoords_centered(): are_texcoords_centered(), with its memcmp, unchanged. - obs_scene_render_effect(): the effect, the point sampler, the base dimension parameters and Area's upscale, from the scale filter and the output scale. - obs_scene_render_multiplier(): the SDR white multiplier, from the two colour spaces and the white level the caller passes. - obs_scene_render_technique(): the technique. Each decision is made where the C made it, from the values the C read there, so every gs_* call, obs_source_video_render(), the texrender objects and obs_get_video_sdr_white_level() stay in obs-scene.c.h in the same order: - gs_texrender_get_format() is still asked only when a texrender is there and wanted (format_matches short-circuits as the old condition did), and the texrender is destroyed and created as before; - the source's size is still read only with a texrender, and the child choice still asks scene_transition_active() of the show transition only when the item is visible and of the hide transition only when it is not, once per draw, at the same three places; - render_item_texture() reads the texture's size, then makes the gs calls of the effect plan in the old order (the point sampler, then base_dimension and base_dimension_i), then takes the white level at the same place as before and passes it to the multiplier. The getter is now called for every space pair, not only the six that use it; it is a plain read of obs->video with no lock and no side effect. - obs-scene.c.h maps the effect value to obs->video.* and the technique value to its name. item->user_visible is read once per child choice instead of twice in the hidden case. It is a plain field read with nothing in between, so the compiler was already free to merge the two. The enum values cross as int, so the header needs only graphics/matrix4.h; obs-scene.c.h checks at compile time that the mirrored scale filter, blend and colour space values match obs.h and graphics.h, and that the four enums are int-sized. The new file joins libobs.core-source with libobs.pch.h, which includes the new header. The exported symbol sets are unchanged (1766). Refs obs-rust#2003 * test: Characterize the scene item render decisions test_scene_render_plan_steps compiles libobs/obs-scene-render-plan.c.h (ASan and UBSan, no libobs core) and calls only its hidden functions, so it runs on every platform. 16 cases: - obs_scene_render_texture_enabled(): no trigger (a group, a scene that is a group, nothing set), and each trigger alone: every side of the crop and the bounds crop at 1, -1, INT_MAX and INT_MIN; every scale filter but Disable, values outside the enum included; sRGB off (and not another blend method outside the enum); every blend mode but Normal, values outside the enum included; a nested scene. - obs_scene_render_texrender_action(): all 8 rows of has / wanted / format matches. - obs_scene_render_size_empty() (obs-rust#573) and obs_scene_render_clear_white() (obs-rust#1406: Darken only). - obs_scene_render_child(): visible or hidden x show active x hide active (8 rows), and obs_scene_render_linear_srgb(). - obs_scene_texcoords_centered(): the identity and whole translations, any other entry moved, fractional translations (the next float above 3, the smallest subnormal), -0.0 and NaN. - obs_scene_render_effect(): each scale filter at scale 1, up, down a little, one axis 1, one up and one down, and below 0.5 (with and without Area's upscale); 0.5 and the floats on either side; 1 +/- EPSILON (both round away from 1 as floats and are not close; the next floats towards 1 are); NaN of either sign and payload, and +/-inf. - obs_scene_render_multiplier() for the 4 x 4 colour space pairs at SDR white levels of 80, 300 and 0, the values written out, and spaces outside the enum (1). - obs_scene_render_technique() for the 4 x 4 pairs, with and without upscale, and spaces outside the enum (Draw or DrawUpscale). Characterized, not endorsed: - a white level of 0 gives 80.f / 0, +inf (and -0 gives -inf); - a NaN output scale is never close to 1 and never below 0.5, so the filter's own effect is used, and Area does not upscale; a negative scale is below 0.5; - memcmp: -0.0 anywhere but the translation is not centred, while a quiet NaN or infinite translation is (floorf gives it back as it is); - the texrender and child rows libobs never passes (format_matches without a texrender, or the other transition active). It is in the native test graph, in the core suite. It builds with -Werror against cmocka 2.0.2 and 1.1.7 and uses no assert_in_range. The real-libobs scene tests are unchanged. Refs obs-rust#2003 * obs-scene: Add Tier 1 tests for the scene item render decisions port RED for the port of libobs/obs-scene-render-plan.c.h to a new render_plan module of rust/obs-scene. The safe core is a stub (todo!()), one function per hidden C function: texture_enabled() over Triggers, texrender_action() giving a Texrender (None, Keep, Destroy, Create, Recreate), size_empty(), clear_white(), child() giving a Child (Source, Show, Hide), linear_srgb(), texcoords_centered() over obs-graphics' Matrix4, effect() giving an EffectPlan (an Effect, the point sampler, the base dimension and the upscale), multiplier() and technique() giving a Technique, with the mirrored scale filter, blend and colour space values and EPSILON. tests/scene/render_plan.rs ports test_scene_render_plan_steps 1:1: its 16 cases under the same names (steps_*), in the same order, with the same inputs and expectations, the characterized-not-endorsed cases included. Edge cases (edge_*): the texrender action's invariants (a texrender is there afterwards exactly when wanted; destroyed only when there, created only when wanted, kept only when there, wanted and matching), the child's (only a visible item draws its show transition, only a hidden one its hide transition), and the upscaled technique as the plain one's DrawUpscale variant for spaces -2 to 6; and five proptests (4000 cases each), with floats drawn from bit patterns (obs-rust#1951): the triggers against a model over full i32 crops, filters, methods and types; the effect against a model whose close-to-1 test is written on the bit patterns; any whole-number translation is centred and any other entry off the identity's bits is not; a fractional translation is not centred; and the multiplier is 1, white / 80 or 80 / white, bit for bit, for any white level. The tests are a module of obs-tests-core (rust/obs-data/tests/core.rs), as crop's are. soldr cargo test -p obs-data --test obs-tests-core scene::render_plan fails 24 of 24 with "not yet implemented". Refs obs-rust#2003 * obs-scene: Port the scene item render decisions Ports libobs/obs-scene-render-plan.c.h, the per-item render decisions of render_item() and render_item_texture(), to the render_plan module of rust/obs-scene. render_item() and render_item_texture() stay C in obs-scene.c.h: every gs_* call, obs_source_video_render(), the texrender objects, obs_get_video_sdr_white_level() (passed as a value), the blend table lookup (obs-rust#1521), calc_cx/calc_cy (obs-rust#1947), and the mapping of the effect and technique values to obs->video.* and the technique names. The hybrid libobs drops the C file and links the Rust shims in its place. Safe core (src/render_plan.rs), one function per hidden C function: - texture_enabled(): any crop or bounds crop side non-zero, a scale filter other than Disable, sRGB off, a blend type other than Normal, or a nested scene that is not a group; - texrender_action(): destroy when there and either not wanted or not in the format, then create when wanted and none is left (None, Keep, Destroy, Create, Recreate); - size_empty() (obs-rust#573), clear_white() (obs-rust#1406: Darken), child() (Show for a visible item with a running show transition, Hide for a hidden one with a running hide transition, else Source) and linear_srgb(); - texcoords_centered(): over obs-graphics' Matrix4, every entry compared by its bits against the identity with the x and y translation replaced by their floor(), as the C's memcmp, so -0.0 and NaN payloads behave as in C; - effect(): Disable draws as it is, Point sets the point sampler, and any other filter at an output scale not within EPSILON of 1 on both axes sets the base dimension and picks the low-resolution bilinear effect below 0.5 on either axis, else Bicubic, Lanczos or Area (which upscales at 1 and over on both axes), else the default effect. fabsf(f - 1) <= EPSILON is written the same way in f32, so NaN is never close; - multiplier(): white / 80 for SDR or extended into scRGB, 80 / white for scRGB into SDR or extended (+inf for a white level of 0, as in C), else 1; - technique(): the eight techniques, with values outside enum gs_color_space drawing as Draw or DrawUpscale. Values from the item and the colour spaces are i32 and compared as they are. The module denies clippy's arithmetic, indexing, as, unwrap, expect, panic, unimplemented and unreachable lints, keeps no state and takes no lock. Shim (src/ffi/scene_render_plan.rs): the ten functions with the C signatures. struct obs_scene_render_triggers and struct obs_scene_render_effect_plan are mirrored (#[repr(C)]); the triggers and the matrix (obs-graphics' ffi matrix4) are read through their pointers and the effect plan written through its pointer. The enums are returned as the C's values. No item or source pointer crosses. C side: the file leaves libobs.core-source for its own group, libobs.ported-scene-render-plan (LIBOBS_PORTED_SOURCES), whose PCH has only math.h, string.h, graphics/math-defs.h and obs-scene-render-plan.h; libobs.pch.h keeps the header for obs-scene.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. The exported symbol sets are unchanged and equal (1766 on the C backend, the hybrid and libobs-c-reference). test_scene_render_plan_steps still compiles the C file into itself, unchanged. The new test_scene_render_plan_steps_rust builds the same test source against libobs_rust-static instead, as test_source_color_space_steps_rust does: the test calls the hidden functions directly, so this variant runs the shims, the structs passed from C included. The real-libobs scene tests see the swap through the hybrid. Tier 1 scene::render_plan passes 24/24. Refs obs-rust#2003 * obs-scene: Check the scene item render decisions port against the C Oracle (oracle/scene_render_plan.c): the original obs-scene-render-plan.c.h, unmodified, with its ten functions renamed to oracle_*, plus the layouts of struct obs_scene_render_triggers, struct obs_scene_render_effect_plan and struct matrix4, the sizes and values of the four enums and the mirrored constants (59 values). The moved texcoords check initializes struct matrix4 with flat lists, which libobs builds with -Wno-missing-braces; the oracle turns that warning off around the include, as image_file.c does for its own. Tier 3 (tests/scene/render_plan_parity.rs, 11 tests), comparing every output field by field, bit for bit (the bools, the enum values as integers, the multiplier as f32 bits), with floats and matrices drawn from bit patterns (obs-rust#1951), so -0.0 and quiet and signalling NaNs of either sign and payload are covered: - the layouts and constants against the C header; - exhaustive: the texrender action and the child (8 rows each); the triggers over every zero/non-zero pattern of the eight crops x 11 scale filters x 6 blend methods x 11 blend types x the two flags (743,424 calls); the size check over the u32 edges; the clear colour and linear sRGB over every value from -2 to 9 and the ends of i32; the technique and the multiplier over every pair of 11 spaces (-2 to 6 and the ends of i32) with 26 white levels; the effect over 15 filters and every pair of 86 scales from around 0.5, 1 - EPSILON, 1, 1 + EPSILON, 0, the infinities and the NaNs (110,940 calls); the centred check with each of the 16 entries set to 30 special values, and every pair of them as the translation; - proptests (10,000 cases each) over full i32 triggers, any i32 filter with any-bit scales biased to the edges, any spaces with any-bit white levels, and matrices whose entries are the identity's, whole or fractional, or any bits. The module passed 10 runs in a row with fresh seeds. Rust's f32::floor and the C's floorf agree on every NaN tried, the signalling ones included (both quiet them). Mutation check (done once, not committed): 48 mutants, 40 in the core and 8 in the shim; 43 fail. 35 of the 40 core mutants fail both Tier 1 (1 to 4 of 24) and Tier 3 (1 or 2 of 11), among them obs-rust#1406 reverted (never white), the group rule dropped, the format ignored and the low-resolution edge moved; "round for floor" in the centred check differs only on a signalling NaN translation and fails Tier 3 alone. 7 of the 8 shim mutants fail Tier 3; Tier 1 does not reach the shims. Five survive and are equivalent: trunc for floor in the centred check (both equal x exactly when x is whole), < for <= against EPSILON and the close-to-1 test in f64 (f - 1 is exact near 1 and never exactly 1e-4f), the 80 / white division in f64 (double rounding from 53 to 24 bits is innocuous for division), and the two scale axes swapped in the shim (the effect is symmetric in x and y). The proptest regression files keep the seeds the mutants failed on. Refs obs-rust#2003 * docs: Record the scene item render decisions port The rust/README.md crate table now lists libobs/obs-scene-render-plan.c.h among the rust/obs-scene units, and its port table has a row for it: the ten decisions and where the C makes them, what stays C (every gs_* call in its order, the renders, the texrender objects, the white level lookup, the blend table, calc_cx and calc_cy, and the effect and technique mapping), the mirrored structs and the compile-time checks, what the characterization pins and the port keeps, the _rust variant of the steps test, the real-libobs tests that see the swap and what Tier 3 compares. The crate's description and lib.rs say what it holds. docs/rust-port/naming.md already maps libobs/obs-scene*.c.h to rust/obs-scene. No docs/features.md line: no user-visible change. port_comparison gets its own bench file, benches/port_comparison/scene_render_plan.rs, for 16 items: the per-item decisions of render_item (texture, texrender action, clear colour, child, linear sRGB), the texture's effect, multiplier and technique, and the centred check, each folded into a checksum both sides must match. On x86_64 Linux (GCC, pinned to one core, but on a machine with a load average near 30, so the numbers are noisy; medians per 16 items, two runs): item 1.09 us / 220 ns Rust against 419 / 408 ns C, texture 534 / 250 ns against 522 / 145 ns, texcoords_centered 450 / 132 ns against 201 / 98 ns. The gap is at most about 40 ns per item per frame (the first run), and for the item decisions the order flips between runs. I have not looked into it further. Fixes obs-rust#2003
7 tasks done
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 #1404
What and why
A source set to Darken blending now leaves the background where it is transparent. Before, it drew black there and cut a hole in the scene's alpha (upstream obsproject/obs-studio#6591, reported by SuslikV; closed upstream as not planned, though the blend-mode author agreed it is a bug).
GS_BLEND_OP_MIN, and Direct3D and OpenGL ignore the blend factors for MIN and MAX: each channel becomesmin(source, destination)on premultiplied colour, and a transparent pixel (0, 0, 0, 0) always wins.item_texture_enabled(): non-default blending). That texture is now cleared to opaque white instead of transparent black for Darken items, so the source is drawn over white. A transparent pixel becomes white with alpha 1 and the minimum keeps the background's colour and alpha. An opaque pixel is the same as before. A partly transparent pixel is darkened as the source over white would be, which is the workaround users were given upstream and on the forum (re-export the image on white).Headless (private Xvfb, private D-Bus, fresh HOME), driven over obs-websocket: a light grey (209) colour source, a PNG over it whose left half is transparent and whose right half is opaque grey (128), scene screenshot:
RED → GREEN
test/cmocka: Add failing test for Darken over a transparent source.test_darken_transparentputs an opaque light grey background on the program and over it a box that is transparent in its left half and opaque darker grey in its right half, runs a raw video encoder on the program and compares each half's mean luma with Darken and with Normal (where the box is opaque it is darker than the background, so the two must agree). On master it fails 1 of 2:darken_keeps_background_where_transparent(left half luma 16 with Darken, 180 with Normal). Needs core video: runs under xvfb-run on Linux, skips without a display.libobs: Draw Darken sources over white so transparency keeps the background. 2 of 2, three runs;test_scaled_mix_alpha(Subtract) still passes. Full build (C libobs lane) and full ctest -j4 (private Xvfb, private D-Bus, fresh HOME, systemlibobs-openglmasked): 304/304; the only skipped case isopen_crashes_without_obs_core, as on master. The scene renderer is C in both libobs lanes.Checklist
master-W..., ratchets): noneAI note: Claude Code (Claude Opus 5.5) wrote the code, the test, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.