[Mesa-dev,3/3] st/mesa: create shaders which have only one variant immediatelly

Submitted by Marek Olšák on Oct. 19, 2015, 10:46 p.m.

Details

Message ID CAAxE2A5zmf32K=uWaX7k8DvXnSW-MxX4_j=dcGKX95yceGw38A@mail.gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Marek Olšák Oct. 19, 2015, 10:46 p.m.
On Mon, Oct 19, 2015 at 9:53 PM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> Actually this just occurred to me -- you should only check
> st->can_force_persamp_interp if PIPE_CAP_SAMPLE_SHADING is enabled.
> Otherwise it should be unreachable. And it's a bit weird for a driver
> to say "sample shading = no, force persamp interp = yes".

The attached patches should fix that.

Marek

Patch hide | download patch | download mbox

From 07caefddb00dc6d091fd9ec2dea182f6a71efe92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= <marek.olsak@amd.com>
Date: Mon, 28 Sep 2015 00:04:39 +0200
Subject: [PATCH 2/2] st/mesa: create shaders which have only one variant
 immediatelly (v2)

v2: fix the condition when lacking sample shading
---
 src/mesa/state_tracker/st_cb_program.c |  5 +++--
 src/mesa/state_tracker/st_context.c    | 14 ++++++++++++++
 src/mesa/state_tracker/st_context.h    |  7 +++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 708bdf5..2c4eccf 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -224,6 +224,7 @@  st_program_string_notify( struct gl_context *ctx,
                                            struct gl_program *prog )
 {
    struct st_context *st = st_context(ctx);
+   gl_shader_stage stage = _mesa_program_enum_to_shader_stage(target);
 
    if (target == GL_FRAGMENT_PROGRAM_ARB) {
       struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
@@ -278,10 +279,10 @@  st_program_string_notify( struct gl_context *ctx,
          st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
    }
 
-   if (ST_DEBUG & DEBUG_PRECOMPILE)
+   if (ST_DEBUG & DEBUG_PRECOMPILE ||
+       st->shader_has_one_variant[stage])
       st_precompile_shader_variant(st, prog);
 
-   /* XXX check if program is legal, within limits */
    return GL_TRUE;
 }
 
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 70e0069..5abb173 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -294,6 +294,20 @@  st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
          ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectSampler = true;
    }
 
+   /* Set which shader types can be compiled at link time. */
+   st->shader_has_one_variant[MESA_SHADER_VERTEX] =
+         st->has_shareable_shaders &&
+         !st->clamp_vert_color_in_shader;
+
+   st->shader_has_one_variant[MESA_SHADER_FRAGMENT] =
+         st->has_shareable_shaders &&
+         !st->clamp_frag_color_in_shader &&
+         !st->force_persample_in_shader;
+
+   st->shader_has_one_variant[MESA_SHADER_TESS_CTRL] = st->has_shareable_shaders;
+   st->shader_has_one_variant[MESA_SHADER_TESS_EVAL] = st->has_shareable_shaders;
+   st->shader_has_one_variant[MESA_SHADER_GEOMETRY] = st->has_shareable_shaders;
+
    _mesa_compute_version(ctx);
 
    if (ctx->Version == 0) {
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index ec95259..c243f5c 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -101,6 +101,13 @@  struct st_context
    boolean force_persample_in_shader;
    boolean has_shareable_shaders;
 
+   /**
+    * If a shader can be created when we get its source.
+    * This means it has only 1 variant, not counting glBitmap and
+    * glDrawPixels.
+    */
+   boolean shader_has_one_variant[MESA_SHADER_STAGES];
+
    boolean needs_texcoord_semantic;
    boolean apply_texture_swizzle_to_border_color;
 
-- 
2.1.4


Comments

On Mon, Oct 19, 2015 at 6:46 PM, Marek Olšák <maraeo@gmail.com> wrote:
> On Mon, Oct 19, 2015 at 9:53 PM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
>> Actually this just occurred to me -- you should only check
>> st->can_force_persamp_interp if PIPE_CAP_SAMPLE_SHADING is enabled.
>> Otherwise it should be unreachable. And it's a bit weird for a driver
>> to say "sample shading = no, force persamp interp = yes".
>
> The attached patches should fix that.

Works for me.