Merge in all the i830 functional differences from the old i830 driver.
authorIan Romanick <idr@us.ibm.com>
Sun, 19 Sep 2004 07:01:26 +0000 (07:01 +0000)
committerIan Romanick <idr@us.ibm.com>
Sun, 19 Sep 2004 07:01:26 +0000 (07:01 +0000)
src/mesa/drivers/dri/i915/i830_context.c
src/mesa/drivers/dri/i915/i830_context.h
src/mesa/drivers/dri/i915/i830_metaops.c
src/mesa/drivers/dri/i915/i830_state.c
src/mesa/drivers/dri/i915/i830_texblend.c
src/mesa/drivers/dri/i915/i915_context.c
src/mesa/drivers/dri/i915/intel_context.c

index 093a2f96f2ae0de7dd7c73d72b35c4a5b461e20e..2c81e3de6dd7a4519358bd408491668cef6fc729 100644 (file)
  * Mesa's Driver Functions
  ***************************************/
 
-/* This is the extension list explicitly enabled by the client and
- * excludes functionality available in Mesa and also excludes legacy
- * extensions.  It is recognized that in an open source driver, those
- * extensions will probably be re-enabled.
- */
-static const GLubyte *i830GetString( GLcontext *ctx, GLenum name )
+static const char * const card_extensions[] =
 {
-#if 0
-   if (name == GL_EXTENSIONS)
-      return 
-        "GL_ARB_multitexture "
-        "GL_ARB_texture_border_clamp "
-        "GL_ARB_texture_compression "
-        "GL_ARB_texture_env_add "
-        "GL_ARB_texture_env_combine "
-        "GL_ARB_texture_env_dot3 "
-        "GL_ARB_texture_mirrored_repeat "
-        "GL_ARB_transpose_matrix "
-        "GL_ARB_vertex_buffer_object "
-        "GL_ARB_vertex_program "
-        "GL_ARB_window_pos "
-        "GL_EXT_abgr "
-        "GL_EXT_bgra "
-        "GL_EXT_blend_color "
-        "GL_EXT_blend_func_separate "
-        "GL_EXT_blend_minmax "
-        "GL_EXT_blend_subtract "
-        "GL_EXT_clip_volume_hint "
-        "GL_EXT_compiled_vertex_array "
-        "GL_EXT_draw_range_elements "
-        "GL_EXT_fog_coord "
-        "GL_EXT_multi_draw_arrays "
-        "GL_EXT_packed_pixels "
-        "GL_EXT_rescale_normal "
-        "GL_EXT_secondary_color "
-        "GL_EXT_separate_specular_color "
-        "GL_EXT_stencil_wrap "
-        "GL_EXT_texture_env_add "
-        "GL_EXT_texture_env_combine "
-        "GL_EXT_texture_filter_anisotropic "
-        "GL_IBM_texture_mirrored_repeat "
-        "GL_MESA_ycbcr_texture "
-        "GL_MESA_window_pos "
-        "GL_NV_texgen_reflection "
-        "GL_SGIS_generate_mipmap ";
-#endif 
-   return intelGetString( ctx, name );
-}
+   "GL_ARB_texture_env_crossbar",
+   "GL_NV_blend_square",
+   NULL
+};
 
 
 static void i830InitDriverFunctions( struct dd_function_table *functions )
@@ -93,7 +51,6 @@ static void i830InitDriverFunctions( struct dd_function_table *functions )
    intelInitDriverFunctions( functions );
    i830InitStateFuncs( functions );
    i830InitTextureFuncs( functions );
-   functions->GetString = i830GetString;
 }
 
 
@@ -153,6 +110,8 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
 
    intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
 
+   driInitExtensions( ctx, card_extensions, GL_FALSE );
+
    i830InitState( i830 );
 
 
index 90cc3592df26260b2a5958db36697cc159fb12ef..48eb704ceac5b542018ce91b000f11f94f758d2b 100644 (file)
@@ -169,12 +169,9 @@ i830AllocTexObj( struct gl_texture_object *tObj );
 
 /* i830_texblend.c
  */
-extern GLuint 
-i830SetBlend_GL1_2(i830ContextPtr i830, int unit, 
-                  GLenum envMode, GLenum format,
-                  GLuint texel_op,
-                  GLuint *state,
-                  const GLfloat *envcolor );
+extern GLuint i830SetTexEnvCombine(i830ContextPtr i830,
+    const struct gl_tex_env_combine_state * combine, GLint blendUnit,
+     GLuint texel_op, GLuint *state, const GLfloat *factor );
 
 extern void 
 i830EmitTextureBlend( i830ContextPtr i830 );
