From 989738137cebd84e89c317441380654f048c2d40 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 26 Feb 2019 16:02:58 +0100 Subject: [PATCH] vrend, blit: Use GL 4.4 logic for blitting On GL 4.4 (and GLES with EXT_sRGB_write_control) blits will decode and encode sRGB when GL_FRAMEBUFFER_SRGB is supported, and they don't decode when it isn't supported. Enabling or disabling this is signalled from the guest by using the according surfaces. In summary, there is no need to use the GL fallback for a blit decoding sRGB, because this can also be handled in a normal blit. Fixes piglits on a GL host: blit texture srgb_to_linear downsample enabled render blit renderbuffer srgb_to_linear msaa enabled render blit renderbuffer srgb_to_linear msaa enabled clear blit renderbuffer srgb_to_linear downsample enabled clear v2: Fix typo in commit message (Erik) Signed-off-by: Gert Wollny Reviewed-by: Gurchetan Singh --- src/vrend_blitter.c | 7 +++++-- src/vrend_renderer.c | 8 ++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/vrend_blitter.c b/src/vrend_blitter.c index dbea83c..d11096f 100644 --- a/src/vrend_blitter.c +++ b/src/vrend_blitter.c @@ -843,10 +843,13 @@ void vrend_renderer_blit_gl(struct vrend_resource *src_res, vrend_fb_bind_texture(dst_res, 0, info->dst.level, layer); if (has_srgb_write_control) { - if (util_format_is_srgb(info->dst.format)) + if (util_format_is_srgb(info->dst.format) || util_format_is_srgb(info->src.format)) { + VREND_DEBUG(dbg_blit, ctx, "%s: Enable GL_FRAMEBUFFER_SRGB\n", __func__); glEnable(GL_FRAMEBUFFER_SRGB); - else + } else { + VREND_DEBUG(dbg_blit, ctx, "%s: Disable GL_FRAMEBUFFER_SRGB\n", __func__); glDisable(GL_FRAMEBUFFER_SRGB); + } } buffers = GL_COLOR_ATTACHMENT0; diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 1a326f9..1f797ea 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -7563,11 +7563,6 @@ static void vrend_renderer_blit_int(struct vrend_context *ctx, !vrend_format_is_ds(dst_res->base.format)) use_gl = true; - if (util_format_is_srgb(info->src.format) && - !util_format_is_srgb(info->dst.format)) { - VREND_DEBUG(dbg_blit, ctx, "BLIT: Use GL fallback because src is SRGB but dest not."); - use_gl = true; - } /* different depth formats */ if (vrend_format_is_ds(src_res->base.format) && vrend_format_is_ds(dst_res->base.format)) { @@ -7726,7 +7721,8 @@ static void vrend_renderer_blit_int(struct vrend_context *ctx, glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ctx->sub->blit_fb_ids[1]); if (has_feature(feat_srgb_write_control)) { - if (util_format_is_srgb(info->dst.format)) + if (util_format_is_srgb(info->dst.format) || + util_format_is_srgb(info->src.format)) glEnable(GL_FRAMEBUFFER_SRGB); else glDisable(GL_FRAMEBUFFER_SRGB);