Kai Schütz wrote:
> 
> By enabling FLAT shading I get a really large speedup:
> 
> ======================================================================
> *** /tmp/gamma.c        Sat Jun  5 16:32:58 1999
> --- gamma.c     Sat Jun  5 16:33:13 1999
> ***************
> *** 38,41 ****
> --- 38,42 ----
>     glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
>     glMatrixMode(GL_MODELVIEW);
> +   glShadeModel(GL_FLAT);
>   }
> ======================================================================
> 
> I think rendering of Rects should always take place with flat rendering,
> because smooth rendering doesn't make sense because it's impossible to
> specify different colors/normals for the vertices. One possible solution
> would be saving ctx->Light.ShadeModel, setting it to GL_FLAT, render the rect
> and restore it. Did I miss something ? Maybe fogging ?
> 
> ======================================================================
> *** /tmp/rect.c.old     Sat Jun  5 17:06:28 1999
> --- rect.c      Sat Jun  5 17:06:38 1999
> ***************
> *** 60,71 ****
> --- 60,76 ----
>       *     flushes the vb...
>       */
> 
> +    GLenum oldshademode;
> +
>      ASSERT_OUTSIDE_BEGIN_END(ctx, "glRect");
>      RESET_IMMEDIATE(ctx);
> +    oldshademode = ctx->Light.ShadeModel;
> +    gl_ShadeModel( ctx, GL_FLAT );
>      gl_Begin( ctx, GL_QUADS );
>      gl_Vertex2f( ctx, x1, y1 );
>      gl_Vertex2f( ctx, x2, y1 );
>      gl_Vertex2f( ctx, x2, y2 );
>      gl_Vertex2f( ctx, x1, y2 );
>      gl_End( ctx );
> +    gl_ShadeModel( ctx, oldshademode );
>   }
> ======================================================================
> 
> This if course makes the patch to gamma.c useless.
> 
> BTW, referring to the TODO in rect.c: calling Driver->RectFunc() is
> only possible if the projection and modelview matrices are orthogonal, right ?


The real problem with this is that changing to flat shade & back again
means a buffer flush per rectangle.  This is masked by the fact that in
the current model we have to do a buffer flush inside the
ASSERT_OUTSIDE_BEGIN_END() command, although this hopefully won't always
be the case.  The real problem that you are addressing is the large
performance differential between smooth and flat shaded primitives in
the X driver.  It shouldn't be too great an effort to attack the problem
at its heart & it would certainly be a bigger win.

Keith


_______________________________________________
Mesa-dev maillist  -  [EMAIL PROTECTED]
http://lists.mesa3d.org/mailman/listinfo/mesa-dev

Reply via email to