index 6d4367c494fd3ab2329be78dda4b728ebc332fb3..751d8e75edf9081835b1c95f85d227543f479687 100644 (file)
@@ -163,10 +163,17 @@ static void set_color_mask( i830ContextPtr i830, GLboolean state )
  */
 static void set_no_texture( i830ContextPtr i830 )
 {
-   i830->meta.TexBlendWordsUsed[0] = 
-      i830SetBlend_GL1_2( i830, 0, GL_NONE, 0, 
-                         TEXBLENDARG_TEXEL0,
-                         i830->meta.TexBlend[0], 0 );
+   static const struct gl_tex_env_combine_state comb = {
+      GL_NONE, GL_NONE,
+      { GL_TEXTURE, 0, 0, }, { GL_TEXTURE, 0, 0, },
+      { GL_SRC_COLOR, 0, 0 }, { GL_SRC_ALPHA, 0, 0 },
+      0, 0, 0, 0
+   };
+
+   i830->meta.TexBlendWordsUsed[0] =
+     i830SetTexEnvCombine( i830, & comb, 0, TEXBLENDARG_TEXEL0,
+                          i830->meta.TexBlend[0], NULL);
+
    i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE;
    i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0);
 }
@@ -177,10 +184,17 @@ static void set_no_texture( i830ContextPtr i830 )
 static void enable_texture_blend_replace( i830ContextPtr i830,
                                          GLenum format )
 {
-   i830->meta.TexBlendWordsUsed[0] = 
-      i830SetBlend_GL1_2( i830, 0, GL_REPLACE, format, 
-                         TEXBLENDARG_TEXEL0,
-                         i830->meta.TexBlend[0], 0 );
+   static const struct gl_tex_env_combine_state comb = {
+      GL_REPLACE, GL_REPLACE,
+      { GL_TEXTURE, 0, 0, }, { GL_TEXTURE, 0, 0, },
+      { GL_SRC_COLOR, 0, 0 }, { GL_SRC_ALPHA, 0, 0 },
+      0, 0, 1, 1
+   };
+
+   i830->meta.TexBlendWordsUsed[0] =
+     i830SetTexEnvCombine( i830, & comb, 0, TEXBLENDARG_TEXEL0,
+                          i830->meta.TexBlend[0], NULL);
+
    i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE;
    i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0);
 
index 185c34aeaa302954fc4cd5c5b71a19db24a7d0ec..c9d0329602637ffe7b83a7c5047086bbeddbfbd3 100644 (file)
@@ -263,11 +263,15 @@ static void i830AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
                                        ALPHA_REF_VALUE(refInt));
 }
 
-/* This function makes sure that the proper enables are
- * set for LogicOp, Independant Alpha Blend, and Blending.
- * It needs to be called from numerous places where we
+/**
+ * Makes sure that the proper enables are set for LogicOp, Independant Alpha
+ * Blend, and Blending.  It needs to be called from numerous places where we
  * could change the LogicOp or Independant Alpha Blend without subsequent
  * calls to glEnable.
+ * 
+ * \todo
+ * This function is substantially different from the old i830-specific driver.
+ * I'm not sure which is correct.
  */
 static void i830EvalLogicOpBlendState(GLcontext *ctx)
 {
@@ -310,48 +314,16 @@ static void i830BlendColor(GLcontext *ctx, const GLfloat color[4])
    i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] = (a<<24) | (r<<16) | (g<<8) | b;
 }
 
-static void i830BlendEquationSeparate(GLcontext *ctx, GLenum modeRGB,
-                                     GLenum modeA) 
-{
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
-   int func = ENABLE_ALPHA_BLENDFUNC;
-
-   assert( modeRGB == modeA );
-
-   if (INTEL_DEBUG&DEBUG_DRI)
-     fprintf(stderr, "%s %s\n", __FUNCTION__,
-            _mesa_lookup_enum_by_nr(modeRGB));
-
-   /* This will catch a logicop blend equation */
-   i830EvalLogicOpBlendState(ctx);
-
-   switch(modeRGB) {
-   case GL_FUNC_ADD: 
-      func |= BLENDFUNC_ADD; 
-      break;
-   case GL_MIN: 
-      func |= BLENDFUNC_MIN; 
-      break;
-   case GL_MAX: 
-      func |= BLENDFUNC_MAX; 
-      break;
-   case GL_FUNC_SUBTRACT: 
-      func |= BLENDFUNC_SUB; 
-      break;
-   case GL_FUNC_REVERSE_SUBTRACT: 
-      func |= BLENDFUNC_RVRSE_SUB; 
-      break;
-   case GL_LOGIC_OP:
-   default: return;
-   }
-
-   I830_STATECHANGE(i830, I830_UPLOAD_CTX);
-   i830->state.Ctx[I830_CTXREG_STATE1] &= ~BLENDFUNC_MASK;
-   i830->state.Ctx[I830_CTXREG_STATE1] |= func;
-}
-
-
 
