updates for Mesa 3.3

This commit is contained in:
Brian Paul 1999-11-19 22:26:52 +00:00
parent 9fd022a905
commit 0498682406
2 changed files with 49 additions and 55 deletions

View File

@ -1,4 +1,4 @@
/* $Id: context.c,v 1.20 1999/11/15 22:21:47 brianp Exp $ */ /* $Id: context.c,v 1.21 1999/11/19 22:26:52 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@ -93,23 +93,12 @@
#ifdef THREADS #ifdef THREADS
#include "mthreads.h" /* Mesa platform independent threads interface */ #include "mthreads.h"
static MesaTSD mesa_ctx_tsd; static MesaTSD mesa_ctx_tsd;
static void mesa_ctx_thread_init() { static void mesa_ctx_thread_init() {
MesaInitTSD(&mesa_ctx_tsd); MesaInitTSD(&mesa_ctx_tsd);
} }
GLcontext *gl_get_thread_context( void ) {
return (GLcontext *) MesaGetTSD(&mesa_ctx_tsd);
}
static void set_thread_context( GLcontext *ctx ) {
MesaSetTSD(&mesa_ctx_tsd, ctx, mesa_ctx_thread_init);
}
#else #else
/* One Current Context pointer for all threads in the address space */ /* One Current Context pointer for all threads in the address space */
@ -1498,19 +1487,20 @@ void gl_make_current( GLcontext *newCtx, GLframebuffer *buffer )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(oldCtx, "gl_make_current"); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(oldCtx, "gl_make_current");
} }
#ifdef THREADS
/* TODO: unbind old buffer from context? */
set_thread_context( newCtx );
#else
if (oldCtx && oldCtx->Buffer) { if (oldCtx && oldCtx->Buffer) {
/* unbind frame buffer from context */ /* unbind frame buffer from context */
oldCtx->Buffer = NULL; oldCtx->Buffer = NULL;
} }
#ifdef THREADS
/* TODO: unbind old buffer from context? */
MesaSetTSD(&mesa_ctx_tsd, (void *) newCtx, mesa_ctx_thread_init);
#else
_mesa_current_context = newCtx; _mesa_current_context = newCtx;
#endif
if (newCtx) { if (newCtx) {
SET_IMMEDIATE(newCtx, newCtx->input); SET_IMMEDIATE(newCtx, newCtx->input);
} }
#endif
if (newCtx) if (newCtx)
_glapi_set_dispatch(newCtx->CurrentDispatch); _glapi_set_dispatch(newCtx->CurrentDispatch);
@ -1529,12 +1519,12 @@ void gl_make_current( GLcontext *newCtx, GLframebuffer *buffer )
/* /*
* Return current context handle. * Return current context handle for the calling thread.
*/ */
GLcontext *gl_get_current_context( void ) GLcontext *gl_get_current_context( void )
{ {
#ifdef THREADS #ifdef THREADS
return gl_get_thread_context(); return (GLcontext *) MesaGetTSD(&mesa_ctx_tsd);
#else #else
return _mesa_current_context; return _mesa_current_context;
#endif #endif

View File

@ -1,4 +1,4 @@
/* $Id: context.h,v 1.2 1999/11/11 01:22:25 brianp Exp $ */ /* $Id: context.h,v 1.3 1999/11/19 22:26:53 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@ -32,39 +32,6 @@
#include "types.h" #include "types.h"
#ifdef THREADS
/*
* A seperate GLcontext for each thread
*/
extern GLcontext *gl_get_thread_context( void );
#define GET_IMMEDIATE struct immediate *IM = (gl_get_thread_context())->input;
#define SET_IMMEDIATE(ctx, im) \
do { \
ctx->input = im; \
} while (0)
#else
/*
* All threads use same pointer to current context.
*/
extern GLcontext *_mesa_current_context;
extern struct immediate *CURRENT_INPUT;
#define GET_CURRENT_CONTEXT(C) GLcontext *C = _mesa_current_context
#define GET_IMMEDIATE struct immediate *IM = CURRENT_INPUT
#define SET_IMMEDIATE(ctx, im) \
do { \
ctx->input = im; \
CURRENT_INPUT = im; \
} while (0)
#endif
/* /*
* There are three Mesa datatypes which are meant to be used by device * There are three Mesa datatypes which are meant to be used by device
* drivers: * drivers:
@ -121,6 +88,10 @@ extern void gl_destroy_context( GLcontext *ctx );
*/ */
extern void gl_context_initialize( GLcontext *ctx ); extern void gl_context_initialize( GLcontext *ctx );
extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
/* /*
* Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable. * Create/destroy a GLframebuffer. A GLframebuffer is like a GLX drawable.
* It bundles up the depth buffer, stencil buffer and accum buffers into a * It bundles up the depth buffer, stencil buffer and accum buffers into a
@ -136,7 +107,40 @@ extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer );
extern GLcontext *gl_get_current_context(void); extern GLcontext *gl_get_current_context(void);
extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
#ifdef THREADS
/*
* A seperate GLcontext for each thread
*/
#define GET_CURRENT_CONTEXT(C) GLcontext *C = gl_get_current_context()
#define GET_IMMEDIATE struct immediate *IM = (gl_get_current_context())->input;
#define SET_IMMEDIATE(ctx, im) \
do { \
ctx->input = im; \
} while (0)
#else
/*
* All threads use same pointer to current context.
*/
extern GLcontext *_mesa_current_context;
extern struct immediate *CURRENT_INPUT;
#define GET_CURRENT_CONTEXT(C) GLcontext *C = _mesa_current_context
#define GET_IMMEDIATE struct immediate *IM = CURRENT_INPUT
#define SET_IMMEDIATE(ctx, im) \
do { \
ctx->input = im; \
CURRENT_INPUT = im; \
} while (0)
#endif
extern void extern void
_mesa_swapbuffers(GLcontext *ctx); _mesa_swapbuffers(GLcontext *ctx);