[Mesa-dev] [i965] i965/draw: Move constant formation outside of for loop and use an enum.

Ian Romanick idr at freedesktop.org
Tue Aug 6 12:31:48 PDT 2013


On 08/06/2013 12:10 PM, mmueller wrote:
> The content of this patch is trivial, the real objective is to become familiar with
> the process and to introduce myself. All of my dealings with Mesa3D over the last
> ~14 years have been in the proprietary arena, specifically developing optimized
> Mesa3D/Gallium based proprietary drivers for specialized embedded applications.
> The focus of my upcoming Mesa-dev contributions will be on i965 performance
> improvements, specifically with current/new Intel hardware.

For additional commentary like this, the usual way to add it after the 
--- (below) by adding --annotate to the 'git send-email' command line. 
The --annotate option opens an editor for each patch before sending it. 
  Putting the text after the --- prevents it from being in the commit 
message when the patch is applied (using 'git am').

> Signed-off-by: mmueller <MarkKMueller at gmail.com>
> ---
>   src/mesa/drivers/dri/i965/brw_draw.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
> index 6170d07..e11d0d8 100644
> --- a/src/mesa/drivers/dri/i965/brw_draw.c
> +++ b/src/mesa/drivers/dri/i965/brw_draw.c
> @@ -367,6 +367,15 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
>      bool retval = true;
>      GLuint i;
>      bool fail_next = false;
> +   enum {
> +       estimated_max_prim_size =
> +           512 + /* batchbuffer commands */
> +           ((BRW_MAX_TEX_UNIT * (sizeof(struct brw_sampler_state) + sizeof(struct gen5_sampler_default_color)))) +
> +           1024 + /* gen6 VS push constants */
> +           1024 + /* gen6 WM push constants */
> +           512 /* misc. pad */
> +   };
> +

I think this would be better as 'const int estimated_max_prim_size = 
...'.  Using an enum is mostly the same (but also enforces that it's a 
compile-time constant), but it looks weird. :)

>      if (ctx->NewState)
>         _mesa_update_state( ctx );
> @@ -405,15 +414,6 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
>      brw->state.dirty.brw |= BRW_NEW_VERTICES;
>
>      for (i = 0; i < nr_prims; i++) {
> -      int estimated_max_prim_size;
> -
> -      estimated_max_prim_size = 512; /* batchbuffer commands */
> -      estimated_max_prim_size += (BRW_MAX_TEX_UNIT *
> -				  (sizeof(struct brw_sampler_state) +
> -				   sizeof(struct gen5_sampler_default_color)));
> -      estimated_max_prim_size += 1024; /* gen6 VS push constants */
> -      estimated_max_prim_size += 1024; /* gen6 WM push constants */
> -      estimated_max_prim_size += 512; /* misc. pad */
>
>         /* Flush the batch if it's approaching full, so that we don't wrap while
>          * we've got validated state that needs to be in the same batch as the
>



More information about the mesa-dev mailing list