From 1cf8cf99c891c02236c40a1f694efe3fcaa9f44f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 10 Mar 2021 14:46:16 -0800 Subject: [PATCH] mesa/st: Fix precompile misses on compat GL VSes writing to color outputs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In compat GL, the gl_FrontColor/BackColor gets clamped unless you explicitly turn it off with ARB_color_buffer_float, and most apps doing floating point color rendering are going to be using non-compat varyings anyway instead of hoping that ARB_color_buffer_float exists. Thus, guess that the app will get clamping on the color outputs to reduce draw-time recompiles. Saves 60 VS recompiles on half-life-2.trace on freedreno (and similarly for many other compat GL apps). Reviewed-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_program.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index fc1be8f80a4..1cf2a01758d 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1946,6 +1946,15 @@ st_precompile_shader_variant(struct st_context *st, memset(&key, 0, sizeof(key)); + if (st->ctx->API == API_OPENGL_COMPAT && + st->clamp_vert_color_in_shader && + (prog->info.outputs_written & (VARYING_SLOT_COL0 | + VARYING_SLOT_COL1 | + VARYING_SLOT_BFC0 | + VARYING_SLOT_BFC1))) { + key.clamp_color = true; + } + key.st = st->has_shareable_shaders ? NULL : st; st_get_common_variant(st, p, &key); break;