[Mesa-dev] [PATCH v4 3/3] i965: if DEBUG_CHECK_OOB is up, check that noise padding for each bo used in batchbuffer is correct

kevin.rogovin at intel.com kevin.rogovin at intel.com
Tue Jan 30 10:51:19 UTC 2018


From: Kevin Rogovin <kevin.rogovin at intel.com>

Signed-off-by: Kevin Rogovin <kevin.rogovin at intel.com>
---
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 86d88a701f..749a384def 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -1023,11 +1023,31 @@ _intel_batchbuffer_flush_fence(struct brw_context *brw,
 
    ret = submit_batch(brw, in_fence_fd, out_fence_fd);
 
-   if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
+   if (unlikely(INTEL_DEBUG & (DEBUG_SYNC | DEBUG_CHECK_OOB))) {
       fprintf(stderr, "waiting for idle\n");
       brw_bo_wait_rendering(brw->batch.batch.bo);
    }
 
+   if (unlikely(INTEL_DEBUG & DEBUG_CHECK_OOB)) {
+      bool detected_out_of_bounds_write = false;
+
+      for (int i = 0; i < brw->batch.exec_count; i++) {
+         struct brw_bo *bo = brw->batch.exec_bos[i];
+
+         if (!brw_bo_padding_is_good(bo)) {
+            detected_out_of_bounds_write = true;
+            fprintf(stderr,
+                    "Detected buffer out-of-bounds write from brw_bo %p "
+                    "(GEM %u, label = \"%s\")\n",
+                    bo, bo->gem_handle, bo->name);
+         }
+      }
+
+      if (unlikely(detected_out_of_bounds_write)) {
+         abort();
+      }
+   }
+
    /* Start a new batch buffer. */
    brw_new_batch(brw);
 
-- 
2.16.1



More information about the mesa-dev mailing list