Killed mmath.[ch]. Moved low-level functions/assembly code into imports.[ch]
[mesa.git] / src / mesa / main / state.c
index 500ba2640ffa3b361a9b473c643ef01795eb054e..1051bda11da3c8fdf9fea141a1b97721a5141906 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: state.c,v 1.89 2002/07/09 01:22:50 brianp Exp $ */
+/* $Id: state.c,v 1.99 2003/03/01 01:50:22 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  4.1
+ * Version:  5.1
  *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -31,9 +31,6 @@
  */
 
 
-#ifdef PC_HEADER
-#include "all.h"
-#else
 #include "glheader.h"
 #include "accum.h"
 #include "api_loopback.h"
 #include "fog.h"
 #include "hint.h"
 #include "histogram.h"
+#include "imports.h"
 #include "light.h"
 #include "lines.h"
 #include "matrix.h"
-#include "mmath.h"
 #include "pixel.h"
 #include "points.h"
 #include "polygon.h"
 #include "texstate.h"
 #include "mtypes.h"
 #include "varray.h"
-#include "vpstate.h"
+#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
+#include "nvprogram.h"
+#endif
 
 #include "math/m_matrix.h"
 #include "math/m_xform.h"
-#endif
 
 
 static int
 generic_noop(void)
 {
 #ifdef DEBUG
-   _mesa_problem(NULL, "undefined function dispatch");
+   _mesa_problem(NULL, "User called no-op dispatch function");
 #endif
    return 0;
 }
@@ -296,6 +294,7 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
 
    /* 1.1 */
    exec->AreTexturesResident = _mesa_AreTexturesResident;
+   exec->AreTexturesResidentEXT = _mesa_AreTexturesResident;
    exec->BindTexture = _mesa_BindTexture;
    exec->ColorPointer = _mesa_ColorPointer;
    exec->CopyTexImage1D = _mesa_CopyTexImage1D;
@@ -307,10 +306,12 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
    exec->EdgeFlagPointer = _mesa_EdgeFlagPointer;
    exec->EnableClientState = _mesa_EnableClientState;
    exec->GenTextures = _mesa_GenTextures;
+   exec->GenTexturesEXT = _mesa_GenTextures;
    exec->GetPointerv = _mesa_GetPointerv;
    exec->IndexPointer = _mesa_IndexPointer;
    exec->InterleavedArrays = _mesa_InterleavedArrays;
    exec->IsTexture = _mesa_IsTexture;
+   exec->IsTextureEXT = _mesa_IsTexture;
    exec->NormalPointer = _mesa_NormalPointer;
    exec->PopClientAttrib = _mesa_PopClientAttrib;
    exec->PrioritizeTextures = _mesa_PrioritizeTextures;
@@ -343,18 +344,31 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
    exec->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D;
    exec->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D;
    exec->GetColorTable = _mesa_GetColorTable;
+   exec->GetColorTableEXT = _mesa_GetColorTable;
    exec->GetColorTableParameterfv = _mesa_GetColorTableParameterfv;
+   exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv;
    exec->GetColorTableParameteriv = _mesa_GetColorTableParameteriv;
+   exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv;
    exec->GetConvolutionFilter = _mesa_GetConvolutionFilter;
+   exec->GetConvolutionFilterEXT = _mesa_GetConvolutionFilter;
    exec->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv;
+   exec->GetConvolutionParameterfvEXT = _mesa_GetConvolutionParameterfv;
    exec->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv;
+   exec->GetConvolutionParameterivEXT = _mesa_GetConvolutionParameteriv;
    exec->GetHistogram = _mesa_GetHistogram;
+   exec->GetHistogramEXT = _mesa_GetHistogram;
    exec->GetHistogramParameterfv = _mesa_GetHistogramParameterfv;
+   exec->GetHistogramParameterfvEXT = _mesa_GetHistogramParameterfv;
    exec->GetHistogramParameteriv = _mesa_GetHistogramParameteriv;
+   exec->GetHistogramParameterivEXT = _mesa_GetHistogramParameteriv;
    exec->GetMinmax = _mesa_GetMinmax;
+   exec->GetMinmaxEXT = _mesa_GetMinmax;
    exec->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv;
+   exec->GetMinmaxParameterfvEXT = _mesa_GetMinmaxParameterfv;
    exec->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv;
+   exec->GetMinmaxParameterivEXT = _mesa_GetMinmaxParameteriv;
    exec->GetSeparableFilter = _mesa_GetSeparableFilter;
+   exec->GetSeparableFilterEXT = _mesa_GetSeparableFilter;
    exec->Histogram = _mesa_Histogram;
    exec->Minmax = _mesa_Minmax;
    exec->ResetHistogram = _mesa_ResetHistogram;
@@ -462,6 +476,7 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
    exec->WindowPos4svMESA = _mesa_WindowPos4svMESA;
 
    /* 233. GL_NV_vertex_program */
+#if FEATURE_NV_vertex_program
    exec->BindProgramNV = _mesa_BindProgramNV;
    exec->DeleteProgramsNV = _mesa_DeleteProgramsNV;
    exec->ExecuteProgramNV = _mesa_ExecuteProgramNV;
@@ -487,11 +502,30 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
    exec->ProgramParameters4fvNV = _mesa_ProgramParameters4fvNV;
    exec->TrackMatrixNV = _mesa_TrackMatrixNV;
    exec->VertexAttribPointerNV = _mesa_VertexAttribPointerNV;
