Changeset 3597 for trunk/src/opengl/mesa/mmath.h
- Timestamp:
- May 23, 2000, 10:35:01 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/mmath.h
r2938 r3597 1 /* $Id: mmath.h,v 1. 1 2000-02-29 00:48:34 sandervlExp $ */1 /* $Id: mmath.h,v 1.2 2000-05-23 20:34:53 jeroen Exp $ */ 2 2 3 3 /* 4 4 * Mesa 3-D graphics library 5 * Version: 3. 15 * Version: 3.3 6 6 * 7 7 * Copyright (C) 1999 Brian Paul All Rights Reserved. … … 24 24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 25 */ 26 /* $XFree86: xc/lib/GL/mesa/src/mmath.h,v 1.2 1999/04/04 00:20:28 dawes Exp $ */27 28 29 30 26 31 27 … … 40 36 #define MMATH_H 41 37 42 #ifdef HAVE_CONFIG_H 43 #include "conf.h" 44 #endif 45 46 #ifndef XFree86Server 47 #include <math.h> 48 #else 49 #include "GL/xf86glx.h" 50 #endif 38 39 #include "glheader.h" 40 51 41 52 42 /* … … 74 64 */ 75 65 #if !defined(NO_FAST_MATH) 76 #define START_FAST_MATH(x) 66 #define START_FAST_MATH(x) \ 77 67 { \ 78 68 static fpu_control_t mask = _FPU_SINGLE | _FPU_MASK_IM \ … … 98 88 } 99 89 90 #define HAVE_FAST_MATH 91 92 #elif defined(__WATCOMC__) && !defined(NO_FAST_MATH) 93 94 /* This is the watcom specific inline assembly version of setcw and getcw */ 95 96 void START_FAST_MATH2(unsigned short *x); 97 #pragma aux START_FAST_MATH2 = \ 98 "fstcw word ptr [esi]" \ 99 "or word ptr [esi], 0x3f" \ 100 "fldcw word ptr [esi]" \ 101 parm [esi] \ 102 modify exact []; 103 104 void END_FAST_MATH2(unsigned short *x); 105 #pragma aux END_FAST_MATH2 = \ 106 "fldcw word ptr [esi]" \ 107 parm [esi] \ 108 modify exact []; 109 110 #define START_FAST_MATH(x) START_FAST_MATH2(& x) 111 #define END_FAST_MATH(x) END_FAST_MATH2(& x) 112 113 /* 114 __inline START_FAST_MATH(unsigned short x) 115 { 116 _asm { 117 fstcw ax 118 mov x , ax 119 or ax, 0x3f 120 fldcw ax 121 } 122 } 123 124 __inline END_FAST_MATH(unsigned short x) 125 { 126 _asm { 127 fldcw x 128 } 129 } 130 */ 100 131 #define HAVE_FAST_MATH 101 132 … … 132 163 int r; 133 164 _asm { 134 fld f135 fistp r136 }165 fld f 166 fistp r 167 } 137 168 return r; 138 169 } 139 #elif defined(__WIN32OS2__) 170 #elif defined(__WATCOMC__) 171 long FloatToInt(float f); 172 #pragma aux FloatToInt = \ 173 "push eax" \ 174 "fistp dword ptr [esp]" \ 175 "pop eax" \ 176 parm [8087] \ 177 value [eax] \ 178 modify exact [eax]; 179 float asm_sqrt (float x); 180 #pragma aux asm_sqrt = \ 181 "fsqrt" \ 182 parm [8087] \ 183 value [8087] \ 184 modify exact []; 185 #else 140 186 #define FloatToInt(F) ((int) (F)) 141 187 #endif … … 145 191 146 192 147 148 149 150 193 /* 151 194 * Square root … … 155 198 156 199 #ifdef FAST_MATH 200 #if defined (__WATCOMC__) && defined(USE_X86_ASM) 201 # define GL_SQRT(X) asm_sqrt(X) 202 #else 157 203 # define GL_SQRT(X) gl_sqrt(X) 204 #endif 158 205 #else 159 206 # define GL_SQRT(X) sqrt(X) … … 161 208 162 209 163 164 210 /* 165 211 * Normalize a 3-element vector to unit length. 166 212 */ 167 #define NORMALIZE_3FV( V ) 168 do { 169 GLdouble len = LEN_SQUARED_3FV(V); 170 if (len > 1e-50) { 171 len = 1.0 / GL_SQRT(len); 172 V[0] = (GLfloat) (V[0] * len); 173 V[1] = (GLfloat) (V[1] * len); 174 V[2] = (GLfloat) (V[2] * len); 175 } 213 #define NORMALIZE_3FV( V ) \ 214 do { \ 215 GLdouble len = LEN_SQUARED_3FV(V); \ 216 if (len > 1e-50) { \ 217 len = 1.0 / GL_SQRT(len); \ 218 V[0] = (GLfloat) (V[0] * len); \ 219 V[1] = (GLfloat) (V[1] * len); \ 220 V[2] = (GLfloat) (V[2] * len); \ 221 } \ 176 222 } while(0) 177 223 … … 194 240 #define IEEE_ONE 0x3f7f0000 195 241 196 #define CLAMP_FLOAT_COLOR(f) 197 do {\198 if (*(GLuint *)&f >= IEEE_ONE)\199 f = (*(GLint *)&f < 0) ? 0 : 1;\200 242 #define CLAMP_FLOAT_COLOR(f) \ 243 do { \ 244 if (*(GLuint *)&f >= IEEE_ONE) \ 245 f = (*(GLint *)&f < 0) ? 0 : 1; \ 246 } while(0) 201 247 202 248 #define CLAMP_FLOAT_COLOR_VALUE(f) \ … … 283 329 284 330 285 extern void gl_init_math(void);286 287 288 #endif 331 extern void _mesa_init_math(void); 332 333 334 #endif
Note:
See TracChangeset
for help on using the changeset viewer.