added tracing facility from Loki
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
/* $Id: glapi.c,v 1.42 2000/05/24 17:53:30 brianp Exp $ */
|
/* $Id: glapi.c,v 1.43 2000/09/05 20:17:37 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
* Version: 3.3
|
* Version: 3.5
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
|
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
|
||||||
*
|
*
|
||||||
@@ -49,6 +49,9 @@
|
|||||||
#include "glapitable.h"
|
#include "glapitable.h"
|
||||||
#include "glthread.h"
|
#include "glthread.h"
|
||||||
|
|
||||||
|
#if defined(TRACE)
|
||||||
|
#include "types.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This is used when thread safety is disabled */
|
/* This is used when thread safety is disabled */
|
||||||
struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table;
|
struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table;
|
||||||
@@ -167,6 +170,10 @@ _glapi_get_context(void)
|
|||||||
void
|
void
|
||||||
_glapi_set_dispatch(struct _glapi_table *dispatch)
|
_glapi_set_dispatch(struct _glapi_table *dispatch)
|
||||||
{
|
{
|
||||||
|
#if defined(TRACE)
|
||||||
|
GLcontext * ctx;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!dispatch) {
|
if (!dispatch) {
|
||||||
/* use the no-op functions */
|
/* use the no-op functions */
|
||||||
dispatch = (struct _glapi_table *) __glapi_noop_table;
|
dispatch = (struct _glapi_table *) __glapi_noop_table;
|
||||||
@@ -178,14 +185,36 @@ _glapi_set_dispatch(struct _glapi_table *dispatch)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(THREADS)
|
#if defined(THREADS)
|
||||||
|
#if defined(TRACE)
|
||||||
|
ctx = (GLcontext *)_glthread_GetTSD(&ContextTSD);
|
||||||
|
if (ctx->TraceCtx->traceEnabled == GL_TRUE) {
|
||||||
|
_glthread_SetTSD(&DispatchTSD, (void*) ctx->TraceDispatch);
|
||||||
|
if (ThreadSafe)
|
||||||
|
_glapi_Dispatch = NULL;
|
||||||
|
else
|
||||||
|
_glapi_Dispatch = ctx->TraceDispatch;
|
||||||
|
} else {
|
||||||
_glthread_SetTSD(&DispatchTSD, (void*) dispatch);
|
_glthread_SetTSD(&DispatchTSD, (void*) dispatch);
|
||||||
if (ThreadSafe)
|
if (ThreadSafe)
|
||||||
_glapi_Dispatch = NULL;
|
_glapi_Dispatch = NULL;
|
||||||
else
|
else
|
||||||
_glapi_Dispatch = dispatch;
|
_glapi_Dispatch = dispatch;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
_glthread_SetTSD(&DispatchTSD, (void*) dispatch);
|
||||||
|
if (ThreadSafe)
|
||||||
|
_glapi_Dispatch = NULL;
|
||||||
|
else
|
||||||
|
_glapi_Dispatch = dispatch;
|
||||||
|
#endif /*TRACE*/
|
||||||
|
#else /*THREADS*/
|
||||||
|
#if defined(TRACE)
|
||||||
|
ctx = (GLcontext *)_glthread_GetTSD(&ContextTSD);
|
||||||
|
_glapi_Dispatch = ctx->TraceDispatch;
|
||||||
#else
|
#else
|
||||||
_glapi_Dispatch = dispatch;
|
_glapi_Dispatch = dispatch;
|
||||||
#endif
|
#endif /*TRACE*/
|
||||||
|
#endif /*THREADS*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -210,6 +239,32 @@ _glapi_get_dispatch(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(TRACE)
|
||||||
|
struct _glapi_table *
|
||||||
|
_glapi_get_true_dispatch(void)
|
||||||
|
{
|
||||||
|
GLcontext* ctx;
|
||||||
|
|
||||||
|
#if defined(THREADS)
|
||||||
|
if (ThreadSafe) {
|
||||||
|
ctx = (GLcontext *) _glthread_GetTSD(&ContextTSD);
|
||||||
|
assert(ctx);
|
||||||
|
assert(ctx->CurrentDispatch);
|
||||||
|
return ctx->CurrentDispatch;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(_glapi_Context);
|
||||||
|
assert(((GLcontext *)_glapi_Context)->CurrentDispatch);
|
||||||
|
return ((GLcontext *)_glapi_Context)->CurrentDispatch;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
assert(_glapi_Context);
|
||||||
|
assert(((GLcontext *)_glapi_Context)->CurrentDispatch);
|
||||||
|
return ((GLcontext *)_glapi_Context)->CurrentDispatch;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif /* TRACE */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return size of dispatch table struct as number of functions (or
|
* Return size of dispatch table struct as number of functions (or
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/* $Id: glapi.h,v 1.14 2000/01/28 20:17:42 brianp Exp $ */
|
/* $Id: glapi.h,v 1.15 2000/09/05 20:17:37 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
* Version: 3.3
|
* Version: 3.5
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
|
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
|
||||||
*
|
*
|
||||||
@@ -59,6 +59,12 @@ extern struct _glapi_table *
|
|||||||
_glapi_get_dispatch(void);
|
_glapi_get_dispatch(void);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(TRACE)
|
||||||
|
extern struct _glapi_table *
|
||||||
|
_glapi_get_true_dispatch(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern GLuint
|
extern GLuint
|
||||||
_glapi_get_dispatch_table_size(void);
|
_glapi_get_dispatch_table_size(void);
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/* $Id: dispatch.c,v 1.15 2000/02/02 19:34:08 brianp Exp $ */
|
/* $Id: dispatch.c,v 1.16 2000/09/05 20:17:37 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
* Version: 3.3
|
* Version: 3.5
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
|
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
|
||||||
*
|
*
|
||||||
@@ -64,6 +64,7 @@
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
|
#if 0
|
||||||
static int
|
static int
|
||||||
trace(void)
|
trace(void)
|
||||||
{
|
{
|
||||||
@@ -72,26 +73,27 @@ trace(void)
|
|||||||
trace = getenv("MESA_TRACE") ? 1 : 0;
|
trace = getenv("MESA_TRACE") ? 1 : 0;
|
||||||
return trace > 0;
|
return trace > 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define F stderr
|
#define F stderr
|
||||||
|
|
||||||
#define DISPATCH(FUNC, ARGS, MESSAGE) \
|
#define DISPATCH(FUNC, ARGS, MESSAGE) \
|
||||||
const struct _glapi_table *dispatch; \
|
const struct _glapi_table *dispatch; \
|
||||||
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
|
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
|
||||||
if (trace()) { \
|
|
||||||
fprintf MESSAGE; \
|
|
||||||
fprintf(F, "\n"); \
|
|
||||||
} \
|
|
||||||
(dispatch->FUNC) ARGS
|
(dispatch->FUNC) ARGS
|
||||||
|
|
||||||
#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
|
#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
|
||||||
const struct _glapi_table *dispatch; \
|
const struct _glapi_table *dispatch; \
|
||||||
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
|
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
|
||||||
|
return (dispatch->FUNC) ARGS
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* From both macros above... */
|
||||||
if (trace()) { \
|
if (trace()) { \
|
||||||
fprintf MESSAGE; \
|
fprintf MESSAGE; \
|
||||||
fprintf(F, "\n"); \
|
fprintf(F, "\n"); \
|
||||||
} \
|
}
|
||||||
return (dispatch->FUNC) ARGS
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user