+#endif
+
+#if 0 && FEATURE_NV_fragment_program
+   exec->ProgramNamedParameter4fNV = _mesa_ProgramNamedParameter4fNV;
+   exec->ProgramNamedParameter4dNV = _mesa_ProgramNamedParameter4dNV;
+   exec->ProgramNamedParameter4fvNV = _mesa_ProgramNamedParameter4fvNV;
+   exec->ProgramNamedParameter4dvNV = _mesa_ProgramNamedParameter4dvNV;
+   exec->GetProgramNamedParameterfvNV = _mesa_GetProgramNamedParameterfvNV;
+   exec->GetProgramNamedParameterdvNV = _mesa_GetProgramNamedParameterdvNV;
+   exec->ProgramLocalParameter4dARB = _mesa_ProgramLocalParameter4dARB;
+   exec->ProgramLocalParameter4dvARB = _mesa_ProgramLocalParameter4dvARB;
+   exec->ProgramLocalParameter4fARB = _mesa_ProgramLocalParameter4fARB;
+   exec->ProgramLocalParameter4fvARB = _mesa_ProgramLocalParameter4fvARB;
+   exec->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB;
+   exec->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB;
+#endif
 
    /* 262. GL_NV_point_sprite */
    exec->PointParameteriNV = _mesa_PointParameteriNV;
    exec->PointParameterivNV = _mesa_PointParameterivNV;
 
+   /* 268. GL_EXT_stencil_two_side */
+   exec->ActiveStencilFaceEXT = _mesa_ActiveStencilFaceEXT;
+
    /* ARB 1. GL_ARB_multitexture */
    exec->ActiveTextureARB = _mesa_ActiveTextureARB;
    exec->ClientActiveTextureARB = _mesa_ClientActiveTextureARB;
@@ -516,7 +550,6 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
 
    /* ARB 14. GL_ARB_point_parameters */
    /* reuse EXT_point_parameters functions */
-
 }
 
 
@@ -539,23 +572,21 @@ update_polygon( GLcontext *ctx )
       ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
 
    /* Any Polygon offsets enabled? */
-   ctx->Polygon._OffsetAny = GL_FALSE;
    if (ctx->Polygon.OffsetPoint ||
        ctx->Polygon.OffsetLine ||
        ctx->Polygon.OffsetFill) {
       ctx->_TriangleCaps |= DD_TRI_OFFSET;
-      ctx->Polygon._OffsetAny = GL_TRUE;
    }
 }
 
 static void
 calculate_model_project_matrix( GLcontext *ctx )
 {
-      _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix,
-                              ctx->ProjectionMatrixStack.Top,
-                              ctx->ModelviewMatrixStack.Top );
+   _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix,
+                            ctx->ProjectionMatrixStack.Top,
+                            ctx->ModelviewMatrixStack.Top );
 
-      _math_matrix_analyse( &ctx->_ModelProjectMatrix );
+   _math_matrix_analyse( &ctx->_ModelProjectMatrix );
 }
 
 static void
@@ -570,9 +601,9 @@ update_modelview_scale( GLcontext *ctx )
       GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
       if (f < 1e-12) f = 1.0;
       if (ctx->_NeedEyeCoords)
-        ctx->_ModelViewInvScale = (GLfloat) (1.0/GL_SQRT(f));
+        ctx->_ModelViewInvScale = 1.0F / SQRTF(f);
       else
-        ctx->_ModelViewInvScale = (GLfloat) GL_SQRT(f);
+        ctx->_ModelViewInvScale = SQRTF(f);
    }
 }
 
@@ -771,7 +802,6 @@ update_texture_state( GLcontext *ctx )
 {
    GLuint unit;
 
-   ctx->Texture._ReallyEnabled = 0;  /* XXX obsolete */
    ctx->Texture._EnabledUnits = 0;
    ctx->Texture._GenFlags = 0;
    ctx->_NeedNormals &= ~NEED_NORMALS_TEXGEN;
@@ -853,15 +883,8 @@ update_texture_state( GLcontext *ctx )
         continue;
       }
 
-      /* Texture._ReallyEnabled records the enable state for all units in
-       * one word.
-       */
-      {
-         GLuint flag = texUnit->_ReallyEnabled << (unit * NUM_TEXTURE_TARGETS);
-        ctx->Texture._ReallyEnabled |= flag;  /* XXX obsolete field! */
-         if (texUnit->_ReallyEnabled)
-            ctx->Texture._EnabledUnits |= (1 << unit);
-      }
+      if (texUnit->_ReallyEnabled)
+         ctx->Texture._EnabledUnits |= (1 << unit);
 
       if (texUnit->TexGenEnabled) {
         if (texUnit->TexGenEnabled & S_BIT) {
@@ -1038,9 +1061,6 @@ void _mesa_update_state( GLcontext *ctx )
    ASSERT(ctx->Driver.CopyTexSubImage2D);
    ASSERT(ctx->Driver.CopyTexSubImage3D);
    if (ctx->Extensions.ARB_texture_compression) {
-      ASSERT(ctx->Driver.BaseCompressedTexFormat);
-      ASSERT(ctx->Driver.CompressedTextureSize);
-      ASSERT(ctx->Driver.GetCompressedTexImage);
 #if 0  /* HW drivers need these, but not SW rasterizers */
       ASSERT(ctx->Driver.CompressedTexImage1D);
       ASSERT(ctx->Driver.CompressedTexImage2D);