summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-01-20 02:49:27 +0000
committerBrian Paul <[email protected]>2004-01-20 02:49:27 +0000
commitd3fd7ba8af15bead2f770d68a893449adeb11397 (patch)
tree2c92f7cb35f2776d6c461378f93b556fc1ca080d /src/mesa/main
parent988a8862c8379c0312d40353ee4b35537dff59a1 (diff)
Before calling _mesa_create_context(), initialize a dd_function_table struct
by calling _mesa_init_driver_functions() and then plugging in the driver- specific functions. In particular, make sure ctx->Driver.NewTextureObject points to the appropriate driver function so that _all_ texture objects are augmented with the driver-specific data. Put in a bunch of assertions in the texture-related driver functions that texObj->DriverData is valid. Remove old dead code in near future.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/bufferobj.c12
-rw-r--r--src/mesa/main/context.c73
-rw-r--r--src/mesa/main/context.h8
-rw-r--r--src/mesa/main/dd.h99
4 files changed, 85 insertions, 107 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0f70829ff49..25457183431 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -347,18 +347,6 @@ _mesa_init_buffer_objects( GLcontext *ctx )
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;
}
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index e554f7508e7..b2ab4916107 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -387,7 +387,8 @@ __glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes)
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;
@@ -858,14 +859,6 @@ alloc_shared_state( GLcontext *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;
@@ -1335,12 +1328,15 @@ add_newer_entrypoints(void)
/**
- * 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
@@ -1349,23 +1345,30 @@ add_newer_entrypoints(void)
* 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) );
@@ -1373,20 +1376,17 @@ _mesa_initialize_context( GLcontext *ctx,
/* 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 */
@@ -1443,33 +1443,39 @@ _mesa_initialize_context( GLcontext *ctx,
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 {
@@ -1478,6 +1484,7 @@ _mesa_create_context( const GLvisual *visual,
}
}
+
/**
* Free the data associated with the given context.
*
@@ -1531,12 +1538,13 @@ _mesa_free_context_data( GLcontext *ctx )
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 )
@@ -1547,6 +1555,7 @@ _mesa_destroy_context( GLcontext *ctx )
}
}
+
#if _HAVE_FULL_GL
/**
* Copy attribute groups from one context to another.
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index d6d7920bb4f..e55b383dec6 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -133,15 +133,15 @@ _mesa_destroy_framebuffer( GLframebuffer *buffer );
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 );
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index e9826abd6d2..60b16db10f2 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -58,6 +58,9 @@ struct gl_pixelstore_attrib;
*
* 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 {
/**
@@ -77,36 +80,6 @@ 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.
*
* Mesa uses this to determine when the driver's window size has changed.
@@ -123,6 +96,13 @@ struct dd_function_table {
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 (*Finish)( GLcontext *ctx );
@@ -133,11 +113,19 @@ struct dd_function_table {
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 );
/**
@@ -505,23 +493,17 @@ struct dd_function_table {
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 );
@@ -627,6 +609,8 @@ struct dd_function_table {
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 */
@@ -656,6 +640,8 @@ struct dd_function_table {
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 */
@@ -708,6 +694,11 @@ struct dd_function_table {
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 );
+ /*@}*/
+
+
/*@}*/
@@ -847,6 +838,12 @@ struct dd_function_table {
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().
*
* Let the T&L component know what is going on with display lists
@@ -874,22 +871,6 @@ struct dd_function_table {
*/
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 );
- /*@}*/
-
};