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

📄 r200_tex.c

📁 mesa-6.5-minigui源码
💻 C
📖 第 1 页 / 共 3 页
字号:
   case 2:   case GL_LUMINANCE_ALPHA:   case GL_LUMINANCE4_ALPHA4:   case GL_LUMINANCE6_ALPHA2:   case GL_LUMINANCE8_ALPHA8:   case GL_LUMINANCE12_ALPHA4:   case GL_LUMINANCE12_ALPHA12:   case GL_LUMINANCE16_ALPHA16:   case GL_COMPRESSED_LUMINANCE_ALPHA:      return _dri_texformat_al88;   case GL_INTENSITY:   case GL_INTENSITY4:   case GL_INTENSITY8:   case GL_INTENSITY12:   case GL_INTENSITY16:   case GL_COMPRESSED_INTENSITY:       return _dri_texformat_i8;   case GL_YCBCR_MESA:      if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||          type == GL_UNSIGNED_BYTE)         return &_mesa_texformat_ycbcr;      else         return &_mesa_texformat_ycbcr_rev;   case GL_RGB_S3TC:   case GL_RGB4_S3TC:   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:      return &_mesa_texformat_rgb_dxt1;   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:      return &_mesa_texformat_rgba_dxt1;   case GL_RGBA_S3TC:   case GL_RGBA4_S3TC:   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:      return &_mesa_texformat_rgba_dxt3;   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:      return &_mesa_texformat_rgba_dxt5;   default:      _mesa_problem(ctx,         "unexpected internalFormat 0x%x in r200ChooseTextureFormat",         (int) internalFormat);      return NULL;   }   return NULL; /* never get here */}static GLbooleanr200ValidateClientStorage( GLcontext *ctx, GLenum target,			   GLint internalFormat,			   GLint srcWidth, GLint srcHeight,                            GLenum format, GLenum type,  const void *pixels,			   const struct gl_pixelstore_attrib *packing,			   struct gl_texture_object *texObj,			   struct gl_texture_image *texImage){   r200ContextPtr rmesa = R200_CONTEXT(ctx);   if (0)      fprintf(stderr, "intformat %s format %s type %s\n",	      _mesa_lookup_enum_by_nr( internalFormat ),	      _mesa_lookup_enum_by_nr( format ),	      _mesa_lookup_enum_by_nr( type ));   if (!ctx->Unpack.ClientStorage)      return 0;   if (ctx->_ImageTransferState ||       texImage->IsCompressed ||       texObj->GenerateMipmap)      return 0;   /* This list is incomplete, may be different on ppc???    */   switch ( internalFormat ) {   case GL_RGBA:      if ( format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV ) {	 texImage->TexFormat = _dri_texformat_argb8888;      }      else	 return 0;      break;   case GL_RGB:      if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {	 texImage->TexFormat = _dri_texformat_rgb565;      }      else	 return 0;      break;   case GL_YCBCR_MESA:      if ( format == GL_YCBCR_MESA && 	   type == GL_UNSIGNED_SHORT_8_8_REV_APPLE ) {	 texImage->TexFormat = &_mesa_texformat_ycbcr_rev;      }      else if ( format == GL_YCBCR_MESA && 		(type == GL_UNSIGNED_SHORT_8_8_APPLE || 		 type == GL_UNSIGNED_BYTE)) {	 texImage->TexFormat = &_mesa_texformat_ycbcr;      }      else	 return 0;      break;   default:      return 0;   }   /* Could deal with these packing issues, but currently don't:    */   if (packing->SkipPixels ||        packing->SkipRows ||        packing->SwapBytes ||       packing->LsbFirst) {      return 0;   }   {            GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,						  format, type);            if (0)	 fprintf(stderr, "%s: srcRowStride %d/%x\n", 		 __FUNCTION__, srcRowStride, srcRowStride);      /* Could check this later in upload, pitch restrictions could be       * relaxed, but would need to store the image pitch somewhere,       * as packing details might change before image is uploaded:       */      if (!r200IsGartMemory( rmesa, pixels, srcHeight * srcRowStride ) ||	  (srcRowStride & 63))	 return 0;      /* Have validated that _mesa_transfer_teximage would be a straight       * memcpy at this point.  NOTE: future calls to TexSubImage will       * overwrite the client data.  This is explicitly mentioned in the       * extension spec.       */      texImage->Data = (void *)pixels;      texImage->IsClientData = GL_TRUE;      texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;      return 1;   }}static void r200TexImage1D( GLcontext *ctx, GLenum target, GLint level,                              GLint internalFormat,                              GLint width, 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, "glTexImage1D");         return;      }   }   /* Note, this will call ChooseTextureFormat */   _mesa_store_teximage1d(ctx, target, level, internalFormat,                          width, border, format, type, pixels,                          &ctx->Unpack, texObj, texImage);   t->dirty_images[0] |= (1 << level);}static void r200TexSubImage1D( GLcontext *ctx, GLenum target, GLint level,                                 GLint xoffset,                                 GLsizei width,                                 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;   assert( t ); /* this _should_ be true */   if ( t ) {      driSwapOutTextureObject( t );   }   else {      t = (driTextureObject *) r200AllocTexObj( texObj );      if (!t) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");         return;      }   }   _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,			     format, type, pixels, packing, texObj,			     texImage);   t->dirty_images[0] |= (1 << level);}static void r200TexImage2D( GLcontext *ctx, GLenum target, GLint level,                              GLint internalFormat,                              GLint width, GLint height, 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;   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;   }   if ( t != NULL ) {      driSwapOutTextureObject( t );   }   else {      t = (driTextureObject *) r200AllocTexObj( texObj );      if (!t) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");         return;      }   }   texImage->IsClientData = GL_FALSE;   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 {      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_teximage2d(ctx, target, level, internalFormat,			     width, height, border, format, type, pixels,			     &ctx->Unpack, texObj, texImage);            t->dirty_images[face] |= (1 << level);   }}static void r200TexSubImage2D( GLcontext *ctx, GLenum target, GLint level,                                 GLint xoffset, GLint yoffset,                                 GLsizei width, GLsizei height,                                 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;   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, "glTexSubImage2D");         return;      }   }   _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,			     height, format, type, pixels, packing, texObj,			     texImage);   t->dirty_images[face] |= (1 << level);}static void r200CompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,                              GLint internalFormat,                              GLint width, GLint height, GLint border,                              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;   }   if ( t != NULL ) {      driSwapOutTextureObject( t );   }   else {      t = (driTextureObject *) r200AllocTexObj( texObj );      if (!t) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");         return;      }   }   texImage->IsClientData = GL_FALSE;/* can't call this, different parameters. Would never evaluate to true anyway currently   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 */{      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_compressed_teximage2d(ctx, target, level, internalFormat, width,                                 height, border, imageSize, data, texObj, texImage);      t->dirty_images[face] |= (1 << level);   }}

⌨️ 快捷键说明

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