[Mesa-dev] [PATCH] i965: First step toward prelocation

Ben Widawsky benjamin.widawsky at intel.com
Fri Aug 22 10:14:54 PDT 2014


On Fri, Aug 22, 2014 at 08:15:28AM -0400, Alex Deucher wrote:
> On Thu, Aug 21, 2014 at 11:12 PM, Ben Widawsky
> <benjamin.widawsky at intel.com> wrote:
> > This was a quick proof of concept to show the new API for prelocating
> > buffers.
> >
> 
> What are prelocated buffers?

http://lists.freedesktop.org/archives/mesa-dev/2014-August/066432.html

> 
> Alex
> 
> > It needs way more testing, to not ifdef the no-relocs, and to do a
> > libdrm ABI dep bump.
> > ---
> >  src/mesa/drivers/dri/i965/Makefile.am               | 1 +
> >  src/mesa/drivers/dri/i965/brw_performance_monitor.c | 6 +++---
> >  src/mesa/drivers/dri/i965/brw_program.c             | 5 +++--
> >  src/mesa/drivers/dri/i965/brw_queryobj.c            | 6 +++---
> >  src/mesa/drivers/dri/i965/brw_state_cache.c         | 4 ++--
> >  src/mesa/drivers/dri/i965/intel_batchbuffer.c       | 3 +++
> >  src/mesa/drivers/dri/i965/intel_batchbuffer.h       | 8 ++++++++
> >  7 files changed, 23 insertions(+), 10 deletions(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/Makefile.am b/src/mesa/drivers/dri/i965/Makefile.am
> > index 5809dc6..4b20d36 100644
> > --- a/src/mesa/drivers/dri/i965/Makefile.am
> > +++ b/src/mesa/drivers/dri/i965/Makefile.am
> > @@ -24,6 +24,7 @@
> >  include Makefile.sources
> >
> >  AM_CFLAGS = \
> > +        -DNO_RELOC \
> >         -I$(top_srcdir)/include \
> >         -I$(top_srcdir)/src/ \
> >         -I$(top_srcdir)/src/mapi \
> > diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c
> > index edfa3d2..e30c527 100644
> > --- a/src/mesa/drivers/dri/i965/brw_performance_monitor.c
> > +++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c
> > @@ -1105,13 +1105,13 @@ brw_begin_perf_monitor(struct gl_context *ctx,
> >         * wasting memory for contexts that don't use performance monitors.
> >         */
> >        if (!brw->perfmon.bookend_bo) {
> > -         brw->perfmon.bookend_bo = drm_intel_bo_alloc(brw->bufmgr,
> > +         brw->perfmon.bookend_bo = drm_intel_bo_alloc_wrapper(brw->bufmgr,
> >                                                        "OA bookend BO",
> >                                                        BOOKEND_BO_SIZE_BYTES, 64);
> >        }
> >
> >        monitor->oa_bo =
> > -         drm_intel_bo_alloc(brw->bufmgr, "perf. monitor OA bo", 4096, 64);
> > +         drm_intel_bo_alloc_wrapper(brw->bufmgr, "perf. monitor OA bo", 4096, 64);
> >  #ifdef DEBUG
> >        /* Pre-filling the BO helps debug whether writes landed. */
> >        drm_intel_bo_map(monitor->oa_bo, true);
> > @@ -1146,7 +1146,7 @@ brw_begin_perf_monitor(struct gl_context *ctx,
> >
> >     if (monitor_needs_statistics_registers(brw, m)) {
> >        monitor->pipeline_stats_bo =
> > -         drm_intel_bo_alloc(brw->bufmgr, "perf. monitor stats bo", 4096, 64);
> > +         drm_intel_bo_alloc_wrapper(brw->bufmgr, "perf. monitor stats bo", 4096, 64);
> >
> >        /* Take starting snapshots. */
> >        snapshot_statistics_registers(brw, monitor, 0);
> > diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
> > index d782b4f..74ff40c 100644
> > --- a/src/mesa/drivers/dri/i965/brw_program.c
> > +++ b/src/mesa/drivers/dri/i965/brw_program.c
> > @@ -43,6 +43,7 @@
> >
> >  #include "brw_context.h"
> >  #include "brw_wm.h"
> > +#include "intel_batchbuffer.h"
> >
> >  static unsigned
> >  get_new_program_id(struct intel_screen *screen)
> > @@ -242,7 +243,7 @@ brw_get_scratch_bo(struct brw_context *brw,
> >     }
> >
> >     if (!old_bo) {
> > -      *scratch_bo = drm_intel_bo_alloc(brw->bufmgr, "scratch bo", size, 4096);
> > +      *scratch_bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "scratch bo", size, 4096);
> >     }
> >  }
> >
> > @@ -265,7 +266,7 @@ void
> >  brw_init_shader_time(struct brw_context *brw)
> >  {
> >     const int max_entries = 4096;
> > -   brw->shader_time.bo = drm_intel_bo_alloc(brw->bufmgr, "shader time",
> > +   brw->shader_time.bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "shader time",
> >                                              max_entries * SHADER_TIME_STRIDE,
> >                                              4096);
> >     brw->shader_time.shader_programs = rzalloc_array(brw, struct gl_shader_program *,
> > diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c
> > index c053c34..cf5a2a5 100644
> > --- a/src/mesa/drivers/dri/i965/brw_queryobj.c
> > +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
> > @@ -230,7 +230,7 @@ brw_begin_query(struct gl_context *ctx, struct gl_query_object *q)
> >         * the system was doing other work, such as running other applications.
> >         */
> >        drm_intel_bo_unreference(query->bo);
> > -      query->bo = drm_intel_bo_alloc(brw->bufmgr, "timer query", 4096, 4096);
> > +      query->bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "timer query", 4096, 4096);
> >        brw_write_timestamp(brw, query->bo, 0);
> >        break;
> >
> > @@ -388,7 +388,7 @@ ensure_bo_has_space(struct gl_context *ctx, struct brw_query_object *query)
> >           brw_queryobj_get_results(ctx, query);
> >        }
> >
> > -      query->bo = drm_intel_bo_alloc(brw->bufmgr, "query", 4096, 1);
> > +      query->bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "query", 4096, 1);
> >        query->last_index = 0;
> >     }
> >  }
> > @@ -474,7 +474,7 @@ brw_query_counter(struct gl_context *ctx, struct gl_query_object *q)
> >     assert(q->Target == GL_TIMESTAMP);
> >
> >     drm_intel_bo_unreference(query->bo);
> > -   query->bo = drm_intel_bo_alloc(brw->bufmgr, "timestamp query", 4096, 4096);
> > +   query->bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "timestamp query", 4096, 4096);
> >     brw_write_timestamp(brw, query->bo, 0);
> >  }
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c
> > index b0986ea..daf5a11 100644
> > --- a/src/mesa/drivers/dri/i965/brw_state_cache.c
> > +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c
> > @@ -171,7 +171,7 @@ brw_cache_new_bo(struct brw_cache *cache, uint32_t new_size)
> >     struct brw_context *brw = cache->brw;
> >     drm_intel_bo *new_bo;
> >
> > -   new_bo = drm_intel_bo_alloc(brw->bufmgr, "program cache", new_size, 64);
> > +   new_bo = drm_intel_bo_alloc_wrapper(brw->bufmgr, "program cache", new_size, 64);
> >
> >     /* Copy any existing data that needs to be saved. */
> >     if (cache->next_offset != 0) {
> > @@ -335,7 +335,7 @@ brw_init_caches(struct brw_context *brw)
> >     cache->items =
> >        calloc(1, cache->size * sizeof(struct brw_cache_item *));
> >
> > -   cache->bo = drm_intel_bo_alloc(brw->bufmgr,
> > +   cache->bo = drm_intel_bo_alloc_wrapper(brw->bufmgr,
> >                                   "program cache",
> >                                   4096, 64);
> >
> > diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > index 71dc268..50834c2 100644
> > --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> > @@ -253,6 +253,9 @@ do_flush_locked(struct brw_context *brw)
> >
> >     if (!brw->intelScreen->no_hw) {
> >        int flags;
> > +#ifdef NO_RELOC
> > +      flags |= I915_EXEC_NO_RELOC;
> > +#endif
> >
> >        if (brw->gen >= 6 && batch->ring == BLT_RING) {
> >           flags = I915_EXEC_BLT;
> > diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.h b/src/mesa/drivers/dri/i965/intel_batchbuffer.h
> > index 7bdd836..2670d22 100644
> > --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.h
> > +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.h
> > @@ -11,6 +11,14 @@
> >  extern "C" {
> >  #endif
> >
> > +#ifdef NO_RELOC
> > + #define drm_intel_bo_alloc_wrapper(bufmgr, name, size, align) \
> > +   drm_intel_bo_alloc_prelocated(bufmgr, name, size, 1)
> > +#else
> > + #define drm_intel_bo_alloc_wrapper drm_intel_bo_alloc
> > +#endif
> > +
> > +
> >  /**
> >   * Number of bytes to reserve for commands necessary to complete a batch.
> >   *
> > --
> > 2.0.4
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev

-- 
Ben Widawsky, Intel Open Source Technology Center


More information about the mesa-dev mailing list