# This should get set in Make-config someday:
DRIVER_SOURCES = \
+ $(COMMON_DRIVER_SOURCES) \
$(X11_DRIVER_SOURCES) \
$(GLIDE_DRIVER_SOURCES) \
$(SVGA_DRIVER_SOURCES) \
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
}
+/**
+ * Called by ctx->Driver.GetBufferSize from in core Mesa to query the
+ * current framebuffer size.
+ */
static void
get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
static void
-init_core_functions( GLcontext *ctx )
+init_core_functions( struct dd_function_table *functions )
{
- ctx->Driver.GetString = get_string;
- ctx->Driver.UpdateState = update_state;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetBufferSize = get_buffer_size;
-
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.Clear = _swrast_Clear; /* could accelerate with blits */
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
-
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
- ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
- ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
- ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
- ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
- ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_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.CopyColorTable = _swrast_CopyColorTable;
- ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
- ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
- ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+ functions->GetString = get_string;
+ functions->UpdateState = update_state;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetBufferSize = get_buffer_size;
+
+ functions->Clear = _swrast_Clear; /* could accelerate with blits */
}
#define FETCH_CI_PIXEL(CI, P) \
CI = P[0]
-#include "swrast/s_spantemp.h"
+ #include "swrast/s_spantemp.h"
{
fbContextPtr fbmesa;
GLcontext *ctx, *shareCtx;
+ struct dd_function_table functions;
assert(glVisual);
assert(driContextPriv);
if ( !fbmesa )
return GL_FALSE;
+ /* Init default driver functions then plug in our FBdev-specific functions
+ */
+ _mesa_init_driver_functions(&functions);
+ init_core_functions(&functions);
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((fbContextPtr) sharedContextPrivate)->glCtx;
shareCtx = NULL;
ctx = fbmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
- (void *) fbmesa,
- GL_TRUE);
+ &functions, (void *) fbmesa);
if (!fbmesa->glCtx) {
FREE(fbmesa);
return GL_FALSE;
driContextPriv->driverPrivate = fbmesa;
/* Create module contexts */
- init_core_functions( ctx );
_swrast_CreateContext( ctx );
_ac_CreateContext( ctx );
_tnl_CreateContext( ctx );
_swsetup_Wakeup( ctx );
-
/* swrast init -- need to verify these tests - I just plucked the
* numbers out of the air. (KW)
*/
}
-
-
static void
fbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
{
}
-
-
/*
* This is the bootstrap function for the driver.
* The __driCreateScreen name is the symbol that libGL.so fetches.
* Return: pointer to a __DRIscreenPrivate.
*/
-void *__driCreateScreen(struct DRIDriverRec *driver,
- struct DRIDriverContextRec *driverContext)
+void *
+__driCreateScreen(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext)
{
__DRIscreenPrivate *psp;
psp = __driUtilCreateScreenNoDRM(driver, driverContext, &fbAPI);
}
+
/**
* \brief Establish the set of modes available for the display.
*
.depthBits = 16, .stencilBits = 0,
.numAuxBuffers= 0, .level = 0, .pixmapMode = GL_FALSE, },
};
-static int __driInitScreenModes( const DRIDriverContext *ctx,
- int *numModes, const __GLcontextModes **modes)
+
+
+static int
+__driInitScreenModes( const DRIDriverContext *ctx,
+ int *numModes, const __GLcontextModes **modes)
{
*numModes = sizeof(__glModes)/sizeof(__GLcontextModes *);
*modes = &__glModes[0];
-static int __driValidateMode(const DRIDriverContext *ctx )
+static int
+__driValidateMode(const DRIDriverContext *ctx )
{
return 1;
}
#else
# define DRM_PAGE_SIZE 4096
#endif
-
-static int __driInitFBDev( struct DRIDriverContextRec *ctx )
+
+static int
+__driInitFBDev( struct DRIDriverContextRec *ctx )
{
int id;
ctx->shared.hFrameBuffer = ctx->FBStart;
return 1;
}
-static void __driHaltFBDev( struct DRIDriverContextRec *ctx )
+static void
+__driHaltFBDev( struct DRIDriverContextRec *ctx )
{
}
# MINIGLX_SOURCES = server/ffb_dri.c
DRIVER_SOURCES = ffb_bitmap.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
-# $Id: Makefile.solo,v 1.1 2003/12/12 15:30:52 brianp Exp $
+# $Id: Makefile.solo,v 1.2 2004/01/20 02:49:27 brianp Exp $
# Mesa 3-D graphics library
# Version: 5.0
gamma_tris.c \
gamma_vb.c \
gamma_xmesa.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "context.h"
#include "simple_list.h"
#include "imports.h"
gammaScreenPtr gammascrn;
GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+
sizeof(XF86DRISAREARec));
+ struct dd_function_table functions;
gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) );
- if ( !gmesa ) return GL_FALSE;
+ if (!gmesa)
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our gamma-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ gammaDDInitTextureFuncs( &functions );
/* Allocate the Mesa context */
if (sharedContextPrivate)
else
shareCtx = NULL;
- gmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) gmesa, GL_TRUE);
+ gmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) gmesa);
if (!gmesa->glCtx) {
FREE(gmesa);
return GL_FALSE;
gammaInitVB( ctx );
gammaDDInitExtensions( ctx );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
gammaDDInitDriverFuncs( ctx );
gammaDDInitStateFuncs( ctx );
gammaDDInitSpanFuncs( ctx );
- gammaDDInitTextureFuncs( ctx );
gammaDDInitTriFuncs( ctx );
gammaDDInitState( gmesa );
void gammaDDInitState( gammaContextPtr gmesa );
void gammaInitHW( gammaContextPtr gmesa );
void gammaDDInitStateFuncs( GLcontext *ctx );
-void gammaDDInitTextureFuncs( GLcontext *ctx );
+void gammaDDInitTextureFuncs( struct dd_function_table *table );
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 )
{
gammaSetTexBorderColor( gmesa, t, tObj->_BorderChan );
}
}
-
+#endif
static void gammaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
return t && t->MemBlock;
}
-static void gammaInitTextureObjects( 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.
+ */
+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;
GLuint tmp = ctx->Texture.CurrentUnit;
ctx->Texture.CurrentUnit = tmp;
}
+#endif
-void gammaDDInitTextureFuncs( GLcontext *ctx )
+void gammaDDInitTextureFuncs( struct dd_function_table *functions )
{
- ctx->Driver.TexEnv = gammaTexEnv;
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = gammaTexImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = gammaTexSubImage2D;
- 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.BindTexture = gammaBindTexture;
- ctx->Driver.DeleteTexture = gammaDeleteTexture;
- ctx->Driver.TexParameter = gammaTexParameter;
- ctx->Driver.UpdateTexturePalette = 0;
- ctx->Driver.IsTextureResident = gammaIsTextureResident;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- gammaInitTextureObjects( ctx );
+ functions->TexEnv = gammaTexEnv;
+ functions->TexImage2D = gammaTexImage2D;
+ functions->TexSubImage2D = gammaTexSubImage2D;
+ /*functions->BindTexture = gammaBindTexture;*/
+ functions->DeleteTexture = gammaDeleteTexture;
+ functions->TexParameter = gammaTexParameter;
+ functions->IsTextureResident = gammaIsTextureResident;
}
i810texstate.c \
i810tris.c \
i810vb.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "i810screen.h"
#include "i810_dri.h"
i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
I810SAREAPtr saPriv = (I810SAREAPtr)
(((GLubyte *)sPriv->pSAREA) + i810Screen->sarea_priv_offset);
+ struct dd_function_table functions;
/* Allocate i810 context */
imesa = (i810ContextPtr) CALLOC_STRUCT(i810_context_t);
return GL_FALSE;
}
+ /* Init default driver functions then plug in our I810-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ i810InitTextureFuncs( &functions );
+ i810InitIoctlFuncs( &functions );
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((i810ContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- imesa->glCtx = _mesa_create_context(mesaVis, shareCtx, (void*) imesa, GL_TRUE);
+ imesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void*) imesa);
if (!imesa->glCtx) {
FREE(imesa);
return GL_FALSE;
_math_matrix_ctr( &imesa->ViewportMatrix );
driInitExtensions( ctx, card_extensions, GL_TRUE );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
i810InitStateFuncs( ctx );
- i810InitTextureFuncs( ctx );
i810InitTriFuncs( ctx );
i810InitSpanFuncs( ctx );
- i810InitIoctlFuncs( ctx );
i810InitVB( ctx );
i810InitState( ctx );
+ driInitTextureObjects( ctx, &imesa->swapped, DRI_TEXMGR_DO_TEXTURE_2D);
+
#if DO_DEBUG
I810_DEBUG = driParseDebugString( getenv( "I810_DEBUG" ),
debug_control );
i810DmaFinish( imesa );
}
-void i810InitIoctlFuncs( GLcontext *ctx )
+void i810InitIoctlFuncs( struct dd_function_table *functions )
{
- ctx->Driver.Flush = i810Flush;
- ctx->Driver.Clear = i810Clear;
- ctx->Driver.Finish = i810Finish;
+ functions->Flush = i810Flush;
+ functions->Clear = i810Clear;
+ functions->Finish = i810Finish;
}
void i810WaitAge( i810ContextPtr imesa, int age );
void i810DmaFinish( i810ContextPtr imesa );
void i810RegetLockQuiescent( i810ContextPtr imesa );
-void i810InitIoctlFuncs( GLcontext *ctx );
+void i810InitIoctlFuncs( struct dd_function_table *functions );
void i810CopyBuffer( const __DRIdrawablePrivate *dpriv );
void i810PageFlip( const __DRIdrawablePrivate *dpriv );
int i810_check_copy(int fd);
}
-static void i810SetTexBorderColor(i810TextureObjectPtr t,
- GLubyte color[4])
+static void
+i810SetTexBorderColor( i810TextureObjectPtr t, GLubyte color[4] )
{
/* Need a fallback.
*/
}
-static i810TextureObjectPtr i810AllocTexObj( GLcontext *ctx, struct gl_texture_object *texObj )
+
+
+static i810TextureObjectPtr
+i810AllocTexObj( GLcontext *ctx, struct gl_texture_object *texObj )
{
i810TextureObjectPtr t;
i810ContextPtr imesa = I810_CONTEXT(ctx);
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
- if (!t)
- return;
+
+ assert(t);
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 );
_mesa_store_teximage2d( ctx, target, level, internalFormat,
width, height, border, format, type,
pixels, packing, texObj, texImage );
-
}
static void i810TexSubImage2D( GLcontext *ctx,
struct gl_texture_image *texImage )
{
driTextureObject *t = (driTextureObject *)texObj->DriverData;
-
+ assert(t);
if (t) {
I810_FIREVERTICES( I810_CONTEXT(ctx) );
driSwapOutTextureObject( t );
_mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
height, format, type, pixels, packing, texObj,
texImage);
-
}
+#if 0
+/* not needed anymore */
static void i810BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
- if (!tObj->DriverData) {
+ assert(t);
+ if (!tObj->DriverData) {
i810AllocTexObj( ctx, tObj );
}
}
+#endif
static void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
- driTextureObject * t = (driTextureObject *) tObj->DriverData;
+ driTextureObject * t = (driTextureObject *) tObj->DriverData;
+ assert(t);
if (t) {
i810ContextPtr imesa = I810_CONTEXT( ctx );
if (imesa)
return NULL; /* never get here */
}
-void i810InitTextureFuncs( 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.
+ */
+static struct gl_texture_object *
+i810NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
-
- ctx->Driver.TexEnv = i810TexEnv;
- ctx->Driver.ChooseTextureFormat = i810ChooseTextureFormat;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = i810TexImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = i810TexSubImage2D;
- 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.BindTexture = i810BindTexture;
- ctx->Driver.DeleteTexture = i810DeleteTexture;
- ctx->Driver.TexParameter = i810TexParameter;
- ctx->Driver.UpdateTexturePalette = 0;
- ctx->Driver.IsTextureResident = driIsTextureResident;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- driInitTextureObjects( ctx, &imesa->swapped, DRI_TEXMGR_DO_TEXTURE_2D);
+ 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;
+}
+void i810InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->ChooseTextureFormat = i810ChooseTextureFormat;
+ functions->TexImage2D = i810TexImage2D;
+ functions->TexSubImage2D = i810TexSubImage2D;
+ /*functions->BindTexture = i810BindTexture;*/
+ functions->NewTextureObject = i810NewTextureObject;
+ functions->DeleteTexture = i810DeleteTexture;
+ functions->TexParameter = i810TexParameter;
+ functions->TexEnv = i810TexEnv;
+ functions->IsTextureResident = driIsTextureResident;
}
};
void i810UpdateTextureState( GLcontext *ctx );
-void i810InitTextureFuncs( GLcontext *ctx );
+void i810InitTextureFuncs( struct dd_function_table *functions );
void i810DestroyTexObj( i810ContextPtr imesa, i810TextureObjectPtr t );
int i810UploadTexImagesLocked( i810ContextPtr imesa, i810TextureObjectPtr t );
i830_texmem.c \
i830_texstate.c \
i830_tris.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "i830_screen.h"
#include "i830_dri.h"
i830ScreenPrivate *screen = (i830ScreenPrivate *)sPriv->private;
I830SAREAPtr saPriv=(I830SAREAPtr)
(((GLubyte *)sPriv->pSAREA)+screen->sarea_priv_offset);
+ struct dd_function_table functions;
/* Allocate i830 context */
imesa = (i830ContextPtr) CALLOC_STRUCT(i830_context_t);
- if (!imesa) return GL_FALSE;
+ if (!imesa)
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our I830-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ i830InitIoctlFuncs(&functions);
+ i830InitTextureFuncs(&functions);
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((i830ContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- imesa->glCtx = _mesa_create_context(mesaVis, shareCtx, (void*) imesa, GL_TRUE);
+ imesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void*) imesa);
if (!imesa->glCtx) {
FREE(imesa);
return GL_FALSE;
ctx->Const.MaxTextureImageUnits = 2;
ctx->Const.MaxTextureCoordUnits = 2;
- /* FIXME: driCalcualteMaxTextureLevels assumes that mipmaps are tightly
+ /* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are tightly
* FIXME: packed, but they're not in Intel graphics hardware.
*/
driCalculateMaxTextureLevels( imesa->texture_heaps,
_math_matrix_ctr (&imesa->ViewportMatrix);
driInitExtensions( ctx, card_extensions, GL_TRUE );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
i830DDInitStateFuncs( ctx );
- i830DDInitTextureFuncs( ctx );
i830InitTriFuncs (ctx);
i830DDInitSpanFuncs( ctx );
- i830DDInitIoctlFuncs( ctx );
i830DDInitState (ctx);
+ driInitTextureObjects( ctx, & imesa->swapped,
+ DRI_TEXMGR_DO_TEXTURE_2D
+ | DRI_TEXMGR_DO_TEXTURE_RECT );
+
#if DO_DEBUG
I830_DEBUG = driParseDebugString( getenv( "I830_DEBUG" ),
debug_control );
FALLBACK(imesa, I830_FALLBACK_USER, 1);
}
-
return GL_TRUE;
}
return drmCommandNone(fd, DRM_I830_DOCOPY);
}
-static void i830DDFlush( GLcontext *ctx )
+static void i830Flush( GLcontext *ctx )
{
i830ContextPtr imesa = I830_CONTEXT( ctx );
I830_FIREVERTICES( imesa );
}
-static void i830DDFinish( GLcontext *ctx )
+static void i830Finish( GLcontext *ctx )
{
i830ContextPtr imesa = I830_CONTEXT( ctx );
i830DmaFinish( imesa );
}
-void i830DDInitIoctlFuncs( GLcontext *ctx )
+void i830InitIoctlFuncs( struct dd_function_table *functions )
{
- ctx->Driver.Flush = i830DDFlush;
- ctx->Driver.Clear = i830Clear;
- ctx->Driver.Finish = i830DDFinish;
+ functions->Flush = i830Flush;
+ functions->Clear = i830Clear;
+ functions->Finish = i830Finish;
}
void i830WaitAge( i830ContextPtr imesa, int age );
void i830DmaFinish( i830ContextPtr imesa );
void i830RegetLockQuiescent( i830ContextPtr imesa );
-void i830DDInitIoctlFuncs( GLcontext *ctx );
+void i830InitIoctlFuncs( struct dd_function_table *functions );
void i830CopyBuffer( const __DRIdrawablePrivate *dpriv );
void i830PageFlip( const __DRIdrawablePrivate *dpriv );
int i830_check_copy(int fd);
i830ContextPtr imesa = I830_CONTEXT(ctx);
i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
GLuint unit = ctx->Texture.CurrentUnit;
- if (!t)
- return;
+
+ assert(t);
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 )
{
driTextureObject * t = (driTextureObject *) tObj->DriverData;
-
+ assert(t);
if ( t != NULL ) {
i830ContextPtr imesa = I830_CONTEXT( ctx );
return NULL; /* never get here */
}
-void i830DDInitTextureFuncs( 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.
+ */
+static struct gl_texture_object *
+i830NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
- i830ContextPtr imesa = I830_CONTEXT(ctx);
+ 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;
+}
- ctx->Driver.TexEnv = i830TexEnv;
- ctx->Driver.ChooseTextureFormat = i830ChooseTextureFormat;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = i830TexImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = i830TexSubImage2D;
- 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.BindTexture = i830BindTexture;
- ctx->Driver.DeleteTexture = i830DeleteTexture;
- ctx->Driver.TexParameter = i830TexParameter;
- ctx->Driver.UpdateTexturePalette = NULL;
- ctx->Driver.IsTextureResident = driIsTextureResident;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- driInitTextureObjects( ctx, & imesa->swapped,
- DRI_TEXMGR_DO_TEXTURE_2D
- | DRI_TEXMGR_DO_TEXTURE_RECT );
+void i830InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->NewTextureObject = i830NewTextureObject;
+ functions->DeleteTexture = i830DeleteTexture;
+ functions->ChooseTextureFormat = i830ChooseTextureFormat;
+ functions->TexImage2D = i830TexImage2D;
+ functions->TexSubImage2D = i830TexSubImage2D;
+ /*functions->BindTexture = i830BindTexture;*/
+ functions->TexParameter = i830TexParameter;
+ functions->TexEnv = i830TexEnv;
+ functions->IsTextureResident = driIsTextureResident;
}
};
void i830UpdateTextureState( GLcontext *ctx );
-void i830DDInitTextureFuncs( GLcontext *ctx );
+void i830InitTextureFuncs( struct dd_function_table *functions );
void i830DestroyTexObj( i830ContextPtr imesa, i830TextureObjectPtr t );
int i830UploadTexImagesLocked( i830ContextPtr imesa, i830TextureObjectPtr t );
mgarender.c \
mgastate.c \
mgatris.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "mgadd.h"
#include "mgastate.h"
#include "mgatex.h"
mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private;
MGASAREAPrivPtr saPriv=(MGASAREAPrivPtr)(((char*)sPriv->pSAREA)+
mgaScreen->sarea_priv_offset);
+ struct dd_function_table functions;
if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
fprintf(stderr, "mgaCreateContext\n");
return GL_FALSE;
}
+ /* Init default driver functions then plug in our Radeon-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ mgaInitDriverFuncs( &functions );
+ mgaInitTextureFuncs( &functions );
+ mgaInitIoctlFuncs( &functions );
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((mgaContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- mmesa->glCtx = _mesa_create_context(mesaVis, shareCtx, (void *) mmesa, GL_TRUE);
+ mmesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void *) mmesa);
if (!mmesa->glCtx) {
FREE(mmesa);
return GL_FALSE;
driInitExtensions( ctx, g400_extensions, GL_FALSE );
}
+ /* XXX these should really go right after _mesa_init_driver_functions() */
mgaDDInitStateFuncs( ctx );
- mgaDDInitTextureFuncs( ctx );
mgaDDInitSpanFuncs( ctx );
- mgaDDInitDriverFuncs( ctx );
- mgaDDInitIoctlFuncs( ctx );
mgaDDInitPixelFuncs( ctx );
mgaDDInitTriFuncs( ctx );
+ driInitTextureObjects( ctx, & mmesa->swapped,
+ (DRI_TEXMGR_DO_TEXTURE_2D |
+ DRI_TEXMGR_DO_TEXTURE_RECT) );
+
mgaInitVB( ctx );
mgaInitState( mmesa );
***************************************/
-static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name )
+static const GLubyte *mgaGetString( GLcontext *ctx, GLenum name )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
static char buffer[128];
}
-
static void mgaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
{
GET_CURRENT_CONTEXT(ctx);
UNLOCK_HARDWARE( mmesa );
}
-void mgaDDInitDriverFuncs( GLcontext *ctx )
+
+void mgaInitDriverFuncs( struct dd_function_table *functions )
{
- ctx->Driver.GetBufferSize = mgaBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetString = mgaDDGetString;
+ functions->GetBufferSize = mgaBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetString = mgaGetString;
}
#include "context.h"
-void mgaDDInitDriverFuncs( GLcontext *ctx );
+extern void mgaInitDriverFuncs( struct dd_function_table *functions );
#endif
static void
-mgaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
/* This is overkill
*/
-void mgaDDFinish( GLcontext *ctx )
+void mgaFinish( GLcontext *ctx )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-void mgaDDFlush( GLcontext *ctx )
+void mgaFlush( GLcontext *ctx )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
}
}
-void mgaDDInitIoctlFuncs( GLcontext *ctx )
+void mgaInitIoctlFuncs( struct dd_function_table *functions )
{
- ctx->Driver.Clear = mgaDDClear;
- ctx->Driver.Flush = mgaDDFlush;
- ctx->Driver.Finish = mgaDDFinish;
+ functions->Clear = mgaClear;
+ functions->Flush = mgaFlush;
+ functions->Finish = mgaFinish;
}
void mgaDDFlush( GLcontext *ctx );
void mgaDDFinish( GLcontext *ctx );
-void mgaDDInitIoctlFuncs( GLcontext *ctx );
+void mgaInitIoctlFuncs( struct dd_function_table *functions );
#define FLUSH_BATCH(mmesa) do { \
if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) \
#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;
-
+ assert(t);
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
*/
-
+ assert(t);
if ( (t == NULL) ||
(target != GL_TEXTURE_2D &&
target != GL_TEXTURE_RECTANGLE_NV) ) {
}
+#if 0
+/* no longer needed */
static void
-mgaDDBindTexture( GLcontext *ctx, GLenum target,
+mgaBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
if ( target == GL_TEXTURE_2D ||
}
}
}
+#endif
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;
+ assert(t);
if ( t ) {
if ( mmesa ) {
FLUSH_BATCH( mmesa );
}
-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.
+ * Fixup MaxAnisotropy according to user preference.
+ */
+static struct gl_texture_object *
+mgaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ 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;
+}
- 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;
+ /*ctx->Driver.BindTexture = mgaBindTexture;*/
+ functions->NewTextureObject = mgaNewTextureObject;
+ functions->DeleteTexture = mgaDeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+ functions->TexEnv = mgaTexEnv;
+ functions->TexParameter = mgaTexParameter;
}
void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t );
-void mgaDDInitTextureFuncs( GLcontext *ctx );
+void mgaInitTextureFuncs( struct dd_function_table *functions );
GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit );
r128_span.c \
r128_texmem.c \
r128_vb.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "r128_context.h"
#include "r128_ioctl.h"
#include "r128_dd.h"
{
GLcontext *ctx, *shareCtx;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ struct dd_function_table functions;
r128ContextPtr rmesa;
r128ScreenPtr r128scrn;
int i;
if ( !rmesa )
return GL_FALSE;
+ /* Init default driver functions then plug in our Radeon-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ r128InitDriverFuncs( &functions );
+ r128InitIoctlFuncs( &functions );
+ r128InitTextureFuncs( &functions );
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((r128ContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) rmesa, GL_TRUE);
+ rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) rmesa);
if (!rmesa->glCtx) {
FREE(rmesa);
return GL_FALSE;
r128InitVB( ctx );
r128InitTriFuncs( ctx );
- r128DDInitDriverFuncs( ctx );
- r128DDInitIoctlFuncs( ctx );
r128DDInitStateFuncs( ctx );
r128DDInitSpanFuncs( ctx );
- r128DDInitTextureFuncs( ctx );
r128DDInitState( rmesa );
+ driInitTextureObjects( ctx, & rmesa->swapped,
+ DRI_TEXMGR_DO_TEXTURE_1D
+ | DRI_TEXMGR_DO_TEXTURE_2D );
+
rmesa->vblank_flags = (rmesa->r128Screen->irq != 0)
? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
/* Return the width and height of the current color buffer.
*/
-static void r128DDGetBufferSize( GLframebuffer *buffer,
+static void r128GetBufferSize( GLframebuffer *buffer,
GLuint *width, GLuint *height )
{
GET_CURRENT_CONTEXT(ctx);
/* Return various strings for glGetString().
*/
-static const GLubyte *r128DDGetString( GLcontext *ctx, GLenum name )
+static const GLubyte *r128GetString( GLcontext *ctx, GLenum name )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
static char buffer[128];
* hardware. All commands that are normally sent to the ring are
* already considered `flushed'.
*/
-static void r128DDFlush( GLcontext *ctx )
+static void r128Flush( GLcontext *ctx )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
/* Make sure all commands have been sent to the hardware and have
* completed processing.
*/
-static void r128DDFinish( GLcontext *ctx )
+static void r128Finish( GLcontext *ctx )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
rmesa->c_drawWaits++;
#endif
- r128DDFlush( ctx );
+ r128Flush( ctx );
r128WaitForIdle( rmesa );
}
/* Initialize the driver's misc functions.
*/
-void r128DDInitDriverFuncs( GLcontext *ctx )
+void r128InitDriverFuncs( struct dd_function_table *functions )
{
- ctx->Driver.GetBufferSize = r128DDGetBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetString = r128DDGetString;
- ctx->Driver.Finish = r128DDFinish;
- ctx->Driver.Flush = r128DDFlush;
- ctx->Driver.Error = NULL;
+ functions->GetBufferSize = r128GetBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetString = r128GetString;
+ functions->Finish = r128Finish;
+ functions->Flush = r128Flush;
}
#ifdef GLX_DIRECT_RENDERING
-extern void r128DDInitDriverFuncs( GLcontext *ctx );
+extern void r128InitDriverFuncs( struct dd_function_table *functions );
#endif
#endif
* Buffer clear
*/
-static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+static void r128Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
}
}
-void r128DDInitIoctlFuncs( GLcontext *ctx )
+void r128InitIoctlFuncs( struct dd_function_table *functions )
{
- ctx->Driver.Clear = r128DDClear;
+ functions->Clear = r128Clear;
}
extern void r128WaitForIdleLocked( r128ContextPtr rmesa );
-extern void r128DDInitIoctlFuncs( GLcontext *ctx );
+extern void r128InitIoctlFuncs( struct dd_function_table *functions );
/* ================================================================
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ assert(t);
if ( t ) {
driSwapOutTextureObject( t );
}
{
driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ assert(t);
if ( t ) {
driSwapOutTextureObject( (driTextureObject *) t );
}
}
-static void r128DDTexEnv( GLcontext *ctx, GLenum target,
+static void r128TexEnv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
}
-static void r128DDTexParameter( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params )
+static void r128TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
}
}
-static void r128DDBindTexture( GLcontext *ctx, GLenum target,
+#if 00
+/* note needed */
+static void r128BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
}
}
}
+#endif
-static void r128DDDeleteTexture( GLcontext *ctx,
+static void r128DeleteTexture( GLcontext *ctx,
struct gl_texture_object *tObj )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
driTextureObject * t = (driTextureObject *) tObj->DriverData;
+ assert(t);
if ( t ) {
if ( t->bound && rmesa ) {
FLUSH_BATCH( rmesa );
_mesa_delete_texture_object(ctx, tObj);
}
-void r128DDInitTextureFuncs( GLcontext *ctx )
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ */
+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;
+}
-
- ctx->Driver.TexEnv = r128DDTexEnv;
- ctx->Driver.ChooseTextureFormat = r128ChooseTextureFormat;
- ctx->Driver.TexImage1D = r128TexImage1D;
- ctx->Driver.TexSubImage1D = r128TexSubImage1D;
- ctx->Driver.TexImage2D = r128TexImage2D;
- ctx->Driver.TexSubImage2D = r128TexSubImage2D;
- 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 = r128DDTexParameter;
- ctx->Driver.BindTexture = r128DDBindTexture;
- ctx->Driver.DeleteTexture = r128DDDeleteTexture;
- ctx->Driver.UpdateTexturePalette = NULL;
- ctx->Driver.ActiveTexture = NULL;
- ctx->Driver.IsTextureResident = driIsTextureResident;
- ctx->Driver.PrioritizeTexture = NULL;
-
- driInitTextureObjects( ctx, & rmesa->swapped,
- DRI_TEXMGR_DO_TEXTURE_1D
- | DRI_TEXMGR_DO_TEXTURE_2D );
+void r128InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->TexEnv = r128TexEnv;
+ functions->ChooseTextureFormat = r128ChooseTextureFormat;
+ functions->TexImage1D = r128TexImage1D;
+ functions->TexSubImage1D = r128TexSubImage1D;
+ functions->TexImage2D = r128TexImage2D;
+ functions->TexSubImage2D = r128TexSubImage2D;
+ functions->TexParameter = r128TexParameter;
+ /*functions->BindTexture = r128BindTexture;*/
+ functions->NewTextureObject = r128NewTextureObject;
+ functions->DeleteTexture = r128DeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
}
+
extern void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t );
-extern void r128DDInitTextureFuncs( GLcontext *ctx );
+extern void r128InitTextureFuncs( struct dd_function_table *functions );
/* ================================================================
r200_screen.c \
r200_state.c \
r200_state_init.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "r200_context.h"
#include "r200_ioctl.h"
#include "r200_state.h"
/* Initialize the driver's misc functions.
*/
-static void r200InitDriverFuncs( GLcontext *ctx )
+static void r200InitDriverFuncs( struct dd_function_table *functions )
{
- ctx->Driver.GetBufferSize = r200GetBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetString = r200GetString;
+ functions->GetBufferSize = r200GetBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetString = r200GetString;
- ctx->Driver.Error = NULL;
- ctx->Driver.DrawPixels = NULL;
- ctx->Driver.Bitmap = NULL;
+ functions->Error = NULL;
+ functions->DrawPixels = NULL;
+ functions->Bitmap = NULL;
}
static const struct dri_debug_control debug_control[] =
}
-/* Create the device specific context.
+/* Create the device specific rendering context.
*/
GLboolean r200CreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
{
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
r200ScreenPtr screen = (r200ScreenPtr)(sPriv->private);
+ struct dd_function_table functions;
r200ContextPtr rmesa;
GLcontext *ctx, *shareCtx;
int i;
if ( !rmesa )
return GL_FALSE;
- /* Allocate the Mesa context */
+ /* Parse configuration files.
+ * Do this here so that initialMaxAnisotropy is set before we create
+ * the default textures.
+ */
+ driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
+ screen->driScreen->myNum, "r200");
+ rmesa->initialMaxAnisotropy = driQueryOptionf(&rmesa->optionCache,
+ "def_max_anisotropy");
+
+ /* Init default driver functions then plug in our R200-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ r200InitDriverFuncs(&functions);
+ r200InitIoctlFuncs(&functions);
+ r200InitStateFuncs(&functions);
+ r200InitTextureFuncs(&functions);
+
+ /* Allocate and initialize the Mesa context */
if (sharedContextPrivate)
shareCtx = ((r200ContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) rmesa, GL_TRUE);
+ rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) rmesa);
if (!rmesa->glCtx) {
FREE(rmesa);
return GL_FALSE;
rmesa->dri.fd = sPriv->fd;
rmesa->dri.drmMinor = sPriv->drmMinor;
- /* Parse configuration files */
- driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
- screen->driScreen->myNum, "r200");
-
rmesa->r200Screen = screen;
rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA +
screen->sarea_priv_offset);
make_empty_list( & rmesa->swapped );
rmesa->nr_heaps = 1 /* screen->numTexHeaps */ ;
+ assert(rmesa->nr_heaps < R200_NR_TEX_HEAPS);
for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa,
screen->texSize[i],
if (rmesa->r200Screen->drmSupportsCubeMaps)
_mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
+#if 0
r200InitDriverFuncs( ctx );
r200InitIoctlFuncs( ctx );
r200InitStateFuncs( ctx );
- r200InitSpanFuncs( ctx );
- r200InitPixelFuncs( ctx );
r200InitTextureFuncs( ctx );
+#endif
+ /* plug in a few more device driver functions */
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ r200InitPixelFuncs( ctx );
+ r200InitSpanFuncs( ctx );
+ r200InitTnlFuncs( ctx );
r200InitState( rmesa );
r200InitSwtcl( ctx );
+ /* used to be in r200InitTextureFuncs() */
+ driInitTextureObjects( ctx, & rmesa->swapped,
+ DRI_TEXMGR_DO_TEXTURE_1D
+ | DRI_TEXMGR_DO_TEXTURE_2D );
+
fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode");
rmesa->iw.irq_seq = -1;
rmesa->irqsEmitted = 0;
driTexHeap * texture_heaps[ R200_NR_TEX_HEAPS ];
driTextureObject swapped;
int texture_depth;
-
+ float initialMaxAnisotropy;
/* Rasterization and vertex state:
*/
-void r200InitIoctlFuncs( GLcontext *ctx )
+void r200InitIoctlFuncs( struct dd_function_table *functions )
{
- ctx->Driver.Clear = r200Clear;
- ctx->Driver.Finish = r200Finish;
- ctx->Driver.Flush = r200Flush;
+ functions->Clear = r200Clear;
+ functions->Finish = r200Finish;
+ functions->Flush = r200Flush;
}
extern void r200Finish( GLcontext *ctx );
extern void r200WaitForIdleLocked( r200ContextPtr rmesa );
extern void r200WaitForVBlank( r200ContextPtr rmesa );
-extern void r200InitIoctlFuncs( GLcontext *ctx );
+extern void r200InitIoctlFuncs( struct dd_function_table *functions );
extern void *r200AllocateMemoryMESA( GLsizei size, GLfloat readfreq,
GLfloat writefreq, GLfloat priority );
/* Initialize the driver's state functions.
*/
-void r200InitStateFuncs( GLcontext *ctx )
+void r200InitStateFuncs( struct dd_function_table *functions )
{
- ctx->Driver.UpdateState = r200InvalidateState;
- ctx->Driver.LightingSpaceChange = r200LightingSpaceChange;
-
- ctx->Driver.DrawBuffer = r200DrawBuffer;
- ctx->Driver.ReadBuffer = r200ReadBuffer;
-
- ctx->Driver.AlphaFunc = r200AlphaFunc;
- ctx->Driver.BlendEquation = r200BlendEquation;
- ctx->Driver.BlendFunc = r200BlendFunc;
- ctx->Driver.BlendFuncSeparate = r200BlendFuncSeparate;
- ctx->Driver.ClearColor = r200ClearColor;
- ctx->Driver.ClearDepth = NULL;
- ctx->Driver.ClearIndex = NULL;
- ctx->Driver.ClearStencil = r200ClearStencil;
- ctx->Driver.ClipPlane = r200ClipPlane;
- ctx->Driver.ColorMask = r200ColorMask;
- ctx->Driver.CullFace = r200CullFace;
- ctx->Driver.DepthFunc = r200DepthFunc;
- ctx->Driver.DepthMask = r200DepthMask;
- ctx->Driver.DepthRange = r200DepthRange;
- ctx->Driver.Enable = r200Enable;
- ctx->Driver.Fogfv = r200Fogfv;
- ctx->Driver.FrontFace = r200FrontFace;
- ctx->Driver.Hint = NULL;
- ctx->Driver.IndexMask = NULL;
- ctx->Driver.LightModelfv = r200LightModelfv;
- ctx->Driver.Lightfv = r200Lightfv;
- ctx->Driver.LineStipple = r200LineStipple;
- ctx->Driver.LineWidth = r200LineWidth;
- ctx->Driver.LogicOpcode = r200LogicOpCode;
- ctx->Driver.PolygonMode = r200PolygonMode;
- ctx->Driver.PolygonOffset = r200PolygonOffset;
- ctx->Driver.PolygonStipple = r200PolygonStipple;
- ctx->Driver.PointSize = r200PointSize;
- ctx->Driver.RenderMode = r200RenderMode;
- ctx->Driver.Scissor = r200Scissor;
- ctx->Driver.ShadeModel = r200ShadeModel;
- ctx->Driver.StencilFunc = r200StencilFunc;
- ctx->Driver.StencilMask = r200StencilMask;
- ctx->Driver.StencilOp = r200StencilOp;
- ctx->Driver.Viewport = r200Viewport;
+ functions->UpdateState = r200InvalidateState;
+ functions->LightingSpaceChange = r200LightingSpaceChange;
+
+ functions->DrawBuffer = r200DrawBuffer;
+ functions->ReadBuffer = r200ReadBuffer;
+
+ functions->AlphaFunc = r200AlphaFunc;
+ functions->BlendEquation = r200BlendEquation;
+ functions->BlendFunc = r200BlendFunc;
+ functions->BlendFuncSeparate = r200BlendFuncSeparate;
+ functions->ClearColor = r200ClearColor;
+ functions->ClearDepth = NULL;
+ functions->ClearIndex = NULL;
+ functions->ClearStencil = r200ClearStencil;
+ functions->ClipPlane = r200ClipPlane;
+ functions->ColorMask = r200ColorMask;
+ functions->CullFace = r200CullFace;
+ functions->DepthFunc = r200DepthFunc;
+ functions->DepthMask = r200DepthMask;
+ functions->DepthRange = r200DepthRange;
+ functions->Enable = r200Enable;
+ functions->Fogfv = r200Fogfv;
+ functions->FrontFace = r200FrontFace;
+ functions->Hint = NULL;
+ functions->IndexMask = NULL;
+ functions->LightModelfv = r200LightModelfv;
+ functions->Lightfv = r200Lightfv;
+ functions->LineStipple = r200LineStipple;
+ functions->LineWidth = r200LineWidth;
+ functions->LogicOpcode = r200LogicOpCode;
+ functions->PolygonMode = r200PolygonMode;
+ functions->PolygonOffset = r200PolygonOffset;
+ functions->PolygonStipple = r200PolygonStipple;
+ functions->PointSize = r200PointSize;
+ functions->RenderMode = r200RenderMode;
+ functions->Scissor = r200Scissor;
+ functions->ShadeModel = r200ShadeModel;
+ functions->StencilFunc = r200StencilFunc;
+ functions->StencilMask = r200StencilMask;
+ functions->StencilOp = r200StencilOp;
+ functions->Viewport = r200Viewport;
/* 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;
+ functions->CopyColorTable = _swrast_CopyColorTable;
+ functions->CopyColorSubTable = _swrast_CopyColorSubTable;
+ functions->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
+
+void r200InitTnlFuncs( GLcontext *ctx )
+{
TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange = r200UpdateMaterial;
TNL_CONTEXT(ctx)->Driver.RunPipeline = r200WrapRunPipeline;
}
#include "r200_context.h"
extern void r200InitState( r200ContextPtr rmesa );
-extern void r200InitStateFuncs( GLcontext *ctx );
+extern void r200InitStateFuncs( struct dd_function_table *functions );
+extern void r200InitTnlFuncs( GLcontext *ctx );
extern void r200UpdateMaterial( GLcontext *ctx );
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
r200ContextPtr rmesa = R200_CONTEXT(ctx);
- GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+ GLuint size = tnl->vb.Size;
static int firsttime = 1;
if (firsttime) {
{
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;
GLuint face;
-
/* 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,
struct gl_texture_object *texObj )
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 ) );
rmesa->recheck_texgen[unit] = GL_TRUE;
}
-/* Fixup MaxAnisotropy according to user preference.
- */
-static struct gl_texture_object *r200NewTextureObject ( GLcontext *ctx,
- GLuint name,
- GLenum target ) {
- struct gl_texture_object *obj;
- obj = _mesa_new_texture_object (ctx, name, target);
- obj->MaxAnisotropy = driQueryOptionf (&R200_CONTEXT(ctx)->optionCache,
- "def_max_anisotropy");
- return obj;
-}
-
-void r200InitTextureFuncs( 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.
+ * Fixup MaxAnisotropy according to user preference.
+ */
+static struct gl_texture_object *
+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;
+ }
+ return obj;
+}
- ctx->Driver.ChooseTextureFormat = r200ChooseTextureFormat;
- ctx->Driver.TexImage1D = r200TexImage1D;
- ctx->Driver.TexImage2D = r200TexImage2D;
+void r200InitTextureFuncs( struct dd_function_table *functions )
+{
+ /* Note: we only plug in the functions we implement in the driver
+ * since _mesa_init_driver_functions() was already called.
+ */
+ functions->ChooseTextureFormat = r200ChooseTextureFormat;
+ functions->TexImage1D = r200TexImage1D;
+ functions->TexImage2D = r200TexImage2D;
#if ENABLE_HW_3D_TEXTURE
- ctx->Driver.TexImage3D = r200TexImage3D;
+ functions->TexImage3D = r200TexImage3D;
#else
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ functions->TexImage3D = _mesa_store_teximage3d;
#endif
- ctx->Driver.TexSubImage1D = r200TexSubImage1D;
- ctx->Driver.TexSubImage2D = r200TexSubImage2D;
+ functions->TexSubImage1D = r200TexSubImage1D;
+ functions->TexSubImage2D = r200TexSubImage2D;
#if ENABLE_HW_3D_TEXTURE
- ctx->Driver.TexSubImage3D = r200TexSubImage3D;
+ functions->TexSubImage3D = r200TexSubImage3D;
#else
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ functions->TexSubImage3D = _mesa_store_texsubimage3d;
#endif
- 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.NewTextureObject = r200NewTextureObject;
- ctx->Driver.BindTexture = r200BindTexture;
- ctx->Driver.CreateTexture = NULL; /* FIXME: Is this used??? */
- ctx->Driver.DeleteTexture = r200DeleteTexture;
- ctx->Driver.IsTextureResident = driIsTextureResident;
- ctx->Driver.PrioritizeTexture = NULL;
- ctx->Driver.ActiveTexture = NULL;
- ctx->Driver.UpdateTexturePalette = NULL;
-
- ctx->Driver.TexEnv = r200TexEnv;
- ctx->Driver.TexParameter = r200TexParameter;
- ctx->Driver.TexGen = r200TexGen;
+ functions->NewTextureObject = r200NewTextureObject;
+ /*functions->BindTexture = r200BindTexture;*/
+ functions->DeleteTexture = r200DeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+
+ functions->TexEnv = r200TexEnv;
+ functions->TexParameter = r200TexParameter;
+ functions->TexGen = r200TexGen;
+#if 000
+ /* moved or obsolete code */
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
driInitTextureObjects( ctx, & rmesa->swapped,
DRI_TEXMGR_DO_TEXTURE_1D
| DRI_TEXMGR_DO_TEXTURE_2D );
* default 2D texture now. */
ctx->Shared->Default2D->MaxAnisotropy = driQueryOptionf (&rmesa->optionCache,
"def_max_anisotropy");
+#endif
}
extern void r200DestroyTexObj( r200ContextPtr rmesa, r200TexObjPtr t );
-extern void r200InitTextureFuncs( GLcontext *ctx );
+extern void r200InitTextureFuncs( struct dd_function_table *functions );
#endif
#endif /* __R200_TEX_H__ */
radeon_screen.c \
radeon_state.c \
radeon_state_init.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#include "radeon_context.h"
#include "radeon_ioctl.h"
#include "radeon_state.h"
/* Initialize the driver's misc functions.
*/
-static void radeonInitDriverFuncs( GLcontext *ctx )
+static void radeonInitDriverFuncs( struct dd_function_table *functions )
{
- ctx->Driver.GetBufferSize = radeonGetBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetString = radeonGetString;
-
- ctx->Driver.Error = NULL;
- ctx->Driver.DrawPixels = NULL;
- ctx->Driver.Bitmap = NULL;
+ functions->GetBufferSize = radeonGetBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetString = radeonGetString;
}
static const struct dri_debug_control debug_control[] =
{
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
+ struct dd_function_table functions;
radeonContextPtr rmesa;
GLcontext *ctx, *shareCtx;
int i;
if ( !rmesa )
return GL_FALSE;
+ /* Parse configuration files.
+ * Do this here so that initialMaxAnisotropy is set before we create
+ * the default textures.
+ */
+ driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
+ screen->driScreen->myNum, "r200");
+ rmesa->initialMaxAnisotropy = driQueryOptionf(&rmesa->optionCache,
+ "def_max_anisotropy");
+
+ /* Init default driver functions then plug in our Radeon-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ radeonInitDriverFuncs( &functions );
+ radeonInitTextureFuncs( &functions );
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((radeonContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) rmesa, GL_TRUE);
+ rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) rmesa);
if (!rmesa->glCtx) {
FREE(rmesa);
return GL_FALSE;
rmesa->dri.fd = sPriv->fd;
rmesa->dri.drmMinor = sPriv->drmMinor;
- /* Parse configuration files */
- driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
- screen->driScreen->myNum, "radeon");
-
rmesa->radeonScreen = screen;
rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA +
screen->sarea_priv_offset);
rmesa->boxes = 0;
+ /* formerly in radeon_tex.c */
+ driInitTextureObjects( ctx, & rmesa->swapped,
+ DRI_TEXMGR_DO_TEXTURE_1D
+ | DRI_TEXMGR_DO_TEXTURE_2D );
+
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext( ctx );
if (rmesa->dri.drmMinor >= 9)
_mesa_enable_extension( ctx, "GL_NV_texture_rectangle");
- radeonInitDriverFuncs( ctx );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
radeonInitIoctlFuncs( ctx );
radeonInitStateFuncs( ctx );
radeonInitSpanFuncs( ctx );
- radeonInitTextureFuncs( ctx );
radeonInitState( rmesa );
radeonInitSwtcl( ctx );
driTexHeap * texture_heaps[ RADEON_NR_TEX_HEAPS ];
driTextureObject swapped;
int texture_depth;
-
+ float initialMaxAnisotropy;
/* Rasterization and vertex state:
*/
{
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;
GLuint face;
-
/* 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 )
_mesa_lookup_enum_by_nr( texObj->Target ) );
}
+ assert(t);
if ( t != NULL ) {
if ( rmesa ) {
RADEON_FIREVERTICES( rmesa );
rmesa->recheck_texgen[unit] = GL_TRUE;
}
-/* Fixup MaxAnisotropy according to user preference.
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
*/
-static struct gl_texture_object *radeonNewTextureObject ( GLcontext *ctx,
- GLuint name,
- GLenum target ) {
- struct gl_texture_object *obj;
- obj = _mesa_new_texture_object (ctx, name, target);
- obj->MaxAnisotropy = driQueryOptionf (&RADEON_CONTEXT(ctx)->optionCache,
- "def_max_anisotropy");
- return obj;
-}
-
-
-void radeonInitTextureFuncs( GLcontext *ctx )
+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;
+}
- ctx->Driver.ChooseTextureFormat = radeonChooseTextureFormat;
- ctx->Driver.TexImage1D = radeonTexImage1D;
- ctx->Driver.TexImage2D = radeonTexImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = radeonTexSubImage1D;
- ctx->Driver.TexSubImage2D = radeonTexSubImage2D;
- 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.NewTextureObject = radeonNewTextureObject;
- ctx->Driver.BindTexture = radeonBindTexture;
- ctx->Driver.CreateTexture = NULL; /* FIXME: Is this used??? */
- ctx->Driver.DeleteTexture = radeonDeleteTexture;
- ctx->Driver.IsTextureResident = driIsTextureResident;
- ctx->Driver.PrioritizeTexture = NULL;
- ctx->Driver.ActiveTexture = NULL;
- ctx->Driver.UpdateTexturePalette = NULL;
-
- ctx->Driver.TexEnv = radeonTexEnv;
- ctx->Driver.TexParameter = radeonTexParameter;
- ctx->Driver.TexGen = radeonTexGen;
-
- driInitTextureObjects( ctx, & rmesa->swapped,
- DRI_TEXMGR_DO_TEXTURE_1D
- | DRI_TEXMGR_DO_TEXTURE_2D );
-
- /* Hack: radeonNewTextureObject is not yet installed when the
- * default textures are created. Therefore set MaxAnisotropy of the
- * default 2D texture now. */
- ctx->Shared->Default2D->MaxAnisotropy = driQueryOptionf (&rmesa->optionCache,
- "def_max_anisotropy");
+void radeonInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->ChooseTextureFormat = radeonChooseTextureFormat;
+ functions->TexImage1D = radeonTexImage1D;
+ functions->TexImage2D = radeonTexImage2D;
+ functions->TexSubImage1D = radeonTexSubImage1D;
+ functions->TexSubImage2D = radeonTexSubImage2D;
+
+ functions->NewTextureObject = radeonNewTextureObject;
+ /*functions->BindTexture = radeonBindTexture;*/
+ functions->DeleteTexture = radeonDeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+
+ functions->TexEnv = radeonTexEnv;
+ functions->TexParameter = radeonTexParameter;
+ functions->TexGen = radeonTexGen;
}
extern void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t );
-extern void radeonInitTextureFuncs( GLcontext *ctx );
+extern void radeonInitTextureFuncs( struct dd_function_table *functions );
#endif
#endif /* __RADEON_TEX_H__ */
sis_texstate.c \
sis_tris.c \
sis_vb.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
#include "extensions.h"
#include "utils.h"
+#include "drivers/common/driverfuncs.h"
+
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "array_cache/acache.h"
sisContextPtr smesa;
sisScreenPtr sisScreen;
int i;
+ struct dd_function_table functions;
smesa = (sisContextPtr)CALLOC( sizeof(*smesa) );
- if ( smesa == NULL )
+ if (smesa == NULL)
return GL_FALSE;
+ /* Init default driver functions then plug in our SIS-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ sisInitTextureFuncs(&functions);
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((sisContextPtr)sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- smesa->glCtx = _mesa_create_context( glVisual, shareCtx, (void *) smesa,
- GL_TRUE);
- if (smesa->glCtx == NULL) {
+ smesa->glCtx = _mesa_create_context( glVisual, shareCtx,
+ &functions, (void *) smesa);
+ if (!smesa->glCtx) {
FREE(smesa);
return GL_FALSE;
}
_swrast_allow_pixel_fog( ctx, GL_TRUE );
_swrast_allow_vertex_fog( ctx, GL_FALSE );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
sisDDInitStateFuncs( ctx );
sisDDInitState( smesa ); /* Initializes smesa->zFormat, important */
sisInitVB( ctx );
sisInitTriFuncs( ctx );
- sisDDInitDriverFuncs( ctx );
sisDDInitSpanFuncs( ctx );
sisDDInitStencilFuncs( ctx );
- sisDDInitTextureFuncs( ctx );
driInitExtensions( ctx, card_extensions, GL_FALSE );
/* Return the width and height of the given buffer.
*/
static void
-sisDDGetBufferSize( GLframebuffer *buffer,
+sisGetBufferSize( GLframebuffer *buffer,
GLuint *width, GLuint *height )
{
GET_CURRENT_CONTEXT(ctx);
/* Return various strings for glGetString().
*/
static const GLubyte *
-sisDDGetString( GLcontext *ctx, GLenum name )
+sisGetString( GLcontext *ctx, GLenum name )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
static char buffer[128];
/* Send all commands to the hardware. No-op, due to mmio.
*/
static void
-sisDDFlush( GLcontext *ctx )
+sisFlush( GLcontext *ctx )
{
/* Do nothing */
}
* completed processing.
*/
static void
-sisDDFinish( GLcontext *ctx )
+sisFinish( GLcontext *ctx )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisDDFlush( ctx );
+ sisFlush( ctx );
WaitEngIdle( smesa );
}
/* Initialize the driver's misc functions.
*/
void
-sisDDInitDriverFuncs( GLcontext *ctx )
+sisInitDriverFuncs( struct dd_function_table *functions )
{
- ctx->Driver.GetBufferSize = sisDDGetBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetString = sisDDGetString;
- ctx->Driver.Finish = sisDDFinish;
- ctx->Driver.Flush = sisDDFlush;
- ctx->Driver.Error = NULL;
+ functions->GetBufferSize = sisGetBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetString = sisGetString;
+ functions->Finish = sisFinish;
+ functions->Flush = sisFlush;
}
extern void sisUpdateBufferSize( sisContextPtr smesa );
-extern void sisDDInitDriverFuncs( GLcontext *ctx );
+extern void sisInitDriverFuncs( struct dd_function_table *functions );
#endif
#endif
#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)
}
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 );
- }
- }
+ sisTexObjPtr t = texObj->DriverData;
- t = texObj->DriverData;
-
- if (t == NULL)
- return;
+ assert(t);
if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) {
smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
}
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;
smesa->clearTexCache = GL_TRUE;
t = texObj->DriverData;
+ assert(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,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t;
-
- if ( texObj->DriverData == NULL )
- sisAllocTexObj( texObj );
- t = texObj->DriverData;
+ sisTexObjPtr t = texObj->DriverData;
- /* Note, this will call sisDDChooseTextureFormat */
+ assert(t);
+ /* 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,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t;
+ sisTexObjPtr t = texObj->DriverData;
GLuint copySize;
GLint texelBytes;
- char *src, *dst;
+ const char *src;
+ GLubyte *dst;
- if ( texObj->DriverData == NULL )
- sisAllocTexObj( texObj );
- t = texObj->DriverData;
+ assert(t);
_mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
format, type, pixels, packing, 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,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t;
+ sisTexObjPtr t = texObj->DriverData;
- if ( texObj->DriverData == NULL )
- sisAllocTexObj( texObj );
- t = texObj->DriverData;
+ assert(t);
- /* 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,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t;
+ sisTexObjPtr t = texObj->DriverData;
GLuint copySize;
GLint texelBytes;
- char *src, *dst;
+ const char *src;
+ GLubyte *dst;
int j;
GLuint soffset;
- if ( texObj->DriverData == NULL )
- sisAllocTexObj( texObj );
- t = texObj->DriverData;
+ assert(t);
_mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
height, format, type, pixels, packing, texObj,
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.
+ */
+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;
}
-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;
}
#ifdef GLX_DIRECT_RENDERING
-extern void sisDDInitTextureFuncs( GLcontext *ctx );
+extern void sisInitTextureFuncs( struct dd_function_table *table );
extern void sisUpdateTextureState( GLcontext *ctx );
#endif /* GLX_DIRECT_RENDERING */
# MINIGLX_SOURCES = server/tdfx_dri.c
DRIVER_SOURCES = tdfx_context.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
#include "tdfx_dd.h"
#include "tdfx_state.h"
#include "tdfx_vb.h"
+#include "tdfx_tex.h"
#include "tdfx_tris.h"
#include "tdfx_render.h"
#include "tdfx_span.h"
#include "tdfx_texman.h"
#include "extensions.h"
-
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "array_cache/acache.h"
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
const char __driConfigOptions[] = { 0 };
const GLuint __driNConfigOptions = 0;
tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA +
sizeof(XF86DRISAREARec));
+ struct dd_function_table functions;
/* Allocate tdfx context */
fxMesa = (tdfxContextPtr) CALLOC( sizeof(tdfxContextRec) );
if (!fxMesa)
return GL_FALSE;
+ /* Init default driver functions then plug in our tdfx-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ tdfxDDInitDriverFuncs(mesaVis, &functions);
+ tdfxInitTextureFuncs(&functions);
+ tdfxInitRenderFuncs(&functions);
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx, (void *) fxMesa, GL_TRUE);
+ fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void *) fxMesa);
if (!fxMesa->glCtx) {
FREE(fxMesa);
return GL_FALSE;
_swrast_allow_vertex_fog( ctx, GL_FALSE );
tdfxDDInitExtensions( ctx );
- tdfxDDInitDriverFuncs( ctx );
- tdfxDDInitStateFuncs( ctx );
- tdfxDDInitRenderFuncs( ctx );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
tdfxDDInitSpanFuncs( ctx );
+ tdfxDDInitStateFuncs( ctx );
tdfxDDInitTriFuncs( ctx );
tdfxInitVB( ctx );
tdfxInitState( fxMesa );
#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
- ((vis.redBits == r) && \
- (vis.greenBits == g) && \
- (vis.blueBits == b) && \
- (vis.alphaBits == a))
+ ((vis->redBits == r) && \
+ (vis->greenBits == g) && \
+ (vis->blueBits == b) && \
+ (vis->alphaBits == a))
-void tdfxDDInitDriverFuncs( GLcontext *ctx )
+void tdfxDDInitDriverFuncs( const __GLcontextModes *visual,
+ struct dd_function_table *functions )
{
if ( MESA_VERBOSE & VERBOSE_DRIVER ) {
fprintf( stderr, "tdfx: %s()\n", __FUNCTION__ );
}
- ctx->Driver.GetString = tdfxDDGetString;
- ctx->Driver.GetBufferSize = tdfxDDGetBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.Error = NULL;
-
- /* Pixel path fallbacks.
- */
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ functions->GetString = tdfxDDGetString;
+ functions->GetBufferSize = tdfxDDGetBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
/* Accelerated paths
*/
- if ( VISUAL_EQUALS_RGBA(ctx->Visual, 8, 8, 8, 8) )
+ if ( VISUAL_EQUALS_RGBA(visual, 8, 8, 8, 8) )
{
- ctx->Driver.DrawPixels = tdfx_drawpixels_R8G8B8A8;
- ctx->Driver.ReadPixels = tdfx_readpixels_R8G8B8A8;
+ functions->DrawPixels = tdfx_drawpixels_R8G8B8A8;
+ functions->ReadPixels = tdfx_readpixels_R8G8B8A8;
}
- else if ( VISUAL_EQUALS_RGBA(ctx->Visual, 5, 6, 5, 0) )
+ else if ( VISUAL_EQUALS_RGBA(visual, 5, 6, 5, 0) )
{
- ctx->Driver.ReadPixels = tdfx_readpixels_R5G6B5;
+ functions->ReadPixels = tdfx_readpixels_R5G6B5;
}
- ctx->Driver.GetBooleanv = tdfxDDGetBooleanv;
- ctx->Driver.GetDoublev = tdfxDDGetDoublev;
- ctx->Driver.GetFloatv = tdfxDDGetFloatv;
- ctx->Driver.GetIntegerv = tdfxDDGetIntegerv;
- ctx->Driver.GetPointerv = NULL;
+ functions->GetBooleanv = tdfxDDGetBooleanv;
+ functions->GetDoublev = tdfxDDGetDoublev;
+ functions->GetFloatv = tdfxDDGetFloatv;
+ functions->GetIntegerv = tdfxDDGetIntegerv;
}
#include "context.h"
-extern void tdfxDDInitDriverFuncs( GLcontext *ctx );
+extern void tdfxDDInitDriverFuncs( const __GLcontextModes *visual,
+ struct dd_function_table *functions );
#endif
#endif
/* Clear the color and/or depth buffers.
*/
-static void tdfxDDClear( GLcontext *ctx,
+static void tdfxClear( GLcontext *ctx,
GLbitfield mask, GLboolean all,
GLint x, GLint y, GLint width, GLint height )
{
-static void tdfxDDFinish( GLcontext *ctx )
+static void tdfxFinish( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
UNLOCK_HARDWARE( fxMesa );
}
-static void tdfxDDFlush( GLcontext *ctx )
+static void tdfxFlush( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
-void tdfxDDInitRenderFuncs( GLcontext *ctx )
+void tdfxInitRenderFuncs( struct dd_function_table *functions )
{
- ctx->Driver.Clear = tdfxDDClear;
- ctx->Driver.Finish = tdfxDDFinish;
- ctx->Driver.Flush = tdfxDDFlush;
+ functions->Clear = tdfxClear;
+ functions->Finish = tdfxFinish;
+ functions->Flush = tdfxFlush;
}
#include "tdfx_context.h"
-extern void tdfxDDInitRenderFuncs( GLcontext *ctx );
+extern void tdfxInitRenderFuncs( struct dd_function_table *functions );
extern void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa );
/* State notification callbacks:
*/
- ctx->Driver.ClearIndex = NULL;
ctx->Driver.ClearColor = tdfxDDClearColor;
ctx->Driver.DrawBuffer = tdfxDDDrawBuffer;
ctx->Driver.ReadBuffer = tdfxDDReadBuffer;
- ctx->Driver.IndexMask = NULL;
ctx->Driver.ColorMask = tdfxDDColorMask;
ctx->Driver.AlphaFunc = tdfxDDAlphaFunc;
ctx->Driver.BlendFunc = tdfxDDBlendFunc;
ctx->Driver.BlendFuncSeparate = tdfxDDBlendFuncSeparate;
ctx->Driver.ClearDepth = tdfxDDClearDepth;
- ctx->Driver.ClearStencil = NULL;
ctx->Driver.CullFace = tdfxDDCullFace;
ctx->Driver.FrontFace = tdfxDDFrontFace;
ctx->Driver.DepthFunc = tdfxDDDepthFunc;
ctx->Driver.DepthRange = tdfxDDDepthRange;
ctx->Driver.Enable = tdfxDDEnable;
ctx->Driver.Fogfv = tdfxDDFogfv;
- ctx->Driver.Hint = NULL;
- ctx->Driver.Lightfv = NULL;
ctx->Driver.LightModelfv = tdfxDDLightModelfv;
- ctx->Driver.LineStipple = NULL;
ctx->Driver.LineWidth = tdfxDDLineWidth;
ctx->Driver.PolygonStipple = tdfxDDPolygonStipple;
ctx->Driver.RenderMode = tdfxDDRenderMode;
ctx->Driver.Scissor = tdfxDDScissor;
ctx->Driver.ShadeModel = tdfxDDShadeModel;
- ctx->Driver.BindTexture = tdfxDDBindTexture;
- ctx->Driver.DeleteTexture = tdfxDDDeleteTexture;
- ctx->Driver.TexEnv = tdfxDDTexEnv;
- ctx->Driver.TexParameter = tdfxDDTexParameter;
- ctx->Driver.ChooseTextureFormat = tdfxDDChooseTextureFormat;
- ctx->Driver.TexImage2D = tdfxDDTexImage2D;
- ctx->Driver.TexSubImage2D = tdfxDDTexSubImage2D;
- /*
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- */
-
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- 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.GetTexImage = tdfxDDGetTexImage; */
ctx->Driver.UpdateTexturePalette = tdfxDDTexturePalette;
ctx->Driver.StencilFunc = tdfxDDStencilFunc;
ctx->Driver.StencilMask = tdfxDDStencilMask;
ctx->Driver.StencilOp = tdfxDDStencilOp;
- } else {
- ctx->Driver.StencilFunc = NULL;
- ctx->Driver.StencilMask = NULL;
- ctx->Driver.StencilOp = NULL;
}
ctx->Driver.Viewport = tdfxDDViewport;
-
/* Swrast hooks for imaging extensions:
*/
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
}
-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.
*/
-
-void
-tdfxDDBindTexture(GLcontext * ctx, GLenum target,
+static void
+tdfxBindTexture(GLcontext * ctx, GLenum target,
struct gl_texture_object *tObj)
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
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;
/*
* Called via glTexEnv.
*/
-void
-tdfxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
+static void
+tdfxTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
const GLfloat * param)
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
/*
* Called via glTexParameter.
*/
-void
-tdfxDDTexParameter(GLcontext * ctx, GLenum target,
+static void
+tdfxTexParameter(GLcontext * ctx, GLenum target,
struct gl_texture_object *tObj,
GLenum pname, const GLfloat * params)
{
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:
* Here, we delete the Glide data associated with the texture.
*/
void
-tdfxDDDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj)
+tdfxDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj)
{
if (ctx && ctx->DriverCtx) {
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
* Return true if texture is resident, false otherwise.
*/
GLboolean
-tdfxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj)
+tdfxIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj)
{
tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
return (GLboolean) (ti && ti->isInTM);
void
-tdfxDDTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj)
+tdfxTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj)
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
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);
/*tdfxTexInvalidate(ctx, tObj);*/
}
#endif
-const struct gl_texture_format *
-tdfxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+static const struct gl_texture_format *
+tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
GLenum srcFormat, GLenum srcType )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
case GL_COLOR_INDEX16_EXT:
return &_mesa_texformat_ci8;
default:
- _mesa_problem(ctx, "unexpected format in tdfxDDChooseTextureFormat");
+ _mesa_problem(ctx, "unexpected format in tdfxChooseTextureFormat");
return NULL;
}
}
}
-void
-tdfxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
+static void
+tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
GLint internalFormat, GLint width, GLint height, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
const struct gl_pixelstore_attrib *packing,
*/
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);
if (!mml) {
}
-void
-tdfxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
+static void
+tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
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);
#if 0000
GLboolean
-tdfxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
+tdfxCompressedTexImage2D( GLcontext *ctx, GLenum target,
GLint level, GLsizei imageSize,
const GLvoid *data,
struct gl_texture_object *texObj,
if (target != GL_TEXTURE_2D || texImage->Border > 0)
return GL_FALSE;
- if (!texObj->DriverData)
- texObj->DriverData = fxAllocTexObjData(fxMesa);
-
ti = TDFX_TEXTURE_DATA(texObj);
+ assert(ti);
mml = &ti->mipmapLevel[level];
isCompressedFormat = tdfxDDIsCompressedGlideFormatMacro(texImage->IntFormat);
}
GLboolean
-tdfxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
+tdfxCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
GLint level, GLint xoffset,
GLint yoffset, GLsizei width,
GLint height, GLenum format,
GLboolean
-tdfxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
+tdfxTestProxyTexImage(GLcontext *ctx, GLenum target,
GLint level, GLint internalFormat,
GLenum format, GLenum type,
GLint width, GLint height,
int memNeeded;
tObj = ctx->Texture.Proxy2D;
- if (!tObj->DriverData)
- tObj->DriverData = fxAllocTexObjData(fxMesa);
ti = TDFX_TEXTURE_DATA(tObj);
+ assert(ti);
/* assign the parameters to test against */
tObj->Image[level]->Width = width;
* copy out the compressed data.
*/
void
-tdfxDDGetCompressedTexImage( GLcontext *ctx, GLenum target,
+tdfxGetCompressedTexImage( GLcontext *ctx, GLenum target,
GLint lod, void *image,
const struct gl_texture_object *texObj,
struct gl_texture_image *texImage )
if (target != GL_TEXTURE_2D)
return;
- if (!texObj->DriverData)
- return;
-
ti = TDFX_TEXTURE_DATA(texObj);
+ assert(ti);
mml = &ti->mipmapLevel[lod];
if (mml->data) {
MEMCPY(image, mml->data, mml->dataSize);
* texture format.
*/
GLint
-tdfxDDSpecificCompressedTexFormat(GLcontext *ctx,
+tdfxSpecificCompressedTexFormat(GLcontext *ctx,
GLint internalFormat,
GLint numDimensions)
{
* texture format.
*/
GLint
-tdfxDDBaseCompressedTexFormat(GLcontext *ctx,
+tdfxBaseCompressedTexFormat(GLcontext *ctx,
GLint internalFormat)
{
switch (internalFormat) {
}
return 0;
}
+
+
+
+/**
+ * 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.
+ */
+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;
+}
+
+
+void tdfxInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->BindTexture = tdfxBindTexture;
+ functions->NewTextureObject = tdfxNewTextureObject;
+ functions->DeleteTexture = tdfxDeleteTexture;
+ functions->TexEnv = tdfxTexEnv;
+ functions->TexParameter = tdfxTexParameter;
+ functions->ChooseTextureFormat = tdfxChooseTextureFormat;
+ functions->TexImage2D = tdfxTexImage2D;
+ functions->TexSubImage2D = tdfxTexSubImage2D;
+}
+
extern void
tdfxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj);
-extern void
-tdfxDDBindTexture(GLcontext * ctx, GLenum target,
- struct gl_texture_object *tObj);
extern void
tdfxDDDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj);
fxDDTexUseGlobalPalette(GLcontext * ctx, GLboolean state);
#endif
-extern void
-tdfxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
- const GLfloat * param);
-
-extern void
-tdfxDDTexParameter(GLcontext * ctx, GLenum target,
- struct gl_texture_object *tObj,
- GLenum pname, const GLfloat * params);
-
-extern const struct gl_texture_format *
-tdfxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
- GLenum srcFormat, GLenum srcType );
-
-extern void
-tdfxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
- GLint internalFormat, GLint width, GLint height,
- GLint border,
- GLenum format, GLenum type, const GLvoid * pixels,
- const struct gl_pixelstore_attrib * packing,
- struct gl_texture_object * texObj,
- struct gl_texture_image * texImage);
-
-extern void
-tdfxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
-
-#if 000
-extern GLboolean
-tdfxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
- GLint level, GLsizei imageSize,
- const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLboolean *retainInternalCopy);
-
-extern GLboolean
-tdfxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
- GLint level, GLint xoffset,
- GLint yoffset, GLsizei width,
- GLint height, GLenum format,
- GLsizei imageSize, const GLvoid *data,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage );
-#endif
-
extern GLboolean
tdfxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
GLint level, GLint internalFormat,
GLuint depth);
+extern void
+tdfxInitTextureFuncs( struct dd_function_table *functions );
+
#endif
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
#define PF_B8G8R8 1
}
-static void
-init_core_functions( GLcontext *ctx )
-{
- ctx->Driver.GetString = get_string;
- ctx->Driver.UpdateState = update_state;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetBufferSize = get_buffer_size;
-
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.Clear = _swrast_Clear; /* would be good to optimize */
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
-
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
- ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
- ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
- ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
- ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
- ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_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.CopyColorTable = _swrast_CopyColorTable;
- ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
- ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
- ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
-}
-
-
/*
* Generate code for span functions.
*/
{
GLFBDevContextPtr ctx;
GLcontext *glctx;
+ struct dd_function_table functions;
ASSERT(visual);
if (!ctx)
return NULL;
+ /* build table of device driver functions */
+ _mesa_init_driver_functions(&functions);
+ functions.GetString = get_string;
+ functions.UpdateState = update_state;
+ functions.GetBufferSize = get_buffer_size;
+
if (!_mesa_initialize_context(&ctx->glcontext, &visual->glvisual,
share ? &share->glcontext : NULL,
- (void *) ctx, GL_FALSE)) {
+ &functions, (void *) ctx)) {
_mesa_free(ctx);
return NULL;
}
/* Create module contexts */
glctx = (GLcontext *) &ctx->glcontext;
- init_core_functions( glctx );
_swrast_CreateContext( glctx );
_ac_CreateContext( glctx );
_tnl_CreateContext( glctx );
{
fxMesaContext fxMesa = NULL;
GLcontext *ctx = NULL, *shareCtx = NULL;
+ struct dd_function_table functions;
int i;
const char *str;
goto errorhandler;
}
- ctx = fxMesa->glCtx = _mesa_create_context(fxMesa->glVis,
- shareCtx,
- (void *) fxMesa, GL_TRUE);
+ _mesa_init_driver_functions(&functions);
+ ctx->Driver.
+ ctx = fxMesa->glCtx = _mesa_create_context(fxMesa->glVis, shareCtx,
+ &functions, (void *) fxMesa);
if (!ctx) {
str = "_mesa_create_context";
goto errorhandler;
fxTexInvalidate(GLcontext * ctx, struct gl_texture_object *tObj)
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
- tfxTexInfo *ti;
-
- ti = fxTMGetTexInfo(tObj);
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ assert(ti);
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);
fxMesa->texBindNumber++;
ti->lastTimeUsed = fxMesa->texBindNumber;
if (target != GL_TEXTURE_2D)
return;
- if (!tObj->DriverData)
- tObj->DriverData = fxAllocTexObjData(fxMesa);
-
ti = fxTMGetTexInfo(tObj);
+ assert(ti);
switch (pname) {
-
case GL_TEXTURE_MIN_FILTER:
switch (param) {
case GL_NEAREST:
fprintf(stderr, "fxDDTexDel(%d, %p)\n", tObj->Name, (void *) ti);
}
- if (!ti)
- return;
+ assert(ti);
fxTMFreeTexture(fxMesa, tObj);
_mesa_delete_texture_object(ctx, tObj);
}
+
+/**
+ * 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.
+ */
+struct gl_texture_object *
+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;
+}
+
+
/*
* Return true if texture is resident, false otherwise.
*/
GLboolean
fxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj)
{
- tfxTexInfo *ti = fxTMGetTexInfo(tObj);
- return (ti && ti->isInTM);
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ return (ti && ti->isInTM);
}
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);
fxTexInvalidate(ctx, tObj);
}
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;
}
- if (!texObj->DriverData) {
- texObj->DriverData = fxAllocTexObjData(fxMesa);
- if (!texObj->DriverData) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
- return;
- }
- }
ti = fxTMGetTexInfo(texObj);
+ assert(ti);
if (!texImage->DriverData) {
texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel));
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;
}
- if (!texObj->DriverData) {
- texObj->DriverData = fxAllocTexObjData(fxMesa);
- if (!texObj->DriverData) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
- return;
- }
- }
ti = fxTMGetTexInfo(texObj);
+ assert(ti);
if (!texImage->DriverData) {
texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel));
#include "math/m_vector.h"
+#include "drivers/common/driverfuncs.h"
+
/* Define some shorter names for these things.
*/
extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
GLenum, const GLfloat *);
extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *);
+extern struct gl_texture_object *fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target );
extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
extern GLboolean fxDDIsTextureResident(GLcontext *, struct gl_texture_object *);
extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
_NEW_RENDERMODE | \
_SWRAST_NEW_RASTERMASK)
+
/* one-time, per-context initialization */
static void
hook_in_driver_functions( GLcontext *ctx )
/* use default TCL pipeline */
tnl->Driver.RunPipeline = _tnl_run_pipeline;
- ctx->Driver.GetString = get_string;
- ctx->Driver.UpdateState = osmesa_update_state;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetBufferSize = get_buffer_size;
-
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.Clear = clear; /* uses _swrast_Clear */
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
-
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
- ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
- ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
- ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
- ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
- ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_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.CopyColorTable = _swrast_CopyColorTable;
- ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
- ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
- ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
-
swdd->SetBuffer = set_buffer;
/* RGB(A) span/pixel functions */
GLint accumBits, OSMesaContext sharelist )
{
OSMesaContext osmesa;
+ struct dd_function_table functions;
GLint rshift, gshift, bshift, ashift;
GLint rind, gind, bind, aind;
GLint indexBits = 0, redBits = 0, greenBits = 0, blueBits = 0, alphaBits =0;
return NULL;
}
- /* Setup these pointers here since they're using for making the default
- * and proxy texture objects. Actually, we don't really need to do
- * this since we're using the default fallback functions which
- * _mesa_initialize_context() would plug in if needed.
- */
- osmesa->mesa.Driver.NewTextureObject = _mesa_new_texture_object;
- osmesa->mesa.Driver.DeleteTexture = _mesa_delete_texture_object;
+ /* Initialize device driver function table */
+ _mesa_init_driver_functions(&functions);
+ /* override with our functions */
+ functions.GetString = get_string;
+ functions.UpdateState = osmesa_update_state;
+ functions.GetBufferSize = get_buffer_size;
+ functions.Clear = clear;
if (!_mesa_initialize_context(&osmesa->mesa,
osmesa->gl_visual,
sharelist ? &sharelist->mesa
: (GLcontext *) NULL,
- (void *) osmesa,
- GL_FALSE)) {
+ &functions, (void *) osmesa)) {
_mesa_destroy_visual( osmesa->gl_visual );
FREE(osmesa);
return NULL;
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
/* Dither not tested for Mesa 4.0 */
#ifdef DITHER
static void wmesa_update_state( GLcontext *ctx, GLuint new_state );
-static void SetFunctionPointers(GLcontext *ctx)
+static void SetFunctionPointers( struct dd_function_table *functions )
{
- struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
- ctx->Driver.GetString = get_string;
- ctx->Driver.UpdateState = wmesa_update_state;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetBufferSize = buffer_size;
-
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.Clear = clear;
-
- ctx->Driver.Flush = flush;
- ctx->Driver.ClearIndex = clear_index;
- ctx->Driver.ClearColor = clear_color;
- ctx->Driver.Enable = enable;
+ functions->GetString = get_string;
+ functions->UpdateState = wmesa_update_state;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetBufferSize = buffer_size;
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
+ functions->Clear = clear;
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
- ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
- ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
- ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
- ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
- ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
+ functions->Flush = flush;
+ functions->ClearIndex = clear_index;
+ functions->ClearColor = clear_color;
+ functions->Enable = enable;
+}
- 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.CopyColorTable = _swrast_CopyColorTable;
- ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
- ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
- ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+static void SetSWrastPointers(GLcontext *ctx)
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
swdd->SetBuffer = set_buffer;
/* Pixel/span writing functions: */
swdd->ReadRGBASpan = read_rgba_span;
swdd->ReadCI32Pixels = read_ci32_pixels;
swdd->ReadRGBAPixels = read_rgba_pixels;
-
}
+
static void wmesa_update_state( GLcontext *ctx, GLuint new_state )
{
* would be good to minimize setting all this when not needed.
*/
#ifndef SET_FPOINTERS_ONCE
- SetFunctionPointers(ctx);
+ SetFunctionPointers(&ctx->Driver);
+ SetSWrastPointers(ctx);
#if 0
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = wmesa_update_state;
RECT CR;
WMesaContext c;
GLboolean true_color_flag;
+ struct dd_function_table functions;
c = (struct wmesa_context * ) calloc(1,sizeof(struct wmesa_context));
if (!c)
if (!c->gl_visual) {
return NULL;
}
+
+ _mesa_init_driver_functions(&functions);
+ SetFunctionPointers(&functions);
/* allocate a new Mesa context */
- c->gl_ctx = _mesa_create_context( c->gl_visual, NULL, (void *) c, GL_FALSE );
+ c->gl_ctx = _mesa_create_context( c->gl_visual, NULL,
+ &functions, (void *) c );
if (!c->gl_ctx) {
_mesa_destroy_visual( c->gl_visual );
_swsetup_CreateContext( ctx );
#ifdef SET_FPOINTERS_ONCE
- SetFunctionPointers(ctx);
+ /*SetFunctionPointers(ctx);*/
+ SetSWrastPointers(ctx);
#endif // SET_FPOINTERS_ONCE
_swsetup_Wakeup( ctx );
}
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "swrast_setup/swrast_setup.h"
#include "array_cache/acache.h"
#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
#ifndef GLX_NONE_EXT
#define GLX_NONE_EXT 0x8000
-/*
+/**
* Create a new XMesaContext.
- * Input: v - XMesaVisual
- * share_list - another XMesaContext with which to share display
- * lists or NULL if no sharing is wanted.
- * Return: an XMesaContext or NULL if error.
+ * \param v the XMesaVisual
+ * \param share_list another XMesaContext with which to share display
+ * lists or NULL if no sharing is wanted.
+ * \return an XMesaContext or NULL if error.
*/
XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
{
static GLboolean firstTime = GL_TRUE;
XMesaContext c;
- GLboolean direct = GL_TRUE; /* not really */
GLcontext *mesaCtx;
+ struct dd_function_table functions;
+ TNLcontext *tnl;
if (firstTime) {
_glthread_INIT_MUTEX(_xmesa_lock);
firstTime = GL_FALSE;
}
+ /* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */
c = (XMesaContext) CALLOC_STRUCT(xmesa_context);
- if (!c) {
+ if (!c)
return NULL;
- }
mesaCtx = &(c->mesa);
- /* Setup these pointers here since they're using for making the default
- * and proxy texture objects. Actually, we don't really need to do
- * this since we're using the default fallback functions which
- * _mesa_initialize_context() would plug in if needed.
- */
- mesaCtx->Driver.NewTextureObject = _mesa_new_texture_object;
- mesaCtx->Driver.DeleteTexture = _mesa_delete_texture_object;
-
+ /* initialize with default driver functions, then plug in XMesa funcs */
+ _mesa_init_driver_functions(&functions);
+ xmesa_init_driver_functions(v, &functions);
if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual,
share_list ? &(share_list->mesa) : (GLcontext *) NULL,
- (void *) c, direct)) {
+ &functions, (void *) c)) {
FREE(c);
return NULL;
}
_mesa_enable_1_4_extensions(mesaCtx);
_mesa_enable_1_5_extensions(mesaCtx);
- if (CHECK_BYTE_ORDER(v)) {
- c->swapbytes = GL_FALSE;
- }
- else {
- c->swapbytes = GL_TRUE;
- }
-
+ /* finish up xmesa context initializations */
+ c->swapbytes = CHECK_BYTE_ORDER(v) ? GL_FALSE : GL_TRUE;
c->xm_visual = v;
c->xm_draw_buffer = NULL; /* set later by XMesaMakeCurrent */
c->xm_read_buffer = NULL; /* set later by XMesaMakeCurrent */
c->display = v->display;
c->pixelformat = v->dithered_pf; /* Dithering is enabled by default */
- mesaCtx->Driver.UpdateState = xmesa_update_state;
-
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext( mesaCtx );
_tnl_CreateContext( mesaCtx );
_swsetup_CreateContext( mesaCtx );
+ /* tnl setup */
+ tnl = TNL_CONTEXT(mesaCtx);
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
+ /* swrast setup */
xmesa_register_swrast_functions( mesaCtx );
-
- /* Set up some constant pointers:
- */
- xmesa_init_pointers( mesaCtx );
+ _swsetup_Wakeup(mesaCtx);
return c;
}
-
void XMesaDestroyContext( XMesaContext c )
{
GLcontext *mesaCtx = &c->mesa;
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
-#include "tnl/t_pipeline.h"
/*
* This chooses the color buffer for reading and writing spans, points,
* lines, and triangles.
*/
-static void
-set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
+void
+xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
{
/* We can make this cast since the XMesaBuffer wraps GLframebuffer.
* GLframebuffer is the first member in a XMesaBuffer struct.
}
-
-
-/* Setup pointers and other driver state that is constant for the life
- * of a context.
+/**
+ * Initialize the device driver function table with the functions
+ * we implement in this driver.
*/
-void xmesa_init_pointers( GLcontext *ctx )
+void xmesa_init_driver_functions( XMesaVisual xmvisual,
+ struct dd_function_table *driver )
{
- TNLcontext *tnl;
- struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference( ctx );
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
-
- /* Plug in our driver-specific functions here */
- ctx->Driver.GetString = get_string;
- ctx->Driver.GetBufferSize = get_buffer_size;
- ctx->Driver.Flush = finish_or_flush;
- ctx->Driver.Finish = finish_or_flush;
- ctx->Driver.ClearIndex = clear_index;
- ctx->Driver.ClearColor = clear_color;
- ctx->Driver.IndexMask = index_mask;
- ctx->Driver.ColorMask = color_mask;
- ctx->Driver.Enable = enable;
-
- /* Software rasterizer pixel paths:
- */
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.Clear = clear_buffers;
- ctx->Driver.ResizeBuffers = xmesa_resize_buffers;
-#ifdef XFree86Server
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
-#else
- ctx->Driver.CopyPixels = /*_swrast_CopyPixels;*/xmesa_CopyPixels;
- if (xmesa->xm_visual->undithered_pf == PF_8R8G8B &&
- xmesa->xm_visual->dithered_pf == PF_8R8G8B) {
- ctx->Driver.DrawPixels = xmesa_DrawPixels_8R8G8B;
- }
- else if (xmesa->xm_visual->undithered_pf == PF_5R6G5B) {
- ctx->Driver.DrawPixels = xmesa_DrawPixels_5R6G5B;
+ driver->GetString = get_string;
+ driver->UpdateState = xmesa_update_state;
+ driver->GetBufferSize = get_buffer_size;
+ driver->Flush = finish_or_flush;
+ driver->Finish = finish_or_flush;
+ driver->ClearIndex = clear_index;
+ driver->ClearColor = clear_color;
+ driver->IndexMask = index_mask;
+ driver->ColorMask = color_mask;
+ driver->Enable = enable;
+ driver->Clear = clear_buffers;
+ driver->ResizeBuffers = xmesa_resize_buffers;
+#ifndef XFree86Server
+ driver->CopyPixels = /*_swrast_CopyPixels;*/xmesa_CopyPixels;
+ if (xmvisual->undithered_pf == PF_8R8G8B &&
+ xmvisual->dithered_pf == PF_8R8G8B) {
+ driver->DrawPixels = xmesa_DrawPixels_8R8G8B;
}
- else {
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ else if (xmvisual->undithered_pf == PF_5R6G5B) {
+ driver->DrawPixels = xmesa_DrawPixels_5R6G5B;
}
#endif
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
-
- /* Software texture functions:
- */
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.TestProxyTexImage = test_proxy_teximage;
-
- 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.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
- ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
- ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
- ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
- ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
- ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
-
- /* 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;
-
- /* Initialize the TNL driver interface:
- */
- tnl = TNL_CONTEXT(ctx);
- tnl->Driver.RunPipeline = _tnl_run_pipeline;
-
- dd->SetBuffer = set_buffer;
-
- /* Install swsetup for tnl->Driver.Render.*:
- */
- _swsetup_Wakeup(ctx);
-
- (void) DitherValues; /* silenced unused var warning */
+ driver->TestProxyTexImage = test_proxy_teximage;
}
-
-
-
#define XMESA_NEW_POINT (_NEW_POINT | \
_NEW_RENDERMODE | \
_SWRAST_NEW_RASTERMASK)
void xmesa_register_swrast_functions( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT( ctx );
+ struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference(ctx);
+
+ dd->SetBuffer = xmesa_set_buffer;
swrast->choose_point = xmesa_choose_point;
swrast->choose_line = xmesa_choose_line;
-
/*
* Mesa 3-D graphics library
- * Version: 5.0.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
extern void xmesa_alloc_back_buffer( XMesaBuffer b );
-extern void xmesa_init_pointers( GLcontext *ctx );
+extern void xmesa_init_driver_functions( XMesaVisual xmvisual,
+ struct dd_function_table *driver );
extern void xmesa_update_state( GLcontext *ctx, GLuint new_state );
extern void xmesa_update_span_funcs( GLcontext *ctx );
+extern void xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer,
+ GLuint bufferBit );
+
/* Plugged into the software rasterizer. Try to use internal
* swrast-style point, line and triangle functions.
*/
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
ctx->Array.VertexAttrib[i].BufferObj = ctx->Array.NullBufferObj;
}
-
- /* Device drivers might override these assignments after the Mesa
- * context is initialized.
- */
- ctx->Driver.NewBufferObject = _mesa_new_buffer_object;
- ctx->Driver.DeleteBuffer = _mesa_delete_buffer_object;
- ctx->Driver.BindBuffer = NULL;
- ctx->Driver.BufferData = _mesa_buffer_data;
- ctx->Driver.BufferSubData = _mesa_buffer_subdata;
- ctx->Driver.GetBufferSubData = _mesa_buffer_get_subdata;
- ctx->Driver.MapBuffer = _mesa_buffer_map;
- ctx->Driver.UnmapBuffer = NULL;
}
return NULL;
}
- _mesa_initialize_context(ctx, modes, NULL, imports, GL_FALSE);
+ /* XXX doesn't work at this time */
+ _mesa_initialize_context(ctx, modes, NULL, NULL, NULL);
ctx->imports = *imports;
return ctx;
if (!ss->DefaultRect)
goto cleanup;
-#if 0
- _mesa_save_texture_object(ctx, ss->Default1D);
- _mesa_save_texture_object(ctx, ss->Default2D);
- _mesa_save_texture_object(ctx, ss->Default3D);
- _mesa_save_texture_object(ctx, ss->DefaultCubeMap);
- _mesa_save_texture_object(ctx, ss->DefaultRect);
-#endif
-
/* Effectively bind the default textures to all texture units */
ss->Default1D->RefCount += MAX_TEXTURE_IMAGE_UNITS;
ss->Default2D->RefCount += MAX_TEXTURE_IMAGE_UNITS;
/**
- * Initialize a GLcontext struct.
+ * Initialize a GLcontext struct (rendering context).
*
* This includes allocating all the other structs and arrays which hang off of
* the context by pointers.
+ * Note that the driver needs to pass in its dd_function_table here since
+ * we need to at least call driverFunctions->NewTextureObject to create the
+ * default texture objects.
*
- * \sa _mesa_create_context() for the parameter description.
+ * Called by _mesa_create_context().
*
* Performs the imports and exports callback tables initialization, and
* miscellaneous one-time initializations. If no shared context is supplied one
* Finally queries the \c MESA_DEBUG and \c MESA_VERBOSE environment variables
* for debug flags.
*
- * \note the direct parameter is ignored (obsolete).
+ * \param ctx the context to initialize
+ * \param visual describes the visual attributes for this context
+ * \param share_list points to context to share textures, display lists,
+ * etc with, or NULL
+ * \param driverFunctions table of device driver functions for this context
+ * to use
+ * \param driverContext pointer to driver-specific context data
*/
GLboolean
_mesa_initialize_context( GLcontext *ctx,
const GLvisual *visual,
GLcontext *share_list,
- void *driver_ctx,
- GLboolean direct )
+ const struct dd_function_table *driverFunctions,
+ void *driverContext )
{
GLuint dispatchSize;
- ASSERT(driver_ctx);
+ ASSERT(driverContext);
+ assert(driverFunctions->NewTextureObject);
/* If the driver wants core Mesa to use special imports, it'll have to
* override these defaults.
*/
- _mesa_init_default_imports( &(ctx->imports), driver_ctx );
+ _mesa_init_default_imports( &(ctx->imports), driverContext );
/* initialize the exports (Mesa functions called by the window system) */
_mesa_init_default_exports( &(ctx->exports) );
/* misc one-time initializations */
one_time_init(ctx);
- ctx->DriverCtx = driver_ctx;
ctx->Visual = *visual;
ctx->DrawBuffer = NULL;
ctx->ReadBuffer = NULL;
- /* Set these pointers to defaults now in case they're not set since
- * we need them while creating the default textures.
+ /* Plug in driver functions and context pointer here.
+ * This is important because when we call alloc_shared_state() below
+ * we'll call ctx->Driver.NewTextureObject() to create the default
+ * textures.
*/
- if (!ctx->Driver.NewTextureObject)
- ctx->Driver.NewTextureObject = _mesa_new_texture_object;
- if (!ctx->Driver.DeleteTexture)
- ctx->Driver.DeleteTexture = _mesa_delete_texture_object;
- if (!ctx->Driver.NewTextureImage)
- ctx->Driver.NewTextureImage = _mesa_new_texture_image;
+ ctx->Driver = *driverFunctions;
+ ctx->DriverCtx = driverContext;
if (share_list) {
/* share state with another context */
return GL_TRUE;
}
+
/**
* Allocate and initialize a GLcontext structure.
+ * Note that the driver needs to pass in its dd_function_table here since
+ * we need to at least call driverFunctions->NewTextureObject to initialize
+ * the rendering context.
*
* \param visual a GLvisual pointer (we copy the struct contents)
* \param share_list another context to share display lists with or NULL
- * \param driver_ctx pointer to device driver's context state struct
- * \param direct obsolete, ignored
+ * \param driverFunctions points to the dd_function_table into which the
+ * driver has plugged in all its special functions.
+ * \param driverCtx points to the device driver's private context state
*
* \return pointer to a new __GLcontextRec or NULL if error.
*/
GLcontext *
_mesa_create_context( const GLvisual *visual,
GLcontext *share_list,
- void *driver_ctx,
- GLboolean direct )
+ const struct dd_function_table *driverFunctions,
+ void *driverContext )
{
GLcontext *ctx;
ASSERT(visual);
- ASSERT(driver_ctx);
+ ASSERT(driverContext);
ctx = (GLcontext *) _mesa_calloc(sizeof(GLcontext));
if (!ctx)
return NULL;
- if (_mesa_initialize_context(ctx, visual, share_list, driver_ctx, direct)) {
+ if (_mesa_initialize_context(ctx, visual, share_list,
+ driverFunctions, driverContext)) {
return ctx;
}
else {
}
}
+
/**
* Free the data associated with the given context.
*
FREE(ctx->Save);
}
+
/**
* Destroy a GLcontext structure.
*
* \param ctx GL context.
*
- * Calls _mesa_free_context_data() and free the structure.
+ * Calls _mesa_free_context_data() and frees the GLcontext structure itself.
*/
void
_mesa_destroy_context( GLcontext *ctx )
}
}
+
#if _HAVE_FULL_GL
/**
* Copy attribute groups from one context to another.
extern GLcontext *
_mesa_create_context( const GLvisual *visual,
GLcontext *share_list,
- void *driver_ctx,
- GLboolean direct );
+ const struct dd_function_table *driverFunctions,
+ void *driverContext );
extern GLboolean
_mesa_initialize_context( GLcontext *ctx,
const GLvisual *visual,
GLcontext *share_list,
- void *driver_ctx,
- GLboolean direct );
+ const struct dd_function_table *driverFunctions,
+ void *driverContext );
extern void
_mesa_free_context_data( GLcontext *ctx );
*
* Vertex transformation/clipping/lighting is patched into the T&L module.
* Rasterization functions are patched into the swrast module.
+ *
+ * Note: when new functions are added here, the drivers/common/driverfuncs.c
+ * file should be updated too!!!
*/
struct dd_function_table {
/**
*/
void (*UpdateState)( GLcontext *ctx, GLuint new_state );
- /**
- * Clear the color/depth/stencil/accum buffer(s).
- *
- * \param mask a bitmask of the DD_*_BIT values defined above that indicates
- * which buffers need to be cleared.
- * \param all if true then clear the whole buffer, else clear only the
- * region defined by <tt>(x, y, width, height)</tt>.
- *
- * This function must obey the glColorMask(), glIndexMask() and glStencilMask()
- * settings!
- * Software Mesa can do masked clears if the device driver can't.
- */
- void (*Clear)( GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint x, GLint y, GLint width, GLint height );
-
- /**
- * Specify the current buffer for writing.
- *
- * Called via glDrawBuffer(). Note the driver must organize fallbacks (e.g.
- * with swrast) if it cannot implement the requested mode.
- */
- void (*DrawBuffer)( GLcontext *ctx, GLenum buffer );
-
- /**
- * Specifies the current buffer for reading.
- *
- * Called via glReadBuffer().
- */
- void (*ReadBuffer)( GLcontext *ctx, GLenum buffer );
-
/**
* Get the width and height of the named buffer/window.
*
*/
void (*ResizeBuffers)( GLframebuffer *buffer );
+ /**
+ * Called whenever an error is generated.
+ *
+ * __GLcontextRec::ErrorValue contains the error value.
+ */
+ void (*Error)( GLcontext *ctx );
+
/**
* This is called whenever glFinish() is called.
*/
void (*Flush)( GLcontext *ctx );
/**
- * Called whenever an error is generated.
+ * Clear the color/depth/stencil/accum buffer(s).
*
- * __GLcontextRec::ErrorValue contains the error value.
+ * \param mask a bitmask of the DD_*_BIT values defined above that indicates
+ * which buffers need to be cleared.
+ * \param all if true then clear the whole buffer, else clear only the
+ * region defined by <tt>(x, y, width, height)</tt>.
+ *
+ * This function must obey the glColorMask(), glIndexMask() and
+ * glStencilMask() settings!
+ * Software Mesa can do masked clears if the device driver can't.
*/
- void (*Error)( GLcontext *ctx );
+ void (*Clear)( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height );
/**
void (*BindTexture)( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj );
- /**
- * Called when a texture object is created.
- */
- void (*CreateTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
-
/**
* Called to allocate a new texture object.
- *
- * \note This function pointer should be initialized by drivers \e before
- * calling _mesa_initialize_context() since context initialization involves
- * allocating some texture objects!
+ * A new gl_texture_object should be returned. The driver should
+ * attach to it any device-specific info it needs.
*/
struct gl_texture_object * (*NewTextureObject)( GLcontext *ctx, GLuint name,
GLenum target );
/**
* Called when a texture object is about to be deallocated.
*
- * Driver should free anything attached to the DriverData pointers.
+ * Driver should delete the gl_texture_object object and anything
+ * hanging off of it.
*/
void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
void (*DepthMask)(GLcontext *ctx, GLboolean flag);
/** Specify mapping of depth values from normalized device coordinates to window coordinates */
void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval);
+ /** Specify the current buffer for writing */
+ void (*DrawBuffer)( GLcontext *ctx, GLenum buffer );
/** Enable or disable server-side gl capabilities */
void (*Enable)(GLcontext *ctx, GLenum cap, GLboolean state);
/** Specify fog parameters */
void (*PolygonOffset)(GLcontext *ctx, GLfloat factor, GLfloat units);
/** Set the polygon stippling pattern */
void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
+ /* Specifies the current buffer for reading */
+ void (*ReadBuffer)( GLcontext *ctx, GLenum buffer );
/** Set rasterization mode */
void (*RenderMode)(GLcontext *ctx, GLenum mode );
/** Define the scissor box */
void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
void (*VertexAttribPointer)(GLcontext *ctx, GLuint index, GLint size,
GLenum type, GLsizei stride, const GLvoid *ptr);
+ void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count );
+ void (*UnlockArraysEXT)( GLcontext *ctx );
+ /*@}*/
+
+
/*@}*/
*/
void (*LightingSpaceChange)( GLcontext *ctx );
+ /**
+ * Let the T&L component know when the context becomes current.
+ */
+ void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer );
+
/**
* Called by glNewList().
*
*/
void (*EndCallList)( GLcontext *ctx );
- /**
- * Let the T&L component know when the context becomes current.
- */
- void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
- GLframebuffer *readBuffer );
-
- /**
- * Called by glLockArraysEXT().
- */
- void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count );
- /**
- * Called by UnlockArraysEXT().
- */
- void (*UnlockArraysEXT)( GLcontext *ctx );
- /*@}*/
-
};
sparc/norm.S \
sparc/xform.S
+COMMON_DRIVER_SOURCES = \
+ drivers/common/driverfuncs.c
+
X11_DRIVER_SOURCES = \
drivers/x11/glxapi.c \
drivers/x11/fakeglx.c \