#include "texformat.h"
#include "texstore.h"
#include "teximage.h"
+#include "texobj.h"
#include "swrast/swrast.h"
}
-static void mgaDDTexEnv( GLcontext *ctx, GLenum target,
+static void mgaTexEnv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
GLuint unit = ctx->Texture.CurrentUnit;
{
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 &&
target != GL_TEXTURE_RECTANGLE_NV) ) {
static void
-mgaDDBindTexture( GLcontext *ctx, GLenum target,
+mgaBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
- if ( target == GL_TEXTURE_2D ||
- target == GL_TEXTURE_RECTANGLE_NV ) {
- 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;
}
-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 |
- DRI_TEXMGR_DO_TEXTURE_RECT) );
+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;
}