[Mesa-dev] [PATCH 2/2] svga: fix test for unfilled triangles fallback

Brian Paul brianp at vmware.com
Thu May 26 14:09:15 UTC 2016


VGPU10 actually supports line-mode triangles.  We failed to make use of
that before.
---
 src/gallium/drivers/svga/svga_draw_arrays.c   |  8 ++++--
 src/gallium/drivers/svga/svga_draw_elements.c |  3 +--
 src/gallium/drivers/svga/svga_draw_private.h  | 38 +++++++++++++++++++++++++--
 3 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c
index c056772..43d7a97 100644
--- a/src/gallium/drivers/svga/svga_draw_arrays.c
+++ b/src/gallium/drivers/svga/svga_draw_arrays.c
@@ -212,6 +212,11 @@ svga_hwtnl_draw_arrays(struct svga_hwtnl *hwtnl,
    unsigned api_pv = hwtnl->api_pv;
    struct svga_context *svga = hwtnl->svga;
 
+   if (svga->curr.rast->templ.fill_front !=
+       svga->curr.rast->templ.fill_back) {
+      assert(hwtnl->api_fillmode == PIPE_POLYGON_MODE_FILL);
+   }
+
    if (svga->curr.rast->templ.flatshade &&
        svga->state.hw_draw.fs->constant_color_output) {
       /* The fragment color is a constant, not per-vertex so the whole
@@ -236,8 +241,7 @@ svga_hwtnl_draw_arrays(struct svga_hwtnl *hwtnl,
       }
    }
 
-   if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL &&
-       u_reduced_prim(prim) == PIPE_PRIM_TRIANGLES) {
+   if (svga_need_unfilled_fallback(hwtnl, prim)) {
       /* Convert unfilled polygons into points, lines, triangles */
       gen_type = u_unfilled_generator(prim,
                                       start,
diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c
index a987b92..b74c745 100644
--- a/src/gallium/drivers/svga/svga_draw_elements.c
+++ b/src/gallium/drivers/svga/svga_draw_elements.c
@@ -138,8 +138,7 @@ svga_hwtnl_draw_range_elements(struct svga_hwtnl *hwtnl,
    u_translate_func gen_func;
    enum pipe_error ret = PIPE_OK;
 
-   if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL &&
-       u_reduced_prim(prim) == PIPE_PRIM_TRIANGLES) {
+   if (svga_need_unfilled_fallback(hwtnl, prim)) {
       gen_type = u_unfilled_translator(prim,
                                        index_size,
                                        count,
diff --git a/src/gallium/drivers/svga/svga_draw_private.h b/src/gallium/drivers/svga/svga_draw_private.h
index 48e0b60..da5d60e 100644
--- a/src/gallium/drivers/svga/svga_draw_private.h
+++ b/src/gallium/drivers/svga/svga_draw_private.h
@@ -29,6 +29,8 @@
 #include "pipe/p_compiler.h"
 #include "pipe/p_defines.h"
 #include "indices/u_indices.h"
+#include "util/u_prim.h"
+#include "svga_context.h"
 #include "svga_hw_reg.h"
 #include "svga3d_shaderdefs.h"
 
@@ -182,9 +184,41 @@ struct svga_hwtnl {
 
 
 
-/***********************************************************************
- * Internal functions
+/**
+ * Do we need to use the gallium 'indices' helper to render unfilled
+ * triangles?
  */
+static inline boolean
+svga_need_unfilled_fallback(const struct svga_hwtnl *hwtnl, unsigned prim)
+{
+   const struct svga_context *svga = hwtnl->svga;
+
+   if (u_reduced_prim(prim) != PIPE_PRIM_TRIANGLES) {
+      /* if we're drawing points or lines, no fallback needed */
+      return FALSE;
+   }
+
+   if (svga_have_vgpu10(svga)) {
+      /* vgpu10 supports polygon fill and line modes */
+      if ((prim == PIPE_PRIM_QUADS ||
+           prim == PIPE_PRIM_QUAD_STRIP ||
+           prim == PIPE_PRIM_POLYGON) &&
+          hwtnl->api_fillmode == PIPE_POLYGON_MODE_LINE) {
+         /* VGPU10 doesn't directly render quads or polygons.  They're
+          * converted to triangles.  If we let the device draw the triangle
+          * outlines we'll get an extra, stray lines in the interiors.
+          * So, to draw unfilled quads correctly, we need the fallback.
+          */
+         return true;
+      }
+      return hwtnl->api_fillmode == PIPE_POLYGON_MODE_POINT;
+   } else {
+      /* vgpu9 doesn't support line or point fill modes */
+      return hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL;
+   }
+}
+
+
 enum pipe_error 
 svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
                  const SVGA3dPrimitiveRange *range,
-- 
1.9.1



More information about the mesa-dev mailing list