+/**
+ * Calculate the hardware blend factor setting.  This same function is used
+ * for source and destination of both alpha and RGB.  
+ *
+ * \returns
+ * The hardware register value for the specified blend factor.  This value
+ * will need to be shifted into the correct position for either source or
+ * destination factor.
+ */
 static int translate_blend_factor( GLenum factor )
 {
    switch(factor) {
@@ -390,35 +362,89 @@ static int translate_blend_factor( GLenum factor )
    }
 }
 
-static void i830BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, 
-                                 GLenum dfactorRGB, GLenum sfactorA,
-                                 GLenum dfactorA )
+
+/**
+ * Sets both the blend equation (called "function" in i830 docs) and the
+ * blend function (called "factor" in i830 docs).  This is done in a single
+ * function because some blend equations (i.e., \c GL_MIN and \c GL_MAX)
+ * change the interpretation of the blend function.
+ */
+static void i830_set_blend_state( GLcontext * ctx )
 {
    i830ContextPtr i830 = I830_CONTEXT(ctx);
-   int iab = i830->state.Ctx[I830_CTXREG_IALPHAB];
-   int s1 = i830->state.Ctx[I830_CTXREG_STATE1];
+   int funcA;
+   int funcRGB;
+   int eqnA;
+   int eqnRGB;
+   int iab;
+   int s1;
 
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s\n", __FUNCTION__);
 
+   funcRGB = SRC_BLND_FACT( translate_blend_factor( ctx->Color.BlendSrcRGB ) )
+       | DST_BLND_FACT( translate_blend_factor( ctx->Color.BlendDstRGB ) );
 
-   iab &= ~(SRC_DST_ABLEND_MASK|ENABLE_INDPT_ALPHA_BLEND);
-   s1 &= ~SRC_DST_BLND_MASK;
-      
-   iab |= (ENABLE_SRC_ABLEND_FACTOR|ENABLE_DST_ABLEND_FACTOR);
-   s1 |= (ENABLE_SRC_BLND_FACTOR|ENABLE_DST_BLND_FACTOR);
+   switch(ctx->Color.BlendEquationRGB) {
+   case GL_FUNC_ADD:
+      eqnRGB = BLENDFUNC_ADD; 
+      break;
+   case GL_MIN:
+      eqnRGB = BLENDFUNC_MIN;
+      funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+      break;
+   case GL_MAX: 
+      eqnRGB = BLENDFUNC_MAX;
+      funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+      break;
+   case GL_FUNC_SUBTRACT: 
+      eqnRGB = BLENDFUNC_SUB; 
+      break;
+   case GL_FUNC_REVERSE_SUBTRACT:
+      eqnRGB = BLENDFUNC_RVRSE_SUB; 
+      break;
+   default:
+      fprintf( stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
+              __func__, __LINE__, ctx->Color.BlendEquationRGB );
+      return;
+   }
+
+
+   funcA = SRC_ABLEND_FACT( translate_blend_factor( ctx->Color.BlendSrcA ) )
+       | DST_ABLEND_FACT( translate_blend_factor( ctx->Color.BlendDstA ) );
 
-   if (ctx->Color.BlendEquationRGB == GL_MIN ||
-       ctx->Color.BlendEquationRGB == GL_MAX) {
-      sfactorA = sfactorRGB = dfactorA = dfactorRGB = GL_ONE;
+   switch(ctx->Color.BlendEquationA) {
+   case GL_FUNC_ADD:
+      eqnA = BLENDFUNC_ADD; 
+      break;
+   case GL_MIN: 
+      eqnA = BLENDFUNC_MIN;
+      funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+      break;
+   case GL_MAX: 
+      eqnA = BLENDFUNC_MAX;
+      funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+      break;
+   case GL_FUNC_SUBTRACT: 
+      eqnA = BLENDFUNC_SUB; 
+      break;
+   case GL_FUNC_REVERSE_SUBTRACT:
+      eqnA = BLENDFUNC_RVRSE_SUB; 
+      break;
+   default:
+      fprintf( stderr, "[%s:%u] Invalid alpha blend equation (0x%04x).\n",
+              __func__, __LINE__, ctx->Color.BlendEquationA );
+      return;
    }
 
-   iab |= SRC_ABLEND_FACT(translate_blend_factor(sfactorA)); 
-   iab |= DST_ABLEND_FACT(translate_blend_factor(dfactorA)); 
-   s1 |= SRC_BLND_FACT(translate_blend_factor(sfactorRGB)); 
-   s1 |= DST_BLND_FACT(translate_blend_factor(dfactorRGB)); 
+   iab = eqnA | funcA
+       | _3DSTATE_INDPT_ALPHA_BLEND_CMD
+       | ENABLE_SRC_ABLEND_FACTOR | ENABLE_DST_ABLEND_FACTOR
+       | ENABLE_ALPHA_BLENDFUNC;
+   s1 = eqnRGB | funcRGB
+       | _3DSTATE_MODES_1_CMD
+       | ENABLE_SRC_BLND_FACTOR | ENABLE_DST_BLND_FACTOR
+       | ENABLE_COLR_BLND_FUNC;
 
-   if (sfactorA != sfactorRGB || dfactorA != dfactorRGB) 
+   if ( (eqnA | funcA) != (eqnRGB | funcRGB) )
       iab |= ENABLE_INDPT_ALPHA_BLEND;
    else
       iab |= DISABLE_INDPT_ALPHA_BLEND;
@@ -429,6 +455,54 @@ static void i830BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
       i830->state.Ctx[I830_CTXREG_IALPHAB] = iab;
       i830->state.Ctx[I830_CTXREG_STATE1] = s1;
    }
+
+   /* This will catch a logicop blend equation.  It will also ensure
+    * independant alpha blend is really in the correct state (either enabled
+    * or disabled) if blending is already enabled.
+    */
+
+   i830EvalLogicOpBlendState(ctx);
+
+   if (0) {
+      fprintf(stderr, "[%s:%u] STATE1: 0x%08x IALPHAB: 0x%08x blend is %sabled\n",
+             __func__, __LINE__,
+             i830->state.Ctx[I830_CTXREG_STATE1],
+             i830->state.Ctx[I830_CTXREG_IALPHAB],
+             (ctx->Color.BlendEnabled) ? "en" : "dis");
+   }
+}
+
+
+static void i830BlendEquationSeparate(GLcontext *ctx, GLenum modeRGB,
+                                     GLenum modeA) 
+{
+   if (INTEL_DEBUG&DEBUG_DRI)
+     fprintf(stderr, "%s -> %s, %s\n", __FUNCTION__,
+            _mesa_lookup_enum_by_nr(modeRGB),
+            _mesa_lookup_enum_by_nr(modeA));
+
+   (void) modeRGB;
+   (void) modeA;
+   i830_set_blend_state( ctx );
+}
+
+
+static void i830BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, 
+                                 GLenum dfactorRGB, GLenum sfactorA,
+                                 GLenum dfactorA )
+{
+   if (INTEL_DEBUG&DEBUG_DRI)
+     fprintf(stderr, "%s -> RGB(%s, %s) A(%s, %s)\n", __FUNCTION__,
+            _mesa_lookup_enum_by_nr(sfactorRGB),
+            _mesa_lookup_enum_by_nr(dfactorRGB),
+            _mesa_lookup_enum_by_nr(sfactorA),
+            _mesa_lookup_enum_by_nr(dfactorA));
+
+   (void) sfactorRGB;
+   (void) dfactorRGB;
+   (void) sfactorA;
+   (void) dfactorA;
+   i830_set_blend_state( ctx );
 }
 
 
