<p dir="ltr">Not a big fan. This makes the prog_data structures less self-contained.  You shouldn't have to look up an almost unrelated structure in order to figure out how big this one is.  Also, I've been trying to move us in the direction of *more* stuff in prog_data, not less, so that we aren't looking up the GL data structures in state setup any more than we have to.</p>
<p dir="ltr">--Jason</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Sep 26, 2016 7:31 AM, "Lionel Landwerlin" <<a href="mailto:llandwerlin@gmail.com">llandwerlin@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We can access this value through gl_shader_program.<br>
<br>
Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a><wbr>><br>
Cc: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_<wbr>compiler.h  | 1 -<br>
 src/mesa/drivers/dri/i965/brw_<wbr>cs.c        | 1 -<br>
 src/mesa/drivers/dri/i965/brw_<wbr>gs.c        | 1 -<br>
 src/mesa/drivers/dri/i965/brw_<wbr>tcs.c       | 1 -<br>
 src/mesa/drivers/dri/i965/brw_<wbr>tes.c       | 1 -<br>
 src/mesa/drivers/dri/i965/brw_<wbr>vs.c        | 5 +----<br>
 src/mesa/drivers/dri/i965/brw_<wbr>wm.c        | 4 +---<br>
 src/mesa/drivers/dri/i965/<wbr>gen7_l3_state.c | 5 ++++-<br>
 8 files changed, 6 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_compiler.h b/src/mesa/drivers/dri/i965/<wbr>brw_compiler.h<br>
