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

📄 r300_tex.c

📁 mesa-6.5-minigui源码
💻 C
📖 第 1 页 / 共 3 页
字号:
         return;      }   }   texImage->IsClientData = GL_FALSE;/* can't call this, different parameters. Would never evaluate to true anyway currently   if (r300ValidateClientStorage( ctx, target, 				  internalFormat,				  width, height,				  format, type, pixels,				  packing, texObj, texImage)) {      if (RADEON_DEBUG & DEBUG_TEXTURE)	 fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);   }   else */{      if (RADEON_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 r300ChooseTextureFormat.       */      _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,                                 height, border, imageSize, data, texObj, texImage);      t->dirty_images[face] |= (1 << level);   }}static void r300CompressedTexSubImage2D( 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 *) r300AllocTexObj( texObj );      if (!t) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3D");         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 r300TexImage3D(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 *) r300AllocTexObj(texObj);		if (!t) {			_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");			return;		}	}	texImage->IsClientData = GL_FALSE;#if 0	if (r300ValidateClientStorage(ctx, target,				      internalFormat,				      width, height,				      format, type, pixels,				      packing, texObj, texImage)) {		if (RADEON_DEBUG & DEBUG_TEXTURE)			fprintf(stderr, "%s: Using client storage\n",				__FUNCTION__);	} else#endif	{		if (RADEON_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 r300ChooseTextureFormat.		 */		_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 voidr300TexSubImage3D(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 *) r300AllocTexObj(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 r300TexEnv(GLcontext * ctx, GLenum target,		       GLenum pname, const GLfloat * param){	if (RADEON_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_LOD_BIAS_EXT:{#if 0 /* Needs to be relocated in order to make sure we got the right tmu */			GLfloat bias, min;			GLuint b;			/* The R300'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->radeon.optionCache,					    "no_neg_lod_bias") ? 0.0 : -16.0;			bias = CLAMP(bias, min, 16.0);			/* 0.0 - 16.0 == 0x0 - 0x1000 */			/* 0.0 - -16.0 == 0x1001 - 0x1fff */			b = 0x1000 / 16.0 * bias;			b &= R300_LOD_BIAS_MASK;			if(b != (rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] & R300_LOD_BIAS_MASK)){				R300_STATECHANGE(rmesa, tex.unknown1);				rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] &= ~R300_LOD_BIAS_MASK;				rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] |= b;			}#endif			break;		}	default:		return;	}}/** * Changes variables and flags for a state update, which will happen at the * next UpdateTextureState */static void r300TexParameter(GLcontext * ctx, GLenum target,			     struct gl_texture_object *texObj,			     GLenum pname, const GLfloat * params){	r300TexObjPtr t = (r300TexObjPtr) texObj->DriverData;	if (RADEON_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:		r300SetTexMaxAnisotropy(t, texObj->MaxAnisotropy);		r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter);		break;	case GL_TEXTURE_WRAP_S:	case GL_TEXTURE_WRAP_T:	case GL_TEXTURE_WRAP_R:		r300SetTexWrap(t, texObj->WrapS, texObj->WrapT, texObj->WrapR);		break;	case GL_TEXTURE_BORDER_COLOR:		r300SetTexBorderColor(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 r300BindTexture(GLcontext * ctx, GLenum target,			    struct gl_texture_object *texObj){	if (RADEON_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 r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj){	r300ContextPtr rmesa = R300_CONTEXT(ctx);	driTextureObject *t = (driTextureObject *) texObj->DriverData;	if (RADEON_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) {			R300_FIREVERTICES(rmesa);		}		driDestroyTextureObject(t);	}	/* Free mipmap images and the texture object itself */	_mesa_delete_texture_object(ctx, texObj);}/** * 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 *r300NewTextureObject(GLcontext * ctx,						      GLuint name,						      GLenum target){	r300ContextPtr rmesa = R300_CONTEXT(ctx);	struct gl_texture_object *obj;	obj = _mesa_new_texture_object(ctx, name, target);	if (!obj)		return NULL;	obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;	r300AllocTexObj(obj);	return obj;}void r300InitTextureFuncs(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 = r300ChooseTextureFormat;	functions->TexImage1D = r300TexImage1D;	functions->TexImage2D = r300TexImage2D;#if ENABLE_HW_3D_TEXTURE	functions->TexImage3D = r300TexImage3D;#else	functions->TexImage3D = _mesa_store_teximage3d;#endif	functions->TexSubImage1D = r300TexSubImage1D;	functions->TexSubImage2D = r300TexSubImage2D;#if ENABLE_HW_3D_TEXTURE	functions->TexSubImage3D = r300TexSubImage3D;#else	functions->TexSubImage3D = _mesa_store_texsubimage3d;#endif	functions->NewTextureObject = r300NewTextureObject;	functions->BindTexture = r300BindTexture;	functions->DeleteTexture = r300DeleteTexture;	functions->IsTextureResident = driIsTextureResident;	functions->TexEnv = r300TexEnv;	functions->TexParameter = r300TexParameter;		functions->CompressedTexImage2D	= r300CompressedTexImage2D;	functions->CompressedTexSubImage2D	= r300CompressedTexSubImage2D;	driInitTextureFormats();#if 0	/* moved or obsolete code */	r300ContextPtr rmesa = R300_CONTEXT(ctx);	driInitTextureObjects(ctx, &rmesa->swapped,			      DRI_TEXMGR_DO_TEXTURE_1D			      | DRI_TEXMGR_DO_TEXTURE_2D);	/* Hack: r300NewTextureObject 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 + -