[Mesa-dev] [PATCH v3 1/1] intel: print performance debug messages to `logcat' on Android.

Oliver McFadden oliver.mcfadden at linux.intel.com
Fri Sep 28 04:01:22 PDT 2012


Split the perf_debug() messages into performance debugging information
which may be useful for application developers or driver developers.

Always print the information useful for application developers on the
Android platform.

Signed-off-by: Oliver McFadden <oliver.mcfadden at linux.intel.com>
CC: Chad Versace <chad.versace at linux.intel.com>
---
v3: forgot to change some DEBUG_PERF into (DEBUG_PERF | DEBUG_PERF_APP)

 src/mesa/drivers/dri/Android.mk                   |    3 +-
 src/mesa/drivers/dri/i965/brw_clear.c             |   10 ++++----
 src/mesa/drivers/dri/i965/brw_draw.c              |    4 +-
 src/mesa/drivers/dri/i965/brw_fs.cpp              |   12 +++++-----
 src/mesa/drivers/dri/i965/brw_queryobj.c          |    4 +-
 src/mesa/drivers/dri/i965/brw_state_cache.c       |    4 +-
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp       |    8 +++---
 src/mesa/drivers/dri/i965/brw_vs.c                |   16 ++++++------
 src/mesa/drivers/dri/i965/brw_wm.c                |   16 ++++++------
 src/mesa/drivers/dri/intel/intel_buffer_objects.c |    8 +++---
 src/mesa/drivers/dri/intel/intel_context.c        |    6 +++++
 src/mesa/drivers/dri/intel/intel_context.h        |   25 +++++++++++++++++---
 src/mesa/drivers/dri/intel/intel_regions.c        |    2 +-
 src/mesa/drivers/dri/intel/intel_tex_subimage.c   |    4 +-
 14 files changed, 73 insertions(+), 49 deletions(-)

diff --git a/src/mesa/drivers/dri/Android.mk b/src/mesa/drivers/dri/Android.mk
index 577f664..d6196bb 100644
--- a/src/mesa/drivers/dri/Android.mk
+++ b/src/mesa/drivers/dri/Android.mk
@@ -34,7 +34,8 @@ MESA_DRI_MODULE_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/dri
 MESA_DRI_CFLAGS := \
 	-DFEATURE_GL=1 \
 	-DFEATURE_ES1=1 \
-	-DFEATURE_ES2=1
+	-DFEATURE_ES2=1 \
+	-DHAVE_ANDROID_PLATFORM
 
 MESA_DRI_C_INCLUDES := \
 	$(addprefix $(MESA_TOP)/, $(mesa_dri_common_INCLUDES)) \
diff --git a/src/mesa/drivers/dri/i965/brw_clear.c b/src/mesa/drivers/dri/i965/brw_clear.c
index 53d8e54..722b0e2 100644
--- a/src/mesa/drivers/dri/i965/brw_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_clear.c
@@ -120,8 +120,8 @@ brw_fast_clear_depth(struct gl_context *ctx)
     * first.
     */
    if (ctx->Scissor.Enabled && !noop_scissor(ctx, fb)) {
-      perf_debug("Failed to fast clear depth due to scissor being enabled.  "
-                 "Possible 5%% performance win if avoided.\n");
+     perf_app_debug("Failed to fast clear depth due to scissor being enabled.  "
+		    "Possible 5%% performance win if avoided.\n");
       return false;
    }
 
@@ -130,9 +130,9 @@ brw_fast_clear_depth(struct gl_context *ctx)
     */
    if (mt->level[depth_irb->mt_level].width % 8 != 0 ||
        mt->level[depth_irb->mt_level].height % 4 != 0) {
-      perf_debug("Failed to fast clear depth due to width/height %d,%d not "
-                 "being aligned to 8,4.  Possible 5%% performance win if "
-                 "avoided\n",
+     perf_app_debug("Failed to fast clear depth due to width/height %d,%d not "
+		    "being aligned to 8,4.  Possible 5%% performance win if "
+		    "avoided\n",
                  mt->level[depth_irb->mt_level].width,
                  mt->level[depth_irb->mt_level].height);
       return false;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index a09f555..8597f61 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -574,8 +574,8 @@ void brw_draw_prims( struct gl_context *ctx,
     * won't support all the extensions we support.
     */
    if (ctx->RenderMode != GL_RENDER) {
-      perf_debug("%s render mode not supported in hardware\n",
-                 _mesa_lookup_enum_by_nr(ctx->RenderMode));
+     perf_app_debug("%s render mode not supported in hardware\n",
+		    _mesa_lookup_enum_by_nr(ctx->RenderMode));
       _swsetup_Wakeup(ctx);
       _tnl_wakeup(ctx);
       _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 9ac2a49..8e06fcb 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2064,7 +2064,7 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,
    if (!prog)
       return false;
 
-   if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+   if (unlikely(INTEL_DEBUG & (DEBUG_PERF | DEBUG_PERF_APP))) {
       start_busy = (intel->batch.last_bo &&
                     drm_intel_bo_busy(intel->batch.last_bo));
       start_time = get_time();
@@ -2101,21 +2101,21 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,
       fs_visitor v2(c, prog, shader);
       v2.import_uniforms(&v);
       if (!v2.run()) {
-         perf_debug("16-wide shader failed to compile, falling back to "
-                    "8-wide at a 10-20%% performance cost: %s", v2.fail_msg);
+	perf_drv_debug("16-wide shader failed to compile, falling back to "
+		       "8-wide at a 10-20%% performance cost: %s", v2.fail_msg);
       }
    }
 
    c->prog_data.dispatch_width = 8;
 
-   if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+   if (unlikely(INTEL_DEBUG & (DEBUG_PERF | DEBUG_PERF_APP))) {
       if (shader->compiled_once)
          brw_wm_debug_recompile(brw, prog, &c->key);
       shader->compiled_once = true;
 
       if (start_busy && !drm_intel_bo_busy(intel->batch.last_bo)) {
-         perf_debug("FS compile took %.03f ms and stalled the GPU\n",
-                    (get_time() - start_time) * 1000);
+	perf_app_debug("FS compile took %.03f ms and stalled the GPU\n",
+		       (get_time() - start_time) * 1000);
       }
    }
 
diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c
index d5c4fdf..3dfdf45 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -142,9 +142,9 @@ brw_queryobj_get_results(struct gl_context *ctx,
    if (query->bo == NULL)
       return;
 
-   if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+   if (unlikely(INTEL_DEBUG & (DEBUG_PERF | DEBUG_PERF_APP))) {
       if (drm_intel_bo_busy(query->bo)) {
-         perf_debug("Stalling on the GPU waiting for a query object.\n");
+         perf_app_debug("Stalling on the GPU waiting for a query object.\n");
       }
    }
 
diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c
index d9bbcd9..79b13d6 100644
--- a/src/mesa/drivers/dri/i965/brw_state_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_state_cache.c
@@ -393,8 +393,8 @@ brw_state_cache_check_size(struct brw_context *brw)
     * state cache.
     */
    if (brw->cache.n_items > 2000) {
-      perf_debug("Exceeded state cache size limit.  Clearing the set "
-                 "of compiled programs, which will trigger recompiles\n");
+     perf_app_debug("Exceeded state cache size limit.  Clearing the set "
+		    "of compiled programs, which will trigger recompiles\n");
       brw_clear_cache(brw, &brw->cache);
    }
 }
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index 27758ab..fdb10f3 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -1013,7 +1013,7 @@ brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c)
    if (!prog)
       return false;
 
-   if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+   if (unlikely(INTEL_DEBUG & (DEBUG_PERF | DEBUG_PERF_APP))) {
       start_busy = (intel->batch.last_bo &&
                     drm_intel_bo_busy(intel->batch.last_bo));
       start_time = get_time();
@@ -1030,13 +1030,13 @@ brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c)
       printf("\n\n");
    }
 
-   if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+   if (unlikely(INTEL_DEBUG & (DEBUG_PERF | DEBUG_PERF_APP))) {
       if (shader->compiled_once) {
          brw_vs_debug_recompile(brw, prog, &c->key);
       }
       if (start_busy && !drm_intel_bo_busy(intel->batch.last_bo)) {
-         perf_debug("VS compile took %.03f ms and stalled the GPU\n",
-                    (get_time() - start_time) * 1000);
+	perf_app_debug("VS compile took %.03f ms and stalled the GPU\n",
+		       (get_time() - start_time) * 1000);
       }
    }
 
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 4507f6c..4e1c822 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -302,9 +302,9 @@ do_vs_prog(struct brw_context *brw,
 
    /* Scratch space is used for register spilling */
    if (c.last_scratch) {
-      perf_debug("Vertex shader triggered register spilling.  "
-                 "Try reducing the number of live vec4 values to "
-                 "improve performance.\n");
+     perf_app_debug("Vertex shader triggered register spilling.  "
+		    "Try reducing the number of live vec4 values to "
+		    "improve performance.\n");
 
       c.prog_data.total_scratch = brw_get_scratch_size(c.last_scratch);
 
@@ -344,7 +344,7 @@ static bool
 key_debug(const char *name, int a, int b)
 {
    if (a != b) {
-      perf_debug("  %s %d->%d\n", name, a, b);
+      perf_drv_debug("  %s %d->%d\n", name, a, b);
       return true;
    }
    return false;
@@ -359,7 +359,7 @@ brw_vs_debug_recompile(struct brw_context *brw,
    const struct brw_vs_prog_key *old_key = NULL;
    bool found = false;
 
-   perf_debug("Recompiling vertex shader for program %d\n", prog->Name);
+   perf_drv_debug("Recompiling vertex shader for program %d\n", prog->Name);
 
    for (unsigned int i = 0; i < brw->cache.size; i++) {
       for (c = brw->cache.items[i]; c; c = c->next) {
@@ -375,8 +375,8 @@ brw_vs_debug_recompile(struct brw_context *brw,
    }
 
    if (!c) {
-      perf_debug("  Didn't find previous compile in the shader cache for "
-                 "debug\n");
+     perf_drv_debug("  Didn't find previous compile in the shader cache for "
+		    "debug\n");
       return;
    }
 
@@ -408,7 +408,7 @@ brw_vs_debug_recompile(struct brw_context *brw,
    found |= brw_debug_recompile_sampler_key(&old_key->tex, &key->tex);
 
    if (!found) {
-      perf_debug("  Something else\n");
+      perf_drv_debug("  Something else\n");
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 995e8f3..4b5f9ad 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -376,9 +376,9 @@ bool do_wm_prog(struct brw_context *brw,
 
    /* Scratch space is used for register spilling */
    if (c->last_scratch) {
-      perf_debug("Fragment shader triggered register spilling.  "
-                 "Try reducing the number of live scalar values to "
-                 "improve performance.\n");
+     perf_app_debug("Fragment shader triggered register spilling.  "
+		    "Try reducing the number of live scalar values to "
+		    "improve performance.\n");
 
       c->prog_data.total_scratch = brw_get_scratch_size(c->last_scratch);
 
@@ -406,7 +406,7 @@ static bool
 key_debug(const char *name, int a, int b)
 {
    if (a != b) {
-      perf_debug("  %s %d->%d\n", name, a, b);
+      perf_drv_debug("  %s %d->%d\n", name, a, b);
       return true;
    } else {
       return false;
@@ -446,7 +446,7 @@ brw_wm_debug_recompile(struct brw_context *brw,
    const struct brw_wm_prog_key *old_key = NULL;
    bool found = false;
 
-   perf_debug("Recompiling fragment shader for program %d\n", prog->Name);
+   perf_drv_debug("Recompiling fragment shader for program %d\n", prog->Name);
 
    for (unsigned int i = 0; i < brw->cache.size; i++) {
       for (c = brw->cache.items[i]; c; c = c->next) {
@@ -462,8 +462,8 @@ brw_wm_debug_recompile(struct brw_context *brw,
    }
 
    if (!c) {
-      perf_debug("  Didn't find previous compile in the shader cache for "
-                 "debug\n");
+     perf_drv_debug("  Didn't find previous compile in the shader cache for "
+		    "debug\n");
       return;
    }
 
@@ -482,7 +482,7 @@ brw_wm_debug_recompile(struct brw_context *brw,
    found |= brw_debug_recompile_sampler_key(&old_key->tex, &key->tex);
 
    if (!found) {
-      perf_debug("  Something else\n");
+      perf_drv_debug("  Something else\n");
    }
 }
 
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index f94c6f5..b9ac6cb 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -212,8 +212,8 @@ intel_bufferobj_subdata(struct gl_context * ctx,
 	 intel_bufferobj_alloc_buffer(intel, intel_obj);
 	 drm_intel_bo_subdata(intel_obj->buffer, 0, size, data);
       } else {
-         perf_debug("Using a blit copy to avoid stalling on glBufferSubData() "
-                    "to a busy buffer object.\n");
+	perf_drv_debug("Using a blit copy to avoid stalling on glBufferSubData() "
+		       "to a busy buffer object.\n");
 	 drm_intel_bo *temp_bo =
 	    drm_intel_bo_alloc(intel->bufmgr, "subdata temp", size, 64);
 
@@ -227,9 +227,9 @@ intel_bufferobj_subdata(struct gl_context * ctx,
 	 drm_intel_bo_unreference(temp_bo);
       }
    } else {
-      if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+      if (unlikely(INTEL_DEBUG & (DEBUG_PERF | DEBUG_PERF_APP))) {
          if (drm_intel_bo_busy(intel_obj->buffer)) {
-            perf_debug("Stalling on the GPU in glBufferSubData().\n");
+            perf_app_debug("Stalling on the GPU in glBufferSubData().\n");
          }
       }
       drm_intel_bo_subdata(intel_obj->buffer, offset, size, data);
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 25334da..ea1d103 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -491,6 +491,7 @@ static const struct dri_debug_control debug_control[] = {
    { "vs",    DEBUG_VS },
    { "clip",  DEBUG_CLIP },
    { "aub",   DEBUG_AUB },
+   { "app",   DEBUG_PERF_APP },
    { NULL,    0 }
 };
 
@@ -744,6 +745,11 @@ intelInitContext(struct intel_context *intel,
    intelInitExtensions(ctx);
 
    INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
+
+#ifdef HAVE_ANDROID_PLATFORM
+   INTEL_DEBUG |= DEBUG_PERF_APP;
+#endif /* HAVE_ANDROID_PLATFORM */
+
    if (INTEL_DEBUG & DEBUG_BUFMGR)
       dri_bufmgr_set_debug(intel->bufmgr, true);
 
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index d16101d..2af69a0 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -456,20 +456,37 @@ extern int INTEL_DEBUG;
 #define DEBUG_VS        0x1000000
 #define DEBUG_CLIP      0x2000000
 #define DEBUG_AUB       0x4000000
+#define DEBUG_PERF_APP	0x8000000
+
+#ifdef HAVE_ANDROID_PLATFORM
+#define LOG_TAG "INTEL-MESA"
+#include <cutils/log.h>
+#ifndef ALOGW
+#define ALOGW LOGW
+#endif
+#define dbg_printf(...)	ALOGW(__VA_ARGS__)
+#else
+#define dbg_printf(...)	printf(__VA_ARGS__)
+#endif /* HAVE_ANDROID_PLATFORM */
 
 #define DBG(...) do {						\
 	if (unlikely(INTEL_DEBUG & FILE_DEBUG_FLAG))		\
-		printf(__VA_ARGS__);			\
+		dbg_printf(__VA_ARGS__);			\
 } while(0)
 
 #define fallback_debug(...) do {				\
 	if (unlikely(INTEL_DEBUG & DEBUG_PERF))			\
-		printf(__VA_ARGS__);				\
+		dbg_printf(__VA_ARGS__);			\
 } while(0)
 
-#define perf_debug(...) do {					\
+#define perf_drv_debug(...) do {				\
 	if (unlikely(INTEL_DEBUG & DEBUG_PERF))			\
-		printf(__VA_ARGS__);				\
+		dbg_printf(__VA_ARGS__);			\
+} while(0)
+
+#define perf_app_debug(...) do {					\
+	if (unlikely(INTEL_DEBUG & (DEBUG_PERF | DEBUG_PERF_APP)))	\
+		dbg_printf(__VA_ARGS__);				\
 } while(0)
 
 #define PCI_CHIP_845_G			0x2562
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index 7cb008c..badd7bb 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -125,7 +125,7 @@ intel_region_map(struct intel_context *intel, struct intel_region *region,
 
    if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
       if (drm_intel_bo_busy(region->bo)) {
-         perf_debug("Mapping a busy BO, causing a stall on the GPU.\n");
+         perf_drv_debug("Mapping a busy BO, causing a stall on the GPU.\n");
       }
    }
 
diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
index d3a8736..1ac8fc9 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
@@ -219,13 +219,13 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
    bo = image->mt->region->bo;
 
    if (drm_intel_bo_references(intel->batch.bo, bo)) {
-      perf_debug("Flushing before mapping a referenced bo.\n");
+      perf_drv_debug("Flushing before mapping a referenced bo.\n");
       intel_batchbuffer_flush(intel);
    }
 
    if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
       if (drm_intel_bo_busy(bo)) {
-         perf_debug("Mapping a busy BO, causing a stall on the GPU.\n");
+         perf_drv_debug("Mapping a busy BO, causing a stall on the GPU.\n");
       }
    }
 
-- 
1.7.8.6



More information about the mesa-dev mailing list