additional wrapper updates, bug 4468

This commit is contained in:
Brian Paul
2005-09-19 20:12:32 +00:00
parent a01cb26a90
commit b3aefd1cfb
26 changed files with 227 additions and 109 deletions

View File

@@ -60,6 +60,31 @@ typedef struct {
char *name; char *name;
} DGL_extension; } DGL_extension;
#ifndef __MINGW32__
/* XXX why is this here?
* It should probaby be somewhere in src/mesa/drivers/windows/
*/
#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(BUILD_FOR_SNAP)
# define WGL_FONT_LINES 0
# define WGL_FONT_POLYGONS 1
#ifndef _GNU_H_WINDOWS32_FUNCTIONS
# ifdef UNICODE
# define wglUseFontBitmaps wglUseFontBitmapsW
# define wglUseFontOutlines wglUseFontOutlinesW
# else
# define wglUseFontBitmaps wglUseFontBitmapsA
# define wglUseFontOutlines wglUseFontOutlinesA
# endif /* !UNICODE */
#endif /* _GNU_H_WINDOWS32_FUNCTIONS */
typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
#if !defined(GLX_USE_MESA)
#include <GL/mesa_wgl.h>
#endif
#endif
#endif /* !__MINGW32__ */
/*------------------------- Function Prototypes ---------------------------*/ /*------------------------- Function Prototypes ---------------------------*/
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -4542,7 +4542,7 @@ const char *_mesa_lookup_enum_by_nr( int nr )
{ {
unsigned * i; unsigned * i;
i = (unsigned *)bsearch( & nr, reduced_enums, Elements(reduced_enums), i = (unsigned *)_mesa_bsearch( & nr, reduced_enums, Elements(reduced_enums),
sizeof(reduced_enums[0]), (cfunc) compar_nr ); sizeof(reduced_enums[0]), (cfunc) compar_nr );
if ( i != NULL ) { if ( i != NULL ) {
@@ -4560,7 +4560,7 @@ int _mesa_lookup_enum_by_name( const char *symbol )
enum_elt * f = NULL; enum_elt * f = NULL;
if ( symbol != NULL ) { if ( symbol != NULL ) {
f = (enum_elt *)bsearch( symbol, all_enums, Elements(all_enums), f = (enum_elt *)_mesa_bsearch( symbol, all_enums, Elements(all_enums),
sizeof( enum_elt ), (cfunc) compar_name ); sizeof( enum_elt ), (cfunc) compar_name );
} }

View File

@@ -118,32 +118,6 @@ typedef UINT_PTR uintptr_t;
#endif /* WIN32 / CYGWIN bracket */ #endif /* WIN32 / CYGWIN bracket */
#ifndef __MINGW32__
/* XXX why is this here?
* It should probaby be somewhere in src/mesa/drivers/windows/
*/
#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(BUILD_FOR_SNAP)
# define WGL_FONT_LINES 0
# define WGL_FONT_POLYGONS 1
#ifndef _GNU_H_WINDOWS32_FUNCTIONS
# ifdef UNICODE
# define wglUseFontBitmaps wglUseFontBitmapsW
# define wglUseFontOutlines wglUseFontOutlinesW
# else
# define wglUseFontBitmaps wglUseFontBitmapsA
# define wglUseFontOutlines wglUseFontOutlinesA
# endif /* !UNICODE */
#endif /* _GNU_H_WINDOWS32_FUNCTIONS */
typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
#if !defined(GLX_USE_MESA)
#include <GL/mesa_wgl.h>
#endif
#endif
#endif /* !__MINGW32__ */
/* /*
* Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN. * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
* Do not use them unless absolutely necessary! * Do not use them unless absolutely necessary!
@@ -173,7 +147,6 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
#define CAPI _cdecl #define CAPI _cdecl
#endif #endif
#include <GL/internal/glcore.h>
/* This is a macro on IRIX */ /* This is a macro on IRIX */
@@ -267,20 +240,6 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
# define __builtin_expect(x, y) x # define __builtin_expect(x, y) x
#endif #endif
/* Windows does not have the ffs() function */
#if defined(_WIN32) && !defined(__MINGW32__)
int INLINE ffs(int value)
{
int bit;
if (value == 0)
return 0;
for (bit=1; !(value & 1); bit++)
value >>= 1;
return bit;
}
#endif
/* The __FUNCTION__ gcc variable is generally only used for debugging. /* The __FUNCTION__ gcc variable is generally only used for debugging.
* If we're not using gcc, define __FUNCTION__ as a cpp symbol here. * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
* Don't define it if using a newer Windows compiler. * Don't define it if using a newer Windows compiler.

View File

@@ -23,7 +23,6 @@
* \todo Functions still needed: * \todo Functions still needed:
* - scanf * - scanf
* - qsort * - qsort
* - bsearch
* - rand and RAND_MAX * - rand and RAND_MAX
* *
* \note When compiled into a XFree86 module these functions wrap around * \note When compiled into a XFree86 module these functions wrap around
@@ -529,6 +528,34 @@ _mesa_pow(double x, double y)
} }
/* Windows does not have the ffs() function */
#if defined(_WIN32) && !defined(__MINGW32__)
int INLINE ffs(int value)
{
int bit;
if (value == 0)
return 0;
for (bit=1; !(value & 1); bit++)
value >>= 1;
return bit;
}
#endif
/**
* Wrapper around either ffs() or xf86ffs().
*/
int
_mesa_ffs(int i)
{
#if defined(XFree86LOADER) && defined(IN_MODULE)
return xf86ffs(i);
#else
return ffs(i);
#endif
}
/** /**
* Return number of bits set in given GLuint. * Return number of bits set in given GLuint.
*/ */
@@ -684,6 +711,27 @@ _mesa_half_to_float(GLhalfARB val)
/*@}*/ /*@}*/
/**********************************************************************/
/** \name Sort & Search */
/*@{*/
/**
* Wrapper for bsearch().
*/
void *
_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *) )
{
#if defined(XFree86LOADER) && defined(IN_MODULE)
return xf86bsearch(key, base, nmemb, size, compar);
#else
return bsearch(key, base, nmemb, size, compar);
#endif
}
/*@}*/
/**********************************************************************/ /**********************************************************************/
/** \name Environment vars */ /** \name Environment vars */
/*@{*/ /*@{*/
@@ -860,6 +908,17 @@ _mesa_printf( const char *fmtString, ... )
#endif #endif
} }
/** Wrapper around either vsprintf() or xf86vsprintf() */
int
_mesa_vsprintf( char *str, const char *fmt, va_list args )
{
#if defined(XFree86LOADER) && defined(IN_MODULE)
return xf86vsprintf( str, fmt, args );
#else
return vsprintf( str, fmt, args );
#endif
}
/*@}*/ /*@}*/
@@ -1035,6 +1094,26 @@ _mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
/*@}*/ /*@}*/
/**********************************************************************/
/** \name Exit */
/*@{*/
/**
* Wrapper for exit().
*/
void
_mesa_exit( int status )
{
#if defined(XFree86LOADER) && defined(IN_MODULE)
xf86exit(status);
#else
exit(status);
#endif
}
/*@}*/
/**********************************************************************/ /**********************************************************************/
/** \name Default Imports Wrapper */ /** \name Default Imports Wrapper */
/*@{*/ /*@{*/

