If we correctly fill the batch with the right relocation value, and that
matches the expected location of the object, we can then tell the kernel
it can forgo checking each individual relocation by only checking
whether the object moved.

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
Cc: Kenneth Graunke <kenn...@whitecape.org>
Cc: Jason Ekstrand <jason.ekstr...@intel.com>
---
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 33 ++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c 
b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 2e10d165c7..1ee60c07a5 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -646,7 +646,19 @@ do_flush_locked(struct brw_context *brw, int in_fence_fd, 
int *out_fence_fd)
    if (!brw->screen->no_hw) {
       unsigned int flags;
 
-      flags = I915_EXEC_HANDLE_LUT;
+      /* The requirement for using I915_EXEC_NO_RELOC are:
+       *
+       *   The addresses written in the objects must match the corresponding
+       *   reloc.presumed_offset which in turn must match the corresponding
+       *   execobject.offset.
+       *
+       *   Any render targets written to in the batch must be flagged with
+       *   EXEC_OBJECT_WRITE.
+       *
+       *   To avoid stalling, execobject.offset should match the current
+       *   address of that object within the active context.
+       */
+      flags = I915_EXEC_HANDLE_LUT | I915_EXEC_NO_RELOC;
       if (brw->gen >= 6 && batch->ring == BLT_RING) {
          flags |= I915_EXEC_BLT;
       } else {
@@ -798,8 +810,23 @@ brw_emit_reloc(struct intel_batchbuffer *batch, uint32_t 
batch_offset,
 
    batch->reloc_count++;
 
-   /* ensure gcc doesn't reload */
-   offset64 = *((volatile uint64_t *)&target->offset64);
+   if (index != -1) {
+      struct drm_i915_gem_exec_object2 *exec = &batch->exec_objects[index];
+
+      offset64 = exec->offset;
+      if (write_domain) {
+         exec->flags |= EXEC_OBJECT_WRITE;
+
+         /* PIPECONTROL needs a w/a on gen6 */
+         if (write_domain == I915_GEM_DOMAIN_INSTRUCTION) {
+            struct brw_context *brw = container_of(batch, brw, batch);
+            if (brw->gen == 6)
+               exec->flags |= EXEC_OBJECT_NEEDS_GTT;
+         }
+      }
+   } else {
+      offset64 = batch->bo->offset64;
+   }
    reloc->offset = batch_offset;
    reloc->delta = target_offset;
    reloc->target_handle = index;
-- 
2.11.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to