Re: [Mesa-dev] [PATCH] llvmpipe: Remove x/y from cmd_bin

2013-05-17 Thread Jose Fonseca


- Original Message -
> Am 16.05.2013 21:44, schrieb Adam Jackson:
> > These were mostly just a waste of memory and cache pressure, and were
> > really only used for debugging.
> > 
> > This change reduces instruction count (as measured by callgrind's Ir
> > event) of gnome-shell-perf-tool on Ivybridge by 3.5% ± 0.015% (n=20).
> > 
> > Signed-off-by: Adam Jackson 
> > ---
> >  src/gallium/drivers/llvmpipe/lp_rast.c   | 37
> >  +++-
> >  src/gallium/drivers/llvmpipe/lp_rast_debug.c | 19 +++---
> >  src/gallium/drivers/llvmpipe/lp_rast_priv.h  |  2 +-
> >  src/gallium/drivers/llvmpipe/lp_scene.c  |  4 ++-
> >  src/gallium/drivers/llvmpipe/lp_scene.h  |  4 +--
> >  src/gallium/drivers/llvmpipe/lp_setup.c  | 11 +
> >  6 files changed, 30 insertions(+), 47 deletions(-)
> > 
> > diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c
> > b/src/gallium/drivers/llvmpipe/lp_rast.c
> > index a557db4..3dc00ef 100644
> > --- a/src/gallium/drivers/llvmpipe/lp_rast.c
> > +++ b/src/gallium/drivers/llvmpipe/lp_rast.c
> > @@ -87,13 +87,14 @@ lp_rast_end( struct lp_rasterizer *rast )
> >   */
> >  static void
> >  lp_rast_tile_begin(struct lp_rasterizer_task *task,
> > -   const struct cmd_bin *bin)
> > +   const struct cmd_bin *bin,
> > +   int x, int y)
> >  {
> > -   LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, bin->x, bin->y);
> > +   LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, x, y);
> >  
> > task->bin = bin;
> > -   task->x = bin->x * TILE_SIZE;
> > -   task->y = bin->y * TILE_SIZE;
> > +   task->x = x * TILE_SIZE;
> > +   task->y = y * TILE_SIZE;
> >  
> > /* reset pointers to color and depth tile(s) */
> > memset(task->color_tiles, 0, sizeof(task->color_tiles));
> > @@ -551,13 +552,14 @@ static lp_rast_cmd_func dispatch[LP_RAST_OP_MAX] =
> >  
> >  static void
> >  do_rasterize_bin(struct lp_rasterizer_task *task,
> > - const struct cmd_bin *bin)
> > + const struct cmd_bin *bin,
> > + int x, int y)
> >  {
> > const struct cmd_block *block;
> > unsigned k;
> >  
> > if (0)
> > -  lp_debug_bin(bin);
> > +  lp_debug_bin(bin, x, y);
> >  
> > for (block = bin->head; block; block = block->next) {
> >for (k = 0; k < block->count; k++) {
> > @@ -576,11 +578,11 @@ do_rasterize_bin(struct lp_rasterizer_task *task,
> >   */
> >  static void
> >  rasterize_bin(struct lp_rasterizer_task *task,
> > -  const struct cmd_bin *bin )
> > +  const struct cmd_bin *bin, int x, int y )
> >  {
> > -   lp_rast_tile_begin( task, bin );
> > +   lp_rast_tile_begin( task, bin, x, y );
> >  
> > -   do_rasterize_bin(task, bin);
> > +   do_rasterize_bin(task, bin, x, y);
> >  
> > lp_rast_tile_end(task);
> >  
> > @@ -622,27 +624,16 @@ rasterize_scene(struct lp_rasterizer_task *task,
> >  
> > if (!task->rast->no_rast && !scene->discard) {
> >/* loop over scene bins, rasterize each */
> > -#if 0
> > -  {
> > - unsigned i, j;
> > - for (i = 0; i < scene->tiles_x; i++) {
> > -for (j = 0; j < scene->tiles_y; j++) {
> > -   struct cmd_bin *bin = lp_scene_get_bin(scene, i, j);
> > -   rasterize_bin(task, bin, i, j);
> > -}
> > - }
> > -  }
> > -#else
> >{
> >   struct cmd_bin *bin;
> > + int i, j;
> >  
> >   assert(scene);
> > - while ((bin = lp_scene_bin_iter_next(scene))) {
> > + while ((bin = lp_scene_bin_iter_next(scene, &i, &j))) {
> >  if (!is_empty_bin( bin ))
> > -   rasterize_bin(task, bin);
> > +   rasterize_bin(task, bin, i, j);
> >   }
> >}
> > -#endif
> > }
> >  
> >  
> > diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c
> > b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
> > index 4008251..3bc75aa 100644
> > --- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c
> > +++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
> > @@ -90,13 +90,13 @@ is_blend( const struct lp_rast_state *state,
> >  
> >  
> >  static void
> > -debug_bin( const struct cmd_bin *bin )
> > +debug_bin( const struct cmd_bin *bin, int x, int y )
> >  {
> > const struct lp_rast_state *state = NULL;
> > const struct cmd_block *head = bin->head;
> > int i, j = 0;
> >  
> > -   debug_printf("bin %d,%d:\n", bin->x, bin->y);
> > +   debug_printf("bin %d,%d:\n", x, y);
> >  
> > while (head) {
> >for (i = 0; i < head->count; i++, j++) {
> > @@ -231,13 +231,14 @@ debug_triangle(int tilex, int tiley,
> >  static void
> >  do_debug_bin( struct tile *tile,
> >const struct cmd_bin *bin,
> > +  int x, int y,
> >boolean print_cmds)
> >  {
> > unsigned k, j = 0;
> > const struct cmd_block *block;
> >  
> > -   int tx = bin->x * TILE_SIZE;
> > -   int ty = bin->y * TI

Re: [Mesa-dev] [PATCH] llvmpipe: Remove x/y from cmd_bin

2013-05-16 Thread Roland Scheidegger
Am 16.05.2013 21:44, schrieb Adam Jackson:
> These were mostly just a waste of memory and cache pressure, and were
> really only used for debugging.
> 
> This change reduces instruction count (as measured by callgrind's Ir
> event) of gnome-shell-perf-tool on Ivybridge by 3.5% ± 0.015% (n=20).
> 
> Signed-off-by: Adam Jackson 
> ---
>  src/gallium/drivers/llvmpipe/lp_rast.c   | 37 
> +++-
>  src/gallium/drivers/llvmpipe/lp_rast_debug.c | 19 +++---
>  src/gallium/drivers/llvmpipe/lp_rast_priv.h  |  2 +-
>  src/gallium/drivers/llvmpipe/lp_scene.c  |  4 ++-
>  src/gallium/drivers/llvmpipe/lp_scene.h  |  4 +--
>  src/gallium/drivers/llvmpipe/lp_setup.c  | 11 +
>  6 files changed, 30 insertions(+), 47 deletions(-)
> 
> diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
> b/src/gallium/drivers/llvmpipe/lp_rast.c
> index a557db4..3dc00ef 100644
> --- a/src/gallium/drivers/llvmpipe/lp_rast.c
> +++ b/src/gallium/drivers/llvmpipe/lp_rast.c
> @@ -87,13 +87,14 @@ lp_rast_end( struct lp_rasterizer *rast )
>   */
>  static void
>  lp_rast_tile_begin(struct lp_rasterizer_task *task,
> -   const struct cmd_bin *bin)
> +   const struct cmd_bin *bin,
> +   int x, int y)
>  {
> -   LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, bin->x, bin->y);
> +   LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, x, y);
>  
> task->bin = bin;
> -   task->x = bin->x * TILE_SIZE;
> -   task->y = bin->y * TILE_SIZE;
> +   task->x = x * TILE_SIZE;
> +   task->y = y * TILE_SIZE;
>  
> /* reset pointers to color and depth tile(s) */
> memset(task->color_tiles, 0, sizeof(task->color_tiles));
> @@ -551,13 +552,14 @@ static lp_rast_cmd_func dispatch[LP_RAST_OP_MAX] =
>  
>  static void
>  do_rasterize_bin(struct lp_rasterizer_task *task,
> - const struct cmd_bin *bin)
> + const struct cmd_bin *bin,
> + int x, int y)
>  {
> const struct cmd_block *block;
> unsigned k;
>  
> if (0)
> -  lp_debug_bin(bin);
> +  lp_debug_bin(bin, x, y);
>  
> for (block = bin->head; block; block = block->next) {
>for (k = 0; k < block->count; k++) {
> @@ -576,11 +578,11 @@ do_rasterize_bin(struct lp_rasterizer_task *task,
>   */
>  static void
>  rasterize_bin(struct lp_rasterizer_task *task,
> -  const struct cmd_bin *bin )
> +  const struct cmd_bin *bin, int x, int y )
>  {
> -   lp_rast_tile_begin( task, bin );
> +   lp_rast_tile_begin( task, bin, x, y );
>  
> -   do_rasterize_bin(task, bin);
> +   do_rasterize_bin(task, bin, x, y);
>  
> lp_rast_tile_end(task);
>  
> @@ -622,27 +624,16 @@ rasterize_scene(struct lp_rasterizer_task *task,
>  
> if (!task->rast->no_rast && !scene->discard) {
>/* loop over scene bins, rasterize each */
> -#if 0
> -  {
> - unsigned i, j;
> - for (i = 0; i < scene->tiles_x; i++) {
> -for (j = 0; j < scene->tiles_y; j++) {
> -   struct cmd_bin *bin = lp_scene_get_bin(scene, i, j);
> -   rasterize_bin(task, bin, i, j);
> -}
> - }
> -  }
> -#else
>{
>   struct cmd_bin *bin;
> + int i, j;
>  
>   assert(scene);
> - while ((bin = lp_scene_bin_iter_next(scene))) {
> + while ((bin = lp_scene_bin_iter_next(scene, &i, &j))) {
>  if (!is_empty_bin( bin ))
> -   rasterize_bin(task, bin);
> +   rasterize_bin(task, bin, i, j);
>   }
>}
> -#endif
> }
>  
>  
> diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c 
> b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
> index 4008251..3bc75aa 100644
> --- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c
> +++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
> @@ -90,13 +90,13 @@ is_blend( const struct lp_rast_state *state,
>  
>  
>  static void
> -debug_bin( const struct cmd_bin *bin )
> +debug_bin( const struct cmd_bin *bin, int x, int y )
>  {
> const struct lp_rast_state *state = NULL;
> const struct cmd_block *head = bin->head;
> int i, j = 0;
>  
> -   debug_printf("bin %d,%d:\n", bin->x, bin->y);
> +   debug_printf("bin %d,%d:\n", x, y);
>  
> while (head) {
>for (i = 0; i < head->count; i++, j++) {
> @@ -231,13 +231,14 @@ debug_triangle(int tilex, int tiley,
>  static void
>  do_debug_bin( struct tile *tile,
>const struct cmd_bin *bin,
> +  int x, int y,
>boolean print_cmds)
>  {
> unsigned k, j = 0;
> const struct cmd_block *block;
>  
> -   int tx = bin->x * TILE_SIZE;
> -   int ty = bin->y * TILE_SIZE;
> +   int tx = x * TILE_SIZE;
> +   int ty = y * TILE_SIZE;
>  
> memset(tile->data, ' ', sizeof tile->data);
> tile->coverage = 0;
> @@ -286,13 +287,13 @@ do_debug_bin( struct tile *tile,
>  }
>  
>  void
> -lp_debug_bin( const struct cmd_bin *bin)
> +lp_debug_bin( const struct cmd_bin 

Re: [Mesa-dev] [PATCH] llvmpipe: Remove x/y from cmd_bin

2013-05-16 Thread Adam Jackson
On Thu, 2013-05-16 at 15:44 -0400, Adam Jackson wrote:
> These were mostly just a waste of memory and cache pressure, and were
> really only used for debugging.
> 
> This change reduces instruction count (as measured by callgrind's Ir
> event) of gnome-shell-perf-tool on Ivybridge by 3.5% ± 0.015% (n=20).

These numbers are somewhat spurious, since it appears what I actually
recorded was the execution of the python harness and not of gnome-shell
itself.  Still the correlation is strong with this one, so I suspect the
improvement is real even if the numbers are unrelated.

I'll get better data, sorry about that.

- ajax

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] llvmpipe: Remove x/y from cmd_bin

2013-05-16 Thread Adam Jackson
These were mostly just a waste of memory and cache pressure, and were
really only used for debugging.

This change reduces instruction count (as measured by callgrind's Ir
event) of gnome-shell-perf-tool on Ivybridge by 3.5% ± 0.015% (n=20).

Signed-off-by: Adam Jackson 
---
 src/gallium/drivers/llvmpipe/lp_rast.c   | 37 +++-
 src/gallium/drivers/llvmpipe/lp_rast_debug.c | 19 +++---
 src/gallium/drivers/llvmpipe/lp_rast_priv.h  |  2 +-
 src/gallium/drivers/llvmpipe/lp_scene.c  |  4 ++-
 src/gallium/drivers/llvmpipe/lp_scene.h  |  4 +--
 src/gallium/drivers/llvmpipe/lp_setup.c  | 11 +
 6 files changed, 30 insertions(+), 47 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index a557db4..3dc00ef 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -87,13 +87,14 @@ lp_rast_end( struct lp_rasterizer *rast )
  */
 static void
 lp_rast_tile_begin(struct lp_rasterizer_task *task,
-   const struct cmd_bin *bin)
+   const struct cmd_bin *bin,
+   int x, int y)
 {
-   LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, bin->x, bin->y);
+   LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, x, y);
 
task->bin = bin;
-   task->x = bin->x * TILE_SIZE;
-   task->y = bin->y * TILE_SIZE;
+   task->x = x * TILE_SIZE;
+   task->y = y * TILE_SIZE;
 
/* reset pointers to color and depth tile(s) */
memset(task->color_tiles, 0, sizeof(task->color_tiles));
@@ -551,13 +552,14 @@ static lp_rast_cmd_func dispatch[LP_RAST_OP_MAX] =
 
 static void
 do_rasterize_bin(struct lp_rasterizer_task *task,
- const struct cmd_bin *bin)
+ const struct cmd_bin *bin,
+ int x, int y)
 {
const struct cmd_block *block;
unsigned k;
 
if (0)
-  lp_debug_bin(bin);
+  lp_debug_bin(bin, x, y);
 
for (block = bin->head; block; block = block->next) {
   for (k = 0; k < block->count; k++) {
@@ -576,11 +578,11 @@ do_rasterize_bin(struct lp_rasterizer_task *task,
  */
 static void
 rasterize_bin(struct lp_rasterizer_task *task,
-  const struct cmd_bin *bin )
+  const struct cmd_bin *bin, int x, int y )
 {
-   lp_rast_tile_begin( task, bin );
+   lp_rast_tile_begin( task, bin, x, y );
 
-   do_rasterize_bin(task, bin);
+   do_rasterize_bin(task, bin, x, y);
 
lp_rast_tile_end(task);
 
@@ -622,27 +624,16 @@ rasterize_scene(struct lp_rasterizer_task *task,
 
if (!task->rast->no_rast && !scene->discard) {
   /* loop over scene bins, rasterize each */
-#if 0
-  {
- unsigned i, j;
- for (i = 0; i < scene->tiles_x; i++) {
-for (j = 0; j < scene->tiles_y; j++) {
-   struct cmd_bin *bin = lp_scene_get_bin(scene, i, j);
-   rasterize_bin(task, bin, i, j);
-}
- }
-  }
-#else
   {
  struct cmd_bin *bin;
+ int i, j;
 
  assert(scene);
- while ((bin = lp_scene_bin_iter_next(scene))) {
+ while ((bin = lp_scene_bin_iter_next(scene, &i, &j))) {
 if (!is_empty_bin( bin ))
-   rasterize_bin(task, bin);
+   rasterize_bin(task, bin, i, j);
  }
   }
-#endif
}
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c 
b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
index 4008251..3bc75aa 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
@@ -90,13 +90,13 @@ is_blend( const struct lp_rast_state *state,
 
 
 static void
-debug_bin( const struct cmd_bin *bin )
+debug_bin( const struct cmd_bin *bin, int x, int y )
 {
const struct lp_rast_state *state = NULL;
const struct cmd_block *head = bin->head;
int i, j = 0;
 
-   debug_printf("bin %d,%d:\n", bin->x, bin->y);
+   debug_printf("bin %d,%d:\n", x, y);
 
while (head) {
   for (i = 0; i < head->count; i++, j++) {
@@ -231,13 +231,14 @@ debug_triangle(int tilex, int tiley,
 static void
 do_debug_bin( struct tile *tile,
   const struct cmd_bin *bin,
+  int x, int y,
   boolean print_cmds)
 {
unsigned k, j = 0;
const struct cmd_block *block;
 
-   int tx = bin->x * TILE_SIZE;
-   int ty = bin->y * TILE_SIZE;
+   int tx = x * TILE_SIZE;
+   int ty = y * TILE_SIZE;
 
memset(tile->data, ' ', sizeof tile->data);
tile->coverage = 0;
@@ -286,13 +287,13 @@ do_debug_bin( struct tile *tile,
 }
 
 void
-lp_debug_bin( const struct cmd_bin *bin)
+lp_debug_bin( const struct cmd_bin *bin, int i, int j)
 {
struct tile tile;
int x,y;
 
if (bin->head) {
-  do_debug_bin(&tile, bin, TRUE);
+  do_debug_bin(&tile, bin, i, j, TRUE);
 
   
debug_printf("--\n");
   for (y = 0; y < TILE_SIZE; y++) {
@@ -349,9 +350,9 @@ lp_debug_draw_bins