View File

@@ -39,6 +39,7 @@
/* XXX some of the stuff in glheader.h should be moved into this file. /* XXX some of the stuff in glheader.h should be moved into this file.
*/ */
#include "glheader.h" #include "glheader.h"
#include <GL/internal/glcore.h>
#ifdef __cplusplus #ifdef __cplusplus
@@ -274,6 +275,8 @@ static INLINE int GET_FLOAT_BITS( float x )
*** CEILF: ceiling of float *** CEILF: ceiling of float
*** FLOORF: floor of float *** FLOORF: floor of float
*** FABSF: absolute value of float *** FABSF: absolute value of float
*** LOGF: the natural logarithm (base e) of the value
*** EXPF: raise e to the value
*** LDEXPF: multiply value by an integral power of two *** LDEXPF: multiply value by an integral power of two
*** FREXPF: extract mantissa and exponent from value *** FREXPF: extract mantissa and exponent from value
***/ ***/
@@ -281,6 +284,8 @@ static INLINE int GET_FLOAT_BITS( float x )
#define CEILF(x) ((GLfloat) xf86ceil(x)) #define CEILF(x) ((GLfloat) xf86ceil(x))
#define FLOORF(x) ((GLfloat) xf86floor(x)) #define FLOORF(x) ((GLfloat) xf86floor(x))
#define FABSF(x) ((GLfloat) xf86fabs(x)) #define FABSF(x) ((GLfloat) xf86fabs(x))
#define LOGF(x) ((GLfloat) xf86log(x))
#define EXPF(x) ((GLfloat) xf86exp(x))
#define LDEXPF(x,y) ((GLfloat) xf86ldexp(x,y)) #define LDEXPF(x,y) ((GLfloat) xf86ldexp(x,y))
#define FREXPF(x,y) ((GLfloat) xf86frexp(x,y)) #define FREXPF(x,y) ((GLfloat) xf86frexp(x,y))
#elif defined(__gnu_linux__) #elif defined(__gnu_linux__)
@@ -288,12 +293,16 @@ static INLINE int GET_FLOAT_BITS( float x )
#define CEILF(x) ceilf(x) #define CEILF(x) ceilf(x)
#define FLOORF(x) floorf(x) #define FLOORF(x) floorf(x)
#define FABSF(x) fabsf(x) #define FABSF(x) fabsf(x)
#define LOGF(x) logf(x)
#define EXPF(x) expf(x)
#define LDEXPF(x,y) ldexpf(x,y) #define LDEXPF(x,y) ldexpf(x,y)
#define FREXPF(x,y) frexpf(x,y) #define FREXPF(x,y) frexpf(x,y)
#else #else
#define CEILF(x) ((GLfloat) ceil(x)) #define CEILF(x) ((GLfloat) ceil(x))
#define FLOORF(x) ((GLfloat) floor(x)) #define FLOORF(x) ((GLfloat) floor(x))
#define FABSF(x) ((GLfloat) fabs(x)) #define FABSF(x) ((GLfloat) fabs(x))
#define LOGF(x) ((GLfloat) log(x))
#define EXPF(x) ((GLfloat) exp(x))
#define LDEXPF(x,y) ((GLfloat) ldexp(x,y)) #define LDEXPF(x,y) ((GLfloat) ldexp(x,y))
#define FREXPF(x,y) ((GLfloat) frexp(x,y)) #define FREXPF(x,y) ((GLfloat) frexp(x,y))
#endif #endif
@@ -637,6 +646,9 @@ _mesa_pow(double x, double y);
extern float extern float
_mesa_log2(float x); _mesa_log2(float x);
extern int
_mesa_ffs(int i);
extern unsigned int extern unsigned int
_mesa_bitcount(unsigned int n); _mesa_bitcount(unsigned int n);
@@ -647,6 +659,10 @@ extern float
_mesa_half_to_float(GLhalfARB h); _mesa_half_to_float(GLhalfARB h);
extern void *
_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *) );
extern char * extern char *
_mesa_getenv( const char *var ); _mesa_getenv( const char *var );
@@ -686,6 +702,9 @@ _mesa_sprintf( char *str, const char *fmt, ... );
extern void extern void
_mesa_printf( const char *fmtString, ... ); _mesa_printf( const char *fmtString, ... );
extern int
_mesa_vsprintf( char *str, const char *fmt, va_list args );
extern void extern void
_mesa_warning( __GLcontext *gc, const char *fmtString, ... ); _mesa_warning( __GLcontext *gc, const char *fmtString, ... );
@@ -699,6 +718,9 @@ _mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
extern void extern void
_mesa_debug( const __GLcontext *ctx, const char *fmtString, ... ); _mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
extern void
_mesa_exit( int status );
extern void extern void
_mesa_init_default_imports( __GLimports *imports, void *driverCtx ); _mesa_init_default_imports( __GLimports *imports, void *driverCtx );

