[Mesa-dev] [PATCH 2/7] i965: Move program cache printing to brw_program_cache.c.

Eduardo Lima Mitev elima at igalia.com
Tue Jan 17 07:43:28 UTC 2017


If there is no plan to use brw_print_program_cache elsewhere, I would
rather keep it a static method where it is used. In general, I prefer
not polluting header files. Not a big deal anyway; feel free to ignore
the comment.

Reviewed-by: Eduardo Lima Mitev <elima at igalia.com>

On 01/17/2017 08:14 AM, Kenneth Graunke wrote:
> It makes sense to put a function which prints out the entire contents
> of the program cache in the file that implements the program cache.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_program_cache.c | 46 +++++++++++++++++++++
>  src/mesa/drivers/dri/i965/brw_state.h         |  2 +
>  src/mesa/drivers/dri/i965/brw_state_dump.c    | 58 +--------------------------
>  3 files changed, 49 insertions(+), 57 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_program_cache.c b/src/mesa/drivers/dri/i965/brw_program_cache.c
> index 3d95372bc0e..8939fb110fd 100644
> --- a/src/mesa/drivers/dri/i965/brw_program_cache.c
> +++ b/src/mesa/drivers/dri/i965/brw_program_cache.c
> @@ -480,3 +480,49 @@ brw_destroy_caches(struct brw_context *brw)
>  {
>     brw_destroy_cache(brw, &brw->cache);
>  }
> +
> +static const char *
> +cache_name(enum brw_cache_id cache_id)
> +{
> +   switch (cache_id) {
> +   case BRW_CACHE_VS_PROG:
> +      return "VS kernel";
> +   case BRW_CACHE_TCS_PROG:
> +      return "TCS kernel";
> +   case BRW_CACHE_TES_PROG:
> +      return "TES kernel";
> +   case BRW_CACHE_FF_GS_PROG:
> +      return "Fixed-function GS kernel";
> +   case BRW_CACHE_GS_PROG:
> +      return "GS kernel";
> +   case BRW_CACHE_CLIP_PROG:
> +      return "CLIP kernel";
> +   case BRW_CACHE_SF_PROG:
> +      return "SF kernel";
> +   case BRW_CACHE_FS_PROG:
> +      return "FS kernel";
> +   case BRW_CACHE_CS_PROG:
> +      return "CS kernel";
> +   default:
> +      return "unknown";
> +   }
> +}
> +
> +void
> +brw_print_program_cache(struct brw_context *brw)
> +{
> +   const struct brw_cache *cache = &brw->cache;
> +   struct brw_cache_item *item;
> +
> +   drm_intel_bo_map(cache->bo, false);
> +
> +   for (unsigned i = 0; i < cache->size; i++) {
> +      for (item = cache->items[i]; item; item = item->next) {
> +         fprintf(stderr, "%s:\n", cache_name(i));
> +         brw_disassemble(&brw->screen->devinfo, cache->bo->virtual,
> +                         item->offset, item->size, stderr);
> +      }
> +   }
> +
> +   drm_intel_bo_unmap(cache->bo);
> +}
> diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
> index bd82212be4d..f2349d8c037 100644
> --- a/src/mesa/drivers/dri/i965/brw_state.h
> +++ b/src/mesa/drivers/dri/i965/brw_state.h
> @@ -245,6 +245,8 @@ void brw_program_cache_check_size(struct brw_context *brw);
>  void brw_init_caches( struct brw_context *brw );
>  void brw_destroy_caches( struct brw_context *brw );
>  
> +void brw_print_program_cache(struct brw_context *brw);
> +
>  /***********************************************************************
>   * brw_state_batch.c
>   */
> diff --git a/src/mesa/drivers/dri/i965/brw_state_dump.c b/src/mesa/drivers/dri/i965/brw_state_dump.c
> index 1ed8aaa481c..13e76ec9d83 100644
> --- a/src/mesa/drivers/dri/i965/brw_state_dump.c
> +++ b/src/mesa/drivers/dri/i965/brw_state_dump.c
> @@ -718,62 +718,6 @@ static void dump_binding_table(struct brw_context *brw, uint32_t offset,
>  }
>  
>  static void
> -dump_prog_cache(struct brw_context *brw)
> -{
> -   struct brw_cache *cache = &brw->cache;
> -   unsigned int b;
> -
> -   drm_intel_bo_map(brw->cache.bo, false);
> -
> -   for (b = 0; b < cache->size; b++) {
> -      struct brw_cache_item *item;
> -
> -      for (item = cache->items[b]; item; item = item->next) {
> -	 const char *name;
> -
> -	 switch (item->cache_id) {
> -	 case BRW_CACHE_VS_PROG:
> -	    name = "VS kernel";
> -	    break;
> -         case BRW_CACHE_TCS_PROG:
> -            name = "TCS kernel";
> -            break;
> -         case BRW_CACHE_TES_PROG:
> -            name = "TES kernel";
> -            break;
> -	 case BRW_CACHE_FF_GS_PROG:
> -	    name = "Fixed-function GS kernel";
> -	    break;
> -         case BRW_CACHE_GS_PROG:
> -            name = "GS kernel";
> -            break;
> -	 case BRW_CACHE_CLIP_PROG:
> -	    name = "CLIP kernel";
> -	    break;
> -	 case BRW_CACHE_SF_PROG:
> -	    name = "SF kernel";
> -	    break;
> -	 case BRW_CACHE_FS_PROG:
> -	    name = "FS kernel";
> -	    break;
> -         case BRW_CACHE_CS_PROG:
> -            name = "CS kernel";
> -            break;
> -	 default:
> -	    name = "unknown";
> -	    break;
> -	 }
> -
> -         fprintf(stderr, "%s:\n", name);
> -         brw_disassemble(&brw->screen->devinfo, brw->cache.bo->virtual,
> -                         item->offset, item->size, stderr);
> -      }
> -   }
> -
> -   drm_intel_bo_unmap(brw->cache.bo);
> -}
> -
> -static void
>  dump_state_batch(struct brw_context *brw)
>  {
>     int i;
> @@ -880,5 +824,5 @@ void brw_debug_batch(struct brw_context *brw)
>     drm_intel_bo_unmap(brw->batch.bo);
>  
>     if (0)
> -      dump_prog_cache(brw);
> +      brw_print_program_cache(brw);
>  }
> 



More information about the mesa-dev mailing list