index 445c166..437528b 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_compiler.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_compiler.h<br>
@@ -344,7 +344,6 @@ struct brw_stage_prog_data {<br>
<br>
    GLuint nr_params;       /**< number of float params/constants */<br>
    GLuint nr_pull_params;<br>
-   unsigned nr_image_params;<br>
<br>
    unsigned curb_read_length;<br>
    unsigned total_scratch;<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_cs.c b/src/mesa/drivers/dri/i965/<wbr>brw_cs.c<br>
index 4e746fe..febf53a 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_cs.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_cs.c<br>
@@ -106,7 +106,6 @@ brw_codegen_cs_prog(struct brw_context *brw,<br>
    prog_data.base.image_param =<br>
       rzalloc_array(NULL, struct brw_image_param, cs->base.NumImages);<br>
    prog_data.base.nr_params = param_count;<br>
-   prog_data.base.nr_image_params = cs->base.NumImages;<br>
<br>
    brw_nir_setup_glsl_uniforms(<wbr>cp->program.Base.nir, prog, &cp->program.Base,<br>
                                &prog_data.base, true);<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_gs.c b/src/mesa/drivers/dri/i965/<wbr>brw_gs.c<br>
index 741216c..486416a 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_gs.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_gs.c<br>
@@ -128,7 +128,6 @@ brw_codegen_gs_prog(struct brw_context *brw,<br>
    prog_data.base.base.image_<wbr>param =<br>
       rzalloc_array(NULL, struct brw_image_param, gs->NumImages);<br>
    prog_data.base.base.nr_params = param_count;<br>
-   prog_data.base.base.nr_image_<wbr>params = gs->NumImages;<br>
<br>
    brw_nir_setup_glsl_uniforms(<wbr>gp->program.Base.nir, prog, &gp->program.Base,<br>
                                &prog_data.base.base,<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_tcs.c b/src/mesa/drivers/dri/i965/<wbr>brw_tcs.c<br>
index 7e6c69a..88df595 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_tcs.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_tcs.c<br>
@@ -216,7 +216,6 @@ brw_codegen_tcs_prog(struct brw_context *brw,<br>
<br>
       prog_data.base.base.image_<wbr>param =<br>
          rzalloc_array(NULL, struct brw_image_param, tcs->NumImages);<br>
-      prog_data.base.base.nr_image_<wbr>params = tcs->NumImages;<br>
<br>
       brw_nir_setup_glsl_uniforms(<wbr>nir, shader_prog, &tcp->program.Base,<br>
                                   &prog_data.base.base,<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_tes.c b/src/mesa/drivers/dri/i965/<wbr>brw_tes.c<br>
index 87ada17..88739b9 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_tes.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_tes.c<br>
@@ -161,7 +161,6 @@ brw_codegen_tes_prog(struct brw_context *brw,<br>
    prog_data.base.base.image_<wbr>param =<br>
       rzalloc_array(NULL, struct brw_image_param, tes->NumImages);<br>
    prog_data.base.base.nr_params = param_count;<br>
-   prog_data.base.base.nr_image_<wbr>params = tes->NumImages;<br>
<br>
    prog_data.base.cull_distance_<wbr>mask =<br>
       ((1 << tep->program.Base.<wbr>CullDistanceArraySize) - 1) <<<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_vs.c b/src/mesa/drivers/dri/i965/<wbr>brw_vs.c<br>
index ba7315e..c242190 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_vs.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_vs.c<br>
@@ -123,9 +123,6 @@ brw_codegen_vs_prog(struct brw_context *brw,<br>
     */<br>
    int param_count = vp->program.Base.nir->num_<wbr>uniforms / 4;<br>
<br>
-   if (vs)<br>
-      prog_data.base.base.nr_image_<wbr>params = vs->base.NumImages;<br>
-<br>
    /* vec4_visitor::setup_uniform_<wbr>clipplane_values() also uploads user clip<br>
     * planes as uniforms.<br>
     */<br>
@@ -137,7 +134,7 @@ brw_codegen_vs_prog(struct brw_context *brw,<br>
       rzalloc_array(NULL, const gl_constant_value *, param_count);<br>
    stage_prog_data->image_param =<br>
       rzalloc_array(NULL, struct brw_image_param,<br>
-                    stage_prog_data->nr_image_<wbr>params);<br>
+                    vs ? vs->base.NumImages : 0);<br>
    stage_prog_data->nr_params = param_count;<br>
<br>
    if (prog) {<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_wm.c b/src/mesa/drivers/dri/i965/<wbr>brw_wm.c<br>
index 6ffe7c8..1af6bf7 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_wm.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_wm.c<br>
@@ -106,8 +106,6 @@ brw_codegen_wm_prog(struct brw_context *brw,<br>
     * by the state cache.<br>
     */<br>
    int param_count = fp->program.Base.nir->num_<wbr>uniforms / 4;<br>
-   if (fs)<br>
-      prog_data.base.nr_image_params = fs->base.NumImages;<br>
    /* The backend also sometimes adds params for texture size. */<br>
    param_count += 2 * ctx->Const.Program[MESA_<wbr>SHADER_FRAGMENT].<wbr>MaxTextureImageUnits;<br>
    prog_data.base.param =<br>
@@ -116,7 +114,7 @@ brw_codegen_wm_prog(struct brw_context *brw,<br>
       rzalloc_array(NULL, const gl_constant_value *, param_count);<br>
    prog_data.base.image_param =<br>
       rzalloc_array(NULL, struct brw_image_param,<br>
-                    prog_data.base.nr_image_<wbr>params);<br>
+                    fs ? fs->base.NumImages : 0);<br>
    prog_data.base.nr_params = param_count;<br>
<br>
    if (prog) {<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>gen7_l3_state.c b/src/mesa/drivers/dri/i965/<wbr>gen7_l3_state.c<br>
index ad70491..92e8788 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>gen7_l3_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>gen7_l3_state.c<br>
@@ -51,10 +51,13 @@ get_pipeline_state_l3_weights(<wbr>const struct brw_context *brw)<br>
    for (unsigned i = 0; i < ARRAY_SIZE(stage_states); i++) {<br>
       const struct gl_shader_program *prog =<br>
          brw->ctx._Shader-><wbr>CurrentProgram[stage_states[i]<wbr>->stage];<br>
+      const struct gl_linked_shader *shader =<br>
+         prog ? prog->_LinkedShaders[stage_<wbr>states[i]->stage] : NULL;<br>
       const struct brw_stage_prog_data *prog_data = stage_states[i]->prog_data;<br>
<br>
       needs_dc |= (prog && prog->NumAtomicBuffers) ||<br>
-         (prog_data && (prog_data->total_scratch || prog_data->nr_image_params));<br>
+         (shader && shader->NumImages) ||<br>
+         (prog_data && prog_data->total_scratch);<br>
       needs_slm |= prog_data && prog_data->total_shared;<br>
    }<br>
<br>
--<br>
2.9.3<br>
<br>
</blockquote></div></div>