summaryrefslogtreecommitdiff
path: root/xc/lib/GL/mesa/src/drv/r200/r200_tex.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/lib/GL/mesa/src/drv/r200/r200_tex.c')
-rw-r--r--xc/lib/GL/mesa/src/drv/r200/r200_tex.c212
1 files changed, 99 insertions, 113 deletions
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_tex.c b/xc/lib/GL/mesa/src/drv/r200/r200_tex.c
index 419a2e426..048108188 100644
--- a/xc/lib/GL/mesa/src/drv/r200/r200_tex.c
+++ b/xc/lib/GL/mesa/src/drv/r200/r200_tex.c
@@ -42,6 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "texformat.h"
#include "texstore.h"
#include "texutil.h"
+#include "texmem.h"
#include "r200_context.h"
#include "r200_state.h"
@@ -50,8 +51,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r200_tex.h"
-/* =============================================================
- * Utility functions:
+
+/**
+ * Set the texture wrap modes.
+ *
+ * \param t Texture object whose wrap modes are to be set
+ * \param swrap Wrap mode for the \a s texture coordinate
+ * \param twrap Wrap mode for the \a t texture coordinate
*/
static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum rwrap )
@@ -71,7 +77,7 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
case GL_CLAMP_TO_BORDER:
t->pp_txfilter |= R200_CLAMP_S_CLAMP_BORDER;
break;
- case GL_MIRRORED_REPEAT_ARB:
+ case GL_MIRRORED_REPEAT:
t->pp_txfilter |= R200_CLAMP_S_MIRROR;
break;
case GL_MIRROR_CLAMP_ATI:
@@ -81,7 +87,7 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_LAST;
break;
default:
- _mesa_problem(NULL, "bad S wrap mode in r200SetTexWrap");
+ _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
}
switch ( twrap ) {
@@ -97,7 +103,7 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
case GL_CLAMP_TO_BORDER:
t->pp_txfilter |= R200_CLAMP_T_CLAMP_BORDER;
break;
- case GL_MIRRORED_REPEAT_ARB:
+ case GL_MIRRORED_REPEAT:
t->pp_txfilter |= R200_CLAMP_T_MIRROR;
break;
case GL_MIRROR_CLAMP_ATI:
@@ -107,7 +113,7 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_LAST;
break;
default:
- _mesa_problem(NULL, "bad S wrap mode in r200SetTexWrap");
+ _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
}
t->pp_txformat_x &= ~R200_CLAMP_Q_MASK;
@@ -125,7 +131,7 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
case GL_CLAMP_TO_BORDER:
t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_BORDER;
break;
- case GL_MIRRORED_REPEAT_ARB:
+ case GL_MIRRORED_REPEAT:
t->pp_txformat_x |= R200_CLAMP_Q_MIRROR;
break;
case GL_MIRROR_CLAMP_ATI:
@@ -135,7 +141,7 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_LAST;
break;
default:
- _mesa_problem(NULL, "bad R wrap mode in r200SetTexWrap");
+ _mesa_problem(NULL, "bad R wrap mode in %s", __FUNCTION__);
}
}
@@ -156,6 +162,14 @@ static void r200SetTexMaxAnisotropy( r200TexObjPtr t, GLfloat max )
}
}
+/**
+ * Set the texture magnification and minification modes.
+ *
+ * \param t Texture whose filter modes are to be set
+ * \param minf Texture minification mode
+ * \param magf Texture magnification mode
+ */
+
static void r200SetTexFilter( r200TexObjPtr t, GLenum minf, GLenum magf )
{
GLuint anisotropy = (t->pp_txfilter & R200_MAX_ANISO_MASK);
@@ -224,27 +238,35 @@ static void r200SetTexBorderColor( r200TexObjPtr t, GLubyte c[4] )
}
+/**
+ * Allocate space for and load the mesa images into the texture memory block.
+ * This will happen before drawing with a new texture, or drawing with a
+ * texture after it was swapped out or teximaged again.
+ */
+
static r200TexObjPtr r200AllocTexObj( struct gl_texture_object *texObj )
{
r200TexObjPtr t;
t = CALLOC_STRUCT( r200_tex_obj );
- if (!t)
- return NULL;
+ texObj->DriverData = t;
+ if ( t != NULL ) {
+ if ( R200_DEBUG & DEBUG_TEXTURE ) {
+ fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, texObj, t );
+ }
- if ( R200_DEBUG & DEBUG_TEXTURE ) {
- fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, texObj, t );
- }
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->base.tObj = texObj;
- t->tObj = texObj;
- make_empty_list( t );
+ make_empty_list( & t->base );
+
+ r200SetTexWrap( t, texObj->WrapS, texObj->WrapT, texObj->WrapR );
+ r200SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
+ r200SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
+ r200SetTexBorderColor( t, texObj->_BorderChan );
+ }
- /* Initialize non-image-dependent parts of the state:
- */
- r200SetTexWrap( t, texObj->WrapS, texObj->WrapT, texObj->WrapR );
- r200SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
- r200SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
- r200SetTexBorderColor( t, texObj->_BorderChan );
return t;
}
@@ -259,6 +281,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
switch ( internalFormat ) {
case 4:
case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
if ( format == GL_BGRA ) {
if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
return &_mesa_texformat_argb8888;
@@ -274,6 +297,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case 3:
case GL_RGB:
+ case GL_COMPRESSED_RGB:
if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
return &_mesa_texformat_rgb565;
}
@@ -308,6 +332,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_ALPHA8:
case GL_ALPHA12:
case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
return &_mesa_texformat_al88;
case 1:
@@ -316,6 +341,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_LUMINANCE8:
case GL_LUMINANCE12:
case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
return &_mesa_texformat_al88;
case 2:
@@ -326,6 +352,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_LUMINANCE12_ALPHA4:
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
return &_mesa_texformat_al88;
case GL_INTENSITY:
@@ -333,6 +360,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_INTENSITY8:
case GL_INTENSITY12:
case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
/* At the moment, glean & conform both fail using the i8 internal
* format.
*/
@@ -347,7 +375,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
return &_mesa_texformat_ycbcr_rev;
default:
- _mesa_problem(ctx, "unexpected texture format in r200ChoosTexFormat");
+ _mesa_problem(ctx, "unexpected texture format in %s", __FUNCTION__);
return NULL;
}
@@ -464,22 +492,20 @@ static void r200TexImage1D( GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
- r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
if ( t ) {
- r200SwapOutTexObj( rmesa, t );
+ driSwapOutTextureObject( t );
}
else {
- t = r200AllocTexObj( texObj );
+ t = (driTextureObject *) r200AllocTexObj( texObj );
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
return;
}
- texObj->DriverData = t;
}
- /* Note, this will call r200ChooseTextureFormat */
+ /* Note, this will call ChooseTextureFormat */
_mesa_store_teximage1d(ctx, target, level, internalFormat,
width, border, format, type, pixels,
&ctx->Unpack, texObj, texImage);
@@ -497,21 +523,18 @@ static void r200TexSubImage1D( GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
- r200TexObjPtr t = (r200TexObjPtr)texObj->DriverData;
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
assert( t ); /* this _should_ be true */
if ( t ) {
- r200SwapOutTexObj( rmesa, t );
- t->dirty_images[0] |= (1 << level);
+ driSwapOutTextureObject( t );
}
else {
- t = r200AllocTexObj(texObj);
+ t = (driTextureObject *) r200AllocTexObj( texObj );
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
return;
}
- texObj->DriverData = t;
}
_mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
@@ -530,8 +553,7 @@ static void r200TexImage2D( GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
- r200TexObjPtr t = (r200TexObjPtr)texObj->DriverData;
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
GLuint face;
/* which cube face or ordinary 2D image */
@@ -549,16 +571,15 @@ static void r200TexImage2D( GLcontext *ctx, GLenum target, GLint level,
face = 0;
}
- if ( t ) {
- r200SwapOutTexObj( rmesa, t );
+ if ( t != NULL ) {
+ driSwapOutTextureObject( t );
}
else {
- t = r200AllocTexObj( texObj );
+ t = (driTextureObject *) r200AllocTexObj( texObj );
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
return;
}
- texObj->DriverData = t;
}
texImage->IsClientData = GL_FALSE;
@@ -599,11 +620,9 @@ static void r200TexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
- r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
GLuint face;
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
/* which cube face or ordinary 2D image */
switch (target) {
@@ -622,15 +641,14 @@ static void r200TexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
assert( t ); /* this _should_ be true */
if ( t ) {
- r200SwapOutTexObj( rmesa, t );
+ driSwapOutTextureObject( t );
}
else {
- t = r200AllocTexObj(texObj);
+ t = (driTextureObject *) r200AllocTexObj( texObj );
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
return;
}
- texObj->DriverData = t;
}
_mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
@@ -641,6 +659,7 @@ static void r200TexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
}
+#if ENABLE_HW_3D_TEXTURE
static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint height, GLint depth,
@@ -650,11 +669,10 @@ static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
- r200TexObjPtr t = (r200TexObjPtr)texObj->DriverData;
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
if ( t ) {
- r200SwapOutTexObj( rmesa, t );
+ driSwapOutTextureObject( t );
}
else {
t = r200AllocTexObj( texObj );
@@ -662,7 +680,6 @@ static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
return;
}
- texObj->DriverData = t;
}
texImage->IsClientData = GL_FALSE;
@@ -696,8 +713,10 @@ static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,
t->dirty_images[0] |= (1 << level);
}
}
+#endif
+#if ENABLE_HW_3D_TEXTURE
static void
r200TexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
@@ -708,14 +727,13 @@ r200TexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
- r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
/* fprintf(stderr, "%s\n", __FUNCTION__); */
assert( t ); /* this _should_ be true */
if ( t ) {
- r200SwapOutTexObj( rmesa, t );
+ driSwapOutTextureObject( t );
}
else {
t = r200AllocTexObj(texObj);
@@ -732,6 +750,7 @@ r200TexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
t->dirty_images[0] |= (1 << level);
}
+#endif
@@ -791,11 +810,16 @@ static void r200TexEnv( GLcontext *ctx, GLenum target,
}
}
+
+/**
+ * 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 )
{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;
if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
@@ -803,7 +827,8 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
_mesa_lookup_enum_by_nr( pname ) );
}
- if (!t)
+ if ( ( target != GL_TEXTURE_2D ) &&
+ ( target != GL_TEXTURE_1D ) )
return;
switch ( pname ) {
@@ -829,11 +854,11 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
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 for R200. Since there's no LOD clamping,
+ * 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.
*/
- r200SwapOutTexObj( rmesa, t );
+ driSwapOutTextureObject( (driTextureObject *) t );
break;
default:
@@ -850,17 +875,14 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
static void r200BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj )
{
- r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;
- GLuint unit = ctx->Texture.CurrentUnit;
-
if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
- fprintf( stderr, "%s( %p ) unit=%d\n", __FUNCTION__, texObj, unit );
+ fprintf( stderr, "%s( %p ) unit=%d\n", __FUNCTION__, texObj,
+ ctx->Texture.CurrentUnit );
}
if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
- if ( !t ) {
- t = r200AllocTexObj( texObj );
- texObj->DriverData = t;
+ if ( texObj->DriverData == NULL ) {
+ r200AllocTexObj( texObj );
}
}
}
@@ -869,61 +891,20 @@ static void r200DeleteTexture( GLcontext *ctx,
struct gl_texture_object *texObj )
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
- r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
- fprintf( stderr, "%s( %p )\n", __FUNCTION__, texObj );
+ fprintf( stderr, "%s( %p (target = %s) )\n", __FUNCTION__, texObj,
+ _mesa_lookup_enum_by_nr( texObj->Target ) );
}
- if ( t ) {
+ if ( t != NULL ) {
if ( rmesa ) {
R200_FIREVERTICES( rmesa );
}
- r200DestroyTexObj( rmesa, t );
- texObj->DriverData = NULL;
- }
-}
-static GLboolean r200IsTextureResident( GLcontext *ctx,
- struct gl_texture_object *texObj )
-{
- r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;
-
- return ( t && t->memBlock );
-}
-
-
-static void r200InitTextureObjects( GLcontext *ctx )
-{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
- struct gl_texture_object *texObj;
- GLuint tmp = ctx->Texture.CurrentUnit;
-
- ctx->Texture.CurrentUnit = 0;
-
- texObj = ctx->Texture.Unit[0].Current1D;
- r200BindTexture( ctx, GL_TEXTURE_1D, texObj );
- move_to_tail( &rmesa->texture.swapped,
- (r200TexObjPtr)texObj->DriverData );
-
- texObj = ctx->Texture.Unit[0].Current2D;
- r200BindTexture( ctx, GL_TEXTURE_2D, texObj );
- move_to_tail( &rmesa->texture.swapped,
- (r200TexObjPtr)texObj->DriverData );
-
- ctx->Texture.CurrentUnit = 1;
-
- texObj = ctx->Texture.Unit[1].Current1D;
- r200BindTexture( ctx, GL_TEXTURE_1D, texObj );
- move_to_tail( &rmesa->texture.swapped,
- (r200TexObjPtr)texObj->DriverData );
-
- texObj = ctx->Texture.Unit[1].Current2D;
- r200BindTexture( ctx, GL_TEXTURE_2D, texObj );
- move_to_tail( &rmesa->texture.swapped,
- (r200TexObjPtr)texObj->DriverData );
-
- ctx->Texture.CurrentUnit = tmp;
+ driDestroyTextureObject( t );
+ }
}
/* Need:
@@ -949,6 +930,9 @@ static void r200TexGen( GLcontext *ctx,
void r200InitTextureFuncs( GLcontext *ctx )
{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+
ctx->Driver.ChooseTextureFormat = r200ChooseTextureFormat;
ctx->Driver.TexImage1D = r200TexImage1D;
ctx->Driver.TexImage2D = r200TexImage2D;
@@ -974,7 +958,7 @@ void r200InitTextureFuncs( GLcontext *ctx )
ctx->Driver.BindTexture = r200BindTexture;
ctx->Driver.CreateTexture = NULL; /* FIXME: Is this used??? */
ctx->Driver.DeleteTexture = r200DeleteTexture;
- ctx->Driver.IsTextureResident = r200IsTextureResident;
+ ctx->Driver.IsTextureResident = driIsTextureResident;
ctx->Driver.PrioritizeTexture = NULL;
ctx->Driver.ActiveTexture = NULL;
ctx->Driver.UpdateTexturePalette = NULL;
@@ -983,5 +967,7 @@ void r200InitTextureFuncs( GLcontext *ctx )
ctx->Driver.TexParameter = r200TexParameter;
ctx->Driver.TexGen = r200TexGen;
- r200InitTextureObjects( ctx );
+ driInitTextureObjects( ctx, & rmesa->swapped,
+ DRI_TEXMGR_DO_TEXTURE_1D
+ | DRI_TEXMGR_DO_TEXTURE_2D );
}