diff options
Diffstat (limited to 'nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi')
22 files changed, 2859 insertions, 0 deletions
diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/.cvsignore b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/.cvsignore new file mode 100644 index 000000000..c8a526b14 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/.cvsignore @@ -0,0 +1 @@ +genkgi.conf diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi.conf.in b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi.conf.in new file mode 100644 index 000000000..02acad2a1 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi.conf.in @@ -0,0 +1,4 @@ +# GGIMesa genkgi helper configuration +.root: @ggi_libdir@/ggi/mesa/default + +tgt-fbdev-kgicon-d3dim-mesa d3dim.so diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi.h new file mode 100644 index 000000000..022189138 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi.h @@ -0,0 +1,76 @@ +/* $Id: genkgi.h,v 1.3 1999/08/22 08:56:50 jtaylor Exp $ +****************************************************************************** + + GGIMesa - KGIcon specific overrides for fbcon-mesa + API header + + Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************************************************** +*/ + +#ifndef _GENKGI_MESA_H +#define _GENKGI_MESA_H + +#undef KGI_USE_PPBUFS + +#include <unistd.h> +#include <sys/mman.h> + +#include <ggi/internal/ggi-dl.h> +#include <ggi/mesa/display_fbdev.h> +#include <kgi/kgi.h> + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +/* FIXME: LibGGI needs to export its genkgi.h */ +struct genkgi_priv +{ + ggi_gc *mapped_gc; + unsigned int gc_size; + ggifunc_drawline *drawline; + ggifunc_drawbox *drawbox; + ggifunc_fillscreen *fillscreen; + int fd_gc; + int close_gc; + int fd_kgicommand; + uint8 *mapped_kgicommand; + uint8 *kgicommand_ptr; + unsigned int kgicommand_buffersize; +}; + +#define GENKGI_PRIV(vis) ((struct genkgi_priv *)FBDEV_PRIV(vis)->accelpriv) + +extern ggifunc_getapi GGIMesa_genkgi_getapi; +extern ggifunc_flush GGIMesa_genkgi_flush; + +struct genkgi_priv_mesa +{ + char accel[100]; + int have_accel; + void *accelpriv; /* Private data of subdrivers */ + struct genkgi_priv *oldpriv; /* LibGGI's private data */ +}; + +#define GENKGI_PRIV_MESA(vis) ((struct genkgi_priv_mesa *)FBDEV_PRIV_MESA(vis)->accelpriv) + +#endif /* _GENKHI_MESA_H */ diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi_mode.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi_mode.c new file mode 100644 index 000000000..938024789 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi_mode.c @@ -0,0 +1,97 @@ +/* $Id: genkgi_mode.c,v 1.4 2000/01/07 08:34:44 jtaylor Exp $ +****************************************************************************** + + display-fbdev-kgicon-generic-mesa + + Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************************************************** +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <sys/mman.h> + +#include <ggi/internal/ggi-dl.h> +#include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/debug.h> +#include "genkgi.h" + +int GGIMesa_genkgi_getapi(ggi_visual *vis, int num, char *apiname, char *arguments) +{ + struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis); + + GGIMESADPRINT_CORE("Entered mesa_genkgi_getapi, num=%d\n", num); + + strcpy(arguments, ""); + + switch(num) + { + case 0: + if (priv->have_accel) + { + strcpy(apiname, priv->accel); + return 0; + } + break; + } + return -1; +} + +int GGIMesa_genkgi_flush(ggi_visual *vis, int x, int y, int w, int h, int tryflag) +{ + struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis); + int junkval; + + priv->oldpriv->kgicommand_ptr += getpagesize(); + (kgiu32)(priv->oldpriv->kgicommand_ptr) &= 0xfffff000; + junkval = *((int *)(priv->oldpriv->kgicommand_ptr)); + + /* Check if we are now in the last page, and reset the + * FIFO if so. We can't use the last page to send + * more commands, since there's no page after it that + * we can touch to fault in the last page's commands. + * + * FIXME: This will be replaced with a flush-and-reset handler + * on the end-of-buffer pagefault at some point.... + * + */ + if ((priv->oldpriv->kgicommand_ptr - priv->oldpriv->mapped_kgicommand) + >= (priv->oldpriv->kgicommand_buffersize - getpagesize())) + { + munmap(priv->oldpriv->mapped_kgicommand, priv->oldpriv->kgicommand_buffersize); + if ((priv->oldpriv->mapped_kgicommand = + mmap(NULL, + priv->oldpriv->kgicommand_buffersize, + PROT_READ | PROT_WRITE, + MAP_SHARED, + priv->oldpriv->fd_kgicommand, + 0)) == MAP_FAILED) + { + ggiPanic("Failed to remap kgicommand!"); + } + priv->oldpriv->kgicommand_ptr = priv->oldpriv->mapped_kgicommand; + } + return 0; +} diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi_visual.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi_visual.c new file mode 100644 index 000000000..17ef9679b --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/genkgi_visual.c @@ -0,0 +1,190 @@ +/* $Id: genkgi_visual.c,v 1.7 2000/06/11 20:11:55 jtaylor Exp $ +****************************************************************************** + + genkgi_visual.c: visual handling for the generic KGI helper + + Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************************************************** +*/ + +#include <ggi/internal/ggi-dl.h> +#include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/display_fbdev.h> +#include <ggi/mesa/debug.h> +#include "genkgi.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> + +#ifdef HAVE_SYS_VT_H +#include <sys/vt.h> +#else +#include <linux/vt.h> +#endif +#ifdef HAVE_LINUX_KDEV_T_H +#include <linux/kdev_t.h> +#endif +#include <linux/tty.h> + +#define DEFAULT_FBNUM 0 + +static char accel_prefix[] = "tgt-fbdev-kgicon-"; +#define PREFIX_LEN (sizeof(accel_prefix)) + +typedef struct { + int async; + char *str; +} accel_info; + +static accel_info accel_strings[] = +{ + { 0, "d3dim" }, /* Direct3D Immediate Mode */ +}; + +#define NUM_ACCELS (sizeof(accel_strings)/sizeof(accel_info)) + +/* FIXME: These should be defined in the makefile system */ +#define CONF_FILE "/usr/local/etc/ggi/mesa/targets/genkgi.conf" +void *_configHandle; +char confstub[512] = CONF_FILE; +char *conffile = confstub; + +static int changed(ggi_visual_t vis, int whatchanged) +{ + GGIMESADPRINT_CORE("Entered ggimesa_genkgi_changed\n"); + + switch (whatchanged) + { + case GGI_CHG_APILIST: + { + char api[256]; + char args[256]; + int i; + const char *fname; + ggi_dlhandle *lib; + + for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++) + { + strcat(api, "-mesa"); + GGIMESADPRINT_CORE("ggimesa_genkgi_changed: api=%s, i=%d\n", api, i); + fname = ggMatchConfig(_configHandle, api, NULL); + if (fname == NULL) + { + /* No special implementation for this sublib */ + continue; + } + + lib = ggiExtensionLoadDL(vis, fname, args, NULL); + } + } + break; + } + return 0; +} + +static int GGIdlinit(ggi_visual *vis, struct ggi_dlhandle *dlh, + const char *args, void *argptr, uint32 *dlret) +{ + struct genkgi_priv_mesa *priv; + char libname[256], libargs[256]; + int id, err; + struct stat junk; + ggifunc_getapi *oldgetapi; + + GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: GGIdlinit start\n"); + + GENKGI_PRIV_MESA(vis) = priv = malloc(sizeof(struct genkgi_priv_mesa)); + if (priv == NULL) + { + fprintf(stderr, "Failed to allocate genkgi private data\n"); + return GGI_DL_ERROR; + } + + priv->oldpriv = GENKGI_PRIV(vis); +#if 0 + err = ggLoadConfig(conffile, &_configHandle); + if (err != GGI_OK) + { + gl_ggiPrint("display-fbdev-kgicon-mesa: Couldn't open %s\n", conffile); + return err; + } + + /* Hack city here. We need to probe the KGI driver properly for + * suggest-strings to discover the acceleration type(s). + */ + priv->have_accel = 0; + + if (stat("/proc/gfx0", &junk) == 0) + { + sprintf(priv->accel, "%s%s", accel_prefix, "d3dim"); + priv->have_accel = 1; + GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: Using accel: \"%s\"\n", priv->accel); + } + + /* Mode management */ + vis->opdisplay->getapi = GGIMesa_genkgi_getapi; + ggiIndicateChange(vis, GGI_CHG_APILIST); + + /* Give the accel sublibs a chance to set up a driver */ + if (priv->have_accel == 1) + { + oldgetapi = vis->opdisplay->getapi; + vis->opdisplay->getapi = GGIMesa_genkgi_getapi; + changed(vis, GGI_CHG_APILIST); + /* If the accel sublibs didn't produce, back up + * and keep looking */ + if ((LIBGGI_MESAEXT(vis)->update_state == NULL) || + (LIBGGI_MESAEXT(vis)->setup_driver == NULL)) + vis->opdisplay->getapi = oldgetapi; + } + + LIBGGI_MESAEXT(vis)->update_state = genkgi_update_state; + LIBGGI_MESAEXT(vis)->setup_driver = genkgi_setup_driver; +#endif + GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: GGIdlinit finished\n"); + + *dlret = GGI_DL_OPDRAW; + return 0; +} + +int MesaGGIdl_fbdev(int func, void **funcptr) +{ + switch (func) { + case GGIFUNC_open: + *funcptr = GGIopen; + return 0; + case GGIFUNC_exit: + case GGIFUNC_close: + *funcptr = NULL; + return 0; + default: + *funcptr = NULL; + } + return GGI_ENOTFOUND; +} + +#include <ggi/internal/ggidlinit.h> diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear.c new file mode 100644 index 000000000..9d29761ad --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear.c @@ -0,0 +1,409 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> +#include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/debug.h> +#include "swrast/swrast.h" + +#define RMASK ((1<<R)-1) +#define GMASK ((1<<G)-1) +#define BMASK ((1<<B)-1) + +#define RS (8-R) +#define GS (8-G) +#define BS (8-B) + +#define PACK(color) (((color[RCOMP]>>RS) << (G+B)) | \ + ((color[GCOMP]>>GS) << B) | \ + ((color[BCOMP]>>BS))) + +#define FLIP(coord) (LIBGGI_VIRTY(ggi_ctx->ggi_visual) - (coord) - 1) + + +/**********************************************************************/ +/***** Write spans of pixels *****/ +/**********************************************************************/ + +void GGIwrite_ci32_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLuint ci[], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + if (mask) { + while (n--) { + if (*mask++) + *fb = *ci; + fb++; + ci++; + } + } else { + while (n--) *fb++ = *ci++; + } +} + +void GGIwrite_ci8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte ci[], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + if (mask) { + while (n--) { + if (*mask++) + *fb = *ci; + fb++; + ci++; + } + } else { + while (n--) *fb++ = *ci++; + } +} + + +void GGIwrite_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLchan rgba[][4], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + if (mask) { + while (n--) { + if (*mask++) + *fb = PACK(rgba[0]); + fb++; + rgba++; + } + } else { + while (n--) { + *fb++ = PACK(rgba[0]); + rgba++; + } + } +} + +void GGIwrite_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLchan rgba[][3], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + if (mask) { + while (n--) { + if (*mask++) + *fb = PACK(rgba[0]); + fb++; + rgba++; + } + } else { + while (n--) { + *fb++ = PACK(rgba[0]); + rgba++; + } + } +} + + +void GGIwrite_mono_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLchan color[4], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + if (mask) { + while (n--){ + if (*mask++) + *fb = PACK(color); + ++fb; + } + } else { + while (n--) + *fb++ = PACK(color); + + /* Alternatively we could write a potentialy faster HLine + ggiSetGCForeground(ggi_ctx->ggi_visual, color); + ggiDrawHLine(ggi_ctx->ggi_visual,x,FLIP(y),n); + */ + } +} + +void GGIwrite_mono_ci_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLuint ci, const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + if (mask){ + while (n--){ + if (*mask++) + *fb = ci; + ++fb; + } + } else { + while (n--) + *fb++ = ci; + + /* Alternatively we could write a potentialy faster HLine + ggiSetGCForeground(ggi_ctx->ggi_visual, ci); + ggiDrawHLine(ggi_ctx->ggi_visual, x, FLIP(y), n); + */ + } +} + + +/**********************************************************************/ +/***** Read spans of pixels *****/ +/**********************************************************************/ + + +void GGIread_ci32_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint ci[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE *fb; + fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + while (n--) + *ci++ = (GLuint)*fb++; +} + +void GGIread_rgba_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, GLchan rgba[][4]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + FB_TYPE color; + FB_TYPE *fb; + fb = (FB_TYPE *)((char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual) + + FLIP(y)*LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual)) + x; + + while (n--) { + color = *fb++; + rgba[0][RCOMP] = (GLubyte) (color>>(G+B))<<RS; + rgba[0][GCOMP] = (GLubyte) ((color>>B)& ((1<<G)-1))<<GS; + rgba[0][BCOMP] = (GLubyte) (color & ((1<<B)-1))<<BS; + rgba[0][ACOMP] = 0; + rgba++; + } +} + +/**********************************************************************/ +/***** Write arrays of pixels *****/ +/**********************************************************************/ + +void GGIwrite_ci32_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLuint ci[], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); + + while (n--) { + if (*mask++){ + FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *dst = *ci; + } + ci++; + x++; + y++; + } +} + +void GGIwrite_mono_ci_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint ci, const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); + + while (n--) { + if (*mask++){ + FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *dst = ci; + } + x++; + y++; + } +} + +void GGIwrite_rgba_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLchan rgba[][4], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); + + while (n--) { + if (*mask++){ + FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *dst = PACK(rgba[0]); + } + x++; + y++; + rgba++; + } +} + +void GGIwrite_mono_rgba_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLchan rgba[4], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); + + while (n--) { + if (*mask++){ + FB_TYPE *dst = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *dst = PACK(rgba); + } + + x++; + y++; + } +} + +/**********************************************************************/ +/***** Read arrays of pixels *****/ +/**********************************************************************/ + +void GGIread_ci32_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint ci[], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); + + while (n--) { + if (*mask++){ + FB_TYPE *src = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + *ci = *src; + } + ci++; + x++; + y++; + } +} + +void GGIread_rgba_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + int stride = LIBGGI_FB_W_STRIDE(ggi_ctx->ggi_visual); + char *fb = (char *)LIBGGI_CURWRITE(ggi_ctx->ggi_visual); + FB_TYPE color; + + while (n--) { + if (*mask++) { + FB_TYPE *src = (FB_TYPE*)(fb + FLIP(*y)*stride) + *x; + color = *src; + + rgba[0][RCOMP] = (GLubyte)(color>>(G+B))<<RS; + rgba[0][GCOMP] = (GLubyte)((color>>B)& ((1<<G)-1))<<GS; + rgba[0][BCOMP] = (GLubyte) (color & ((1<<B)-1))<<BS; + rgba[0][ACOMP] = 0; + } + x++; + y++; + rgba++; + } +} + +void GGIset_buffer(GLcontext *ctx, GLframebuffer *buffer, GLenum mode) +{ +} + +int GGIsetup_driver(ggi_mesa_context_t ggi_ctx) +{ + struct swrast_device_driver *swdd = + _swrast_GetDeviceDriverReference(ggi_ctx->gl_ctx); + + GGIMESADPRINT_LIBS("linear_%d: GGIsetup_driver\n", sizeof(FB_TYPE)*8); + + swdd->WriteRGBASpan = GGIwrite_rgba_span; + swdd->WriteRGBSpan = GGIwrite_rgb_span; + swdd->WriteMonoRGBASpan = GGIwrite_mono_rgba_span; + swdd->WriteRGBAPixels = GGIwrite_rgba_pixels; + swdd->WriteMonoRGBAPixels = GGIwrite_mono_rgba_pixels; + + swdd->WriteCI32Span = GGIwrite_ci32_span; + swdd->WriteCI8Span = GGIwrite_ci8_span; + swdd->WriteMonoCISpan = GGIwrite_mono_ci_span; + swdd->WriteCI32Pixels = GGIwrite_ci32_pixels; + swdd->WriteMonoCIPixels = GGIwrite_mono_ci_pixels; + + swdd->ReadCI32Span = GGIread_ci32_span; + swdd->ReadRGBASpan = GGIread_rgba_span; + swdd->ReadCI32Pixels = GGIread_ci32_pixels; + swdd->ReadRGBAPixels = GGIread_rgba_pixels; + + swdd->SetBuffer = GGIset_buffer; + + return 0; +} + +static int GGIopen(ggi_visual_t vis,struct ggi_dlhandle *dlh, + const char *args,void *argptr, uint32 *dlret) +{ + GGIMESADPRINT_CORE("linear_%d: GGIOpen\n", sizeof(FB_TYPE)*8); + LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver; + + *dlret = GGI_DL_OPDRAW; + return 0; +} + +int DLOPENFUNC(int func, void **funcptr) +{ + switch (func) { + case GGIFUNC_open: + *funcptr = GGIopen; + return 0; + case GGIFUNC_exit: + case GGIFUNC_close: + *funcptr = NULL; + return 0; + default: + *funcptr = NULL; + } + return GGI_ENOTFOUND; +} + diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_15.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_15.c new file mode 100644 index 000000000..ead7cc584 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_15.c @@ -0,0 +1,36 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 5 +#define G 5 +#define B 5 + +#define FB_TYPE uint16 +#define FB_BITS 15 +#define DLOPENFUNC MesaGGIdl_linear_15 + +#include "linear.c" + diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_16.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_16.c new file mode 100644 index 000000000..6028699bb --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_16.c @@ -0,0 +1,36 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 5 +#define G 6 +#define B 5 + +#define FB_TYPE uint16 +#define FB_BITS 16 +#define DLOPENFUNC MesaGGIdl_linear_16 + +#include "linear.c" + diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_24.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_24.c new file mode 100644 index 000000000..7a2236f12 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_24.c @@ -0,0 +1,36 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 8 +#define G 8 +#define B 8 + +#define FB_TYPE uint32 +#define FB_BITS 24 +#define DLOPENFUNC MesaGGIdl_linear_24 + +#include "linear.c" + diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_32.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_32.c new file mode 100644 index 000000000..7cbf945f3 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_32.c @@ -0,0 +1,36 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 8 +#define G 8 +#define B 8 + +#define FB_TYPE uint32 +#define FB_BITS 32 +#define DLOPENFUNC MesaGGIdl_linear_32 + +#include "linear.c" + diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_8.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_8.c new file mode 100644 index 000000000..9c7b5d712 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/linear_8.c @@ -0,0 +1,36 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 3 +#define G 3 +#define B 2 + +#define FB_TYPE uint8 +#define FB_BITS 8 +#define DLOPENFUNC MesaGGIdl_linear_8 + +#include "linear.c" + diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/stubs.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/stubs.c new file mode 100644 index 000000000..7b442b6d2 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/default/stubs.c @@ -0,0 +1,512 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <stdio.h> + +#include <ggi/internal/ggi-dl.h> +#include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/debug.h> + +#include "swrast/swrast.h" +//#include "swrast_setup/swrast_setup.h" +//#include "swrast/s_context.h" +//#include "swrast/s_depth.h" +//#include "swrast/s_triangle.h" + +#define FLIP(coord) (LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y-(coord)-1) + +/**********************************************************************/ +/***** Write spans of pixels *****/ +/**********************************************************************/ + +void GGIwrite_ci32_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLuint ci[], + const GLubyte mask[] ) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + y = FLIP(y); + if (mask) + { + while (n--) { + if (*mask++) + ggiPutPixel(ggi_ctx->ggi_visual, x, y, *ci); + x++; + ci++; + } + } + else + { + while (n--) + ggiPutPixel(ggi_ctx->ggi_visual, x++, y, *ci++); + } +} + +void GGIwrite_ci8_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte ci[], + const GLubyte mask[] ) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + y = FLIP(y); + if (mask) + { + while (n--) { + if (*mask++) + ggiPutPixel(ggi_ctx->ggi_visual, x, y, *ci); + x++; + ci++; + } + } + else + { + while (n--) + ggiPutPixel(ggi_ctx->ggi_visual, x++, y, *ci++); + } +} + +void GGIwrite_mono_ci_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLuint ci, const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + y = FLIP(y); + if (mask) + { + while (n--) { + if (*mask++) + ggiPutPixel(ggi_ctx->ggi_visual, x, y, ci); + x++; + } + } + else + { + while (n--) + ggiPutPixel(ggi_ctx->ggi_visual, x++, y, ci); + } +} + +void GGIwrite_mono_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLchan rgba[4], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + ggi_color rgb; + ggi_pixel col; + + y = FLIP(y); + + rgb.r = (uint16)(rgba[RCOMP]) << SHIFT; + rgb.g = (uint16)(rgba[GCOMP]) << SHIFT; + rgb.b = (uint16)(rgba[BCOMP]) << SHIFT; + col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); + + if (mask) + { + while (n--) { + if (*mask++) + ggiPutPixel(ggi_ctx->ggi_visual, x, y, col); + x++; + } + } + else + { + ggiDrawHLine(ggi_ctx->ggi_visual, x, y, n); + } +} + +void GGIwrite_rgba_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], + const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + ggi_color rgb; + ggi_pixel col; + y = FLIP(y); + + if (mask) + { + while (n--) { + if (*mask++) + { + rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; + col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); + ggiPutPixel(ggi_ctx->ggi_visual, x, y, col); + } + x++; + rgba++; + } + } + else + { + while (n--) + { + rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; + col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); + ggiPutPixel(ggi_ctx->ggi_visual, x++, y, col); + rgba++; + } + } +} + +void GGIwrite_rgb_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte rgba[][3], + const GLubyte mask[] ) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + ggi_color rgb; + ggi_pixel col; + y = FLIP(y); + + if (mask) + { + while (n--) { + if (*mask++) + { + rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; + col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); + ggiPutPixel(ggi_ctx->ggi_visual, x, y, col); + } + x++; + rgba++; + } + } + else + { + while (n--) + { + rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; + col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); + ggiPutPixel(ggi_ctx->ggi_visual, x++, y, col); + rgba++; + } + } +} + + + +/**********************************************************************/ +/***** Read spans of pixels *****/ +/**********************************************************************/ + + +void GGIread_ci32_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint ci[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + y = FLIP(y); + while (n--) + ggiGetPixel(ggi_ctx->ggi_visual, x++, y, ci++); +} + +void GGIread_rgba_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte rgba[][4]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + ggi_color rgb; + ggi_pixel col; + + y = FLIP(y); + + while (n--) + { + ggiGetPixel(ggi_ctx->ggi_visual, x++, y, &col); + ggiUnmapPixel(ggi_ctx->ggi_visual, col, &rgb); + rgba[0][RCOMP] = (GLubyte) (rgb.r >> SHIFT); + rgba[0][GCOMP] = (GLubyte) (rgb.g >> SHIFT); + rgba[0][BCOMP] = (GLubyte) (rgb.b >> SHIFT); + rgba[0][ACOMP] = 0; + rgba++; + } +} + +/**********************************************************************/ +/***** Write arrays of pixels *****/ +/**********************************************************************/ + +void GGIwrite_ci32_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLuint ci[], const GLubyte mask[] ) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + while (n--) { + if (*mask++) + ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), *ci); + ci++; + x++; + y++; + } +} + +void GGIwrite_mono_ci_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint ci, const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + while (n--) { + if (*mask++) + ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), ci); + x++; + y++; + } +} + +void GGIwrite_rgba_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte rgba[][4], + const GLubyte mask[] ) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + ggi_pixel col; + ggi_color rgb; + while (n--) { + if (*mask++) { + rgb.r = (uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g = (uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b = (uint16)(rgba[0][BCOMP]) << SHIFT; + col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); + ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), col); + } + x++; + y++; + rgba++; + } +} + +void GGIwrite_mono_rgba_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLchan rgba[4], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + ggi_color rgb; + ggi_pixel col; + + rgb.r = (uint16)(rgba[RCOMP]) << SHIFT; + rgb.g = (uint16)(rgba[GCOMP]) << SHIFT; + rgb.b = (uint16)(rgba[BCOMP]) << SHIFT; + col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); + + while (n--) { + if (*mask++) + ggiPutPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), col); + x++; + y++; + } +} + +/**********************************************************************/ +/***** Read arrays of pixels *****/ +/**********************************************************************/ + +void GGIread_ci32_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint ci[], const GLubyte mask[]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + while (n--) { + if (*mask++) + ggiGetPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), ci); + ci++; + x++; + y++; + } +} + +void GGIread_rgba_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], + const GLubyte mask[] ) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + ggi_color rgb; + ggi_pixel col; + + while (n--) + { + if (*mask++) + { + ggiGetPixel(ggi_ctx->ggi_visual, *x, FLIP(*y), &col); + ggiUnmapPixel(ggi_ctx->ggi_visual, col, &rgb); + rgba[0][RCOMP] = rgb.r >> SHIFT; + rgba[0][GCOMP] = rgb.g >> SHIFT; + rgba[0][BCOMP] = rgb.b >> SHIFT; + rgba[0][ACOMP] = 0; + } + x++; + y++; + rgba++; + } +} + +int GGIextend_visual(ggi_visual_t vis) +{ + return 0; +} + +//static swrast_tri_func ggimesa_stubs_get_triangle_func(GLcontext *ctx); + +int GGIsetup_driver(ggi_mesa_context_t ggi_ctx) +{ + struct swrast_device_driver *swdd = + _swrast_GetDeviceDriverReference(ggi_ctx->gl_ctx); + + GGIMESADPRINT_CORE("stubs: setup_driver\n"); + + swdd->WriteRGBASpan = GGIwrite_rgba_span; + swdd->WriteRGBSpan = GGIwrite_rgb_span; + swdd->WriteMonoRGBASpan = GGIwrite_mono_rgba_span; + swdd->WriteRGBAPixels = GGIwrite_rgba_pixels; + swdd->WriteMonoRGBAPixels = GGIwrite_mono_rgba_pixels; + + swdd->WriteCI32Span = GGIwrite_ci32_span; + swdd->WriteCI8Span = GGIwrite_ci8_span; + swdd->WriteMonoCISpan = GGIwrite_mono_ci_span; + swdd->WriteCI32Pixels = GGIwrite_ci32_pixels; + swdd->WriteMonoCIPixels = GGIwrite_mono_ci_pixels; + + swdd->ReadCI32Span = GGIread_ci32_span; + swdd->ReadRGBASpan = GGIread_rgba_span; + swdd->ReadCI32Pixels = GGIread_ci32_pixels; + swdd->ReadRGBAPixels = GGIread_rgba_pixels; + + return 0; +} + +void GGIupdate_state(ggi_mesa_context_t *ctx) +{ + //ctx->Driver.TriangleFunc = _swsetup_Triangle; +} + +/* +void GGItriangle_flat(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2) +{ +//#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE + +#define SETUP_CODE \ + ggi_color color; \ + color.r = v0->color[0]; \ + color.g = v0->color[1]; \ + color.b = v0->color[2]; \ + color.a = v0->color[3]; \ + ggiSetGCForeground(VIS, ggiMapColor(VIS, &color)); + +#define INNER_LOOP(LEFT,RIGHT,Y) \ + ggiDrawHLine(VIS,LEFT,FLIP(Y),RIGHT-LEFT); + +#include "swrast/s_tritemp.h" +} + + +static void GGItriangle_flat_depth(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2) +{ +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE + +#define SETUP_CODE \ + ggi_color color; \ + color.r = v0->color[0]; \ + color.g = v0->color[1]; \ + color.b = v0->color[2]; \ + color.a = v0->color[3]; \ + ggiSetGCForeground(VIS, ggiMapColor(VIS, &color)); + +#define INNER_LOOP(LEFT,RIGHT,Y) \ + { \ + GLint i,xx=LEFT,yy=FLIP(Y),n=RIGHT-LEFT,length=0; \ + GLint startx=xx; \ + for (i=0;i<n;i++){ \ + GLdepth z=FixedToDepth(ffz); \ + if (z<zRow[i]) \ + { \ + zRow[i]=z; \ + length++; \ + } \ + else \ + { \ + if (length) \ + { \ + ggiDrawHLine(VIS,startx,yy,length); \ + length=0; \ + } \ + startx=xx+i+1; \ + } \ + ffz+=fdzdx; \ + } \ + if (length) ggiDrawHLine(VIS,startx,yy,length); \ + } + +#include "swrast/s_tritemp.h" +} + + +static swrast_tri_func ggimesa_stubs_get_triangle_func(GLcontext *ctx) +{ + if (ctx->Stencil.Enabled) return NULL; + if (ctx->Polygon.SmoothFlag) return NULL; + if (ctx->Polygon.StippleFlag) return NULL; + if (ctx->Texture._ReallyEnabled) return NULL; + if (ctx->Light.ShadeModel==GL_SMOOTH) return NULL; + if (ctx->Depth.Test && ctx->Depth.Func != GL_LESS) return NULL; + + if (ctx->Depth.Test) + return GGItriangle_flat_depth; + + return GGItriangle_flat; +} +*/ +static int GGIopen(ggi_visual_t vis, struct ggi_dlhandle *dlh, + const char *args, void *argptr, uint32 *dlret) +{ + LIBGGI_MESAEXT(vis)->update_state = GGIupdate_state; + LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver; + + *dlret = GGI_DL_OPDRAW; + return 0; +} + +int MesaGGIdl_stubs(int func, void **funcptr) +{ + switch (func) { + case GGIFUNC_open: + *funcptr = GGIopen; + return 0; + case GGIFUNC_exit: + case GGIFUNC_close: + *funcptr = NULL; + return 0; + default: + *funcptr = NULL; + } + return GGI_ENOTFOUND; +} diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/.cvsignore b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/.cvsignore new file mode 100644 index 000000000..98858db2c --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/.cvsignore @@ -0,0 +1 @@ +fbdev.conf diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/fbdev.conf.in b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/fbdev.conf.in new file mode 100644 index 000000000..2acb89426 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/fbdev.conf.in @@ -0,0 +1,4 @@ +# GGIMesa fbdev target configuration +.root: @ggi_libdir@/ggi/mesa/default + +tgt-fbdev-kgicon-generic-mesa genkgi.so diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/fbdev_mode.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/fbdev_mode.c new file mode 100644 index 000000000..85c35ffe0 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/fbdev_mode.c @@ -0,0 +1,130 @@ +/****************************************************************************** + + display-fbdev-mesa + + Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************************************************** +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <sys/mman.h> + +#include <linux/fb.h> + +#include <ggi/internal/ggi-dl.h> +#include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/display_fbdev.h> +#include <ggi/mesa/debug.h> + +#ifndef MAP_FAILED +#define MAP_FAILED ((void*)-1) +#endif + +#define FB_KLUDGE_FONTX 8 +#define FB_KLUDGE_FONTY 16 +#define FB_KLUDGE_TEXTMODE 13 +#define TIMINGFILE "/etc/fb.modes" + +int GGIMesa_fbdev_getapi(ggi_visual *vis, int num, char *apiname, char *arguments) +{ + struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis); + + arguments = '\0'; + + switch(num) { + case 0: + if (priv->oldpriv->have_accel) { + strcpy(apiname, priv->oldpriv->accel); + return 0; + } + break; + } + + return -1; +} + +static int do_setmode(ggi_visual *vis) +{ + struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis); + int err, id; + char libname[GGI_API_MAXLEN], libargs[GGI_API_MAXLEN]; + ggi_graphtype gt; + + _ggiZapMode(vis, ~GGI_DL_OPDISPLAY); + priv->have_accel = 0; + + for (id = 1; GGIMesa_fbdev_getapi(vis, id, libname, libargs) == 0; id++) { + if (_ggiOpenDL(vis, libname, libargs, NULL) == 0) { + GGIMESADPRINT_LIBS(stderr, "display-fbdev-mesa: Error opening the " + "%s (%s) library.\n", libname, libargs); + return GGI_EFATAL; + } + + GGIMESADPRINT_CORE("Success in loading %s (%s)\n", + libname, libargs); + } + + if (priv->oldpriv->accel && + _ggiOpenDL(vis, priv->accel, NULL, NULL) != 0) { + priv->have_accel = 1; + } else { + priv->have_accel = 0; + } + vis->accelactive = 0; + + ggiIndicateChange(vis, GGI_CHG_APILIST); + + GGIMESADPRINT_CORE("display-fbdev-mesa: do_setmode SUCCESS\n"); + + return 0; +} + + +int GGIMesa_fbdev_setmode(ggi_visual *vis, ggi_mode *mode) +{ + int err; + + if ((err = ggiCheckMode(vis, mode)) != 0) { + return err; + } + + GGIMESADPRINT_CORE("display-fbdev-mesa: setmode %dx%d#%dx%dF%d[0x%02x]\n", + mode->visible.x, mode->visible.y, + mode->virt.x, mode->virt.y, + mode->frames, mode->graphtype); + + memcpy(LIBGGI_MODE(vis), mode, sizeof(ggi_mode)); + + /* Now actually set the mode */ + err = do_setmode(vis); + if (err != 0) { + return err; + } + + GGIMESADPRINT_CORE("display-fbdev-mesa: setmode success.\n"); + + return 0; +} diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/fbdev_visual.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/fbdev_visual.c new file mode 100644 index 000000000..f0c1771c7 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/display/fbdev_visual.c @@ -0,0 +1,138 @@ +/****************************************************************************** + + display-fbdev-mesa: visual handling + + Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************************************************** +*/ + +#include <ggi/internal/ggi-dl.h> +#include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/display_fbdev.h> +#include <ggi/mesa/debug.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> + + +#ifdef HAVE_SYS_VT_H +#include <sys/vt.h> +#else +#include <linux/vt.h> +#endif +#ifdef HAVE_LINUX_KDEV_T_H +#include <linux/kdev_t.h> +#endif +#include <linux/tty.h> + +#define MAX_DEV_LEN 63 +#define DEFAULT_FBNUM 0 + +static char accel_prefix[] = "tgt-fbdev-"; +#define PREFIX_LEN (sizeof(accel_prefix)) + +typedef struct { + int async; + char *str; +} accel_info; + +static accel_info accel_strings[] = { + { 0, "kgicon-generic",}, /* no accel - check for KGIcon */ + { 0, NULL }, /* Atari Blitter */ +}; + +#define NUM_ACCELS (sizeof(accel_strings)/sizeof(accel_info)) + + + +static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh, + const char *args, void *argptr, uint32 *dlret) +{ + int err; + struct fbdev_priv_mesa *priv; + ggifunc_getapi *oldgetapi; + + + priv->oldpriv = LIBGGI_PRIVATE(vis); /* Hook back */ + + GGIMESA_PRIV(vis) = priv = malloc(sizeof(struct fbdev_priv_mesa)); + if (priv == NULL) { + fprintf(stderr, "GGIMesa: Failed to allocate fbdev private data\n"); + return GGI_ENOMEM; + } + + oldgetapi = vis->opdisplay->getapi; + vis->opdisplay->getapi = GGIMesa_fbdev_getapi; + changed(vis, GGI_CHG_APILIST); + + /* If the accel sublibs didn't sucessfuly hook a driver, + * back up and keep looking */ + if ((LIBGGI_MESAEXT(vis)->update_state == NULL) || + (LIBGGI_MESAEXT(vis)->setup_driver == NULL)) + { + vis->opdisplay->getapi = oldgetapi; + } + + *dlret = GGI_DL_EXTENSION; + return 0; +} + + +static int GGIclose(ggi_visual *vis, struct ggi_dlhandle *dlh) +{ + struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis); + + if (priv) { + LIBGGI_PRIVATE(vis) = priv->oldpriv; + free(priv); + } + + return 0; +} + + +int MesaGGIdl_fbdev_mesa(int func, void **funcptr) +{ + switch (func) { + case GGIFUNC_open: + *funcptr = GGIopen; + return 0; + case GGIFUNC_exit: + *funcptr = NULL; + return 0; + case GGIFUNC_close: + *funcptr = GGIclose; + return 0; + default: + *funcptr = NULL; + } + + return GGI_ENOTFOUND; +} + + +#include <ggi/internal/ggidlinit.h> diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/ggimesa.c b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/ggimesa.c new file mode 100644 index 000000000..0652d7624 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/ggimesa.c @@ -0,0 +1,696 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997-1998 Uwe Maurer - uwe_maurer@t-online.de + * 2002 Filip Spacek + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#ifdef HAVE_CONFIG_H +#include "conf.h" +#endif + +#include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/debug.h> +#include "extensions.h" +#include "buffers.h" +#include "colormac.h" +#include "imports.h" +#include "matrix.h" +#include "swrast/swrast.h" +#include "swrast_setup/swrast_setup.h" +#include "tnl/tnl.h" +#include "tnl/t_context.h" +#include "tnl/t_pipeline.h" +#include "array_cache/acache.h" +#include "teximage.h" +#include "texformat.h" +#include "texstore.h" + +/* We use LibGG to manage config files */ +#include <ggi/gg.h> + + +/* XXX: Those #defines should be provided via + * config.h + */ +#define GGIMESAPATHTAG "pAtHTAg" +#define GGIMESACONFDIR "pAtHTAg/usr/local/etc/ggi" +#define GGIMESATAGLEN 7 +#define GGIMESACONFFILE "ggimesa.conf" + + +/* Static variables + */ +static int _ggimesaLibIsUp = 0; +static void *_ggimesaConfigHandle; +static char _ggimesaconfstub[512] = GGIMESACONFDIR; +static char *_ggimesaconfdir = _ggimesaconfstub+GGIMESATAGLEN; + +int _ggimesaDebugSync = 0; +uint32 _ggimesaDebugState = 0; + + + +/* Extension ID. Defaulting to -1 should make segfault on abuse more likely... + */ +ggi_extid _ggiMesaID = -1; + + +#define SUBLIB_PREFIX "MesaGGIdl_" + + +/* + * Returns the directory where global config files are kept + */ + +const char *ggiMesaGetConfDir(void) +{ +#ifdef __WIN32__ + /* On Win32 we allow overriding of the compiled in path. */ + const char *envdir = getenv("GGI_CONFDIR"); + if (envdir) return envdir; +#endif + return _ggimesaconfdir; +} + + +/* Dummy function which returns -1 + We use this to reset the function pointers */ +static int _ggi_error(void) +{ + GGIMESADPRINT_CORE("_ggi_error() called\n"); + + return -1; +} + + +static int changed(ggi_visual_t vis, int whatchanged) +{ + GLcontext *ctx; + ctx = _mesa_get_current_context(); + + GGIMESADPRINT_CORE("changed() called\n"); + + switch (whatchanged) { + case GGI_CHG_APILIST: + { + char api[GGI_MAX_APILEN]; + char args[GGI_MAX_APILEN]; + int i; + const char *fname; + ggi_dlhandle *lib; + + GLvisual *gl_vis = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual); + GLframebuffer *gl_fb = &(LIBGGI_MESAEXT(vis)->mesa_buffer); + + /* Initialize the framebuffer to provide all necessary + buffers in software. The target libraries that are loaded + next are free to modify this according to their + capabilities. + */ + /* FIXME: if the target changes capabilities we'll leak + swrast's memory !!! Need to deallocate first */ + _mesa_initialize_framebuffer(gl_fb, gl_vis, + gl_vis->depthBits > 0, + gl_vis->stencilBits > 0, + gl_vis->accumRedBits > 0, + gl_vis->alphaBits > 0); + + for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++) { + strcat(api, "-mesa"); + GGIMESADPRINT_CORE("GGIMesa: looking for" + "a sublib named %s\n", api); + fname = ggMatchConfig(_ggimesaConfigHandle, api, NULL); + if (fname == NULL) { + /* No special implementation for this sublib */ + continue; + } + lib = ggiExtensionLoadDL(vis, fname, args, NULL, + SUBLIB_PREFIX); + } + + /* The targets have cleared everything they can do from + the framebuffer structure so we provide the rest in sw + */ + _swrast_alloc_buffers(gl_fb); + + break; + } + } + return 0; +} + + +int ggiMesaInit() +{ + int err; + char *str; + char *conffile; + + GGIMESADPRINT_CORE("ggiMesaInit() called\n"); + + _ggimesaLibIsUp++; + if (_ggimesaLibIsUp > 1) return 0; /* Initialize only at first call */ + + str = getenv("GGIMESA_DEBUGSYNC"); + if (str != NULL) { + _ggimesaDebugSync = 1; + } + + str = getenv("GGIMESA_DEBUG"); + if (str != NULL) { + _ggimesaDebugState = atoi(str); + GGIMESADPRINT_CORE("%s Debugging=%d\n", + _ggimesaDebugSync ? "sync" : "async", + _ggimesaDebugState); + } + + + conffile = malloc(strlen(ggiMesaGetConfDir()) + 1 + + strlen(GGIMESACONFFILE) +1); + if (conffile == NULL) { + fprintf(stderr, "GGIMesa: unable to allocate memory for config filename.\n"); + return GGI_ENOMEM; + } + sprintf(conffile, "%s%c%s", + ggiMesaGetConfDir(), '/', GGIMESACONFFILE); + err = ggLoadConfig(conffile, &_ggimesaConfigHandle); + if (err != GGI_OK) { + fprintf(stderr, "GGIMesa: Couldn't open %s\n", + conffile); + free(conffile); + _ggimesaLibIsUp--; + return err; + } + free(conffile); + + _ggiMesaID = ggiExtensionRegister("GGIMesa", + sizeof(struct ggi_mesa_ext), changed); + if (_ggiMesaID < 0) { + fprintf(stderr, "GGIMesa: failed to register as extension\n"); + _ggimesaLibIsUp--; + ggFreeConfig(_ggimesaConfigHandle); + return _ggiMesaID; + } + + return 0; +} + +int ggiMesaExit(void) +{ + int rc; + + GGIMESADPRINT_CORE("ggiMesaExit() called\n"); + + if (!_ggimesaLibIsUp) return -1; + + if (_ggimesaLibIsUp > 1) { + /* Exit only at last call */ + _ggimesaLibIsUp--; + return 0; + } + + rc = ggiExtensionUnregister(_ggiMesaID); + ggFreeConfig(_ggimesaConfigHandle); + + _ggimesaLibIsUp = 0; + + return rc; +} + + + + +static void gl_ggiUpdateState(GLcontext *ctx, GLuint new_state); + + +static void gl_ggiGetSize(GLframebuffer *fb, GLuint *width, GLuint *height) +{ + /* FIXME: this is a hack to work around the new interface */ + GLcontext *ctx; + ggi_mesa_context_t ggi_ctx; + ctx = _mesa_get_current_context(); + ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + + GGIMESADPRINT_CORE("gl_ggiGetSize() called\n"); + + *width = LIBGGI_VIRTX(ggi_ctx->ggi_visual); + *height = LIBGGI_VIRTY(ggi_ctx->ggi_visual); + printf("returning %d, %d\n", *width, *height); +} + +static void gl_ggiViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) +{ + /* poll for window size change and realloc software Z/stencil/etc if needed */ + _mesa_ResizeBuffersMESA(); +} + + +static void gl_ggiSetIndex(GLcontext *ctx, GLuint ci) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + + GGIMESADPRINT_CORE("gl_ggiSetIndex() called\n"); + + ggiSetGCForeground(ggi_ctx->ggi_visual, ci); + ggi_ctx->color = (ggi_pixel)ci; +} + +static void gl_ggiSetClearIndex(GLcontext *ctx, GLuint ci) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + + GGIMESADPRINT_CORE("gl_ggiSetClearIndex() called\n"); + + ggiSetGCForeground(ggi_ctx->ggi_visual, ci); + ggi_ctx->clearcolor = (ggi_pixel)ci; +} + +static void gl_ggiSetClearColor(GLcontext *ctx, const GLfloat color[4]) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + ggi_color rgb; + ggi_pixel col; + GLubyte byteColor[3]; + + GGIMESADPRINT_CORE("gl_ggiSetClearColor() called\n"); + + CLAMPED_FLOAT_TO_UBYTE(byteColor[0], color[0]); + CLAMPED_FLOAT_TO_UBYTE(byteColor[1], color[1]); + CLAMPED_FLOAT_TO_UBYTE(byteColor[2], color[2]); + + rgb.r = (uint16)byteColor[0] << SHIFT; + rgb.g = (uint16)byteColor[1] << SHIFT; + rgb.b = (uint16)byteColor[2] << SHIFT; + col = ggiMapColor(ggi_ctx->ggi_visual, &rgb); + ggiSetGCForeground(ggi_ctx->ggi_visual, col); + ggi_ctx->clearcolor = col; +} + +static void gl_ggiClear(GLcontext *ctx, GLbitfield mask, GLboolean all, + GLint x, GLint y, GLint width, GLint height) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + + GGIMESADPRINT_CORE("gl_ggiClear() called\n"); + + if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) { + ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->clearcolor); + + if (all) { + int w, h; + w = LIBGGI_VIRTX(ggi_ctx->ggi_visual); + h = LIBGGI_VIRTX(ggi_ctx->ggi_visual); + ggiDrawBox(ggi_ctx->ggi_visual, 0, 0, w, h); + } else { + ggiDrawBox(ggi_ctx->ggi_visual, x, y, //FLIP(y), + width, height); + } + ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->color); + + mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT); + } + _swrast_Clear(ctx, mask, all, x, y, width, height); + +} + + +/* Set the buffer used for reading */ +/* XXX support for separate read/draw buffers hasn't been tested */ +static GLboolean gl_ggiSetBuffer(GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + + printf("set read %d\n", bufferBit); + GGIMESADPRINT_CORE("gl_ggiSetBuffer() called\n"); + + if (bufferBit == DD_FRONT_LEFT_BIT) + { + ggiSetReadFrame(ggi_ctx->ggi_visual, + ggiGetDisplayFrame(ggi_ctx->ggi_visual)); + ggiSetWriteFrame(ggi_ctx->ggi_visual, + ggiGetDisplayFrame(ggi_ctx->ggi_visual)); + return GL_TRUE; + } + else if (bufferBit == DD_BACK_LEFT_BIT) + { + ggiSetReadFrame(ggi_ctx->ggi_visual, + ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1); + ggiSetWriteFrame(ggi_ctx->ggi_visual, + ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1); + return GL_TRUE; + } + else + return GL_FALSE; +} + + +static const GLubyte * gl_ggiGetString(GLcontext *ctx, GLenum name) +{ + GGIMESADPRINT_CORE("gl_ggiGetString() called\n"); + + if (name == GL_RENDERER) { + return (GLubyte *) "Mesa GGI"; + } else { + return NULL; + } +} + +static void gl_ggiFlush(GLcontext *ctx) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + + GGIMESADPRINT_CORE("gl_ggiFlush() called\n"); + + ggiFlush(ggi_ctx->ggi_visual); +} + +static void gl_ggiIndexMask(GLcontext *ctx, GLuint mask) +{ + GGIMESADPRINT_CORE("gl_ggiIndexMask() called\n"); +} + +static void gl_ggiColorMask(GLcontext *ctx, GLboolean rmask, GLboolean gmask, + GLboolean bmask, GLboolean amask) +{ + GGIMESADPRINT_CORE("gl_ggiColorMask() called\n"); +} + +static void gl_ggiEnable(GLcontext *ctx, GLenum pname, GLboolean state) +{ + GGIMESADPRINT_CORE("gl_ggiEnable() called\n"); +} + +static void gl_ggiSetupPointers(GLcontext *ctx) +{ + TNLcontext *tnl; + + GGIMESADPRINT_CORE("gl_ggiSetupPointers() called\n"); + + /* General information */ + ctx->Driver.GetString = gl_ggiGetString; + ctx->Driver.GetBufferSize = gl_ggiGetSize; + ctx->Driver.Viewport = gl_ggiViewport; + ctx->Driver.Finish = gl_ggiFlush; + ctx->Driver.Flush = gl_ggiFlush; + + /* Software rasterizer pixel paths */ + ctx->Driver.Accum = _swrast_Accum; + ctx->Driver.Bitmap = _swrast_Bitmap; + ctx->Driver.Clear = gl_ggiClear; + ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; + ctx->Driver.CopyPixels = _swrast_CopyPixels; + ctx->Driver.DrawPixels = _swrast_DrawPixels; + ctx->Driver.ReadPixels = _swrast_ReadPixels; + ctx->Driver.DrawBuffer = _swrast_DrawBuffer; + + /* Software texturing */ + ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format; + ctx->Driver.TexImage1D = _mesa_store_teximage1d; + ctx->Driver.TexImage2D = _mesa_store_teximage2d; + ctx->Driver.TexImage3D = _mesa_store_teximage3d; + ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d; + ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d; + ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d; + ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage; + + ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d; + ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d; + ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d; + ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d; + ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d; + ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d; + + ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d; + ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d; + ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d; + ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d; + ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d; + + /* Imaging extensions */ + ctx->Driver.CopyColorTable = _swrast_CopyColorTable; + ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable; + ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; + ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; + + /* State change callbacks */ + ctx->Driver.ClearIndex = gl_ggiSetClearIndex; + ctx->Driver.ClearColor = gl_ggiSetClearColor; + ctx->Driver.IndexMask = gl_ggiIndexMask; + ctx->Driver.ColorMask = gl_ggiColorMask; + ctx->Driver.Enable = gl_ggiEnable; + + ctx->Driver.UpdateState = gl_ggiUpdateState; + + /* Initialize TNL driver interface */ + tnl = TNL_CONTEXT(ctx); + tnl->Driver.RunPipeline = _tnl_run_pipeline; + + /* Install setup for tnl */ + _swsetup_Wakeup(ctx); +} + +static void get_mode_info(ggi_visual_t vis, int *r, int *g, int *b, + GLboolean *rgb, GLboolean *db, int *ci) +{ + unsigned int i; + + *r = 0; + *g = 0; + *b = 0; + + for(i = 0; i < sizeof(ggi_pixel)*8; ++i) { + int mask = 1 << i; + if (LIBGGI_PIXFMT(vis)->red_mask & mask) + ++(*r); + if (LIBGGI_PIXFMT(vis)->green_mask & mask) + ++(*g); + if (LIBGGI_PIXFMT(vis)->blue_mask & mask) + ++(*b); + } + + *rgb = GT_SCHEME(LIBGGI_MODE(vis)->graphtype) == GT_TRUECOLOR; + *db = LIBGGI_MODE(vis)->frames > 1; + *ci = GT_SIZE(LIBGGI_MODE(vis)->graphtype); + + printf("rgb (%d, %d, %d) db %d, rgb %d ci %d\n",*r,*g,*b,*db,*rgb,*ci); +} + + +int ggiMesaAttach(ggi_visual_t vis) +{ + int rc; + + GGIMESADPRINT_CORE("ggiMesaAttach() called\n"); + + rc = ggiExtensionAttach(vis, _ggiMesaID); + if (rc == 0) + { + int r, g, b, ci; + GLboolean rgb, db; + GLvisual *gl_visual; + + /* We are creating the primary instance */ + memset(LIBGGI_MESAEXT(vis), 0, sizeof(struct ggi_mesa_ext)); + LIBGGI_MESAEXT(vis)->update_state = (void *)_ggi_error; + LIBGGI_MESAEXT(vis)->setup_driver = (void *)_ggi_error; + + /* Initialize default mesa visual */ + get_mode_info(vis, &r, &g, &b, &rgb, &db, &ci); + gl_visual = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual); + _mesa_initialize_visual(gl_visual, + rgb, db, 0 /* No stereo */, + r, g, b, 0 /* No alpha */, ci, + 0 /* No depth */, 0 /* No stencil */, + 0, 0, 0, 0 /* No accum */, 0); + + /* Now fake an "API change" so the right libs get loaded */ + changed(vis, GGI_CHG_APILIST); + } + + return rc; +} + +int ggiMesaDetach(ggi_visual_t vis) +{ + GGIMESADPRINT_CORE("ggiMesaDetach() called\n"); + + return ggiExtensionDetach(vis, _ggiMesaID); +} + +int ggiMesaExtendVisual(ggi_visual_t vis, GLboolean alpha_flag, + GLboolean stereo_flag, GLint depth_size, + GLint stencil_size, GLint accum_red_size, + GLint accum_green_size, GLint accum_blue_size, + GLint accum_alpha_size, GLint num_samples) +{ + GLvisual *gl_vis = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual); + int r, g, b, ci; + GLboolean db, rgb; + + get_mode_info(vis, &r, &g, &b, &rgb, &db, &ci); + + /* Initialize the visual with the provided information */ + _mesa_initialize_visual(gl_vis, + rgb, db, stereo_flag, + r, g, b, 0 /* FIXME */, ci, + depth_size, stencil_size, + accum_red_size, accum_green_size, + accum_blue_size, accum_alpha_size, 0); + + /* Now fake an "API change" so the right libs get loaded. After all, + extending the visual by all these new buffers could be considered + a "mode change" which requires an "API change". + */ + changed(vis, GGI_CHG_APILIST); + + return 0; +} + + +ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis) +{ + ggi_mesa_context_t ctx; + int err; + + GGIMESADPRINT_CORE("ggiMesaCreateContext() called\n"); + + ctx = (ggi_mesa_context_t)malloc(sizeof(struct ggi_mesa_context)); + if (!ctx) + return NULL; + + ctx->ggi_visual = vis; + ctx->color = 0; + + ctx->gl_ctx = + _mesa_create_context(&(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual), + NULL, (void *) ctx, GL_FALSE); + if (!ctx->gl_ctx) + goto free_context; + + _mesa_enable_sw_extensions(ctx->gl_ctx); + + _swrast_CreateContext(ctx->gl_ctx); + _ac_CreateContext(ctx->gl_ctx); + _tnl_CreateContext(ctx->gl_ctx); + _swsetup_CreateContext(ctx->gl_ctx); + + gl_ggiSetupPointers(ctx->gl_ctx); + + /* Make sure that an appropriate sublib has been loaded */ + if (!LIBGGI_MESAEXT(ctx->ggi_visual)->setup_driver){ + GGIMESADPRINT_CORE("setup_driver==NULL!\n"); + GGIMESADPRINT_CORE("Please check your config files!\n"); + goto free_context; + } + + /* Set up the sublib driver */ + err = LIBGGI_MESAEXT(ctx->ggi_visual)->setup_driver(ctx); + if (err){ + GGIMESADPRINT_CORE("setup_driver failed (err = %d)", err); + goto free_gl_context; + } + + return ctx; + +free_gl_context: + _mesa_destroy_context(ctx->gl_ctx); +free_context: + free(ctx); + + return NULL; +} + +void ggiMesaDestroyContext(ggi_mesa_context_t ctx) +{ + GGIMESADPRINT_CORE("ggiMesaDestroyContext() called\n"); + + if(!ctx) + return; + + _mesa_destroy_context(ctx->gl_ctx); + free(ctx); +} + +void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis) +{ + GGIMESADPRINT_CORE("ggiMesaMakeCurrent(ctx = %p) called\n", ctx); + + /* FIXME: clean up where are ggi_vis */ + if (ctx->ggi_visual != vis) { + GGIMESADPRINT_CORE("Cannot migrate GL contexts\n"); + return; + } + + _mesa_make_current(ctx->gl_ctx, &LIBGGI_MESAEXT(vis)->mesa_buffer); +} + + +/* + * Swap front/back buffers for current context if double buffered. + */ +void ggiMesaSwapBuffers(void) +{ + GLcontext *ctx; + ggi_mesa_context_t ggi_ctx; + ctx = _mesa_get_current_context(); + ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + + GGIMESADPRINT_CORE("ggiMesaSwapBuffers() called\n"); + + _mesa_notifySwapBuffers(ctx); + gl_ggiFlush(ctx); + + ggiSetDisplayFrame(ggi_ctx->ggi_visual, + !ggiGetDisplayFrame(ggi_ctx->ggi_visual)); + ggiSetWriteFrame(ggi_ctx->ggi_visual, + !ggiGetWriteFrame(ggi_ctx->ggi_visual)); + ggiSetReadFrame(ggi_ctx->ggi_visual, + !ggiGetReadFrame(ggi_ctx->ggi_visual)); + + GGIMESADPRINT_CORE("swap disp: %d, write %d\n", + ggiGetDisplayFrame(ggi_ctx->ggi_visual), + ggiGetWriteFrame(ggi_ctx->ggi_visual)); +} + +static void gl_ggiUpdateState(GLcontext *ctx, GLuint new_state) +{ + ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; + + GGIMESADPRINT_CORE("gl_ggiUpdateState() called\n"); + + /* Propogate statechange information to swrast and swrast_setup + * modules. The GGI driver has no internal GL-dependent state. + */ + _swrast_InvalidateState(ctx, new_state); + _swsetup_InvalidateState(ctx, new_state); + _tnl_InvalidateState(ctx, new_state); + + /* XXX: Better use an assertion that bails out here on failure */ + if (!LIBGGI_MESAEXT(ggi_ctx->ggi_visual)->update_state) { + GGIMESADPRINT_CORE("update_state == NULL!\n"); + GGIMESADPRINT_CORE("Please check your config files!\n"); + ggiPanic(""); + } + + LIBGGI_MESAEXT(ggi_ctx->ggi_visual)->update_state(ggi_ctx); +} + diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/ggimesa.conf.in b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/ggimesa.conf.in new file mode 100644 index 000000000..72132334f --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/ggimesa.conf.in @@ -0,0 +1,13 @@ +# GGIMesa global configuration +.root: @ggi_libdir@/ggi/mesa + +generic-stubs-mesa default/stubs.so +generic-linear-8-mesa default/linear_8.so +generic-linear-15-mesa default/linear_15.so +generic-linear-16-mesa default/linear_16.so +generic-linear-24-mesa default/linear_24.so +generic-linear-32-mesa default/linear_32.so + +display-fbdev-mesa display/fbdev.so + +# .include @ggi_confdir@/ggi/mesa/targets/fbdev.conf diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/debug.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/debug.h new file mode 100644 index 000000000..35d11624c --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/debug.h @@ -0,0 +1,260 @@ +/* $Id: debug.h,v 1.5 2003/09/22 15:18:51 brianp Exp $ +****************************************************************************** + + GGIMesa debugging macros + + Copyright (C) 1998-1999 Marcus Sundberg [marcus@ggi-project.org] + Copyright (C) 1999-2000 Jon Taylor [taylorj@ggi-project.org] + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************************************************** +*/ + +#ifndef _GGI_MESA_INTERNAL_DEBUG_H +#define _GGI_MESA_INTERNAL_DEBUG_H + +#include <stdio.h> +#include <stdarg.h> +#include <ggi/types.h> +#include <ggi/gg.h> + +#ifndef DEBUG +#define DEBUG +#endif + +__BEGIN_DECLS + +/* Exported variables */ +#ifdef BUILDING_GGIMESA +extern uint32 _ggimesaDebugState; +extern int _ggimesaDebugSync; +#else +IMPORTVAR uint32 _ggimesaDebugState; +IMPORTVAR int _ggimesaDebugSync; +#endif + +__END_DECLS + + +/* Debugging types + * bit 0 is reserved! */ + +#define GGIMESADEBUG_CORE (1<<1) /* 2 */ +#define GGIMESADEBUG_MODE (1<<2) /* 4 */ +#define GGIMESADEBUG_COLOR (1<<3) /* 8 */ +#define GGIMESADEBUG_DRAW (1<<4) /* 16 */ +#define GGIMESADEBUG_MISC (1<<5) /* 32 */ +#define GGIMESADEBUG_LIBS (1<<6) /* 64 */ +#define GGIMESADEBUG_EVENTS (1<<7) /* 128 */ + +#define GGIMESADEBUG_ALL 0xffffffff + +#ifdef __GNUC__ + +#ifdef DEBUG +#define GGIMESADPRINT(args...) if (_ggimesaDebugState) { ggDPrintf(_ggimesaDebugSync, "GGIMesa",args); } +#define GGIMESADPRINT_CORE(args...) if (_ggimesaDebugState & GGIMESADEBUG_CORE) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } +#define GGIMESADPRINT_MODE(args...) if (_ggimesaDebugState & GGIMESADEBUG_MODE) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } +#define GGIMESADPRINT_COLOR(args...) if (_ggimesaDebugState & GGIMESADEBUG_COLOR) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } +#define GGIMESADPRINT_DRAW(args...) if (_ggimesaDebugState & GGIMESADEBUG_DRAW) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } +#define GGIMESADPRINT_MISC(args...) if (_ggimesaDebugState & GGIMESADEBUG_MISC) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } +#define GGIMESADPRINT_LIBS(args...) if (_ggimesaDebugState & GGIMESADEBUG_LIBS) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } +#define GGIMESADPRINT_EVENTS(args...) if (_ggimesaDebugState & GGIMESADEBUG_EVENTS) { ggDPrintf(_ggimesaDebugSync,"GGIMesa",args); } +#else /* DEBUG */ +#define GGIMESADPRINT(args...) do{}while(0) +#define GGIMESADPRINT_CORE(args...) do{}while(0) +#define GGIMESADPRINT_MODE(args...) do{}while(0) +#define GGIMESADPRINT_COLOR(args...) do{}while(0) +#define GGIMESADPRINT_DRAW(args...) do{}while(0) +#define GGIMESADPRINT_MISC(args...) do{}while(0) +#define GGIMESADPRINT_LIBS(args...) do{}while(0) +#define GGIMESADPRINT_EVENTS(args...) do{}while(0) +#endif /* DEBUG */ + +#else /* __GNUC__ */ + +__BEGIN_DECLS + +static inline void GGIMESADPRINT(const char *form,...) +{ +#ifdef DEBUG + if (_ggiDebugState) { + va_list args; + + fprintf(stderr, "GGIMesa: "); + va_start(args, form); + vfprintf(stderr, form, args); + va_end(args); + if (_ggimesaDebugSync) fflush(stderr); + } +#endif +} + +static inline void GGIMESADPRINT_CORE(const char *form,...) +{ +#ifdef DEBUG + if (_ggiDebugState & GGIDEBUG_CORE) { + va_list args; + + fprintf(stderr, "GGIMesa: "); + va_start(args, form); + vfprintf(stderr, form, args); + va_end(args); + if (_ggimesaDebugSync) fflush(stderr); + } +#endif +} + +static inline void GGIMESADPRINT_MODE(const char *form,...) +{ +#ifdef DEBUG + if (_ggiDebugState & GGIDEBUG_MODE) { + va_list args; + + fprintf(stderr, "GGIMesa: "); + va_start(args, form); + vfprintf(stderr, form, args); + va_end(args); + if (_ggimesaDebugSync) fflush(stderr); + } +#endif +} + +static inline void GGIMESADPRINT_COLOR(const char *form,...) +{ +#ifdef DEBUG + if (_ggiDebugState & GGIDEBUG_COLOR) { + va_list args; + + fprintf(stderr, "GGIMesa: "); + va_start(args, form); + vfprintf(stderr, form, args); + va_end(args); + if (_ggimesaDebugSync) fflush(stderr); + } +#endif +} + +static inline void GGIMESADPRINT_DRAW(const char *form,...) +{ +#ifdef DEBUG + if (_ggiDebugState & GGIDEBUG_DRAW) { + va_list args; + + fprintf(stderr, "GGIMesa: "); + va_start(args, form); + vfprintf(stderr, form, args); + va_end(args); + if (_ggimesaDebugSync) fflush(stderr); + } +#endif +} + +static inline void GGIMESADPRINT_MISC(const char *form,...) +{ +#ifdef DEBUG + if (_ggiDebugState & GGIDEBUG_MISC) { + va_list args; + + fprintf(stderr, "GGIMesa: "); + va_start(args, form); + vfprintf(stderr, form, args); + va_end(args); + if (_ggimesaDebugSync) fflush(stderr); + } +#endif +} + +static inline void GGIMESADPRINT_LIBS(const char *form,...) +{ +#ifdef DEBUG + if (_ggiDebugState & GGIDEBUG_LIBS) { + va_list args; + + fprintf(stderr, "GGIMesa: "); + va_start(args, form); + vfprintf(stderr, form, args); + va_end(args); + if (_ggimesaDebugSync) fflush(stderr); + } +#endif +} + +static inline void GGIMESADPRINT_EVENTS(const char *form,...) +{ +#ifdef DEBUG + if (_ggiDebugState & GGIDEBUG_EVENTS) { + va_list args; + + fprintf(stderr, "GGIMesa: "); + va_start(args, form); + vfprintf(stderr, form, args); + va_end(args); + if (_ggimesaDebugSync) fflush(stderr); + } +#endif +} + +__END_DECLS + +#endif /* __GNUC__ */ + +#ifdef DEBUG +#define GGIMESA_ASSERT(x,str) \ +{ if (!(x)) { \ + fprintf(stderr,"GGIMESA:%s:%d: INTERNAL ERROR: %s\n",__FILE__,__LINE__,str); \ + exit(1); \ +} } +#define GGIMESA_APPASSERT(x,str) \ +{ if (!(x)) { \ + fprintf(stderr,"GGIMESA:%s:%d: APPLICATION ERROR: %s\n",__FILE__,__LINE__,str); \ + exit(1); \ +} } +#else /* DEBUG */ +#define GGIMESA_ASSERT(x,str) do{}while(0) +#define GGIMESA_APPASSERT(x,str) do{}while(0) +#endif /* DEBUG */ + +#ifdef DEBUG +# define GGIMESAD0(x) x +#else +# define GGIMESAD0(x) /* empty */ +#endif + +#ifdef GGIMESADLEV +# if GGIMESADLEV == 1 +# define GGIMESAD1(x) x +# define GGIMESAD2(x) /* empty */ +# define GGIMESAD3(x) /* empty */ +# elif GGIMESADLEV == 2 +# define GGIMESAD1(x) x +# define GGIMESAD2(x) x +# define GGIMESAD3(x) /* empty */ +# elif GGIMESADLEV > 2 +# define GGIMESAD1(x) x +# define GGIMESAD2(x) x +# define GGIMESAD3(x) x +# endif +#else +# define GGIMESAD1(x) /* empty */ +# define GGIMESAD2(x) /* empty */ +# define GGIMESAD3(x) /* empty */ +#endif + +#endif /* _GGI_MESA_INTERNAL_DEBUG_H */ diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h new file mode 100644 index 000000000..5c3c1e290 --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h @@ -0,0 +1,20 @@ +#ifndef _GGIMESA_DISPLAY_FBDEV_H +#define _GGIMESA_DISPLAY_FBDEV_H + +#include <ggi/internal/ggi-dl.h> +#include <ggi/display/fbdev.h> + +ggifunc_setmode GGIMesa_fbdev_setmode; +ggifunc_getapi GGIMesa_fbdev_getapi; + +#define FBDEV_PRIV_MESA(vis) ((struct fbdev_priv_mesa *)(FBDEV_PRIV(vis)->accelpriv)) + +struct fbdev_priv_mesa +{ + char *accel; + int have_accel; + void *accelpriv; + ggi_fbdev_priv *oldpriv; /* Hooks back to the LibGGI fbdev target's private data */ +}; + +#endif /* _GGIMESA_DISPLAY_FBDEV_H */ diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h new file mode 100644 index 000000000..ecdbe414f --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h @@ -0,0 +1,84 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#ifndef _GGIMESA_H +#define _GGIMESA_H + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include "config.h" +#include "context.h" +#include "drawpix.h" +#include "imports.h" +#include "matrix.h" +#include "state.h" +#include "mtypes.h" +#include "macros.h" +#include "depth.h" + +#undef ASSERT /* ASSERT is redefined */ + +#include <ggi/internal/internal.h> +#include <ggi/ggi_ext.h> +#include <ggi/ggi.h> +#include "GL/ggimesa.h" + +/* + * GGIMesa visual configuration. + * + * This structure "derives" from Mesa's GLvisual and extends it by + * GGI's visual. Combination of these two structures is enough to fully + * describe the mode the application is currently running in. GGI + * visual provides information about color configuration and buffering + * method, GLvisual fills the rest. + */ +struct ggi_mesa_visual { + GLvisual gl_visual; + ggi_visual_t ggi_visual; +}; + +/* + * GGIMesa context. + * + * GGIMesa context expands the Mesa's context (it doesn't actualy derive + * from it, but this ability isn't needed, and it is best if GL context + * creation is left up to Mesa). It also contains a reference to the GGI + * visual it is attached to, which is very useful for all Mesa callbacks. + */ +struct ggi_mesa_context +{ + GLcontext *gl_ctx; + ggi_visual_t ggi_visual; + + ggi_pixel color; /* Current color or index*/ + ggi_pixel clearcolor; + + void *priv; +}; + +#define SHIFT (GGI_COLOR_PRECISION - 8) + +#endif + diff --git a/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h new file mode 100644 index 000000000..faafc779e --- /dev/null +++ b/nx-X11/extras/Mesa_6.4.2/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h @@ -0,0 +1,44 @@ +#ifndef _GGI_MESA_INT_H +#define _GGI_MESA_INT_H + +#include <ggi/internal/internal.h> +#include "ggimesa.h" + + +extern ggi_extid _ggiMesaID; + +ggifunc_setmode GGIMesa_setmode; +ggifunc_getapi GGIMesa_getapi; + +typedef struct ggi_mesa_ext +{ + /* + * How mesa extends this visual; i.e., size of the depth buffer etc. + * + * By default (upon attaching) this structure is initialized to what + * libggi is guaranteed to handle without any help: single buffered + * visual without any ancilary buffers. + */ + struct ggi_mesa_visual mesa_visual; + + /* + * Mesa framebuffer is a collection of all ancilary buffers required. + * + * This structure contains the ancilary buffers provided in in + * software. On each mode change it is loaded with the list of + * required buffers and the target is expected to clear the ones + * it can provide in hw. The remaining ones are then provided in sw. + * + */ + GLframebuffer mesa_buffer; + + void (*update_state)(ggi_mesa_context_t ctx); + int (*setup_driver)(ggi_mesa_context_t ctx); + + void *private; +} ggi_mesa_ext_t; + +#define LIBGGI_MESAEXT(vis) ((ggi_mesa_ext_t *)LIBGGI_EXT(vis,_ggiMesaID)) +#define GGIMESA_PRIV(vis) ((LIBGGI_MESAEXT(vis)->priv)) + +#endif /* _GGI_MISC_INT_H */ |