#include "simple_list.h"
#include "texformat.h"
#include "texstore.h"
-#include "texutil.h"
#include "texmem.h"
#include "teximage.h"
#include "texobj.h"
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
- int texelBytes;
if (0)
fprintf(stderr, "intformat %s format %s type %s\n",
case GL_RGBA:
if ( format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
texImage->TexFormat = &_mesa_texformat_argb8888;
- texelBytes = 4;
}
else
return 0;
case GL_RGB:
if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
texImage->TexFormat = &_mesa_texformat_rgb565;
- texelBytes = 2;
}
else
return 0;
if ( format == GL_YCBCR_MESA &&
type == GL_UNSIGNED_SHORT_8_8_REV_APPLE ) {
texImage->TexFormat = &_mesa_texformat_ycbcr_rev;
- texelBytes = 2;
}
else if ( format == GL_YCBCR_MESA &&
(type == GL_UNSIGNED_SHORT_8_8_APPLE ||
type == GL_UNSIGNED_BYTE)) {
texImage->TexFormat = &_mesa_texformat_ycbcr;
- texelBytes = 2;
}
else
return 0;
break;
-
-
+
default:
return 0;
}
*/
texImage->Data = (void *)pixels;
texImage->IsClientData = GL_TRUE;
- texImage->RowStride = srcRowStride / texelBytes;
+ texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;
+
return 1;
}
}
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
- assert(t);
if ( t ) {
driSwapOutTextureObject( t );
}
driTextureObject * t = (driTextureObject *) texObj->DriverData;
GLuint face;
- assert(t);
-
/* which cube face or ordinary 2D image */
switch (target) {
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
- assert(t);
-
if ( t ) {
driSwapOutTextureObject( t );
}
else {
- t = r200AllocTexObj( texObj );
+ t = (driTextureObject *) r200AllocTexObj( texObj );
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
return;
driSwapOutTextureObject( t );
}
else {
- t = r200AllocTexObj(texObj);
+ t = (driTextureObject *) r200AllocTexObj( texObj );
if (!t) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
return;
_mesa_lookup_enum_by_nr( pname ) );
}
- if ( ( target != GL_TEXTURE_2D ) &&
- ( target != GL_TEXTURE_1D ) )
- return;
-
switch ( pname ) {
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_MAG_FILTER:
-#if 0
-/* not needed anymore */
static void r200BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj )
{
ctx->Texture.CurrentUnit );
}
- if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
- if ( texObj->DriverData == NULL ) {
- r200AllocTexObj( texObj );
- }
+ 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 );
}
}
-#endif
static void r200DeleteTexture( GLcontext *ctx,
r200ContextPtr rmesa = R200_CONTEXT(ctx);
driTextureObject * t = (driTextureObject *) texObj->DriverData;
- assert(t);
-
if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
fprintf( stderr, "%s( %p (target = %s) )\n", __FUNCTION__, (void *)texObj,
_mesa_lookup_enum_by_nr( texObj->Target ) );
* 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 *
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
struct gl_texture_object *obj;
- driTextureObject *t;
obj = _mesa_new_texture_object(ctx, name, target);
if (!obj)
return NULL;
obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
- t = (driTextureObject *) r200AllocTexObj( obj );
- if (!t) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
+ r200AllocTexObj( obj );
return obj;
}
functions->TexSubImage3D = _mesa_store_texsubimage3d;
#endif
functions->NewTextureObject = r200NewTextureObject;
- /*functions->BindTexture = r200BindTexture;*/
+ functions->BindTexture = r200BindTexture;
functions->DeleteTexture = r200DeleteTexture;
functions->IsTextureResident = driIsTextureResident;