ctx->Driver.UpdateState = ffbDDUpdateState;
ctx->Driver.Enable = ffbDDEnable;
- ctx->Driver.LightModelfv = NULL;
ctx->Driver.AlphaFunc = ffbDDAlphaFunc;
ctx->Driver.BlendEquation = ffbDDBlendEquation;
ctx->Driver.BlendFunc = ffbDDBlendFunc;
ctx->Driver.LineStipple = ffbDDLineStipple;
ctx->Driver.PolygonStipple = ffbDDPolygonStipple;
ctx->Driver.Scissor = ffbDDScissor;
- ctx->Driver.CullFace = NULL;
- ctx->Driver.FrontFace = NULL;
ctx->Driver.ColorMask = ffbDDColorMask;
ctx->Driver.LogicOpcode = ffbDDLogicOp;
ctx->Driver.Viewport = ffbDDViewport;
ctx->Driver.StencilFunc = ffbDDStencilFunc;
ctx->Driver.StencilMask = ffbDDStencilMask;
ctx->Driver.StencilOp = ffbDDStencilOp;
- } else {
- ctx->Driver.StencilFunc = NULL;
- ctx->Driver.StencilMask = NULL;
- ctx->Driver.StencilOp = NULL;
}
ctx->Driver.DrawBuffer = ffbDDDrawBuffer;
ctx->Driver.ClearStencil = ffbDDClearStencil;
/* We will support color index modes later... -DaveM */
+ /*
ctx->Driver.ClearIndex = 0;
ctx->Driver.IndexMask = 0;
-
-
-
- /* Pixel path fallbacks.
- */
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
-
- /* Swrast hooks for imaging extensions:
- */
- ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
- ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
- ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
- ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+ */
{
struct swrast_device_driver *swdd =
* David S. Miller <davem@redhat.com>
*/
-#include <GL/gl.h>
-#include "texformat.h"
-#include "texstore.h"
-#include "teximage.h"
-#include "swrast/swrast.h"
-
-#include "ffb_tex.h"
+#include "glheader.h"
+#include "mtypes.h"
/* No texture unit, all software. */
+/* XXX this function isn't needed since _mesa_init_driver_functions()
+ * will make all these assignments.
+ */
void ffbDDInitTexFuncs(GLcontext *ctx)
{
+ /*
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
ctx->Driver.TexImage2D = _mesa_store_teximage2d;
ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+ */
}
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
#include "array_cache/acache.h"
+#include "drivers/common/driverfuncs.h"
#include "ffb_context.h"
#include "ffb_dd.h"
__DRIscreenPrivate *sPriv;
ffbScreenPrivate *ffbScreen;
char *debug;
+ struct dd_function_table functions;
/* Allocate ffb context */
fmesa = (ffbContextPtr) CALLOC(sizeof(ffbContextRec));
if (!fmesa)
return GL_FALSE;
+ _mesa_init_driver_functions(&functions);
+
/* Allocate Mesa context */
if (sharedContextPrivate)
shareCtx = ((ffbContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- fmesa->glCtx = _mesa_create_context(mesaVis, shareCtx, fmesa, GL_TRUE);
+ fmesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, fmesa);
if (!fmesa->glCtx) {
FREE(fmesa);
return GL_FALSE;
_swsetup_CreateContext( ctx );
/* All of this need only be done once for a new context. */
+ /* XXX these should be moved right after the
+ * _mesa_init_driver_functions() call above.
+ */
ffbDDExtensionsInit(ctx);
ffbDDInitDriverFuncs(ctx);
ffbDDInitStateFuncs(ctx);
ffbDDInitDepthFuncs(ctx);
ffbDDInitStencilFuncs(ctx);
ffbDDInitRenderFuncs(ctx);
- ffbDDInitTexFuncs(ctx);
+ /*ffbDDInitTexFuncs(ctx); not needed */
ffbDDInitBitmapFuncs(ctx);
ffbInitVB(ctx);
gammaDDInitTriFuncs( ctx );
gammaDDInitState( gmesa );
+ gammaInitTextureObjects( ctx );
+
driContextPriv->driverPrivate = (void *)gmesa;
GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
void gammaInitHW( gammaContextPtr gmesa );
void gammaDDInitStateFuncs( GLcontext *ctx );
void gammaDDInitTextureFuncs( struct dd_function_table *table );
+void gammaInitTextureObjects( GLcontext *ctx );
void gammaDDInitTriFuncs( GLcontext *ctx );
void gammaUpdateWindow( GLcontext *ctx );
texImage);
}
-#if 0
-/* no longer needed */
static void gammaBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
if (target == GL_TEXTURE_2D) {
t->TextureAddressMode |= TAM_TexMapType_2D;
t->TextureReadMode |= TRM_TexMapType_2D;
- } else
- if (target == GL_TEXTURE_1D) {
+ }
+ else if (target == GL_TEXTURE_1D) {
t->TextureAddressMode |= TAM_TexMapType_1D;
t->TextureReadMode |= TRM_TexMapType_1D;
}
gammaSetTexBorderColor( gmesa, t, tObj->_BorderChan );
}
}
-#endif
static void gammaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
* 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 *
gammaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
- gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
struct gl_texture_object *obj;
- gammaTextureObjectPtr t;
-
obj = _mesa_new_texture_object(ctx, name, target);
- if (!obj)
- return NULL;
-
- t = CALLOC_STRUCT(gamma_texture_object_t);
- if (!t) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
-
- /* Initialize non-image-dependent parts of the state:
- */
- t->globj = obj;
- obj->DriverData = t;
-
- t->TextureAddressMode = TextureAddressModeEnable | TAM_Operation_3D |
- TAM_DY_Enable | TAM_LODEnable;
- t->TextureReadMode = TextureReadModeEnable | TRM_PrimaryCacheEnable |
- TRM_MipMapEnable | TRM_BorderClamp | TRM_Border;
- t->TextureColorMode = TextureColorModeEnable;
- t->TextureFilterMode = TextureFilterModeEnable;
-
- if (target == GL_TEXTURE_2D) {
- t->TextureAddressMode |= TAM_TexMapType_2D;
- t->TextureReadMode |= TRM_TexMapType_2D;
- }
- else if (target == GL_TEXTURE_1D) {
- t->TextureAddressMode |= TAM_TexMapType_1D;
- t->TextureReadMode |= TRM_TexMapType_1D;
- }
-
- t->TextureColorMode = TextureColorModeEnable;
-
- t->TextureFilterMode = TextureFilterModeEnable;
-
-#ifdef MESA_LITTLE_ENDIAN
- t->TextureFormat = (TF_LittleEndian |
-#else
- t->TextureFormat = (TF_BigEndian |
-#endif
- TF_ColorOrder_RGB |
- TF_OutputFmt_Texel);
-
- t->dirty_images = ~0;
-
- make_empty_list( t );
-
- gammaSetTexWrapping( t, obj->WrapS, obj->WrapT );
- gammaSetTexFilter( gmesa, t, obj->MinFilter, obj->MagFilter,
- ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias);
-
- gammaSetTexBorderColor( gmesa, t, obj->_BorderChan );
-
return obj;
}
-
-#if 0
-/* no longer needed */
void gammaInitTextureObjects( GLcontext *ctx )
{
struct gl_texture_object *texObj;
ctx->Texture.CurrentUnit = tmp;
}
-#endif
void gammaDDInitTextureFuncs( struct dd_function_table *functions )
functions->TexEnv = gammaTexEnv;
functions->TexImage2D = gammaTexImage2D;
functions->TexSubImage2D = gammaTexSubImage2D;
- /*functions->BindTexture = gammaBindTexture;*/
+ functions->BindTexture = gammaBindTexture;
functions->DeleteTexture = gammaDeleteTexture;
functions->TexParameter = gammaTexParameter;
functions->IsTextureResident = gammaIsTextureResident;
i810ContextPtr imesa = I810_CONTEXT(ctx);
i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
- assert(t);
+ if (!t)
+ return;
if ( target != GL_TEXTURE_2D )
return;
struct gl_texture_image *texImage )
{
i810TextureObjectPtr t = (i810TextureObjectPtr) texObj->DriverData;
- assert(t);
if (t) {
i810SwapOutTexObj( imesa, t );
}
struct gl_texture_image *texImage )
{
driTextureObject *t = (driTextureObject *) texObj->DriverData;
- assert(t);
if (t) {
I810_FIREVERTICES( I810_CONTEXT(ctx) );
driSwapOutTextureObject( t );
struct gl_texture_image *texImage )
{
driTextureObject *t = (driTextureObject *)texObj->DriverData;
- assert(t);
if (t) {
I810_FIREVERTICES( I810_CONTEXT(ctx) );
driSwapOutTextureObject( t );
}
-#if 0
-/* not needed anymore */
static void i810BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
- assert(t);
if (!tObj->DriverData) {
i810AllocTexObj( ctx, tObj );
- }
+ }
}
-#endif
static void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
* 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 *
i810NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
struct gl_texture_object *obj;
- driTextureObject *t;
obj = _mesa_new_texture_object(ctx, name, target);
- if (!obj)
- return NULL;
- t = (driTextureObject *) i810AllocTexObj( ctx, obj );
- if (!t) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
return obj;
}
functions->ChooseTextureFormat = i810ChooseTextureFormat;
functions->TexImage2D = i810TexImage2D;
functions->TexSubImage2D = i810TexSubImage2D;
- /*functions->BindTexture = i810BindTexture;*/
+ functions->BindTexture = i810BindTexture;
functions->NewTextureObject = i810NewTextureObject;
functions->DeleteTexture = i810DeleteTexture;
functions->TexParameter = i810TexParameter;
i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
GLuint unit = ctx->Texture.CurrentUnit;
- assert(t);
+ if (!t)
+ return;
if ( target != GL_TEXTURE_2D )
return;
struct gl_texture_image *texImage )
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
- assert(t);
if (t) {
I830_FIREVERTICES( I830_CONTEXT(ctx) );
driSwapOutTextureObject( t );
struct gl_texture_image *texImage )
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
- assert(t);
if (t) {
I830_FIREVERTICES( I830_CONTEXT(ctx) );
driSwapOutTextureObject( t );
}
-#if 0
-/* no longer needed */
static void i830BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
i830AllocTexObj( tObj );
}
}
-#endif
static void i830DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
* 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 *
i830NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
struct gl_texture_object *obj;
- driTextureObject *t;
obj = _mesa_new_texture_object(ctx, name, target);
- if (!obj)
- return NULL;
- t = (driTextureObject *) i830AllocTexObj( obj );
- if (!t) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
return obj;
}
functions->ChooseTextureFormat = i830ChooseTextureFormat;
functions->TexImage2D = i830TexImage2D;
functions->TexSubImage2D = i830TexSubImage2D;
- /*functions->BindTexture = i830BindTexture;*/
+ functions->BindTexture = i830BindTexture;
functions->TexParameter = i830TexParameter;
functions->TexEnv = i830TexEnv;
functions->IsTextureResident = driIsTextureResident;
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
- assert(t);
if ( t != NULL ) {
driSwapOutTextureObject( t );
}
* created with current state before it is used, so we don't have
* to do anything now
*/
- assert(t);
if ( (t == NULL) ||
(target != GL_TEXTURE_2D &&
target != GL_TEXTURE_RECTANGLE_NV) ) {
}
-#if 0
-/* no longer needed */
static void
mgaBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
}
}
}
-#endif
static void
* Called via ctx->Driver.NewTextureObject.
* Note: this function will be called during context creation to
* allocate the default texture objects.
- * Fixup MaxAnisotropy according to user preference.
+ * 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 rmesa = MGA_CONTEXT(ctx);
struct gl_texture_object *obj;
- driTextureObject *t;
obj = _mesa_new_texture_object(ctx, name, target);
- if (!obj)
- return NULL;
- t = (driTextureObject *) mgaAllocTexObj( obj );
- if (!t) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
return obj;
}
functions->ChooseTextureFormat = mgaChooseTextureFormat;
functions->TexImage2D = mgaTexImage2D;
functions->TexSubImage2D = mgaTexSubImage2D;
- /*ctx->Driver.BindTexture = mgaBindTexture;*/
+ functions->BindTexture = mgaBindTexture;
functions->NewTextureObject = mgaNewTextureObject;
functions->DeleteTexture = mgaDeleteTexture;
- functions->IsTextureResident = driIsTextureResident;
+ functions->IsTextureResident = driIsTextureResident;
functions->TexEnv = mgaTexEnv;
functions->TexParameter = mgaTexParameter;
}
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
- assert(t);
if ( t ) {
driSwapOutTextureObject( t );
}
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
- assert(t);
if ( t ) {
driSwapOutTextureObject( (driTextureObject *) t );
}
}
}
-#if 00
-/* note needed */
static void r128BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
}
}
}
-#endif
+
static void r128DeleteTexture( GLcontext *ctx,
struct gl_texture_object *tObj )
/**
* Allocate a new texture object.
* Called via ctx->Driver.NewTextureObject.
+ * 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 *
r128NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
struct gl_texture_object *obj;
- driTextureObject *t;
obj = _mesa_new_texture_object(ctx, name, target);
- if (!obj)
- return NULL;
- t = (driTextureObject *) r128AllocTexObj(obj);
- if (!t) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
return obj;
}
functions->TexImage2D = r128TexImage2D;
functions->TexSubImage2D = r128TexSubImage2D;
functions->TexParameter = r128TexParameter;
- /*functions->BindTexture = r128BindTexture;*/
+ functions->BindTexture = r128BindTexture;
functions->NewTextureObject = r128NewTextureObject;
functions->DeleteTexture = r128DeleteTexture;
functions->IsTextureResident = driIsTextureResident;
{
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 );
}
-#if 0
-/* not needed anymore */
static void r200BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj )
{
}
}
}
-#endif
static void r200DeleteTexture( 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 *
{
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;
- }
return obj;
}
functions->TexSubImage3D = _mesa_store_texsubimage3d;
#endif
functions->NewTextureObject = r200NewTextureObject;
- /*functions->BindTexture = r200BindTexture;*/
+ functions->BindTexture = r200BindTexture;
functions->DeleteTexture = r200DeleteTexture;
functions->IsTextureResident = driIsTextureResident;
{
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:
}
-#if 00
-/* not needed anymore */
static void radeonBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj )
{
}
}
}
-#endif
+
static void radeonDeleteTexture( GLcontext *ctx,
struct gl_texture_object *texObj )
/**
* Allocate a new texture object.
* Called via ctx->Driver.NewTextureObject.
+ * 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 *
radeonNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
radeonContextPtr rmesa = RADEON_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 *) radeonAllocTexObj(obj);
- if (!t) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
return obj;
}
functions->TexSubImage2D = radeonTexSubImage2D;
functions->NewTextureObject = radeonNewTextureObject;
- /*functions->BindTexture = radeonBindTexture;*/
+ functions->BindTexture = radeonBindTexture;
functions->DeleteTexture = radeonDeleteTexture;
functions->IsTextureResident = driIsTextureResident;
struct gl_texture_object *texObj )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t = texObj->DriverData;
+ sisTexObjPtr t;
- assert(t);
+ if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
+ if ( texObj->DriverData == NULL ) {
+ sisAllocTexObj( texObj );
+ }
+ }
+
+ t = texObj->DriverData;
+ if (!t)
+ return;
if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) {
smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
smesa->clearTexCache = GL_TRUE;
t = texObj->DriverData;
- assert(t);
if (t == NULL) {
/*
* this shows the texture is default object and never be a
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t = texObj->DriverData;
+ sisTexObjPtr t;
+
+ if ( texObj->DriverData == NULL )
+ sisAllocTexObj( texObj );
+ t = texObj->DriverData;
- assert(t);
/* Note, this will call sisChooseTextureFormat */
_mesa_store_teximage1d( ctx, target, level, internalFormat,
width, border, format, type,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t = texObj->DriverData;
+ sisTexObjPtr t;
GLuint copySize;
GLint texelBytes;
const char *src;
GLubyte *dst;
- assert(t);
+ if ( texObj->DriverData == NULL )
+ sisAllocTexObj( texObj );
+ t = texObj->DriverData;
_mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
format, type, pixels, packing, texObj,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t = texObj->DriverData;
+ sisTexObjPtr t;
- assert(t);
+ if ( texObj->DriverData == NULL )
+ sisAllocTexObj( texObj );
+ t = texObj->DriverData;
/* Note, this will call sisChooseTextureFormat */
_mesa_store_teximage2d(ctx, target, level, internalFormat,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t = texObj->DriverData;
+ sisTexObjPtr t;
GLuint copySize;
GLint texelBytes;
const char *src;
int j;
GLuint soffset;
- assert(t);
+ if ( texObj->DriverData == NULL )
+ sisAllocTexObj( texObj );
+ t = texObj->DriverData;
_mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
height, format, type, pixels, packing, texObj,
* 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;
- sisTexObjPtr t;
obj = _mesa_new_texture_object(ctx, name, target);
- if (!obj)
- return NULL;
- t = (sisTexObjPtr) sisAllocTexObj( obj );
- if (!t) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
return obj;
}
}
+static tdfxTexInfo *
+fxAllocTexObjData(tdfxContextPtr fxMesa)
+{
+ tdfxTexInfo *ti;
+
+ if (!(ti = CALLOC(sizeof(tdfxTexInfo)))) {
+ _mesa_problem(NULL, "tdfx driver: out of memory");
+ return NULL;
+ }
+
+ ti->isInTM = GL_FALSE;
+
+ ti->whichTMU = TDFX_TMU_NONE;
+
+ ti->tm[TDFX_TMU0] = NULL;
+ ti->tm[TDFX_TMU1] = NULL;
+
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->magFilt = GR_TEXTUREFILTER_BILINEAR;
+
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
+
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXFALSE;
+
+ return ti;
+}
+
+
/*
* Called via glBindTexture.
*/
if (target != GL_TEXTURE_2D)
return;
+ if (!tObj->DriverData) {
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ }
+
ti = TDFX_TEXTURE_DATA(tObj);
- assert(ti);
ti->lastTimeUsed = fxMesa->texBindNumber++;
fxMesa->new_state |= TDFX_NEW_TEXTURE;
if (target != GL_TEXTURE_2D)
return;
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+
ti = TDFX_TEXTURE_DATA(tObj);
- assert(ti);
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
if (!tObj->Palette.Table)
return;
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
ti = TDFX_TEXTURE_DATA(tObj);
assert(ti);
convertPalette(ti->palette.data, &tObj->Palette);
*/
ti = TDFX_TEXTURE_DATA(texObj);
+ if (!ti) {
+ texObj->DriverData = fxAllocTexObjData(fxMesa);
+ if (!texObj->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ ti = TDFX_TEXTURE_DATA(texObj);
+ }
assert(ti);
mml = TDFX_TEXIMAGE_DATA(texImage);
tdfxMipMapLevel *mml;
GLint texelBytes;
+ if (!texObj->DriverData) {
+ _mesa_problem(ctx, "problem in fxDDTexSubImage2D");
+ return;
+ }
+
ti = TDFX_TEXTURE_DATA(texObj);
assert(ti);
mml = TDFX_TEXIMAGE_DATA(texImage);
int memNeeded;
tObj = ctx->Texture.Proxy2D;
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
ti = TDFX_TEXTURE_DATA(tObj);
assert(ti);
if (target != GL_TEXTURE_2D)
return;
+ if (!texObj->DriverData)
+ return;
+
ti = TDFX_TEXTURE_DATA(texObj);
assert(ti);
mml = &ti->mipmapLevel[lod];
* 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 *
tdfxNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
struct gl_texture_object *obj;
- tdfxTexInfo *ti;
obj = _mesa_new_texture_object(ctx, name, target);
- if (!obj)
- return NULL;
-
- if (!(ti = CALLOC(sizeof(tdfxTexInfo)))) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
-
- ti->isInTM = GL_FALSE;
-
- ti->whichTMU = TDFX_TMU_NONE;
-
- ti->tm[TDFX_TMU0] = NULL;
- ti->tm[TDFX_TMU1] = NULL;
-
- ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
- ti->magFilt = GR_TEXTUREFILTER_BILINEAR;
-
- ti->sClamp = GR_TEXTURECLAMP_WRAP;
- ti->tClamp = GR_TEXTURECLAMP_WRAP;
-
- ti->mmMode = GR_MIPMAP_NEAREST;
- ti->LODblend = FXFALSE;
-
- obj->DriverData = ti;
-
return obj;
}
fxTexInvalidate(GLcontext * ctx, struct gl_texture_object *tObj)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
- tfxTexInfo *ti = fxTMGetTexInfo(tObj);
- assert(ti);
+ tfxTexInfo *ti;
+
+ ti = fxTMGetTexInfo(tObj);
if (ti->isInTM)
fxTMMoveOutTM(fxMesa, tObj); /* TO DO: SLOW but easy to write */
fxMesa->new_state |= FX_NEW_TEXTURING;
}
+static tfxTexInfo *
+fxAllocTexObjData(fxMesaContext fxMesa)
+{
+ tfxTexInfo *ti;
+
+ if (!(ti = CALLOC(sizeof(tfxTexInfo)))) {
+ fprintf(stderr, "fxAllocTexObjData: ERROR: out of memory !\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ ti->validated = GL_FALSE;
+ ti->isInTM = GL_FALSE;
+
+ ti->whichTMU = FX_TMU_NONE;
+
+ ti->tm[FX_TMU0] = NULL;
+ ti->tm[FX_TMU1] = NULL;
+
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->maxFilt = GR_TEXTUREFILTER_BILINEAR;
+
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
+
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXFALSE;
+
+ return ti;
+}
+
void
fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj)
{
if (target != GL_TEXTURE_2D)
return;
+ if (!tObj->DriverData) {
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ }
ti = fxTMGetTexInfo(tObj);
assert(ti);
if (target != GL_TEXTURE_2D)
return;
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
ti = fxTMGetTexInfo(tObj);
assert(ti);
fprintf(stderr, "fxDDTexDel(%d, %p)\n", tObj->Name, (void *) ti);
}
- assert(ti);
+ if (!ti)
+ return;
fxTMFreeTexture(fxMesa, tObj);
fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
struct gl_texture_object *obj;
- fxTexInfo *ti;
-
obj = _mesa_new_texture_object(ctx, name, target);
- if (!obj)
- return NULL;
-
- ti = CALLOC(sizeof(tfxTexInfo));
- if (!ti) {
- _mesa_delete_texture_object(ctx, obj);
- return NULL;
- }
-
- ti->validated = GL_FALSE;
- ti->isInTM = GL_FALSE;
-
- ti->whichTMU = FX_TMU_NONE;
-
- ti->tm[FX_TMU0] = NULL;
- ti->tm[FX_TMU1] = NULL;
-
- ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
- ti->maxFilt = GR_TEXTUREFILTER_BILINEAR;
-
- ti->sClamp = GR_TEXTURECLAMP_WRAP;
- ti->tClamp = GR_TEXTURECLAMP_WRAP;
-
- ti->mmMode = GR_MIPMAP_NEAREST;
- ti->LODblend = FXFALSE;
-
- obj->DriverData = ti;
-
return obj;
}
fprintf(stderr, "fxDDTexPalette(%d, %x)\n",
tObj->Name, (GLuint) tObj->DriverData);
}
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
ti = fxTMGetTexInfo(tObj);
assert(ti);
ti->paltype = convertPalette(fxMesa, ti->palette.data, &tObj->Palette);
if ((ctx->Texture.Unit[0]._Current == ctx->Texture.Unit[0].Current2D) &&
(ctx->Texture.Unit[0]._Current != NULL)) {
struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current;
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
assert(tObj->DriverData);
fxTexInvalidate(ctx, tObj);
}
return;
}
- ti = fxTMGetTexInfo(texObj);
- assert(ti);
+ if (!texObj->DriverData) {
+ texObj->DriverData = fxAllocTexObjData(fxMesa);
+ if (!texObj->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
if (!texImage->DriverData) {
texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel));
return;
}
}
+ ti = fxTMGetTexInfo(texObj);
+
mml = FX_MIPMAP_DATA(texImage);
fxTexGetInfo(width, height, NULL, NULL, NULL, NULL,
fprintf(stderr, "fxDDTexSubImage2D: id=%d\n", texObj->Name);
}
+ if (!texObj->DriverData) {
+ _mesa_problem(ctx, "problem in fxDDTexSubImage2D");
+ return;
+ }
+
ti = fxTMGetTexInfo(texObj);
assert(ti);
mml = FX_MIPMAP_DATA(texImage);
return;
}
- ti = fxTMGetTexInfo(texObj);
- assert(ti);
+ if (!texObj->DriverData) {
+ texObj->DriverData = fxAllocTexObjData(fxMesa);
+ if (!texObj->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
if (!texImage->DriverData) {
texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel));
return;
}
}
+ ti = fxTMGetTexInfo(texObj);
mml = FX_MIPMAP_DATA(texImage);
fxTexGetInfo(width, height, NULL, NULL, NULL, NULL,