[Mesa-dev] [PATCH 3/3] i965: Call gen6_upload_push_constants() even when the stage is disabled.

Pohjolainen, Topi topi.pohjolainen at gmail.com
Tue Oct 24 06:21:39 UTC 2017


On Mon, Oct 23, 2017 at 11:57:53AM -0700, Kenneth Graunke wrote:
> This properly sets stage_state->push_constant_dirty = true, so that we
> emit 3DSTATE_CONSTANT_XS to disable the constant buffer for the shader
> stage.  It also sets stage_state->push_const_size = 0.
> ---
>  src/mesa/drivers/dri/i965/gen6_constant_state.c |  9 +++++++--
>  src/mesa/drivers/dri/i965/genX_state_upload.c   | 25 +++++++++----------------
>  2 files changed, 16 insertions(+), 18 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/gen6_constant_state.c b/src/mesa/drivers/dri/i965/gen6_constant_state.c
> index 6b5d2e66cc9..acf7454cef5 100644
> --- a/src/mesa/drivers/dri/i965/gen6_constant_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_constant_state.c
> @@ -130,9 +130,14 @@ gen6_upload_push_constants(struct brw_context *brw,
>     const struct gen_device_info *devinfo = &brw->screen->devinfo;
>     struct gl_context *ctx = &brw->ctx;
>  
> -   _mesa_shader_write_subroutine_indices(ctx, stage_state->stage);
> +   bool active = prog_data &&
> +      (stage_state->stage != MESA_SHADER_TESS_CTRL ||
> +       brw->programs[MESA_SHADER_TESS_EVAL]);

Had to read this condition a few times but it looks to do exactly what you
wrote in the commit. Series:

Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>

>  
> -   if (prog_data->nr_params == 0) {
> +   if (active)
> +      _mesa_shader_write_subroutine_indices(ctx, stage_state->stage);
> +
> +   if (!active || prog_data->nr_params == 0) {
>        stage_state->push_const_size = 0;
>     } else {
>        /* Updates the ParamaterValues[i] pointers for all parameters of the
> diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
> index f2b3e4570b2..4ccfd489191 100644
> --- a/src/mesa/drivers/dri/i965/genX_state_upload.c
> +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
> @@ -3165,12 +3165,10 @@ genX(upload_gs_push_constants)(struct brw_context *brw)
>     /* BRW_NEW_GEOMETRY_PROGRAM */
>     const struct gl_program *gp = brw->programs[MESA_SHADER_GEOMETRY];
>  
> -   if (gp) {
> -      /* BRW_NEW_GS_PROG_DATA */
> -      struct brw_stage_prog_data *prog_data = brw->gs.base.prog_data;
> +   /* BRW_NEW_GS_PROG_DATA */
> +   struct brw_stage_prog_data *prog_data = brw->gs.base.prog_data;
>  
> -      gen6_upload_push_constants(brw, gp, prog_data, stage_state);
> -   }
> +   gen6_upload_push_constants(brw, gp, prog_data, stage_state);
>  }
>  
>  static const struct brw_tracked_state genX(gs_push_constants) = {
> @@ -4027,11 +4025,9 @@ genX(upload_tes_push_constants)(struct brw_context *brw)
>     /* BRW_NEW_TESS_PROGRAMS */
>     const struct gl_program *tep = brw->programs[MESA_SHADER_TESS_EVAL];
>  
> -   if (tep) {
> -      /* BRW_NEW_TES_PROG_DATA */
> -      const struct brw_stage_prog_data *prog_data = brw->tes.base.prog_data;
> -      gen6_upload_push_constants(brw, tep, prog_data, stage_state);
> -   }
> +   /* BRW_NEW_TES_PROG_DATA */
> +   const struct brw_stage_prog_data *prog_data = brw->tes.base.prog_data;
> +   gen6_upload_push_constants(brw, tep, prog_data, stage_state);
>  }
>  
>  static const struct brw_tracked_state genX(tes_push_constants) = {
> @@ -4051,14 +4047,11 @@ genX(upload_tcs_push_constants)(struct brw_context *brw)
>     struct brw_stage_state *stage_state = &brw->tcs.base;
>     /* BRW_NEW_TESS_PROGRAMS */
>     const struct gl_program *tcp = brw->programs[MESA_SHADER_TESS_CTRL];
> -   bool active = brw->programs[MESA_SHADER_TESS_EVAL];
>  
> -   if (active) {
> -      /* BRW_NEW_TCS_PROG_DATA */
> -      const struct brw_stage_prog_data *prog_data = brw->tcs.base.prog_data;
> +   /* BRW_NEW_TCS_PROG_DATA */
> +   const struct brw_stage_prog_data *prog_data = brw->tcs.base.prog_data;
>  
> -      gen6_upload_push_constants(brw, tcp, prog_data, stage_state);
> -   }
> +   gen6_upload_push_constants(brw, tcp, prog_data, stage_state);
>  }
>  
>  static const struct brw_tracked_state genX(tcs_push_constants) = {
> -- 
> 2.14.2
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list