[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mesa3d-dev
Subject:    Re: [Mesa3d-dev] [PATCH] st/mesa: Coalesce imm mode prims into a
From:       Keith Whitwell <keithw () vmware ! com>
Date:       2009-11-30 10:47:53
Message-ID: 2F4B3E5A36150E47A6A1ADB6106574AA2C7D55AC () EXCH-MBX-21 ! vmware ! com
[Download RAW message or body]

Younes,

This is a reasonable thing to do, but your logic is missing a few cases - line-loops, \
line-strips, polygons and quad-strips will all break with this - basically it only \
works with the discrete primitives (points, lines, tris, quads).  I'm not sure why \
you need the tests for unfilled -- I don't see any problem combining those \
primitives.  Also, it seems like this would apply to non-indexed primitives as well.

Could this be done at a slightly higher level, perhaps insert a new vbo-draw \
entrypoint that just rewrites the primitive list and then passes it down to lower \
levels?  Or indeed could it be done in the tnl/ module?

Keith


________________________________________
From: Younes Manton [younes.m@gmail.com]
Sent: Saturday, November 28, 2009 12:11 PM
To: Mesa3d-dev@lists.sourceforge.net
Subject: [Mesa3d-dev] [PATCH] st/mesa: Coalesce imm mode prims into a single    draw \
call

Is there anything in the spec or mesa internals that say this isn't
allowed? I was trying to fix what seems like an unrelated HW errata
with no luck, but it might as well be used if it's useful. I'll apply
if no one raises any concerns.

diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index c76bff9..794b426 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -672,14 +672,36 @@ st_draw_vbo(GLcontext *ctx,
                                    prims[i].start + indexOffset,
prims[i].count);
       }
       else {
-         for (i = 0; i < nr_prims; i++) {
-            setup_edgeflags(ctx, prims[i].mode,
-                            prims[i].start + indexOffset, prims[i].count,
-                            arrays[VERT_ATTRIB_EDGEFLAG]);
-
-            pipe->draw_elements(pipe, indexBuf, indexSize,
-                                prims[i].mode,
-                                prims[i].start + indexOffset, prims[i].count);
+         if (ctx->Polygon.FrontMode == GL_FILL &&
+             ctx->Polygon.BackMode == GL_FILL) {
+            /* Coalesce runs of prims into a single draw call */
+            for (i = 0; i < nr_prims; i++) {
+               GLuint firstPrimMode = prims[i].mode;
+               GLuint firstPrimStart = prims[i].start;
+               GLuint totalCount = prims[i].count;
+               if (firstPrimMode != GL_TRIANGLE_STRIP &&
firstPrimMode != GL_TRIANGLE_FAN)
+                  while (i + 1 < nr_prims && prims[i + 1].mode ==
firstPrimMode &&
+                         prims[i + 1].start == prims[i].start +
prims[i].count) {
+                     totalCount += prims[i + 1].count;
+                     i++;
+                  }
+
+               pipe->draw_elements(pipe, indexBuf, indexSize,
+                                   firstPrimMode,
+                                   firstPrimStart + indexOffset, totalCount);
+            }
+         }
+         else
+         {
+            for (i = 0; i < nr_prims; i++) {
+               setup_edgeflags(ctx, prims[i].mode,
+                               prims[i].start + indexOffset, prims[i].count,
+                               arrays[VERT_ATTRIB_EDGEFLAG]);
+
+               pipe->draw_elements(pipe, indexBuf, indexSize,
+                                   prims[i].mode,
+                                   prims[i].start + indexOffset,
prims[i].count);
+            }
          }
       }

@@ -688,12 +710,32 @@ st_draw_vbo(GLcontext *ctx,
    else {
       /* non-indexed */
       GLuint i;
-      for (i = 0; i < nr_prims; i++) {
-         setup_edgeflags(ctx, prims[i].mode,
-                         prims[i].start, prims[i].count,
-                         arrays[VERT_ATTRIB_EDGEFLAG]);
+      if (ctx->Polygon.FrontMode == GL_FILL &&
+          ctx->Polygon.BackMode == GL_FILL) {
+         /* Coalesce runs of prims into a single draw call */
+         for (i = 0; i < nr_prims; i++) {
+            GLuint firstPrimMode = prims[i].mode;
+            GLuint firstPrimStart = prims[i].start;
+            GLuint totalCount = prims[i].count;
+            if (firstPrimMode != GL_TRIANGLE_STRIP && firstPrimMode
!= GL_TRIANGLE_FAN)
+               while (i + 1 < nr_prims && prims[i + 1].mode == firstPrimMode &&
+                      prims[i + 1].start == prims[i].start + prims[i].count) {
+                  totalCount += prims[i + 1].count;
+                  i++;
+               }
+
+         pipe->draw_arrays(pipe, firstPrimMode, firstPrimStart, totalCount);
+         }
+      }
+      else
+      {
+         for (i = 0; i < nr_prims; i++) {
+            setup_edgeflags(ctx, prims[i].mode,
+                            prims[i].start, prims[i].count,
+                            arrays[VERT_ATTRIB_EDGEFLAG]);

-         pipe->draw_arrays(pipe, prims[i].mode, prims[i].start,
prims[i].count);
+            pipe->draw_arrays(pipe, prims[i].mode, prims[i].start,
prims[i].count);
+         }
       }
    }

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic