OSDN Git Service

Clean up / sanitize debugging
authorKeith Whitwell <keith@tungstengraphics.com>
Fri, 10 Aug 2007 09:37:20 +0000 (10:37 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Fri, 10 Aug 2007 09:37:20 +0000 (10:37 +0100)
src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c
src/mesa/drivers/dri/intel_winsys/intel_blit.c
src/mesa/drivers/dri/intel_winsys/intel_buffers.c
src/mesa/drivers/dri/intel_winsys/intel_context.c
src/mesa/drivers/dri/intel_winsys/intel_context.h
src/mesa/drivers/dri/intel_winsys/intel_ioctl.c

index d1fb290..30511bc 100644 (file)
@@ -71,11 +71,10 @@ static void
 intel_dump_batchbuffer(GLuint offset, GLuint * ptr, GLuint count)
 {
    int i;
-   fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", count / 4);
+   _mesa_printf("\n\n\nSTART BATCH (%d dwords):\n", count / 4);
    for (i = 0; i < count / 4; i += 1)
-      fprintf(stderr, "\t0x%08x\n",
-              ptr[i]);
-   fprintf(stderr, "END BATCH\n\n\n");
+      _mesa_printf("\t0x%08x\n", ptr[i]);
+   _mesa_printf("END BATCH\n\n\n");
 }
 
 void
@@ -193,7 +192,7 @@ do_flush_locked(struct intel_batchbuffer *batch,
       ptr[r->offset / 4] = driBOOffset(r->buf) + r->delta;
    }
 
-   if (INTEL_DEBUG & DEBUG_BATCH)
+   if (0)
       intel_dump_batchbuffer(0, ptr, used);
 
    driBOUnmap(batch->buffer);
index f099eb2..1578340 100644 (file)
@@ -41,8 +41,6 @@
 #include "state_tracker/st_cb_fbo.h"
 
 
-#define FILE_DEBUG_FLAG DEBUG_BLIT
-
 /**
  * Copy the back color buffer to the front color buffer. 
  * Used for SwapBuffers().
@@ -55,7 +53,7 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv,
    struct intel_context *intel;
    const intelScreenPrivate *intelScreen;
 
-   DBG("%s\n", __FUNCTION__);
+   DBG(SWAP, "%s\n", __FUNCTION__);
 
    assert(dPriv);
 
@@ -127,8 +125,8 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv,
       ASSERT(backRegion);
       ASSERT(backRegion->cpp == cpp);
 
-      DBG("front pitch %d back pitch %d\n",
-        pitch, backRegion->pitch);
+      DBG(SWAP, "front pitch %d back pitch %d\n",
+         pitch, backRegion->pitch);
 
       if (cpp == 2) {
         BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24);
@@ -178,8 +176,8 @@ intelCopyBuffer(__DRIdrawablePrivate * dPriv,
         if (box.y2 - box.y1 > backHeight)
            box.y2 = backHeight + box.y1;
 
-        DBG("box x1 x2 y1 y2 %d %d %d %d\n",
-             box.x1, box.x2, box.y1, box.y2);
+        DBG(SWAP, "box x1 x2 y1 y2 %d %d %d %d\n",
+            box.x1, box.x2, box.y1, box.y2);
 
         sbox.x1 = box.x1 - dPriv->x;
         sbox.y1 = box.y1 - dPriv->y;
index eb42be9..1bd2a36 100644 (file)
@@ -145,10 +145,9 @@ intelWindowMoved(struct intel_context *intel)
 
       pf_active = pf_pipes && (pf_pipes & intel->sarea->pf_active) == pf_pipes;
 
-      if (INTEL_DEBUG & DEBUG_LOCK)
-        if (pf_active != intel_fb->pf_active)
-           _mesa_printf("%s - Page flipping %sactive\n", __progname,
-                        pf_active ? "" : "in");
+      if (pf_active != intel_fb->pf_active)
+        DBG(LOCK, "%s - Page flipping %sactive\n",
+            __progname, pf_active ? "" : "in");
 
       if (pf_active) {
         /* Sync pages between pipes if we're flipping on both at the same time */
@@ -283,8 +282,7 @@ intelPageFlip(const __DRIdrawablePrivate * dPriv)
    int ret;
    struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
 
-   if (INTEL_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
+   DBG(SWAP, "%s\n", __FUNCTION__);
 
    assert(dPriv);
    assert(dPriv->driContextPriv);
@@ -332,8 +330,7 @@ intelPageFlip(const __DRIdrawablePrivate * dPriv)
    intel_draw_buffer(&intel->ctx, &intel_fb->Base);
 #endif
 
-   if (INTEL_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s: success\n", __FUNCTION__);
+   DBG(SWAP, "%s: success\n", __FUNCTION__);
 
    return GL_TRUE;
 }
index 3782148..1032fc2 100644 (file)
@@ -59,8 +59,8 @@
 
 
 
-#ifndef INTEL_DEBUG
-int INTEL_DEBUG = (0);
+#if DEBUG
+int __intel_debug = 0;
 #endif
 
 #define need_GL_ARB_multisample
@@ -210,18 +210,10 @@ const struct dri_extension card_extensions[] = {
 
 
 static const struct dri_debug_control debug_control[] = {
-   {"tex", DEBUG_TEXTURE},
-   {"state", DEBUG_STATE},
    {"ioctl", DEBUG_IOCTL},
-   {"blit", DEBUG_BLIT},
-   {"mip", DEBUG_MIPTREE},
-   {"verb", DEBUG_VERBOSE},
    {"bat", DEBUG_BATCH},
-   {"pix", DEBUG_PIXEL},
-   {"buf", DEBUG_BUFMGR},
-   {"reg", DEBUG_REGION},
-   {"fbo", DEBUG_FBO},
    {"lock", DEBUG_LOCK},
+   {"swap", DEBUG_SWAP},
    {NULL, 0}
 };
 
@@ -397,8 +389,8 @@ intelCreateContext(const __GLcontextModes * mesaVis,
       _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
    }
 
-#if DO_DEBUG
-   INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
+#if DEBUG
+   __intel_debug = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
 #endif
 
 
@@ -470,8 +462,6 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
          /* This share group is about to go away, free our private
           * texture object data.
           */
-         if (INTEL_DEBUG & DEBUG_TEXTURE)
-            fprintf(stderr, "do something to free texture heaps\n");
       }
 
       /* free the Mesa context */
@@ -570,8 +560,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
 
    drmGetLock(intel->driFd, intel->hHWContext, flags);
 
-   if (INTEL_DEBUG & DEBUG_LOCK)
-      _mesa_printf("%s - got contended lock\n", __progname);
+   DBG(LOCK, "%s - got contended lock\n", __progname);
 
    /* If the window moved, may need to set a new cliprect now.
     *
@@ -660,8 +649,7 @@ void LOCK_HARDWARE( struct intel_context *intel )
     if (__ret)
        intelContendedLock( intel, 0 );
 
-    if (INTEL_DEBUG & DEBUG_LOCK)
-      _mesa_printf("%s - locked\n", __progname);
+    DBG(LOCK, "%s - locked\n", __progname);
 
     intel->locked = 1;
 }
@@ -678,7 +666,6 @@ void UNLOCK_HARDWARE( struct intel_context *intel )
 
    _glthread_UNLOCK_MUTEX(lockMutex);
 
-   if (INTEL_DEBUG & DEBUG_LOCK)
-      _mesa_printf("%s - unlocked\n", __progname);
+   DBG(LOCK, "%s - unlocked\n", __progname);
 } 
 
index e84f53d..924b7ca 100644 (file)
@@ -109,27 +109,23 @@ extern char *__progname;
 /* ================================================================
  * Debugging:
  */
-#define DO_DEBUG               0
-#if DO_DEBUG
-extern int INTEL_DEBUG;
+#if DEBUG
+extern int __intel_debug;
+
+#define DEBUG_SWAP     0x1
+#define DEBUG_LOCK      0x2
+#define DEBUG_IOCTL    0x4
+#define DEBUG_BATCH     0x8
+
+#define DBG(flag, ...)  do {                   \
+   if (__intel_debug & (DEBUG_##flag))                 \
+      _mesa_printf(__VA_ARGS__);               \
+} while(0)
+
 #else
-#define INTEL_DEBUG            0
+#define DBG(flag, ...) 
 #endif
 
-#define DEBUG_TEXTURE  0x1
-#define DEBUG_STATE    0x2
-#define DEBUG_IOCTL    0x4
-#define DEBUG_BLIT     0x8
-#define DEBUG_MIPTREE   0x10
-#define DEBUG_VERBOSE  0x40
-#define DEBUG_BATCH     0x80
-#define DEBUG_PIXEL     0x100
-#define DEBUG_BUFMGR    0x200
-#define DEBUG_REGION    0x400
-#define DEBUG_FBO       0x800
-#define DEBUG_LOCK      0x1000
-
-#define DBG(...)  do { if (INTEL_DEBUG & FILE_DEBUG_FLAG) _mesa_printf(__VA_ARGS__); } while(0)
 
 
 #define PCI_CHIP_845_G                 0x2562
index 154a3e2..6e4d134 100644 (file)
@@ -40,7 +40,6 @@
 #include "intel_blit.h"
 #include "drm.h"
 
-#define FILE_DEBUG_FLAG DEBUG_IOCTL
 
 int
 intelEmitIrqLocked(struct intel_context *intel)
@@ -60,7 +59,7 @@ intelEmitIrqLocked(struct intel_context *intel)
       exit(1);
    }
 
-   DBG("%s -->  %d\n", __FUNCTION__, seq);
+   DBG(IOCTL, "%s -->  %d\n", __FUNCTION__, seq);
 
    return seq;
 }
@@ -70,7 +69,7 @@ intelWaitIrq(struct intel_context *intel, int seq)
 {
    int ret;
 
-   DBG("%s %d\n", __FUNCTION__, seq);
+   DBG(IOCTL, "%s %d\n", __FUNCTION__, seq);
 
    intel->iw.irq_seq = seq;
 
@@ -98,7 +97,7 @@ intel_batch_ioctl(struct intel_context *intel,
    assert(intel->locked);
    assert(used);
 
-   DBG("%s used %d offset %x..%x ignore_cliprects %d\n",
+   DBG(IOCTL, "%s used %d offset %x..%x ignore_cliprects %d\n",
        __FUNCTION__,
        used, start_offset, start_offset + used, ignore_cliprects);
 
@@ -116,7 +115,7 @@ intel_batch_ioctl(struct intel_context *intel,
    batch.DR1 = 0;
    batch.DR4 = 0; /* still need this ? */
 
-   DBG("%s: 0x%x..0x%x DR4: %x cliprects: %d\n",
+   DBG(IOCTL, "%s: 0x%x..0x%x DR4: %x cliprects: %d\n",
        __FUNCTION__,
        batch.start,
        batch.start + batch.used * 4, batch.DR4, batch.num_cliprects);