svga: try to avoid index generation for some primitive types
authorBrian Paul <brianp@vmware.com>
Fri, 16 Oct 2015 22:14:46 +0000 (16:14 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 22 Oct 2015 23:19:20 +0000 (17:19 -0600)
The svga device doesn't directly support quads, quad strips or polygons
so we have to convert those types to indexed triangle lists.  But we
can sometimes avoid that if we're drawing flat/constant-colored prims
and we don't have to worry about provoking vertex.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/drivers/svga/svga_draw_arrays.c

index e4d776443c5476c8d5d5903bed3a4acb60b18a1c..caf4b17de168d340bae38497816ac89622635878 100644 (file)
@@ -218,6 +218,20 @@ svga_hwtnl_draw_arrays(struct svga_hwtnl *hwtnl,
        * the hardware wants.
        */
       api_pv = hwtnl->hw_pv;
+
+      if (hwtnl->api_fillmode == PIPE_POLYGON_MODE_FILL) {
+         /* Do some simple primitive conversions to avoid index buffer
+          * generation below.  Note that polygons and quads are not directly
+          * supported by the svga device.  Also note, we can only do this
+          * for flat/constant-colored rendering because of provoking vertex.
+          */
+         if (prim == PIPE_PRIM_POLYGON) {
+            prim = PIPE_PRIM_TRIANGLE_FAN;
+         }
+         else if (prim == PIPE_PRIM_QUADS && count == 4) {
+            prim = PIPE_PRIM_TRIANGLE_FAN;
+         }
+      }
    }
 
    if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL &&