Mesa (master): llvmpipe: added some jit debug code

Brian Paul brianp at kemper.freedesktop.org
Thu Jul 29 23:32:08 UTC 2010


Module: Mesa
Branch: master
Commit: 6c1625cc405f0d77523c122cedf3e8003f2aa7bf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6c1625cc405f0d77523c122cedf3e8003f2aa7bf

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Jul 29 17:31:17 2010 -0600

llvmpipe: added some jit debug code

If we crash in the jitted function we can examine jit_line and
jit_state in gdb to learn more about the shader.

---

 src/gallium/drivers/llvmpipe/lp_rast.c      |   10 +++++++++
 src/gallium/drivers/llvmpipe/lp_rast_priv.h |   30 +++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index ba7b483..3215d0f 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -43,6 +43,12 @@
 #include "lp_scene.h"
 
 
+#ifdef DEBUG
+int jit_line = 0;
+const struct lp_rast_state *jit_state = NULL;
+#endif
+
+
 /**
  * Begin rasterizing a scene.
  * Called once per scene by one thread.
@@ -419,6 +425,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
          depth = lp_rast_get_depth_block_pointer(task, tile_x + x, tile_y + y);
 
          /* run shader on 4x4 block */
+         BEGIN_JIT_CALL(state);
          variant->jit_function[RAST_WHOLE]( &state->jit_context,
                                             tile_x + x, tile_y + y,
                                             inputs->facing,
@@ -429,6 +436,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
                                             depth,
                                             0xffff,
                                             &task->vis_counter);
+         END_JIT_CALL();
       }
    }
 }
@@ -498,6 +506,7 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
    assert(lp_check_alignment(state->jit_context.blend_color, 16));
 
    /* run shader on 4x4 block */
+   BEGIN_JIT_CALL(state);
    variant->jit_function[RAST_EDGE_TEST](&state->jit_context,
                                          x, y,
                                          inputs->facing,
@@ -508,6 +517,7 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
                                          depth,
                                          mask,
                                          &task->vis_counter);
+   END_JIT_CALL();
 }
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index b4a48cf..760ab3d 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -40,6 +40,34 @@
 #include "lp_limits.h"
 
 
+/* If we crash in a jitted function, we can examine jit_line and jit_state
+ * to get some info.  This is not thread-safe, however.
+ */
+#ifdef DEBUG
+
+extern int jit_line;
+extern const struct lp_rast_state *jit_state;
+
+#define BEGIN_JIT_CALL(state) \
+   do { \
+      jit_line = __LINE__; \
+      jit_state = state; \
+   } while (0)
+
+#define END_JIT_CALL() \
+   do { \
+      jit_line = 0; \
+      jit_state = NULL; \
+   } while (0)
+
+#else
+
+#define BEGIN_JIT_CALL(X)
+#define END_JIT_CALL
+
+#endif
+
+
 struct lp_rasterizer;
 
 
@@ -249,6 +277,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
    depth = lp_rast_get_depth_block_pointer(task, x, y);
 
    /* run shader on 4x4 block */
+   BEGIN_JIT_CALL(state);
    variant->jit_function[RAST_WHOLE]( &state->jit_context,
                                       x, y,
                                       inputs->facing,
@@ -259,6 +288,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
                                       depth,
                                       0xffff,
                                       &task->vis_counter );
+   END_JIT_CALL();
 }
 
 




More information about the mesa-commit mailing list