#include "texformat.h"
#include "texstore.h"
#include "teximage.h"
+#include "texobj.h"
-#define ALIGN(value, align) (char *)((long)(value + align - 1) & ~(align - 1))
+#define ALIGN(value, align) (GLubyte *)((long)(value + align - 1) & ~(align - 1))
#define TEXTURE_HW_ALIGNMENT 4
#define TEXTURE_HW_PLUS (4 + 4)
t->hwformat = TEXEL_ARGB_0888_32;
break;
default:
- assert(0);
+ sis_fatal_error("Bad texture format.\n");
}
}
assert(t->format == image->Format);
addr = sisAllocFB( smesa, size, &t->image[level].handle );
if (addr == NULL) {
addr = sisAllocAGP( smesa, size, &t->image[level].handle );
- if (addr == NULL) {
- fprintf (stderr, "SIS driver : out of video/agp memory\n");
- sis_fatal_error();
- }
+ if (addr == NULL)
+ sis_fatal_error("Failure to allocate texture memory.\n");
t->image[level].memType = AGP_TYPE;
}
else
}
static void
-sisDDTexEnv( GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param )
+sisTexEnv( GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
}
static void
-sisDDTexParameter( GLcontext *ctx, GLenum target,
- struct gl_texture_object *texObj, GLenum pname,
- const GLfloat *params )
+sisTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj, GLenum pname,
+ const GLfloat *params )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
}
static void
-sisDDBindTexture( GLcontext *ctx, GLenum target,
- struct gl_texture_object *texObj )
+sisBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
sisTexObjPtr t;
if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
if ( texObj->DriverData == NULL ) {
- sisAllocTexObj( texObj );
+ sisAllocTexObj( texObj );
}
}
t = texObj->DriverData;
-
- if (t == NULL)
+ if (!t)
return;
if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) {
}
static void
-sisDDDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj )
+sisDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
sisTexObjPtr t;
if (t == NULL) {
/*
* this shows the texture is default object and never be a
- * argument of sisDDTexImage*
+ * argument of sisTexImage*
*/
return;
}
_mesa_delete_texture_object(ctx, texObj);
}
-static GLboolean sisDDIsTextureResident( GLcontext * ctx,
+static GLboolean sisIsTextureResident( GLcontext * ctx,
struct gl_texture_object *texObj )
{
return (texObj->DriverData != NULL);
}
static const struct gl_texture_format *
-sisDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
GLenum format, GLenum type )
{
/* XXX 16-bit internal texture formats? */
}
}
-static void sisDDTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+static void sisTexImage1D( GLcontext *ctx, GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
sisAllocTexObj( texObj );
t = texObj->DriverData;
- /* Note, this will call sisDDChooseTextureFormat */
+ /* Note, this will call sisChooseTextureFormat */
_mesa_store_teximage1d( ctx, target, level, internalFormat,
width, border, format, type,
pixels, packing, texObj, texImage );
}
-static void sisDDTexSubImage1D( GLcontext *ctx,
+static void sisTexSubImage1D( GLcontext *ctx,
GLenum target,
GLint level,
GLint xoffset,
sisTexObjPtr t;
GLuint copySize;
GLint texelBytes;
- char *src, *dst;
+ const char *src;
+ GLubyte *dst;
if ( texObj->DriverData == NULL )
sisAllocTexObj( texObj );
smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
}
-static void sisDDTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+static void sisTexImage2D( GLcontext *ctx, GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint height, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
sisAllocTexObj( texObj );
t = texObj->DriverData;
- /* Note, this will call sisDDChooseTextureFormat */
+ /* Note, this will call sisChooseTextureFormat */
_mesa_store_teximage2d(ctx, target, level, internalFormat,
width, height, border, format, type, pixels,
&ctx->Unpack, texObj, texImage);
smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
}
-static void sisDDTexSubImage2D( GLcontext *ctx,
+static void sisTexSubImage2D( GLcontext *ctx,
GLenum target,
GLint level,
GLint xoffset, GLint yoffset,
sisTexObjPtr t;
GLuint copySize;
GLint texelBytes;
- char *src, *dst;
+ const char *src;
+ GLubyte *dst;
int j;
GLuint soffset;
smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format;
}
smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+/**
+ * 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 *
+sisNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ return obj;
}
-void sisDDInitTextureFuncs( GLcontext *ctx )
+
+void sisInitTextureFuncs( struct dd_function_table *functions )
{
- ctx->Driver.TexEnv = sisDDTexEnv;
- ctx->Driver.ChooseTextureFormat = sisDDChooseTextureFormat;
- ctx->Driver.TexImage1D = sisDDTexImage1D;
- ctx->Driver.TexSubImage1D = sisDDTexSubImage1D;
- ctx->Driver.TexImage2D = sisDDTexImage2D;
- ctx->Driver.TexSubImage2D = sisDDTexSubImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- 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.TexParameter = sisDDTexParameter;
- ctx->Driver.BindTexture = sisDDBindTexture;
- ctx->Driver.DeleteTexture = sisDDDeleteTexture;
- ctx->Driver.IsTextureResident = sisDDIsTextureResident;
- ctx->Driver.PrioritizeTexture = NULL;
+ functions->TexEnv = sisTexEnv;
+ functions->ChooseTextureFormat = sisChooseTextureFormat;
+ functions->TexImage1D = sisTexImage1D;
+ functions->TexSubImage1D = sisTexSubImage1D;
+ functions->TexImage2D = sisTexImage2D;
+ functions->TexSubImage2D = sisTexSubImage2D;
+ functions->TexParameter = sisTexParameter;
+ functions->BindTexture = sisBindTexture;
+ functions->NewTextureObject = sisNewTextureObject;
+ functions->DeleteTexture = sisDeleteTexture;
+ functions->IsTextureResident = sisIsTextureResident;
}