numLevels = t->base.lastLevel - t->base.firstLevel + 1;
- assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS);
+ assert(numLevels <= R300_MAX_TEXTURE_LEVELS);
/* Calculate mipmap offsets and dimensions for blitting (uploading)
* The idea is that we lay out the mipmap levels within a block of
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- struct gl_texture_object *tObj = texUnit->_Current;
- r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
+ struct gl_texture_object *tObj = texUnit->_ReallyEnabled ?
+ texUnit->_Current : NULL;
+ r300TexObjPtr t = tObj ? (r300TexObjPtr) tObj->DriverData : NULL;
/* Fallback if there's a texture border */
- if (tObj->Image[0][tObj->BaseLevel]->Border > 0)
- return GL_FALSE;
+ if (tObj && tObj->Image[0][tObj->BaseLevel]->Border > 0) {
+ tObj = NULL;
+ t = NULL;
+ }
/* Update state if this is a different texture object to last
* time.
*/
- if (rmesa->state.texture.unit[unit].texobj != t) {
+ if (rmesa->state.texture.unit[unit].texobj != tObj) {
if (rmesa->state.texture.unit[unit].texobj != NULL) {
+ r300TexObjPtr t_old = (r300TexObjPtr) rmesa->state.texture.unit[unit].texobj->DriverData;
+
/* The old texture is no longer bound to this texture unit.
* Mark it as such.
*/
- rmesa->state.texture.unit[unit].texobj->base.bound &=
- ~(1 << unit);
+ t_old->base.bound &= ~(1 << unit);
}
- rmesa->state.texture.unit[unit].texobj = t;
- t->base.bound |= (1 << unit);
- driUpdateTextureLRU((driTextureObject *) t); /* XXX: should be locked! */
+ _mesa_reference_texobj(&rmesa->state.texture.unit[unit].texobj, tObj);
+
+ if (t) {
+ t->base.bound |= (1 << unit);
+ driUpdateTextureLRU(&t->base); /* XXX: should be locked! */
+ }
}
- return !t->border_fallback;
+ return !t || !t->border_fallback;
}
void r300SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
} else if (texUnit->_ReallyEnabled) {
return GL_FALSE;
} else {
- return GL_TRUE;
+ return r300UpdateTexture(ctx, unit);
}
}