[intel] Enable INTEL_DEBUG=bufmgr output in TTM mode as well as classic.
authorEric Anholt <eric@anholt.net>
Fri, 14 Dec 2007 00:49:55 +0000 (16:49 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 14 Dec 2007 07:26:43 +0000 (23:26 -0800)
src/mesa/drivers/dri/common/dri_bufmgr.c
src/mesa/drivers/dri/common/dri_bufmgr.h
src/mesa/drivers/dri/common/dri_bufmgr_fake.c
src/mesa/drivers/dri/i915/intel_context.c
src/mesa/drivers/dri/i965/intel_context.c
src/mesa/drivers/dri/intel/intel_bufmgr_ttm.c

index 757a23749487791ab1d194e7ef4a5b8ab8ae3793..18b12c63f72f108bb379a4421dca645ffcb7937b 100644 (file)
@@ -154,3 +154,9 @@ void dri_post_submit(dri_bo *batch_buf, dri_fence **last_fence)
 {
    batch_buf->bufmgr->post_submit(batch_buf, last_fence);
 }
+
+void
+dri_bufmgr_set_debug(dri_bufmgr *bufmgr, GLboolean enable_debug)
+{
+   bufmgr->debug = enable_debug;
+}
index d263ad279bfca22cdf1342526e59cf4c26c924a4..cdf27b903fb59d147f50f324bc09e95610a91189 100644 (file)
@@ -172,6 +172,8 @@ struct _dri_bufmgr {
    void *(*process_relocs)(dri_bo *batch_buf, GLuint *count);
 
    void (*post_submit)(dri_bo *batch_buf, dri_fence **fence);
+
+   GLboolean debug; /**< Enables verbose debugging printouts */
 };
 
 dri_bo *dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
@@ -202,7 +204,7 @@ dri_bufmgr *dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
                                 int (*fence_wait)(void *private,
                                                   unsigned int cookie),
                                 void *driver_priv);
-void dri_bufmgr_fake_set_debug(dri_bufmgr *bufmgr, GLboolean enable_debug);
+void dri_bufmgr_set_debug(dri_bufmgr *bufmgr, GLboolean enable_debug);
 void dri_bo_fake_disable_backing_store(dri_bo *bo,
                                       void (*invalidate_cb)(dri_bo *bo,
                                                             void *ptr),
index f022552ed8566ccefee8f2c5544f8897b86d5494..9f86ddda9bade1f9ce08c32ee4a145ccc495468f 100644 (file)
@@ -42,7 +42,7 @@
 #include "imports.h"
 
 #define DBG(...) do {                                  \
-   if (bufmgr_fake->debug)                             \
+   if (bufmgr_fake->bufmgr.debug)                      \
       _mesa_printf(__VA_ARGS__);                       \
 } while (0)
 
@@ -1151,14 +1151,6 @@ dri_fake_post_submit(dri_bo *batch_buf, dri_fence **last_fence)
    bufmgr_fake->nr_relocs = 0;
 }
 
-void
-dri_bufmgr_fake_set_debug(dri_bufmgr *bufmgr, GLboolean enable_debug)
-{
-   dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bufmgr;
-
-   bufmgr_fake->debug = enable_debug;
-}
-
 dri_bufmgr *
 dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
                     unsigned long size,