View File

@@ -36,6 +36,7 @@
#include "glheader.h" #include "glheader.h"
#include <GL/internal/glcore.h> /* GLimports/GLexports/GLcontextModes */
#include "config.h" /* Hardwired parameters */ #include "config.h" /* Hardwired parameters */
#include "glapitable.h" #include "glapitable.h"
#include "glthread.h" #include "glthread.h"

View File

@@ -350,16 +350,16 @@ static struct ureg get_temp( struct texenv_fragment_program *p )
/* First try and reuse temps which have been used already: /* First try and reuse temps which have been used already:
*/ */
bit = ffs( ~p->temp_in_use & p->alu_temps ); bit = _mesa_ffs( ~p->temp_in_use & p->alu_temps );
/* Then any unused temporary: /* Then any unused temporary:
*/ */
if (!bit) if (!bit)
bit = ffs( ~p->temp_in_use ); bit = _mesa_ffs( ~p->temp_in_use );
if (!bit) { if (!bit) {
_mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
exit(1); _mesa_exit(1);
} }
if (bit > p->program->Base.NumTemporaries) if (bit > p->program->Base.NumTemporaries)
@@ -378,16 +378,16 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p )
* ~p->temps_output isn't necessary, but will keep it there for * ~p->temps_output isn't necessary, but will keep it there for
* now: * now:
*/ */
bit = ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output ); bit = _mesa_ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output );
/* Then any unused temporary: /* Then any unused temporary:
*/ */
if (!bit) if (!bit)
bit = ffs( ~p->temp_in_use ); bit = _mesa_ffs( ~p->temp_in_use );
if (!bit) { if (!bit) {
_mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
exit(1); _mesa_exit(1);
} }
if (bit > p->program->Base.NumTemporaries) if (bit > p->program->Base.NumTemporaries)

View File

@@ -165,7 +165,7 @@ static void ref_norm_transform_normalize( const GLmatrix *mat,
/* Hmmm, don't know how we could test the precalculated /* Hmmm, don't know how we could test the precalculated
* length case... * length case...
*/ */
scale = 1.0 / sqrt( len ); scale = 1.0 / SQRTF( len );
SCALE_SCALAR_3V( out[i], scale, t ); SCALE_SCALAR_3V( out[i], scale, t );
} else { } else {
out[i][0] = out[i][1] = out[i][2] = 0; out[i][0] = out[i][1] = out[i][2] = 0;
@@ -230,7 +230,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
case VAR: case VAR:
break; break;
default: default:
abort(); _mesa_exit(1);
} }
} }
} }
@@ -241,7 +241,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 ); ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
for ( j = 0 ; j < 3 ; j++ ) for ( j = 0 ; j < 3 ; j++ )
s[i][j] = rnd(); s[i][j] = rnd();
length[i] = 1 / sqrt( LEN_SQUARED_3FV( s[i] ) ); length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
} }
source->data = (GLfloat(*)[4]) s; source->data = (GLfloat(*)[4]) s;
@@ -339,7 +339,7 @@ void _math_test_all_normal_transform_functions( char *description )
if ( first_time ) { if ( first_time ) {
first_time = 0; first_time = 0;
mesa_profile = getenv( "MESA_PROFILE" ); mesa_profile = _mesa_getenv( "MESA_PROFILE" );
} }
#ifdef RUN_DEBUG_BENCHMARK #ifdef RUN_DEBUG_BENCHMARK

View File

@@ -284,7 +284,7 @@ void _math_test_all_transform_functions( char *description )
if ( first_time ) { if ( first_time ) {
first_time = 0; first_time = 0;
mesa_profile = getenv( "MESA_PROFILE" ); mesa_profile = _mesa_getenv( "MESA_PROFILE" );
} }
#ifdef RUN_DEBUG_BENCHMARK #ifdef RUN_DEBUG_BENCHMARK