index ae359d67b40e00b885376adca79afdcfbab83bd2..b15002271349498c6e0c6c6fac8a27c1f347f132 100644 (file)
@@ -113,640 +113,35 @@ static __inline__ GLuint GetTexelOp(GLint unit)
 }
 
 
-GLuint i830SetBlend_GL1_2(i830ContextPtr i830, int blendUnit, 
-                         GLenum envMode, GLenum format, GLuint texel_op,
-                         GLuint *state, const GLfloat *factor)
+/**
+ * Calculate the hardware instuctions to setup the current texture enviromnemt
+ * settings.  Since \c gl_texture_unit::_CurrentCombine is used, both
+ * "classic" texture enviroments and GL_ARB_texture_env_combine type texture
+ * environments are treated identically.
+ *
+ * \todo
+ * This function should return \c GLboolean.  When \c GL_FALSE is returned,
+ * it means that an environment is selected that the hardware cannot do.  This
+ * is the way the Radeon and R200 drivers work.
+ * 
+ * \todo
+ * Looking at i830_3d_regs.h, it seems the i830 can do part of
+ * GL_ATI_texture_env_combine3.  It can handle using \c GL_ONE and
+ * \c GL_ZERO as combine inputs (which the code already supports).  It can
+ * also handle the \c GL_MODULATE_ADD_ATI mode.  Is it worth investigating
+ * partial support for the extension?
+ */
+GLuint
+i830SetTexEnvCombine(i830ContextPtr i830,
+                    const struct gl_tex_env_combine_state * combine,
+                    GLint blendUnit,
+                    GLuint texel_op,
+                    GLuint *state,
+                    const GLfloat *factor )
 {
-   if(INTEL_DEBUG&DEBUG_TEXTURE)
-      fprintf(stderr, "%s %s %s texel_op(0x%x)\n",
-             __FUNCTION__,
-             _mesa_lookup_enum_by_nr(format),
-             _mesa_lookup_enum_by_nr(envMode),
-             texel_op);
-
-   switch(envMode) {
-   case GL_REPLACE:
-      switch(format) {
-      case GL_ALPHA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        return 4;
-
-      case GL_LUMINANCE:
-      case GL_RGB:
-      case GL_YCBCR_MESA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 4;
-
-      case GL_INTENSITY:
-      case GL_LUMINANCE_ALPHA:
-      case GL_RGBA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        return 4;
-
-      default:
-        /* Always set to passthru if something is funny */
-        return pass_through( state, blendUnit );
-      }
-
-   case GL_MODULATE:
-      switch(format) {
-      case GL_ALPHA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_MODULATE);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 5;
-
-      case GL_LUMINANCE:
-      case GL_RGB:
-      case GL_YCBCR_MESA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_MODULATE);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 5;
-
-      case GL_INTENSITY:
-      case GL_LUMINANCE_ALPHA:
-      case GL_RGBA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_MODULATE);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_MODULATE);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[5] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 6;
-
-      default:
-        /* Always set to passthru if something is funny */
-        return pass_through( state, blendUnit );
-      }
-
-   case GL_DECAL:
-      switch(format) {
-      case GL_RGB:
-      case GL_YCBCR_MESA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 4;
-
-      case GL_RGBA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_BLEND);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG0 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_REPLICATE_ALPHA |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[5] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 6;
-      default:
-        /* Always set to passthru if something is funny */
-        return pass_through( state, blendUnit );
-      }
-
-   case GL_BLEND:
-      switch(format) {
-      case GL_ALPHA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_MODULATE);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 5;
-
-      case GL_LUMINANCE:
-      case GL_RGB:
-      case GL_YCBCR_MESA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_BLEND);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG0 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_FACTOR_N);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[5] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return emit_factor( blendUnit, state, 6, factor );
-
-      case GL_INTENSITY:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_BLEND);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_BLEND);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG0 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_FACTOR_N);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[5] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG0 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[6] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_FACTOR_N);
-        state[7] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return emit_factor( blendUnit, state, 8, factor );
-
-
-      case GL_LUMINANCE_ALPHA:
-      case GL_RGBA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_BLEND);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_MODULATE);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG0 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_FACTOR_N);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[5] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[6] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return emit_factor( blendUnit, state, 7, factor );
-
-      default:
-        /* Always set to passthru if something is funny */
-        return pass_through( state, blendUnit );
-      }
-
-   case GL_ADD:
-      switch(format) {
-      case GL_ALPHA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_MODULATE);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 5;
-
-      case GL_LUMINANCE:
-      case GL_RGB:
-      case GL_YCBCR_MESA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ADD);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ARG1);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 5;
-
-      case GL_INTENSITY:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ADD);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ADD);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[5] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 6;
-
-      case GL_LUMINANCE_ALPHA:
-      case GL_RGBA:
-        state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    DISABLE_TEX_CNTRL_STAGE |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_ADD);
-        state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    ENABLE_TEXOUTPUT_WRT_SEL |
-                    TEXOP_OUTPUT_CURRENT |
-                    TEXOP_SCALE_1X |
-                    TEXOP_MODIFY_PARMS |
-                    TEXBLENDOP_MODULATE);
-        state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_COLOR |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        state[4] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG1 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    texel_op);
-        state[5] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                    TEXPIPE_ALPHA |
-                    TEXBLEND_ARG2 |
-                    TEXBLENDARG_MODIFY_PARMS |
-                    TEXBLENDARG_CURRENT);
-        return 6;
-
-      default:
-        /* Always set to passthru if something is funny */
-        return pass_through( state, blendUnit );
-      }
+   const GLuint numColorArgs = combine->_NumArgsRGB;
+   const GLuint numAlphaArgs = combine->_NumArgsA;
 
