frontend: Change overflow texture rendering to be sRGB-aware

Current code assumes that the overflow texture and the render target
always share the same color format including transfer function.

This assumption is incorrect however as OBS might use a 16-bit floating
point texture with a linear gamma transfer function when a high-bitrate
format is selected. On top of that OBS Studio wants rendering code to
ensure that linear color blending is used throughout the application.

The DrawOverflow function had not been updated to reflect this. This
change brings it in line with other functions involved in preview
rendering, which enable automatic sRGB conversion for the framebuffer
and the texture used in the fragment shader.
This commit is contained in:
PatTheMav
2025-08-24 15:29:33 -04:00
committed by Ryan Foster
parent 7685a0c78b
commit c8ec906844
+5 -1
View File
@@ -1841,7 +1841,7 @@ bool OBSBasicPreview::DrawSelectedOverflow(obs_scene_t *, obs_sceneitem_t *item,
vec2_set(&s, boxTransform.x.x / 96, boxTransform.y.y / 96);
gs_effect_set_vec2(scale, &s);
gs_effect_set_texture(image, prev->overflow);
gs_effect_set_texture_srgb(image, prev->overflow);
gs_matrix_push();
gs_matrix_mul(&boxTransform);
@@ -1849,10 +1849,14 @@ bool OBSBasicPreview::DrawSelectedOverflow(obs_scene_t *, obs_sceneitem_t *item,
obs_sceneitem_crop crop;
obs_sceneitem_get_crop(item, &crop);
const bool currentFramebufferSrgbState = gs_framebuffer_srgb_enabled();
gs_enable_framebuffer_srgb(true);
while (gs_effect_loop(solid, "Draw")) {
gs_draw_sprite(prev->overflow, 0, 1, 1);
}
gs_enable_framebuffer_srgb(currentFramebufferSrgbState);
gs_matrix_pop();
GS_DEBUG_MARKER_END();