libobs: Render async video with DrawNonlinearAlpha

Match previous OBS alpha behavior.

DrawNonlinearAlpha requires premultiplied alpha blend state.
This commit is contained in:
jpark37
2021-04-24 17:33:09 -07:00
parent 50dfa566e6
commit aed52412d4

View File

@@ -2056,17 +2056,30 @@ static void obs_source_draw_async_texture(struct obs_source *source)
{
gs_effect_t *effect = gs_get_effect();
bool def_draw = (!effect);
bool premultiplied = false;
gs_technique_t *tech = NULL;
if (def_draw) {
effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
tech = gs_effect_get_technique(effect, "Draw");
const bool linear = gs_get_linear_srgb();
const char *tech_name = linear ? "DrawNonlinearAlpha" : "Draw";
premultiplied = linear;
tech = gs_effect_get_technique(effect, tech_name);
gs_technique_begin(tech);
gs_technique_begin_pass(tech, 0);
}
if (premultiplied) {
gs_blend_state_push();
gs_blend_function(GS_BLEND_ONE, GS_BLEND_INVSRCALPHA);
}
obs_source_draw_texture(source, effect);
if (premultiplied) {
gs_blend_state_pop();
}
if (def_draw) {
gs_technique_end_pass(tech);
gs_technique_end(tech);