View File

@@ -382,9 +382,9 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
/* choose pivot - or die */ /* choose pivot - or die */
if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2); if (FABSF(r3[0])>FABSF(r2[0])) SWAP_ROWS(r3, r2);
if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1); if (FABSF(r2[0])>FABSF(r1[0])) SWAP_ROWS(r2, r1);
if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0); if (FABSF(r1[0])>FABSF(r0[0])) SWAP_ROWS(r1, r0);
if (0.0 == r0[0]) return GL_FALSE; if (0.0 == r0[0]) return GL_FALSE;
/* eliminate first variable */ /* eliminate first variable */
@@ -402,8 +402,8 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; } if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */ /* choose pivot - or die */
if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2); if (FABSF(r3[1])>FABSF(r2[1])) SWAP_ROWS(r3, r2);
if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1); if (FABSF(r2[1])>FABSF(r1[1])) SWAP_ROWS(r2, r1);
if (0.0 == r1[1]) return GL_FALSE; if (0.0 == r1[1]) return GL_FALSE;
/* eliminate second variable */ /* eliminate second variable */
@@ -416,7 +416,7 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */ /* choose pivot - or die */
if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2); if (FABSF(r3[2])>FABSF(r2[2])) SWAP_ROWS(r3, r2);
if (0.0 == r2[2]) return GL_FALSE; if (0.0 == r2[2]) return GL_FALSE;
/* eliminate third variable */ /* eliminate third variable */
@@ -1075,7 +1075,7 @@ _math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
m[2] *= x; m[6] *= y; m[10] *= z; m[2] *= x; m[6] *= y; m[10] *= z;
m[3] *= x; m[7] *= y; m[11] *= z; m[3] *= x; m[7] *= y; m[11] *= z;
if (fabs(x - y) < 1e-8 && fabs(x - z) < 1e-8) if (FABSF(x - y) < 1e-8 && FABSF(x - z) < 1e-8)
mat->flags |= MAT_FLAG_UNIFORM_SCALE; mat->flags |= MAT_FLAG_UNIFORM_SCALE;
else else
mat->flags |= MAT_FLAG_GENERAL_SCALE; mat->flags |= MAT_FLAG_GENERAL_SCALE;

View File

