Skip to content

bug: libobs/graphics: gs_reset_blend_state leaves a non-default blend op when the blend function is the default #2519

Closed

Description

@vpacher

What

gs_reset_blend_state is documented to "set the blend state to the default value" (docs/sphinx/reference-libobs-graphics-graphics.rst). Since blend ops were added in 2021 (33a6d2a, "libobs: Expose blending operation types"), the blend state includes the op (GS_BLEND_OP_ADD by default), but the reset only resets the op inside the branch for a blend function that differs from the default:

if (graphics->cur_blend_state.src_c != GS_BLEND_SRCALPHA || ... ) {
	gs_blend_function_separate(GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA, GS_BLEND_ONE, GS_BLEND_INVSRCALPHA);
	gs_blend_op(GS_BLEND_OP_ADD);
}

With the default function and, for example, GS_BLEND_OP_REVERSE_SUBTRACT, the op stays.

Who can reach it

Not OBS's own blend modes: the ones with another op (Subtract, Lighten, Darken) also use another function (ONE, ONE, ONE, ONE), and each scene item pushes and pops its blend state. A plugin or a script can: gs_blend_op is public API, and scene_video_render calls gs_reset_blend_state() before it draws the scene's items, so a scene rendered with the op still set draws with the wrong blending. Unchanged in upstream OBS master.

Fix

Reset the op whenever it is not GS_BLEND_OP_ADD, also when the function is the default.

Plan

Inside the state stacks port (#2517), as its own RED and GREEN commits: the reset is testable on the extracted seam (which device steps it takes) without a graphics device, while the public API has no getter for the current blend state. RED: with the default function and a non-default op, the reset takes the op step (now: none). GREEN: the change, in the C before the port's RED.

Activity

  1. added a commit that references this issue on Oct 26, 2026
    3321450
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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions