Mesa (master): mesa: check for z=0 in _mesa_Vertex3dv()

Brian Paul brianp at kemper.freedesktop.org
Tue Jan 5 20:04:16 UTC 2016


Module: Mesa
Branch: master
Commit: f04d7439a0ad6e13ff2912ff824553b6bcf511a4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f04d7439a0ad6e13ff2912ff824553b6bcf511a4

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Jan  5 13:03:04 2016 -0700

mesa: check for z=0 in _mesa_Vertex3dv()

It's very rare that a GL app calls glVertex3dv(), but one in particular
calls it lot, always with Z = 0.  Check for that condition and convert
the call into glVertex2f.  This reduces VBO memory used and reduces
the number of times we have to switch between float[2] and float[3]
vertex formats in the svga driver.  This results in a small but
measurable performance improvement.

Reviewed-by: Charmaine Lee <charmainel at vmware.com>

---

 src/mesa/main/api_loopback.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c
index a7fd82c..8b63d9c 100644
--- a/src/mesa/main/api_loopback.c
+++ b/src/mesa/main/api_loopback.c
@@ -629,7 +629,10 @@ _mesa_Vertex2sv( const GLshort *v )
 void GLAPIENTRY
 _mesa_Vertex3dv( const GLdouble *v )
 {
-   VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
+   if (v[2] == 0.0)
+      VERTEX2( (GLfloat) v[0], (GLfloat) v[1] );
+   else
+      VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
 }
 
 void GLAPIENTRY




More information about the mesa-commit mailing list