radeonsi: enable string markers and record apitrace call numbers
authorMarek Olšák <marek.olsak@amd.com>
Wed, 29 Jun 2016 23:15:19 +0000 (01:15 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 4 Jul 2016 22:47:13 +0000 (00:47 +0200)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_debug.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_pipe.h

index 112e68684f39655ccc5b4df57668a4f46e4a4809..220ce13dab33aa6631abbc66cc78dc7ce64e2e35 100644 (file)
@@ -814,6 +814,10 @@ void si_check_vm_faults(struct r600_common_context *ctx,
        fprintf(f, "Device name: %s\n\n", screen->get_name(screen));
        fprintf(f, "Failing VM page: 0x%08x\n\n", addr);
 
+       if (sctx->apitrace_call_number)
+               fprintf(f, "Last apitrace call: %u\n\n",
+                       sctx->apitrace_call_number);
+
        switch (ring) {
        case RING_GFX:
                si_dump_debug_state(&sctx->b.b, f, 0);
index 6c88fe381f4f867bd984c4a6cdf887405b9d15f5..f15e58904ec8bc7d30ce2b16e75f1718ec12b538 100644 (file)
@@ -31,6 +31,7 @@
 #include "util/u_memory.h"
 #include "util/u_suballoc.h"
 #include "vl/vl_decoder.h"
+#include "../ddebug/dd_util.h"
 
 #define SI_LLVM_DEFAULT_FEATURES \
        "+DumpCode,+vgpr-spilling,-fp32-denormals,+fp64-denormals"
@@ -106,6 +107,22 @@ si_amdgpu_get_reset_status(struct pipe_context *ctx)
        return sctx->b.ws->ctx_query_reset_status(sctx->b.ctx);
 }
 
+/* Apitrace profiling:
+ *   1) qapitrace : Tools -> Profile: Measure CPU & GPU times
+ *   2) In the middle panel, zoom in (mouse wheel) on some bad draw call
+ *      and remember its number.
+ *   3) In Mesa, enable queries and performance counters around that draw
+ *      call and print the results.
+ *   4) glretrace --benchmark --markers ..
+ */
+static void si_emit_string_marker(struct pipe_context *ctx,
+                                 const char *string, int len)
+{
+       struct si_context *sctx = (struct si_context *)ctx;
+
+       dd_parse_apitrace_marker(string, len, &sctx->apitrace_call_number);
+}
+
 static struct pipe_context *si_create_context(struct pipe_screen *screen,
                                               void *priv, unsigned flags)
 {
@@ -125,6 +142,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
        sctx->b.b.screen = screen; /* this must be set first */
        sctx->b.b.priv = priv;
        sctx->b.b.destroy = si_destroy_context;
+       sctx->b.b.emit_string_marker = si_emit_string_marker;
        sctx->b.set_atom_dirty = (void *)si_set_atom_dirty;
        sctx->screen = sscreen; /* Easy accessing of screen/winsys. */
        sctx->is_debug = (flags & PIPE_CONTEXT_DEBUG) != 0;
@@ -361,6 +379,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:
        case PIPE_CAP_GENERATE_MIPMAP:
        case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
+       case PIPE_CAP_STRING_MARKER:
                return 1;
 
        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
@@ -413,7 +432,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_DRAW_PARAMETERS:
        case PIPE_CAP_MULTI_DRAW_INDIRECT:
        case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
-       case PIPE_CAP_STRING_MARKER:
        case PIPE_CAP_QUERY_BUFFER_OBJECT:
        case PIPE_CAP_CULL_DISTANCE:
        case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
index 3aff0ac8c056186beb83fca71ef74d428ac3e17f..9d15cbf2225f425e3c6e4bb1c5f3bf4cfb608c4a 100644 (file)
@@ -330,6 +330,7 @@ struct si_context {
        struct r600_resource    *trace_buf;
        unsigned                trace_id;
        uint64_t                dmesg_timestamp;
+       unsigned                apitrace_call_number;
 
        /* Other state */
        bool need_check_render_feedback;