From 95dcb43951b5d3c99514d1f2a50ea797217d328d Mon Sep 17 00:00:00 2001 From: Jon Taylor Date: Sat, 21 Aug 1999 05:57:17 +0000 Subject: *** empty log message *** --- src/mesa/drivers/ggi/default/genkgi.conf.in | 4 + src/mesa/drivers/ggi/default/genkgi.h | 43 +++ src/mesa/drivers/ggi/default/genkgi_mode.c | 61 ++++ src/mesa/drivers/ggi/default/genkgi_visual.c | 184 ++++++++++++ src/mesa/drivers/ggi/default/linear.c | 333 ++++++++++++++++++++++ src/mesa/drivers/ggi/default/linear_15.c | 35 +++ src/mesa/drivers/ggi/default/linear_16.c | 35 +++ src/mesa/drivers/ggi/default/linear_24.c | 35 +++ src/mesa/drivers/ggi/default/linear_32.c | 35 +++ src/mesa/drivers/ggi/default/linear_8.c | 35 +++ src/mesa/drivers/ggi/default/stubs.c | 409 +++++++++++++++++++++++++++ 11 files changed, 1209 insertions(+) create mode 100644 src/mesa/drivers/ggi/default/genkgi.conf.in create mode 100644 src/mesa/drivers/ggi/default/genkgi.h create mode 100644 src/mesa/drivers/ggi/default/genkgi_mode.c create mode 100644 src/mesa/drivers/ggi/default/genkgi_visual.c create mode 100644 src/mesa/drivers/ggi/default/linear.c create mode 100644 src/mesa/drivers/ggi/default/linear_15.c create mode 100644 src/mesa/drivers/ggi/default/linear_16.c create mode 100644 src/mesa/drivers/ggi/default/linear_24.c create mode 100644 src/mesa/drivers/ggi/default/linear_32.c create mode 100644 src/mesa/drivers/ggi/default/linear_8.c create mode 100644 src/mesa/drivers/ggi/default/stubs.c (limited to 'src/mesa/drivers/ggi/default') diff --git a/src/mesa/drivers/ggi/default/genkgi.conf.in b/src/mesa/drivers/ggi/default/genkgi.conf.in new file mode 100644 index 00000000000..8b3a25431b6 --- /dev/null +++ b/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-savage4-mesa kgi/savage4.so diff --git a/src/mesa/drivers/ggi/default/genkgi.h b/src/mesa/drivers/ggi/default/genkgi.h new file mode 100644 index 00000000000..135c9aeec3d --- /dev/null +++ b/src/mesa/drivers/ggi/default/genkgi.h @@ -0,0 +1,43 @@ +/* $Id: genkgi.h,v 1.1 1999/08/21 05:59:29 jtaylor Exp $ +****************************************************************************** + + GGIMesa - KGIcon specific overrides for fbcon-mesa + API header + + Copyright (C) 1999 Creative Labs + + 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 +#include + +//ggifunc_setmode GGIMesa_genkgi_setmode; +ggifunc_getapi GGIMesa_genkgi_getapi; + +typedef struct genkgi_hook_mesa +{ + char accel[100]; + int have_accel; + void *accelpriv; +} genkgi_hook_mesa; + +#define GENKGI_PRIVATE(vis) ((genkgi_hook_mesa *)FBDEV_PRIV_MESA(vis)->accelpriv) diff --git a/src/mesa/drivers/ggi/default/genkgi_mode.c b/src/mesa/drivers/ggi/default/genkgi_mode.c new file mode 100644 index 00000000000..81cf6c84071 --- /dev/null +++ b/src/mesa/drivers/ggi/default/genkgi_mode.c @@ -0,0 +1,61 @@ +/* $Id: genkgi_mode.c,v 1.1 1999/08/21 05:59:29 jtaylor Exp $ +****************************************************************************** + + display-fbdev-kgicon-generic-mesa + + Copyright (C) 1999 Creative Labs + + 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 +#include +#include +#include +#include +#include +#include + +//#include + +#include +#include +#include "genkgi.h" + +int GGIMesa_genkgi_getapi(ggi_visual *vis, int num, char *apiname, char *arguments) +{ + genkgi_hook_mesa *priv = GENKGI_PRIVATE(vis); + + gl_ggiDEBUG("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; +} diff --git a/src/mesa/drivers/ggi/default/genkgi_visual.c b/src/mesa/drivers/ggi/default/genkgi_visual.c new file mode 100644 index 00000000000..1c90120b3e6 --- /dev/null +++ b/src/mesa/drivers/ggi/default/genkgi_visual.c @@ -0,0 +1,184 @@ +/* $Id: genkgi_visual.c,v 1.1 1999/08/21 05:59:29 jtaylor Exp $ +****************************************************************************** + + display-fbdev-mesa-generic-kgi: visual handling + + Copyright (C) 1998 Andrew Apted [andrew@ggi-project.org] + Copyright (C) 1999 Marcus Sundberg [marcus@ggi-project.org] + Copyright (C) 1999 Creative Labs + + 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 +#include +#include +#include "genkgi.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_SYS_VT_H +#include +#else +#include +#endif +#ifdef HAVE_LINUX_KDEV_T_H +#include +#endif +#include + + +static int refcount = 0; +static int vtnum; +static void *_ggi_fbdev_lock = NULL; +#ifdef FBIOGET_CON2FBMAP +static struct fb_con2fbmap origconmap; +#endif + +#define MAX_DEV_LEN 63 +#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, "savage4" }, /* S3 Savage4 */ +}; + +#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) +{ + gl_ggiDEBUG("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"); + gl_ggiDEBUG("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; +} + +int GGIdlinit(ggi_visual *vis, const char *args, void *argptr) +{ + genkgi_hook_mesa *priv; + char libname[256], libargs[256]; + int id, err; + struct stat junk; + ggifunc_getapi *oldgetapi; + + gl_ggiDEBUG("display-fbdev-kgicon-mesa: GGIdlinit start\n"); + + GENKGI_PRIVATE(vis) = priv = malloc(sizeof(genkgi_hook_mesa)); + if (priv == NULL) + { + fprintf(stderr, "Failed to allocate genkgi_hook!\n"); + return GGI_DL_ERROR; + } + + err = ggLoadConfig(conffile, &_configHandle); + if (err != GGI_OK) + { + gl_ggiPrint("display-fbdev: Couldn't open %s\n", conffile); + return err; + } + + /* Hack city here. We need to probe the KGI driver properly to discover + * the acceleration type. + */ + priv->have_accel = 0; +#if 1 + if (stat("/proc/savage4", &junk) == 0) + { + sprintf(priv->accel, "%s%s", accel_prefix, "savage4"); + priv->have_accel = 1; + gl_ggiDEBUG("display-fbdev-kgicon-mesa: Using accel: \"%s\"\n", priv->accel); + } + +#endif + /* 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; + } + + gl_ggiDEBUG("display-fbdev-kgicon-mesa: GGIdlinit finished\n"); + + return 0; +} + +int GGIdlcleanup(ggi_visual *vis) +{ + return 0; +} + +#include diff --git a/src/mesa/drivers/ggi/default/linear.c b/src/mesa/drivers/ggi/default/linear.c new file mode 100644 index 00000000000..6acdf4d8012 --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear.c @@ -0,0 +1,333 @@ +/* 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 +#include + +#define RMASK ((1<>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B) | + ((rgba[0][BCOMP]>>BS)); + } + fb++; + rgba++; + } + } + else + { + while (n--) { + *fb++= ((rgba[0][RCOMP]>>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B)| + ((rgba[0][BCOMP]>>BS)); + rgba++; + } + } +} + +void GGIwrite_rgb_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte rgba[][3], + const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + if (mask) + { + while (n--) { + if (*mask++) { + *fb= ((rgba[0][RCOMP]>>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B) | + ((rgba[0][BCOMP]>>BS)); + } + fb++; + rgba++; + } + } + else + { + while (n--) { + *fb++= ((rgba[0][RCOMP]>>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B) | + ((rgba[0][BCOMP]>>BS)); + rgba++; + } + } +} + + +void GGIwrite_mono_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte mask[]) +{ + FB_TYPE *fb; + FB_TYPE color; + + if (mask) + { + fb=LFB(FB_TYPE,x,FLIP(y)); + color=(FB_TYPE) GGICTX->color; + + while (n--) + { + if (*mask++) *fb=color; + fb++; + } + } + else + { + ggiDrawHLine(VIS,x,FLIP(y),n); + } +} + + +/**********************************************************************/ +/***** Read spans of pixels *****/ +/**********************************************************************/ + + +void GGIread_ci32_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint ci[]) +{ + FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + while (n--) + *ci++=(GLuint)*fb++; +} + +void GGIread_rgba_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte rgba[][4]) +{ + FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + FB_TYPE color; + + while (n--) + { + color=*fb++; + rgba[0][RCOMP] = (GLubyte) (color>>(G+B))<>B)& ((1<width)=*ci; + ci++; + x++; + y++; + } +} + +void GGIwrite_mono_pixels(const GLcontext *ctx, + GLuint n, + const GLint x[], const GLint y[], + const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,0,0); + FB_TYPE color=(FB_TYPE) GGICTX->color; + + while (n--) { + if (*mask++) *(fb+ *x + FLIP(*y)*GGICTX->width)=color; + x++; + y++; + } +} + +void GGIwrite_rgba_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte rgba[][4], + const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,0,0); + FB_TYPE color; + + while (n--) { + if (*mask++) { + color= ((rgba[0][RCOMP]>>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B) | + ((rgba[0][BCOMP]>>BS)); + *(fb+ *x + FLIP(*y)*GGICTX->width)=color; + } + x++;y++; + rgba++; + } +} + + +/**********************************************************************/ +/***** Read arrays of pixels *****/ +/**********************************************************************/ + +void GGIread_ci32_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint ci[], const GLubyte mask[]) +{ + FB_TYPE *fb=LFB(FB_TYPE,0,0); + + while (n--) { + if (*mask++) + *ci=*(fb+ *x + FLIP(*y)*GGICTX->width); + ci++; + x++; + y++; + } +} + +void GGIread_rgba_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], + const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,0,0); + FB_TYPE color; + + while (n--) + { + if (*mask++) + { + color=*(fb+ *x + FLIP(*y)*GGICTX->width); + rgba[0][RCOMP] =(GLubyte)(color>>(G+B))<>B)& ((1<gl_ctx; + + ctx->Driver.WriteRGBASpan = GGIwrite_rgba_span; + ctx->Driver.WriteRGBSpan = GGIwrite_rgb_span; + ctx->Driver.WriteMonoRGBASpan = GGIwrite_mono_span; + ctx->Driver.WriteRGBAPixels = GGIwrite_rgba_pixels; + ctx->Driver.WriteMonoRGBAPixels = GGIwrite_mono_pixels; + + ctx->Driver.WriteCI32Span = GGIwrite_ci32_span; + ctx->Driver.WriteCI8Span = GGIwrite_ci8_span; + ctx->Driver.WriteMonoCISpan = GGIwrite_mono_span; + ctx->Driver.WriteCI32Pixels = GGIwrite_ci32_pixels; + ctx->Driver.WriteMonoCIPixels = GGIwrite_mono_pixels; + + ctx->Driver.ReadCI32Span = GGIread_ci32_span; + ctx->Driver.ReadRGBASpan = GGIread_rgba_span; + ctx->Driver.ReadCI32Pixels = GGIread_ci32_pixels; + ctx->Driver.ReadRGBAPixels = GGIread_rgba_pixels; + + info->red_bits=R; + info->green_bits=G; + info->blue_bits=B; + + return 0; +} + +int GGIdlinit(ggi_visual_t vis,const char *version,void *argptr) +{ + LIBGGI_MESAEXT(vis)->setup_driver=GGIsetup_driver; + + return 0; +} + +int GGIdlcleanup(ggi_visual_t vis) +{ + return 0; +} diff --git a/src/mesa/drivers/ggi/default/linear_15.c b/src/mesa/drivers/ggi/default/linear_15.c new file mode 100644 index 00000000000..8eb89f97954 --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_15.c @@ -0,0 +1,35 @@ +/* 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 + +#define R 5 +#define G 5 +#define B 5 + +#define FB_TYPE uint16 +#define FB_BITS 15 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/linear_16.c b/src/mesa/drivers/ggi/default/linear_16.c new file mode 100644 index 00000000000..d7eeef1123a --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_16.c @@ -0,0 +1,35 @@ +/* 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 + +#define R 5 +#define G 6 +#define B 5 + +#define FB_TYPE uint16 +#define FB_BITS 16 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/linear_24.c b/src/mesa/drivers/ggi/default/linear_24.c new file mode 100644 index 00000000000..6058a2a168a --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_24.c @@ -0,0 +1,35 @@ +/* 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 + +#define R 8 +#define G 8 +#define B 8 + +#define FB_TYPE uint32 +#define FB_BITS 24 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/linear_32.c b/src/mesa/drivers/ggi/default/linear_32.c new file mode 100644 index 00000000000..13631b4747c --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_32.c @@ -0,0 +1,35 @@ +/* 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 + +#define R 8 +#define G 8 +#define B 8 + +#define FB_TYPE uint32 +#define FB_BITS 32 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/linear_8.c b/src/mesa/drivers/ggi/default/linear_8.c new file mode 100644 index 00000000000..027f21f80d9 --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_8.c @@ -0,0 +1,35 @@ +/* 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 + +#define R 3 +#define G 3 +#define B 2 + +#define FB_TYPE uint8 +#define FB_BITS 8 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/stubs.c b/src/mesa/drivers/ggi/default/stubs.c new file mode 100644 index 00000000000..52f55d409d3 --- /dev/null +++ b/src/mesa/drivers/ggi/default/stubs.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 + +#include +#include + +/**********************************************************************/ +/***** Write spans of pixels *****/ +/**********************************************************************/ + +void GGIwrite_ci32_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLuint ci[], + const GLubyte mask[] ) +{ + y=FLIP(y); + if (mask) + { + while (n--) { + if (*mask++) ggiPutPixel(VIS,x,y,*ci); + x++; + ci++; + } + } + else + { + while (n--) ggiPutPixel(VIS,x++,y,*ci++); + } +} + +void GGIwrite_ci8_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte ci[], + const GLubyte mask[] ) +{ + y=FLIP(y); + if (mask) + { + while (n--) { + if (*mask++) ggiPutPixel(VIS,x,y,*ci); + x++; + ci++; + } + } + else + { + while (n--) ggiPutPixel(VIS,x++,y,*ci++); + } +} + +void GGIwrite_mono_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte mask[] ) +{ + y=FLIP(y); + if (mask) + { + while (n--) { + if (*mask++) ggiDrawPixel(VIS,x,y); + x++; + } + } + else + { + ggiDrawHLine(VIS,x,y,n); + } +} + +void GGIwrite_rgba_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], + const GLubyte mask[]) +{ + 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(VIS,&rgb); + ggiPutPixel(VIS,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(VIS,&rgb); + ggiPutPixel(VIS,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_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(VIS,&rgb); + ggiPutPixel(VIS,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(VIS,&rgb); + ggiPutPixel(VIS,x++,y,col); + rgba++; + } + } +} + + + +/**********************************************************************/ +/***** Read spans of pixels *****/ +/**********************************************************************/ + + +void GGIread_ci32_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint ci[]) +{ + y = FLIP(y); + while (n--) + ggiGetPixel(VIS, x++, y,ci++); +} + +void GGIread_rgba_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte rgba[][4]) +{ + ggi_color rgb; + ggi_pixel col; + + y=FLIP(y); + + while (n--) + { + ggiGetPixel(VIS,x++,y,&col); + ggiUnmapPixel(VIS,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[] ) +{ + while (n--) { + if (*mask++) ggiPutPixel(VIS,*x, FLIP(*y),*ci); + ci++; + x++; + y++; + } +} + +void GGIwrite_mono_pixels( const GLcontext *ctx, + GLuint n, + const GLint x[], const GLint y[], + const GLubyte mask[] ) +{ + while (n--) { + if (*mask++) ggiDrawPixel(VIS,*x,FLIP(*y)); + 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_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(VIS,&rgb); + ggiPutPixel(VIS,*x,FLIP(*y),col); + } + x++;y++; + rgba++; + } +} + + +/**********************************************************************/ +/***** Read arrays of pixels *****/ +/**********************************************************************/ + +void GGIread_ci32_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint ci[], const GLubyte mask[]) +{ + while (n--) { + if (*mask++) + ggiGetPixel(VIS, *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_color rgb; + ggi_pixel col; + + while (n--) + { + if (*mask++) + { + ggiGetPixel(VIS,*x,FLIP(*y),&col); + ggiUnmapPixel(VIS,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++; + } +} + + +triangle_func ggiGetTriangleFunc(GLcontext *ctx); + +int GGIsetup_driver(GGIMesaContext ggictx,struct ggi_mesa_info *info) +{ + GLcontext *ctx=ggictx->gl_ctx; + + ctx->Driver.WriteRGBASpan = GGIwrite_rgba_span; + ctx->Driver.WriteRGBSpan = GGIwrite_rgb_span; + ctx->Driver.WriteMonoRGBASpan = GGIwrite_mono_span; + ctx->Driver.WriteRGBAPixels = GGIwrite_rgba_pixels; + ctx->Driver.WriteMonoRGBAPixels = GGIwrite_mono_pixels; + + ctx->Driver.WriteCI32Span = GGIwrite_ci32_span; + ctx->Driver.WriteCI8Span = GGIwrite_ci8_span; + ctx->Driver.WriteMonoCISpan = GGIwrite_mono_span; + ctx->Driver.WriteCI32Pixels = GGIwrite_ci32_pixels; + ctx->Driver.WriteMonoCIPixels = GGIwrite_mono_pixels; + + ctx->Driver.ReadCI32Span = GGIread_ci32_span; + ctx->Driver.ReadRGBASpan = GGIread_rgba_span; + ctx->Driver.ReadCI32Pixels = GGIread_ci32_pixels; + ctx->Driver.ReadRGBAPixels = GGIread_rgba_pixels; + + return 0; +} + +void GGIupdate_state(GLcontext *ctx) +{ + ctx->Driver.TriangleFunc = ggiGetTriangleFunc(ctx); +} + + +void GGItriangle_flat(GLcontext *ctx,GLuint v0,GLuint v1,GLuint v2,GLuint pv) +{ +#define SETUP_CODE \ + GLubyte r = VB->ColorPtr->data[pv][0]; \ + GLubyte g = VB->ColorPtr->data[pv][1]; \ + GLubyte b = VB->ColorPtr->data[pv][2]; \ + GLubyte a = VB->ColorPtr->data[pv][3]; \ + (*ctx->Driver.Color)(ctx,r,g,b,a); + +#define INNER_LOOP(LEFT,RIGHT,Y) \ + ggiDrawHLine(VIS,LEFT,FLIP(Y),RIGHT-LEFT); + +#include "tritemp.h" +} + + +void GGItriangle_flat_depth(GLcontext *ctx,GLuint v0,GLuint v1, + GLuint v2,GLuint pv) +{ +#define INTERP_Z 1 + +#define SETUP_CODE \ + GLubyte r = VB->ColorPtr->data[pv][0]; \ + GLubyte g = VB->ColorPtr->data[pv][1]; \ + GLubyte b = VB->ColorPtr->data[pv][2]; \ + GLubyte a = VB->ColorPtr->data[pv][3]; \ + (*ctx->Driver.Color)(ctx,r,g,b,a); + +#define INNER_LOOP(LEFT,RIGHT,Y) \ + { \ + GLint i,xx=LEFT,yy=FLIP(Y),n=RIGHT-LEFT,length=0; \ + GLint startx=xx; \ + for (i=0;iStencil.Enabled) return NULL; + if (ctx->Polygon.SmoothFlag) return NULL; + if (ctx->Polygon.StippleFlag) return NULL; + if (ctx->Texture.Enabled) 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; +} + +int GGIdlinit(ggi_visual_t vis, const char *version, void *argptr) +{ + LIBGGI_MESAEXT(vis)->update_state = GGIupdate_state; + LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver; + + return 0; +} + +int GGIdlcleanup(ggi_visual_t vis) +{ + return 0; +} -- cgit v1.2.3