Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dreveman:openSUSE:11.1:cr
Mesa
mesa-chromium.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File mesa-chromium.diff of Package Mesa
diff -urN ../Mesa-7.2.old/configure.ac ./configure.ac --- ../Mesa-7.2.old/configure.ac 2009-03-18 23:12:30.000000000 -0400 +++ ./configure.ac 2009-03-18 23:12:39.000000000 -0400 @@ -1004,6 +1004,20 @@ AC_SUBST([APP_LIB_DEPS]) AC_SUBST([PROGRAM_DIRS]) +dnl CHROMIUM +AC_ARG_ENABLE([chromium], + [AS_HELP_STRING([--enable-chromium], + [use CHROMIUM for GLX @<:@default=disabled@:>@])], + [enable_cr="$enableval"], + [enable_cr=no]) +if test "x$enable_cr" = xyes; then + PKG_CHECK_MODULES([CHROMIUM], [cr]) + X11_INCLUDES="$X11_INCLUDES $CHROMIUM_CFLAGS" + GL_LIB_DEPS="$GL_LIB_DEPS $CHROMIUM_LIBS" + DEFINES="$DEFINES -DCHROMIUM" +else + enable_cr=no +fi dnl Restore LDFLAGS and CPPFLAGS LDFLAGS="$_SAVE_LDFLAGS" diff -urN ../Mesa-7.2.old/src/glx/x11/dricr_glx.c ./src/glx/x11/dricr_glx.c --- ../Mesa-7.2.old/src/glx/x11/dricr_glx.c 1969-12-31 19:00:00.000000000 -0500 +++ ./src/glx/x11/dricr_glx.c 2009-03-18 23:12:53.000000000 -0400 @@ -0,0 +1,660 @@ +/* + * Copyright © 2009 Novell, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Novell, Inc. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * Novell, Inc. makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: David Reveman <davidr@novell.com> + */ + +#ifdef GLX_DIRECT_RENDERING +#ifdef CHROMIUM + +#include <stdarg.h> +#include <X11/Xlib.h> +#include <X11/Xatom.h> +#include "glxclient.h" +#include "glcontextmodes.h" +#include "dri_common.h" +#include "cr_spu.h" +#include "cr_net.h" +#include "cr_error.h" +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_mothership.h" +#include "cr_net.h" +#include "cr_environment.h" +#include "cr_process.h" + +#include "glapi.h" +#include "glapioffsets.h" +#include "glapitable.h" + +#define KEYWORD1 static +#define KEYWORD1_ALT static +#define KEYWORD2 GLAPIENTRY +#define NAME(func) NoOp##func + +#define F NULL + +#define DISPATCH(func, args, msg) \ + crErrorMessage (F, "unimplemented GL dispatch function call: "); \ + crErrorMessage msg + +#define RETURN_DISPATCH(func, args, msg) \ + crErrorMessage (F, "unimplemented GL dispatch function call: "); \ + crErrorMessage msg; \ + return 0 + +#define DISPATCH_TABLE_NAME __glapi_table +#define UNUSED_TABLE_NAME __unused_functions + +#define TABLE_ENTRY(name) (_glapi_proc) NoOp##name + +static void crErrorMessage (void *d, const char *f, ...) +{ + va_list args; + const char *env; + + if ((env = getenv ("LIBGL_DEBUG")) && !strstr (env, "quiet")) + { + fprintf (stderr, "libGL error: "); + va_start (args, f); + vfprintf (stderr, f, args); + va_end (args); + } +} + +static GLint NoOpUnused (void) +{ + crErrorMessage (F, "unused GL dispatch function call\n"); + return 0; +} + +#include "glapitemp.h" + +typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate; +typedef struct __GLXDRIscreenPrivateRec __GLXDRIscreenPrivate; +typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate; +typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate; + +struct __GLXDRIdisplayPrivateRec +{ + __GLXDRIdisplay base; + SPU *spu; +}; + +struct __GLXDRIscreenPrivateRec +{ + __GLXDRIscreen base; + struct __GLXDRIdisplayPrivateRec *pdp; +}; + +struct __GLXDRIcontextPrivateRec +{ + __GLXDRIcontext base; + __GLXscreenConfigs *psc; + GLint spuContext; +}; + +struct __GLXDRIdrawablePrivateRec +{ + __GLXDRIdrawable base; + GLint spuDrawable; +}; + +static void +driGetConfigurationOptions (CRConnection *conn, + char **spuDir) +{ + char response[1024]; + int myRank = 0; + int lowContext = CR_QUADRICS_DEFAULT_LOW_CONTEXT; + int highContext = CR_QUADRICS_DEFAULT_HIGH_CONTEXT; + char *lowNode = "none"; + char *highNode = "none"; + unsigned char key[16]= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + if (crMothershipGetFakerParam (conn, response, "spu_dir") && + crStrlen (response) > 0) + { + *spuDir = crStrdup (response); + } + else + { + *spuDir = NULL; + } + + if (crMothershipGetRank (conn, response)) + myRank = crStrToInt (response); + + crNetSetRank (myRank); + + if (crMothershipGetParam (conn, "low_context", response)) + lowContext = crStrToInt (response); + if (crMothershipGetParam (conn, "high_context", response)) + highContext = crStrToInt (response); + + crNetSetContextRange (lowContext, highContext); + + if (crMothershipGetParam (conn, "low_node", response)) + lowNode = crStrdup (response); + if (crMothershipGetParam (conn, "high_node", response)) + highNode = crStrdup (response); + + crNetSetNodeRange (lowNode, highNode); + + if (crMothershipGetParam (conn, "comm_key", response)) + { + unsigned int a; + char **words, *found; + + /* remove the silly []'s */ + while ((found = crStrchr (response, '[')) != NULL) + *found = ' '; + while ((found = crStrchr (response, ']')) != NULL) + *found = ' '; + + words = crStrSplit(response, ","); + + a = 0; + while (words[a] != NULL && a < sizeof (key)) + { + key[a]= crStrToInt (words[a]); + a++; + } + + crFreeStrings (words); + } + + crNetSetKey (key, sizeof (key)); +} + +static const void * +__cr_lookup_func (const char *name, SPU *spu) +{ + SPUNamedFunctionTable *temp; + + if (spu == NULL) + return NULL; + + for (temp = spu->function_table->table; temp->name != NULL; temp++) + if (!strcmp (name, temp->name)) + return temp->fn; + + return __cr_lookup_func (name, spu->superSPU); +} + +static const void * +__cr_fuzzy_lookup_func (const char *name, SPU *spu) +{ + SPUNamedFunctionTable *temp; + + if (spu == NULL) + return NULL; + + for (temp = spu->function_table->table; temp->name != NULL; temp++) + { + static const char *suffix[] = { + "EXT", "ARB", "NV", "ATI", "SGIS", "MESA", "IBM", "APPLE" + }; + int i, j; + + for (i = 0; temp->name[i] == name[i]; i++) + if (name[i] == '\0') + return temp->fn; + + j = 0; + if (name[i] != '\0') + for (; j < sizeof (suffix) / sizeof (suffix[0]); j++) + if (strcmp (&name[i], suffix[j]) == 0) + break; + + if (j < sizeof (suffix) / sizeof (suffix[0])) + { + if (temp->name[i] == '\0') + return temp->fn; + + for (j = 0; j < sizeof (suffix) / sizeof (suffix[0]); j++) + if (strcmp (&temp->name[i], suffix[j]) == 0) + return temp->fn; + } + } + + return __cr_fuzzy_lookup_func (name, spu->superSPU); +} + +static const void * +__cr_reverse_lookup_func (int offset, SPU *spu) +{ + SPUNamedFunctionTable *temp; + char name[1024]; + + if (spu == NULL) + return NULL; + + name[0] = 'g'; + name[1] = 'l'; + + for (temp = spu->function_table->table; temp->name != NULL; temp++) + { + strcpy (&name[2], temp->name); + + if (_glapi_get_proc_offset (name) == offset) + return temp->fn; + } + + return __cr_reverse_lookup_func (offset, spu->superSPU); +} + +static SPU * +driCreateSPUChain (Display *dpy) +{ + CRConnection *conn; + char response[1024]; + char *spuDir = NULL; + char **spuChain; + int numSpus; + int *spuIds; + char **spuNames; + SPU *spu = NULL; + int i; + char *env; + Atom actual; + int result, format; + unsigned long n, left; + unsigned char *data = NULL; + static Display *display = 0; + + if (display) + return NULL; + + display = dpy; + + env = getenv ("CRMOTHERSHIP"); + if (env) + env = strdup (env); + + result = XGetWindowProperty (dpy, DefaultRootWindow (dpy), + XInternAtom (dpy, "CRMOTHERSHIP", False), + 0L, 1024L, False, + XA_STRING, + &actual, &format, + &n, &left, &data); + + if (result == Success && n && data) + { + char str[1025]; + + strncpy (str, (const char *) data, n); + str[n] = '\0'; + + InfoMessageF ("Found CRMOTHERSHIP property on root window\n"); + setenv ("CRMOTHERSHIP", str, 1); + } + else if (env) + { + InfoMessageF ("Found CRMOTHERSHIP environment variable\n"); + } + else + { + return NULL; + } + + InfoMessageF ("Connecting to CHROMIUM mothership: %s\n", + getenv ("CRMOTHERSHIP")); + + conn = crMothershipConnect (); + if (conn) + { + char *appId = getenv ("CR_APPLICATION_ID_NUMBER"); + + if (!appId) + appId = "-1"; + + InfoMessageF ("Using CHROMIUM application ID: %s\n", appId); + + crMothershipIdentifyOpenGL (conn, response, appId); + + spuChain = crStrSplit (response, " "); + numSpus = crStrToInt (spuChain[0]); + spuIds = (int *) crAlloc (numSpus * sizeof (*spuIds)); + spuNames = (char **) crAlloc (numSpus * sizeof (*spuNames)); + + for (i = 0; i < numSpus; i++) + { + spuIds[i] = crStrToInt (spuChain[2 * i + 1]); + spuNames[i] = crStrdup (spuChain[2 * i + 2]); + } + + driGetConfigurationOptions (conn, &spuDir); + + crMothershipDisconnect (conn); + + if (spuDir) + InfoMessageF ("Using CHROMIUM SPU directory: %s\n", spuDir); + + InfoMessageF ("Loading CHROMIUM SPU chain:\n"); + + for (i = 0; i < numSpus; i++) + InfoMessageF (" SPU %d/%d: (%d) \"%s\"\n", + i + 1, numSpus, spuIds[i], spuNames[i]); + + spu = crSPULoadChain (numSpus, spuIds, spuNames, spuDir, NULL); + + crFree (spuChain); + crFree (spuIds); + for (i = 0; i < numSpus; i++) + crFree (spuNames[i]); + crFree (spuNames); + + if (spuDir) + crFree (spuDir); + + if (spu) + { + const int entries = sizeof (__glapi_table) / sizeof (void *); + const void **tab = (const void **) __glapi_table; + int i, count = 0, missing = 0; + + for (i = 0; i < entries; i++) + { + const char *name = _glapi_get_proc_name (i); + + if (name && name[0] == 'g' && name[1] == 'l') + { + const void *proc; + + count++; + + proc = __cr_lookup_func (&name[2], spu); + if (proc) + { + tab[i] = proc; + continue; + } + + proc = __cr_reverse_lookup_func (i, spu); + if (proc) + { + tab[i] = proc; + continue; + } + + proc = __cr_fuzzy_lookup_func (&name[2], spu); + if (proc) + { + tab[i] = proc; + continue; + } + + missing++; + } + } + + InfoMessageF ("CHROMIUM dispatch table completeness: " + "%d/%d (%d missing)\n", + count - missing, count, missing); + + _glapi_set_dispatch ((struct _glapi_table *) __glapi_table); + } + } + else + { + ErrorMessageF ("Unable to connect to CHROMIUM mothership"); + } + + if (env) + { + setenv ("CRMOTHERSHIP", env, 1); + free (env); + } + + if (data) + XFree (data); + + return spu; +} + +static GLint +visBitsFromMode (const __GLcontextModes *mode) +{ + GLint visBits = 0; + + if (mode->rgbMode) + visBits |= CR_RGB_BIT; + + if (mode->alphaBits) + visBits |= CR_ALPHA_BIT; + + if (mode->doubleBufferMode) + visBits |= CR_DOUBLE_BIT; + + if (mode->haveDepthBuffer) + visBits |= CR_DEPTH_BIT; + + if (mode->haveStencilBuffer) + visBits |= CR_STENCIL_BIT; + + return visBits; +} + +static void +driDestroyContext (__GLXDRIcontext *context, + __GLXscreenConfigs *psc, + Display *dpy) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + __GLXDRIscreenPrivate *psp = (__GLXDRIscreenPrivate *) + pcp->psc->driScreen; + + (*psp->pdp->spu->dispatch_table.DestroyContext) (pcp->spuContext); + + Xfree (pcp); +} + +static Bool +driBindContext (__GLXDRIcontext *context, + __GLXDRIdrawable *draw, + __GLXDRIdrawable *read) +{ + __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context; + __GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) draw; + __GLXDRIscreenPrivate *psp = (__GLXDRIscreenPrivate *) + pcp->psc->driScreen; + + if (draw != read) + return False; + + (*psp->pdp->spu->dispatch_table.MakeCurrent) (pdp->spuDrawable, + draw->xDrawable, + pcp->spuContext); + + return True; +} + +static void +driUnbindContext (__GLXDRIcontext *context) +{ +} + +static __GLXDRIcontext * +driCreateContext (__GLXscreenConfigs *psc, + const __GLcontextModes *mode, + GLXContext gc, + GLXContext shareList, + int renderType) +{ + __GLXDRIcontextPrivate *pcp, *pcp_shared; + __GLXDRIscreenPrivate *psp = (__GLXDRIscreenPrivate *) psc->driScreen; + GLint spuShareContext = 0; + + if (!psc || !psp) + return NULL; + + if (shareList) + { + pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext; + spuShareContext = pcp_shared->spuContext; + } + + pcp = Xmalloc (sizeof *pcp); + if (pcp == NULL) + return NULL; + + pcp->base.destroyContext = driDestroyContext; + pcp->base.bindContext = driBindContext; + pcp->base.unbindContext = driUnbindContext; + + pcp->psc = psc; + pcp->spuContext = + (*psp->pdp->spu->dispatch_table.CreateContext) (DisplayString (psc->dpy), + visBitsFromMode (mode), + spuShareContext); + if (pcp->spuContext == -1) + { + Xfree (pcp); + return NULL; + } + + return &pcp->base; +} + +static void +driDestroyDrawable (__GLXDRIdrawable *pdraw) +{ + __GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) pdraw; + __GLXDRIscreenPrivate *psp = (__GLXDRIscreenPrivate *) + pdraw->psc->driScreen; + + (*psp->pdp->spu->dispatch_table.WindowDestroy) (pdp->spuDrawable); + + Xfree (pdp); +} + +static __GLXDRIdrawable * +driCreateDrawable (__GLXscreenConfigs *psc, + XID xDrawable, + GLXDrawable drawable, + const __GLcontextModes *mode) +{ + __GLXDRIdrawablePrivate *pdp; + __GLXDRIscreenPrivate *psp = (__GLXDRIscreenPrivate *) psc->driScreen; + + pdp = Xmalloc (sizeof *pdp); + if (!pdp) + return NULL; + + pdp->base.destroyDrawable = driDestroyDrawable; + pdp->base.xDrawable = xDrawable; + pdp->base.drawable = drawable; + pdp->base.psc = psc; + pdp->base.textureTarget = 0; + pdp->base.driDrawable = (__DRIdrawable *) pdp; + + XSync (psc->dpy, False); + + pdp->spuDrawable = + (*psp->pdp->spu->dispatch_table.WindowCreate) (DisplayString (psc->dpy), + visBitsFromMode (mode)); + if (pdp->spuDrawable == -1) + { + Xfree (pdp); + return NULL; + } + + return &pdp->base; +} + +static void +driSwapBuffers (__GLXDRIdrawable *pdraw) +{ + __GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) pdraw; + __GLXDRIscreenPrivate *psp = (__GLXDRIscreenPrivate *) + pdraw->psc->driScreen; + + (*psp->pdp->spu->dispatch_table.SwapBuffers) (pdp->spuDrawable, 0); +} + +static void +driDestroyScreen (__GLXscreenConfigs *psc) +{ +} + +static const __DRIcoreExtension dricr_core = { + .swapBuffers = driSwapBuffers +}; + +static __GLXDRIscreen * +driCreateScreen (__GLXscreenConfigs *psc, + int screen, + __GLXdisplayPrivate *pd) +{ + __GLXDRIdisplayPrivate *pdp = (__GLXDRIdisplayPrivate *) pd->dricrDisplay; + __GLXDRIscreenPrivate *psp; + + psp = Xmalloc (sizeof *psp); + if (psp == NULL) + return NULL; + + /* Initialize per screen dynamic client GLX extensions */ + psc->ext_list_first_time = GL_TRUE; + psc->core = &dricr_core; + + psp->base.destroyScreen = driDestroyScreen; + psp->base.createContext = driCreateContext; + psp->base.createDrawable = driCreateDrawable; + + psp->pdp = pdp; + + return &psp->base; +} + +static void +driDestroyDisplay (__GLXDRIdisplay *pd) +{ + Xfree (pd); +} + +_X_HIDDEN __GLXDRIdisplay * +dricrCreateDisplay (Display *dpy) +{ + __GLXDRIdisplayPrivate *pdp; + + pdp = Xmalloc (sizeof *pdp); + if (pdp == NULL) + return NULL; + + pdp->spu = driCreateSPUChain (dpy); + if (pdp->spu == NULL) + { + Xfree (pdp); + return NULL; + } + + pdp->base.destroyDisplay = driDestroyDisplay; + pdp->base.createScreen = driCreateScreen; + + (void) __unused_functions; + + return &pdp->base; +} + +#endif /* CHROMIUM */ +#endif /* GLX_DIRECT_RENDERING */ diff -urN ../Mesa-7.2.old/src/glx/x11/glxclient.h ./src/glx/x11/glxclient.h --- ../Mesa-7.2.old/src/glx/x11/glxclient.h 2009-03-18 23:12:30.000000000 -0400 +++ ./src/glx/x11/glxclient.h 2009-03-18 23:12:39.000000000 -0400 @@ -146,6 +146,9 @@ */ extern __GLXDRIdisplay *driswCreateDisplay(Display *dpy); extern __GLXDRIdisplay *driCreateDisplay(Display *dpy); +#ifdef CHROMIUM +extern __GLXDRIdisplay *dricrCreateDisplay(Display *dpy); +#endif extern void DRI_glXUseXFont( Font font, int first, int count, int listbase ); @@ -564,6 +567,9 @@ */ __GLXDRIdisplay *driswDisplay; __GLXDRIdisplay *driDisplay; +#ifdef CHROMIUM + __GLXDRIdisplay *dricrDisplay; +#endif #endif }; diff -urN ../Mesa-7.2.old/src/glx/x11/glxext.c ./src/glx/x11/glxext.c --- ../Mesa-7.2.old/src/glx/x11/glxext.c 2009-03-18 23:12:30.000000000 -0400 +++ ./src/glx/x11/glxext.c 2009-03-18 23:12:39.000000000 -0400 @@ -193,6 +193,12 @@ #ifdef GLX_DIRECT_RENDERING /* Free the direct rendering per display data */ +#ifdef CHROMIUM + if (priv->dricrDisplay) + (*priv->dricrDisplay->destroyDisplay) (priv->dricrDisplay); + priv->dricrDisplay = NULL; +#endif + if (priv->driswDisplay) (*priv->driswDisplay->destroyDisplay)(priv->driswDisplay); priv->driswDisplay = NULL; @@ -600,6 +606,11 @@ if (psc->driScreen == NULL && priv->driDisplay) psc->driScreen = (*priv->driDisplay->createScreen)(psc, i, priv); +#ifdef CHROMIUM + if (psc->driScreen == NULL && priv->dricrDisplay) + psc->driScreen = (*priv->dricrDisplay->createScreen) (psc, i, priv); +#endif + if (psc->driScreen == NULL && priv->driswDisplay) psc->driScreen = (*priv->driswDisplay->createScreen)(psc, i, priv); @@ -701,6 +712,10 @@ ** Note: This _must_ be done before calling any other DRI routines ** (e.g., those called in AllocAndFetchScreenConfigs). */ +#ifdef CHROMIUM + if (glx_direct) + dpyPriv->dricrDisplay = dricrCreateDisplay(dpy); +#endif if (glx_direct && glx_accel) { dpyPriv->driDisplay = driCreateDisplay(dpy); } diff -urN ../Mesa-7.2.old/src/glx/x11/Makefile ./src/glx/x11/Makefile --- ../Mesa-7.2.old/src/glx/x11/Makefile 2009-03-18 23:12:30.000000000 -0400 +++ ./src/glx/x11/Makefile 2009-03-18 23:12:39.000000000 -0400 @@ -32,6 +32,7 @@ glx_pbuffer.c \ glx_query.c \ drisw_glx.c \ + dricr_glx.c \ dri_common.c \ dri_glx.c \ XF86dri.c \
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor