svga: use the debug callback to report issues to the state tracker
authorBrian Paul <brianp@vmware.com>
Fri, 4 Dec 2015 19:26:35 +0000 (12:26 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 7 Dec 2015 15:57:49 +0000 (08:57 -0700)
Use the new debug callback hook to report conformance, performance
and fallbacks to the state tracker.  The state tracker, in turn can
report this issues to the user via the GL_ARB_debug_output extension.

More issues can be reported in the future; this is just a start.

v2: remove conditionals around pipe_debug_message() calls since the
check is now done in the macro itself.
v3: remove unneeded dummy %s substitutions

Acked-by: Ilia Mirkin <imirkin@alum.mit.edu>,
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_draw_arrays.c
src/gallium/drivers/svga/svga_pipe_blend.c
src/gallium/drivers/svga/svga_pipe_misc.c
src/gallium/drivers/svga/svga_pipe_rasterizer.c
src/gallium/drivers/svga/svga_state_need_swtnl.c

index 6a4f9d8d076270133334d5dc375791c691abd571..c4284cc3e5b491ef5a0255ee510b07941f1ca3db 100644 (file)
@@ -392,6 +392,9 @@ struct svga_context
 
       boolean no_line_width;
       boolean force_hw_line_stipple;
+
+      /** To report perf/conformance/etc issues to the state tracker */
+      struct pipe_debug_callback callback;
    } debug;
 
    struct {
index 1bf19e8522e530548eb9cdc98e582b6f7056a672..7d82930677b9f0f7912e6eb4fbe8a44f37372561 100644 (file)
@@ -26,6 +26,7 @@
 #include "svga_cmd.h"
 
 #include "util/u_inlines.h"
+#include "util/u_prim.h"
 #include "indices/u_indices.h"
 
 #include "svga_hw_reg.h"
@@ -277,6 +278,10 @@ svga_hwtnl_draw_arrays(struct svga_hwtnl *hwtnl,
       if (ret != PIPE_OK)
          goto done;
 
+      pipe_debug_message(&svga->debug.callback, PERF_INFO,
+                         "generating temporary index buffer for drawing %s",
+                         u_prim_name(prim));
+
       ret = svga_hwtnl_simple_draw_range_elements(hwtnl,
                                                   gen_buf,
                                                   gen_size,
index 0c9d6129b53e144f51db4db31be472031a9b6a5f..0af80cd42967a53ad3f887b0baf85524e0eaa1fe 100644 (file)
@@ -243,6 +243,15 @@ svga_create_blend_state(struct pipe_context *pipe,
          blend->rt[i].srcblend_alpha = blend->rt[i].srcblend;
          blend->rt[i].dstblend_alpha = blend->rt[i].dstblend;
          blend->rt[i].blendeq_alpha = blend->rt[i].blendeq;
+
+         if (templ->logicop_func == PIPE_LOGICOP_XOR) {
+            pipe_debug_message(&svga->debug.callback, CONFORMANCE,
+                               "XOR logicop mode has limited support");
+         }
+         else if (templ->logicop_func != PIPE_LOGICOP_COPY) {
+            pipe_debug_message(&svga->debug.callback, CONFORMANCE,
+                               "general logicops are not supported");
+         }
       }
       else {
          /* Note: the vgpu10 device does not yet support independent
index c8020da7c7a448e0ecafa360b2aeb362d73ba43b..af9356d7c755744bef816037d0631ab7389f25a2 100644 (file)
@@ -244,6 +244,22 @@ static void svga_set_viewport_states( struct pipe_context *pipe,
 }
 
 
+/**
+ * Called by state tracker to specify a callback function the driver
+ * can use to report info back to the state tracker.
+ */
+static void
+svga_set_debug_callback(struct pipe_context *pipe,
+                        const struct pipe_debug_callback *cb)
+{
+   struct svga_context *svga = svga_context(pipe);
+
+   if (cb)
+      svga->debug.callback = *cb;
+   else
+      memset(&svga->debug.callback, 0, sizeof(svga->debug.callback));
+}
+
 
 void svga_init_misc_functions( struct svga_context *svga )
 {
@@ -252,6 +268,7 @@ void svga_init_misc_functions( struct svga_context *svga )
    svga->pipe.set_framebuffer_state = svga_set_framebuffer_state;
    svga->pipe.set_clip_state = svga_set_clip_state;
    svga->pipe.set_viewport_states = svga_set_viewport_states;
+   svga->pipe.set_debug_callback = svga_set_debug_callback;
 }
 
 
index 6310b7a5e86f567341c5770e525f17b1d0356b80..fa1744fc33e6c04008b17452635ba6e8c6bd3d3a 100644 (file)
@@ -352,6 +352,11 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
       define_rasterizer_object(svga, rast);
    }
 
+   if (templ->poly_smooth) {
+      pipe_debug_message(&svga->debug.callback, CONFORMANCE,
+                         "GL_POLYGON_SMOOTH not supported");
+   }
+
    svga->hud.num_state_objects++;
 
    return rast;
index 429241e64e27d963406963b239e7ae30b01d79b8..b07c62da40546f758cf1f9d6df16479d76770289 100644 (file)
@@ -62,6 +62,7 @@ update_need_pipeline(struct svga_context *svga, unsigned dirty)
 {
    boolean need_pipeline = FALSE;
    struct svga_vertex_shader *vs = svga->curr.vs;
+   const char *reason = "";
 
    /* SVGA_NEW_RAST, SVGA_NEW_REDUCED_PRIMITIVE
     */
@@ -76,6 +77,20 @@ update_need_pipeline(struct svga_context *svga, unsigned dirty)
                  svga->curr.rast->need_pipeline_lines_str,
                  svga->curr.rast->need_pipeline_points_str);
       need_pipeline = TRUE;
+
+      switch (svga->curr.reduced_prim) {
+      case PIPE_PRIM_POINTS:
+         reason = svga->curr.rast->need_pipeline_points_str;
+         break;
+      case PIPE_PRIM_LINES:
+         reason = svga->curr.rast->need_pipeline_lines_str;
+         break;
+      case PIPE_PRIM_TRIANGLES:
+         reason = svga->curr.rast->need_pipeline_tris_str;
+         break;
+      default:
+         assert(!"Unexpected reduced prim type");
+      }
    }
 
    /* EDGEFLAGS
@@ -83,6 +98,7 @@ update_need_pipeline(struct svga_context *svga, unsigned dirty)
     if (vs && vs->base.info.writes_edgeflag) {
       SVGA_DBG(DEBUG_SWTNL, "%s: edgeflags\n", __FUNCTION__);
       need_pipeline = TRUE;
+      reason = "edge flags";
    }
 
    /* SVGA_NEW_FS, SVGA_NEW_RAST, SVGA_NEW_REDUCED_PRIMITIVE
@@ -104,6 +120,7 @@ update_need_pipeline(struct svga_context *svga, unsigned dirty)
           * point stage.
           */
          need_pipeline = TRUE;
+         reason = "point sprite coordinate generation";
       }
    }
 
@@ -116,6 +133,12 @@ update_need_pipeline(struct svga_context *svga, unsigned dirty)
    if (0 && svga->state.sw.need_pipeline)
       debug_printf("sw.need_pipeline = %d\n", svga->state.sw.need_pipeline);
 
+   if (svga->state.sw.need_pipeline) {
+      assert(reason);
+      pipe_debug_message(&svga->debug.callback, FALLBACK,
+                         "Using semi-fallback for %s", reason);
+   }
+
    return PIPE_OK;
 }