⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r200_tex.c

📁 mesa-6.5-minigui源码
💻 C
📖 第 1 页 / 共 3 页
字号:
static void r200CompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,                                 GLint xoffset, GLint yoffset,                                 GLsizei width, GLsizei height,                                 GLenum format,                                 GLsizei imageSize, const GLvoid *data,                                 struct gl_texture_object *texObj,                                 struct gl_texture_image *texImage ){   driTextureObject * t = (driTextureObject *) texObj->DriverData;   GLuint face;   /* which cube face or ordinary 2D image */   switch (target) {   case GL_TEXTURE_CUBE_MAP_POSITIVE_X:   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:      face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;      ASSERT(face < 6);      break;   default:      face = 0;   }   assert( t ); /* this _should_ be true */   if ( t ) {      driSwapOutTextureObject( t );   }   else {      t = (driTextureObject *) r200AllocTexObj( texObj );      if (!t) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D");         return;      }   }   _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,                            height, format, imageSize, data, texObj, texImage);   t->dirty_images[face] |= (1 << level);}#if ENABLE_HW_3D_TEXTUREstatic void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,                            GLint internalFormat,                            GLint width, GLint height, GLint depth,                            GLint border,                            GLenum format, GLenum type, const GLvoid *pixels,                            const struct gl_pixelstore_attrib *packing,                            struct gl_texture_object *texObj,                            struct gl_texture_image *texImage ){   driTextureObject * t = (driTextureObject *) texObj->DriverData;   if ( t ) {      driSwapOutTextureObject( t );   }   else {      t = (driTextureObject *) r200AllocTexObj( texObj );      if (!t) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");         return;      }   }   texImage->IsClientData = GL_FALSE;#if 0   if (r200ValidateClientStorage( ctx, target, 				  internalFormat, 				  width, height, 				  format, type, pixels, 				  packing, texObj, texImage)) {      if (R200_DEBUG & DEBUG_TEXTURE)	 fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);    }   else#endif   {      if (R200_DEBUG & DEBUG_TEXTURE)	 fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);       /* Normal path: copy (to cached memory) and eventually upload       * via another copy to GART memory and then a blit...  Could       * eliminate one copy by going straight to (permanent) GART.       *       * Note, this will call r200ChooseTextureFormat.       */      _mesa_store_teximage3d(ctx, target, level, internalFormat,			     width, height, depth, border,                             format, type, pixels,			     &ctx->Unpack, texObj, texImage);            t->dirty_images[0] |= (1 << level);   }}#endif#if ENABLE_HW_3D_TEXTUREstatic voidr200TexSubImage3D( GLcontext *ctx, GLenum target, GLint level,                   GLint xoffset, GLint yoffset, GLint zoffset,                   GLsizei width, GLsizei height, GLsizei depth,                   GLenum format, GLenum type,                   const GLvoid *pixels,                   const struct gl_pixelstore_attrib *packing,                   struct gl_texture_object *texObj,                   struct gl_texture_image *texImage ){   driTextureObject * t = (driTextureObject *) texObj->DriverData;/*     fprintf(stderr, "%s\n", __FUNCTION__); */   assert( t ); /* this _should_ be true */   if ( t ) {      driSwapOutTextureObject( t );   }   else {      t = (driTextureObject *) r200AllocTexObj( texObj );      if (!t) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");         return;      }      texObj->DriverData = t;   }   _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,                             width, height, depth,                             format, type, pixels, packing, texObj, texImage);   t->dirty_images[0] |= (1 << level);}#endifstatic void r200TexEnv( GLcontext *ctx, GLenum target,			  GLenum pname, const GLfloat *param ){   r200ContextPtr rmesa = R200_CONTEXT(ctx);   GLuint unit = ctx->Texture.CurrentUnit;   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];   if ( R200_DEBUG & DEBUG_STATE ) {      fprintf( stderr, "%s( %s )\n",	       __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );   }   /* This is incorrect: Need to maintain this data for each of    * GL_TEXTURE_{123}D, GL_TEXTURE_RECTANGLE_NV, etc, and switch    * between them according to _ReallyEnabled.    */   switch ( pname ) {   case GL_TEXTURE_ENV_COLOR: {      GLubyte c[4];      GLuint envColor;      UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );      envColor = r200PackColor( 4, c[0], c[1], c[2], c[3] );      if ( rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] != envColor ) {	 R200_STATECHANGE( rmesa, tf );	 rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] = envColor;      }      break;   }   case GL_TEXTURE_LOD_BIAS_EXT: {      GLfloat bias, min;      GLuint b;      const int fixed_one = 0x8000000;      /* The R200's LOD bias is a signed 2's complement value with a       * range of -16.0 <= bias < 16.0.        *       * NOTE: Add a small bias to the bias for conform mipsel.c test.       */      bias = *param + .01;      min = driQueryOptionb (&rmesa->optionCache, "no_neg_lod_bias") ?	  0.0 : -16.0;      bias = CLAMP( bias, min, 16.0 );      b = (int)(bias * fixed_one) & R200_LOD_BIAS_MASK;            if ( (rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] & R200_LOD_BIAS_MASK) != b ) {	 R200_STATECHANGE( rmesa, tex[unit] );	 rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] &= ~R200_LOD_BIAS_MASK;	 rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] |= b;      }      break;   }   default:      return;   }}/** * Changes variables and flags for a state update, which will happen at the * next UpdateTextureState */static void r200TexParameter( GLcontext *ctx, GLenum target,				struct gl_texture_object *texObj,				GLenum pname, const GLfloat *params ){   r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;   if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {      fprintf( stderr, "%s( %s )\n", __FUNCTION__,	       _mesa_lookup_enum_by_nr( pname ) );   }   switch ( pname ) {   case GL_TEXTURE_MIN_FILTER:   case GL_TEXTURE_MAG_FILTER:   case GL_TEXTURE_MAX_ANISOTROPY_EXT:      r200SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );      r200SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );      break;   case GL_TEXTURE_WRAP_S:   case GL_TEXTURE_WRAP_T:   case GL_TEXTURE_WRAP_R:      r200SetTexWrap( t, texObj->WrapS, texObj->WrapT, texObj->WrapR );      break;   case GL_TEXTURE_BORDER_COLOR:      r200SetTexBorderColor( t, texObj->_BorderChan );      break;   case GL_TEXTURE_BASE_LEVEL:   case GL_TEXTURE_MAX_LEVEL:   case GL_TEXTURE_MIN_LOD:   case GL_TEXTURE_MAX_LOD:      /* This isn't the most efficient solution but there doesn't appear to       * be a nice alternative.  Since there's no LOD clamping,       * we just have to rely on loading the right subset of mipmap levels       * to simulate a clamped LOD.       */      driSwapOutTextureObject( (driTextureObject *) t );      break;   default:      return;   }   /* Mark this texobj as dirty (one bit per tex unit)    */   t->dirty_state = TEX_ALL;}static void r200BindTexture( GLcontext *ctx, GLenum target,			       struct gl_texture_object *texObj ){   if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {      fprintf( stderr, "%s( %p ) unit=%d\n", __FUNCTION__, (void *)texObj,	       ctx->Texture.CurrentUnit );   }   if ( (target == GL_TEXTURE_1D)	|| (target == GL_TEXTURE_2D) #if ENABLE_HW_3D_TEXTURE	|| (target == GL_TEXTURE_3D)#endif	|| (target == GL_TEXTURE_CUBE_MAP)	|| (target == GL_TEXTURE_RECTANGLE_NV) ) {      assert( texObj->DriverData != NULL );   }}static void r200DeleteTexture( GLcontext *ctx,				 struct gl_texture_object *texObj ){   r200ContextPtr rmesa = R200_CONTEXT(ctx);   driTextureObject * t = (driTextureObject *) texObj->DriverData;   if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {      fprintf( stderr, "%s( %p (target = %s) )\n", __FUNCTION__, (void *)texObj,	       _mesa_lookup_enum_by_nr( texObj->Target ) );   }   if ( t != NULL ) {      if ( rmesa ) {         R200_FIREVERTICES( rmesa );      }      driDestroyTextureObject( t );   }   /* Free mipmap images and the texture object itself */   _mesa_delete_texture_object(ctx, texObj);}/* Need:   *  - Same GEN_MODE for all active bits *  - Same EyePlane/ObjPlane for all active bits when using Eye/Obj *  - STRQ presumably all supported (matrix means incoming R values *    can end up in STQ, this has implications for vertex support, *    presumably ok if maos is used, though?) *   * Basically impossible to do this on the fly - just collect some * basic info & do the checks from ValidateState(). */static void r200TexGen( GLcontext *ctx,			  GLenum coord,			  GLenum pname,			  const GLfloat *params ){   r200ContextPtr rmesa = R200_CONTEXT(ctx);   GLuint unit = ctx->Texture.CurrentUnit;   rmesa->recheck_texgen[unit] = GL_TRUE;}/** * Allocate a new texture object. * Called via ctx->Driver.NewTextureObject. * Note: this function will be called during context creation to * allocate the default texture objects. * Note: we could use containment here to 'derive' the driver-specific * texture object from the core mesa gl_texture_object.  Not done at this time. * Fixup MaxAnisotropy according to user preference. */static struct gl_texture_object *r200NewTextureObject( GLcontext *ctx, GLuint name, GLenum target ){   r200ContextPtr rmesa = R200_CONTEXT(ctx);   struct gl_texture_object *obj;   obj = _mesa_new_texture_object(ctx, name, target);   if (!obj)      return NULL;   obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;   r200AllocTexObj( obj );   return obj;}void r200InitTextureFuncs( struct dd_function_table *functions ){   /* Note: we only plug in the functions we implement in the driver    * since _mesa_init_driver_functions() was already called.    */   functions->ChooseTextureFormat	= r200ChooseTextureFormat;   functions->TexImage1D		= r200TexImage1D;   functions->TexImage2D		= r200TexImage2D;#if ENABLE_HW_3D_TEXTURE   functions->TexImage3D		= r200TexImage3D;#else   functions->TexImage3D		= _mesa_store_teximage3d;#endif   functions->TexSubImage1D		= r200TexSubImage1D;   functions->TexSubImage2D		= r200TexSubImage2D;#if ENABLE_HW_3D_TEXTURE   functions->TexSubImage3D		= r200TexSubImage3D;#else   functions->TexSubImage3D		= _mesa_store_texsubimage3d;#endif   functions->NewTextureObject		= r200NewTextureObject;   functions->BindTexture		= r200BindTexture;   functions->DeleteTexture		= r200DeleteTexture;   functions->IsTextureResident		= driIsTextureResident;   functions->TexEnv			= r200TexEnv;   functions->TexParameter		= r200TexParameter;   functions->TexGen			= r200TexGen;   functions->CompressedTexImage2D	= r200CompressedTexImage2D;   functions->CompressedTexSubImage2D	= r200CompressedTexSubImage2D;   driInitTextureFormats();#if 000   /* moved or obsolete code */   r200ContextPtr rmesa = R200_CONTEXT(ctx);   driInitTextureObjects( ctx, & rmesa->swapped,			  DRI_TEXMGR_DO_TEXTURE_1D			  | DRI_TEXMGR_DO_TEXTURE_2D );   /* Hack: r200NewTextureObject is not yet installed when the    * default textures are created. Therefore set MaxAnisotropy of the    * default 2D texture now. */   ctx->Shared->Default2D->MaxAnisotropy = driQueryOptionf (&rmesa->optionCache,							    "def_max_anisotropy");#endif}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -