context-related cleanups (ex: _mesa_notifySwapBuffers instead of _mesa_swapbuffers)

This commit is contained in:
Brian Paul
2002-10-14 17:08:17 +00:00
parent 795ae30787
commit 60b6e4fd7e
11 changed files with 41 additions and 116 deletions

View File

@@ -936,6 +936,6 @@ void DMesaSwapBuffers (DMesaBuffer b)
{ {
/* copy/swap back buffer to front if applicable */ /* copy/swap back buffer to front if applicable */
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
_mesa_swapbuffers(ctx); _mesa_notifySwapBuffers(ctx);
vl_flip(b->the_window, b->stride, b->height); vl_flip(b->the_window, b->stride, b->height);
} }

View File

@@ -554,7 +554,7 @@ void ggiMesaSwapBuffers(void)
GGIMESADPRINT_CORE("ggiMesaSwapBuffers() called\n"); GGIMESADPRINT_CORE("ggiMesaSwapBuffers() called\n");
_mesa_swapbuffers(ctx); _mesa_notifySwapBuffers(ctx);
gl_ggiFlush(ctx); gl_ggiFlush(ctx);
ggiSetDisplayFrame(ggi_ctx->ggi_visual, ggiSetDisplayFrame(ggi_ctx->ggi_visual,

View File

@@ -1,4 +1,4 @@
/* $Id: fxapi.c,v 1.33 2002/06/15 02:38:16 brianp Exp $ */ /* $Id: fxapi.c,v 1.34 2002/10/14 17:08:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -742,7 +742,7 @@ fxMesaSwapBuffers(void)
} }
if (fxMesaCurrentCtx) { if (fxMesaCurrentCtx) {
_mesa_swapbuffers(fxMesaCurrentCtx->glCtx); _mesa_notifySwapBuffers(fxMesaCurrentCtx->glCtx);
if (fxMesaCurrentCtx->haveDoubleBuffer) { if (fxMesaCurrentCtx->haveDoubleBuffer) {

View File

@@ -1,4 +1,4 @@
/* $Id: osmesa.c,v 1.90 2002/10/11 17:41:05 brianp Exp $ */ /* $Id: osmesa.c,v 1.91 2002/10/14 17:08:27 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -305,6 +305,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
_mesa_enable_sw_extensions(&(osmesa->gl_ctx)); _mesa_enable_sw_extensions(&(osmesa->gl_ctx));
_mesa_enable_1_3_extensions(&(osmesa->gl_ctx)); _mesa_enable_1_3_extensions(&(osmesa->gl_ctx));
/*_mesa_enable_1_4_extensions(&(osmesa->gl_ctx));*/
osmesa->gl_buffer = _mesa_create_framebuffer( osmesa->gl_visual, osmesa->gl_buffer = _mesa_create_framebuffer( osmesa->gl_visual,
(GLboolean) ( osmesa->gl_visual->depthBits > 0 ), (GLboolean) ( osmesa->gl_visual->depthBits > 0 ),

View File

@@ -1,4 +1,4 @@
/* $Id: svgamesa.c,v 1.20 2002/07/09 01:22:51 brianp Exp $ */ /* $Id: svgamesa.c,v 1.21 2002/10/14 17:08:27 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -482,7 +482,7 @@ void SVGAMesaSwapBuffers( void )
copy_buffer(SVGABuffer.BackBuffer); copy_buffer(SVGABuffer.BackBuffer);
#ifndef DEV #ifndef DEV
_mesa_swapbuffers( SVGAMesa->gl_ctx ); _mesa_notifySwapBuffers( SVGAMesa->gl_ctx );
if (SVGAMesa->gl_vis->doubleBufferMode) if (SVGAMesa->gl_vis->doubleBufferMode)
#endif /* DEV */ #endif /* DEV */
{ {

View File

@@ -1,4 +1,4 @@
/* $Id: wmesa.c,v 1.39 2002/10/11 17:41:05 brianp Exp $ */ /* $Id: wmesa.c,v 1.40 2002/10/14 17:08:28 brianp Exp $ */
/* /*
* Windows (Win32) device driver for Mesa 3.4 * Windows (Win32) device driver for Mesa 3.4
@@ -1459,7 +1459,7 @@ void WMesaSwapBuffers( void )
* we have to flush any pending rendering commands first. * we have to flush any pending rendering commands first.
*/ */
if (Current && Current->gl_ctx == ctx) if (Current && Current->gl_ctx == ctx)
_mesa_swapbuffers(ctx); _mesa_notifySwapBuffers(ctx);
if (Current->db_flag) if (Current->db_flag)
wmFlush(Current); wmFlush(Current);

View File

@@ -1,4 +1,4 @@
/* $Id: xm_api.c,v 1.44 2002/10/09 19:35:11 brianp Exp $ */ /* $Id: xm_api.c,v 1.45 2002/10/14 17:08:34 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -1642,6 +1642,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
_mesa_enable_sw_extensions(ctx); _mesa_enable_sw_extensions(ctx);
_mesa_enable_1_3_extensions(ctx); _mesa_enable_1_3_extensions(ctx);
/*_mesa_enable_1_4_extensions(ctx);*/
if (CHECK_BYTE_ORDER(v)) { if (CHECK_BYTE_ORDER(v)) {
c->swapbytes = GL_FALSE; c->swapbytes = GL_FALSE;
@@ -2329,7 +2330,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
* we have to flush any pending rendering commands first. * we have to flush any pending rendering commands first.
*/ */
if (ctx && ctx->DrawBuffer == &(b->mesa_buffer)) if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
_mesa_swapbuffers(ctx); _mesa_notifySwapBuffers(ctx);
if (b->db_state) { if (b->db_state) {
#ifdef FX #ifdef FX
@@ -2395,7 +2396,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
* we have to flush any pending rendering commands first. * we have to flush any pending rendering commands first.
*/ */
if (ctx && ctx->DrawBuffer == &(b->mesa_buffer)) if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
_mesa_swapbuffers(ctx); _mesa_notifySwapBuffers(ctx);
if (b->db_state) { if (b->db_state) {
int yTop = b->height - y - height; int yTop = b->height - y - height;

View File

@@ -1,4 +1,4 @@
/* $Id: xm_dd.c,v 1.38 2002/10/11 17:41:06 brianp Exp $ */ /* $Id: xm_dd.c,v 1.39 2002/10/14 17:08:38 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -146,7 +146,7 @@ set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
ASSERT(target->db_state); ASSERT(target->db_state);
if (target->backpixmap) { if (target->backpixmap) {
/* back buffer is a pixmape */ /* back buffer is a pixmape */
target->buffer = target->backpixmap; target->buffer = target->backpixmap; /* incompatible types? */
} }
else if (target->backimage) { else if (target->backimage) {
/* back buffer is an XImage */ /* back buffer is an XImage */

View File

@@ -1,4 +1,4 @@
/* $Id: context.c,v 1.183 2002/10/11 17:41:03 brianp Exp $ */ /* $Id: context.c,v 1.184 2002/10/14 17:08:17 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -77,19 +77,6 @@ int MESA_VERBOSE = 0;
int MESA_DEBUG_FLAGS = 0; int MESA_DEBUG_FLAGS = 0;
#endif #endif
/* XFree86 stuff */
#ifdef getenv
#undef getenv
#endif
#ifdef calloc
#undef calloc
extern void *calloc(size_t, size_t);
#endif
#ifdef free
#undef free
extern void free(void *);
#endif
static void static void
free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ); free_shared_state( GLcontext *ctx, struct gl_shared_state *ss );
@@ -186,6 +173,8 @@ _mesa_notifyResize(__GLcontext *gc)
void void
_mesa_notifyDestroy(__GLcontext *gc) _mesa_notifyDestroy(__GLcontext *gc)
{ {
/* Called when the context's window/buffer is going to be destroyed. */
/* Unbind from it. */
} }
/* Called by window system just before swapping buffers. /* Called by window system just before swapping buffers.
@@ -250,28 +239,10 @@ __glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes)
if (ctx == NULL) { if (ctx == NULL) {
return NULL; return NULL;
} }
ctx->Driver.CurrentExecPrimitive=0; /* XXX why is this here??? */
ctx->imports = *imports; ctx->imports = *imports;
_mesa_init_default_exports(&(ctx->exports)); _mesa_init_default_exports(&(ctx->exports));
_mesa_initialize_context(ctx, modes, NULL, imports);
_mesa_initialize_visual(&ctx->Visual,
modes->rgbMode,
modes->doubleBufferMode,
modes->stereoMode,
modes->redBits,
modes->greenBits,
modes->blueBits,
modes->alphaBits,
modes->indexBits,
modes->depthBits,
modes->stencilBits,
modes->accumRedBits,
modes->accumGreenBits,
modes->accumBlueBits,
modes->accumAlphaBits,
0);
_mesa_initialize_context(ctx, &ctx->Visual, NULL, imports);
return ctx; return ctx;
} }
@@ -590,7 +561,7 @@ one_time_init( GLcontext *ctx )
#ifdef USE_SPARC_ASM #ifdef USE_SPARC_ASM
_mesa_init_sparc_glapi_relocs(); _mesa_init_sparc_glapi_relocs();
#endif #endif
if (ctx->imports.getenv(ctx, "MESA_DEBUG")) { if ((*ctx->imports.getenv)(ctx, "MESA_DEBUG")) {
_glapi_noop_enable_warnings(GL_TRUE); _glapi_noop_enable_warnings(GL_TRUE);
#ifndef GLX_DIRECT_RENDERING #ifndef GLX_DIRECT_RENDERING
/* libGL from before 2002/06/28 don't have this function. Someday, /* libGL from before 2002/06/28 don't have this function. Someday,
@@ -1499,13 +1470,13 @@ init_attrib_groups( GLcontext *ctx )
ctx->_Facing = 0; ctx->_Facing = 0;
/* For debug/development only */ /* For debug/development only */
ctx->NoRaster = ctx->imports.getenv(ctx, "MESA_NO_RASTER") ? GL_TRUE : GL_FALSE; ctx->NoRaster = (*ctx->imports.getenv)(ctx, "MESA_NO_RASTER") ? GL_TRUE : GL_FALSE;
ctx->FirstTimeCurrent = GL_TRUE; ctx->FirstTimeCurrent = GL_TRUE;
/* Dither disable */ /* Dither disable */
ctx->NoDither = ctx->imports.getenv(ctx, "MESA_NO_DITHER") ? GL_TRUE : GL_FALSE; ctx->NoDither = (*ctx->imports.getenv)(ctx, "MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
if (ctx->NoDither) { if (ctx->NoDither) {
if (ctx->imports.getenv(ctx, "MESA_DEBUG")) { if ((*ctx->imports.getenv)(ctx, "MESA_DEBUG")) {
_mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n"); _mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n");
} }
ctx->Color.DitherFlag = GL_FALSE; ctx->Color.DitherFlag = GL_FALSE;
@@ -1660,6 +1631,7 @@ _mesa_initialize_context( GLcontext *ctx,
const __GLimports *imports ) const __GLimports *imports )
{ {
GLuint dispatchSize; GLuint dispatchSize;
const char *c;
ASSERT(imports); ASSERT(imports);
ASSERT(imports->other); /* other points to the device driver's context */ ASSERT(imports->other); /* other points to the device driver's context */
@@ -1881,41 +1853,13 @@ _mesa_initialize_context( GLcontext *ctx,
} }
ctx->MRD = 1.0; /* Minimum resolvable depth value, for polygon offset */ ctx->MRD = 1.0; /* Minimum resolvable depth value, for polygon offset */
c = (*ctx->imports.getenv)(ctx, "MESA_DEBUG");
if (c)
add_debug_flags(c);
#if defined(MESA_TRACE) c = (*ctx->imports.getenv)(ctx, "MESA_VERBOSE");
ctx->TraceCtx = (trace_context_t *) CALLOC( sizeof(trace_context_t) ); if (c)
#if 0 add_debug_flags(c);
/* Brian: do you want to have CreateContext fail here,
or should we just trap in NewTrace (currently done)? */
if (!(ctx->TraceCtx)) {
free_shared_state(ctx, ctx->Shared);
FREE( ctx->Exec );
FREE( ctx->Save );
return GL_FALSE;
}
#endif
trInitContext(ctx->TraceCtx);
ctx->TraceDispatch = (struct _glapi_table *)
CALLOC(dispatchSize * sizeof(void*));
#if 0
if (!(ctx->TraceCtx)) {
free_shared_state(ctx, ctx->Shared);
FREE( ctx->Exec );
FREE( ctx->Save );
FREE( ctx->TraceCtx );
return GL_FALSE;
}
#endif
trInitDispatch(ctx->TraceDispatch);
#endif
if (ctx->imports.getenv(ctx, "MESA_DEBUG"))
add_debug_flags(ctx->imports.getenv(ctx, "MESA_DEBUG"));
if (ctx->imports.getenv(ctx, "MESA_VERBOSE"))
add_debug_flags(ctx->imports.getenv(ctx, "MESA_VERBOSE"));
return GL_TRUE; return GL_TRUE;
} }
@@ -1940,17 +1884,15 @@ _mesa_create_context( const GLvisual *visual,
ASSERT(imports); ASSERT(imports);
ASSERT(imports->calloc); ASSERT(imports->calloc);
ctx = (GLcontext *) imports->calloc(NULL, 1, sizeof(GLcontext)); ctx = (GLcontext *) (*imports->calloc)(NULL, 1, sizeof(GLcontext));
if (!ctx) if (!ctx)
return NULL; return NULL;
ctx->Driver.CurrentExecPrimitive = 0; /* XXX why is this here??? */
if (_mesa_initialize_context(ctx, visual, share_list, imports)) { if (_mesa_initialize_context(ctx, visual, share_list, imports)) {
return ctx; return ctx;
} }
else { else {
imports->free(NULL, ctx); (*imports->free)(NULL, ctx);
return NULL; return NULL;
} }
} }
@@ -2330,7 +2272,7 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
* information. * information.
*/ */
if (newCtx->FirstTimeCurrent) { if (newCtx->FirstTimeCurrent) {
if (newCtx->imports.getenv(newCtx, "MESA_INFO")) { if ((*newCtx->imports.getenv)(newCtx, "MESA_INFO")) {
print_info(); print_info();
} }
newCtx->FirstTimeCurrent = GL_FALSE; newCtx->FirstTimeCurrent = GL_FALSE;
@@ -2352,20 +2294,6 @@ _mesa_get_current_context( void )
} }
/*
* This should be called by device drivers just before they do a
* swapbuffers. Any pending rendering commands will be executed.
* XXX we should really rename this function to _mesa_flush() or something.
*/
void
_mesa_swapbuffers(GLcontext *ctx)
{
FLUSH_VERTICES( ctx, 0 );
}
/* /*
* Return pointer to this context's current API dispatch table. * Return pointer to this context's current API dispatch table.
* It'll either be the immediate-mode execute dispatcher or the * It'll either be the immediate-mode execute dispatcher or the

View File

@@ -1,4 +1,4 @@
/* $Id: context.h,v 1.33 2002/06/29 19:48:15 brianp Exp $ */ /* $Id: context.h,v 1.34 2002/10/14 17:08:21 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -216,10 +216,6 @@ _mesa_endDispatchOverride(__GLcontext *gc);
extern void
_mesa_swapbuffers(GLcontext *ctx);
extern struct _glapi_table * extern struct _glapi_table *
_mesa_get_dispatch(GLcontext *ctx); _mesa_get_dispatch(GLcontext *ctx);

View File

@@ -1,4 +1,4 @@
/* $Id: imports.c,v 1.18 2002/08/03 16:19:20 kschultz Exp $ */ /* $Id: imports.c,v 1.19 2002/10/14 17:08:21 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -84,12 +84,11 @@ static char * CAPI
_mesa_getenv(__GLcontext *gc, const char *var) _mesa_getenv(__GLcontext *gc, const char *var)
{ {
(void) gc; (void) gc;
/* Whacko XFree86 macro: #ifdef XFree86LOADER
*/ return xf86getenv(var);
#ifdef getenv #else
#undef getenv
#endif
return getenv(var); return getenv(var);
#endif
} }