mesa: switch texel fetch functions from GLchan to GLfloat
[mesa.git] / src / mesa / tnl / t_vb_texgen.c
index bfb7a5036916379eddf8d5f38d96cd3ac4d117b2..7c1819b223cc7d6d9f100d1d507df8aff67fe153 100644 (file)
  * including any use thereof or modifications thereto.
  */
 
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/colormac.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
 
 #include "math/m_xform.h"
 
@@ -254,12 +254,12 @@ static void texgen_reflection_map_nv( GLcontext *ctx,
                                      GLuint unit )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-   GLvector4f *in = VB->TexCoordPtr[unit];
+   GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit];
    GLvector4f *out = &store->texcoord[unit];
 
    build_f_tab[VB->EyePtr->size]( out->start,
                                  out->stride,
-                                 VB->NormalPtr,
+                                 VB->AttribPtr[_TNL_ATTRIB_NORMAL],
                                  VB->EyePtr );
 
    out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3;
@@ -276,9 +276,9 @@ static void texgen_normal_map_nv( GLcontext *ctx,
                                  GLuint unit )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-   GLvector4f *in = VB->TexCoordPtr[unit];
+   GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit];
    GLvector4f *out = &store->texcoord[unit];
-   GLvector4f *normal = VB->NormalPtr;
+   GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
    GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->start;
    GLuint count = VB->Count;
    GLuint i;
@@ -304,7 +304,7 @@ static void texgen_sphere_map( GLcontext *ctx,
                               GLuint unit )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-   GLvector4f *in = VB->TexCoordPtr[unit];
+   GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit];
    GLvector4f *out = &store->texcoord[unit];
    GLfloat (*texcoord)[4] = (GLfloat (*)[4]) out->start;
    GLuint count = VB->Count;
@@ -314,7 +314,7 @@ static void texgen_sphere_map( GLcontext *ctx,
 
    (build_m_tab[VB->EyePtr->size])( store->tmp_f,
                                    store->tmp_m,
-                                   VB->NormalPtr,
+                                   VB->AttribPtr[_TNL_ATTRIB_NORMAL],
                                    VB->EyePtr );
 
    out->size = MAX2(in->size,2);
@@ -338,12 +338,12 @@ static void texgen( GLcontext *ctx,
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
-   GLvector4f *in = VB->TexCoordPtr[unit];
+   GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit];
    GLvector4f *out = &store->texcoord[unit];
    const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
    const GLvector4f *obj = VB->ObjPtr;
    const GLvector4f *eye = VB->EyePtr;
-   const GLvector4f *normal = VB->NormalPtr;
+   const GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
    const GLfloat *m = store->tmp_m;
    const GLuint count = VB->Count;
    GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->data;
@@ -367,16 +367,16 @@ static void texgen( GLcontext *ctx,
 
    if (texUnit->TexGenEnabled & S_BIT) {
       GLuint i;
-      switch (texUnit->GenModeS) {
+      switch (texUnit->GenS.Mode) {
       case GL_OBJECT_LINEAR:
         _mesa_dotprod_tab[obj->size]( (GLfloat *)out->data,
                                       sizeof(out->data[0]), obj,
-                                      texUnit->ObjectPlaneS );
+                                      texUnit->GenS.ObjectPlane );
         break;
       case GL_EYE_LINEAR:
         _mesa_dotprod_tab[eye->size]( (GLfloat *)out->data,
                                       sizeof(out->data[0]), eye,
-                                      texUnit->EyePlaneS );
+                                      texUnit->GenS.EyePlane );
         break;
       case GL_SPHERE_MAP:
          for (i = 0; i < count; i++)
@@ -400,16 +400,16 @@ static void texgen( GLcontext *ctx,
 
    if (texUnit->TexGenEnabled & T_BIT) {
       GLuint i;
-      switch (texUnit->GenModeT) {
+      switch (texUnit->GenT.Mode) {
       case GL_OBJECT_LINEAR:
         _mesa_dotprod_tab[obj->size]( &(out->data[0][1]),
                                       sizeof(out->data[0]), obj,
-                                      texUnit->ObjectPlaneT );
+                                      texUnit->GenT.ObjectPlane );
         break;
       case GL_EYE_LINEAR:
         _mesa_dotprod_tab[eye->size]( &(out->data[0][1]),
                                       sizeof(out->data[0]), eye,
-                                      texUnit->EyePlaneT );
+                                      texUnit->GenT.EyePlane );
         break;
       case GL_SPHERE_MAP:
          for (i = 0; i < count; i++)
@@ -433,16 +433,16 @@ static void texgen( GLcontext *ctx,
 
    if (texUnit->TexGenEnabled & R_BIT) {
       GLuint i;
-      switch (texUnit->GenModeR) {
+      switch (texUnit->GenR.Mode) {
       case GL_OBJECT_LINEAR:
         _mesa_dotprod_tab[obj->size]( &(out->data[0][2]),
                                       sizeof(out->data[0]), obj,
-                                      texUnit->ObjectPlaneR );
+                                      texUnit->GenR.ObjectPlane );
         break;
       case GL_EYE_LINEAR:
         _mesa_dotprod_tab[eye->size]( &(out->data[0][2]),
                                       sizeof(out->data[0]), eye,
-                                      texUnit->EyePlaneR );
+                                      texUnit->GenR.EyePlane );
         break;
       case GL_REFLECTION_MAP_NV:
         for (i=0;i<count;i++)
@@ -461,16 +461,16 @@ static void texgen( GLcontext *ctx,
    }
 
    if (texUnit->TexGenEnabled & Q_BIT) {
-      switch (texUnit->GenModeQ) {
+      switch (texUnit->GenQ.Mode) {
       case GL_OBJECT_LINEAR:
         _mesa_dotprod_tab[obj->size]( &(out->data[0][3]),
                                       sizeof(out->data[0]), obj,
-                                      texUnit->ObjectPlaneQ );
+                                      texUnit->GenQ.ObjectPlane );
         break;
       case GL_EYE_LINEAR:
         _mesa_dotprod_tab[eye->size]( &(out->data[0][3]),
                                       sizeof(out->data[0]), eye,
-                                      texUnit->EyePlaneQ );
+                                      texUnit->GenQ.EyePlane );
         break;
       default:
         _mesa_problem(ctx, "Bad Q texgen");
@@ -488,10 +488,7 @@ static GLboolean run_texgen_stage( GLcontext *ctx,
    struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
    GLuint i;
 
-   if (ctx->ShaderObjects._VertexShaderPresent)
-      return GL_TRUE;
-
-   if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled) 
+   if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current) 
       return GL_TRUE;
 
    for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
@@ -501,8 +498,8 @@ static GLboolean run_texgen_stage( GLcontext *ctx,
 
         store->TexgenFunc[i]( ctx, store, i );
 
-        VB->AttribPtr[VERT_ATTRIB_TEX0+i] = 
-           VB->TexCoordPtr[i] = &store->texcoord[i];
+         VB->TexCoordPtr[i] =
+         VB->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->texcoord[i];
       }
    }
 
@@ -516,10 +513,7 @@ static void validate_texgen_stage( GLcontext *ctx,
    struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
    GLuint i;
 
-   if (ctx->ShaderObjects._VertexShaderPresent)
-      return;
-
-   if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled) 
+   if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current) 
       return;
 
    for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {