Ignore:
Timestamp:
May 23, 2000, 10:35:01 PM (25 years ago)
Author:
jeroen
Message:

* empty log message *

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 sandervl Exp $ */
     1/* $Id: mmath.h,v 1.2 2000-05-23 20:34:53 jeroen Exp $ */
    22
    33/*
    44 * Mesa 3-D graphics library
    5  * Version:  3.1
     5 * Version:  3.3
    66 *
    77 * Copyright (C) 1999  Brian Paul   All Rights Reserved.
     
    2424 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    2525 */
    26 /* $XFree86: xc/lib/GL/mesa/src/mmath.h,v 1.2 1999/04/04 00:20:28 dawes Exp $ */
    27 
    28 
    29 
    3026
    3127
     
    4036#define MMATH_H
    4137
    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
    5141
    5242/*
     
    7464 */
    7565#if !defined(NO_FAST_MATH)
    76 #define START_FAST_MATH(x)                                      \
     66#define START_FAST_MATH(x)                  \
    7767   {                                                            \
    7868      static fpu_control_t mask = _FPU_SINGLE | _FPU_MASK_IM    \
     
    9888   }
    9989
     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
     96void 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
     104void 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*/
    100131#define HAVE_FAST_MATH
    101132
     
    132163   int r;
    133164   _asm {
    134      fld f
    135      fistp r
    136     }
     165         fld f
     166         fistp r
     167        }
    137168   return r;
    138169}
    139 #elif defined(__WIN32OS2__)
     170#elif defined(__WATCOMC__)
     171long 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];
     179float asm_sqrt (float x);
     180#pragma aux asm_sqrt =                  \
     181        "fsqrt"                             \
     182        parm [8087]                         \
     183        value [8087]                        \
     184        modify exact [];
     185#else
    140186#define FloatToInt(F) ((int) (F))
    141187#endif
     
    145191
    146192
    147 
    148 
    149 
    150193/*
    151194 * Square root
     
    155198
    156199#ifdef FAST_MATH
     200#if defined (__WATCOMC__) && defined(USE_X86_ASM)
     201#  define GL_SQRT(X)  asm_sqrt(X)
     202#else
    157203#  define GL_SQRT(X)  gl_sqrt(X)
     204#endif
    158205#else
    159206#  define GL_SQRT(X)  sqrt(X)
     
    161208
    162209
    163 
    164210/*
    165211 * Normalize a 3-element vector to unit length.
    166212 */
    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 )                      \
     214do {                                            \
     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   }                                            \
    176222} while(0)
    177223
     
    194240#define IEEE_ONE 0x3f7f0000
    195241
    196 #define CLAMP_FLOAT_COLOR(f)                    \
    197         do {                                    \
    198            if (*(GLuint *)&f >= IEEE_ONE)       \
    199               f = (*(GLint *)&f < 0) ? 0 : 1;   \
    200         } while(0)
     242#define CLAMP_FLOAT_COLOR(f)                    \
     243        do {                                    \
     244           if (*(GLuint *)&f >= IEEE_ONE)       \
     245              f = (*(GLint *)&f < 0) ? 0 : 1;   \
     246        } while(0)
    201247
    202248#define CLAMP_FLOAT_COLOR_VALUE(f)              \
     
    283329
    284330
    285 extern void gl_init_math(void);
    286 
    287 
    288 #endif
     331extern void _mesa_init_math(void);
     332
     333
     334#endif
Note: See TracChangeset for help on using the changeset viewer.