#include "texformat.h"
#include "texstore.h"
#include "teximage.h"
+#include "texobj.h"
#include "swrast/swrast.h"
+#include "xmlpool.h"
+
/**
* Set the texture wrap modes.
* Currently \c GL_REPEAT, \c GL_CLAMP and \c GL_CLAMP_TO_EDGE are supported.
/* See OpenGL 1.2 specification */
if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST ||
minf == GL_NEAREST_MIPMAP_LINEAR)) {
- val |= (0x20 << TF_fthres_SHIFT); /* c = 0.5 */
+ val |= MGA_FIELD( TF_fthres, 0x20 ); /* c = 0.5 */
} else {
- val |= (0x10 << TF_fthres_SHIFT); /* c = 0 */
+ val |= MGA_FIELD( TF_fthres, 0x10 ); /* c = 0 */
}
GLenum format, GLenum type )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- const GLboolean do32bpt = mmesa->default32BitTextures;
+ const GLboolean do32bpt =
+ ( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
+ const GLboolean force16bpt =
+ ( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
+ (void) format;
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;
- }
- else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
- return &_mesa_texformat_argb4444;
- }
- else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
- return &_mesa_texformat_argb1555;
- }
+ switch ( type ) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ default:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
}
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
case 3:
case GL_RGB:
case GL_COMPRESSED_RGB:
- if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
+ switch ( type ) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
return &_mesa_texformat_rgb565;
+ default:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
}
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ return !force16bpt ?
+ &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
case GL_RGBA4:
case GL_RGBA2:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+ return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
case GL_RGB5:
case GL_RGB4:
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
/* FIXME: This will report incorrect component sizes... */
- return &_mesa_texformat_argb4444;
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
/* FIXME: This will report incorrect component sizes... */
- return &_mesa_texformat_rgb565;
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_rgb565;
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
/* FIXME: This will report incorrect component sizes... */
- return &_mesa_texformat_argb4444;
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
/* FIXME: This will report incorrect component sizes... */
- return &_mesa_texformat_argb4444;
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_i8 : &_mesa_texformat_argb4444;
case GL_YCBCR_MESA:
if (MGA_IS_G400(mmesa) &&
t->setup.texctl = TMC_takey_1 | TMC_tamask_0;
t->setup.texctl2 = TMC_ckstransdis_enable;
- t->setup.texfilter = (TF_minfilter_nrst
- | TF_magfilter_nrst
- | TF_filteralpha_enable
- | TF_uvoffset_OGL);
+ t->setup.texfilter = TF_filteralpha_enable | TF_uvoffset_OGL;
t->border_fallback = GL_FALSE;
+ t->texenv_fallback = GL_FALSE;
make_empty_list( & t->base );
}
-static void mgaDDTexEnv( GLcontext *ctx, GLenum target,
+static void mgaTexEnv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
GLuint unit = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-
switch( pname ) {
case GL_TEXTURE_ENV_COLOR: {
GLubyte c[4];
- GLuint envColor;
UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
- envColor = mgaPackColor( mmesa->mgaScreen->cpp, c[0], c[1], c[2], c[3] );
- mmesa->envcolor = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );
-
- if (mmesa->setup.fcol != envColor) {
- FLUSH_BATCH(mmesa);
- mmesa->setup.fcol = envColor;
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
-
- mmesa->blend_flags &= ~MGA_BLEND_ENV_COLOR;
-
- /* Actually just require all four components to be
- * equal. This permits a single-pass GL_BLEND.
- *
- * More complex multitexture/multipass fallbacks
- * for blend can be done later.
- */
- if (mmesa->envcolor != 0x0 && mmesa->envcolor != 0xffffffff)
- mmesa->blend_flags |= MGA_BLEND_ENV_COLOR;
- }
+ mmesa->envcolor[unit] = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );
break;
}
}
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
if ( t != NULL ) {
driSwapOutTextureObject( t );
}
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
-
- assert( t != NULL ); /* this _should_ be true */
+ assert( t ); /* this _should_ be true */
if ( t != NULL ) {
driSwapOutTextureObject( t );
}
*/
static void
-mgaDDTexParameter( GLcontext *ctx, GLenum target,
+mgaTexParameter( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj,
GLenum pname, const GLfloat *params )
{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaTextureObjectPtr t;
-
- t = (mgaTextureObjectPtr) tObj->DriverData;
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
/* If we don't have a hardware texture, it will be automatically
* created with current state before it is used, so we don't have
* to do anything now
*/
-
- if ( (t == NULL)
- || (target != GL_TEXTURE_2D) ) {
+ if ( (t == NULL) ||
+ (target != GL_TEXTURE_2D &&
+ target != GL_TEXTURE_RECTANGLE_NV) ) {
return;
}
static void
-mgaDDBindTexture( GLcontext *ctx, GLenum target,
+mgaBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
- if ( target == GL_TEXTURE_2D ) {
- if ( tObj->DriverData == NULL ) {
- mgaAllocTexObj( tObj );
- }
- }
+ assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV) ||
+ (tObj->DriverData != NULL) );
}
static void
-mgaDDDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
driTextureObject * t = (driTextureObject *) tObj->DriverData;
driDestroyTextureObject( t );
}
+
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
}
-void
-mgaDDInitTextureFuncs( GLcontext *ctx )
+/**
+ * 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.
+ */
+static struct gl_texture_object *
+mgaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ mgaAllocTexObj( obj );
+ return obj;
+}
- ctx->Driver.ChooseTextureFormat = mgaChooseTextureFormat;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = mgaTexImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = mgaTexSubImage2D;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
- ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
- ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
- ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
- ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- ctx->Driver.BindTexture = mgaDDBindTexture;
- ctx->Driver.CreateTexture = NULL; /* FIXME: Is this used??? */
- ctx->Driver.DeleteTexture = mgaDDDeleteTexture;
- ctx->Driver.IsTextureResident = driIsTextureResident;
- ctx->Driver.PrioritizeTexture = NULL;
- ctx->Driver.ActiveTexture = NULL;
- ctx->Driver.UpdateTexturePalette = NULL;
-
- ctx->Driver.TexEnv = mgaDDTexEnv;
- ctx->Driver.TexParameter = mgaDDTexParameter;
-
- driInitTextureObjects( ctx, & mmesa->swapped, DRI_TEXMGR_DO_TEXTURE_2D );
+void
+mgaInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->ChooseTextureFormat = mgaChooseTextureFormat;
+ functions->TexImage2D = mgaTexImage2D;
+ functions->TexSubImage2D = mgaTexSubImage2D;
+ functions->BindTexture = mgaBindTexture;
+ functions->NewTextureObject = mgaNewTextureObject;
+ functions->DeleteTexture = mgaDeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+ functions->TexEnv = mgaTexEnv;
+ functions->TexParameter = mgaTexParameter;
}