Mesa (master): ilo: rework winsys batch buffer functions

Chia-I Wu olv at kemper.freedesktop.org
Mon Mar 10 08:46:19 UTC 2014


Module: Mesa
Branch: master
Commit: 249b1ad98440fee5174aa490e7c3269b88de8904
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=249b1ad98440fee5174aa490e7c3269b88de8904

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Sat Mar  8 17:32:37 2014 +0800

ilo: rework winsys batch buffer functions

Rename

  intel_winsys_check_aperture_size() to intel_winsys_can_submit_bo(),
  intel_bo_exec() to intel_winsys_submit_bo(), and
  intel_winsys_decode_commands() to intel_winsys_decode_bo().

Make a semantic change to ignore intel_context when the ring is not the render
ring.

---

 src/gallium/drivers/ilo/ilo_3d_pipeline.c       |    9 +----
 src/gallium/drivers/ilo/ilo_blitter_blt.c       |    2 +-
 src/gallium/drivers/ilo/ilo_cp.c                |   16 ++++----
 src/gallium/winsys/intel/drm/intel_drm_winsys.c |   48 +++++++++++++----------
 src/gallium/winsys/intel/intel_winsys.h         |   37 +++++++++--------
 5 files changed, 58 insertions(+), 54 deletions(-)

diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline.c b/src/gallium/drivers/ilo/ilo_3d_pipeline.c
index 17ac1e5..a821282 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline.c
@@ -173,7 +173,6 @@ ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
 
    while (true) {
       struct ilo_cp_jmp_buf jmp;
-      int err;
 
       /* we will rewind if aperture check below fails */
       ilo_cp_setjmp(p->cp, &jmp);
@@ -185,8 +184,7 @@ ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
       p->emit_draw(p, ilo);
       ilo_cp_assert_no_implicit_flush(p->cp, false);
 
-      err = intel_winsys_check_aperture_space(ilo->winsys, &p->cp->bo, 1);
-      if (!err) {
+      if (intel_winsys_can_submit_bo(ilo->winsys, &p->cp->bo, 1)) {
          success = true;
          break;
       }
@@ -271,7 +269,6 @@ ilo_3d_pipeline_emit_rectlist(struct ilo_3d_pipeline *p,
 
    while (true) {
       struct ilo_cp_jmp_buf jmp;
-      int err;
 
       /* we will rewind if aperture check below fails */
       ilo_cp_setjmp(p->cp, &jmp);
@@ -282,9 +279,7 @@ ilo_3d_pipeline_emit_rectlist(struct ilo_3d_pipeline *p,
       p->emit_rectlist(p, blitter);
       ilo_cp_assert_no_implicit_flush(p->cp, false);
 
-      err = intel_winsys_check_aperture_space(blitter->ilo->winsys,
-            &p->cp->bo, 1);
-      if (err) {
+      if (!intel_winsys_can_submit_bo(blitter->ilo->winsys, &p->cp->bo, 1)) {
          /* rewind */
          ilo_cp_longjmp(p->cp, &jmp);
 
diff --git a/src/gallium/drivers/ilo/ilo_blitter_blt.c b/src/gallium/drivers/ilo/ilo_blitter_blt.c
index d978150..a230cb7 100644
--- a/src/gallium/drivers/ilo/ilo_blitter_blt.c
+++ b/src/gallium/drivers/ilo/ilo_blitter_blt.c
@@ -349,7 +349,7 @@ ilo_blitter_blt_begin(struct ilo_blitter *blitter, int max_cmd_size,
       count++;
    }
 
-   if (intel_winsys_check_aperture_space(ilo->winsys, aper_check, count))
+   if (!intel_winsys_can_submit_bo(ilo->winsys, aper_check, count))
       ilo_cp_flush(ilo->cp, "out of aperture");
 
    /* set BCS_SWCTRL */
diff --git a/src/gallium/drivers/ilo/ilo_cp.c b/src/gallium/drivers/ilo/ilo_cp.c
index cda58eb..8bcb196 100644
--- a/src/gallium/drivers/ilo/ilo_cp.c
+++ b/src/gallium/drivers/ilo/ilo_cp.c
@@ -42,7 +42,7 @@ ilo_cp_dump(struct ilo_cp *cp)
 {
    ilo_printf("dumping %d bytes\n", cp->used * 4);
    if (cp->used)
-      intel_winsys_decode_commands(cp->winsys, cp->bo, cp->used * 4);
+      intel_winsys_decode_bo(cp->winsys, cp->bo, cp->used * 4);
 }
 
 /**
@@ -182,31 +182,31 @@ static int
 ilo_cp_exec_bo(struct ilo_cp *cp)
 {
    const bool do_exec = !(ilo_debug & ILO_DEBUG_NOHW);
-   struct intel_context *ctx;
    unsigned long flags;
    int err;
 
    switch (cp->ring) {
    case ILO_CP_RING_RENDER:
-      ctx = cp->render_ctx;
       flags = INTEL_EXEC_RENDER;
       break;
    case ILO_CP_RING_BLT:
-      ctx = NULL;
       flags = INTEL_EXEC_BLT;
       break;
    default:
-      ctx = NULL;
+      assert(!"unknown cp ring");
       flags = 0;
       break;
    }
 
    flags |= cp->one_off_flags;
 
-   if (likely(do_exec))
-      err = intel_bo_exec(cp->bo, cp->used * 4, ctx, flags);
-   else
+   if (likely(do_exec)) {
+      err = intel_winsys_submit_bo(cp->winsys,
+            cp->bo, cp->used * 4, cp->render_ctx, flags);
+   }
+   else {
       err = 0;
+   }
 
    cp->one_off_flags = 0;
 
diff --git a/src/gallium/winsys/intel/drm/intel_drm_winsys.c b/src/gallium/winsys/intel/drm/intel_drm_winsys.c
index e119f9e..12ed2e4 100644
--- a/src/gallium/winsys/intel/drm/intel_drm_winsys.c
+++ b/src/gallium/winsys/intel/drm/intel_drm_winsys.c
@@ -356,18 +356,38 @@ intel_winsys_export_handle(struct intel_winsys *winsys,
    return 0;
 }
 
+bool
+intel_winsys_can_submit_bo(struct intel_winsys *winsys,
+                           struct intel_bo **bo_array,
+                           int count)
+{
+   return !drm_intel_bufmgr_check_aperture_space((drm_intel_bo **) bo_array,
+                                                 count);
+}
+
 int
-intel_winsys_check_aperture_space(struct intel_winsys *winsys,
-                                  struct intel_bo **bo_array,
-                                  int count)
+intel_winsys_submit_bo(struct intel_winsys *winsys,
+                       struct intel_bo *bo, int used,
+                       struct intel_context *ctx,
+                       unsigned long flags)
 {
-   return drm_intel_bufmgr_check_aperture_space((drm_intel_bo **) bo_array,
-                                                count);
+   /* logical contexts are only available for the render ring */
+   if ((flags & 0x7) > INTEL_EXEC_RENDER)
+      ctx = NULL;
+
+   if (ctx) {
+      return drm_intel_gem_bo_context_exec(gem_bo(bo),
+            (drm_intel_context *) ctx, used, flags);
+   }
+   else {
+      return drm_intel_bo_mrb_exec(gem_bo(bo),
+            used, NULL, 0, 0, flags);
+   }
 }
 
 void
-intel_winsys_decode_commands(struct intel_winsys *winsys,
-                             struct intel_bo *bo, int used)
+intel_winsys_decode_bo(struct intel_winsys *winsys,
+                       struct intel_bo *bo, int used)
 {
    void *ptr;
 
@@ -510,20 +530,6 @@ intel_bo_has_reloc(struct intel_bo *bo, struct intel_bo *target_bo)
 }
 
 int
-intel_bo_exec(struct intel_bo *bo, int used,
-              struct intel_context *ctx, unsigned long flags)
-{
-   if (ctx) {
-      return drm_intel_gem_bo_context_exec(gem_bo(bo),
-            (drm_intel_context *) ctx, used, flags);
-   }
-   else {
-      return drm_intel_bo_mrb_exec(gem_bo(bo),
-            used, NULL, 0, 0, flags);
-   }
-}
-
-int
 intel_bo_wait(struct intel_bo *bo, int64_t timeout)
 {
    int err;
diff --git a/src/gallium/winsys/intel/intel_winsys.h b/src/gallium/winsys/intel/intel_winsys.h
index b16f3a2..e84c960 100644
--- a/src/gallium/winsys/intel/intel_winsys.h
+++ b/src/gallium/winsys/intel/intel_winsys.h
@@ -161,13 +161,26 @@ intel_winsys_export_handle(struct intel_winsys *winsys,
                            struct winsys_handle *handle);
 
 /**
- * Check that buffer objects directly specified in \p bo_array, and those
- * indirectly referenced by them, can fit in the aperture space.
+ * Return true when buffer objects directly specified in \p bo_array, and
+ * those indirectly referenced by them, can fit in the aperture space.
+ */
+bool
+intel_winsys_can_submit_bo(struct intel_winsys *winsys,
+                           struct intel_bo **bo_array,
+                           int count);
+
+/**
+ * Submit \p bo for execution.
+ *
+ * \p bo and all bos referenced by \p bo will be considered busy until all
+ * commands are parsed and executed.  \p ctx is ignored when the bo is not
+ * submitted to the render ring.
  */
 int
-intel_winsys_check_aperture_space(struct intel_winsys *winsys,
-                                  struct intel_bo **bo_array,
-                                  int count);
+intel_winsys_submit_bo(struct intel_winsys *winsys,
+                       struct intel_bo *bo, int used,
+                       struct intel_context *ctx,
+                       unsigned long flags);
 
 /**
  * Decode the commands contained in \p bo.  For debugging.
@@ -176,8 +189,8 @@ intel_winsys_check_aperture_space(struct intel_winsys *winsys,
  * \param used    Size of the commands in bytes.
  */
 void
-intel_winsys_decode_commands(struct intel_winsys *winsys,
-                             struct intel_bo *bo, int used);
+intel_winsys_decode_bo(struct intel_winsys *winsys,
+                       struct intel_bo *bo, int used);
 
 /**
  * Increase the reference count of \p bo.
@@ -274,16 +287,6 @@ bool
 intel_bo_has_reloc(struct intel_bo *bo, struct intel_bo *target_bo);
 
 /**
- * Submit \p bo for execution.
- *
- * \p bo and all bos referenced by \p bo will be considered busy until all
- * commands are parsed and executed.
- */
-int
-intel_bo_exec(struct intel_bo *bo, int used,
-              struct intel_context *ctx, unsigned long flags);
-
-/**
  * Wait until \bo is idle, or \p timeout nanoseconds have passed.  A
  * negative timeout means to wait indefinitely.
  *




More information about the mesa-commit mailing list