From e1a16b901b401efd94b452a9c4c641259e669a47 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 24 Nov 2015 16:15:20 +0100 Subject: [PATCH] =?utf8?q?i965/gen9/fast-clear:=20Handle=20linear=E2=86=92?= =?utf8?q?SRGB=20conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If GL_FRAMEBUFFER_SRGB is enabled when writing to an SRGB-capable framebuffer then the color will be converted from linear to SRGB before being written. There is no chance for the hardware to do this itself because it can't modify the clear color that is programmed in the surface state so it seems pretty clear that the driver should be handling this itself. Note that this wasn't a problem before Gen9 because previously we were only able to do fast clears to 0 or 1 and those values are the same in linear and SRGB space. Reviewed-by: Topi Pohjolainen --- src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c index 1b2ea425002..f1920b2edce 100644 --- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c +++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c @@ -41,6 +41,8 @@ #include "main/api_validate.h" #include "main/state.h" +#include "util/format_srgb.h" + #include "vbo/vbo_context.h" #include "drivers/common/meta.h" @@ -424,6 +426,15 @@ set_fast_clear_color(struct brw_context *brw, override_color.f[3] = 1.0f; } + /* Handle linear→SRGB conversion */ + if (brw->ctx.Color.sRGBEnabled && + _mesa_get_srgb_format_linear(mt->format) != mt->format) { + for (int i = 0; i < 3; i++) { + override_color.f[i] = + util_format_linear_to_srgb_float(override_color.f[i]); + } + } + if (brw->gen >= 9) { mt->gen9_fast_clear_color = override_color; } else { -- 2.30.2