@@ -3886,7 +3886,7 @@ static int extension_is_supported (const GLubyte *ext)
while (extensions < end) while (extensions < end)
{ {
const GLubyte *name_end = (const GLubyte *) strchr ((const char *) extensions, ' '); const GLubyte *name_end = (const GLubyte *) _mesa_strstr ((const char *) extensions, " ");
if (name_end == NULL) if (name_end == NULL)
name_end = end; name_end = end;
if (name_end - extensions == ext_len && _mesa_strncmp ((const char *) ext, if (name_end - extensions == ext_len && _mesa_strncmp ((const char *) ext,
@@ -4037,7 +4037,7 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
strz[len] = '\0'; strz[len] = '\0';
#if DEBUG_PARSING #if DEBUG_PARSING
printf ("Checking Grammar!\n"); fprintf (stderr, "Checking Grammar!\n");
#endif #endif
/* do a fast check on program string - initial production buffer is 4K */ /* do a fast check on program string - initial production buffer is 4K */
err = grammar_fast_check (arbprogram_syn_id, strz, &parsed, &parsed_len, 0x1000); err = grammar_fast_check (arbprogram_syn_id, strz, &parsed, &parsed_len, 0x1000);
@@ -4050,21 +4050,23 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
_mesa_error (ctx, GL_INVALID_OPERATION, "glProgramStringARB(syntax error)"); _mesa_error (ctx, GL_INVALID_OPERATION, "glProgramStringARB(syntax error)");
/* useful for debugging */ /* useful for debugging */
if (0) { #if DEBUG_PARSING
do {
int line, col; int line, col;
char *s; char *s;
printf("Program: %s\n", (char *) strz); fprintf(stderr, "Program: %s\n", (char *) strz);
printf("Error Pos: %d\n", ctx->Program.ErrorPos); fprintf(stderr, "Error Pos: %d\n", ctx->Program.ErrorPos);
s = (char *) _mesa_find_line_column(strz, strz+ctx->Program.ErrorPos, &line, &col); s = (char *) _mesa_find_line_column(strz, strz+ctx->Program.ErrorPos, &line, &col);
printf("line %d col %d: %s\n", line, col, s); fprintf(stderr, "line %d col %d: %s\n", line, col, s);
} } while (0)
#endif
grammar_destroy (arbprogram_syn_id); grammar_destroy (arbprogram_syn_id);
return 1; return 1;
} }
#if DEBUG_PARSING #if DEBUG_PARSING
printf ("Destroying grammer dict [parse retval: %d]\n", err); fprintf (stderr, "Destroying grammer dict [parse retval: %d]\n", err);
#endif #endif
grammar_destroy (arbprogram_syn_id); grammar_destroy (arbprogram_syn_id);
@@ -4120,7 +4122,7 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
_mesa_free (parsed); _mesa_free (parsed);
#if DEBUG_PARSING #if DEBUG_PARSING
printf ("_mesa_parse_arb_program() done\n"); fprintf (stderr, "_mesa_parse_arb_program() done\n");
#endif #endif
return err; return err;
} }

View File

@@ -452,7 +452,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{ {
GLfloat t[4], q[4], floor_t0; GLfloat t[4], q[4], floor_t0;
fetch_vector1( &inst->SrcReg[0], state, t ); fetch_vector1( &inst->SrcReg[0], state, t );
floor_t0 = (float) floor(t[0]); floor_t0 = FLOORF(t[0]);
if (floor_t0 > FLT_MAX_EXP) { if (floor_t0 > FLT_MAX_EXP) {
SET_POS_INFINITY(q[0]); SET_POS_INFINITY(q[0]);
SET_POS_INFINITY(q[2]); SET_POS_INFINITY(q[2]);
@@ -481,7 +481,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{ {
GLfloat t[4], q[4], abs_t0; GLfloat t[4], q[4], abs_t0;
fetch_vector1( &inst->SrcReg[0], state, t ); fetch_vector1( &inst->SrcReg[0], state, t );
abs_t0 = (GLfloat) fabs(t[0]); abs_t0 = FABSF(t[0]);
if (abs_t0 != 0.0F) { if (abs_t0 != 0.0F) {
/* Since we really can't handle infinite values on VMS /* Since we really can't handle infinite values on VMS
* like other OSes we'll use __MAXFLOAT to represent * like other OSes we'll use __MAXFLOAT to represent
@@ -499,7 +499,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
} }
else { else {
int exponent; int exponent;
double mantissa = frexp(t[0], &exponent); GLfloat mantissa = FREXPF(t[0], &exponent);
q[0] = (GLfloat) (exponent - 1); q[0] = (GLfloat) (exponent - 1);
q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */ q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */
q[2] = (GLfloat) (q[0] + LOG2(q[1])); q[2] = (GLfloat) (q[0] + LOG2(q[1]));
@@ -635,7 +635,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{ {
GLfloat t[4]; GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t ); fetch_vector4( &inst->SrcReg[0], state, t );
state->AddressReg[0] = (GLint) floor(t[0]); state->AddressReg[0] = (GLint) FLOORF(t[0]);
} }
break; break;
case VP_OPCODE_DPH: case VP_OPCODE_DPH:

View File

@@ -635,7 +635,7 @@ int slang_info_log_error (slang_info_log *log, const char *msg, ...)
char buf[1024]; char buf[1024];
va_start (va, msg); va_start (va, msg);
_mesa_sprintf (buf, msg, va); _mesa_vsprintf (buf, msg, va);
if (slang_info_log_message (log, "error", buf)) if (slang_info_log_message (log, "error", buf))
return 1; return 1;
slang_info_log_memory (log); slang_info_log_memory (log);
@@ -649,7 +649,7 @@ int slang_info_log_warning (slang_info_log *log, const char *msg, ...)
char buf[1024]; char buf[1024];
va_start (va, msg); va_start (va, msg);
_mesa_sprintf (buf, msg, va); _mesa_vsprintf (buf, msg, va);
if (slang_info_log_message (log, "warning", buf)) if (slang_info_log_message (log, "warning", buf))
return 1; return 1;
slang_info_log_memory (log); slang_info_log_memory (log);
@@ -685,7 +685,7 @@ static int parse_identifier (slang_parse_ctx *C, char **id)
slang_info_log_memory (C->L); slang_info_log_memory (C->L);
return 0; return 0;
} }
C->I += strlen ((const char *) C->I) + 1; C->I += _mesa_strlen ((const char *) C->I) + 1;
return 1; return 1;
} }
@@ -734,8 +734,9 @@ static int parse_float (slang_parse_ctx *C, float *number)
return 0; return 0;
} }
whole = (char *) (slang_alloc_malloc ((strlen (integral) + strlen (fractional) + strlen ( whole = (char *) (slang_alloc_malloc ((_mesa_strlen (integral) +
exponent) + 3) * sizeof (char))); _mesa_strlen (fractional) + _mesa_strlen (exponent) + 3) *
sizeof (char)));
if (whole == NULL) if (whole == NULL)
{ {
slang_alloc_free (exponent); slang_alloc_free (exponent);
@@ -751,7 +752,7 @@ static int parse_float (slang_parse_ctx *C, float *number)
slang_string_concat (whole, "E"); slang_string_concat (whole, "E");
slang_string_concat (whole, exponent); slang_string_concat (whole, exponent);
*number = (float) (atof (whole)); *number = (float) (_mesa_strtod(whole, (char **)NULL));
slang_alloc_free (whole); slang_alloc_free (whole);
slang_alloc_free (exponent); slang_alloc_free (exponent);
@@ -2115,7 +2116,7 @@ if (slang_string_compare ("main", (**parsed_func_ret).header.name) == 0)
xxx_prolog (&file, (**parsed_func_ret).address); xxx_prolog (&file, (**parsed_func_ret).address);
_slang_execute (&file); _slang_execute (&file);
slang_assembly_file_destruct (&file); slang_assembly_file_destruct (&file);
exit (0); _mesa_exit (0);
} }
} }
return 1; return 1;

View File

@@ -34,6 +34,9 @@
#include "slang_storage.h" #include "slang_storage.h"
#include "slang_execute.h" #include "slang_execute.h"
#define DEBUG_SLANG
#ifdef DEBUG_SLANG
static void dump_instruction (FILE *f, slang_assembly *a, unsigned int i) static void dump_instruction (FILE *f, slang_assembly *a, unsigned int i)
{ {
fprintf (f, "%.5u:\t", i); fprintf (f, "%.5u:\t", i);
@@ -179,11 +182,14 @@ static void dump (const slang_assembly_file *file)
fclose (f); fclose (f);
} }
#endif
int _slang_execute (const slang_assembly_file *file) int _slang_execute (const slang_assembly_file *file)
{ {
slang_machine mach; slang_machine mach;
#ifdef DEBUG_SLANG
FILE *f; FILE *f;
#endif
mach.ip = 0; mach.ip = 0;
mach.sp = SLANG_MACHINE_STACK_SIZE; mach.sp = SLANG_MACHINE_STACK_SIZE;
@@ -200,13 +206,18 @@ int _slang_execute (const slang_assembly_file *file)
static_assert(sizeof (GLuint) == 4); static_assert(sizeof (GLuint) == 4);
/*static_assert(sizeof (GLuint *) == 4);*/ /*static_assert(sizeof (GLuint *) == 4);*/
#ifdef DEBUG_SLANG
dump (file); dump (file);
#endif
#ifdef DEBUG_SLANG
f = fopen ("~mesa-slang-assembly-execution.txt", "w"); f = fopen ("~mesa-slang-assembly-execution.txt", "w");
#endif
while (!mach.exit) while (!mach.exit)
{ {
slang_assembly *a = file->code + mach.ip; slang_assembly *a = file->code + mach.ip;
#ifdef DEBUG_SLANG
if (f != NULL) if (f != NULL)
{ {
unsigned int i; unsigned int i;
@@ -216,6 +227,7 @@ int _slang_execute (const slang_assembly_file *file)
fprintf (f, "\t%.5u\t%6f\t%u\n", i, mach.stack._float[i], mach.stack._addr[i]); fprintf (f, "\t%.5u\t%6f\t%u\n", i, mach.stack._float[i], mach.stack._addr[i]);
fflush (f); fflush (f);
} }
#endif
mach.ip++; mach.ip++;
switch (a->type) switch (a->type)
@@ -344,8 +356,10 @@ int _slang_execute (const slang_assembly_file *file)
} }
} }
#ifdef DEBUG_SLANG
if (f != NULL) if (f != NULL)
fclose (f); fclose (f);
#endif
return 0; return 0;
} }

