[Mesa-dev] [PATCH 34/70] i965: stop passing gl_shader_program to the precompile and codegen functions

Timothy Arceri timothy.arceri at collabora.com
Tue Dec 20 10:37:44 UTC 2016


We no longer need it.

While we are at it we mark the vs, gs, and wm codegen functions as static.
---
 src/mesa/drivers/dri/i965/brw_cs.c      | 12 +++---------
 src/mesa/drivers/dri/i965/brw_gs.c      | 14 ++++----------
 src/mesa/drivers/dri/i965/brw_gs.h      |  6 ------
 src/mesa/drivers/dri/i965/brw_link.cpp  |  8 ++++----
 src/mesa/drivers/dri/i965/brw_program.c |  4 ++--
 src/mesa/drivers/dri/i965/brw_shader.h  | 16 ++++------------
 src/mesa/drivers/dri/i965/brw_tcs.c     | 13 ++++---------
 src/mesa/drivers/dri/i965/brw_tes.c     |  7 ++-----
 src/mesa/drivers/dri/i965/brw_vs.c      | 14 ++++----------
 src/mesa/drivers/dri/i965/brw_vs.h      |  6 ------
 src/mesa/drivers/dri/i965/brw_wm.c      | 13 ++++---------
 src/mesa/drivers/dri/i965/brw_wm.h      |  5 -----
 12 files changed, 31 insertions(+), 87 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_cs.c b/src/mesa/drivers/dri/i965/brw_cs.c
index 6882bb5..2f05854 100644
--- a/src/mesa/drivers/dri/i965/brw_cs.c
+++ b/src/mesa/drivers/dri/i965/brw_cs.c
@@ -52,7 +52,6 @@ assign_cs_binding_table_offsets(const struct gen_device_info *devinfo,
 
 static bool
 brw_codegen_cs_prog(struct brw_context *brw,
-                    struct gl_shader_program *prog,
                     struct brw_program *cp,
                     struct brw_cs_prog_key *key)
 {
@@ -216,10 +215,7 @@ brw_upload_cs_prog(struct brw_context *brw)
                          &key, sizeof(key),
                          &brw->cs.base.prog_offset,
                          &brw->cs.base.prog_data)) {
-      bool success =
-         brw_codegen_cs_prog(brw,
-                             ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE],
-                             cp, &key);
+      bool success = brw_codegen_cs_prog(brw, cp, &key);
       (void) success;
       assert(success);
    }
@@ -227,9 +223,7 @@ brw_upload_cs_prog(struct brw_context *brw)
 
 
 bool
-brw_cs_precompile(struct gl_context *ctx,
-                  struct gl_shader_program *shader_prog,
-                  struct gl_program *prog)
+brw_cs_precompile(struct gl_context *ctx, struct gl_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_cs_prog_key key;
@@ -244,7 +238,7 @@ brw_cs_precompile(struct gl_context *ctx,
    uint32_t old_prog_offset = brw->cs.base.prog_offset;
    struct brw_stage_prog_data *old_prog_data = brw->cs.base.prog_data;
 
-   bool success = brw_codegen_cs_prog(brw, shader_prog, bcp, &key);
+   bool success = brw_codegen_cs_prog(brw, bcp, &key);
 
    brw->cs.base.prog_offset = old_prog_offset;
    brw->cs.base.prog_data = old_prog_data;
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index d6dd926..b120a7d 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -87,9 +87,8 @@ assign_gs_binding_table_offsets(const struct gen_device_info *devinfo,
                                            reserved);
 }
 
-bool
+static bool
 brw_codegen_gs_prog(struct brw_context *brw,
-                    struct gl_shader_program *prog,
                     struct brw_program *gp,
                     struct brw_gs_prog_key *key)
 {
@@ -211,8 +210,6 @@ brw_gs_populate_key(struct brw_context *brw,
 void
 brw_upload_gs_prog(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->ctx;
-   struct gl_shader_program **current = ctx->_Shader->CurrentProgram;
    struct brw_stage_state *stage_state = &brw->gs.base;
    struct brw_gs_prog_key key;
    /* BRW_NEW_GEOMETRY_PROGRAM */
@@ -243,17 +240,14 @@ brw_upload_gs_prog(struct brw_context *brw)
                          &key, sizeof(key),
                          &stage_state->prog_offset,
                          &brw->gs.base.prog_data)) {
-      bool success = brw_codegen_gs_prog(brw, current[MESA_SHADER_GEOMETRY],
-                                         gp, &key);
+      bool success = brw_codegen_gs_prog(brw, gp, &key);
       assert(success);
       (void)success;
    }
 }
 
 bool
-brw_gs_precompile(struct gl_context *ctx,
-                  struct gl_shader_program *shader_prog,
-                  struct gl_program *prog)
+brw_gs_precompile(struct gl_context *ctx, struct gl_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_gs_prog_key key;
@@ -268,7 +262,7 @@ brw_gs_precompile(struct gl_context *ctx,
    brw_setup_tex_for_precompile(brw, &key.tex, prog);
    key.program_string_id = bgp->id;
 
-   success = brw_codegen_gs_prog(brw, shader_prog, bgp, &key);
+   success = brw_codegen_gs_prog(brw, bgp, &key);
 
    brw->gs.base.prog_offset = old_prog_offset;
    brw->gs.base.prog_data = old_prog_data;
diff --git a/src/mesa/drivers/dri/i965/brw_gs.h b/src/mesa/drivers/dri/i965/brw_gs.h
index e1f8c4d..537a416 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.h
+++ b/src/mesa/drivers/dri/i965/brw_gs.h
@@ -41,12 +41,6 @@ void
 brw_gs_populate_key(struct brw_context *brw,
                     struct brw_gs_prog_key *key);
 
-bool
-brw_codegen_gs_prog(struct brw_context *brw,
-                    struct gl_shader_program *prog,
-                    struct brw_program *gp,
-                    struct brw_gs_prog_key *key);
-
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp
index 83f73b4..457b8a8 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -50,10 +50,10 @@ brw_shader_precompile(struct gl_context *ctx,
    struct gl_linked_shader *fs = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
    struct gl_linked_shader *cs = sh_prog->_LinkedShaders[MESA_SHADER_COMPUTE];
 
-   if (fs && !brw_fs_precompile(ctx, sh_prog, fs->Program))
+   if (fs && !brw_fs_precompile(ctx, fs->Program))
       return false;
 
-   if (gs && !brw_gs_precompile(ctx, sh_prog, gs->Program))
+   if (gs && !brw_gs_precompile(ctx, gs->Program))
       return false;
 
    if (tes && !brw_tes_precompile(ctx, sh_prog, tes->Program))
@@ -62,10 +62,10 @@ brw_shader_precompile(struct gl_context *ctx,
    if (tcs && !brw_tcs_precompile(ctx, sh_prog, tcs->Program))
       return false;
 
-   if (vs && !brw_vs_precompile(ctx, sh_prog, vs->Program))
+   if (vs && !brw_vs_precompile(ctx, vs->Program))
       return false;
 
-   if (cs && !brw_cs_precompile(ctx, sh_prog, cs->Program))
+   if (cs && !brw_cs_precompile(ctx, cs->Program))
       return false;
 
    return true;
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index e7df6e7..0d57f5c 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -201,7 +201,7 @@ brwProgramStringNotify(struct gl_context *ctx,
 
       prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_FRAGMENT, true);
 
-      brw_fs_precompile(ctx, NULL, prog);
+      brw_fs_precompile(ctx, prog);
       break;
    }
    case GL_VERTEX_PROGRAM_ARB: {
@@ -225,7 +225,7 @@ brwProgramStringNotify(struct gl_context *ctx,
       prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_VERTEX,
                                  compiler->scalar_stage[MESA_SHADER_VERTEX]);
 
-      brw_vs_precompile(ctx, NULL, prog);
+      brw_vs_precompile(ctx, prog);
       break;
    }
    default:
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index bd03204..242a9cc 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -262,24 +262,16 @@ brw_assign_common_binding_table_offsets(gl_shader_stage stage,
                                         struct brw_stage_prog_data *stage_prog_data,
                                         uint32_t next_binding_table_offset);
 
-bool brw_vs_precompile(struct gl_context *ctx,
-                       struct gl_shader_program *shader_prog,
-                       struct gl_program *prog);
+bool brw_vs_precompile(struct gl_context *ctx, struct gl_program *prog);
 bool brw_tcs_precompile(struct gl_context *ctx,
                         struct gl_shader_program *shader_prog,
                         struct gl_program *prog);
 bool brw_tes_precompile(struct gl_context *ctx,
                         struct gl_shader_program *shader_prog,
                         struct gl_program *prog);
-bool brw_gs_precompile(struct gl_context *ctx,
-                       struct gl_shader_program *shader_prog,
-                       struct gl_program *prog);
-bool brw_fs_precompile(struct gl_context *ctx,
-                       struct gl_shader_program *shader_prog,
-                       struct gl_program *prog);
-bool brw_cs_precompile(struct gl_context *ctx,
-                       struct gl_shader_program *shader_prog,
-                       struct gl_program *prog);
+bool brw_gs_precompile(struct gl_context *ctx, struct gl_program *prog);
+bool brw_fs_precompile(struct gl_context *ctx, struct gl_program *prog);
+bool brw_cs_precompile(struct gl_context *ctx, struct gl_program *prog);
 
 GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
 struct gl_linked_shader *brw_new_shader(gl_shader_stage stage);
diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
index 822437e..0cb120c 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs.c
@@ -163,11 +163,8 @@ brw_tcs_debug_recompile(struct brw_context *brw, struct gl_program *prog,
 }
 
 static bool
-brw_codegen_tcs_prog(struct brw_context *brw,
-                     struct gl_shader_program *shader_prog,
-                     struct brw_program *tcp,
-                     struct brw_program *tep,
-                     struct brw_tcs_prog_key *key)
+brw_codegen_tcs_prog(struct brw_context *brw, struct brw_program *tcp,
+                     struct brw_program *tep, struct brw_tcs_prog_key *key)
 {
    struct gl_context *ctx = &brw->ctx;
    const struct brw_compiler *compiler = brw->screen->compiler;
@@ -347,7 +344,6 @@ brw_tcs_populate_key(struct brw_context *brw,
 void
 brw_upload_tcs_prog(struct brw_context *brw)
 {
-   struct gl_shader_program **current = brw->ctx._Shader->CurrentProgram;
    struct brw_stage_state *stage_state = &brw->tcs.base;
    struct brw_tcs_prog_key key;
    /* BRW_NEW_TESS_PROGRAMS */
@@ -368,8 +364,7 @@ brw_upload_tcs_prog(struct brw_context *brw)
                          &key, sizeof(key),
                          &stage_state->prog_offset,
                          &brw->tcs.base.prog_data)) {
-      bool success = brw_codegen_tcs_prog(brw, current[MESA_SHADER_TESS_CTRL],
-                                          tcp, tep, &key);
+      bool success = brw_codegen_tcs_prog(brw, tcp, tep, &key);
       assert(success);
       (void)success;
    }
@@ -417,7 +412,7 @@ brw_tcs_precompile(struct gl_context *ctx,
    key.outputs_written = prog->nir->info->outputs_written;
    key.patch_outputs_written = prog->nir->info->patch_outputs_written;
 
-   success = brw_codegen_tcs_prog(brw, shader_prog, btcp, btep, &key);
+   success = brw_codegen_tcs_prog(brw, btcp, btep, &key);
 
    brw->tcs.base.prog_offset = old_prog_offset;
    brw->tcs.base.prog_data = old_prog_data;
diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c
index f98f874..0cc2a31 100644
--- a/src/mesa/drivers/dri/i965/brw_tes.c
+++ b/src/mesa/drivers/dri/i965/brw_tes.c
@@ -77,7 +77,6 @@ brw_tes_debug_recompile(struct brw_context *brw, struct gl_program *prog,
 
 static bool
 brw_codegen_tes_prog(struct brw_context *brw,
-                     struct gl_shader_program *shader_prog,
                      struct brw_program *tep,
                      struct brw_tes_prog_key *key)
 {
@@ -256,7 +255,6 @@ brw_tes_populate_key(struct brw_context *brw,
 void
 brw_upload_tes_prog(struct brw_context *brw)
 {
-   struct gl_shader_program **current = brw->ctx._Shader->CurrentProgram;
    struct brw_stage_state *stage_state = &brw->tes.base;
    struct brw_tes_prog_key key;
    /* BRW_NEW_TESS_PROGRAMS */
@@ -273,8 +271,7 @@ brw_upload_tes_prog(struct brw_context *brw)
                          &key, sizeof(key),
                          &stage_state->prog_offset,
                          &brw->tes.base.prog_data)) {
-      bool success = brw_codegen_tes_prog(brw, current[MESA_SHADER_TESS_EVAL],
-                                          tep, &key);
+      bool success = brw_codegen_tes_prog(brw, tep, &key);
       assert(success);
       (void)success;
    }
@@ -313,7 +310,7 @@ brw_tes_precompile(struct gl_context *ctx,
 
    brw_setup_tex_for_precompile(brw, &key.tex, prog);
 
-   success = brw_codegen_tes_prog(brw, shader_prog, btep, &key);
+   success = brw_codegen_tes_prog(brw, btep, &key);
 
    brw->tes.base.prog_offset = old_prog_offset;
    brw->tes.base.prog_data = old_prog_data;
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index dfa40ac..c1a6938 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -137,9 +137,8 @@ brw_vs_debug_recompile(struct brw_context *brw, struct gl_program *prog,
    }
 }
 
-bool
+static bool
 brw_codegen_vs_prog(struct brw_context *brw,
-                    struct gl_shader_program *prog,
                     struct brw_program *vp,
                     struct brw_vs_prog_key *key)
 {
@@ -347,8 +346,6 @@ brw_vs_populate_key(struct brw_context *brw,
 void
 brw_upload_vs_prog(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->ctx;
-   struct gl_shader_program **current = ctx->_Shader->CurrentProgram;
    struct brw_vs_prog_key key;
    /* BRW_NEW_VERTEX_PROGRAM */
    struct brw_program *vp = (struct brw_program *)brw->vertex_program;
@@ -361,17 +358,14 @@ brw_upload_vs_prog(struct brw_context *brw)
    if (!brw_search_cache(&brw->cache, BRW_CACHE_VS_PROG,
 			 &key, sizeof(key),
 			 &brw->vs.base.prog_offset, &brw->vs.base.prog_data)) {
-      bool success = brw_codegen_vs_prog(brw, current[MESA_SHADER_VERTEX],
-                                         vp, &key);
+      bool success = brw_codegen_vs_prog(brw, vp, &key);
       (void) success;
       assert(success);
    }
 }
 
 bool
-brw_vs_precompile(struct gl_context *ctx,
-                  struct gl_shader_program *shader_prog,
-                  struct gl_program *prog)
+brw_vs_precompile(struct gl_context *ctx, struct gl_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_vs_prog_key key;
@@ -390,7 +384,7 @@ brw_vs_precompile(struct gl_context *ctx,
        (VARYING_BIT_COL0 | VARYING_BIT_COL1 | VARYING_BIT_BFC0 |
         VARYING_BIT_BFC1));
 
-   success = brw_codegen_vs_prog(brw, shader_prog, bvp, &key);
+   success = brw_codegen_vs_prog(brw, bvp, &key);
 
    brw->vs.base.prog_offset = old_prog_offset;
    brw->vs.base.prog_data = old_prog_data;
diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h
index 8a5024d..2b49afb 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.h
+++ b/src/mesa/drivers/dri/i965/brw_vs.h
@@ -58,12 +58,6 @@ brw_vs_outputs_written(struct brw_context *brw, struct brw_vs_prog_key *key,
 void
 brw_upload_vs_prog(struct brw_context *brw);
 
-bool
-brw_codegen_vs_prog(struct brw_context *brw,
-                    struct gl_shader_program *prog,
-                    struct brw_program *vp,
-                    struct brw_vs_prog_key *key);
-
 void
 brw_vs_populate_key(struct brw_context *brw,
                     struct brw_vs_prog_key *key);
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index de8671b..6e2b6a1 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -133,9 +133,8 @@ brw_wm_debug_recompile(struct brw_context *brw, struct gl_program *prog,
  * Depending on the instructions used (i.e. flow control instructions)
  * we'll use one of two code generators.
  */
-bool
+static bool
 brw_codegen_wm_prog(struct brw_context *brw,
-                    struct gl_shader_program *prog,
                     struct brw_program *fp,
                     struct brw_wm_prog_key *key,
                     struct brw_vue_map *vue_map)
@@ -564,8 +563,6 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
 void
 brw_upload_wm_prog(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->ctx;
-   struct gl_shader_program *current = ctx->_Shader->_CurrentFragmentProgram;
    struct brw_wm_prog_key key;
    struct brw_program *fp = (struct brw_program *) brw->fragment_program;
 
@@ -578,7 +575,7 @@ brw_upload_wm_prog(struct brw_context *brw)
                          &key, sizeof(key),
                          &brw->wm.base.prog_offset,
                          &brw->wm.base.prog_data)) {
-      bool success = brw_codegen_wm_prog(brw, current, fp, &key,
+      bool success = brw_codegen_wm_prog(brw, fp, &key,
                                          &brw->vue_map_geom_out);
       (void) success;
       assert(success);
@@ -586,9 +583,7 @@ brw_upload_wm_prog(struct brw_context *brw)
 }
 
 bool
-brw_fs_precompile(struct gl_context *ctx,
-                  struct gl_shader_program *shader_prog,
-                  struct gl_program *prog)
+brw_fs_precompile(struct gl_context *ctx, struct gl_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_wm_prog_key key;
@@ -638,7 +633,7 @@ brw_fs_precompile(struct gl_context *ctx,
                           false);
    }
 
-   bool success = brw_codegen_wm_prog(brw, shader_prog, bfp, &key, &vue_map);
+   bool success = brw_codegen_wm_prog(brw, bfp, &key, &vue_map);
 
    brw->wm.base.prog_offset = old_prog_offset;
    brw->wm.base.prog_data = old_prog_data;
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index 3a03c16..c037b3d 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -60,11 +60,6 @@ extern "C" {
 #endif
 
 bool brw_color_buffer_write_enabled(struct brw_context *brw);
-bool brw_codegen_wm_prog(struct brw_context *brw,
-                         struct gl_shader_program *prog,
-                         struct brw_program *fp,
-                         struct brw_wm_prog_key *key,
-                         struct brw_vue_map *vue_map);
 
 void
 brw_upload_wm_prog(struct brw_context *brw);
-- 
2.9.3



More information about the mesa-dev mailing list