intel/perf: create a vtable entry for bo_unreference
authorMark Janes <mark.a.janes@intel.com>
Fri, 24 May 2019 21:31:27 +0000 (14:31 -0700)
committerMark Janes <mark.a.janes@intel.com>
Thu, 8 Aug 2019 04:33:55 +0000 (21:33 -0700)
In preparation for calling both Iris and i965 implementions from perf.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/intel/perf/gen_perf.h
src/mesa/drivers/dri/i965/brw_performance_query.c

index fa7d7f87c5773cb073c9882db51107f86a06a252..2e50345c1dbdfd8dd6b59da04f60a61de4bba591 100644 (file)
@@ -191,6 +191,7 @@ struct gen_perf_config {
 
    struct {
       void *(*bo_alloc)(void *bufmgr, const char *name, uint64_t size);
+      void (*bo_unreference)(void *bo);
    } vtbl;
 };
 
index 190769b92ccb424aba5010e5feb16c9217ec669a..980a042fc4940a32d9c36ff629da2ccdbc5c2628 100644 (file)
@@ -1119,7 +1119,7 @@ brw_begin_perf_query(struct gl_context *ctx,
       }
 
       if (obj->oa.bo) {
-         brw_bo_unreference(obj->oa.bo);
+         brw->perfquery.perf->vtbl.bo_unreference(obj->oa.bo);
          obj->oa.bo = NULL;
       }
 
@@ -1178,7 +1178,7 @@ brw_begin_perf_query(struct gl_context *ctx,
 
    case GEN_PERF_QUERY_TYPE_PIPELINE:
       if (obj->pipeline_stats.bo) {
-         brw_bo_unreference(obj->pipeline_stats.bo);
+         brw->perfquery.perf->vtbl.bo_unreference(obj->pipeline_stats.bo);
          obj->pipeline_stats.bo = NULL;
       }
 
@@ -1545,6 +1545,7 @@ brw_delete_perf_query(struct gl_context *ctx,
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_perf_query_object *obj = brw_perf_query(o);
+   struct gen_perf_config *perf_cfg = brw->perfquery.perf;
 
    /* We can assume that the frontend waits for a query to complete
     * before ever calling into here, so we don't have to worry about
@@ -1564,7 +1565,7 @@ brw_delete_perf_query(struct gl_context *ctx,
             dec_n_oa_users(brw);
          }
 
-         brw_bo_unreference(obj->oa.bo);
+         perf_cfg->vtbl.bo_unreference(obj->oa.bo);
          obj->oa.bo = NULL;
       }
 
@@ -1573,7 +1574,7 @@ brw_delete_perf_query(struct gl_context *ctx,
 
    case GEN_PERF_QUERY_TYPE_PIPELINE:
       if (obj->pipeline_stats.bo) {
-         brw_bo_unreference(obj->pipeline_stats.bo);
+         perf_cfg->vtbl.bo_unreference(obj->pipeline_stats.bo);
          obj->pipeline_stats.bo = NULL;
       }
       break;
@@ -1731,6 +1732,8 @@ brw_oa_bo_alloc(void *bufmgr, const char *name, uint64_t size)
    return brw_bo_alloc(bufmgr, name, size, BRW_MEMZONE_OTHER);
 }
 
+typedef void (*bo_unreference_t)(void *);
+
 static unsigned
 brw_init_perf_query_info(struct gl_context *ctx)
 {
@@ -1745,6 +1748,7 @@ brw_init_perf_query_info(struct gl_context *ctx)
 
    struct gen_perf_config *perf_cfg = brw->perfquery.perf;
    perf_cfg->vtbl.bo_alloc = brw_oa_bo_alloc;
+   perf_cfg->vtbl.bo_unreference = (bo_unreference_t)brw_bo_unreference;
 
    init_pipeline_statistic_query_registers(brw);
    brw_perf_query_register_mdapi_statistic_query(brw);