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

📄 r300_tex.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
			   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 *) r300AllocTexObj(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 r300TexSubImage1D(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 *) r300AllocTexObj(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 r300TexImage2D(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 *) r300AllocTexObj(texObj);		if (!t) {			_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");			return;		}	}	texImage->IsClientData = GL_FALSE;	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_teximage2d(ctx, target, level, internalFormat,				       width, height, border, format, type,				       pixels, &ctx->Unpack, texObj, texImage);		t->dirty_images[face] |= (1 << level);	}}static void r300TexSubImage2D(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 *) r300AllocTexObj(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 r300CompressedTexImage2D(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 *) r300AllocTexObj(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 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_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);}static 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);	}}static 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);}/** * 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:		r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter, texObj->MaxAnisotropy);		break;	case GL_TEXTURE_WRAP_S:	case GL_TEXTURE_WRAP_T:	case GL_TEXTURE_WRAP_R:		r300UpdateTexWrap(t);		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;	case GL_DEPTH_TEXTURE_MODE:		if (!texObj->Image[0][texObj->BaseLevel])			return;		if (texObj->Image[0][texObj->BaseLevel]->TexFormat->BaseFormat		    == GL_DEPTH_COMPONENT) {			r300SetDepthTexMode(texObj);			break;		} else {			/* If the texture isn't a depth texture, changing this			 * state won't cause any changes to the hardware.			 * Don't force a flush of texture state.			 */			return;		}	default:		return;	}}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)	    || (target == GL_TEXTURE_3D)	    || (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;	functions->TexImage3D = r300TexImage3D;	functions->TexSubImage1D = r300TexSubImage1D;	functions->TexSubImage2D = r300TexSubImage2D;	functions->TexSubImage3D = r300TexSubImage3D;	functions->NewTextureObject = r300NewTextureObject;	functions->BindTexture = r300BindTexture;	functions->DeleteTexture = r300DeleteTexture;	functions->IsTextureResident = driIsTextureResident;	functions->TexParameter = r300TexParameter;	functions->CompressedTexImage2D = r300CompressedTexImage2D;	functions->CompressedTexSubImage2D = r300CompressedTexSubImage2D;	driInitTextureFormats();}

⌨️ 快捷键说明

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