View File

@@ -210,7 +210,7 @@ compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4],
if (rho2 == 0.0F) if (rho2 == 0.0F)
return 0.0; return 0.0;
else else
return (GLfloat) (log(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */ return (GLfloat) (LOGF(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */
} }

View File

@@ -51,12 +51,12 @@ _swrast_z_to_fogfactor(GLcontext *ctx, GLfloat z)
return CLAMP(f, 0.0F, 1.0F); return CLAMP(f, 0.0F, 1.0F);
case GL_EXP: case GL_EXP:
d = ctx->Fog.Density; d = ctx->Fog.Density;
f = (GLfloat) exp(-d * z); f = EXPF(-d * z);
f = CLAMP(f, 0.0F, 1.0F); f = CLAMP(f, 0.0F, 1.0F);
return f; return f;
case GL_EXP2: case GL_EXP2:
d = ctx->Fog.Density; d = ctx->Fog.Density;
f = (GLfloat) exp(-(d * d * z * z)); f = EXPF(-(d * d * z * z));
f = CLAMP(f, 0.0F, 1.0F); f = CLAMP(f, 0.0F, 1.0F);
return f; return f;
default: default:
@@ -130,7 +130,7 @@ _swrast_fog_rgba_span( const GLcontext *ctx, struct sw_span *span )
GLuint i; GLuint i;
for (i = 0; i < span->end; i++) { for (i = 0; i < span->end; i++) {
GLfloat f, oneMinusF; GLfloat f, oneMinusF;
f = (GLfloat) exp(density * FABSF(fogCoord) / w); f = EXPF(density * FABSF(fogCoord) / w);
f = CLAMP(f, 0.0F, 1.0F); f = CLAMP(f, 0.0F, 1.0F);
oneMinusF = 1.0F - f; oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog); rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
@@ -158,7 +158,7 @@ _swrast_fog_rgba_span( const GLcontext *ctx, struct sw_span *span )
if (tmp < FLT_MIN_10_EXP) if (tmp < FLT_MIN_10_EXP)
tmp = FLT_MIN_10_EXP; tmp = FLT_MIN_10_EXP;
#endif #endif
f = (GLfloat) exp(tmp); f = EXPF(tmp);
f = CLAMP(f, 0.0F, 1.0F); f = CLAMP(f, 0.0F, 1.0F);
oneMinusF = 1.0F - f; oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog); rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
@@ -259,7 +259,7 @@ _swrast_fog_ci_span( const GLcontext *ctx, struct sw_span *span )
GLfloat w = haveW ? span->w : 1.0F; GLfloat w = haveW ? span->w : 1.0F;
GLuint i; GLuint i;
for (i = 0; i < span->end; i++) { for (i = 0; i < span->end; i++) {
GLfloat f = (GLfloat) exp(density * fogCoord / w); GLfloat f = EXPF(density * fogCoord / w);
f = CLAMP(f, 0.0F, 1.0F); f = CLAMP(f, 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex); index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fogCoord += fogStep; fogCoord += fogStep;
@@ -284,7 +284,7 @@ _swrast_fog_ci_span( const GLcontext *ctx, struct sw_span *span )
if (tmp < FLT_MIN_10_EXP) if (tmp < FLT_MIN_10_EXP)
tmp = FLT_MIN_10_EXP; tmp = FLT_MIN_10_EXP;
#endif #endif
f = (GLfloat) exp(tmp); f = EXPF(tmp);
f = CLAMP(f, 0.0F, 1.0F); f = CLAMP(f, 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex); index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fogCoord += fogStep; fogCoord += fogStep;

View File

@@ -821,7 +821,7 @@ execute_program( GLcontext *ctx,
result[0] = 1.0F; result[0] = 1.0F;
result[1] = a[0]; result[1] = a[0];
/* XXX we could probably just use pow() here */ /* XXX we could probably just use pow() here */
result[2] = (a[0] > 0.0F) ? (GLfloat) exp(a[3] * log(a[1])) : 0.0F; result[2] = (a[0] > 0.0F) ? EXPF(a[3] * LOGF(a[1])) : 0.0F;
result[3] = 1.0F; result[3] = 1.0F;
store_vector4( inst, machine, result ); store_vector4( inst, machine, result );
} }

View File

@@ -297,7 +297,7 @@ repeat_remainder(GLint a, GLint b)
} \ } \
break; \ break; \
case GL_MIRROR_CLAMP_EXT: \ case GL_MIRROR_CLAMP_EXT: \
U = (GLfloat) fabs(S); \ U = FABSF(S); \
if (U >= 1.0F) \ if (U >= 1.0F) \
U = (GLfloat) SIZE; \ U = (GLfloat) SIZE; \
else \ else \
@@ -307,7 +307,7 @@ repeat_remainder(GLint a, GLint b)
I1 = I0 + 1; \ I1 = I0 + 1; \
break; \ break; \
case GL_MIRROR_CLAMP_TO_EDGE_EXT: \ case GL_MIRROR_CLAMP_TO_EDGE_EXT: \
U = (GLfloat) fabs(S); \ U = FABSF(S); \
if (U >= 1.0F) \ if (U >= 1.0F) \
U = (GLfloat) SIZE; \ U = (GLfloat) SIZE; \
else \ else \
@@ -324,7 +324,7 @@ repeat_remainder(GLint a, GLint b)
{ \ { \
const GLfloat min = -1.0F / (2.0F * SIZE); \ const GLfloat min = -1.0F / (2.0F * SIZE); \
const GLfloat max = 1.0F - min; \ const GLfloat max = 1.0F - min; \
U = (GLfloat) fabs(S); \ U = FABSF(S); \
if (U <= min) \ if (U <= min) \
U = min * SIZE; \ U = min * SIZE; \
else if (U >= max) \ else if (U >= max) \
@@ -418,7 +418,7 @@ repeat_remainder(GLint a, GLint b)
{ \ { \
/* s limited to [0,1] */ \ /* s limited to [0,1] */ \
/* i limited to [0,size-1] */ \ /* i limited to [0,size-1] */ \
const GLfloat u = (GLfloat) fabs(S); \ const GLfloat u = FABSF(S); \
if (u <= 0.0F) \ if (u <= 0.0F) \
I = 0; \ I = 0; \
else if (u >= 1.0F) \ else if (u >= 1.0F) \
@@ -433,7 +433,7 @@ repeat_remainder(GLint a, GLint b)
/* i limited to [0, size-1] */ \ /* i limited to [0, size-1] */ \
const GLfloat min = 1.0F / (2.0F * SIZE); \ const GLfloat min = 1.0F / (2.0F * SIZE); \
const GLfloat max = 1.0F - min; \ const GLfloat max = 1.0F - min; \
const GLfloat u = (GLfloat) fabs(S); \ const GLfloat u = FABSF(S); \
if (u < min) \ if (u < min) \
I = 0; \ I = 0; \
else if (u > max) \ else if (u > max) \
@@ -448,7 +448,7 @@ repeat_remainder(GLint a, GLint b)
/* i limited to [0, size-1] */ \ /* i limited to [0, size-1] */ \
const GLfloat min = -1.0F / (2.0F * SIZE); \ const GLfloat min = -1.0F / (2.0F * SIZE); \
const GLfloat max = 1.0F - min; \ const GLfloat max = 1.0F - min; \
const GLfloat u = (GLfloat) fabs(S); \ const GLfloat u = FABSF(S); \
if (u < min) \ if (u < min) \
I = -1; \ I = -1; \
else if (u > max) \ else if (u > max) \

View File

@@ -97,7 +97,7 @@ static GLfloat RoughApproxPower(GLfloat x, GLfloat y)
*/ */
static GLfloat ApproxLog2(GLfloat t) static GLfloat ApproxLog2(GLfloat t)
{ {
return (GLfloat) (log(t) * 1.442695F); return (GLfloat) (LOGF(t) * 1.442695F);
} }
static GLfloat ApproxExp2(GLfloat t) static GLfloat ApproxExp2(GLfloat t)

View File

@@ -80,7 +80,7 @@ init_static_data( void )
GLfloat f = 0.0F; GLfloat f = 0.0F;
GLint i = 0; GLint i = 0;
for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) { for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
exp_table[i] = (GLfloat) exp(-f); exp_table[i] = EXPF(-f);
} }
inited = 1; inited = 1;
} }

View File

@@ -203,7 +203,7 @@ static INLINE void insert_3f_xyw_4( const struct tnl_clipspace_attr *a, GLubyte
static INLINE void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) static INLINE void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
{ {
(void) a; (void) v; (void) in; (void) a; (void) v; (void) in;
abort(); _mesa_exit(1);
} }
static INLINE void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ) static INLINE void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )

View File

@@ -326,10 +326,10 @@ static struct ureg swizzle1( struct ureg reg, int x )
static struct ureg get_temp( struct tnl_program *p ) static struct ureg get_temp( struct tnl_program *p )
{ {
int bit = ffs( ~p->temp_in_use ); int bit = _mesa_ffs( ~p->temp_in_use );
if (!bit) { if (!bit) {
fprintf(stderr, "%s: out of temporaries\n", __FILE__); _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
exit(1); _mesa_exit(1);
} }
p->temp_in_use |= 1<<(bit-1); p->temp_in_use |= 1<<(bit-1);

View File

@@ -113,8 +113,12 @@ static void _tnl_vb_bind_vtx( GLcontext *ctx )
GLuint count = tnl->vtx.initial_counter - tnl->vtx.counter; GLuint count = tnl->vtx.initial_counter - tnl->vtx.counter;
GLuint attr, i; GLuint attr, i;
if (0) fprintf(stderr, "_tnl_vb_bind_vtx(): %d verts %d vertsize\n", #undef DEBUG_VTX
#ifdef DEBUG_VTX
fprintf(stderr, "_tnl_vb_bind_vtx(): %d verts %d vertsize\n",
count, tnl->vtx.vertex_size); count, tnl->vtx.vertex_size);
#endif
/* Setup constant data in the VB. /* Setup constant data in the VB.

View File

@@ -44,7 +44,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "t_vtx_api.h" #include "t_vtx_api.h"
#include "simple_list.h" #include "simple_list.h"
#if defined(USE_X86_ASM) && !defined(HAVE_NONSTANDARD_GLAPIENTRY) #if defined(USE_X86_ASM) && !defined(HAVE_NONSTANDARD_GLAPIENTRY)
#define EXTERN( FUNC ) \ #define EXTERN( FUNC ) \
@@ -94,6 +93,18 @@ EXTERN( _tnl_x86_choose_fv );
#undef DEBUG_VTX
#ifdef DEBUG_VTX
#define FIXUP_PRINTF( offset, NEWVAL ) \
fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL))
#define FIXUPREL_PRINTF( offset, NEWVAL, CODE ) \
fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL) - ((int)(CODE)+offset) - 4)
#else
#define FIXUP_PRINTF( offset, NEWVAL )
#define FIXUPREL_PRINTF( offset, NEWVAL, CODE )
#endif
#define FIXUP( CODE, KNOWN_OFFSET, CHECKVAL, NEWVAL ) \ #define FIXUP( CODE, KNOWN_OFFSET, CHECKVAL, NEWVAL ) \
do { \ do { \
GLint subst = 0x10101010 + CHECKVAL; \ GLint subst = 0x10101010 + CHECKVAL; \
@@ -101,7 +112,7 @@ do { \
if (DONT_KNOW_OFFSETS) { \ if (DONT_KNOW_OFFSETS) { \
while (*(int *)(CODE+offset) != subst) offset++; \ while (*(int *)(CODE+offset) != subst) offset++; \
*(int *)(CODE+offset) = (int)(NEWVAL); \ *(int *)(CODE+offset) = (int)(NEWVAL); \
if (0) fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL)); \ FIXUP_PRINTF(offset, NEWVAL); \
offset += 4; \ offset += 4; \
} \ } \
else { \ else { \
@@ -120,7 +131,7 @@ do { \
if (DONT_KNOW_OFFSETS) { \ if (DONT_KNOW_OFFSETS) { \
while (*(int *)(CODE+offset) != subst) offset++; \ while (*(int *)(CODE+offset) != subst) offset++; \
*(int *)(CODE+offset) = (int)(NEWVAL) - ((int)(CODE)+offset) - 4; \ *(int *)(CODE+offset) = (int)(NEWVAL) - ((int)(CODE)+offset) - 4; \
if (0) fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL) - ((int)(CODE)+offset) - 4); \ FIXUPREL_PRINTF(offset, NEWVAL, CODE); \
offset += 4; \ offset += 4; \
} \ } \
else { \ else { \

View File

@@ -1,4 +1,4 @@
/* $Id: x86-64.c,v 1.1 2005/05/07 16:59:59 brianp Exp $ */ /* $Id: x86-64.c,v 1.2 2005/09/19 20:12:33 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -70,7 +70,7 @@ static void message( const char *msg )
} }
#endif #endif
if ( debug ) { if ( debug ) {
fprintf( stderr, "%s", msg ); _mesa_debug( NULL, "%s", msg );
} }
} }
#endif #endif

View File

@@ -71,7 +71,7 @@ static void message( const char *msg )
} }
#endif #endif
if ( debug ) { if ( debug ) {
fprintf( stderr, "%s", msg ); _mesa_debug( NULL, "%s", msg );
} }
} }