1e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes/*
2e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * Mesa 3-D graphics library
3b8f29f29eb611c92d43aaf8ffcd2d9743b3af967Brian Paul * Version:  6.1
4e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes *
5b8f29f29eb611c92d43aaf8ffcd2d9743b3af967Brian Paul * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
6e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes *
7e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * Permission is hereby granted, free of charge, to any person obtaining a
8e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * copy of this software and associated documentation files (the "Software"),
9e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * to deal in the Software without restriction, including without limitation
10e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * and/or sell copies of the Software, and to permit persons to whom the
12e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * Software is furnished to do so, subject to the following conditions:
13e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes *
14e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * The above copyright notice and this permission notice shall be included
15e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * in all copies or substantial portions of the Software.
16e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes *
17e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes *
24e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * Authors:
2505a4b37707d2c598ea68c05d07a3d65bcbf5a076Brian Paul *    Gareth Hughes
26e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes */
27e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
28bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul#include "main/glheader.h"
29bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul#include "main/context.h"
30bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul#include "main/macros.h"
31bbd287103dad776d8a45c87c4e51fbc26d9b80d5Brian Paul#include "main/imports.h"
32e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
33e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#include "m_matrix.h"
34e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#include "m_xform.h"
35e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
36e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#include "m_debug.h"
37e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#include "m_debug_util.h"
38e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
39462183fe4cb6df6d90632d9e2cee881c8d26b1cbAlan Hourihane#ifdef __UNIXOS2__
40462183fe4cb6df6d90632d9e2cee881c8d26b1cbAlan Hourihane/* The linker doesn't like empty files */
41462183fe4cb6df6d90632d9e2cee881c8d26b1cbAlan Hourihanestatic char dummy;
42462183fe4cb6df6d90632d9e2cee881c8d26b1cbAlan Hourihane#endif
43462183fe4cb6df6d90632d9e2cee881c8d26b1cbAlan Hourihane
4481a22ef53953d950052c7bd5a282e96107a25f24Brian Paul#ifdef DEBUG_MATH  /* This code only used for debugging */
45e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
46e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughesstatic clip_func *clip_tab[2] = {
47e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   _mesa_clip_tab,
48e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   _mesa_clip_np_tab
49e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes};
50e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughesstatic char *cnames[2] = {
51e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   "_mesa_clip_tab",
52e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   "_mesa_clip_np_tab"
53e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes};
544e9676fb13f60ecdbc247b120031f18cd3febcb0Brian Paul#ifdef RUN_DEBUG_BENCHMARK
55e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughesstatic char *cstrings[2] = {
56e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   "clip, perspective divide",
57e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   "clip, no divide"
58e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes};
594e9676fb13f60ecdbc247b120031f18cd3febcb0Brian Paul#endif
60e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
61e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
62e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes/* =============================================================
63e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * Reference cliptests
64e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes */
65e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
66e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughesstatic GLvector4f *ref_cliptest_points4( GLvector4f *clip_vec,
67e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes					 GLvector4f *proj_vec,
68e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes					 GLubyte clipMask[],
69e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes					 GLubyte *orMask,
70b4922b533155cc139ebafb111502bb55d2ad2ccfEric Anholt					 GLubyte *andMask,
71b4922b533155cc139ebafb111502bb55d2ad2ccfEric Anholt					 GLboolean viewport_z_clip )
72e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes{
73e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   const GLuint stride = clip_vec->stride;
74e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   const GLuint count = clip_vec->count;
75e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   const GLfloat *from = (GLfloat *)clip_vec->start;
76e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLuint c = 0;
77e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start;
78e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLubyte tmpAndMask = *andMask;
79e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLubyte tmpOrMask = *orMask;
80e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLuint i;
81e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) {
82e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      const GLfloat cx = from[0];
83e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      const GLfloat cy = from[1];
84e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      const GLfloat cz = from[2];
85e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      const GLfloat cw = from[3];
86e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      GLubyte mask = 0;
87e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( -cx + cw < 0 ) mask |= CLIP_RIGHT_BIT;
88e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if (  cx + cw < 0 ) mask |= CLIP_LEFT_BIT;
89e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( -cy + cw < 0 ) mask |= CLIP_TOP_BIT;
90e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if (  cy + cw < 0 ) mask |= CLIP_BOTTOM_BIT;
91b4922b533155cc139ebafb111502bb55d2ad2ccfEric Anholt      if (viewport_z_clip) {
92b4922b533155cc139ebafb111502bb55d2ad2ccfEric Anholt	 if ( -cz + cw < 0 ) mask |= CLIP_FAR_BIT;
93b4922b533155cc139ebafb111502bb55d2ad2ccfEric Anholt	 if (  cz + cw < 0 ) mask |= CLIP_NEAR_BIT;
94b4922b533155cc139ebafb111502bb55d2ad2ccfEric Anholt      }
95e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      clipMask[i] = mask;
96e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( mask ) {
97e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 c++;
98e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 tmpAndMask &= mask;
99e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 tmpOrMask |= mask;
100e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 vProj[i][0] = 0;
101e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 vProj[i][1] = 0;
102e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 vProj[i][2] = 0;
103e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 vProj[i][3] = 1;
104e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      } else {
105e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 GLfloat oow = 1.0F / cw;
106e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 vProj[i][0] = cx * oow;
107e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 vProj[i][1] = cy * oow;
108e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 vProj[i][2] = cz * oow;
109e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 vProj[i][3] = oow;
110e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      }
111e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
112e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
113e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   *orMask = tmpOrMask;
114e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   *andMask = (GLubyte) (c < count ? 0 : tmpAndMask);
115e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
116e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   proj_vec->flags |= VEC_SIZE_4;
117e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   proj_vec->size = 4;
118e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   proj_vec->count = clip_vec->count;
119e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   return proj_vec;
120e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes}
121e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
122e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes/* Keep these here for now, even though we don't use them...
123e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes */
124e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughesstatic GLvector4f *ref_cliptest_points3( GLvector4f *clip_vec,
125e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes					 GLvector4f *proj_vec,
126e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes					 GLubyte clipMask[],
127e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes					 GLubyte *orMask,
128126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul					 GLubyte *andMask,
129126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul                                         GLboolean viewport_z_clip )
130e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes{
131e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   const GLuint stride = clip_vec->stride;
132e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   const GLuint count = clip_vec->count;
133e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   const GLfloat *from = (GLfloat *)clip_vec->start;
134e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
135e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLubyte tmpOrMask = *orMask;
136e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLubyte tmpAndMask = *andMask;
137e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLuint i;
138e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) {
139e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      const GLfloat cx = from[0], cy = from[1], cz = from[2];
140e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      GLubyte mask = 0;
141e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( cx >  1.0 )		mask |= CLIP_RIGHT_BIT;
142e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      else if ( cx < -1.0 )	mask |= CLIP_LEFT_BIT;
143e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( cy >  1.0 )		mask |= CLIP_TOP_BIT;
144e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      else if ( cy < -1.0 )	mask |= CLIP_BOTTOM_BIT;
145126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul      if (viewport_z_clip) {
146126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul         if ( cz >  1.0 )		mask |= CLIP_FAR_BIT;
147126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul         else if ( cz < -1.0 )	mask |= CLIP_NEAR_BIT;
148126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul      }
149e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      clipMask[i] = mask;
150e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      tmpOrMask |= mask;
151e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      tmpAndMask &= mask;
152e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
153e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
154e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   *orMask = tmpOrMask;
155e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   *andMask = tmpAndMask;
156e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   return clip_vec;
157e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes}
158e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
159e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughesstatic GLvector4f * ref_cliptest_points2( GLvector4f *clip_vec,
160e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes					  GLvector4f *proj_vec,
161e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes					  GLubyte clipMask[],
162e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes					  GLubyte *orMask,
163126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul					  GLubyte *andMask,
164126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul                                          GLboolean viewport_z_clip )
165e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes{
166e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   const GLuint stride = clip_vec->stride;
167e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   const GLuint count = clip_vec->count;
168e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   const GLfloat *from = (GLfloat *)clip_vec->start;
169e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
170e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLubyte tmpOrMask = *orMask;
171e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLubyte tmpAndMask = *andMask;
172e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLuint i;
173126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul
174126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul   (void) viewport_z_clip;
175126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul
176e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) {
177e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      const GLfloat cx = from[0], cy = from[1];
178e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      GLubyte mask = 0;
179e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( cx >  1.0 )		mask |= CLIP_RIGHT_BIT;
180e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      else if ( cx < -1.0 )	mask |= CLIP_LEFT_BIT;
181e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( cy >  1.0 )		mask |= CLIP_TOP_BIT;
182e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      else if ( cy < -1.0 )	mask |= CLIP_BOTTOM_BIT;
183e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      clipMask[i] = mask;
184e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      tmpOrMask |= mask;
185e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      tmpAndMask &= mask;
186e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
187e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
188e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   *orMask = tmpOrMask;
189e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   *andMask = tmpAndMask;
190e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   return clip_vec;
191e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes}
192e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
193e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughesstatic clip_func ref_cliptest[5] = {
194e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   0,
195e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   0,
196e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   ref_cliptest_points2,
197e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   ref_cliptest_points3,
198e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   ref_cliptest_points4
199e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes};
200e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
201e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
202e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes/* =============================================================
203e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes * Cliptest tests
204e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes */
205e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
206b8f29f29eb611c92d43aaf8ffcd2d9743b3af967Brian PaulALIGN16(static GLfloat, s[TEST_COUNT][4]);
207b8f29f29eb611c92d43aaf8ffcd2d9743b3af967Brian PaulALIGN16(static GLfloat, d[TEST_COUNT][4]);
208b8f29f29eb611c92d43aaf8ffcd2d9743b3af967Brian PaulALIGN16(static GLfloat, r[TEST_COUNT][4]);
209b8f29f29eb611c92d43aaf8ffcd2d9743b3af967Brian Paul
210e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
211b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul/**
212b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul * Check if X, Y or Z component of the coordinate is close to W, in terms
213b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul * of the clip test.
214b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul */
215b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paulstatic GLboolean
216b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paulxyz_close_to_w(const GLfloat c[4])
217b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul{
218b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul   float k = 0.0001;
219b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul   return (fabs(c[0] - c[3]) < k ||
220b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul           fabs(c[1] - c[3]) < k ||
221b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul           fabs(c[2] - c[3]) < k ||
222b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul           fabs(-c[0] - c[3]) < k ||
223b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul           fabs(-c[1] - c[3]) < k ||
224b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul           fabs(-c[2] - c[3]) < k);
225b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul}
226b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul
227b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul
228b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul
229e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughesstatic int test_cliptest_function( clip_func func, int np,
230e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes				   int psize, long *cycles )
231e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes{
232e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLvector4f source[1], dest[1], ref[1];
233e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLubyte dm[TEST_COUNT], dco, dca;
234e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   GLubyte rm[TEST_COUNT], rco, rca;
235e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   int i, j;
236e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#ifdef  RUN_DEBUG_BENCHMARK
237e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   int cycle_i;                /* the counter for the benchmarks we run */
238e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#endif
239126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul   GLboolean viewport_z_clip = GL_TRUE;
240e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
241e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   (void) cycles;
242e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
243e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   if ( psize > 4 ) {
244e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      _mesa_problem( NULL, "test_cliptest_function called with psize > 4\n" );
245e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      return 0;
246e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
247e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
248e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   for ( i = 0 ; i < TEST_COUNT ; i++) {
249e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      ASSIGN_4V( d[i], 0.0, 0.0, 0.0, 1.0 );
250e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      ASSIGN_4V( s[i], 0.0, 0.0, 0.0, 1.0 );
251e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      for ( j = 0 ; j < psize ; j++ )
252e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes         s[i][j] = rnd();
253e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
254e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
255e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   source->data = (GLfloat(*)[4])s;
256e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   source->start = (GLfloat *)s;
257e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   source->count = TEST_COUNT;
258e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   source->stride = sizeof(s[0]);
259e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   source->size = 4;
260e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   source->flags = 0;
261e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
262e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   dest->data = (GLfloat(*)[4])d;
263e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   dest->start = (GLfloat *)d;
264e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   dest->count = TEST_COUNT;
265e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   dest->stride = sizeof(float[4]);
266e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   dest->size = 0;
267e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   dest->flags = 0;
268e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
269e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   ref->data = (GLfloat(*)[4])r;
270e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   ref->start = (GLfloat *)r;
271e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   ref->count = TEST_COUNT;
272e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   ref->stride = sizeof(float[4]);
273e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   ref->size = 0;
274e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   ref->flags = 0;
275e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
276e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   dco = rco = 0;
27751faca127005c41277df76bc8eafc8fd64ca0673Brian Paul   dca = rca = CLIP_FRUSTUM_BITS;
278e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
279126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul   ref_cliptest[psize]( source, ref, rm, &rco, &rca, viewport_z_clip );
280e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
281e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   if ( mesa_profile ) {
282e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      BEGIN_RACE( *cycles );
283126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul      func( source, dest, dm, &dco, &dca, viewport_z_clip );
284e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      END_RACE( *cycles );
285e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
286e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   else {
287126696caf7c2ab66420ab60a2c363613b88bacb4Brian Paul      func( source, dest, dm, &dco, &dca, viewport_z_clip );
288e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
289e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
290e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   if ( dco != rco ) {
291298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg      printf( "\n-----------------------------\n" );
292298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg      printf( "dco = 0x%02x   rco = 0x%02x\n", dco, rco );
293e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      return 0;
294e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
295e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   if ( dca != rca ) {
296298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg      printf( "\n-----------------------------\n" );
297298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg      printf( "dca = 0x%02x   rca = 0x%02x\n", dca, rca );
298e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      return 0;
299e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
300e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   for ( i = 0 ; i < TEST_COUNT ; i++ ) {
301e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( dm[i] != rm[i] ) {
302b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul         GLfloat *c = source->start;
303b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul         STRIDE_F(c, source->stride * i);
304b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul         if (psize == 4 && xyz_close_to_w(c)) {
305b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul            /* The coordinate is very close to the clip plane.  The clipmask
306b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul             * may vary depending on code path, but that's OK.
307b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul             */
308b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul            continue;
309b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul         }
310298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg	 printf( "\n-----------------------------\n" );
311b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul	 printf( "mask[%d] = 0x%02x   ref mask[%d] = 0x%02x\n", i, dm[i], i,rm[i] );
312b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul         printf(" coord = %f, %f, %f, %f\n",
313b89a731ff297dec597e3a4be1abf94e97d9b0e44Brian Paul                c[0], c[1], c[2], c[3]);
314e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 return 0;
315e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      }
316e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
317e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
318e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   /* Only verify output on projected points4 case.  FIXME: Do we need
319e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes    * to test other cases?
320e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes    */
321e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   if ( np || psize < 4 )
322e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      return 1;
323e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
324e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   for ( i = 0 ; i < TEST_COUNT ; i++ ) {
325e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      for ( j = 0 ; j < 4 ; j++ ) {
326e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes         if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) {
327298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg            printf( "\n-----------------------------\n" );
328298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg            printf( "(i = %i, j = %i)  dm = 0x%02x   rm = 0x%02x\n",
329e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		    i, j, dm[i], rm[i] );
330298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg            printf( "%f \t %f \t [diff = %e - %i bit missed]\n",
331e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		    d[i][0], r[i][0], r[i][0]-d[i][0],
332e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		    MAX_PRECISION - significand_match( d[i][0], r[i][0] ) );
333298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg            printf( "%f \t %f \t [diff = %e - %i bit missed]\n",
334e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		    d[i][1], r[i][1], r[i][1]-d[i][1],
335e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		    MAX_PRECISION - significand_match( d[i][1], r[i][1] ) );
336298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg            printf( "%f \t %f \t [diff = %e - %i bit missed]\n",
337e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		    d[i][2], r[i][2], r[i][2]-d[i][2],
338e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		    MAX_PRECISION - significand_match( d[i][2], r[i][2] ) );
339298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg            printf( "%f \t %f \t [diff = %e - %i bit missed]\n",
340e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		    d[i][3], r[i][3], r[i][3]-d[i][3],
341e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		    MAX_PRECISION - significand_match( d[i][3], r[i][3] ) );
342e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes            return 0;
343e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes         }
344e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      }
345e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
346e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
347e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   return 1;
348e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes}
349e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
350e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughesvoid _math_test_all_cliptest_functions( char *description )
351e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes{
352e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   int np, psize;
353e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   long benchmark_tab[2][4];
354e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   static int first_time = 1;
355e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
356e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   if ( first_time ) {
357e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      first_time = 0;
3589167d04dea5b66e07cb0f133295d56367868e19cBrian Paul      mesa_profile = _mesa_getenv( "MESA_PROFILE" );
359e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
360e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
361e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#ifdef RUN_DEBUG_BENCHMARK
362e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   if ( mesa_profile ) {
363e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( !counter_overhead ) {
364e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 INIT_COUNTER();
365298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg	 printf( "counter overhead: %ld cycles\n\n", counter_overhead );
366e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      }
367298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg      printf( "cliptest results after hooking in %s functions:\n", description );
368e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
369e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#endif
370e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
371e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#ifdef RUN_DEBUG_BENCHMARK
372e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   if ( mesa_profile ) {
373298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg      printf( "\n\t" );
374e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      for ( psize = 2 ; psize <= 4 ; psize++ ) {
375298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg	 printf( " p%d\t", psize );
376e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      }
377298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg      printf( "\n--------------------------------------------------------\n\t" );
378e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
379e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#endif
380e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
381e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   for ( np = 0 ; np < 2 ; np++ ) {
382e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      for ( psize = 2 ; psize <= 4 ; psize++ ) {
383e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 clip_func func = clip_tab[np][psize];
384e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 long *cycles = &(benchmark_tab[np][psize-1]);
385e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
386e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 if ( test_cliptest_function( func, np, psize, cycles ) == 0 ) {
387e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	    char buf[100];
388298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg	    sprintf( buf, "%s[%d] failed test (%s)",
389e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes		     cnames[np], psize, description );
390ae0cd811892d55bee12afed88fd12bb2611517d3Vinson Lee	    _mesa_problem( NULL, "%s", buf );
391e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 }
392e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#ifdef RUN_DEBUG_BENCHMARK
393e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes	 if ( mesa_profile )
394298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg	    printf( " %li\t", benchmark_tab[np][psize-1] );
395e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#endif
396e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      }
397e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#ifdef RUN_DEBUG_BENCHMARK
398e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes      if ( mesa_profile )
399298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg	 printf( " | [%s]\n\t", cstrings[np] );
400e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#endif
401e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   }
402e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#ifdef RUN_DEBUG_BENCHMARK
403e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes   if ( mesa_profile )
404298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg      printf( "\n" );
405e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes#endif
406e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes}
407e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
408e7e38a47a8dd567fd5a848cbef09b14018fb2fe0Gareth Hughes
40981a22ef53953d950052c7bd5a282e96107a25f24Brian Paul#endif /* DEBUG_MATH */
410