-   default:
-      /* Always set to passthru if something is funny */
-      return pass_through( state, blendUnit );
-   }
-}
-
-static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
-                                  const struct gl_texture_unit *texUnit, 
-                                  GLint blendUnit,
-                                  GLuint texel_op,
-                                  GLuint *state,
-                                  const GLfloat *factor )
-{
    GLuint blendop;
    GLuint ablendop;
    GLuint args_RGB[3];
@@ -755,6 +150,23 @@ static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
    GLuint alpha_shift;
    GLboolean need_factor = 0;
    int i;
+   unsigned used;
+   static const GLuint tex_blend_rgb[3] = {
+      TEXPIPE_COLOR | TEXBLEND_ARG1 | TEXBLENDARG_MODIFY_PARMS,
+      TEXPIPE_COLOR | TEXBLEND_ARG2 | TEXBLENDARG_MODIFY_PARMS,
+      TEXPIPE_COLOR | TEXBLEND_ARG0 | TEXBLENDARG_MODIFY_PARMS,
+   };
+   static const GLuint tex_blend_a[3] = {
+      TEXPIPE_ALPHA | TEXBLEND_ARG1 | TEXBLENDARG_MODIFY_PARMS,
+      TEXPIPE_ALPHA | TEXBLEND_ARG2 | TEXBLENDARG_MODIFY_PARMS,
+      TEXPIPE_ALPHA | TEXBLEND_ARG0 | TEXBLENDARG_MODIFY_PARMS,
+   };
+   static const GLuint op_rgb[4] = {
+      0,
+      TEXBLENDARG_INV_ARG,
+      TEXBLENDARG_REPLICATE_ALPHA,
+      TEXBLENDARG_REPLICATE_ALPHA | TEXBLENDARG_INV_ARG,
+   };
 
    if(INTEL_DEBUG&DEBUG_TEXTURE)
       fprintf(stderr, "%s\n", __FUNCTION__);
@@ -764,9 +176,9 @@ static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
     * scale factor, but the ARB version (and the version in OpenGL
     * 1.3) does.
     */
-   switch (texUnit->Combine.ModeRGB) {
+   switch (combine->ModeRGB) {
    case GL_DOT3_RGB_EXT:
-      alpha_shift = texUnit->Combine.ScaleShiftA;
+      alpha_shift = combine->ScaleShiftA;
       rgb_shift = 0;
       break;
 
@@ -776,13 +188,13 @@ static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
       break;
 
    default:
-      rgb_shift = texUnit->Combine.ScaleShiftRGB;
-      alpha_shift = texUnit->Combine.ScaleShiftA;
+      rgb_shift = combine->ScaleShiftRGB;
+      alpha_shift = combine->ScaleShiftA;
       break;
    }
 
 
-   switch(texUnit->Combine.ModeRGB) {
+   switch(combine->ModeRGB) {
    case GL_REPLACE: 
       blendop = TEXBLENDOP_ARG1;
       break;
@@ -818,10 +230,16 @@ static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
 
    /* Handle RGB args */
    for(i = 0; i < 3; i++) {
-      switch(texUnit->Combine.SourceRGB[i]) {
+      switch(combine->SourceRGB[i]) {
       case GL_TEXTURE: 
         args_RGB[i] = texel_op;
         break;
+      case GL_TEXTURE0:
+      case GL_TEXTURE1:
+      case GL_TEXTURE2:
+      case GL_TEXTURE3:
+        args_RGB[i] = GetTexelOp( combine->SourceRGB[i] - GL_TEXTURE0 );
+        break;
       case GL_CONSTANT:
         args_RGB[i] = TEXBLENDARG_FACTOR_N; 
         need_factor = 1;
@@ -836,7 +254,7 @@ static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
         return pass_through( state, blendUnit );
       }
 
-      switch(texUnit->Combine.OperandRGB[i]) {
+      switch(combine->OperandRGB[i]) {
       case GL_SRC_COLOR: 
         args_RGB[i] |= 0;
         break;
@@ -863,15 +281,15 @@ static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
     * Note - the global factor is set up with alpha == .5, so 
     * the alpha part of the DOT4 calculation should be zero.
     */
-   if ( texUnit->Combine.ModeRGB == GL_DOT3_RGBA_EXT || 
-       texUnit->Combine.ModeRGB == GL_DOT3_RGBA ) {
+   if ( combine->ModeRGB == GL_DOT3_RGBA_EXT || 
+       combine->ModeRGB == GL_DOT3_RGBA ) {
       ablendop = TEXBLENDOP_DOT4;
       args_A[0] = TEXBLENDARG_FACTOR; /* the global factor */
       args_A[1] = TEXBLENDARG_FACTOR;
       args_A[2] = TEXBLENDARG_FACTOR;
    }
    else {
-      switch(texUnit->Combine.ModeA) {
+      switch(combine->ModeA) {
       case GL_REPLACE: 
         ablendop = TEXBLENDOP_ARG1;
         break;
@@ -899,10 +317,16 @@ static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
 
       /* Handle A args */
       for(i = 0; i < 3; i++) {
-        switch(texUnit->Combine.SourceA[i]) {
+        switch(combine->SourceA[i]) {
         case GL_TEXTURE: 
            args_A[i] = texel_op;
            break;
+        case GL_TEXTURE0:
+        case GL_TEXTURE1:
+        case GL_TEXTURE2:
+        case GL_TEXTURE3:
+           args_A[i] = GetTexelOp( combine->SourceA[i] - GL_TEXTURE0 );
+           break;
         case GL_CONSTANT:
            args_A[i] = TEXBLENDARG_FACTOR_N; 
            need_factor = 1;
@@ -917,7 +341,7 @@ static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
            return pass_through( state, blendUnit );
         }
 
-        switch(texUnit->Combine.OperandA[i]) {
+        switch(combine->OperandA[i]) {
         case GL_SRC_ALPHA: 
            args_A[i] |= 0;
            break;
@@ -941,59 +365,38 @@ static GLuint i830SetTexEnvCombine(i830ContextPtr i830,
     */
 
 
-   /* Build color pipeline */
-
-   state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-              TEXPIPE_COLOR |
-              ENABLE_TEXOUTPUT_WRT_SEL |
-              TEXOP_OUTPUT_CURRENT |
-              DISABLE_TEX_CNTRL_STAGE |
-              TEXOP_MODIFY_PARMS |
-              blendop);
-   state[1] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-              TEXPIPE_COLOR |
-              TEXBLEND_ARG1 |
-              TEXBLENDARG_MODIFY_PARMS |
-              args_RGB[0]);
-   state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-              TEXPIPE_COLOR |
-              TEXBLEND_ARG2 |
-              TEXBLENDARG_MODIFY_PARMS |
-              args_RGB[1]);
-   state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-              TEXPIPE_COLOR |
-              TEXBLEND_ARG0 |
-              TEXBLENDARG_MODIFY_PARMS |
-              args_RGB[2]);
+   /* Build color & alpha pipelines */
+
+   used = 0;
+   state[used++] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
+                   TEXPIPE_COLOR |
+                   ENABLE_TEXOUTPUT_WRT_SEL |
+                   TEXOP_OUTPUT_CURRENT |
+                   DISABLE_TEX_CNTRL_STAGE |
+                   TEXOP_MODIFY_PARMS |
+                   blendop);
+   state[used++] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
+                   TEXPIPE_ALPHA |
+                   ENABLE_TEXOUTPUT_WRT_SEL |
+                   TEXOP_OUTPUT_CURRENT |
+                   TEXOP_MODIFY_PARMS |
+                   ablendop);
+
+   for ( i = 0 ; i < numColorArgs ; i++ ) {
+      state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
+                      tex_blend_rgb[i] | args_RGB[i]);
+   }
 
-   /* Build Alpha pipeline */
-   state[4] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
-              TEXPIPE_ALPHA |
-              ENABLE_TEXOUTPUT_WRT_SEL |
-              TEXOP_OUTPUT_CURRENT |
-              TEXOP_MODIFY_PARMS |
-              ablendop);
-   state[5] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-              TEXPIPE_ALPHA |
-              TEXBLEND_ARG1 |
-              TEXBLENDARG_MODIFY_PARMS |
-              args_A[0]);
-   state[6] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-              TEXPIPE_ALPHA |
-              TEXBLEND_ARG2 |
-              TEXBLENDARG_MODIFY_PARMS |
-              args_A[1]);
-   state[7] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-              TEXPIPE_ALPHA |
-              TEXBLEND_ARG0 |
-              TEXBLENDARG_MODIFY_PARMS |
-              args_A[2]);
+   for ( i = 0 ; i < numAlphaArgs ; i++ ) {
+      state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
+                      tex_blend_a[i] | args_A[i]);
+   }
 
 
    if (need_factor) 
-      return emit_factor( blendUnit, state, 8, factor );
+      return emit_factor( blendUnit, state, used, factor );
    else 
-      return 8;
+      return used;
 }
 
 
@@ -1010,17 +413,9 @@ static void emit_texblend( i830ContextPtr i830, GLuint unit, GLuint blendUnit,
 
    /* Update i830->state.TexBlend
     */ 
-   if (texUnit->EnvMode == GL_COMBINE) {
-      tmp_sz = i830SetTexEnvCombine(i830, texUnit, blendUnit, 
-                                   GetTexelOp(unit), tmp,
-                                   texUnit->EnvColor );
-   } 
-   else {
-      tmp_sz = i830SetBlend_GL1_2(i830, blendUnit, texUnit->EnvMode,
-                                 t->intel.image[0][0].internalFormat, 
-                                 GetTexelOp(unit), tmp,
-                                 texUnit->EnvColor );
-   }
+   tmp_sz = i830SetTexEnvCombine(i830, texUnit->_CurrentCombine, blendUnit, 
+                                GetTexelOp(unit), tmp,
+                                texUnit->EnvColor );
 
    if (last_stage) 
       tmp[0] |= TEXOP_LAST_STAGE;
index 00e698ea6cf9595e2ddb85ec2bd9fb4c3b663d61..87408b6c77a8a1d6f116fd9b308406bbef4a10a2 100644 (file)
  * Mesa's Driver Functions
  ***************************************/
 
-
 static const char * const card_extensions[] =
 {
    "GL_ARB_fragment_program",
-   "GL_ARB_texture_cube_map",
-   "GL_EXT_blend_equation_separate",
-   "GL_ATI_blend_equation_separate",
    "GL_ARB_point_parameters",
+   "GL_ARB_texture_cube_map",
    NULL
 };
 
index 29f5c64812883d518e51142312c4db3c74140bf3..e32a98befb745b9c2f2822cb6b3f822a93e71bcf 100644 (file)
@@ -72,7 +72,7 @@ int prevLockLine;
  * Mesa's Driver Functions
  ***************************************/
 
-#define DRIVER_DATE                     "20040528"
+#define DRIVER_DATE                     "20040914"
 
 const GLubyte *intelGetString( GLcontext *ctx, GLenum name )
 {
@@ -125,16 +125,21 @@ static void intelBufferSize(GLframebuffer *buffer,
 
 
 
-/* Extension strings exported by the intel driver.
+/**
+ * Extension strings exported by the intel driver.
  *
- * NOTE: See implementation of glGetString in each hw_context.c file:
+ * \note
+ * It appears that ARB_texture_env_crossbar and NV_blend_square have
+ * "disappeared" compared to the old i830-specific driver.
+ *
+ * \note
+ * See implementation of \c glGetString in each hw_context.c file:
  * This set of extensions is overridden and many are not actually
  * exported to the driver.  They are however enabled internally as
  * Mesa requires this when calculating things like GL version number.
  */
 static const char * const card_extensions[] =
 {
-   "GL_APPLE_client_storage",
    "GL_ARB_multisample",
    "GL_ARB_multitexture",
    "GL_ARB_texture_border_clamp",
@@ -143,40 +148,35 @@ static const char * const card_extensions[] =
    "GL_ARB_texture_env_combine",
    "GL_ARB_texture_env_dot3",
    "GL_ARB_texture_mirrored_repeat",
+   "GL_ARB_texture_rectangle",
+   "GL_ARB_vertex_buffer_object",
    "GL_ARB_vertex_program",
+   "GL_ARB_window_pos",
+
+   "GL_EXT_abgr",
+   "GL_EXT_bgra",
    "GL_EXT_blend_color",
+   "GL_EXT_blend_equation_separate",
    "GL_EXT_blend_func_separate",
    "GL_EXT_blend_minmax",
    "GL_EXT_blend_subtract",
    "GL_EXT_fog_coord",
+   "GL_EXT_multi_draw_arrays",
    "GL_EXT_secondary_color",
    "GL_EXT_stencil_wrap",
    "GL_EXT_texture_edge_clamp",
-   "GL_EXT_texture_env_add",
    "GL_EXT_texture_env_combine",
    "GL_EXT_texture_env_dot3",
    "GL_EXT_texture_filter_anisotropic",
    "GL_EXT_texture_lod_bias",
-   "GL_IBM_texture_mirrored_repeat",
-   "GL_INGR_blend_func_separate",
+
+   "GL_3DFX_texture_compression_FXT1",
+   "GL_APPLE_client_storage",
    "GL_MESA_pack_invert",
    "GL_MESA_ycbcr_texture",
-   "GL_NV_texture_rectangle",
    "GL_NV_vertex_program",
-
-/* New in final:
- */
-   "GL_ARB_vertex_buffer_object",
-   "GL_ARB_window_pos",
-   "GL_EXT_multi_draw_arrays",
-   "GL_EXT_abgr",
-   "GL_EXT_bgra",
-
-
+   "GL_NV_vertex_program1_1",
    "GL_SGIS_generate_mipmap",
-   "GL_SGIS_texture_border_clamp",
-   "GL_SGIS_texture_edge_clamp",
-   "GL_3DFX_texture_compression_FXT1",
 
    NULL
 };