Open/Close FullScreen die. unichrome and savage implemented, code is ifdef'd out
[mesa.git] / src / mesa / drivers / dri / r200 / r200_tex.c
index 1990d661919c3573076c0ba91b20e65c91a82cac..810607c35384c2a139f1a10d0af1256e7ff2d3ae 100644 (file)
@@ -41,7 +41,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "simple_list.h"
 #include "texformat.h"
 #include "texstore.h"
-#include "texutil.h"
 #include "texmem.h"
 #include "teximage.h"
 #include "texobj.h"
@@ -445,7 +444,6 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
 
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   int texelBytes;
 
    if (0)
       fprintf(stderr, "intformat %s format %s type %s\n",
@@ -468,7 +466,6 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
    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;
@@ -477,7 +474,6 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
    case GL_RGB:
       if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
         texImage->TexFormat = &_mesa_texformat_rgb565;
-        texelBytes = 2;
       }
       else
         return 0;
@@ -487,19 +483,16 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
       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;
    }
@@ -538,7 +531,8 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
        */
       texImage->Data = (void *)pixels;
       texImage->IsClientData = GL_TRUE;
-      texImage->RowStride = srcRowStride / texelBytes;
+      texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;
+
       return 1;
    }
 }
@@ -554,7 +548,6 @@ static void r200TexImage1D( GLcontext *ctx, GLenum target, GLint level,
 {
    driTextureObject * t = (driTextureObject *) texObj->DriverData;
 
-   assert(t);
    if ( t ) {
       driSwapOutTextureObject( t );
    }
@@ -617,8 +610,6 @@ static void r200TexImage2D( GLcontext *ctx, GLenum target, GLint level,
    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:
@@ -733,13 +724,11 @@ static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,
 {
    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;
@@ -800,7 +789,7 @@ r200TexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
       driSwapOutTextureObject( t );
    }
    else {
-      t = r200AllocTexObj(texObj);
+      t = (driTextureObject *) r200AllocTexObj( texObj );
       if (!t) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
          return;
@@ -893,10 +882,6 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
               _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:
@@ -938,8 +923,6 @@ static void r200TexParameter( GLcontext *ctx, GLenum target,
 
 
 
-#if 0
-/* not needed anymore */
 static void r200BindTexture( GLcontext *ctx, GLenum target,
                               struct gl_texture_object *texObj )
 {
@@ -948,13 +931,16 @@ static void r200BindTexture( GLcontext *ctx, GLenum target,
               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,
@@ -963,8 +949,6 @@ 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 ) );
@@ -1007,6 +991,8 @@ static void r200TexGen( GLcontext *ctx,
  * 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 *
@@ -1014,16 +1000,11 @@ r200NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
 {
    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;
 }
 
@@ -1049,7 +1030,7 @@ void r200InitTextureFuncs( struct dd_function_table *functions )
    functions->TexSubImage3D            = _mesa_store_texsubimage3d;
 #endif
    functions->NewTextureObject         = r200NewTextureObject;
-   /*functions->BindTexture            = r200BindTexture;*/
+   functions->BindTexture              = r200BindTexture;
    functions->DeleteTexture            = r200DeleteTexture;
    functions->IsTextureResident                = driIsTextureResident;