index c67d906db06f7db93a57c9ee82afaec1c6ac0476..be084903c2492fc8a174f0c52e80fdb823c8231b 100644 (file)
@@ -544,8 +544,8 @@ intelInitContext(struct intel_context *intel,
 
 #if DO_DEBUG
    INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
-   if (!intel->ttm && (INTEL_DEBUG & DEBUG_BUFMGR))
-      dri_bufmgr_fake_set_debug(intel->bufmgr, GL_TRUE);
+   if (INTEL_DEBUG & DEBUG_BUFMGR)
+      dri_bufmgr_set_debug(intel->bufmgr, GL_TRUE);
 #endif
 
    if (getenv("INTEL_NO_RAST")) {
index fb95c492eb6b808b3d23705bfe96595bec15f68f..1277dd15aa578af2f074918572e9b4a40714f175 100644 (file)
@@ -534,8 +534,8 @@ GLboolean intelInitContext( struct intel_context *intel,
 
    INTEL_DEBUG  = driParseDebugString( getenv( "INTEL_DEBUG" ),
                                       debug_control );
-   if (!intel->ttm && (INTEL_DEBUG & DEBUG_BUFMGR))
-      dri_bufmgr_fake_set_debug(intel->bufmgr, GL_TRUE);
+   if (INTEL_DEBUG & DEBUG_BUFMGR)
+      dri_bufmgr_set_debug(intel->bufmgr, GL_TRUE);
 
    intel_recreate_static_regions(intel);
 
index 2ec0241af495ed57c8397e1e5e3172258d8a3a07..ea39b2c6956cde3df6afc86d3f7216eb0b09bd20 100644 (file)
 
 #include "intel_bufmgr_ttm.h"
 
-#define BUFMGR_DEBUG 0
+#define DBG(...) do {                                  \
+   if (bufmgr_ttm->bufmgr.debug)                       \
+      _mesa_printf(__VA_ARGS__);                       \
+} while (0)
 
 struct intel_reloc_info
 {
@@ -485,14 +488,12 @@ dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
              unsigned long size, unsigned int alignment,
              uint64_t location_mask)
 {
-    dri_bufmgr_ttm *ttm_bufmgr;
+    dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
     dri_bo_ttm *ttm_buf;
     unsigned int pageSize = getpagesize();
     int ret;
     unsigned int flags, hint;
 
-    ttm_bufmgr = (dri_bufmgr_ttm *)bufmgr;
-
     ttm_buf = malloc(sizeof(*ttm_buf));
     if (!ttm_buf)
        return NULL;
@@ -506,7 +507,7 @@ dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
     /* No hints we want to use. */
     hint = 0;
 
-    ret = drmBOCreate(ttm_bufmgr->fd, size, alignment / pageSize,
+    ret = drmBOCreate(bufmgr_ttm->fd, size, alignment / pageSize,
                      NULL, flags, hint, &ttm_buf->drm_bo);
     if (ret != 0) {
        free(ttm_buf);
@@ -519,9 +520,7 @@ dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
     ttm_buf->name = name;
     ttm_buf->refcount = 1;
 
-#if BUFMGR_DEBUG
-    fprintf(stderr, "bo_create: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
-#endif
+    DBG("bo_create: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
 
     return &ttm_buf->bo;
 }
@@ -548,17 +547,15 @@ dri_bo *
 intel_ttm_bo_create_from_handle(dri_bufmgr *bufmgr, const char *name,
                              unsigned int handle)
 {
-    dri_bufmgr_ttm *ttm_bufmgr;
+    dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
     dri_bo_ttm *ttm_buf;
     int ret;
 
-    ttm_bufmgr = (dri_bufmgr_ttm *)bufmgr;
-
     ttm_buf = malloc(sizeof(*ttm_buf));
     if (!ttm_buf)
        return NULL;
 
-    ret = drmBOReference(ttm_bufmgr->fd, handle, &ttm_buf->drm_bo);
+    ret = drmBOReference(bufmgr_ttm->fd, handle, &ttm_buf->drm_bo);
     if (ret != 0) {
        fprintf(stderr, "Couldn't reference %s handle 0x%08x: %s\n",
               name, handle, strerror(-ret));
@@ -572,10 +569,8 @@ intel_ttm_bo_create_from_handle(dri_bufmgr *bufmgr, const char *name,
     ttm_buf->name = name;
     ttm_buf->refcount = 1;
 
-#if BUFMGR_DEBUG
-    fprintf(stderr, "bo_create_from_handle: %p %08x (%s)\n",
-           &ttm_buf->bo, handle, ttm_buf->name);
-#endif
+    DBG("bo_create_from_handle: %p %08x (%s)\n",
+       &ttm_buf->bo, handle, ttm_buf->name);
 
     return &ttm_buf->bo;
 }
@@ -609,10 +604,8 @@ dri_ttm_bo_unreference(dri_bo *buf)
            fprintf(stderr, "drmBOUnreference failed (%s): %s\n",
                    ttm_buf->name, strerror(-ret));
        }
-#if BUFMGR_DEBUG
-       fprintf(stderr, "bo_unreference final: %p (%s)\n",
-               &ttm_buf->bo, ttm_buf->name);
-#endif
+       DBG("bo_unreference final: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
+
        _glthread_UNLOCK_MUTEX(bufmgr_ttm->mutex);
        free(buf);
        return;
@@ -635,9 +628,7 @@ dri_ttm_bo_map(dri_bo *buf, GLboolean write_enable)
 
     assert(buf->virtual == NULL);
 
-#if BUFMGR_DEBUG
-    fprintf(stderr, "bo_map: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
-#endif
+    DBG("bo_map: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
 
     return drmBOMap(bufmgr_ttm->fd, &ttm_buf->drm_bo, flags, 0, &buf->virtual);
 }
@@ -657,9 +648,7 @@ dri_ttm_bo_unmap(dri_bo *buf)
 
     buf->virtual = NULL;
 
-#if BUFMGR_DEBUG
-    fprintf(stderr, "bo_unmap: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
-#endif
+    DBG("bo_unmap: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
 
     return drmBOUnmap(bufmgr_ttm->fd, &ttm_buf->drm_bo);
 }
@@ -674,11 +663,9 @@ dri_fence *
 intel_ttm_fence_create_from_arg(dri_bufmgr *bufmgr, const char *name,
                                drm_fence_arg_t *arg)
 {
-    dri_bufmgr_ttm *ttm_bufmgr;
+    dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
     dri_fence_ttm *ttm_fence;
 
-    ttm_bufmgr = (dri_bufmgr_ttm *)bufmgr;
-
     ttm_fence = malloc(sizeof(*ttm_fence));
     if (!ttm_fence)
        return NULL;
@@ -694,10 +681,8 @@ intel_ttm_fence_create_from_arg(dri_bufmgr *bufmgr, const char *name,
     ttm_fence->name = name;
     ttm_fence->refcount = 1;
 
-#if BUFMGR_DEBUG
-    fprintf(stderr, "fence_create_from_handle: %p (%s)\n", &ttm_fence->fence,
-           ttm_fence->name);
-#endif
+    DBG("fence_create_from_handle: %p (%s)\n",
+       &ttm_fence->fence, ttm_fence->name);
 
     return &ttm_fence->fence;
 }
@@ -712,10 +697,7 @@ dri_ttm_fence_reference(dri_fence *fence)
     _glthread_LOCK_MUTEX(bufmgr_ttm->mutex);
     ++fence_ttm->refcount;
     _glthread_UNLOCK_MUTEX(bufmgr_ttm->mutex);
-#if BUFMGR_DEBUG
-    fprintf(stderr, "fence_reference: %p (%s)\n", &fence_ttm->fence,
-           fence_ttm->name);
-#endif
+    DBG("fence_reference: %p (%s)\n", &fence_ttm->fence, fence_ttm->name);
 }
 
 static void
@@ -727,10 +709,8 @@ dri_ttm_fence_unreference(dri_fence *fence)
     if (!fence)
        return;
 
-#if BUFMGR_DEBUG
-    fprintf(stderr, "fence_unreference: %p (%s)\n", &fence_ttm->fence,
-           fence_ttm->name);
-#endif
+    DBG("fence_unreference: %p (%s)\n", &fence_ttm->fence, fence_ttm->name);
+
     _glthread_LOCK_MUTEX(bufmgr_ttm->mutex);
     if (--fence_ttm->refcount == 0) {
        int ret;
@@ -764,10 +744,7 @@ dri_ttm_fence_wait(dri_fence *fence)
        abort();
     }
 
-#if BUFMGR_DEBUG
-    fprintf(stderr, "fence_wait: %p (%s)\n", &fence_ttm->fence,
-           fence_ttm->name);
-#endif
+    DBG("fence_wait: %p (%s)\n", &fence_ttm->fence, fence_ttm->name);
 }
 
 static void