From 8d3ee211ba0b13982f831dd1ee6b53a7d07c8066 Mon Sep 17 00:00:00 2001 From: alanh Date: Thu, 6 May 2004 09:37:58 +0000 Subject: minor fixes --- xc/lib/GL/glx/Imakefile | 10 ++--- xc/lib/GL/glx/g_render.c | 2 +- xc/lib/GL/glx/glxclient.h | 1 + xc/lib/GL/glx/glxcmds.c | 12 +++--- xc/lib/GL/glx/glxext.c | 95 ++++++++++++++++++++++++++++++++++++++++++- xc/lib/GL/glx/glxextensions.h | 5 +-- xc/lib/GL/glx/packrender.h | 7 ++-- xc/lib/GL/glx/packsingle.h | 19 +++++---- xc/lib/GL/glx/packvendpriv.h | 7 ++-- xc/lib/GL/glx/single2.c | 9 ++-- 10 files changed, 131 insertions(+), 36 deletions(-) diff --git a/xc/lib/GL/glx/Imakefile b/xc/lib/GL/glx/Imakefile index 43ca2699d..e844375b9 100644 --- a/xc/lib/GL/glx/Imakefile +++ b/xc/lib/GL/glx/Imakefile @@ -31,7 +31,7 @@ XCOMM SUBDIRS = \ XCOMM glu \ XCOMM glw -# Files from Mesa +/* Files from Mesa */ LinkSourceFile(glapi.c, $(MESASRCDIR)/src/mesa/glapi) LinkSourceFile(glthread.c, $(MESASRCDIR)/src/mesa/glapi) @@ -42,10 +42,10 @@ LinkSourceFile(glapi_x86.S, $(MESASRCDIR)/src/mesa/x86) LinkSourceFile(glapi_sparc.S, $(MESASRCDIR)/src/mesa/sparc) #endif - -# Maybe some of these could come from -# xc/extras/ogl-sample/main/glx/lib at some point. - +/* + * Maybe some of these could come from + * xc/extras/ogl-sample/main/glx/lib at some point. + */ GLX_SRCS = \ clientattrib.c \ compsize.c \ diff --git a/xc/lib/GL/glx/g_render.c b/xc/lib/GL/glx/g_render.c index cd6646bac..386d308d8 100644 --- a/xc/lib/GL/glx/g_render.c +++ b/xc/lib/GL/glx/g_render.c @@ -423,8 +423,8 @@ void __indirect_gl ## name (GLenum target, GLenum pname, const type * v) \ { \ __GLX_DECLARE_VARIABLES(); \ - compsize = __gl ## name ## _size(pname); \ __GLX_LOAD_VARIABLES(); \ + compsize = __gl ## name ## _size(pname); \ cmdlen = 8 + RENDER_SIZE(type, compsize); \ __GLX_BEGIN(rop, cmdlen); \ __GLX_PUT_LONG(4, target); \ diff --git a/xc/lib/GL/glx/glxclient.h b/xc/lib/GL/glx/glxclient.h index 74dfe69c9..45bffd8cb 100644 --- a/xc/lib/GL/glx/glxclient.h +++ b/xc/lib/GL/glx/glxclient.h @@ -51,6 +51,7 @@ #include #include #include +#include #include "GL/glxint.h" #include "GL/glxproto.h" #include "GL/internal/glcore.h" diff --git a/xc/lib/GL/glx/glxcmds.c b/xc/lib/GL/glx/glxcmds.c index 50d361ed0..2713fd03d 100644 --- a/xc/lib/GL/glx/glxcmds.c +++ b/xc/lib/GL/glx/glxcmds.c @@ -1683,7 +1683,7 @@ Display *glXGetCurrentDisplay(void) } GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (), - glXGetCurrentDisplay); + glXGetCurrentDisplay) /** * Used internally by libGL to send \c xGLXQueryContextinfoExtReq requests @@ -2024,7 +2024,7 @@ void GLX_PREFIX(glXSelectEvent)(Display *dpy, GLXDrawable drawable, unsigned lon */ GLX_ALIAS(GLXDrawable, glXGetCurrentReadDrawableSGI, (void), (), - glXGetCurrentReadDrawable); + glXGetCurrentReadDrawable) /* @@ -2352,17 +2352,17 @@ void GLX_PREFIX(glXDestroyGLXVideoSourceSGIX)(Display *dpy, GLXVideoSourceSGIX s GLX_ALIAS(int, glXGetFBConfigAttribSGIX, (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value), (dpy, config, attribute, value), - glXGetFBConfigAttrib); + glXGetFBConfigAttrib) GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX, (Display *dpy, int screen, int *attrib_list, int *nelements), (dpy, screen, attrib_list, nelements), - glXChooseFBConfig); + glXChooseFBConfig) GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX, (Display * dpy, GLXFBConfigSGIX config), (dpy, config), - glXGetVisualFromFBConfig); + glXGetVisualFromFBConfig) GLXPixmap GLX_PREFIX(glXCreateGLXPixmapWithConfigSGIX)(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap) { @@ -3256,7 +3256,7 @@ void (*glXGetProcAddressARB(const GLubyte *procName))( void ) * \sa glXGetProcAddressARB */ void (*glXGetProcAddress(const GLubyte *procName))( void ) -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED) __attribute__ ((alias ("glXGetProcAddressARB"))); #else { diff --git a/xc/lib/GL/glx/glxext.c b/xc/lib/GL/glx/glxext.c index b3fb73b7d..c5ca0f208 100644 --- a/xc/lib/GL/glx/glxext.c +++ b/xc/lib/GL/glx/glxext.c @@ -71,6 +71,37 @@ void __glXDumpDrawBuffer(__GLXcontext *ctx); #endif +#ifdef USE_SPARC_ASM +/* + * This is where our dispatch table's bounds are. + * And the static mesa_init is taken directly from + * Mesa's 'sparc.c' initializer. + * + * We need something like this here, because this version + * of openGL/glx never initializes a Mesa context, and so + * the address of the dispatch table pointer never gets stuffed + * into the dispatch jump table otherwise. + * + * It matters only on SPARC, and only if you are using assembler + * code instead of C-code indirect dispatch. + * + * -- FEM, 04.xii.03 + */ +extern unsigned int _mesa_sparc_glapi_begin; +extern unsigned int _mesa_sparc_glapi_end; +extern void __glapi_sparc_icache_flush(unsigned int *); +static void _glx_mesa_init_sparc_glapi_relocs(void); +static int _mesa_sparc_needs_init = 1; +#define INIT_MESA_SPARC { \ + if(_mesa_sparc_needs_init) { \ + _glx_mesa_init_sparc_glapi_relocs(); \ + _mesa_sparc_needs_init = 0; \ + } \ +} +#else +#define INIT_MESA_SPARC +#endif + static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext gc); @@ -1092,6 +1123,7 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy) } #endif + INIT_MESA_SPARC /* The one and only long long lock */ __glXLock(); @@ -1206,6 +1238,7 @@ CARD8 __glXSetupForCommand(Display *dpy) if (gc->currentDpy == dpy) { /* Use opcode from gc because its right */ + INIT_MESA_SPARC return gc->majorOpcode; } else { /* @@ -1729,11 +1762,11 @@ Bool GLX_PREFIX(glXMakeCurrent)(Display *dpy, GLXDrawable draw, GLXContext gc) GLX_ALIAS(Bool, glXMakeCurrentReadSGI, (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx), - (dpy, d, r, ctx), MakeContextCurrent); + (dpy, d, r, ctx), MakeContextCurrent) GLX_ALIAS(Bool, glXMakeContextCurrent, (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx), - (dpy, d, r, ctx), MakeContextCurrent); + (dpy, d, r, ctx), MakeContextCurrent) #ifdef DEBUG @@ -1759,3 +1792,61 @@ void __glXDumpDrawBuffer(__GLXcontext *ctx) } } #endif + +#ifdef USE_SPARC_ASM +/* + * Used only when we are sparc, using sparc assembler. + * + */ + +static void +_glx_mesa_init_sparc_glapi_relocs(void) +{ + unsigned int *insn_ptr, *end_ptr; + unsigned long disp_addr; + + insn_ptr = &_mesa_sparc_glapi_begin; + end_ptr = &_mesa_sparc_glapi_end; + disp_addr = (unsigned long) &_glapi_Dispatch; + + /* + * Verbatim from Mesa sparc.c. It's needed because there doesn't + * seem to be a better way to do this: + * + * UNCONDITIONAL_JUMP ( (*_glapi_Dispatch) + entry_offset ) + * + * This code is patching in the ADDRESS of the pointer to the + * dispatch table. Hence, it must be called exactly once, because + * that address is not going to change. + * + * What it points to can change, but Mesa (and hence, we) assume + * that there is only one pointer. + * + */ + while (insn_ptr < end_ptr) { +#if ( defined(__sparc_v9__) && ( !defined(__linux__) || defined(__linux_64__) ) ) +/* + This code patches for 64-bit addresses. This had better + not happen for Sparc/Linux, no matter what architecture we + are building for. So, don't do this. + + The 'defined(__linux_64__)' is used here as a placeholder for + when we do do 64-bit usermode on sparc linux. + */ + insn_ptr[0] |= (disp_addr >> (32 + 10)); + insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10); + __glapi_sparc_icache_flush(&insn_ptr[0]); + insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1)); + insn_ptr[3] |= (disp_addr & ((1 << 10) - 1)); + __glapi_sparc_icache_flush(&insn_ptr[2]); + insn_ptr += 11; +#else + insn_ptr[0] |= (disp_addr >> 10); + insn_ptr[1] |= (disp_addr & ((1 << 10) - 1)); + __glapi_sparc_icache_flush(&insn_ptr[0]); + insn_ptr += 5; +#endif + } +} +#endif /* sparc ASM in use */ + diff --git a/xc/lib/GL/glx/glxextensions.h b/xc/lib/GL/glx/glxextensions.h index 390c100d3..b75c5539d 100644 --- a/xc/lib/GL/glx/glxextensions.h +++ b/xc/lib/GL/glx/glxextensions.h @@ -87,13 +87,12 @@ typedef void (* PFNGLXDISABLEEXTENSIONPROC) ( const char * name ); #ifdef GLX_NO_STATIC_EXTENSION_FUNCTIONS # define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) #else -# ifdef __GNUC__ +# if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED) # define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \ return_type GLX_PREFIX( real_func ) proto_args \ - __attribute__ ((alias( # aliased_func ) )) + __attribute__ ((alias( # aliased_func ) )); # else # define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \ - return_type GLX_PREFIX( real_func ) proto_args ; \ return_type GLX_PREFIX( real_func ) proto_args \ { return aliased_func args ; } # endif /* __GNUC__ */ diff --git a/xc/lib/GL/glx/packrender.h b/xc/lib/GL/glx/packrender.h index 305838054..9f177d8c9 100644 --- a/xc/lib/GL/glx/packrender.h +++ b/xc/lib/GL/glx/packrender.h @@ -68,9 +68,10 @@ #define __GLX_LOAD_VARIABLES() \ gc = __glXGetCurrentContext(); \ pc = gc->pc; \ - (void) cmdlen; \ - (void) compsize; \ - (void) pixelHeaderPC + /* Muffle compilers */ \ + cmdlen = 0; (void)cmdlen; \ + compsize = 0; (void)compsize; \ + pixelHeaderPC = 0; (void)pixelHeaderPC /* ** Variable sized command support macro. This macro is used by calls diff --git a/xc/lib/GL/glx/packsingle.h b/xc/lib/GL/glx/packsingle.h index db73d80bf..52c0cd4df 100644 --- a/xc/lib/GL/glx/packsingle.h +++ b/xc/lib/GL/glx/packsingle.h @@ -63,9 +63,10 @@ #define __GLX_SINGLE_LOAD_VARIABLES() \ pc = gc->pc; \ - (void) pixelHeaderPC; \ - (void) compsize; \ - (void) cmdlen + /* Muffle compilers */ \ + pixelHeaderPC = 0; (void)pixelHeaderPC; \ + compsize = 0; (void)compsize; \ + cmdlen = 0; (void)cmdlen /* Start a single command */ #define __GLX_SINGLE_BEGIN(opcode,bytes) \ @@ -172,25 +173,25 @@ extern float gl_ntoh_double(GLubyte *); #endif /* Get an array of typed data */ -#define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \ +#define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \ { \ GLint slop = alen*__GLX_SIZE_INT8 & 3; \ - _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ + _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ if (slop) _XEatData(dpy,4-slop); \ } -#define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \ +#define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \ { \ GLint slop = alen*__GLX_SIZE_INT8 & 3; \ - _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ + _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ if (slop) _XEatData(dpy,4-slop); \ } -#define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \ +#define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \ { \ GLint slop = (alen*__GLX_SIZE_INT16) & 3; \ - _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16); \ + _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16);\ if (slop) _XEatData(dpy,4-slop); \ } diff --git a/xc/lib/GL/glx/packvendpriv.h b/xc/lib/GL/glx/packvendpriv.h index 208c324dd..5ebdc9d9f 100644 --- a/xc/lib/GL/glx/packvendpriv.h +++ b/xc/lib/GL/glx/packvendpriv.h @@ -63,9 +63,10 @@ #define __GLX_VENDPRIV_LOAD_VARIABLES() \ pc = gc->pc; \ - (void) pixelHeaderPC; \ - (void) compsize; \ - (void) cmdlen + /* Muffle compilers */ \ + pixelHeaderPC = 0; (void)pixelHeaderPC; \ + compsize = 0; (void)compsize; \ + cmdlen = 0; (void)cmdlen /* Start a vendor private command */ #define __GLX_VENDPRIV_BEGIN(glxcode, opcode,bytes) \ diff --git a/xc/lib/GL/glx/single2.c b/xc/lib/GL/glx/single2.c index 7edbc8110..a5fa80f3e 100644 --- a/xc/lib/GL/glx/single2.c +++ b/xc/lib/GL/glx/single2.c @@ -912,7 +912,7 @@ const GLubyte *glGetString(GLenum name) } else { gc->version = Xmalloc( strlen(__glXGLClientVersion) - + strlen(s) + 4 ); + + strlen((char *)s) + 4 ); if ( gc->version == NULL ) { /* If we couldn't allocate memory for the new string, * make a best-effort and just copy the client-side version @@ -921,10 +921,10 @@ const GLubyte *glGetString(GLenum name) * for a short string, the system is probably going to die * soon anyway. */ - strcpy(s, __glXGLClientVersion); + strcpy((char *)s, __glXGLClientVersion); } else { - sprintf( gc->version, "%s (%s)", __glXGLClientVersion, s ); + sprintf( (char *)gc->version, "%s (%s)", __glXGLClientVersion, s ); Xfree( s ); s = gc->version; } @@ -932,7 +932,8 @@ const GLubyte *glGetString(GLenum name) break; } case GL_EXTENSIONS: - gc->extensions = __glXCombineExtensionStrings( s, __glXGLClientExtensions ); + gc->extensions = (GLubyte *)__glXCombineExtensionStrings( (char *)s, + __glXGLClientExtensions ); XFree( s ); s = gc->extensions; break; -- cgit v1.2.3