OSDN Git Service

mesa: separate legacy stuff from gl_texture_unit into gl_fixedfunc_texture_unit
authorMarek Olšák <marek.olsak@amd.com>
Wed, 15 Nov 2017 21:02:51 +0000 (22:02 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 13 Feb 2018 00:00:45 +0000 (01:00 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
32 files changed:
src/mesa/drivers/common/meta.c
src/mesa/drivers/dri/i915/i830_texblend.c
src/mesa/drivers/dri/nouveau/nouveau_util.h
src/mesa/drivers/dri/nouveau/nv04_context.c
src/mesa/drivers/dri/nouveau/nv04_state_frag.c
src/mesa/drivers/dri/nouveau/nv10_state_frag.c
src/mesa/drivers/dri/nouveau/nv10_state_tex.c
src/mesa/drivers/dri/nouveau/nv20_state_tex.c
src/mesa/drivers/dri/r200/r200_tex.c
src/mesa/drivers/dri/r200/r200_texstate.c
src/mesa/drivers/dri/radeon/radeon_maos_verts.c
src/mesa/drivers/dri/radeon/radeon_state.c
src/mesa/drivers/dri/radeon/radeon_tex.c
src/mesa/drivers/dri/radeon/radeon_texstate.c
src/mesa/main/attrib.c
src/mesa/main/context.c
src/mesa/main/enable.c
src/mesa/main/ff_fragment_shader.cpp
src/mesa/main/ffvertex_prog.c
src/mesa/main/get.c
src/mesa/main/get_hash_params.py
src/mesa/main/mtypes.h
src/mesa/main/rastpos.c
src/mesa/main/texenv.c
src/mesa/main/texgen.c
src/mesa/main/texstate.c
src/mesa/main/texstate.h
src/mesa/program/prog_statevars.c
src/mesa/swrast/s_context.c
src/mesa/swrast/s_texcombine.c
src/mesa/swrast/s_triangle.c
src/mesa/tnl/t_vb_texgen.c

index a7dd139..cd898e2 100644 (file)
@@ -631,14 +631,14 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
       GLuint u, tgt;
 
       save->ActiveUnit = ctx->Texture.CurrentUnit;
-      save->EnvMode = ctx->Texture.Unit[0].EnvMode;
+      save->EnvMode = ctx->Texture.FixedFuncUnit[0].EnvMode;
 
       /* Disable all texture units */
       for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-         save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled;
-         save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled;
-         if (ctx->Texture.Unit[u].Enabled ||
-             ctx->Texture.Unit[u].TexGenEnabled) {
+         save->TexEnabled[u] = ctx->Texture.FixedFuncUnit[u].Enabled;
+         save->TexGenEnabled[u] = ctx->Texture.FixedFuncUnit[u].TexGenEnabled;
+         if (ctx->Texture.FixedFuncUnit[u].Enabled ||
+             ctx->Texture.FixedFuncUnit[u].TexGenEnabled) {
             _mesa_ActiveTexture(GL_TEXTURE0 + u);
             _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE);
             if (ctx->Extensions.ARB_texture_cube_map)
@@ -1065,14 +1065,14 @@ _mesa_meta_end(struct gl_context *ctx)
 
       /* Restore fixed function texture enables, texgen */
       for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-         if (ctx->Texture.Unit[u].Enabled != save->TexEnabled[u]) {
+         if (ctx->Texture.FixedFuncUnit[u].Enabled != save->TexEnabled[u]) {
             FLUSH_VERTICES(ctx, _NEW_TEXTURE);
-            ctx->Texture.Unit[u].Enabled = save->TexEnabled[u];
+            ctx->Texture.FixedFuncUnit[u].Enabled = save->TexEnabled[u];
          }
 
-         if (ctx->Texture.Unit[u].TexGenEnabled != save->TexGenEnabled[u]) {
+         if (ctx->Texture.FixedFuncUnit[u].TexGenEnabled != save->TexGenEnabled[u]) {
             FLUSH_VERTICES(ctx, _NEW_TEXTURE);
-            ctx->Texture.Unit[u].TexGenEnabled = save->TexGenEnabled[u];
+            ctx->Texture.FixedFuncUnit[u].TexGenEnabled = save->TexGenEnabled[u];
          }
       }
 
index 15d6d54..390a54f 100644 (file)
@@ -388,7 +388,8 @@ static void
 emit_texblend(struct i830_context *i830, GLuint unit, GLuint blendUnit,
               bool last_stage)
 {
-   struct gl_texture_unit *texUnit = &i830->intel.ctx.Texture.Unit[unit];
+   struct gl_fixedfunc_texture_unit *texUnit =
+      &i830->intel.ctx.Texture.FixedFuncUnit[unit];
    GLuint tmp[I830_TEXBLEND_SIZE], tmp_sz;
 
 
index 8087445..088a256 100644 (file)
@@ -193,7 +193,7 @@ is_texture_source(int s)
 }
 
 static inline struct gl_texgen *
-get_texgen_coord(struct gl_texture_unit *u, int i)
+get_texgen_coord(struct gl_fixedfunc_texture_unit *u, int i)
 {
        return ((struct gl_texgen *[])
                { &u->GenS, &u->GenT, &u->GenR, &u->GenQ }) [i];
index 4dbb950..324595e 100644 (file)
 #include "nv04_driver.h"
 
 static GLboolean
-texunit_needs_combiners(struct gl_texture_unit *u)
+texunit_needs_combiners(struct gl_texture_unit *u,
+                        struct gl_fixedfunc_texture_unit *f)
 {
        struct gl_texture_object *t = u->_Current;
        struct gl_texture_image *ti = t->Image[0][t->BaseLevel];
 
        return ti->TexFormat == MESA_FORMAT_A_UNORM8 ||
                ti->TexFormat == MESA_FORMAT_L_UNORM8 ||
-               u->EnvMode == GL_COMBINE ||
-               u->EnvMode == GL_COMBINE4_NV ||
-               u->EnvMode == GL_BLEND ||
-               u->EnvMode == GL_ADD;
+               f->EnvMode == GL_COMBINE ||
+               f->EnvMode == GL_COMBINE4_NV ||
+               f->EnvMode == GL_BLEND ||
+               f->EnvMode == GL_ADD;
 }
 
 struct nouveau_object *
@@ -54,7 +55,8 @@ nv04_context_engine(struct gl_context *ctx)
        struct nouveau_object *fahrenheit;
 
        if ((ctx->Texture.Unit[0]._Current &&
-            texunit_needs_combiners(&ctx->Texture.Unit[0])) ||
+            texunit_needs_combiners(&ctx->Texture.Unit[0],
+                                     &ctx->Texture.FixedFuncUnit[0])) ||
            ctx->Texture.Unit[1]._Current ||
            ctx->Stencil.Enabled ||
            GET_COLORMASK(ctx->Color.ColorMask, 0) != 0xf)
index bfe8eae..26e2e91 100644 (file)
@@ -64,7 +64,7 @@ struct combiner_state {
  * context. */
 #define INIT_COMBINER(chan, ctx, rc, i) do {                   \
                struct gl_tex_env_combine_state *c =            \
-                       ctx->Texture.Unit[i]._CurrentCombine;   \
+                       ctx->Texture.FixedFuncUnit[i]._CurrentCombine;  \
                (rc)->ctx = ctx;                                \
                (rc)->unit = i;                                 \
                (rc)->alpha = __INIT_COMBINER_ALPHA_##chan;     \
@@ -287,7 +287,7 @@ nv04_emit_tex_env(struct gl_context *ctx, int emit)
        /* calculate non-multitex state */
        nv04->blend &= ~NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP__MASK;
        if (ctx->Texture._MaxEnabledTexImageUnit != -1)
-               nv04->blend |= get_texenv_mode(ctx->Texture.Unit[0].EnvMode);
+               nv04->blend |= get_texenv_mode(ctx->Texture.FixedFuncUnit[0].EnvMode);
        else
                nv04->blend |= get_texenv_mode(GL_MODULATE);
 
@@ -295,5 +295,5 @@ nv04_emit_tex_env(struct gl_context *ctx, int emit)
        nv04->alpha[i] = rc_a.hw;
        nv04->color[i] = rc_c.hw;
        nv04->factor   = pack_rgba_f(MESA_FORMAT_B8G8R8A8_UNORM,
-                                    ctx->Texture.Unit[0].EnvColor);
+                                    ctx->Texture.FixedFuncUnit[0].EnvColor);
 }
index 42dff08..27400d3 100644 (file)
@@ -80,7 +80,7 @@ struct combiner_state {
  * context. */
 #define INIT_COMBINER(chan, ctx, rc, i) do {                   \
                struct gl_tex_env_combine_state *c =            \
-                       ctx->Texture.Unit[i]._CurrentCombine;   \
+                       ctx->Texture.FixedFuncUnit[i]._CurrentCombine;  \
                (rc)->ctx = ctx;                                \
                (rc)->unit = i;                                 \
                (rc)->premodulate = c->_NumArgs##chan == 4;     \
@@ -332,7 +332,7 @@ nv10_get_general_combiner(struct gl_context *ctx, int i,
        }
 
        *k = pack_rgba_f(MESA_FORMAT_B8G8R8A8_UNORM,
-                        ctx->Texture.Unit[i].EnvColor);
+                        ctx->Texture.FixedFuncUnit[i].EnvColor);
        *a_in = rc_a.in;
        *a_out = rc_a.out;
        *c_in = rc_c.in;
index d85adfa..d741d41 100644 (file)
@@ -39,7 +39,8 @@ nv10_emit_tex_gen(struct gl_context *ctx, int emit)
        const int i = emit - NOUVEAU_STATE_TEX_GEN0;
        struct nouveau_context *nctx = to_nouveau_context(ctx);
        struct nouveau_pushbuf *push = context_push(ctx);
-       struct gl_texture_unit *unit = &ctx->Texture.Unit[i];
+       struct gl_fixedfunc_texture_unit *unit =
+           &ctx->Texture.FixedFuncUnit[i];
        int j;
 
        for (j = 0; j < 4; j++) {
@@ -73,7 +74,7 @@ nv10_emit_tex_mat(struct gl_context *ctx, int emit)
 
        if (nctx->fallback == HWTNL &&
            ((ctx->Texture._TexMatEnabled & 1 << i) ||
-            ctx->Texture.Unit[i]._GenFlags)) {
+            ctx->Texture.FixedFuncUnit[i]._GenFlags)) {
                BEGIN_NV04(push, NV10_3D(TEX_MATRIX_ENABLE(i)), 1);
                PUSH_DATA (push, 1);
 
index 72df814..9960ae0 100644 (file)
@@ -39,7 +39,8 @@ nv20_emit_tex_gen(struct gl_context *ctx, int emit)
        const int i = emit - NOUVEAU_STATE_TEX_GEN0;
        struct nouveau_context *nctx = to_nouveau_context(ctx);
        struct nouveau_pushbuf *push = context_push(ctx);
-       struct gl_texture_unit *unit = &ctx->Texture.Unit[i];
+       struct gl_fixedfunc_texture_unit *unit =
+           &ctx->Texture.FixedFuncUnit[i];
        int j;
 
        for (j = 0; j < 4; j++) {
index 0696c0d..1b217b9 100644 (file)
@@ -297,7 +297,8 @@ static void r200TexEnv( struct gl_context *ctx, GLenum target,
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLuint unit = ctx->Texture.CurrentUnit;
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   struct gl_fixedfunc_texture_unit *texUnit =
+      &ctx->Texture.FixedFuncUnit[unit];
 
    radeon_print(RADEON_TEXTURE | RADEON_STATE, RADEON_VERBOSE, "%s( %s )\n",
               __func__, _mesa_enum_to_string( pname ) );
index dcf211f..60a2007 100644 (file)
@@ -217,7 +217,9 @@ do {                                                        \
 static GLboolean r200UpdateTextureEnv( struct gl_context *ctx, int unit, int slot, GLuint replaceargs )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   const struct gl_texture_unit *rtexUnit = &ctx->Texture.Unit[unit];
+   const struct gl_fixedfunc_texture_unit *texUnit =
+      &ctx->Texture.FixedFuncUnit[unit];
    GLuint color_combine, alpha_combine;
    GLuint color_scale = rmesa->hw.pix[slot].cmd[PIX_PP_TXCBLEND2] &
       ~(R200_TXC_SCALE_MASK | R200_TXC_OUTPUT_REG_MASK | R200_TXC_TFACTOR_SEL_MASK |
@@ -244,7 +246,7 @@ static GLboolean r200UpdateTextureEnv( struct gl_context *ctx, int unit, int slo
                        (unit << R200_TXA_TFACTOR_SEL_SHIFT) |
                        (replaceargs << R200_TXA_TFACTOR1_SEL_SHIFT);
 
-   if ( !texUnit->_Current ) {
+   if ( !rtexUnit->_Current ) {
       assert( unit == 0);
       color_combine = R200_TXC_ARG_A_ZERO | R200_TXC_ARG_B_ZERO
          | R200_TXC_ARG_C_DIFFUSE_COLOR | R200_TXC_OP_MADD;
@@ -261,9 +263,9 @@ static GLboolean r200UpdateTextureEnv( struct gl_context *ctx, int unit, int slo
 
 
       const GLint replaceoprgb =
-        ctx->Texture.Unit[replaceargs]._CurrentCombine->OperandRGB[0] - GL_SRC_COLOR;
+        ctx->Texture.FixedFuncUnit[replaceargs]._CurrentCombine->OperandRGB[0] - GL_SRC_COLOR;
       const GLint replaceopa =
-        ctx->Texture.Unit[replaceargs]._CurrentCombine->OperandA[0] - GL_SRC_ALPHA;
+        ctx->Texture.FixedFuncUnit[replaceargs]._CurrentCombine->OperandA[0] - GL_SRC_ALPHA;
 
       /* Step 1:
        * Extract the color and alpha combine function arguments.
@@ -286,7 +288,7 @@ static GLboolean r200UpdateTextureEnv( struct gl_context *ctx, int unit, int slo
         case GL_PREVIOUS:
            if (replaceargs != unit) {
               const GLint srcRGBreplace =
-                 ctx->Texture.Unit[replaceargs]._CurrentCombine->SourceRGB[0];
+                 ctx->Texture.FixedFuncUnit[replaceargs]._CurrentCombine->SourceRGB[0];
               if (op >= 2) {
                  op = op ^ replaceopa;
               }
@@ -373,7 +375,7 @@ static GLboolean r200UpdateTextureEnv( struct gl_context *ctx, int unit, int slo
         case GL_PREVIOUS:
            if (replaceargs != unit) {
               const GLint srcAreplace =
-                 ctx->Texture.Unit[replaceargs]._CurrentCombine->SourceA[0];
+                 ctx->Texture.FixedFuncUnit[replaceargs]._CurrentCombine->SourceA[0];
               op = op ^ replaceopa;
               switch (srcAreplace) {
               case GL_TEXTURE:
@@ -771,7 +773,9 @@ static GLboolean r200UpdateAllTexEnv( struct gl_context *ctx )
    stageref[maxunitused + 1] = REF_COLOR | REF_ALPHA;
 
    for ( j = maxunitused; j >= 0; j-- ) {
-      const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[j];
+      const struct gl_texture_unit *rtexUnit = &ctx->Texture.Unit[j];
+      const struct gl_fixedfunc_texture_unit *texUnit =
+         &ctx->Texture.FixedFuncUnit[j];
 
       rmesa->state.texture.unit[j].outputreg = -1;
 
@@ -793,7 +797,7 @@ static GLboolean r200UpdateAllTexEnv( struct gl_context *ctx )
 
          nextunit[j] = currentnext;
 
-         if (!texUnit->_Current) {
+         if (!rtexUnit->_Current) {
         /* the not enabled stages are referenced "indirectly",
             must not cut off the lower stages */
            stageref[j] = REF_COLOR | REF_ALPHA;
@@ -880,10 +884,10 @@ static GLboolean r200UpdateAllTexEnv( struct gl_context *ctx )
       if (ctx->Texture.Unit[i]._Current && stageref[i+1]) {
          GLuint replaceunit = i;
         /* try to optimize GL_REPLACE away (only one level deep though) */
-        if (   (ctx->Texture.Unit[i]._CurrentCombine->ModeRGB == GL_REPLACE) &&
-               (ctx->Texture.Unit[i]._CurrentCombine->ModeA == GL_REPLACE) &&
-               (ctx->Texture.Unit[i]._CurrentCombine->ScaleShiftRGB == 0) &&
-               (ctx->Texture.Unit[i]._CurrentCombine->ScaleShiftA == 0) &&
+        if (   (ctx->Texture.FixedFuncUnit[i]._CurrentCombine->ModeRGB == GL_REPLACE) &&
+               (ctx->Texture.FixedFuncUnit[i]._CurrentCombine->ModeA == GL_REPLACE) &&
+               (ctx->Texture.FixedFuncUnit[i]._CurrentCombine->ScaleShiftRGB == 0) &&
+               (ctx->Texture.FixedFuncUnit[i]._CurrentCombine->ScaleShiftA == 0) &&
                (nextunit[i] > 0) ) {
            /* yippie! can optimize it away! */
            replaceunit = i;
@@ -1086,7 +1090,8 @@ static GLuint r200_need_dis_texgen(const GLbitfield texGenEnabled,
 static GLboolean r200_validate_texgen( struct gl_context *ctx, GLuint unit )
 {  
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   const struct gl_fixedfunc_texture_unit *texUnit =
+      &ctx->Texture.FixedFuncUnit[unit];
    GLuint inputshift = R200_TEXGEN_0_INPUT_SHIFT + unit*4;
    GLuint tgi, tgcm;
    GLuint mode = 0;
index 9a77850..c9c91f8 100644 (file)
@@ -352,7 +352,7 @@ void radeonEmitArrays( struct gl_context *ctx, GLuint inputs )
            req |= RADEON_Q_BIT(unit);
            vtx |= RADEON_Q_BIT(unit);
         }
-        if ( (ctx->Texture.Unit[unit].TexGenEnabled & (R_BIT | Q_BIT)) )
+        if ( (ctx->Texture.FixedFuncUnit[unit].TexGenEnabled & (R_BIT | Q_BIT)) )
            vtx |= RADEON_Q_BIT(unit);
         else if ((VB->AttribPtr[_TNL_ATTRIB_TEX0 + unit]->size >= 3) &&
                  (!ctx->Texture.Unit[unit]._Current ||
index e413df3..58d8fc5 100644 (file)
@@ -1890,7 +1890,7 @@ static void update_texturematrix( struct gl_context *ctx )
         if (needMatrix) {
            rmesa->NeedTexMatrix |= 1 << unit;
            radeonUploadTexMatrix( rmesa, unit,
-                       !ctx->Texture.Unit[unit].TexGenEnabled );
+                       !ctx->Texture.FixedFuncUnit[unit].TexGenEnabled );
         }
       }
    }
index b4964f1..da5d469 100644 (file)
@@ -257,7 +257,8 @@ static void radeonTexEnv( struct gl_context *ctx, GLenum target,
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint unit = ctx->Texture.CurrentUnit;
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   struct gl_fixedfunc_texture_unit *texUnit =
+      &ctx->Texture.FixedFuncUnit[unit];
 
    if ( RADEON_DEBUG & RADEON_STATE ) {
       fprintf( stderr, "%s( %s )\n",
index 5cabba1..47eac85 100644 (file)
@@ -208,7 +208,9 @@ texture_base_format(const struct gl_texture_object *t)
 static GLboolean radeonUpdateTextureEnv( struct gl_context *ctx, int unit )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
-   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   const struct gl_texture_unit *rtexUnit = &ctx->Texture.Unit[unit];
+   const struct gl_fixedfunc_texture_unit *texUnit =
+      &ctx->Texture.FixedFuncUnit[unit];
    GLuint color_combine, alpha_combine;
    const GLuint color_combine0 = RADEON_COLOR_ARG_A_ZERO | RADEON_COLOR_ARG_B_ZERO
          | RADEON_COLOR_ARG_C_CURRENT_COLOR | RADEON_BLEND_CTL_ADD
@@ -234,7 +236,7 @@ static GLboolean radeonUpdateTextureEnv( struct gl_context *ctx, int unit )
    rmesa->state.texture.unit[unit].format = 0;
    rmesa->state.texture.unit[unit].envMode = 0;
 
-   if ( !texUnit->_Current ) {
+   if ( !rtexUnit->_Current ) {
       color_combine = color_combine0;
       alpha_combine = alpha_combine0;
    }
@@ -257,7 +259,7 @@ static GLboolean radeonUpdateTextureEnv( struct gl_context *ctx, int unit )
         assert(op <= 3);
         switch ( srcRGBi ) {
         case GL_TEXTURE:
-           if (texture_base_format(texUnit->_Current) == GL_ALPHA)
+           if (texture_base_format(rtexUnit->_Current) == GL_ALPHA)
               color_arg[i] = radeon_zero_color[op];
            else
               color_arg[i] = radeon_texture_color[op][unit];
@@ -302,7 +304,7 @@ static GLboolean radeonUpdateTextureEnv( struct gl_context *ctx, int unit )
         assert(op <= 1);
         switch ( srcAi ) {
         case GL_TEXTURE:
-           if (texture_base_format(texUnit->_Current) == GL_LUMINANCE)
+           if (texture_base_format(rtexUnit->_Current) == GL_LUMINANCE)
               alpha_arg[i] = radeon_zero_alpha[op+1];
            else
               alpha_arg[i] = radeon_texture_alpha[op][unit];
@@ -798,7 +800,8 @@ static void set_texgen_matrix( r100ContextPtr rmesa,
 static GLboolean radeon_validate_texgen( struct gl_context *ctx, GLuint unit )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   struct gl_fixedfunc_texture_unit *texUnit =
+      &ctx->Texture.FixedFuncUnit[unit];
    GLuint inputshift = RADEON_TEXGEN_0_INPUT_SHIFT + unit*4;
    GLuint tmp = rmesa->TexGenEnabled;
    static const GLfloat reflect[16] = {
index 8ac5db0..398ff65 100644 (file)
@@ -374,8 +374,8 @@ _mesa_PushAttrib(GLbitfield mask)
       attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne;
       attr->SampleCoverage = ctx->Multisample.SampleCoverage;
       for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-         attr->Texture[i] = ctx->Texture.Unit[i].Enabled;
-         attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled;
+         attr->Texture[i] = ctx->Texture.FixedFuncUnit[i].Enabled;
+         attr->TexGen[i] = ctx->Texture.FixedFuncUnit[i].TexGenEnabled;
       }
       /* GL_ARB_vertex_program */
       attr->VertexProgram = ctx->VertexProgram.Enabled;
@@ -718,7 +718,7 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
       const GLbitfield enabled = enable->Texture[i];
       const GLbitfield genEnabled = enable->TexGen[i];
 
-      if (ctx->Texture.Unit[i].Enabled != enabled) {
+      if (ctx->Texture.FixedFuncUnit[i].Enabled != enabled) {
          _mesa_ActiveTexture(GL_TEXTURE0 + i);
 
          _mesa_set_enable(ctx, GL_TEXTURE_1D, !!(enabled & TEXTURE_1D_BIT));
@@ -734,7 +734,7 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
          }
       }
 
-      if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) {
+      if (ctx->Texture.FixedFuncUnit[i].TexGenEnabled != genEnabled) {
          _mesa_ActiveTexture(GL_TEXTURE0 + i);
          _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, !!(genEnabled & S_BIT));
          _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, !!(genEnabled & T_BIT));
@@ -758,7 +758,8 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
    _mesa_lock_context_textures(ctx);
 
    for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-      const struct gl_texture_unit *unit = &texstate->Texture.Unit[u];
+      const struct gl_fixedfunc_texture_unit *unit =
+         &texstate->Texture.FixedFuncUnit[u];
       GLuint tgt;
 
       _mesa_ActiveTexture(GL_TEXTURE0_ARB + u);
@@ -785,7 +786,9 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
       _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane);
       /* Eye plane done differently to avoid re-transformation */
       {
-         struct gl_texture_unit *destUnit = &ctx->Texture.Unit[u];
+         struct gl_fixedfunc_texture_unit *destUnit =
+            &ctx->Texture.FixedFuncUnit[u];
+
          COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane);
          COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane);
          COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane);
@@ -802,7 +805,7 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
       _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, !!(unit->TexGenEnabled & R_BIT));
       _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, !!(unit->TexGenEnabled & Q_BIT));
       _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS,
-                    unit->LodBias);
+                   texstate->Texture.Unit[u].LodBias);
       _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB,
                     unit->Combine.ModeRGB);
       _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,
index 7dbf678..79d3e39 100644 (file)
@@ -1264,8 +1264,10 @@ _mesa_initialize_context(struct gl_context *ctx,
        * GL_OES_texture_cube_map says
        * "Initially all texture generation modes are set to REFLECTION_MAP_OES"
        */
-      for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
-         struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+      for (i = 0; i < ARRAY_SIZE(ctx->Texture.FixedFuncUnit); i++) {
+         struct gl_fixedfunc_texture_unit *texUnit =
+            &ctx->Texture.FixedFuncUnit[i];
+
          texUnit->GenS.Mode = GL_REFLECTION_MAP_NV;
          texUnit->GenT.Mode = GL_REFLECTION_MAP_NV;
          texUnit->GenR.Mode = GL_REFLECTION_MAP_NV;
index 967d230..4c5f9dc 100644 (file)
@@ -186,7 +186,7 @@ _mesa_DisableClientState( GLenum cap )
  * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
  * texture unit is higher than the number of supported coordinate units.
  */
-static struct gl_texture_unit *
+static struct gl_fixedfunc_texture_unit *
 get_texcoord_unit(struct gl_context *ctx)
 {
    if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
@@ -194,7 +194,7 @@ get_texcoord_unit(struct gl_context *ctx)
       return NULL;
    }
    else {
-      return &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+      return &ctx->Texture.FixedFuncUnit[ctx->Texture.CurrentUnit];
    }
 }
 
@@ -207,7 +207,9 @@ get_texcoord_unit(struct gl_context *ctx)
 static GLboolean
 enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit)
 {
-   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+   struct gl_fixedfunc_texture_unit *texUnit =
+      _mesa_get_current_fixedfunc_tex_unit(ctx);
+
    const GLbitfield newenabled = state
       ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit);
 
@@ -748,7 +750,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
       case GL_TEXTURE_GEN_R:
       case GL_TEXTURE_GEN_Q:
          {
-            struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+            struct gl_fixedfunc_texture_unit *texUnit = get_texcoord_unit(ctx);
 
             if (ctx->API != API_OPENGL_COMPAT)
                goto invalid_enum_error;
@@ -769,7 +771,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
       case GL_TEXTURE_GEN_STR_OES:
          /* disable S, T, and R at the same time */
          {
-            struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+            struct gl_fixedfunc_texture_unit *texUnit = get_texcoord_unit(ctx);
 
             if (ctx->API != API_OPENGLES)
                goto invalid_enum_error;
@@ -1288,8 +1290,9 @@ _mesa_IsEnabledi( GLenum cap, GLuint index )
 static GLboolean
 is_texture_enabled(struct gl_context *ctx, GLbitfield bit)
 {
-   const struct gl_texture_unit *const texUnit =
-       &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   const struct gl_fixedfunc_texture_unit *const texUnit =
+      _mesa_get_current_fixedfunc_tex_unit(ctx);
+
    return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE;
 }
 
@@ -1506,7 +1509,8 @@ _mesa_IsEnabled( GLenum cap )
       case GL_TEXTURE_GEN_R:
       case GL_TEXTURE_GEN_Q:
          {
-            const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+            const struct gl_fixedfunc_texture_unit *texUnit =
+               get_texcoord_unit(ctx);
 
             if (ctx->API != API_OPENGL_COMPAT)
                goto invalid_enum_error;
@@ -1519,7 +1523,8 @@ _mesa_IsEnabled( GLenum cap )
          return GL_FALSE;
       case GL_TEXTURE_GEN_STR_OES:
          {
-            const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+            const struct gl_fixedfunc_texture_unit *texUnit =
+               get_texcoord_unit(ctx);
 
             if (ctx->API != API_OPENGLES)
                goto invalid_enum_error;
index 2be3ae3..a698931 100644 (file)
@@ -268,7 +268,8 @@ static GLuint make_state_key( struct gl_context *ctx,  struct state_key *key )
       i = u_bit_scan(&mask);
       const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
       const struct gl_texture_object *texObj = texUnit->_Current;
-      const struct gl_tex_env_combine_packed *comb = &texUnit->_CurrentCombinePacked;
+      const struct gl_tex_env_combine_packed *comb =
+         &ctx->Texture.FixedFuncUnit[i]._CurrentCombinePacked;
 
       if (!texObj)
          continue;
index 6a022b8..976b6f4 100644 (file)
@@ -235,7 +235,8 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
       | ctx->Texture._TexMatEnabled | ctx->Point.CoordReplace;
    while (mask) {
       const int i = u_bit_scan(&mask);
-      struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+      struct gl_fixedfunc_texture_unit *texUnit =
+         &ctx->Texture.FixedFuncUnit[i];
 
       if (ctx->Point.PointSprite)
         if (ctx->Point.CoordReplace & (1u << i))
index 516e8d1..2188017 100644 (file)
@@ -1390,7 +1390,6 @@ static const struct value_desc *
 find_value(const char *func, GLenum pname, void **p, union value *v)
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_texture_unit *unit;
    int mask, hash;
    const struct value_desc *d;
    int api;
@@ -1445,8 +1444,10 @@ find_value(const char *func, GLenum pname, void **p, union value *v)
       *p = ((char *) ctx->Array.VAO + d->offset);
       return d;
    case LOC_TEXUNIT:
-      unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-      *p = ((char *) unit + d->offset);
+      if (ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->Texture.FixedFuncUnit)) {
+         unsigned index = ctx->Texture.CurrentUnit;
+         *p = ((char *)&ctx->Texture.FixedFuncUnit[index] + d->offset);
+      }
       return d;
    case LOC_CUSTOM:
       find_custom_value(ctx, d, v);
index df082af..e127b6b 100644 (file)
@@ -234,7 +234,7 @@ descriptor=[
 # GL_ARB_texture_cube_map
   [ "TEXTURE_CUBE_MAP_ARB", "LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA" ],
 # S, T, and R are always set at the same time
-  [ "TEXTURE_GEN_STR_OES", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
+  [ "TEXTURE_GEN_STR_OES", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
 
 # GL_ARB_multisample
   [ "MULTISAMPLE_ARB", "CONTEXT_BOOL(Multisample.Enabled), NO_EXTRA" ],
@@ -760,10 +760,10 @@ descriptor=[
   [ "TEXTURE_3D", "LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA" ],
   [ "TEXTURE_BINDING_1D", "LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA" ],
   [ "TEXTURE_BINDING_1D_ARRAY", "LOC_CUSTOM, TYPE_INT, TEXTURE_1D_ARRAY_INDEX, extra_EXT_texture_array" ],
-  [ "TEXTURE_GEN_S", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
-  [ "TEXTURE_GEN_T", "LOC_TEXUNIT, TYPE_BIT_1, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
-  [ "TEXTURE_GEN_R", "LOC_TEXUNIT, TYPE_BIT_2, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
-  [ "TEXTURE_GEN_Q", "LOC_TEXUNIT, TYPE_BIT_3, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
+  [ "TEXTURE_GEN_S", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
+  [ "TEXTURE_GEN_T", "LOC_TEXUNIT, TYPE_BIT_1, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
+  [ "TEXTURE_GEN_R", "LOC_TEXUNIT, TYPE_BIT_2, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
+  [ "TEXTURE_GEN_Q", "LOC_TEXUNIT, TYPE_BIT_3, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
   [ "UNPACK_LSB_FIRST", "CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA" ],
   [ "UNPACK_SWAP_BYTES", "CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA" ],
   [ "ZOOM_X", "CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA" ],
index 46137f5..562fb17 100644 (file)
@@ -1275,11 +1275,32 @@ struct gl_texgen
 
 
 /**
- * Texture unit state.  Contains enable flags, texture environment/function/
- * combiners, texgen state, and pointers to current texture objects.
+ * Sampler-related subset of a texture unit, like current texture objects.
  */
 struct gl_texture_unit
 {
+   GLfloat LodBias;            /**< for biasing mipmap levels */
+
+   /** Texture targets that have a non-default texture bound */
+   GLbitfield _BoundTextures;
+
+   /** Current sampler object (GL_ARB_sampler_objects) */
+   struct gl_sampler_object *Sampler;
+
+   /** Current texture object pointers */
+   struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
+
+   /** Points to highest priority, complete and enabled texture object */
+   struct gl_texture_object *_Current;
+};
+
+
+/**
+ * Fixed-function-related subset of a texture unit, like enable flags,
+ * texture environment/function/combiners, and texgen state.
+ */
+struct gl_fixedfunc_texture_unit
+{
    GLbitfield Enabled;          /**< bitmask of TEXTURE_*_BIT flags */
 
    GLenum16 EnvMode;            /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
@@ -1293,14 +1314,6 @@ struct gl_texture_unit
    GLbitfield TexGenEnabled;   /**< Bitwise-OR of [STRQ]_BIT values */
    GLbitfield _GenFlags;       /**< Bitwise-OR of Gen[STRQ]._ModeBit */
 
-   GLfloat LodBias;            /**< for biasing mipmap levels */
-
-   /** Texture targets that have a non-default texture bound */
-   GLbitfield _BoundTextures;
-
-   /** Current sampler object (GL_ARB_sampler_objects) */
-   struct gl_sampler_object *Sampler;
-
    /**
     * \name GL_EXT_texture_env_combine
     */
@@ -1318,12 +1331,6 @@ struct gl_texture_unit
     */
    struct gl_tex_env_combine_state *_CurrentCombine;
 
-   /** Current texture object pointers */
-   struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
-
-   /** Points to highest priority, complete and enabled texture object */
-   struct gl_texture_object *_Current;
-
    /** Current compressed TexEnv & Combine state */
    struct gl_tex_env_combine_packed _CurrentCombinePacked;
 };
@@ -1363,6 +1370,7 @@ struct gl_texture_attrib
    GLint NumCurrentTexUsed;
 
    struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
+   struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
 };
 
 
index 43f6759..dd1042f 100644 (file)
@@ -266,7 +266,8 @@ static void
 compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye[4],
                const GLfloat normal[3], GLuint unit, GLfloat texcoord[4])
 {
-   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   const struct gl_fixedfunc_texture_unit *texUnit =
+      &ctx->Texture.FixedFuncUnit[unit];
 
    /* always compute sphere map terms, just in case */
    GLfloat u[3], two_nu, rx, ry, rz, m, mInv;
@@ -464,7 +465,7 @@ _mesa_RasterPos(struct gl_context *ctx, const GLfloat vObj[4])
          for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
             GLfloat tc[4];
             COPY_4V(tc, ctx->Current.Attrib[VERT_ATTRIB_TEX0 + u]);
-            if (ctx->Texture.Unit[u].TexGenEnabled) {
+            if (ctx->Texture.FixedFuncUnit[u].TexGenEnabled) {
                compute_texgen(ctx, vObj, eye, norm, u, tc);
             }
             TRANSFORM_POINT(ctx->Current.RasterTexCoords[u],
index 2fcaf7c..9018ce9 100644 (file)
@@ -48,7 +48,7 @@
 /** Set texture env mode */
 static void
 set_env_mode(struct gl_context *ctx,
-             struct gl_texture_unit *texUnit,
+             struct gl_fixedfunc_texture_unit *texUnit,
              GLenum mode)
 {
    GLboolean legal;
@@ -88,7 +88,7 @@ set_env_mode(struct gl_context *ctx,
 
 static void
 set_env_color(struct gl_context *ctx,
-              struct gl_texture_unit *texUnit,
+              struct gl_fixedfunc_texture_unit *texUnit,
               const GLfloat *color)
 {
    if (TEST_EQ_4V(color, texUnit->EnvColorUnclamped))
@@ -105,7 +105,7 @@ set_env_color(struct gl_context *ctx,
 /** Set an RGB or A combiner mode/function */
 static void
 set_combiner_mode(struct gl_context *ctx,
-                  struct gl_texture_unit *texUnit,
+                  struct gl_fixedfunc_texture_unit *texUnit,
                   GLenum pname, GLenum mode)
 {
    GLboolean legal;
@@ -171,7 +171,7 @@ set_combiner_mode(struct gl_context *ctx,
 /** Set an RGB or A combiner source term */
 static void
 set_combiner_source(struct gl_context *ctx,
-                    struct gl_texture_unit *texUnit,
+                    struct gl_fixedfunc_texture_unit *texUnit,
                     GLenum pname, GLenum param)
 {
    GLuint term;
@@ -261,7 +261,7 @@ set_combiner_source(struct gl_context *ctx,
 /** Set an RGB or A combiner operand term */
 static void
 set_combiner_operand(struct gl_context *ctx,
-                     struct gl_texture_unit *texUnit,
+                     struct gl_fixedfunc_texture_unit *texUnit,
                      GLenum pname, GLenum param)
 {
    GLuint term;
@@ -342,7 +342,7 @@ set_combiner_operand(struct gl_context *ctx,
 
 static void
 set_combiner_scale(struct gl_context *ctx,
-                   struct gl_texture_unit *texUnit,
+                   struct gl_fixedfunc_texture_unit *texUnit,
                    GLenum pname, GLfloat scale)
 {
    GLuint shift;
@@ -386,7 +386,6 @@ void GLAPIENTRY
 _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
 {
    const GLint iparam0 = (GLint) param[0];
-   struct gl_texture_unit *texUnit;
    GLuint maxUnit;
    GET_CURRENT_CONTEXT(ctx);
 
@@ -397,9 +396,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-
    if (target == GL_TEXTURE_ENV) {
+      struct gl_fixedfunc_texture_unit *texUnit =
+         _mesa_get_current_fixedfunc_tex_unit(ctx);
+
       switch (pname) {
       case GL_TEXTURE_ENV_MODE:
          set_env_mode(ctx, texUnit, (GLenum) iparam0);
@@ -441,6 +441,9 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
       }
    }
    else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
+      struct gl_texture_unit *texUnit =
+         _mesa_get_current_tex_unit(ctx);
+
       if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
         if (texUnit->LodBias == param[0])
            return;
@@ -547,7 +550,8 @@ _mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param )
  * \return  value of queried pname or -1 if error.
  */
 static GLint
-get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit,
+get_texenvi(struct gl_context *ctx,
+            const struct gl_fixedfunc_texture_unit *texUnit,
             GLenum pname)
 {
    switch (pname) {
@@ -632,7 +636,6 @@ void GLAPIENTRY
 _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
 {
    GLuint maxUnit;
-   const struct gl_texture_unit *texUnit;
    GET_CURRENT_CONTEXT(ctx);
 
    maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
@@ -642,9 +645,10 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-
    if (target == GL_TEXTURE_ENV) {
+      struct gl_fixedfunc_texture_unit *texUnit =
+         _mesa_get_current_fixedfunc_tex_unit(ctx);
+
       if (pname == GL_TEXTURE_ENV_COLOR) {
          if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
             _mesa_update_state(ctx);
@@ -661,6 +665,8 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
       }
    }
    else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
+      const struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+
       if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
          *params = texUnit->LodBias;
       }
@@ -698,7 +704,6 @@ void GLAPIENTRY
 _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
 {
    GLuint maxUnit;
-   const struct gl_texture_unit *texUnit;
    GET_CURRENT_CONTEXT(ctx);
 
    maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
@@ -708,9 +713,10 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
-
    if (target == GL_TEXTURE_ENV) {
+      struct gl_fixedfunc_texture_unit *texUnit =
+         _mesa_get_current_fixedfunc_tex_unit(ctx);
+
       if (pname == GL_TEXTURE_ENV_COLOR) {
          params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] );
          params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
@@ -725,6 +731,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
       }
    }
    else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
+      const struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+
       if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
          *params = (GLint) texUnit->LodBias;
       }
index 1b8d187..45f86fd 100644 (file)
@@ -44,7 +44,7 @@
  * Return texgen state for given coordinate
  */
 static struct gl_texgen *
-get_texgen(struct gl_context *ctx, struct gl_texture_unit *texUnit,
+get_texgen(struct gl_context *ctx, struct gl_fixedfunc_texture_unit *texUnit,
            GLenum coord)
 {
    if (ctx->API == API_OPENGLES) {
@@ -70,7 +70,7 @@ get_texgen(struct gl_context *ctx, struct gl_texture_unit *texUnit,
 void GLAPIENTRY
 _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
 {
-   struct gl_texture_unit *texUnit;
+   struct gl_fixedfunc_texture_unit *texUnit;
    struct gl_texgen *texgen;
    GET_CURRENT_CONTEXT(ctx);
 
@@ -86,7 +86,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
+   texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
 
    texgen = get_texgen(ctx, texUnit, coord);
    if (!texgen) {
@@ -289,7 +289,7 @@ _mesa_TexGeni( GLenum coord, GLenum pname, GLint param )
 void GLAPIENTRY
 _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
 {
-   struct gl_texture_unit *texUnit;
+   struct gl_fixedfunc_texture_unit *texUnit;
    struct gl_texgen *texgen;
    GET_CURRENT_CONTEXT(ctx);
 
@@ -298,7 +298,7 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
+   texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
 
    texgen = get_texgen(ctx, texUnit, coord);
    if (!texgen) {
@@ -326,7 +326,7 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
 void GLAPIENTRY
 _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
 {
-   struct gl_texture_unit *texUnit;
+   struct gl_fixedfunc_texture_unit *texUnit;
    struct gl_texgen *texgen;
    GET_CURRENT_CONTEXT(ctx);
 
@@ -335,7 +335,7 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
+   texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
 
    texgen = get_texgen(ctx, texUnit, coord);
    if (!texgen) {
@@ -371,7 +371,7 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
 void GLAPIENTRY
 _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
 {
-   struct gl_texture_unit *texUnit;
+   struct gl_fixedfunc_texture_unit *texUnit;
    struct gl_texgen *texgen;
    GET_CURRENT_CONTEXT(ctx);
 
@@ -380,7 +380,7 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
       return;
    }
 
-   texUnit = _mesa_get_current_tex_unit(ctx);
+   texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
 
    texgen = get_texgen(ctx, texUnit, coord);
    if (!texgen) {
index e24b3c4..2b05630 100644 (file)
@@ -78,19 +78,8 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
 
    /* per-unit state */
    for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) {
-      dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled;
-      dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode;
-      COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor);
-      dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled;
-      dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS;
-      dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT;
-      dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR;
-      dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ;
       dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias;
 
-      /* GL_EXT_texture_env_combine */
-      dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine;
-
       /*
        * XXX strictly speaking, we should compare texture names/ids and
        * bind textures in the dest context according to id.  For now, only
@@ -113,6 +102,20 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
          _mesa_unlock_context_textures(dst);
       }
    }
+
+   for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) {
+      dst->Texture.FixedFuncUnit[u].Enabled = src->Texture.FixedFuncUnit[u].Enabled;
+      dst->Texture.FixedFuncUnit[u].EnvMode = src->Texture.FixedFuncUnit[u].EnvMode;
+      COPY_4V(dst->Texture.FixedFuncUnit[u].EnvColor, src->Texture.FixedFuncUnit[u].EnvColor);
+      dst->Texture.FixedFuncUnit[u].TexGenEnabled = src->Texture.FixedFuncUnit[u].TexGenEnabled;
+      dst->Texture.FixedFuncUnit[u].GenS = src->Texture.FixedFuncUnit[u].GenS;
+      dst->Texture.FixedFuncUnit[u].GenT = src->Texture.FixedFuncUnit[u].GenT;
+      dst->Texture.FixedFuncUnit[u].GenR = src->Texture.FixedFuncUnit[u].GenR;
+      dst->Texture.FixedFuncUnit[u].GenQ = src->Texture.FixedFuncUnit[u].GenQ;
+
+      /* GL_EXT_texture_env_combine */
+      dst->Texture.FixedFuncUnit[u].Combine = src->Texture.FixedFuncUnit[u].Combine;
+   }
 }
 
 
@@ -122,7 +125,7 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
 void
 _mesa_print_texunit_state( struct gl_context *ctx, GLuint unit )
 {
-   const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit;
+   const struct gl_fixedfunc_texture_unit *texUnit = ctx->Texture.FixedFuncUnit + unit;
    printf("Texture Unit %d\n", unit);
    printf("  GL_TEXTURE_ENV_MODE = %s\n", _mesa_enum_to_string(texUnit->EnvMode));
    printf("  GL_COMBINE_RGB = %s\n", _mesa_enum_to_string(texUnit->Combine.ModeRGB));
@@ -461,7 +464,7 @@ tex_combine_translate_operand(GLenum operand)
 
 
 static void
-pack_tex_combine(struct gl_texture_unit *texUnit)
+pack_tex_combine(struct gl_fixedfunc_texture_unit *texUnit)
 {
    struct gl_tex_env_combine_state *state = texUnit->_CurrentCombine;
    struct gl_tex_env_combine_packed *packed = &texUnit->_CurrentCombinePacked;
@@ -493,7 +496,9 @@ pack_tex_combine(struct gl_texture_unit *texUnit)
  * Examine texture unit's combine/env state to update derived state.
  */
 static void
-update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
+update_tex_combine(struct gl_context *ctx,
+                   struct gl_texture_unit *texUnit,
+                   struct gl_fixedfunc_texture_unit *fftexUnit)
 {
    struct gl_tex_env_combine_state *combine;
 
@@ -505,9 +510,9 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
     * state, or the combiner state which is derived from traditional texenv
     * mode.
     */
-   if (texUnit->EnvMode == GL_COMBINE ||
-       texUnit->EnvMode == GL_COMBINE4_NV) {
-      texUnit->_CurrentCombine = & texUnit->Combine;
+   if (fftexUnit->EnvMode == GL_COMBINE ||
+       fftexUnit->EnvMode == GL_COMBINE4_NV) {
+      fftexUnit->_CurrentCombine = & fftexUnit->Combine;
    }
    else {
       const struct gl_texture_object *texObj = texUnit->_Current;
@@ -516,11 +521,11 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
       if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
          format = texObj->DepthMode;
       }
-      calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format);
-      texUnit->_CurrentCombine = & texUnit->_EnvMode;
+      calculate_derived_texenv(&fftexUnit->_EnvMode, fftexUnit->EnvMode, format);
+      fftexUnit->_CurrentCombine = & fftexUnit->_EnvMode;
    }
 
-   combine = texUnit->_CurrentCombine;
+   combine = fftexUnit->_CurrentCombine;
 
    /* Determine number of source RGB terms in the combiner function */
    switch (combine->ModeRGB) {
@@ -529,7 +534,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
       break;
    case GL_ADD:
    case GL_ADD_SIGNED:
-      if (texUnit->EnvMode == GL_COMBINE4_NV)
+      if (fftexUnit->EnvMode == GL_COMBINE4_NV)
          combine->_NumArgsRGB = 4;
       else
          combine->_NumArgsRGB = 2;
@@ -561,7 +566,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
       break;
    case GL_ADD:
    case GL_ADD_SIGNED:
-      if (texUnit->EnvMode == GL_COMBINE4_NV)
+      if (fftexUnit->EnvMode == GL_COMBINE4_NV)
          combine->_NumArgsA = 4;
       else
          combine->_NumArgsA = 2;
@@ -582,7 +587,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
       break;
    }
 
-   pack_tex_combine(texUnit);
+   pack_tex_combine(fftexUnit);
 }
 
 static void
@@ -592,7 +597,8 @@ update_texgen(struct gl_context *ctx)
 
    /* Setup texgen for those texture coordinate sets that are in use */
    for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) {
-      struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+      struct gl_fixedfunc_texture_unit *texUnit =
+         &ctx->Texture.FixedFuncUnit[unit];
 
       texUnit->_GenFlags = 0x0;
 
@@ -748,10 +754,12 @@ update_ff_texture_state(struct gl_context *ctx,
 
    for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+      struct gl_fixedfunc_texture_unit *fftexUnit =
+         &ctx->Texture.FixedFuncUnit[unit];
       GLbitfield mask;
       bool complete;
 
-      if (texUnit->Enabled == 0x0)
+      if (fftexUnit->Enabled == 0x0)
          continue;
 
       /* If a shader already dictated what texture target was used for this
@@ -788,7 +796,7 @@ update_ff_texture_state(struct gl_context *ctx,
        *      undefined."
        */
       complete = false;
-      mask = texUnit->Enabled;
+      mask = fftexUnit->Enabled;
       while (mask) {
          const int texIndex = u_bit_scan(&mask);
          struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
@@ -815,7 +823,7 @@ update_ff_texture_state(struct gl_context *ctx,
 
       ctx->Texture._EnabledCoordUnits |= 1 << unit;
 
-      update_tex_combine(ctx, texUnit);
+      update_tex_combine(ctx, texUnit, fftexUnit);
    }
 }
 
@@ -998,6 +1006,19 @@ _mesa_init_texture(struct gl_context *ctx)
       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
       GLuint tex;
 
+      /* initialize current texture object ptrs to the shared default objects */
+      for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
+         _mesa_reference_texobj(&texUnit->CurrentTex[tex],
+                                ctx->Shared->DefaultTex[tex]);
+      }
+
+      texUnit->_BoundTextures = 0;
+   }
+
+   for (u = 0; u < ARRAY_SIZE(ctx->Texture.FixedFuncUnit); u++) {
+      struct gl_fixedfunc_texture_unit *texUnit =
+         &ctx->Texture.FixedFuncUnit[u];
+
       texUnit->EnvMode = GL_MODULATE;
       ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
 
@@ -1024,14 +1045,6 @@ _mesa_init_texture(struct gl_context *ctx)
       ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 );
       ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 );
       ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 );
-
-      /* initialize current texture object ptrs to the shared default objects */
-      for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
-         _mesa_reference_texobj(&texUnit->CurrentTex[tex],
-                                ctx->Shared->DefaultTex[tex]);
-      }
-
-      texUnit->_BoundTextures = 0;
    }
 
    /* After we're done initializing the context's texture state the default
index 4f515e4..cf3f7e5 100644 (file)
@@ -54,6 +54,21 @@ _mesa_get_current_tex_unit(struct gl_context *ctx)
    return _mesa_get_tex_unit(ctx, ctx->Texture.CurrentUnit);
 }
 
+
+/**
+ * Return pointer to current fixed-func texture unit.
+ * This the texture unit set by glActiveTexture(), not glClientActiveTexture().
+ * \return NULL if the current unit is not a fixed-func texture unit
+ */
+static inline struct gl_fixedfunc_texture_unit *
+_mesa_get_current_fixedfunc_tex_unit(struct gl_context *ctx)
+{
+   unsigned unit = ctx->Texture.CurrentUnit;
+
+   return &ctx->Texture.FixedFuncUnit[unit];
+}
+
+
 static inline GLuint
 _mesa_max_tex_unit(struct gl_context *ctx)
 {
index 481123a..78f7005 100644 (file)
@@ -215,28 +215,28 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
          /* state[2] is the texgen attribute */
          switch (state[2]) {
          case STATE_TEXGEN_EYE_S:
-            COPY_4V(value, ctx->Texture.Unit[unit].GenS.EyePlane);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenS.EyePlane);
             return;
          case STATE_TEXGEN_EYE_T:
-            COPY_4V(value, ctx->Texture.Unit[unit].GenT.EyePlane);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenT.EyePlane);
             return;
          case STATE_TEXGEN_EYE_R:
-            COPY_4V(value, ctx->Texture.Unit[unit].GenR.EyePlane);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenR.EyePlane);
             return;
          case STATE_TEXGEN_EYE_Q:
-            COPY_4V(value, ctx->Texture.Unit[unit].GenQ.EyePlane);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenQ.EyePlane);
             return;
          case STATE_TEXGEN_OBJECT_S:
-            COPY_4V(value, ctx->Texture.Unit[unit].GenS.ObjectPlane);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenS.ObjectPlane);
             return;
          case STATE_TEXGEN_OBJECT_T:
-            COPY_4V(value, ctx->Texture.Unit[unit].GenT.ObjectPlane);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenT.ObjectPlane);
             return;
          case STATE_TEXGEN_OBJECT_R:
-            COPY_4V(value, ctx->Texture.Unit[unit].GenR.ObjectPlane);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenR.ObjectPlane);
             return;
          case STATE_TEXGEN_OBJECT_Q:
-            COPY_4V(value, ctx->Texture.Unit[unit].GenQ.ObjectPlane);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenQ.ObjectPlane);
             return;
          default:
             _mesa_problem(ctx, "Invalid texgen state in fetch_state");
@@ -248,9 +248,9 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
          /* state[1] is the texture unit */
          const GLuint unit = (GLuint) state[1];
          if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
-            COPY_4V(value, ctx->Texture.Unit[unit].EnvColor);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].EnvColor);
          else
-            COPY_4V(value, ctx->Texture.Unit[unit].EnvColorUnclamped);
+            COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].EnvColorUnclamped);
       }
       return;
    case STATE_FOG_COLOR:
index f7f08b1..0c12a63 100644 (file)
@@ -185,7 +185,7 @@ _swrast_update_texture_env( struct gl_context *ctx )
 
    for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
       const struct gl_tex_env_combine_state *combine =
-         ctx->Texture.Unit[i]._CurrentCombine;
+         ctx->Texture.FixedFuncUnit[i]._CurrentCombine;
       GLuint term;
       for (term = 0; term < combine->_NumArgsRGB; term++) {
          if (combine->SourceRGB[term] == GL_PRIMARY_COLOR) {
index da4a013..743ee40 100644 (file)
@@ -84,7 +84,8 @@ texture_combine( struct gl_context *ctx, GLuint unit,
                  SWspan *span )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
-   const struct gl_texture_unit *textureUnit = &(ctx->Texture.Unit[unit]);
+   const struct gl_fixedfunc_texture_unit *textureUnit =
+      &ctx->Texture.FixedFuncUnit[unit];
    const struct gl_tex_env_combine_state *combine = textureUnit->_CurrentCombine;
    float4_array argRGB[MAX_COMBINER_TERMS];
    float4_array argA[MAX_COMBINER_TERMS];
index c84cfec..d80ab18 100644 (file)
@@ -539,7 +539,7 @@ affine_span(struct gl_context *ctx, SWspan *span,
 
 #define SETUP_CODE                                                     \
    struct affine_info info;                                            \
-   struct gl_texture_unit *unit = ctx->Texture.Unit+0;                 \
+   struct gl_fixedfunc_texture_unit *unit = ctx->Texture.FixedFuncUnit+0; \
    const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
    const struct gl_texture_image *texImg =                             \
@@ -808,7 +808,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
 
 #define SETUP_CODE                                                     \
    struct persp_info info;                                             \
-   const struct gl_texture_unit *unit = ctx->Texture.Unit+0;           \
+   const struct gl_fixedfunc_texture_unit *unit = ctx->Texture.FixedFuncUnit+0; \
    const struct gl_texture_object *obj =                               \
       ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];               \
    const struct gl_texture_image *texImg =                             \
@@ -1066,7 +1066,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
          format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;
          minFilter = texObj2D ? samp->MinFilter : GL_NONE;
          magFilter = texObj2D ? samp->MagFilter : GL_NONE;
-         envMode = ctx->Texture.Unit[0].EnvMode;
+         envMode = ctx->Texture.FixedFuncUnit[0].EnvMode;
 
          /* First see if we can use an optimized 2-D texture function */
          if (ctx->Texture._EnabledCoordUnits == 0x1
@@ -1085,8 +1085,8 @@ _swrast_choose_triangle( struct gl_context *ctx )
              && minFilter == magFilter
              && ctx->Light.Model.ColorControl == GL_SINGLE_COLOR
              && !swrast->_FogEnabled
-             && ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT
-             && ctx->Texture.Unit[0].EnvMode != GL_COMBINE4_NV) {
+             && ctx->Texture.FixedFuncUnit[0].EnvMode != GL_COMBINE_EXT
+             && ctx->Texture.FixedFuncUnit[0].EnvMode != GL_COMBINE4_NV) {
            if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) {
               if (minFilter == GL_NEAREST
                   && format == MESA_FORMAT_BGR_UNORM8
index 94066f4..a13262d 100644 (file)
@@ -337,7 +337,8 @@ static void texgen( struct gl_context *ctx,
    struct vertex_buffer *VB = &tnl->vb;
    GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit];
    GLvector4f *out = &store->texcoord[unit];
-   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   const struct gl_fixedfunc_texture_unit *texUnit =
+      &ctx->Texture.FixedFuncUnit[unit];
    const GLvector4f *obj = VB->AttribPtr[_TNL_ATTRIB_POS];
    const GLvector4f *eye = VB->EyePtr;
    const GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
@@ -489,10 +490,10 @@ static GLboolean run_texgen_stage( struct gl_context *ctx,
       return GL_TRUE;
 
    for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
-      struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+      struct gl_fixedfunc_texture_unit *texUnit =
+         &ctx->Texture.FixedFuncUnit[i];
 
       if (texUnit->TexGenEnabled) {
-
         store->TexgenFunc[i]( ctx, store, i );
 
          VB->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->texcoord[i];
@@ -513,7 +514,8 @@ static void validate_texgen_stage( struct gl_context *ctx,
       return;
 
    for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
-      struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+      struct gl_fixedfunc_texture_unit *texUnit =
+         &ctx->Texture.FixedFuncUnit[i];
 
       if (texUnit->TexGenEnabled) {
         GLuint sz;