summaryrefslogtreecommitdiff
path: root/xc/extras/Mesa/src/X
diff options
context:
space:
mode:
authordawes <dawes>2002-02-14 01:59:27 +0000
committerdawes <dawes>2002-02-14 01:59:27 +0000
commit316e8f1af01604b1638a7613f2becd051cf3fcb5 (patch)
tree42de1a90195578a20c62fe804d9bc7db2c1613cf /xc/extras/Mesa/src/X
parentd7079b0d92edbc78a16a913bfa9851332bfcc435 (diff)
First pass of mesa-4-0 branch merge into trunk.
Diffstat (limited to 'xc/extras/Mesa/src/X')
-rw-r--r--xc/extras/Mesa/src/X/Makefile.am23
-rw-r--r--xc/extras/Mesa/src/X/fakeglx.c959
-rw-r--r--xc/extras/Mesa/src/X/glxapi.c837
-rw-r--r--xc/extras/Mesa/src/X/glxapi.h119
-rw-r--r--xc/extras/Mesa/src/X/glxheader.h11
-rw-r--r--xc/extras/Mesa/src/X/realglx.c174
-rw-r--r--xc/extras/Mesa/src/X/realglx.h315
-rw-r--r--xc/extras/Mesa/src/X/xfonts.c19
-rw-r--r--xc/extras/Mesa/src/X/xfonts.h6
-rw-r--r--xc/extras/Mesa/src/X/xm_api.c (renamed from xc/extras/Mesa/src/X/xmesa1.c)328
-rw-r--r--xc/extras/Mesa/src/X/xm_dd.c1044
-rw-r--r--xc/extras/Mesa/src/X/xm_line.c (renamed from xc/extras/Mesa/src/X/xmesa3.c)397
-rw-r--r--xc/extras/Mesa/src/X/xm_span.c (renamed from xc/extras/Mesa/src/X/xmesa2.c)1978
-rw-r--r--xc/extras/Mesa/src/X/xm_tri.c1704
-rw-r--r--xc/extras/Mesa/src/X/xmesa4.c1695
-rw-r--r--xc/extras/Mesa/src/X/xmesaP.h91
16 files changed, 5692 insertions, 4008 deletions
diff --git a/xc/extras/Mesa/src/X/Makefile.am b/xc/extras/Mesa/src/X/Makefile.am
deleted file mode 100644
index f0d65fd8f..000000000
--- a/xc/extras/Mesa/src/X/Makefile.am
+++ /dev/null
@@ -1,23 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-#AUTOMAKE_OPTIONS = no-dependencies
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src $(X_CFLAGS) $(FX_CFLAGS)
-
-if HAVE_X11
-# Build a libtool convenience library.
-noinst_LTLIBRARIES = libMesaX11.la
-endif
-
-libMesaX11_la_SOURCES = \
- glxapi.c \
- glxapi.h \
- fakeglx.c \
- xfonts.c \
- xmesa1.c \
- xmesa2.c \
- xmesa3.c \
- xmesa4.c \
- xmesaP.h
-
-libMesaX11_la_LIBADD = $(X_LIBS) $(X_PRE_LIBS) $(X_LIBADD)
diff --git a/xc/extras/Mesa/src/X/fakeglx.c b/xc/extras/Mesa/src/X/fakeglx.c
index c05385239..59f8fdcf6 100644
--- a/xc/extras/Mesa/src/X/fakeglx.c
+++ b/xc/extras/Mesa/src/X/fakeglx.c
@@ -1,20 +1,21 @@
+/* $Id: fakeglx.c,v 1.16 2002/02/14 01:59:35 dawes Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.4.2
- *
+ * Version: 4.0.1
+ *
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
- *
+ *
* 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
@@ -47,24 +48,25 @@
#include "context.h"
#include "config.h"
#include "macros.h"
+#include "mem.h"
#include "mmath.h"
-#include "types.h"
+#include "mtypes.h"
#include "xfonts.h"
#include "xmesaP.h"
/* This indicates the client-side GLX API and GLX encoder version. */
#define CLIENT_MAJOR_VERSION 1
-#define CLIENT_MINOR_VERSION 2
+#define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
/* This indicates the server-side GLX decoder version.
- * GLX 1.3 indicates OpenGL 1.2 support
+ * GLX 1.4 indicates OpenGL 1.3 support
*/
#define SERVER_MAJOR_VERSION 1
-#define SERVER_MINOR_VERSION 3
+#define SERVER_MINOR_VERSION 4
/* This is appended onto the glXGetClient/ServerString version strings. */
-#define MESA_GLX_VERSION "Mesa 3.4.2"
+#define MESA_GLX_VERSION "Mesa 4.0.1"
/* Who implemented this GLX? */
#define VENDOR "Brian Paul"
@@ -82,9 +84,28 @@ void Fake_glXDummyFunc( void )
}
+/*
+ * Our fake GLX context will contain a "real" GLX context and an XMesa context.
+ *
+ * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
+ * and vice versa.
+ *
+ * We really just need this structure in order to make the libGL functions
+ * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
+ * work correctly.
+ */
+struct fake_glx_context {
+ __GLXcontext glxContext; /* this MUST be first! */
+ XMesaContext xmesaContext;
+};
+
+
-#define DONT_CARE -1
+/**********************************************************************/
+/*** GLX Visual Code ***/
+/**********************************************************************/
+#define DONT_CARE -1
#define MAX_VISUALS 100
@@ -92,7 +113,6 @@ static XMesaVisual VisualTable[MAX_VISUALS];
static int NumVisuals = 0;
-
/*
* This struct and some code fragments borrowed
* from Mark Kilgard's GLUT library.
@@ -268,16 +288,16 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
if (v->display == dpy
&& v->level == level
&& v->ximage_flag == ximageFlag
- && v->gl_visual->RGBAflag == rgbFlag
- && v->gl_visual->DBflag == dbFlag
- && v->gl_visual->StereoFlag == stereoFlag
- && (v->gl_visual->AlphaBits > 0) == alphaFlag
- && (v->gl_visual->DepthBits >= depth_size || depth_size == 0)
- && (v->gl_visual->StencilBits >= stencil_size || stencil_size == 0)
- && (v->gl_visual->AccumRedBits >= accumRedSize || accumRedSize == 0)
- && (v->gl_visual->AccumGreenBits >= accumGreenSize || accumGreenSize == 0)
- && (v->gl_visual->AccumBlueBits >= accumBlueSize || accumBlueSize == 0)
- && (v->gl_visual->AccumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
+ && v->mesa_visual.rgbMode == rgbFlag
+ && v->mesa_visual.doubleBufferMode == dbFlag
+ && v->mesa_visual.stereoMode == stereoFlag
+ && (v->mesa_visual.alphaBits > 0) == alphaFlag
+ && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
+ && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
+ && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
+ && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
+ && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
+ && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
/* now either compare XVisualInfo pointers or visual IDs */
if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
|| (comparePointers && v->vishandle == vinfo)) {
@@ -868,6 +888,10 @@ static XVisualInfo *choose_x_overlay_visual( Display *dpy, int scr,
}
+/**********************************************************************/
+/*** Begin Fake GLX API Functions ***/
+/**********************************************************************/
+
static XVisualInfo *
Fake_glXChooseVisual( Display *dpy, int screen, int *list )
@@ -875,7 +899,7 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
int *parselist;
XVisualInfo *vis;
int min_ci = 0;
- int min_red=0, min_green=0, min_blue=0, min_alpha=0;
+ int min_red=0, min_green=0, min_blue=0;
GLboolean rgb_flag = GL_FALSE;
GLboolean alpha_flag = GL_FALSE;
GLboolean double_flag = GL_FALSE;
@@ -939,8 +963,10 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
break;
case GLX_ALPHA_SIZE:
parselist++;
- min_alpha = *parselist++;
- alpha_flag = (min_alpha > 0);
+ {
+ GLint size = *parselist++;
+ alpha_flag = size>0 ? 1 : 0;
+ }
break;
case GLX_DEPTH_SIZE:
parselist++;
@@ -1002,7 +1028,7 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
parselist++;
parselist++;
break;
-
+
/*
* GLX_EXT_visual_info extension
*/
@@ -1019,16 +1045,6 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
}
}
- /* DEBUG
- printf("glXChooseVisual:\n");
- printf(" GLX_RED_SIZE = %d\n", min_red);
- printf(" GLX_GREEN_SIZE = %d\n", min_green);
- printf(" GLX_BLUE_SIZE = %d\n", min_blue);
- printf(" GLX_ALPHA_SIZE = %d\n", min_alpha);
- printf(" GLX_DEPTH_SIZE = %d\n", depth_size);
- printf(" GLX_STENCIL_SIZE = %d\n", stencil_size);
- */
-
/*
* Since we're only simulating the GLX extension this function will never
* find any real GL visuals. Instead, all we can do is try to find an RGB
@@ -1085,33 +1101,17 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
else if (depth_size > 0)
depth_size = DEFAULT_SOFTWARE_DEPTH_BITS; /*16*/
- /* If using Glide, make sure we don't try to setup an impossible
- * visual. This fixes the Q3 bug in which 24-bit Z was being reported.
- */
- {
- const char *fx = getenv("MESA_GLX_FX");
- if (fx && fx[0] != 'd')
- if (depth_size > 16 ||
- stencil_size > 0 ||
- (min_red > 1 && min_red > 5) ||
- (min_green > 1 && min_green > 6) ||
- (min_blue > 1 && min_blue > 5) ||
- alpha_flag)
- return NULL;
- }
-
-
/* we only support one size of stencil and accum buffers. */
if (stencil_size > 0)
stencil_size = STENCIL_BITS;
- if (accumRedSize > 0)
+ if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
+ accumAlphaSize > 0) {
accumRedSize = ACCUM_BITS;
- if (accumGreenSize > 0)
accumGreenSize = ACCUM_BITS;
- if (accumBlueSize > 0)
accumBlueSize = ACCUM_BITS;
- if (accumAlphaSize > 0)
- accumAlphaSize = ACCUM_BITS;
+ accumAlphaSize = alpha_flag ? ACCUM_BITS : 0;
+ }
+
if (!save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
stereo_flag, depth_size, stencil_size,
accumRedSize, accumGreenSize,
@@ -1131,7 +1131,11 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
GLXContext share_list, Bool direct )
{
XMesaVisual glxvis;
- XMesaContext xmctx;
+ struct fake_glx_context *glxCtx;
+ struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
+ glxCtx = CALLOC_STRUCT(fake_glx_context);
+ if (!glxCtx)
+ return 0;
/* deallocate unused windows/buffers */
XMesaGarbageCollect();
@@ -1142,33 +1146,47 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
glxvis = create_glx_visual( dpy, visinfo );
if (!glxvis) {
/* unusable visual */
+ FREE(glxCtx);
return NULL;
}
}
- xmctx = XMesaCreateContext( glxvis, (XMesaContext) share_list );
- if (xmctx) {
- /* set the direct/indirect flag */
- xmctx->direct = direct;
+ glxCtx->xmesaContext = XMesaCreateContext(glxvis,
+ shareCtx ? shareCtx->xmesaContext : NULL);
+ if (!glxCtx->xmesaContext) {
+ FREE(glxCtx);
+ return NULL;
}
- return (GLXContext) xmctx;
+
+ glxCtx->xmesaContext->direct = GL_FALSE;
+ glxCtx->glxContext.isDirect = GL_FALSE;
+ glxCtx->glxContext.currentDpy = dpy;
+ glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
+
+ assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
+
+ return (GLXContext) glxCtx;
}
+/* XXX these may have to be removed due to thread-safety issues. */
static GLXContext MakeCurrent_PrevContext = 0;
static GLXDrawable MakeCurrent_PrevDrawable = 0;
static GLXDrawable MakeCurrent_PrevReadable = 0;
static XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
static XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
+
/* GLX 1.3 and later */
static Bool
Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
GLXDrawable read, GLXContext ctx )
{
+ struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
+
if (ctx && draw && read) {
XMesaBuffer drawBuffer, readBuffer;
- XMesaContext xmctx = (XMesaContext) ctx;
+ XMesaContext xmctx = glxCtx->xmesaContext;
/* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
if (ctx == MakeCurrent_PrevContext
@@ -1180,7 +1198,7 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
}
if (!drawBuffer) {
/* drawable must be a new window! */
- drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, (XMesaContext) ctx );
+ drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx);
if (!drawBuffer) {
/* Out of memory, or context/drawable depth mismatch */
return False;
@@ -1197,7 +1215,8 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
}
if (!readBuffer) {
/* drawable must be a new window! */
- readBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, read, (XMesaContext) ctx );
+ readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual,
+ read, xmctx);
if (!readBuffer) {
/* Out of memory, or context/drawable depth mismatch */
return False;
@@ -1211,7 +1230,19 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
MakeCurrent_PrevReadBuffer = readBuffer;
/* Now make current! */
- return (Bool) XMesaMakeCurrent2((XMesaContext) ctx, drawBuffer, readBuffer);
+ if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
+ ((__GLXcontext *) ctx)->currentDpy = dpy;
+ ((__GLXcontext *) ctx)->currentDrawable = draw;
+ ((__GLXcontext *) ctx)->currentReadable = read;
+#ifdef GLX_BUILT_IN_XMESA
+ printf("Set fake context ctx %p\n", ctx);
+ __glXSetCurrentContext(ctx);
+#endif
+ return True;
+ }
+ else {
+ return False;
+ }
}
else if (!ctx && !draw && !read) {
/* release current context w/out assigning new one. */
@@ -1221,6 +1252,9 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
MakeCurrent_PrevReadable = 0;
MakeCurrent_PrevDrawBuffer = 0;
MakeCurrent_PrevReadBuffer = 0;
+#ifdef GLX_BUILT_IN_XMESA
+ /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
+#endif
return True;
}
else {
@@ -1264,7 +1298,8 @@ Fake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
}
-#ifdef GLX_MESA_pixmap_colormap
+/*** GLX_MESA_pixmap_colormap ***/
+
static GLXPixmap
Fake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
Pixmap pixmap, Colormap cmap )
@@ -1287,7 +1322,6 @@ Fake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
}
return b->frontbuffer;
}
-#endif
static void
@@ -1311,7 +1345,7 @@ Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
XMesaContext xm_src = (XMesaContext) src;
XMesaContext xm_dst = (XMesaContext) dst;
(void) dpy;
- gl_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask );
+ _mesa_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask );
}
@@ -1338,13 +1372,14 @@ void _kw_ungrab_all( Display *dpy )
static void
Fake_glXDestroyContext( Display *dpy, GLXContext ctx )
{
+ struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
(void) dpy;
MakeCurrent_PrevContext = 0;
MakeCurrent_PrevDrawable = 0;
MakeCurrent_PrevReadable = 0;
MakeCurrent_PrevDrawBuffer = 0;
MakeCurrent_PrevReadBuffer = 0;
- XMesaDestroyContext( (XMesaContext) ctx );
+ XMesaDestroyContext( glxCtx->xmesaContext );
XMesaGarbageCollect();
}
@@ -1353,8 +1388,9 @@ Fake_glXDestroyContext( Display *dpy, GLXContext ctx )
static Bool
Fake_glXIsDirect( Display *dpy, GLXContext ctx )
{
+ struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
(void) dpy;
- return ((XMesaContext) ctx)->direct;
+ return glxCtx->xmesaContext->direct;
}
@@ -1374,7 +1410,8 @@ Fake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
-#ifdef GLX_MESA_copy_sub_buffer
+/*** GLX_MESA_copy_sub_buffer ***/
+
static void
Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
int x, int y, int width, int height )
@@ -1387,7 +1424,6 @@ Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
fprintf(stderr, "Mesa Warning: glXCopySubBufferMESA: invalid drawable\n");
}
}
-#endif
@@ -1441,7 +1477,7 @@ Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
*value = glxvis->level;
return 0;
case GLX_RGBA:
- if (glxvis->gl_visual->RGBAflag) {
+ if (glxvis->mesa_visual.rgbMode) {
*value = True;
}
else {
@@ -1449,43 +1485,43 @@ Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
}
return 0;
case GLX_DOUBLEBUFFER:
- *value = (int) glxvis->gl_visual->DBflag;
+ *value = (int) glxvis->mesa_visual.doubleBufferMode;
return 0;
case GLX_STEREO:
- *value = (int) glxvis->gl_visual->StereoFlag;
+ *value = (int) glxvis->mesa_visual.stereoMode;
return 0;
case GLX_AUX_BUFFERS:
*value = (int) False;
return 0;
case GLX_RED_SIZE:
- *value = glxvis->gl_visual->RedBits;
+ *value = glxvis->mesa_visual.redBits;
return 0;
case GLX_GREEN_SIZE:
- *value = glxvis->gl_visual->GreenBits;
+ *value = glxvis->mesa_visual.greenBits;
return 0;
case GLX_BLUE_SIZE:
- *value = glxvis->gl_visual->BlueBits;
+ *value = glxvis->mesa_visual.blueBits;
return 0;
case GLX_ALPHA_SIZE:
- *value = glxvis->gl_visual->AlphaBits;
+ *value = glxvis->mesa_visual.alphaBits;
return 0;
case GLX_DEPTH_SIZE:
- *value = glxvis->gl_visual->DepthBits;
+ *value = glxvis->mesa_visual.depthBits;
return 0;
case GLX_STENCIL_SIZE:
- *value = glxvis->gl_visual->StencilBits;
+ *value = glxvis->mesa_visual.stencilBits;
return 0;
case GLX_ACCUM_RED_SIZE:
- *value = glxvis->gl_visual->AccumRedBits;
+ *value = glxvis->mesa_visual.accumRedBits;
return 0;
case GLX_ACCUM_GREEN_SIZE:
- *value = glxvis->gl_visual->AccumGreenBits;
+ *value = glxvis->mesa_visual.accumGreenBits;
return 0;
case GLX_ACCUM_BLUE_SIZE:
- *value = glxvis->gl_visual->AccumBlueBits;
+ *value = glxvis->mesa_visual.accumBlueBits;
return 0;
case GLX_ACCUM_ALPHA_SIZE:
- *value = glxvis->gl_visual->AccumAlphaBits;
+ *value = glxvis->mesa_visual.accumAlphaBits;
return 0;
/*
@@ -1508,7 +1544,7 @@ Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
}
else if (glxvis->level>0) {
/* overlay */
- if (glxvis->gl_visual->RGBAflag) {
+ if (glxvis->mesa_visual.rgbMode) {
*value = GLX_TRANSPARENT_RGB_EXT;
}
else {
@@ -1660,6 +1696,15 @@ Fake_glXGetClientString( Display *dpy, int name )
* GLX 1.3 and later
*/
+/* XXX Move this when done.
+ * Create an XMesaBuffer as a Pbuffer.
+ * New in Mesa 4.0 but untested.
+ */
+extern XMesaBuffer XMesaCreatePBuffer( XMesaVisual v, XMesaColormap cmap,
+ unsigned int width, unsigned int height );
+
+
+
static GLXFBConfig *
Fake_glXChooseFBConfig( Display *dpy, int screen,
const int *attribList, int *nitems )
@@ -1676,11 +1721,154 @@ static int
Fake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
int attribute, int *value )
{
+ XMesaVisual v = NULL; /* XXX Fix this */
(void) dpy;
(void) config;
(void) attribute;
(void) value;
- return 0;
+
+ if (!dpy || !config || !value)
+ return -1;
+
+ switch (attribute) {
+ case GLX_FBCONFIG_ID:
+ case GLX_BUFFER_SIZE:
+ if (v->mesa_visual.rgbMode)
+ *value = v->mesa_visual.redBits + v->mesa_visual.greenBits +
+ v->mesa_visual.blueBits + v->mesa_visual.alphaBits;
+ else
+ *value = v->mesa_visual.indexBits;
+ break;
+ case GLX_LEVEL:
+ *value = v->level;
+ break;
+ case GLX_DOUBLEBUFFER:
+ *value = v->mesa_visual.doubleBufferMode;
+ break;
+ case GLX_STEREO:
+ *value = v->mesa_visual.stereoMode;
+ break;
+ case GLX_AUX_BUFFERS:
+ *value = v->mesa_visual.numAuxBuffers;
+ break;
+ case GLX_RED_SIZE:
+ *value = v->mesa_visual.redBits;
+ break;
+ case GLX_GREEN_SIZE:
+ *value = v->mesa_visual.greenBits;
+ break;
+ case GLX_BLUE_SIZE:
+ *value = v->mesa_visual.blueBits;
+ break;
+ case GLX_ALPHA_SIZE:
+ *value = v->mesa_visual.alphaBits;
+ break;
+ case GLX_DEPTH_SIZE:
+ *value = v->mesa_visual.depthBits;
+ break;
+ case GLX_STENCIL_SIZE:
+ *value = v->mesa_visual.stencilBits;
+ break;
+ case GLX_ACCUM_RED_SIZE:
+ *value = v->mesa_visual.accumRedBits;
+ break;
+ case GLX_ACCUM_GREEN_SIZE:
+ *value = v->mesa_visual.accumGreenBits;
+ break;
+ case GLX_ACCUM_BLUE_SIZE:
+ *value = v->mesa_visual.accumBlueBits;
+ break;
+ case GLX_ACCUM_ALPHA_SIZE:
+ *value = v->mesa_visual.accumAlphaBits;
+ break;
+ case GLX_RENDER_TYPE:
+ *value = 0; /* XXX ??? */
+ break;
+ case GLX_DRAWABLE_TYPE:
+ *value = GLX_PBUFFER_BIT; /* XXX fix? */
+ break;
+ case GLX_X_RENDERABLE:
+ *value = False; /* XXX ??? */
+ break;
+ case GLX_X_VISUAL_TYPE:
+ switch (v->vishandle->class) {
+ case GrayScale:
+ *value = GLX_GRAY_SCALE;
+ break;
+ case StaticGray:
+ *value = GLX_STATIC_GRAY;
+ break;
+ case StaticColor:
+ *value = GLX_STATIC_COLOR;
+ break;
+ case PseudoColor:
+ *value = GLX_PSEUDO_COLOR;
+ break;
+ case TrueColor:
+ *value = GLX_TRUE_COLOR;
+ break;
+ case DirectColor:
+ *value = GLX_DIRECT_COLOR;
+ break;
+ default:
+ *value = 0;
+ }
+ break;
+ case GLX_CONFIG_CAVEAT:
+ *value = 0; /* XXX ??? */
+ break;
+ case GLX_TRANSPARENT_TYPE:
+ if (v->level == 0) {
+ /* normal planes */
+ *value = GLX_NONE_EXT;
+ }
+ else if (v->level > 0) {
+ /* overlay */
+ if (v->mesa_visual.rgbMode) {
+ *value = GLX_TRANSPARENT_RGB_EXT;
+ }
+ else {
+ *value = GLX_TRANSPARENT_INDEX_EXT;
+ }
+ }
+ else if (v->level < 0) {
+ /* underlay */
+ *value = GLX_NONE_EXT;
+ }
+ break;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ *value = transparent_pixel( v );
+ break;
+ case GLX_TRANSPARENT_RED_VALUE:
+ *value = 0; /* not implemented */
+ break;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ *value = 0; /* not implemented */
+ break;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ *value = 0; /* not implemented */
+ break;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ *value = 0; /* not implemented */
+ break;
+ case GLX_MAX_PBUFFER_WIDTH:
+ *value = DisplayWidth(dpy, v->vishandle->screen);
+ break;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ *value = DisplayHeight(dpy, v->vishandle->screen);
+ break;
+ case GLX_MAX_PBUFFER_PIXELS:
+ *value = DisplayWidth(dpy, v->vishandle->screen) *
+ DisplayHeight(dpy, v->vishandle->screen);
+ break;
+ case GLX_VISUAL_ID:
+ *value = v->vishandle->visualid;
+ break;
+ default:
+ return GLX_BAD_ATTRIBUTE;
+ }
+
+ return Success;
}
@@ -1697,9 +1885,13 @@ Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
static XVisualInfo *
Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
{
- (void) dpy;
- (void) config;
- return 0;
+ if (dpy && config) {
+ XMesaVisual v = (XMesaVisual) config;
+ return v->vishandle;
+ }
+ else {
+ return NULL;
+ }
}
@@ -1710,38 +1902,66 @@ Fake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
(void) dpy;
(void) config;
(void) win;
- (void) attribList;
- return 0;
+ (void) attribList; /* Ignored in GLX 1.3 */
+
+ return win; /* A hack for now */
}
static void
Fake_glXDestroyWindow( Display *dpy, GLXWindow window )
{
- (void) dpy;
- (void) window;
- return;
+ XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
+ if (b)
+ XMesaDestroyBuffer(b);
+ /* don't destroy X window */
}
+/* XXX untested */
static GLXPixmap
Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
const int *attribList )
{
+ XMesaVisual v = (XMesaVisual) config;
+ XVisualInfo *visinfo;
+ XMesaBuffer b;
+
(void) dpy;
(void) config;
(void) pixmap;
- (void) attribList;
- return 0;
+ (void) attribList; /* Ignored in GLX 1.3 */
+
+ if (!dpy || !config || !pixmap)
+ return 0;
+
+ visinfo = v->vishandle;
+
+ v = find_glx_visual( dpy, visinfo );
+ if (!v) {
+ v = create_glx_visual( dpy, visinfo );
+ if (!v) {
+ /* unusable visual */
+ return 0;
+ }
+ }
+
+ b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
+ if (!b) {
+ return 0;
+ }
+
+ return pixmap;
}
static void
Fake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
{
- (void) dpy;
- (void) pixmap;
- return;
+ XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
+ if (b)
+ XMesaDestroyBuffer(b);
+ /* don't destroy X pixmap */
}
@@ -1749,9 +1969,36 @@ static GLXPbuffer
Fake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
const int *attribList )
{
+ const int *attrib;
+ int width = 0, height = 0;
+ GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
+
(void) dpy;
(void) config;
- (void) attribList;
+
+ for (attrib = attribList; attrib; attrib++) {
+ switch (*attrib) {
+ case GLX_PBUFFER_WIDTH:
+ width = *(++attrib);
+ break;
+ case GLX_PBUFFER_HEIGHT:
+ height = *(++attrib);
+ break;
+ case GLX_PRESERVED_CONTENTS:
+ preserveContents = GL_TRUE; /* ignored */
+ break;
+ case GLX_LARGEST_PBUFFER:
+ useLargest = GL_TRUE; /* ignored */
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ if (width == 0 || height == 0)
+ return 0;
+
+
return 0;
}
@@ -1770,8 +2017,18 @@ Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
{
(void) dpy;
(void) draw;
- (void) attribute;
- (void) value;
+
+ switch (attribute) {
+ case GLX_WIDTH:
+ case GLX_HEIGHT:
+ case GLX_PRESERVED_CONTENTS:
+ case GLX_LARGEST_PBUFFER:
+ case GLX_FBCONFIG_ID:
+ *value = 0;
+ return;
+ default:
+ return; /* GLX_BAD_ATTRIBUTE? */
+ }
}
@@ -1779,12 +2036,13 @@ static GLXContext
Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
int renderType, GLXContext shareList, Bool direct )
{
- (void) dpy;
- (void) config;
- (void) renderType;
- (void) shareList;
- (void) direct;
- return 0;
+ XMesaVisual v = (XMesaVisual) config;
+
+ if (!dpy || !config ||
+ (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
+ return 0;
+
+ return Fake_glXCreateContext(dpy, v->vishandle, shareList, direct);
}
@@ -1793,9 +2051,16 @@ Fake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
{
(void) dpy;
(void) ctx;
- (void) attribute;
- (void) value;
- return 0;
+
+ switch (attribute) {
+ case GLX_FBCONFIG_ID:
+ case GLX_RENDER_TYPE:
+ case GLX_SCREEN:
+ *value = 0;
+ return Success;
+ default:
+ return GLX_BAD_ATTRIBUTE;
+ }
}
@@ -1819,57 +2084,393 @@ Fake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
-#ifdef GLX_MESA_release_buffers
-/*
- * Release the depth, stencil, accum buffers attached to a GLXDrawable
- * (a window or pixmap) prior to destroying the GLXDrawable.
- */
+/*** GLX_SGI_swap_control ***/
+
+static int
+Fake_glXSwapIntervalSGI(int interval)
+{
+ (void) interval;
+ return 0;
+}
+
+
+
+/*** GLX_SGI_video_sync ***/
+
+static int
+Fake_glXGetVideoSyncSGI(unsigned int *count)
+{
+ (void) count;
+ return 0;
+}
+
+static int
+Fake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+{
+ (void) divisor;
+ (void) remainder;
+ (void) count;
+ return 0;
+}
+
+
+
+/*** GLX_SGI_make_current_read ***/
+
static Bool
-Fake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
+Fake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
{
- XMesaBuffer b = XMesaFindBuffer(dpy, d);
- if (b) {
- XMesaDestroyBuffer(b);
- return True;
- }
+ (void) dpy;
+ (void) draw;
+ (void) read;
+ (void) ctx;
return False;
}
-#endif
+
+/* not used
+static GLXDrawable
+Fake_glXGetCurrentReadDrawableSGI(void)
+{
+ return 0;
+}
+*/
+/*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
-#ifdef GLX_MESA_set_3dfx_mode
-static GLboolean
-Fake_glXSet3DfxModeMESA( GLint mode )
+static GLXVideoSourceSGIX
+Fake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
{
- return XMesaSetFXmode( mode );
+ (void) dpy;
+ (void) screen;
+ (void) server;
+ (void) path;
+ (void) nodeClass;
+ (void) drainNode;
+ return 0;
}
+
+static void
+Fake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
+{
+ (void) dpy;
+ (void) src;
+}
+
#endif
+/*** GLX_EXT_import_context ***/
-/*
- * GLX_SGI_video_sync
- */
+static void
+Fake_glXFreeContextEXT(Display *dpy, GLXContext context)
+{
+ (void) dpy;
+ (void) context;
+}
-#ifdef GLX_SGI_video_sync
+static GLXContextID
+Fake_glXGetContextIDEXT(const GLXContext context)
+{
+ (void) context;
+ return 0;
+}
+
+static GLXContext
+Fake_glXImportContextEXT(Display *dpy, GLXContextID contextID)
+{
+ (void) dpy;
+ (void) contextID;
+ return 0;
+}
static int
-Fake_glXGetVideoSyncSGI(unsigned int *count)
+Fake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
{
+ (void) dpy;
+ (void) context;
+ (void) attribute;
+ (void) value;
return 0;
}
+
+/*** GLX_SGIX_fbconfig ***/
+
static int
-Fake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+Fake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
+{
+ (void) dpy;
+ (void) config;
+ (void) attribute;
+ (void) value;
+ return 0;
+}
+
+static GLXFBConfigSGIX *
+Fake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
+{
+ (void) dpy;
+ (void) screen;
+ (void) attrib_list;
+ (void) nelements;
+ return 0;
+}
+
+static GLXPixmap
+Fake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
+{
+ (void) dpy;
+ (void) config;
+ (void) pixmap;
+ return 0;
+}
+
+static GLXContext
+Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
+{
+ (void) dpy;
+ (void) config;
+ (void) render_type;
+ (void) share_list;
+ (void) direct;
+ return 0;
+}
+
+static XVisualInfo *
+Fake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
+{
+ (void) dpy;
+ (void) config;
+ return NULL;
+}
+
+static GLXFBConfigSGIX
+Fake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
+{
+ (void) dpy;
+ (void) vis;
+ return 0;
+}
+
+
+
+/*** GLX_SGIX_pbuffer ***/
+
+static GLXPbufferSGIX
+Fake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
+{
+ (void) dpy;
+ (void) config;
+ (void) width;
+ (void) height;
+ (void) attrib_list;
+ return 0;
+}
+
+static void
+Fake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
+{
+ (void) dpy;
+ (void) pbuf;
+}
+
+static int
+Fake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
+{
+ (void) dpy;
+ (void) pbuf;
+ (void) attribute;
+ (void) value;
+ return 0;
+}
+
+static void
+Fake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) mask;
+}
+
+static void
+Fake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) mask;
+}
+
+
+
+/*** GLX_SGI_cushion ***/
+
+static void
+Fake_glXCushionSGI(Display *dpy, Window win, float cushion)
+{
+ (void) dpy;
+ (void) win;
+ (void) cushion;
+}
+
+
+
+/*** GLX_SGIX_video_resize ***/
+
+static int
+Fake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) window;
+ return 0;
+}
+
+static int
+Fake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) x;
+ (void) y;
+ (void) w;
+ (void) h;
+ return 0;
+}
+
+static int
+Fake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) x;
+ (void) y;
+ (void) w;
+ (void) h;
return 0;
}
+static int
+Fake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) dx;
+ (void) dy;
+ (void) dw;
+ (void) dh;
+ return 0;
+}
+
+static int
+Fake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) synctype;
+ return 0;
+}
+
+
+
+/*** GLX_SGIX_dmbuffer **/
+
+#if defined(_DM_BUFFER_H_)
+static Bool
+Fake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
+{
+ (void) dpy;
+ (void) pbuffer;
+ (void) params;
+ (void) dmbuffer;
+ return False;
+}
#endif
+/*** GLX_SGIX_swap_group ***/
+
+static void
+Fake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) member;
+}
+
+
+
+/*** GLX_SGIX_swap_barrier ***/
+
+static void
+Fake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) barrier;
+}
+
+static Bool
+Fake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
+{
+ (void) dpy;
+ (void) screen;
+ (void) max;
+ return False;
+}
+
+
+
+/*** GLX_SUN_get_transparent_index ***/
+
+static Status
+Fake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
+{
+ (void) dpy;
+ (void) overlay;
+ (void) underlay;
+ (void) pTransparent;
+ return 0;
+}
+
+
+
+/*** GLX_MESA_release_buffers ***/
+
+/*
+ * Release the depth, stencil, accum buffers attached to a GLXDrawable
+ * (a window or pixmap) prior to destroying the GLXDrawable.
+ */
+static Bool
+Fake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
+{
+ XMesaBuffer b = XMesaFindBuffer(dpy, d);
+ if (b) {
+ XMesaDestroyBuffer(b);
+ return True;
+ }
+ return False;
+}
+
+
+
+/*** GLX_MESA_set_3dfx_mode ***/
+
+static Bool
+Fake_glXSet3DfxModeMESA( int mode )
+{
+ return XMesaSetFXmode( mode );
+}
+
+
+
extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
struct _glxapi_table *_mesa_GetGLXDispatchTable(void)
@@ -1878,9 +2479,9 @@ struct _glxapi_table *_mesa_GetGLXDispatchTable(void)
/* be sure our dispatch table size <= libGL's table */
{
- int size = sizeof(struct _glxapi_table) / sizeof(void *);
+ GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
(void) size;
- assert((GLint) _glxapi_get_dispatch_table_size() >= size);
+ assert(_glxapi_get_dispatch_table_size() >= size);
}
/* initialize the whole table to no-ops */
@@ -1905,17 +2506,15 @@ struct _glxapi_table *_mesa_GetGLXDispatchTable(void)
glx.WaitGL = Fake_glXWaitGL;
glx.WaitX = Fake_glXWaitX;
-#ifdef GLX_VERSION_1_1
+ /*** GLX_VERSION_1_1 ***/
glx.GetClientString = Fake_glXGetClientString;
glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
glx.QueryServerString = Fake_glXQueryServerString;
-#endif
-#ifdef GLX_VERSION_1_2
+ /*** GLX_VERSION_1_2 ***/
/*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
-#endif
-#ifdef GLX_VERSION_1_3
+ /*** GLX_VERSION_1_3 ***/
glx.ChooseFBConfig = Fake_glXChooseFBConfig;
glx.CreateNewContext = Fake_glXCreateNewContext;
glx.CreatePbuffer = Fake_glXCreatePbuffer;
@@ -1933,28 +2532,82 @@ struct _glxapi_table *_mesa_GetGLXDispatchTable(void)
glx.QueryContext = Fake_glXQueryContext;
glx.QueryDrawable = Fake_glXQueryDrawable;
glx.SelectEvent = Fake_glXSelectEvent;
-#endif
-#ifdef GLX_SGI_video_sync
+ /*** GLX_SGI_swap_control ***/
+ glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI;
+
+ /*** GLX_SGI_video_sync ***/
glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
+
+ /*** GLX_SGI_make_current_read ***/
+ glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI;
+ /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
+
+/*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
+ glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX;
+ glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX;
#endif
-#ifdef GLX_MESA_copy_sub_buffer
- glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
+ /*** GLX_EXT_import_context ***/
+ glx.FreeContextEXT = Fake_glXFreeContextEXT;
+ glx.GetContextIDEXT = Fake_glXGetContextIDEXT;
+ /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
+ glx.ImportContextEXT = Fake_glXImportContextEXT;
+ glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT;
+
+ /*** GLX_SGIX_fbconfig ***/
+ glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX;
+ glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX;
+ glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX;
+ glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX;
+ glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX;
+ glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX;
+
+ /*** GLX_SGIX_pbuffer ***/
+ glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX;
+ glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX;
+ glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX;
+ glx.SelectEventSGIX = Fake_glXSelectEventSGIX;
+ glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX;
+
+ /*** GLX_SGI_cushion ***/
+ glx.CushionSGI = Fake_glXCushionSGI;
+
+ /*** GLX_SGIX_video_resize ***/
+ glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX;
+ glx.ChannelRectSGIX = Fake_glXChannelRectSGIX;
+ glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX;
+ glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX;
+ glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX;
+
+ /*** GLX_SGIX_dmbuffer **/
+#if defined(_DM_BUFFER_H_)
+ glx.AssociateDMPbufferSGIX = NULL;
#endif
-#ifdef GLX_MESA_release_buffers
+ /*** GLX_SGIX_swap_group ***/
+ glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX;
+
+ /*** GLX_SGIX_swap_barrier ***/
+ glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX;
+ glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX;
+
+ /*** GLX_SUN_get_transparent_index ***/
+ glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN;
+
+ /*** GLX_MESA_copy_sub_buffer ***/
+ glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
+
+ /*** GLX_MESA_release_buffers ***/
glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
-#endif
-#ifdef GLX_MESA_pixmap_colormap
+ /*** GLX_MESA_pixmap_colormap ***/
glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
-#endif
-#ifdef GLX_MESA_set_3dfx_mode
+ /*** GLX_MESA_set_3dfx_mode ***/
glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
-#endif
return &glx;
}
diff --git a/xc/extras/Mesa/src/X/glxapi.c b/xc/extras/Mesa/src/X/glxapi.c
index cd71f2c98..2a9e26861 100644
--- a/xc/extras/Mesa/src/X/glxapi.c
+++ b/xc/extras/Mesa/src/X/glxapi.c
@@ -1,9 +1,10 @@
+/* $Id: glxapi.c,v 1.8 2002/02/14 01:59:35 dawes Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.5
*
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -26,35 +27,21 @@
/*
* This is the GLX API dispatcher. Calls to the glX* functions are
- * either routed to real (SGI / Utah) GLX encoders or to Mesa's
- * pseudo-GLX module.
+ * either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
*/
#include <assert.h>
#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+/*#include <dlfcn.h>*/ /* XXX not portable? */
#include "glapi.h"
#include "glxapi.h"
-/*
- * XXX - this really shouldn't be here.
- * Instead, add -DUSE_MESA_GLX to the compiler flags when needed.
- */
-#define USE_MESA_GLX 1
-
-
-/* Rather than include possibly non-existant headers... */
-#ifdef USE_SGI_GLX
-extern struct _glxapi_table *_sgi_GetGLXDispatchtable(void);
-#endif
-#ifdef USE_UTAH_GLX
-extern struct _glxapi_table *_utah_GetGLXDispatchTable(void);
-#endif
-#ifdef USE_MESA_GLX
+extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
-#endif
-
struct display_dispatch {
@@ -66,20 +53,17 @@ struct display_dispatch {
static struct display_dispatch *DispatchList = NULL;
+/* Display -> Dispatch caching */
+static Display *prevDisplay = NULL;
+static struct _glxapi_table *prevTable = NULL;
+
+
static struct _glxapi_table *
get_dispatch(Display *dpy)
{
- static Display *prevDisplay = NULL;
- static struct _glxapi_table *prevTable = NULL;
-
if (!dpy)
return NULL;
- /* try cached display */
- if (dpy == prevDisplay) {
- return prevTable;
- }
-
/* search list of display/dispatch pairs for this display */
{
const struct display_dispatch *d = DispatchList;
@@ -93,32 +77,35 @@ get_dispatch(Display *dpy)
}
}
- /* A new display, determine if we should use real GLX (SGI / Utah)
+ /* A new display, determine if we should use real GLX
* or Mesa's pseudo-GLX.
*/
{
struct _glxapi_table *t = NULL;
-#if defined(USE_SGI_GLX) || defined(USE_UTAH_GLX)
- if (!getenv("MESA_FORCE_SOFTX")) {
+#ifdef GLX_BUILT_IN_XMESA
+ if (!getenv("LIBGL_FORCE_XMESA")) {
int ignore;
if (XQueryExtension( dpy, "GLX", &ignore, &ignore, &ignore )) {
/* the X server has the GLX extension */
-#if defined(USE_SGI_GLX)
- t = _sgi_GetGLXDispatchtable();
-#elif defined(USE_UTAH_GLX)
- t = _utah_GetGLXDispatchTable();
-#endif
+ t = _real_GetGLXDispatchTable();
}
}
#endif
-#if defined(USE_MESA_GLX)
if (!t) {
+ /* Fallback to Mesa with Xlib driver */
+#ifdef GLX_BUILT_IN_XMESA
+ if (getenv("LIBGL_DEBUG")) {
+ fprintf(stderr,
+ "libGL: server %s lacks the GLX extension.",
+ dpy->display_name);
+ fprintf(stderr, " Using Mesa Xlib renderer.\n");
+ }
+#endif
t = _mesa_GetGLXDispatchTable();
assert(t); /* this has to work */
}
-#endif
if (t) {
struct display_dispatch *d;
@@ -145,23 +132,37 @@ get_dispatch(Display *dpy)
}
+#define GET_DISPATCH(DPY, TABLE) \
+ if (DPY == prevDisplay) { \
+ TABLE = prevTable; \
+ } \
+ else if (!DPY) { \
+ TABLE = NULL; \
+ } \
+ else { \
+ TABLE = get_dispatch(DPY); \
+ }
+
+
+
/* Set by glXMakeCurrent() and glXMakeContextCurrent() only */
-static Display *CurrentDisplay = NULL;
+#ifndef GLX_BUILT_IN_XMESA
static GLXContext CurrentContext = 0;
-static GLXDrawable CurrentDrawable = 0;
-static GLXDrawable CurrentReadDrawable = 0;
-
+#define __glXGetCurrentContext() CurrentContext;
+#endif
/*
* GLX API entrypoints
*/
+/*** GLX_VERSION_1_0 ***/
XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *list)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return NULL;
return (t->ChooseVisual)(dpy, screen, list);
@@ -170,7 +171,8 @@ XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *list)
void glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->CopyContext)(dpy, src, dst, mask);
@@ -179,7 +181,8 @@ void glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long
GLXContext glXCreateContext(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->CreateContext)(dpy, visinfo, shareList, direct);
@@ -188,7 +191,8 @@ GLXContext glXCreateContext(Display *dpy, XVisualInfo *visinfo, GLXContext share
GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->CreateGLXPixmap)(dpy, visinfo, pixmap);
@@ -197,7 +201,8 @@ GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap)
void glXDestroyContext(Display *dpy, GLXContext ctx)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->DestroyContext)(dpy, ctx);
@@ -206,7 +211,8 @@ void glXDestroyContext(Display *dpy, GLXContext ctx)
void glXDestroyGLXPixmap(Display *dpy, GLXPixmap pixmap)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->DestroyGLXPixmap)(dpy, pixmap);
@@ -215,28 +221,41 @@ void glXDestroyGLXPixmap(Display *dpy, GLXPixmap pixmap)
int glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return GLX_NO_EXTENSION;
return (t->GetConfig)(dpy, visinfo, attrib, value);
}
+#ifdef GLX_BUILT_IN_XMESA
+/* Use real libGL's glXGetCurrentContext() function */
+#else
+/* stand-alone Mesa */
GLXContext glXGetCurrentContext(void)
{
return CurrentContext;
}
+#endif
+#ifdef GLX_BUILT_IN_XMESA
+/* Use real libGL's glXGetCurrentContext() function */
+#else
+/* stand-alone Mesa */
GLXDrawable glXGetCurrentDrawable(void)
{
- return CurrentDrawable;
+ __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+ return gc ? gc->currentDrawable : 0;
}
+#endif
Bool glXIsDirect(Display *dpy, GLXContext ctx)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return False;
return (t->IsDirect)(dpy, ctx);
@@ -246,23 +265,25 @@ Bool glXIsDirect(Display *dpy, GLXContext ctx)
Bool glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx)
{
Bool b;
- struct _glxapi_table *t = get_dispatch(dpy);
- if (!t)
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t) {
return False;
+ }
b = (*t->MakeCurrent)(dpy, drawable, ctx);
+#ifndef GLX_BUILT_IN_XMESA
if (b) {
- CurrentDisplay = dpy;
CurrentContext = ctx;
- CurrentDrawable = drawable;
- CurrentReadDrawable = drawable;
}
+#endif
return b;
}
Bool glXQueryExtension(Display *dpy, int *errorb, int *event)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return False;
return (t->QueryExtension)(dpy, errorb, event);
@@ -271,7 +292,8 @@ Bool glXQueryExtension(Display *dpy, int *errorb, int *event)
Bool glXQueryVersion(Display *dpy, int *maj, int *min)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return False;
return (t->QueryVersion)(dpy, maj, min);
@@ -280,7 +302,8 @@ Bool glXQueryVersion(Display *dpy, int *maj, int *min)
void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->SwapBuffers)(dpy, drawable);
@@ -289,7 +312,9 @@ void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
void glXUseXFont(Font font, int first, int count, int listBase)
{
- struct _glxapi_table *t = get_dispatch(CurrentDisplay);
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->UseXFont)(font, first, count, listBase);
@@ -298,7 +323,9 @@ void glXUseXFont(Font font, int first, int count, int listBase)
void glXWaitGL(void)
{
- struct _glxapi_table *t = get_dispatch(CurrentDisplay);
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->WaitGL)();
@@ -307,7 +334,9 @@ void glXWaitGL(void)
void glXWaitX(void)
{
- struct _glxapi_table *t = get_dispatch(CurrentDisplay);
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->WaitX)();
@@ -315,11 +344,12 @@ void glXWaitX(void)
-#ifdef GLX_VERSION_1_1
+/*** GLX_VERSION_1_1 ***/
const char *glXGetClientString(Display *dpy, int name)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return NULL;
return (t->GetClientString)(dpy, name);
@@ -328,7 +358,8 @@ const char *glXGetClientString(Display *dpy, int name)
const char *glXQueryExtensionsString(Display *dpy, int screen)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return NULL;
return (t->QueryExtensionsString)(dpy, screen);
@@ -337,30 +368,34 @@ const char *glXQueryExtensionsString(Display *dpy, int screen)
const char *glXQueryServerString(Display *dpy, int screen, int name)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return NULL;
return (t->QueryServerString)(dpy, screen, name);
}
-#endif
-
+/*** GLX_VERSION_1_2 ***/
-#ifdef GLX_VERSION_1_2
+#if !defined(GLX_BUILT_IN_XMESA)
Display *glXGetCurrentDisplay(void)
{
- return CurrentDisplay;
+ /* Same code as in libGL's glxext.c */
+ __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+ if (NULL == gc) return NULL;
+ return gc->currentDpy;
}
#endif
-#ifdef GLX_VERSION_1_3
+/*** GLX_VERSION_1_3 ***/
GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->ChooseFBConfig)(dpy, screen, attribList, nitems);
@@ -369,7 +404,8 @@ GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attribList,
GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->CreateNewContext)(dpy, config, renderType, shareList, direct);
@@ -378,7 +414,8 @@ GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType,
GLXPbuffer glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribList)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->CreatePbuffer)(dpy, config, attribList);
@@ -387,7 +424,8 @@ GLXPbuffer glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribL
GLXPixmap glXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->CreatePixmap)(dpy, config, pixmap, attribList);
@@ -396,7 +434,8 @@ GLXPixmap glXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap, const
GLXWindow glXCreateWindow(Display *dpy, GLXFBConfig config, Window win, const int *attribList)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->CreateWindow)(dpy, config, win, attribList);
@@ -405,7 +444,8 @@ GLXWindow glXCreateWindow(Display *dpy, GLXFBConfig config, Window win, const in
void glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->DestroyPbuffer)(dpy, pbuf);
@@ -414,7 +454,8 @@ void glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
void glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->DestroyPixmap)(dpy, pixmap);
@@ -423,22 +464,29 @@ void glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
void glXDestroyWindow(Display *dpy, GLXWindow window)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->DestroyWindow)(dpy, window);
}
+#ifdef GLX_BUILT_IN_XMESA
+/* Use the glXGetCurrentReadDrawable() function from libGL */
+#else
GLXDrawable glXGetCurrentReadDrawable(void)
{
- return CurrentReadDrawable;
+ __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+ return gc ? gc->currentReadable : 0;
}
+#endif
int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return GLX_NO_EXTENSION;
return (t->GetFBConfigAttrib)(dpy, config, attribute, value);
@@ -447,7 +495,8 @@ int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *v
GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->GetFBConfigs)(dpy, screen, nelements);
@@ -455,7 +504,8 @@ GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
void glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->GetSelectedEvent)(dpy, drawable, mask);
@@ -464,7 +514,8 @@ void glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask
XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return NULL;
return (t->GetVisualFromFBConfig)(dpy, config);
@@ -473,24 +524,25 @@ XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
Bool glXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
{
- struct _glxapi_table *t = get_dispatch(dpy);
Bool b;
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return False;
b = (t->MakeContextCurrent)(dpy, draw, read, ctx);
+#ifndef GLX_BUILT_IN_XMESA
if (b) {
- CurrentDisplay = dpy;
CurrentContext = ctx;
- CurrentDrawable = draw;
- CurrentReadDrawable = read;
}
+#endif
return b;
}
int glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
assert(t);
if (!t)
return 0; /* XXX correct? */
@@ -500,7 +552,8 @@ int glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
void glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->QueryDrawable)(dpy, draw, attribute, value);
@@ -509,45 +562,133 @@ void glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned in
void glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->SelectEvent)(dpy, drawable, mask);
}
-#endif /* GLX_VERSION_1_3 */
-#ifdef GLX_EXT_import_context
+/*** GLX_SGI_swap_control ***/
-void glXFreeContextEXT(Display *dpy, GLXContext context)
+int glXSwapIntervalSGI(int interval)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
if (!t)
- return;
- (t->FreeContextEXT)(dpy, context);
+ return 0;
+ return (t->SwapIntervalSGI)(interval);
}
-GLXContextID glXGetContextIDEXT(const GLXContext context)
+
+/*** GLX_SGI_video_sync ***/
+
+int glXGetVideoSyncSGI(unsigned int *count)
{
- /* XXX is this function right? */
- struct _glxapi_table *t = get_dispatch(CurrentDisplay);
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
- return (t->GetContextIDEXT)(context);
+ return (t->GetVideoSyncSGI)(count);
}
+int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->WaitVideoSyncSGI)(divisor, remainder, count);
+}
-Display *glXGetCurrentDisplayEXT(void)
+
+
+/*** GLX_SGI_make_current_read ***/
+
+Bool glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
{
- return CurrentDisplay;
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->MakeCurrentReadSGI)(dpy, draw, read, ctx);
+}
+
+#ifdef GLX_BUILT_IN_XMESA
+/* Use glXGetCurrentReadDrawableSGI() from libGL */
+#else
+/* stand-alone Mesa */
+GLXDrawable glXGetCurrentReadDrawableSGI(void)
+{
+ return glXGetCurrentReadDrawable();
}
+#endif
+
+
+#if defined(_VL_H)
+GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateGLXVideoSourceSGIX)(dpy, screen, server, path, nodeClass, drainNode);
+}
+
+void glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->DestroyGLXVideoSourceSGIX)(dpy, src);
+}
+
+#endif
+
+
+/*** GLX_EXT_import_context ***/
+
+void glXFreeContextEXT(Display *dpy, GLXContext context)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->FreeContextEXT)(dpy, context);
+}
+
+#ifdef GLX_BUILT_IN_XMESA
+/* Use real libGL's glXGetContextIDEXT() function */
+#else
+/* stand-alone Mesa */
+GLXContextID glXGetContextIDEXT(const GLXContext context)
+{
+ return ((__GLXcontext *) context)->xid;
+}
+#endif
+
+#ifdef GLX_BUILT_IN_XMESA
+/* Use real libGL's glXGetCurrentDisplayEXT() function */
+#else
+/* stand-alone Mesa */
+Display *glXGetCurrentDisplayEXT(void)
+{
+ return glXGetCurrentDisplay();
+}
+#endif
GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->ImportContextEXT)(dpy, contextID);
@@ -555,87 +696,296 @@ GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID)
int glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute,int *value)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0; /* XXX ok? */
return (t->QueryContextInfoEXT)(dpy, context, attribute, value);
}
-#endif
-#ifdef GLX_SGI_video_sync
+/*** GLX_SGIX_fbconfig ***/
-int glXGetVideoSyncSGI(unsigned int *count)
+int glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
{
- struct _glxapi_table *t = get_dispatch(CurrentDisplay);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
- return (t->GetVideoSyncSGI)(count);
+ return (t->GetFBConfigAttribSGIX)(dpy, config, attribute, value);
}
+GLXFBConfigSGIX *glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->ChooseFBConfigSGIX)(dpy, screen, attrib_list, nelements);
+}
-int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
{
- struct _glxapi_table *t = get_dispatch(CurrentDisplay);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
- return (t->WaitVideoSyncSGI)(divisor, remainder, count);
+ return (t->CreateGLXPixmapWithConfigSGIX)(dpy, config, pixmap);
+}
+
+GLXContext glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateContextWithConfigSGIX)(dpy, config, render_type, share_list, direct);
+}
+
+XVisualInfo * glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->GetVisualFromFBConfigSGIX)(dpy, config);
+}
+
+GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->GetFBConfigFromVisualSGIX)(dpy, vis);
+}
+
+
+
+/*** GLX_SGIX_pbuffer ***/
+
+GLXPbufferSGIX glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateGLXPbufferSGIX)(dpy, config, width, height, attrib_list);
+}
+
+void glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->DestroyGLXPbufferSGIX)(dpy, pbuf);
+}
+
+int glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->QueryGLXPbufferSGIX)(dpy, pbuf, attribute, value);
+}
+
+void glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->SelectEventSGIX)(dpy, drawable, mask);
+}
+
+void glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->GetSelectedEventSGIX)(dpy, drawable, mask);
+}
+
+
+
+/*** GLX_SGI_cushion ***/
+
+void glXCushionSGI(Display *dpy, Window win, float cushion)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->CushionSGI)(dpy, win, cushion);
+}
+
+
+
+/*** GLX_SGIX_video_resize ***/
+
+int glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->BindChannelToWindowSGIX)(dpy, screen, channel, window);
+}
+
+int glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->ChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
+}
+
+int glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->QueryChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
+}
+
+int glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->QueryChannelDeltasSGIX)(dpy, screen, channel, dx, dy, dw, dh);
+}
+
+int glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->ChannelRectSyncSGIX)(dpy, screen, channel, synctype);
+}
+
+
+
+#if defined(_DM_BUFFER_H_)
+
+Bool glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (t->AssociateDMPbufferSGIX)(dpy, pbuffer, params, dmbuffer);
}
#endif
-#ifdef GLX_MESA_copy_sub_buffer
+/*** GLX_SGIX_swap_group ***/
+
+void glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (*t->JoinSwapGroupSGIX)(dpy, drawable, member);
+}
+
+
+/*** GLX_SGIX_swap_barrier ***/
+
+void glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (*t->BindSwapBarrierSGIX)(dpy, drawable, barrier);
+}
+
+Bool glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (*t->QueryMaxSwapBarriersSGIX)(dpy, screen, max);
+}
+
+
+
+/*** GLX_SUN_get_transparent_index ***/
+
+Status glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (*t->GetTransparentIndexSUN)(dpy, overlay, underlay, pTransparent);
+}
+
+
+
+/*** GLX_MESA_copy_sub_buffer ***/
void glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return;
(t->CopySubBufferMESA)(dpy, drawable, x, y, width, height);
}
-#endif
-#ifdef GLX_MESA_release_buffers
+/*** GLX_MESA_release_buffers ***/
Bool glXReleaseBuffersMESA(Display *dpy, Window w)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return False;
return (t->ReleaseBuffersMESA)(dpy, w);
}
-#endif
-#ifdef GLX_MESA_pixmap_colormap
+/*** GLX_MESA_pixmap_colormap ***/
GLXPixmap glXCreateGLXPixmapMESA(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap)
{
- struct _glxapi_table *t = get_dispatch(dpy);
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
if (!t)
return 0;
return (t->CreateGLXPixmapMESA)(dpy, visinfo, pixmap, cmap);
}
-#endif
-#ifdef GLX_MESA_set_3dfx_mode
+/*** GLX_MESA_set_3dfx_mode ***/
-GLboolean glXSet3DfxModeMESA(GLint mode)
+Bool glXSet3DfxModeMESA(int mode)
{
- struct _glxapi_table *t = get_dispatch(CurrentDisplay);
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
if (!t)
return False;
return (t->Set3DfxModeMESA)(mode);
}
-#endif
@@ -714,6 +1064,142 @@ _glxapi_set_no_op_table(struct _glxapi_table *t)
}
+#if 00
+/*
+ * Open the named library and use dlsym() to populate the given dispatch
+ * table with GLX function pointers.
+ * Return: true = all OK
+ * false = can't open libName or can't get required GLX function
+ */
+GLboolean
+_glxapi_load_library_table(const char *libName, struct _glxapi_table *t)
+{
+ void *libHandle;
+ void **entry; /* used to avoid a lot of cast/type warnings */
+
+ libHandle = dlopen(libName, 0);
+ if (!libHandle) {
+ return GL_FALSE;
+ }
+
+#define GET_REQ_FUNCTION(ENTRY, NAME) \
+ entry = (void **) &(t->ENTRY); \
+ *entry = dlsym(libHandle, NAME); \
+ if (!*entry) { \
+ fprintf(stderr, "libGL Error: couldn't load %s from %s\n", \
+ NAME, libName); \
+ dlclose(libHandle); \
+ return GL_FALSE; \
+ }
+
+ /* 1.0 and 1.1 functions */
+ GET_REQ_FUNCTION(ChooseVisual, "glXChooseVisual");
+ GET_REQ_FUNCTION(CopyContext, "glXCopyContext");
+ GET_REQ_FUNCTION(CreateContext, "glXCreateContext");
+ GET_REQ_FUNCTION(CreateGLXPixmap, "glXCreateGLXPixmap");
+ GET_REQ_FUNCTION(DestroyContext, "glXDestroyContext");
+ GET_REQ_FUNCTION(GetConfig, "glXGetConfig");
+ GET_REQ_FUNCTION(IsDirect, "glXIsDirect");
+ GET_REQ_FUNCTION(MakeCurrent, "glXMakeCurrent");
+ GET_REQ_FUNCTION(QueryExtension, "glXQueryExtension");
+ GET_REQ_FUNCTION(QueryVersion, "glXQueryVersion");
+ GET_REQ_FUNCTION(SwapBuffers, "glXSwapBuffers");
+ GET_REQ_FUNCTION(UseXFont, "glXUseXFont");
+ GET_REQ_FUNCTION(WaitGL, "glXWaitGL");
+ GET_REQ_FUNCTION(WaitX, "glXWaitX");
+ GET_REQ_FUNCTION(GetClientString, "glXGetClientString");
+ GET_REQ_FUNCTION(QueryExtensionsString, "glXQueryExtensionsString");
+ GET_REQ_FUNCTION(QueryServerString, "glXQueryServerString");
+
+#define GET_OPT_FUNCTION(ENTRY, NAME) \
+ entry = (void **) &(t->ENTRY); \
+ *entry = dlsym(libHandle, NAME); \
+ if (!*entry) { \
+ *entry = (void *) generic_no_op_func; \
+ }
+
+ /* 1.2, 1.3 and extensions */
+ GET_OPT_FUNCTION(ChooseFBConfig, "glXChooseFBConfig");
+ GET_OPT_FUNCTION(CreateNewContext, "glXCreateNewContext");
+ GET_OPT_FUNCTION(CreatePbuffer, "glXCreatePbuffer");
+ GET_OPT_FUNCTION(CreatePixmap, "glXCreatePixmap");
+ GET_OPT_FUNCTION(CreateWindow, "glXCreateWindow");
+ GET_OPT_FUNCTION(DestroyPbuffer, "glXDestroyPbuffer");
+ GET_OPT_FUNCTION(DestroyPixmap, "glXDestroyPixmap");
+ GET_OPT_FUNCTION(DestroyWindow, "glXDestroyWindow");
+ GET_OPT_FUNCTION(GetFBConfigAttrib, "glXGetFBConfigAttrib");
+ GET_OPT_FUNCTION(GetFBConfigs, "glXGetFBConfigs");
+ GET_OPT_FUNCTION(GetSelectedEvent, "glXGetSelectedEvent");
+ GET_OPT_FUNCTION(GetVisualFromFBConfig, "glXGetVisualFromFBConfig");
+ GET_OPT_FUNCTION(MakeContextCurrent, "glXMakeContextCurrent");
+ GET_OPT_FUNCTION(QueryContext, "glXQueryContext");
+ GET_OPT_FUNCTION(QueryDrawable, "glXQueryDrawable");
+ GET_OPT_FUNCTION(SelectEvent, "glXSelectEvent");
+ /*** GLX_SGI_swap_control ***/
+ GET_OPT_FUNCTION(SwapIntervalSGI, "glXSwapIntervalSGI");
+ /*** GLX_SGI_video_sync ***/
+ GET_OPT_FUNCTION(GetVideoSyncSGI, "glXGetVideoSyncSGI");
+ GET_OPT_FUNCTION(WaitVideoSyncSGI, "glXWaitVideoSyncSGI");
+ /*** GLX_SGI_make_current_read ***/
+ GET_OPT_FUNCTION(MakeCurrentReadSGI, "glXMakeCurrentReadSGI");
+ GET_OPT_FUNCTION(GetCurrentReadDrawableSGI, "glXGetCurrentReadDrawableSGI");
+ /*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
+ GET_OPT_FUNCTION(CreateGLXVideoSourceSGIX, "glXCreateGLXVideoSourceSGIX");
+ GET_OPT_FUNCTION(DestroyGLXVideoSourceSGIX, "glXDestroyGLXVideoSourceSGIX");
+#endif
+ /*** GLX_EXT_import_context ***/
+ GET_OPT_FUNCTION(FreeContextEXT, "glXFreeContextEXT");
+ GET_OPT_FUNCTION(GetContextIDEXT, "glXGetContextIDEXT");
+ GET_OPT_FUNCTION(GetCurrentDisplayEXT, "glXGetCurrentDisplayEXT");
+ GET_OPT_FUNCTION(ImportContextEXT, "glXImportContextEXT");
+ GET_OPT_FUNCTION(QueryContextInfoEXT, "glXQueryContextInfoEXT");
+ /*** GLX_SGIX_fbconfig ***/
+ GET_OPT_FUNCTION(GetFBConfigAttribSGIX, "glXGetFBConfigAttribSGIX");
+ GET_OPT_FUNCTION(ChooseFBConfigSGIX, "glXChooseFBConfigSGIX");
+ GET_OPT_FUNCTION(CreateGLXPixmapWithConfigSGIX, "glXCreateGLXPixmapWithConfigSGIX");
+ GET_OPT_FUNCTION(CreateContextWithConfigSGIX, "glXCreateContextWithConfigSGIX");
+ GET_OPT_FUNCTION(GetVisualFromFBConfigSGIX, "glXGetVisualFromFBConfigSGIX");
+ GET_OPT_FUNCTION(GetFBConfigFromVisualSGIX, "glXGetFBConfigFromVisualSGIX");
+ /*** GLX_SGIX_pbuffer ***/
+ GET_OPT_FUNCTION(CreateGLXPbufferSGIX, "glXCreateGLXPbufferSGIX");
+ GET_OPT_FUNCTION(DestroyGLXPbufferSGIX, "glXDestroyGLXPbufferSGIX");
+ GET_OPT_FUNCTION(QueryGLXPbufferSGIX, "glXQueryGLXPbufferSGIX");
+ GET_OPT_FUNCTION(SelectEventSGIX, "glXSelectEventSGIX");
+ GET_OPT_FUNCTION(GetSelectedEventSGIX, "glXGetSelectedEventSGIX");
+ /*** GLX_SGI_cushion ***/
+ GET_OPT_FUNCTION(CushionSGI, "glXCushionSGI");
+ /*** GLX_SGIX_video_resize ***/
+ GET_OPT_FUNCTION(BindChannelToWindowSGIX, "glXBindChannelToWindowSGIX");
+ GET_OPT_FUNCTION(ChannelRectSGIX, "glXChannelRectSGIX");
+ GET_OPT_FUNCTION(QueryChannelRectSGIX, "glXQueryChannelRectSGIX");
+ GET_OPT_FUNCTION(QueryChannelDeltasSGIX, "glXQueryChannelDeltasSGIX");
+ GET_OPT_FUNCTION(ChannelRectSyncSGIX, "glXChannelRectSyncSGIX");
+ /*** GLX_SGIX_dmbuffer ***/
+#if defined (_DM_BUFFER_H_)
+ GET_OPT_FUNCTION(AssociateDMPbufferSGIX, "glXAssociateDMPbufferSGIX");
+#endif
+ /*** GLX_SGIX_swap_group ***/
+ GET_OPT_FUNCTION(JoinSwapGroupSGIX, "glXJoinSwapGroupSGIX");
+ /*** GLX_SGIX_swap_barrier ***/
+ GET_OPT_FUNCTION(BindSwapBarrierSGIX, "glXBindSwapBarrierSGIX");
+ GET_OPT_FUNCTION(QueryMaxSwapBarriersSGIX, "glXQueryMaxSwapBarriersSGIX");
+ /*** GLX_SUN_get_transparent_index ***/
+ GET_OPT_FUNCTION(GetTransparentIndexSUN, "glXGetTransparentIndexSUN");
+ /*** GLX_MESA_copy_sub_buffer ***/
+ GET_OPT_FUNCTION(CopySubBufferMESA, "glXCopySubBufferMESA");
+ /*** GLX_MESA_release_buffers ***/
+ GET_OPT_FUNCTION(ReleaseBuffersMESA, "glXReleaseBuffersMESA");
+ /*** GLX_MESA_pixmap_colormap ***/
+ GET_OPT_FUNCTION(CreateGLXPixmapMESA, "glXCreateGLXPixmapMESA");
+ /*** GLX_MESA_set_3dfx_mode ***/
+ GET_OPT_FUNCTION(Set3DfxModeMESA, "glXSet3DfxModeMESA");
+
+ return GL_TRUE;
+}
+#endif
+
+
struct name_address_pair {
const char *Name;
@@ -721,6 +1207,7 @@ struct name_address_pair {
};
static struct name_address_pair GLX_functions[] = {
+ /*** GLX_VERSION_1_0 ***/
{ "glXChooseVisual", (GLvoid *) glXChooseVisual },
{ "glXCopyContext", (GLvoid *) glXCopyContext },
{ "glXCreateContext", (GLvoid *) glXCreateContext },
@@ -739,17 +1226,15 @@ static struct name_address_pair GLX_functions[] = {
{ "glXWaitGL", (GLvoid *) glXWaitGL },
{ "glXWaitX", (GLvoid *) glXWaitX },
-#ifdef GLX_VERSION_1_1
+ /*** GLX_VERSION_1_1 ***/
{ "glXGetClientString", (GLvoid *) glXGetClientString },
{ "glXQueryExtensionsString", (GLvoid *) glXQueryExtensionsString },
{ "glXQueryServerString", (GLvoid *) glXQueryServerString },
-#endif
-#ifdef GLX_VERSION_1_2
+ /*** GLX_VERSION_1_2 ***/
{ "glXGetCurrentDisplay", (GLvoid *) glXGetCurrentDisplay },
-#endif
-#ifdef GLX_VERSION_1_3
+ /*** GLX_VERSION_1_3 ***/
{ "glXChooseFBConfig", (GLvoid *) glXChooseFBConfig },
{ "glXCreateNewContext", (GLvoid *) glXCreateNewContext },
{ "glXCreatePbuffer", (GLvoid *) glXCreatePbuffer },
@@ -760,35 +1245,94 @@ static struct name_address_pair GLX_functions[] = {
{ "glXDestroyWindow", (GLvoid *) glXDestroyWindow },
{ "glXGetCurrentReadDrawable", (GLvoid *) glXGetCurrentReadDrawable },
{ "glXGetFBConfigAttrib", (GLvoid *) glXGetFBConfigAttrib },
+ { "glXGetFBConfigs", (GLvoid *) glXGetFBConfigs },
{ "glXGetSelectedEvent", (GLvoid *) glXGetSelectedEvent },
{ "glXGetVisualFromFBConfig", (GLvoid *) glXGetVisualFromFBConfig },
{ "glXMakeContextCurrent", (GLvoid *) glXMakeContextCurrent },
{ "glXQueryContext", (GLvoid *) glXQueryContext },
{ "glXQueryDrawable", (GLvoid *) glXQueryDrawable },
{ "glXSelectEvent", (GLvoid *) glXSelectEvent },
-#endif
-#ifdef GLX_SGI_video_sync
+ /*** GLX_VERSION_1_4 ***/
+ { "glXGetProcAddress", (GLvoid *) glXGetProcAddress },
+
+ /*** GLX_SGI_swap_control ***/
+ { "glXSwapIntervalSGI", (GLvoid *) glXSwapIntervalSGI },
+
+ /*** GLX_SGI_video_sync ***/
{ "glXGetVideoSyncSGI", (GLvoid *) glXGetVideoSyncSGI },
{ "glXWaitVideoSyncSGI", (GLvoid *) glXWaitVideoSyncSGI },
-#endif
-#ifdef GLX_MESA_copy_sub_buffer
- { "glXCopySubBufferMESA", (GLvoid *) glXCopySubBufferMESA },
+ /*** GLX_SGI_make_current_read ***/
+ { "glXMakeCurrentReadSGI", (GLvoid *) glXMakeCurrentReadSGI },
+ { "glXGetCurrentReadDrawableSGI", (GLvoid *) glXGetCurrentReadDrawableSGI },
+
+ /*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
+ { "glXCreateGLXVideoSourceSGIX", (GLvoid *) glXCreateGLXVideoSourceSGIX },
+ { "glXDestroyGLXVideoSourceSGIX", (GLvoid *) glXDestroyGLXVideoSourceSGIX },
#endif
-#ifdef GLX_MESA_release_buffers
- { "glXReleaseBuffersMESA", (GLvoid *) glXReleaseBuffersMESA },
+ /*** GLX_EXT_import_context ***/
+ { "glXFreeContextEXT", (GLvoid *) glXFreeContextEXT },
+ { "glXGetContextIDEXT", (GLvoid *) glXGetContextIDEXT },
+ { "glXGetCurrentDisplayEXT", (GLvoid *) glXGetCurrentDisplayEXT },
+ { "glXImportContextEXT", (GLvoid *) glXImportContextEXT },
+ { "glXQueryContextInfoEXT", (GLvoid *) glXQueryContextInfoEXT },
+
+ /*** GLX_SGIX_fbconfig ***/
+ { "glXGetFBConfigAttribSGIX", (GLvoid *) glXGetFBConfigAttribSGIX },
+ { "glXChooseFBConfigSGIX", (GLvoid *) glXChooseFBConfigSGIX },
+ { "glXCreateGLXPixmapWithConfigSGIX", (GLvoid *) glXCreateGLXPixmapWithConfigSGIX },
+ { "glXCreateContextWithConfigSGIX", (GLvoid *) glXCreateContextWithConfigSGIX },
+ { "glXGetVisualFromFBConfigSGIX", (GLvoid *) glXGetVisualFromFBConfigSGIX },
+ { "glXGetFBConfigFromVisualSGIX", (GLvoid *) glXGetFBConfigFromVisualSGIX },
+
+ /*** GLX_SGIX_pbuffer ***/
+ { "glXCreateGLXPbufferSGIX", (GLvoid *) glXCreateGLXPbufferSGIX },
+ { "glXDestroyGLXPbufferSGIX", (GLvoid *) glXDestroyGLXPbufferSGIX },
+ { "glXQueryGLXPbufferSGIX", (GLvoid *) glXQueryGLXPbufferSGIX },
+ { "glXSelectEventSGIX", (GLvoid *) glXSelectEventSGIX },
+ { "glXGetSelectedEventSGIX", (GLvoid *) glXGetSelectedEventSGIX },
+
+ /*** GLX_SGI_cushion ***/
+ { "glXCushionSGI", (GLvoid *) glXCushionSGI },
+
+ /*** GLX_SGIX_video_resize ***/
+ { "glXBindChannelToWindowSGIX", (GLvoid *) glXBindChannelToWindowSGIX },
+ { "glXChannelRectSGIX", (GLvoid *) glXChannelRectSGIX },
+ { "glXQueryChannelRectSGIX", (GLvoid *) glXQueryChannelRectSGIX },
+ { "glXQueryChannelDeltasSGIX", (GLvoid *) glXQueryChannelDeltasSGIX },
+ { "glXChannelRectSyncSGIX", (GLvoid *) glXChannelRectSyncSGIX },
+
+ /*** GLX_SGIX_dmbuffer **/
+#if defined(_DM_BUFFER_H_)
+ { "glXAssociateDMPbufferSGIX", (GLvoid *) glXAssociateDMPbufferSGIX },
#endif
-#ifdef GLX_MESA_pixmap_colormap
+ /*** GLX_SGIX_swap_group ***/
+ { "glXJoinSwapGroupSGIX", (GLvoid *) glXJoinSwapGroupSGIX },
+
+ /*** GLX_SGIX_swap_barrier ***/
+ { "glXBindSwapBarrierSGIX", (GLvoid *) glXBindSwapBarrierSGIX },
+ { "glXQueryMaxSwapBarriersSGIX", (GLvoid *) glXQueryMaxSwapBarriersSGIX },
+
+ /*** GLX_SUN_get_transparent_index ***/
+ { "glXGetTransparentIndexSUN", (GLvoid *) glXGetTransparentIndexSUN },
+
+ /*** GLX_MESA_copy_sub_buffer ***/
+ { "glXCopySubBufferMESA", (GLvoid *) glXCopySubBufferMESA },
+
+ /*** GLX_MESA_pixmap_colormap ***/
{ "glXCreateGLXPixmapMESA", (GLvoid *) glXCreateGLXPixmapMESA },
-#endif
-#ifdef GLX_MESA_set_3dfx_mode
+ /*** GLX_MESA_release_buffers ***/
+ { "glXReleaseBuffersMESA", (GLvoid *) glXReleaseBuffersMESA },
+
+ /*** GLX_MESA_set_3dfx_mode ***/
{ "glXSet3DfxModeMESA", (GLvoid *) glXSet3DfxModeMESA },
-#endif
+ /*** GLX_ARB_get_proc_address ***/
{ "glXGetProcAddressARB", (GLvoid *) glXGetProcAddressARB },
{ NULL, NULL } /* end of list */
@@ -829,3 +1373,10 @@ void (*glXGetProcAddressARB(const GLubyte *procName))()
f = (gl_function) _glapi_get_proc_address((const char *) procName);
return f;
}
+
+
+/* GLX 1.4 */
+void (*glXGetProcAddress(const GLubyte *procName))()
+{
+ return glXGetProcAddressARB(procName);
+}
diff --git a/xc/extras/Mesa/src/X/glxapi.h b/xc/extras/Mesa/src/X/glxapi.h
index e77a4ff45..7db20d21a 100644
--- a/xc/extras/Mesa/src/X/glxapi.h
+++ b/xc/extras/Mesa/src/X/glxapi.h
@@ -1,9 +1,10 @@
+/* $Id: glxapi.h,v 1.8 2002/02/14 01:59:35 dawes Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.5
*
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -28,11 +29,25 @@
#define _glxapi_h_
-#define GLX_GLXEXT_LEGACY
-#define GL_GLEXT_PROTOTYPES
+#define GLX_GLXEXT_PROTOTYPES
#include "GL/glx.h"
+#ifdef GLX_BUILT_IN_XMESA
+/* The GLX API dispatcher is being built into XFree86's libGL */
+#include "glxclient.h"
+#else
+/* The GLX API dispatcher is being built into stand-alone Mesa */
+typedef struct __GLXcontextRec {
+ Display *currentDpy;
+ GLboolean isDirect;
+ GLXDrawable currentDrawable;
+ GLXDrawable currentReadable;
+ XID xid;
+} __GLXcontext;
+#endif
+
+
/*
* Almost all the GLX API functions get routed through this dispatch table.
* The exceptions are the glXGetCurrentXXX() functions.
@@ -41,9 +56,12 @@
* Specifically, a real GLX library (like SGI's or the Utah GLX) and Mesa's
* pseudo-GLX can be present at the same time. The former being used on
* GLX-enabled X servers and the later on non-GLX X servers.
+ *
+ * XXX Note that this hasn't actually been fully used yet in either Mesa or
+ * the DRI. Red Hat, however, has used it for their custom libGL.
*/
struct _glxapi_table {
- /* GLX 1.0 functions */
+ /*** GLX_VERSION_1_0 ***/
XVisualInfo *(*ChooseVisual)(Display *dpy, int screen, int *list);
void (*CopyContext)(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
GLXContext (*CreateContext)(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct);
@@ -62,17 +80,15 @@ struct _glxapi_table {
void (*WaitGL)(void);
void (*WaitX)(void);
-#ifdef GLX_VERSION_1_1
+ /*** GLX_VERSION_1_1 ***/
const char *(*GetClientString)(Display *dpy, int name);
const char *(*QueryExtensionsString)(Display *dpy, int screen);
const char *(*QueryServerString)(Display *dpy, int screen, int name);
-#endif
-#ifdef GLX_VERSION_1_2
+ /*** GLX_VERSION_1_2 ***/
/*Display *(*GetCurrentDisplay)(void);*/
-#endif
-#ifdef GLX_VERSION_1_3
+ /*** GLX_VERSION_1_3 ***/
GLXFBConfig *(*ChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems);
GLXContext (*CreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct);
GLXPbuffer (*CreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attribList);
@@ -90,40 +106,87 @@ struct _glxapi_table {
int (*QueryContext)(Display *dpy, GLXContext ctx, int attribute, int *value);
void (*QueryDrawable)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
void (*SelectEvent)(Display *dpy, GLXDrawable drawable, unsigned long mask);
+
+ /*** GLX_SGI_swap_control ***/
+ int (*SwapIntervalSGI)(int);
+
+ /*** GLX_SGI_video_sync ***/
+ int (*GetVideoSyncSGI)(unsigned int *count);
+ int (*WaitVideoSyncSGI)(int divisor, int remainder, unsigned int *count);
+
+ /*** GLX_SGI_make_current_read ***/
+ Bool (*MakeCurrentReadSGI)(Display *, GLXDrawable, GLXDrawable, GLXContext);
+ /*GLXDrawable (*GetCurrentReadDrawableSGI)(void);*/
+
+ /*** GLX_SGIX_video_source (needs video library) ***/
+#if defined(_VL_H_)
+ GLXVideoSourceSGIX (*CreateGLXVideoSourceSGIX)(Display *, int, VLServer, VLPath, int, VLNode);
+ void (*DestroyGLXVideoSourceSGIX)(Display *, GLXVideoSourceSGIX);
+#else
+ void *CreateGLXVideoSourceSGIX;
+ void *DestroyGLXVideoSourceSGIX;
#endif
-#ifdef GLX_EXT_import_context
+ /*** GLX_EXT_import_context ***/
void (*FreeContextEXT)(Display *dpy, GLXContext context);
GLXContextID (*GetContextIDEXT)(const GLXContext context);
- Display *(*GetCurrentDisplayEXT)(void);
+ /*Display *(*GetCurrentDisplayEXT)(void);*/
GLXContext (*ImportContextEXT)(Display *dpy, GLXContextID contextID);
int (*QueryContextInfoEXT)(Display *dpy, GLXContext context, int attribute,int *value);
-#endif
-#ifdef GLX_SGI_video_sync
- int (*GetVideoSyncSGI)(unsigned int *count);
- int (*WaitVideoSyncSGI)(int divisor, int remainder, unsigned int *count);
+ /*** GLX_SGIX_fbconfig ***/
+ int (*GetFBConfigAttribSGIX)(Display *, GLXFBConfigSGIX, int, int *);
+ GLXFBConfigSGIX * (*ChooseFBConfigSGIX)(Display *, int, int *, int *);
+ GLXPixmap (*CreateGLXPixmapWithConfigSGIX)(Display *, GLXFBConfigSGIX, Pixmap);
+ GLXContext (*CreateContextWithConfigSGIX)(Display *, GLXFBConfigSGIX, int, GLXContext, Bool);
+ XVisualInfo * (*GetVisualFromFBConfigSGIX)(Display *, GLXFBConfigSGIX);
+ GLXFBConfigSGIX (*GetFBConfigFromVisualSGIX)(Display *, XVisualInfo *);
+
+ /*** GLX_SGIX_pbuffer ***/
+ GLXPbufferSGIX (*CreateGLXPbufferSGIX)(Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *);
+ void (*DestroyGLXPbufferSGIX)(Display *, GLXPbufferSGIX);
+ int (*QueryGLXPbufferSGIX)(Display *, GLXPbufferSGIX, int, unsigned int *);
+ void (*SelectEventSGIX)(Display *, GLXDrawable, unsigned long);
+ void (*GetSelectedEventSGIX)(Display *, GLXDrawable, unsigned long *);
+
+ /*** GLX_SGI_cushion ***/
+ void (*CushionSGI)(Display *, Window, float);
+
+ /*** GLX_SGIX_video_resize ***/
+ int (*BindChannelToWindowSGIX)(Display *, int, int, Window);
+ int (*ChannelRectSGIX)(Display *, int, int, int, int, int, int);
+ int (*QueryChannelRectSGIX)(Display *, int, int, int *, int *, int *, int *);
+ int (*QueryChannelDeltasSGIX)(Display *, int, int, int *, int *, int *, int *);
+ int (*ChannelRectSyncSGIX)(Display *, int, int, GLenum);
+
+ /*** GLX_SGIX_dmbuffer (needs dmedia library) ***/
+#if defined (_DM_BUFFER_H_)
+ Bool (*AssociateDMPbufferSGIX)(Display *, GLXPbufferSGIX, DMparams *, DMbuffer);
+#else
+ void *AssociciateDMPbufferSGIX;
#endif
- /*
- * XXX thesa Mesa-specific functions might not belong here
- */
+ /*** GLX_SGIX_swap_group ***/
+ void (*JoinSwapGroupSGIX)(Display *, GLXDrawable, GLXDrawable);
+
+ /*** GLX_SGIX_swap_barrier ***/
+ void (*BindSwapBarrierSGIX)(Display *, GLXDrawable, int);
+ Bool (*QueryMaxSwapBarriersSGIX)(Display *, int, int *);
-#ifdef GLX_MESA_copy_sub_buffer
+ /*** GLX_SUN_get_transparent_index ***/
+ Status (*GetTransparentIndexSUN)(Display *, Window, Window, long *);
+
+ /*** GLX_MESA_copy_sub_buffer ***/
void (*CopySubBufferMESA)(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
-#endif
-#ifdef GLX_MESA_release_buffers
+ /*** GLX_MESA_release_buffers ***/
Bool (*ReleaseBuffersMESA)(Display *dpy, Window w);
-#endif
-#ifdef GLX_MESA_pixmap_colormap
+ /*** GLX_MESA_pixmap_colormap ***/
GLXPixmap (*CreateGLXPixmapMESA)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap);
-#endif
-#ifdef GLX_MESA_set_3dfx_mode
- GLboolean (*Set3DfxModeMESA)(GLint mode);
-#endif
+ /*** GLX_MESA_set_3dfx_mode ***/
+ Bool (*Set3DfxModeMESA)(int mode);
};
diff --git a/xc/extras/Mesa/src/X/glxheader.h b/xc/extras/Mesa/src/X/glxheader.h
index 5bd1f5c65..24e8b6994 100644
--- a/xc/extras/Mesa/src/X/glxheader.h
+++ b/xc/extras/Mesa/src/X/glxheader.h
@@ -1,7 +1,8 @@
+/* $Id: glxheader.h,v 1.6 2002/02/14 01:59:35 dawes Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.5
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -27,11 +28,10 @@
#ifndef GLX_HEADER_H
#define GLX_HEADER_H
-#ifdef VMS
-#include <vms_x_fix.h>
+#ifdef __VMS
+#include <GL/vms_x_fix.h>
#endif
-
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
@@ -50,9 +50,6 @@
#else
-# ifdef GLX_DIRECT_RENDERING
-# include "dri_mesaint.h"
-# endif
# include <X11/Xlib.h>
# include <X11/Xutil.h>
# ifdef USE_XSHM /* was SHM */
diff --git a/xc/extras/Mesa/src/X/realglx.c b/xc/extras/Mesa/src/X/realglx.c
new file mode 100644
index 000000000..291e93cd8
--- /dev/null
+++ b/xc/extras/Mesa/src/X/realglx.c
@@ -0,0 +1,174 @@
+/* $Id: realglx.c,v 1.5 2002/02/14 01:59:35 dawes Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * 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
+ * BRIAN PAUL 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 <assert.h>
+#include <GL/glx.h>
+#include "realglx.h"
+#include "glxapi.h"
+
+
+struct _glxapi_table *
+_real_GetGLXDispatchTable(void)
+{
+ static struct _glxapi_table glx;
+
+ /* be sure our dispatch table size <= libGL's table */
+ {
+ GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
+ (void) size;
+ assert(_glxapi_get_dispatch_table_size() >= size);
+ }
+
+ /* initialize the whole table to no-ops */
+ _glxapi_set_no_op_table(&glx);
+
+ /* now initialize the table with the functions I implement */
+
+ /*** GLX_VERSION_1_0 ***/
+ glx.ChooseVisual = _real_glXChooseVisual;
+ glx.CopyContext = _real_glXCopyContext;
+ glx.CreateContext = _real_glXCreateContext;
+ glx.CreateGLXPixmap = _real_glXCreateGLXPixmap;
+ glx.DestroyContext = _real_glXDestroyContext;
+ glx.DestroyGLXPixmap = _real_glXDestroyGLXPixmap;
+ glx.GetConfig = _real_glXGetConfig;
+ /*glx.GetCurrentContext = _real_glXGetCurrentContext;*/
+ /*glx.GetCurrentDrawable = _real_glXGetCurrentDrawable;*/
+ glx.IsDirect = _real_glXIsDirect;
+ glx.MakeCurrent = _real_glXMakeCurrent;
+ glx.QueryExtension = _real_glXQueryExtension;
+ glx.QueryVersion = _real_glXQueryVersion;
+ glx.SwapBuffers = _real_glXSwapBuffers;
+ glx.UseXFont = _real_glXUseXFont;
+ glx.WaitGL = _real_glXWaitGL;
+ glx.WaitX = _real_glXWaitX;
+
+ /*** GLX_VERSION_1_1 ***/
+ glx.GetClientString = _real_glXGetClientString;
+ glx.QueryExtensionsString = _real_glXQueryExtensionsString;
+ glx.QueryServerString = _real_glXQueryServerString;
+
+ /*** GLX_VERSION_1_2 ***/
+ /*glx.GetCurrentDisplay = _real_glXGetCurrentDisplay;*/
+
+ /*** GLX_VERSION_1_3 ***/
+ glx.ChooseFBConfig = _real_glXChooseFBConfig;
+ glx.CreateNewContext = _real_glXCreateNewContext;
+ glx.CreatePbuffer = _real_glXCreatePbuffer;
+ glx.CreatePixmap = _real_glXCreatePixmap;
+ glx.CreateWindow = _real_glXCreateWindow;
+ glx.DestroyPbuffer = _real_glXDestroyPbuffer;
+ glx.DestroyPixmap = _real_glXDestroyPixmap;
+ glx.DestroyWindow = _real_glXDestroyWindow;
+ /*glx.GetCurrentReadDrawable = _real_glXGetCurrentReadDrawable;*/
+ glx.GetFBConfigAttrib = _real_glXGetFBConfigAttrib;
+ glx.GetFBConfigs = _real_glXGetFBConfigs;
+ glx.GetSelectedEvent = _real_glXGetSelectedEvent;
+ glx.GetVisualFromFBConfig = _real_glXGetVisualFromFBConfig;
+ glx.MakeContextCurrent = _real_glXMakeContextCurrent;
+ glx.QueryContext = _real_glXQueryContext;
+ glx.QueryDrawable = _real_glXQueryDrawable;
+ glx.SelectEvent = _real_glXSelectEvent;
+
+ /*** GLX_SGI_swap_control ***/
+ glx.SwapIntervalSGI = _real_glXSwapIntervalSGI;
+
+ /*** GLX_SGI_video_sync ***/
+ glx.GetVideoSyncSGI = _real_glXGetVideoSyncSGI;
+ glx.WaitVideoSyncSGI = _real_glXWaitVideoSyncSGI;
+
+ /*** GLX_SGI_make_current_read ***/
+ glx.MakeCurrentReadSGI = _real_glXMakeCurrentReadSGI;
+ /*glx.GetCurrentReadDrawableSGI = _real_glXGetCurrentReadDrawableSGI;*/
+
+#if defined(_VL_H)
+ /*** GLX_SGIX_video_source ***/
+ glx.CreateGLXVideoSourceSGIX = _real_glXCreateGLXVideoSourceSGIX;
+ glx.DestroyGLXVideoSourceSGIX = _real_glXDestroyGLXVideoSourceSGIX;
+#endif
+
+ /*** GLX_EXT_import_context ***/
+ glx.FreeContextEXT = _real_glXFreeContextEXT;
+ /*glx.GetContextIDEXT = _real_glXGetContextIDEXT;*/
+ /*glx.GetCurrentDisplayEXT = _real_glXGetCurrentDisplayEXT;*/
+ glx.ImportContextEXT = _real_glXImportContextEXT;
+ glx.QueryContextInfoEXT = _real_glXQueryContextInfoEXT;
+
+ /*** GLX_SGIX_fbconfig ***/
+ glx.GetFBConfigAttribSGIX = _real_glXGetFBConfigAttribSGIX;
+ glx.ChooseFBConfigSGIX = _real_glXChooseFBConfigSGIX;
+ glx.CreateGLXPixmapWithConfigSGIX = _real_glXCreateGLXPixmapWithConfigSGIX;
+ glx.CreateContextWithConfigSGIX = _real_glXCreateContextWithConfigSGIX;
+ glx.GetVisualFromFBConfigSGIX = _real_glXGetVisualFromFBConfigSGIX;
+ glx.GetFBConfigFromVisualSGIX = _real_glXGetFBConfigFromVisualSGIX;
+
+ /*** GLX_SGIX_pbuffer ***/
+ glx.CreateGLXPbufferSGIX = _real_glXCreateGLXPbufferSGIX;
+ glx.DestroyGLXPbufferSGIX = _real_glXDestroyGLXPbufferSGIX;
+ glx.QueryGLXPbufferSGIX = _real_glXQueryGLXPbufferSGIX;
+ glx.SelectEventSGIX = _real_glXSelectEventSGIX;
+ glx.GetSelectedEventSGIX = _real_glXGetSelectedEventSGIX;
+
+ /*** GLX_SGI_cushion ***/
+ glx.CushionSGI = _real_glXCushionSGI;
+
+ /*** GLX_SGIX_video_resize ***/
+ glx.BindChannelToWindowSGIX = _real_glXBindChannelToWindowSGIX;
+ glx.ChannelRectSGIX = _real_glXChannelRectSGIX;
+ glx.QueryChannelRectSGIX = _real_glXQueryChannelRectSGIX;
+ glx.QueryChannelDeltasSGIX = _real_glXQueryChannelDeltasSGIX;
+ glx.ChannelRectSyncSGIX = _real_glXChannelRectSyncSGIX;
+
+#if defined(_DM_BUFFER_H_)
+ /*** (GLX_SGIX_dmbuffer ***/
+ glx.AssociateDMPbufferSGIX = NULL;
+#endif
+
+ /*** GLX_SGIX_swap_group ***/
+ glx.JoinSwapGroupSGIX = _real_glXJoinSwapGroupSGIX;
+
+ /*** GLX_SGIX_swap_barrier ***/
+ glx.BindSwapBarrierSGIX = _real_glXBindSwapBarrierSGIX;
+ glx.QueryMaxSwapBarriersSGIX = _real_glXQueryMaxSwapBarriersSGIX;
+
+ /*** GLX_SUN_get_transparent_index ***/
+ glx.GetTransparentIndexSUN = _real_glXGetTransparentIndexSUN;
+
+ /*** GLX_MESA_copy_sub_buffer ***/
+ glx.CopySubBufferMESA = _real_glXCopySubBufferMESA;
+
+ /*** GLX_MESA_release_buffers ***/
+ glx.ReleaseBuffersMESA = _real_glXReleaseBuffersMESA;
+
+ /*** GLX_MESA_pixmap_colormap ***/
+ glx.CreateGLXPixmapMESA = _real_glXCreateGLXPixmapMESA;
+
+ /*** GLX_MESA_set_3dfx_mode ***/
+ glx.Set3DfxModeMESA = _real_glXSet3DfxModeMESA;
+
+ return &glx;
+}
diff --git a/xc/extras/Mesa/src/X/realglx.h b/xc/extras/Mesa/src/X/realglx.h
new file mode 100644
index 000000000..59d2539d1
--- /dev/null
+++ b/xc/extras/Mesa/src/X/realglx.h
@@ -0,0 +1,315 @@
+/* $Id: realglx.h,v 1.5 2002/02/14 01:59:35 dawes Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * 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
+ * BRIAN PAUL 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 REALGLX_H
+#define REALGLX_H
+
+
+extern struct _glxapi_table *
+_real_GetGLXDispatchTable(void);
+
+
+/*
+ * Basically just need these to prevent compiler warnings.
+ */
+
+
+extern XVisualInfo *
+_real_glXChooseVisual( Display *dpy, int screen, int *list );
+
+extern GLXContext
+_real_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
+ GLXContext share_list, Bool direct );
+
+extern GLXPixmap
+_real_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap );
+
+extern GLXPixmap
+_real_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
+ Pixmap pixmap, Colormap cmap );
+
+extern void
+_real_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
+
+extern void
+_real_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
+ unsigned long mask );
+
+extern Bool
+_real_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx );
+
+extern Bool
+_real_glXQueryExtension( Display *dpy, int *errorb, int *event );
+
+extern void
+_real_glXDestroyContext( Display *dpy, GLXContext ctx );
+
+extern Bool
+_real_glXIsDirect( Display *dpy, GLXContext ctx );
+
+extern void
+_real_glXSwapBuffers( Display *dpy, GLXDrawable drawable );
+
+extern void
+_real_glXUseXFont( Font font, int first, int count, int listbase );
+
+extern Bool
+_real_glXQueryVersion( Display *dpy, int *maj, int *min );
+
+extern int
+_real_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
+ int attrib, int *value );
+
+extern void
+_real_glXWaitGL( void );
+
+
+extern void
+_real_glXWaitX( void );
+
+/* GLX 1.1 and later */
+extern const char *
+_real_glXQueryExtensionsString( Display *dpy, int screen );
+
+/* GLX 1.1 and later */
+extern const char *
+_real_glXQueryServerString( Display *dpy, int screen, int name );
+
+/* GLX 1.1 and later */
+extern const char *
+_real_glXGetClientString( Display *dpy, int name );
+
+
+/*
+ * GLX 1.3 and later
+ */
+
+extern GLXFBConfig *
+_real_glXChooseFBConfig( Display *dpy, int screen,
+ const int *attribList, int *nitems );
+
+extern int
+_real_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
+ int attribute, int *value );
+
+extern GLXFBConfig *
+_real_glXGetFBConfigs( Display *dpy, int screen, int *nelements );
+
+extern XVisualInfo *
+_real_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config );
+
+extern GLXWindow
+_real_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
+ const int *attribList );
+
+extern void
+_real_glXDestroyWindow( Display *dpy, GLXWindow window );
+
+extern GLXPixmap
+_real_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
+ const int *attribList );
+
+extern void
+_real_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
+
+extern GLXPbuffer
+_real_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
+ const int *attribList );
+
+extern void
+_real_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
+
+extern void
+_real_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
+ unsigned int *value );
+
+extern GLXContext
+_real_glXCreateNewContext( Display *dpy, GLXFBConfig config,
+ int renderType, GLXContext shareList, Bool direct );
+
+
+extern Bool
+_real_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext ctx );
+
+extern int
+_real_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value );
+
+extern void
+_real_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask );
+
+extern void
+_real_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
+ unsigned long *mask );
+
+#ifdef GLX_SGI_swap_control
+extern int
+_real_glXSwapIntervalSGI(int interval);
+#endif
+
+
+#ifdef GLX_SGI_video_sync
+extern int
+_real_glXGetVideoSyncSGI(unsigned int *count);
+
+extern int
+_real_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count);
+#endif
+
+
+#ifdef GLX_SGI_make_current_read
+extern Bool
+_real_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+
+extern GLXDrawable
+_real_glXGetCurrentReadDrawableSGI(void);
+#endif
+
+#if defined(_VL_H) && defined(GLX_SGIX_video_source)
+extern GLXVideoSourceSGIX
+_real_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
+
+extern void
+_real_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src);
+#endif
+
+#ifdef GLX_EXT_import_context
+extern void
+_real_glXFreeContextEXT(Display *dpy, GLXContext context);
+
+extern GLXContextID
+_real_glXGetContextIDEXT(const GLXContext context);
+
+extern Display *
+_real_glXGetCurrentDisplayEXT(void);
+
+extern GLXContext
+_real_glXImportContextEXT(Display *dpy, GLXContextID contextID);
+
+extern int
+_real_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value);
+#endif
+
+#ifdef GLX_SGIX_fbconfig
+extern int
+_real_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
+
+extern GLXFBConfigSGIX *
+_real_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements);
+
+extern GLXPixmap
+_real_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
+
+extern GLXContext
+_real_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
+
+extern XVisualInfo *
+_real_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config);
+
+extern GLXFBConfigSGIX
+_real_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis);
+#endif
+
+#ifdef GLX_SGIX_pbuffer
+extern GLXPbufferSGIX
+_real_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
+
+extern void
+_real_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf);
+
+extern int
+_real_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
+
+extern void
+_real_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask);
+
+extern void
+_real_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask);
+#endif
+
+#ifdef GLX_SGI_cushion
+extern void
+_real_glXCushionSGI(Display *dpy, Window win, float cushion);
+#endif
+
+#ifdef GLX_SGIX_video_resize
+extern int
+_real_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window);
+
+extern int
+_real_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h);
+
+extern int
+_real_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h);
+
+extern int
+_real_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
+
+extern int
+_real_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype);
+#endif
+
+#if defined(_DM_BUFFER_H_) && defined(GLX_SGIX_dmbuffer)
+extern Bool
+_real_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
+#endif
+
+#ifdef GLX_SGIX_swap_group
+extern void
+_real_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member);
+#endif
+
+#ifdef GLX_SGIX_swap_barrier
+extern void
+_real_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier);
+
+extern Bool
+_real_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max);
+#endif
+
+#ifdef GLX_SUN_get_transparent_index
+extern Status
+_real_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent);
+#endif
+
+#ifdef GLX_MESA_release_buffers
+extern Bool
+_real_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
+#endif
+
+#ifdef GLX_MESA_set_3dfx_mode
+extern Bool
+_real_glXSet3DfxModeMESA( int mode );
+#endif
+
+#ifdef GLX_MESA_copy_sub_buffer
+extern void
+_real_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height );
+#endif
+
+#endif /* REALGLX_H */
diff --git a/xc/extras/Mesa/src/X/xfonts.c b/xc/extras/Mesa/src/X/xfonts.c
index 70190e4be..c8bc65d0c 100644
--- a/xc/extras/Mesa/src/X/xfonts.c
+++ b/xc/extras/Mesa/src/X/xfonts.c
@@ -1,7 +1,8 @@
+/* $Id: xfonts.c,v 1.10 2002/02/14 01:59:35 dawes Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.4
+ * Version: 3.5
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -28,16 +29,14 @@
* Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de
*/
+#ifdef __VMS
+#include <GL/vms_x_fix.h>
+#endif
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
-#ifdef VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -181,10 +180,10 @@ fill_bitmap (Display *dpy, Window win, GC gc,
* determine if a given glyph is valid and return the
* corresponding XCharStruct.
*/
-static XCharStruct *isvalid(XFontStruct *fs, int which)
+static XCharStruct *isvalid(XFontStruct *fs, unsigned int which)
{
unsigned int rows,pages;
- int byte1 = 0,byte2 = 0;
+ unsigned int byte1 = 0,byte2 = 0;
int i,valid = 1;
rows = fs->max_byte1 - fs->min_byte1 + 1;
@@ -245,7 +244,7 @@ void Fake_glXUseXFont( Font font, int first, int count, int listbase )
fs = XQueryFont (dpy, font);
if (!fs) {
- gl_error(NULL, GL_INVALID_VALUE,
+ _mesa_error(NULL, GL_INVALID_VALUE,
"Couldn't get font structure information");
return;
}
@@ -260,7 +259,7 @@ void Fake_glXUseXFont( Font font, int first, int count, int listbase )
(GLubyte));
if (!bm) {
XFreeFontInfo( NULL, fs, 1 );
- gl_error(NULL, GL_OUT_OF_MEMORY,
+ _mesa_error(NULL, GL_OUT_OF_MEMORY,
"Couldn't allocate bitmap in glXUseXFont()");
return;
}
diff --git a/xc/extras/Mesa/src/X/xfonts.h b/xc/extras/Mesa/src/X/xfonts.h
index 1fe67f980..c206c48b2 100644
--- a/xc/extras/Mesa/src/X/xfonts.h
+++ b/xc/extras/Mesa/src/X/xfonts.h
@@ -1,7 +1,8 @@
+/* $Id: xfonts.h,v 1.2 2002/02/14 01:59:35 dawes Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.5
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -27,6 +28,9 @@
#ifndef XFONTS_H
#define XFONTS_H
+#ifdef __VMS
+#include <GL/vms_x_fix.h>
+#endif
#include <X11/Xlib.h>
diff --git a/xc/extras/Mesa/src/X/xmesa1.c b/xc/extras/Mesa/src/X/xm_api.c
index 800a37f56..a8b96e18b 100644
--- a/xc/extras/Mesa/src/X/xmesa1.c
+++ b/xc/extras/Mesa/src/X/xm_api.c
@@ -1,9 +1,10 @@
-/* $XFree86: xc/extras/Mesa/src/X/xmesa1.c,v 1.17 2001/11/14 10:28:07 alanh Exp $ */
+/* $Id: xm_api.c,v 1.2 2002/02/14 01:59:35 dawes Exp $ */
+
/*
* Mesa 3-D graphics library
- * Version: 3.4.2
+ * Version: 3.5
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,8 +26,6 @@
/*
- * Mesa/X11 interface, part 1.
- *
* This file contains the implementations of all the XMesa* functions.
*
*
@@ -72,11 +71,18 @@
#include "glthread.h"
#include "matrix.h"
#include "mem.h"
-#include "types.h"
+#include "mmath.h"
+#include "mtypes.h"
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
-
+#include "macros.h"
+#include "texformat.h"
+#include "texstore.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
#ifndef GLX_NONE_EXT
#define GLX_NONE_EXT 0x8000
@@ -261,7 +267,7 @@ static GLint gamma_adjust( GLfloat gamma, GLint value, GLint max )
}
else {
double x = (double) value / (double) max;
- return (GLint) ((GLfloat) max * pow( x, 1.0F/gamma ) + 0.5F);
+ return IROUND_POS((GLfloat) max * pow(x, 1.0F/gamma));
}
}
@@ -322,7 +328,7 @@ static int bits_per_pixel( XMesaVisual xmv )
/*
* Determine if a given X window ID is valid (window exists).
- * Do this by calling XGetIconName() for the window and
+ * Do this by calling XGetWindowAttributes() for the window and
* checking if we catch an X error.
* Input: dpy - the display
* win - the window to check for existance
@@ -343,14 +349,12 @@ static int window_exists_err_handler( XMesaDisplay* dpy, XErrorEvent* xerr )
static GLboolean window_exists( XMesaDisplay *dpy, Window win )
{
- char *name;
+ XWindowAttributes wa;
int (*old_handler)( XMesaDisplay*, XErrorEvent* );
WindowExistsFlag = GL_TRUE;
old_handler = XSetErrorHandler(window_exists_err_handler);
- XGetIconName(dpy, win, &name); /* dummy request */
+ XGetWindowAttributes( dpy, win, &wa ); /* dummy request */
XSetErrorHandler(old_handler);
- if (name)
- XFree(name);
return WindowExistsFlag;
}
#endif
@@ -423,14 +427,17 @@ static void free_xmesa_buffer(int client, XMesaBuffer buffer)
#endif
}
}
+
+ _mesa_free_framebuffer_data(&buffer->mesa_buffer);
FREE(buffer);
+
return;
}
/* continue search */
prev = b;
}
/* buffer not found in XMesaBufferList */
- gl_problem(NULL,"free_xmesa_buffer() - buffer not found\n");
+ _mesa_problem(NULL,"free_xmesa_buffer() - buffer not found\n");
}
@@ -598,7 +605,6 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
*/
void xmesa_alloc_back_buffer( XMesaBuffer b )
{
- (void)DitherValues;
if (b->db_state==BACK_XIMAGE) {
/* Deallocate the old backimage, if any */
if (b->backimage) {
@@ -822,8 +828,8 @@ static GLboolean setup_grayscale( int client, XMesaVisual v,
prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
if (prevBuffer &&
- (buffer->xm_visual->gl_visual->RGBAflag ==
- prevBuffer->xm_visual->gl_visual->RGBAflag)) {
+ (buffer->xm_visual->mesa_visual.rgbMode ==
+ prevBuffer->xm_visual->mesa_visual.rgbMode)) {
/* Copy colormap stuff from previous XMesaBuffer which uses same
* X colormap. Do this to avoid time spent in noFaultXAllocColor.
*/
@@ -910,8 +916,8 @@ static GLboolean setup_dithered_color( int client, XMesaVisual v,
prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
if (prevBuffer &&
- (buffer->xm_visual->gl_visual->RGBAflag ==
- prevBuffer->xm_visual->gl_visual->RGBAflag)) {
+ (buffer->xm_visual->mesa_visual.rgbMode ==
+ prevBuffer->xm_visual->mesa_visual.rgbMode)) {
/* Copy colormap stuff from previous, matching XMesaBuffer.
* Do this to avoid time spent in noFaultXAllocColor.
*/
@@ -985,19 +991,19 @@ static void setup_8bit_hpcr( XMesaVisual v )
g = 1.0 / v->RedGamma;
for (i=0; i<256; i++) {
- GLint red = (GLint) (255.0 * pow( hpcr_rgbTbl[0][i]/255.0, g ) + 0.5);
+ GLint red = IROUND_POS(255.0 * pow( hpcr_rgbTbl[0][i]/255.0, g ));
v->hpcr_rgbTbl[0][i] = CLAMP( red, 16, 239 );
}
g = 1.0 / v->GreenGamma;
for (i=0; i<256; i++) {
- GLint green = (GLint) (255.0 * pow( hpcr_rgbTbl[1][i]/255.0, g ) + 0.5);
+ GLint green = IROUND_POS(255.0 * pow( hpcr_rgbTbl[1][i]/255.0, g ));
v->hpcr_rgbTbl[1][i] = CLAMP( green, 16, 239 );
}
g = 1.0 / v->BlueGamma;
for (i=0; i<256; i++) {
- GLint blue = (GLint) (255.0 * pow( hpcr_rgbTbl[2][i]/255.0, g ) + 0.5);
+ GLint blue = IROUND_POS(255.0 * pow( hpcr_rgbTbl[2][i]/255.0, g ));
v->hpcr_rgbTbl[2][i] = CLAMP( blue, 32, 223 );
}
v->undithered_pf = PF_HPCR; /* can't really disable dithering for now */
@@ -1024,11 +1030,10 @@ static void setup_8bit_hpcr( XMesaVisual v )
* Setup RGB rendering for a window with a True/DirectColor visual.
*/
static void setup_truecolor( XMesaVisual v, XMesaBuffer buffer,
- XMesaWindow window, XMesaColormap cmap )
+ XMesaColormap cmap )
{
unsigned long rmask, gmask, bmask;
(void) buffer;
- (void) window;
(void) cmap;
/* Compute red multiplier (mask) and bit shift */
@@ -1068,7 +1073,7 @@ static void setup_truecolor( XMesaVisual v, XMesaBuffer buffer,
GLint rBits = bitcount(rmask);
GLint gBits = bitcount(gmask);
GLint bBits = bitcount(bmask);
- GLint minBits;
+ GLint maxBits;
GLuint i;
/* convert pixel components in [0,_mask] to RGB values in [0,255] */
@@ -1097,11 +1102,11 @@ static void setup_truecolor( XMesaVisual v, XMesaBuffer buffer,
}
/* setup dithering kernel */
- minBits = rBits;
- if (gBits < minBits) minBits = gBits;
- if (bBits < minBits) minBits = bBits;
+ maxBits = rBits;
+ if (gBits > maxBits) maxBits = gBits;
+ if (bBits > maxBits) maxBits = bBits;
for (i=0;i<16;i++) {
- v->Kernel[i] = kernel[i] >> minBits;
+ v->Kernel[i] = kernel[i] >> maxBits;
}
v->undithered_pf = PF_TRUECOLOR;
@@ -1221,7 +1226,7 @@ static GLboolean initialize_visual_and_buffer( int client,
int xclass;
xclass = GET_VISUAL_CLASS(v);
if (xclass==TrueColor || xclass==DirectColor) {
- setup_truecolor( v, b, (XMesaWindow)window, cmap );
+ setup_truecolor( v, b, cmap );
}
else if (xclass==StaticGray && GET_VISUAL_DEPTH(v)==1) {
setup_monochrome( v, b );
@@ -1255,7 +1260,7 @@ static GLboolean initialize_visual_and_buffer( int client,
* reports bugs.
*/
if (getenv("MESA_INFO")) {
- fprintf(stderr, "X/Mesa visual = %p\n", v);
+ fprintf(stderr, "X/Mesa visual = %p\n", (void *) v);
fprintf(stderr, "X/Mesa dithered pf = %u\n", v->dithered_pf);
fprintf(stderr, "X/Mesa undithered pf = %u\n", v->undithered_pf);
fprintf(stderr, "X/Mesa level = %d\n", v->level);
@@ -1274,10 +1279,8 @@ static GLboolean initialize_visual_and_buffer( int client,
b->frontbuffer = window;
- assert( v->gl_visual );
-
/* Setup for single/double buffering */
- if (v->gl_visual->DBflag) {
+ if (v->mesa_visual.doubleBufferMode) {
/* Double buffered */
#ifndef XFree86Server
b->shm = check_for_xshm( v->display );
@@ -1297,14 +1300,11 @@ static GLboolean initialize_visual_and_buffer( int client,
/* X11 graphics contexts */
#ifdef XFree86Server
- b->gc1 = CreateScratchGC(v->display, window->depth);
- b->gc2 = CreateScratchGC(v->display, window->depth);
+ b->gc = CreateScratchGC(v->display, window->depth);
#else
- b->gc1 = XCreateGC( v->display, window, 0, NULL );
- b->gc2 = XCreateGC( v->display, window, 0, NULL );
+ b->gc = XCreateGC( v->display, window, 0, NULL );
#endif
- XMesaSetFunction( v->display, b->gc1, GXcopy );
- XMesaSetFunction( v->display, b->gc2, GXcopy );
+ XMesaSetFunction( v->display, b->gc, GXcopy );
/*
* Don't generate Graphics Expose/NoExpose events in swapbuffers().
@@ -1413,7 +1413,7 @@ xmesa_color_to_pixel( XMesaContext xmesa, GLubyte r, GLubyte g, GLubyte b, GLuby
return p;
}
default:
- gl_problem(NULL, "Bad pixel format in xmesa_color_to_pixel");
+ _mesa_problem(NULL, "Bad pixel format in xmesa_color_to_pixel");
}
return 0;
}
@@ -1571,23 +1571,16 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
if (alpha_flag && alpha_bits == 0)
alpha_bits = 8;
- v->gl_visual = _mesa_create_visual( rgb_flag, db_flag, stereo_flag,
- red_bits, green_bits,
- blue_bits, alpha_bits,
- v->index_bits,
- depth_size,
- stencil_size,
- accum_red_size, accum_green_size,
- accum_blue_size, accum_alpha_size,
- 0 );
- if (!v->gl_visual) {
-#ifndef XFree86Server
- FREE(v->visinfo);
-#endif
- FREE(v);
- return NULL;
- }
-
+ _mesa_initialize_visual( &v->mesa_visual,
+ rgb_flag, db_flag, stereo_flag,
+ red_bits, green_bits,
+ blue_bits, alpha_bits,
+ v->index_bits,
+ depth_size,
+ stencil_size,
+ accum_red_size, accum_green_size,
+ accum_blue_size, accum_alpha_size,
+ 0 );
return v;
}
@@ -1600,7 +1593,6 @@ void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v )
void XMesaDestroyVisual( XMesaVisual v )
{
- _mesa_destroy_visual( v->gl_visual );
#ifndef XFree86Server
FREE(v->visinfo);
#endif
@@ -1619,6 +1611,7 @@ void XMesaDestroyVisual( XMesaVisual v )
XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
{
XMesaContext c;
+ GLcontext *ctx;
GLboolean direct = GL_TRUE; /* XXXX */
/* NOT_DONE: should this be GL_FALSE??? */
static GLboolean firstTime = GL_TRUE;
@@ -1633,7 +1626,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
return NULL;
}
- c->gl_ctx = gl_create_context( v->gl_visual,
+ ctx = c->gl_ctx = _mesa_create_context( &v->mesa_visual,
share_list ? share_list->gl_ctx : (GLcontext *) NULL,
(void *) c, direct );
if (!c->gl_ctx) {
@@ -1641,10 +1634,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
return NULL;
}
- gl_extensions_enable(c->gl_ctx, "GL_HP_occlusion_test");
- gl_extensions_enable(c->gl_ctx, "GL_ARB_texture_cube_map");
- gl_extensions_enable(c->gl_ctx, "GL_EXT_texture_env_combine");
- gl_extensions_enable(c->gl_ctx, "GL_EXT_texture_env_dot3");
+ _mesa_enable_sw_extensions(ctx);
+ _mesa_enable_1_3_extensions(ctx);
if (CHECK_BYTE_ORDER(v)) {
c->swapbytes = GL_FALSE;
@@ -1658,14 +1649,26 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
c->display = v->display;
c->pixelformat = v->dithered_pf; /* Dithering is enabled by default */
- c->gl_ctx->Driver.UpdateState = xmesa_update_state;
+ ctx->Driver.UpdateState = xmesa_update_state;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ xmesa_register_swrast_functions( ctx );
+
+ /* Set up some constant pointers:
+ */
+ xmesa_init_pointers( ctx );
-#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
- c->driContextPriv = driContextPriv;
-#endif
- /* Run the config file */
- gl_context_initialize( c->gl_ctx );
+ /* Run the config file
+ */
+ _mesa_read_config_file( ctx );
+
return c;
}
@@ -1679,13 +1682,20 @@ void XMesaDestroyContext( XMesaContext c )
if (c->xm_buffer && c->xm_buffer->FXctx)
fxMesaDestroyContext(c->xm_buffer->FXctx);
#endif
- if (c->gl_ctx)
- gl_destroy_context( c->gl_ctx );
-
- /* Disassociate old buffer with this context */
- if (c->xm_buffer)
- c->xm_buffer->xm_context = NULL;
+ if (c->gl_ctx) {
+ _swsetup_DestroyContext( c->gl_ctx );
+ _swrast_DestroyContext( c->gl_ctx );
+ _tnl_DestroyContext( c->gl_ctx );
+ _ac_DestroyContext( c->gl_ctx );
+ _mesa_destroy_context( c->gl_ctx );
+ }
+ /*
+ * XXX This code should really go away because the ancilliary data
+ * associated with a window/pixmap should not go away just because
+ * a context is destroyed.
+ */
+#if 0
/* Destroy any buffers which are using this context. If we don't
* we may have dangling references. Hmm, maybe we should just
* set the buffer's context pointer to NULL instead of deleting it?
@@ -1707,6 +1717,7 @@ void XMesaDestroyContext( XMesaContext c )
}
}
}
+#endif
FREE( c );
}
@@ -1780,7 +1791,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
#endif
/* determine back buffer implementation */
- if (v->gl_visual->DBflag) {
+ if (v->mesa_visual.doubleBufferMode) {
if (v->ximage_flag) {
b->db_state = BACK_XIMAGE;
}
@@ -1792,19 +1803,15 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
b->db_state = 0;
}
- b->gl_buffer = gl_create_framebuffer( v->gl_visual,
- v->gl_visual->DepthBits > 0,
- v->gl_visual->StencilBits > 0,
- v->gl_visual->AccumRedBits > 0,
- v->gl_visual->AlphaBits > 0 );
- if (!b->gl_buffer) {
- free_xmesa_buffer(client, b);
- return NULL;
- }
+ _mesa_initialize_framebuffer(&b->mesa_buffer,
+ &v->mesa_visual,
+ v->mesa_visual.depthBits > 0,
+ v->mesa_visual.stencilBits > 0,
+ v->mesa_visual.accumRedBits > 0,
+ v->mesa_visual.alphaBits > 0 );
- if (!initialize_visual_and_buffer( client, v, b, v->gl_visual->RGBAflag,
+ if (!initialize_visual_and_buffer( client, v, b, v->mesa_visual.rgbMode,
(XMesaDrawable)w, b->cmap )) {
- gl_destroy_framebuffer( b->gl_buffer );
free_xmesa_buffer(client, b);
return NULL;
}
@@ -1816,22 +1823,22 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
int attribs[100];
int numAttribs = 0;
int hw;
- if (v->gl_visual->DepthBits > 0) {
+ if (v->mesa_visual.depthBits > 0) {
attribs[numAttribs++] = FXMESA_DEPTH_SIZE;
attribs[numAttribs++] = 1;
}
- if (v->gl_visual->DBflag) {
+ if (v->mesa_visual.doubleBufferMode) {
attribs[numAttribs++] = FXMESA_DOUBLEBUFFER;
}
- if (v->gl_visual->AccumRedBits > 0) {
+ if (v->mesa_visual.accumRedBits > 0) {
attribs[numAttribs++] = FXMESA_ACCUM_SIZE;
- attribs[numAttribs++] = v->gl_visual->AccumRedBits;
+ attribs[numAttribs++] = v->mesa_visual.accumRedBits;
}
- if (v->gl_visual->StencilBits > 0) {
+ if (v->mesa_visual.stencilBits > 0) {
attribs[numAttribs++] = FXMESA_STENCIL_SIZE;
- attribs[numAttribs++] = v->gl_visual->StencilBits;
+ attribs[numAttribs++] = v->mesa_visual.stencilBits;
}
- if (v->gl_visual->AlphaBits > 0) {
+ if (v->mesa_visual.alphaBits > 0) {
attribs[numAttribs++] = FXMESA_ALPHA_SIZE;
attribs[numAttribs++] = 1;
}
@@ -1876,10 +1883,6 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
}
#endif
-#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
- b->driDrawPriv = driDrawPriv;
-#endif
-
return b;
}
@@ -1922,7 +1925,7 @@ XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
b->cmap = cmap;
/* determine back buffer implementation */
- if (v->gl_visual->DBflag) {
+ if (v->mesa_visual.doubleBufferMode) {
if (v->ximage_flag) {
b->db_state = BACK_XIMAGE;
}
@@ -1934,31 +1937,74 @@ XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
b->db_state = 0;
}
- b->gl_buffer = gl_create_framebuffer( v->gl_visual,
- v->gl_visual->DepthBits > 0,
- v->gl_visual->StencilBits > 0,
- v->gl_visual->AccumRedBits +
- v->gl_visual->AccumGreenBits +
- v->gl_visual->AccumBlueBits > 0,
- v->gl_visual->AlphaBits > 0 );
- if (!b->gl_buffer) {
+ _mesa_initialize_framebuffer(&b->mesa_buffer,
+ &v->mesa_visual,
+ v->mesa_visual.depthBits > 0,
+ v->mesa_visual.stencilBits > 0,
+ v->mesa_visual.accumRedBits +
+ v->mesa_visual.accumGreenBits +
+ v->mesa_visual.accumBlueBits > 0,
+ v->mesa_visual.alphaBits > 0 );
+
+ if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode,
+ (XMesaDrawable)p, cmap)) {
free_xmesa_buffer(client, b);
return NULL;
}
- if (!initialize_visual_and_buffer(client, v, b, v->gl_visual->RGBAflag,
- (XMesaDrawable)p, cmap)) {
- gl_destroy_framebuffer( b->gl_buffer );
- free_xmesa_buffer(client, b);
+ return b;
+}
+
+
+
+#if 0 /* not done */
+XMesaBuffer XMesaCreatePBuffer( XMesaVisual v, XMesaColormap cmap,
+ unsigned int width, unsigned int height )
+{
+ int client = 0;
+ XMesaBuffer b = alloc_xmesa_buffer();
+ if (!b) {
return NULL;
}
-#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
- b->driDrawPriv = driDrawPriv;
-#endif
+ b->xm_context = NULL; /* Associate no context with this buffer */
+
+ b->xm_visual = v;
+ b->pbuffer_flag = GL_TRUE;
+ b->display = v->display;
+ b->cmap = cmap;
+
+ /* determine back buffer implementation */
+ if (v->mesa_visual.doubleBufferMode) {
+ if (v->ximage_flag) {
+ b->db_state = BACK_XIMAGE;
+ }
+ else {
+ b->db_state = BACK_PIXMAP;
+ }
+ }
+ else {
+ b->db_state = 0;
+ }
+
+ _mesa_initialize_framebuffer(&b->mesa_buffer,
+ &v->mesa_visual,
+ v->mesa_visual.depthBits > 0,
+ v->mesa_visual.stencilBits > 0,
+ v->mesa_visual.accumRedBits +
+ v->mesa_visual.accumGreenBits +
+ v->mesa_visual.accumBlueBits > 0,
+ v->mesa_visual.alphaBits > 0 );
+
+ if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode,
+ 0, cmap)) {
+ free_xmesa_buffer(client, b);
+ return NULL;
+ }
return b;
}
+#endif
@@ -1974,8 +2020,7 @@ void XMesaDestroyBuffer( XMesaBuffer b )
client = CLIENT_ID(b->frontbuffer->id);
#endif
- if (b->gc1) XMesaFreeGC( b->xm_visual->display, b->gc1 );
- if (b->gc2) XMesaFreeGC( b->xm_visual->display, b->gc2 );
+ if (b->gc) XMesaFreeGC( b->xm_visual->display, b->gc );
if (b->cleargc) XMesaFreeGC( b->xm_visual->display, b->cleargc );
if (b->backimage) {
@@ -2004,9 +2049,8 @@ void XMesaDestroyBuffer( XMesaBuffer b )
}
if (b->xm_context)
- b->xm_context->xm_buffer = NULL;
+ b->xm_context->xm_buffer = NULL;
- gl_destroy_framebuffer( b->gl_buffer );
free_xmesa_buffer(client, b);
}
@@ -2053,7 +2097,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
return GL_TRUE;
}
#endif
- if (c->gl_ctx == gl_get_current_context()
+ if (c->gl_ctx == _mesa_get_current_context()
&& c->xm_buffer == drawBuffer
&& c->xm_read_buffer == readBuffer
&& c->xm_buffer->wasCurrent) {
@@ -2075,7 +2119,9 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
c->xm_read_buffer = readBuffer;
c->use_read_buffer = (drawBuffer != readBuffer);
- gl_make_current2(c->gl_ctx, drawBuffer->gl_buffer, readBuffer->gl_buffer);
+ _mesa_make_current2(c->gl_ctx,
+ &drawBuffer->mesa_buffer,
+ &readBuffer->mesa_buffer);
if (c->gl_ctx->Viewport.Width == 0) {
/* initialize viewport to window size */
@@ -2084,14 +2130,11 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
c->gl_ctx->Scissor.Height = drawBuffer->height;
}
- if (c->xm_visual->gl_visual->RGBAflag) {
+ if (c->xm_visual->mesa_visual.rgbMode) {
/*
* Must recompute and set these pixel values because colormap
* can be different for different windows.
*/
- c->pixel = xmesa_color_to_pixel( c, c->red, c->green,
- c->blue, c->alpha, c->pixelformat );
- XMesaSetForeground( c->display, c->xm_buffer->gc1, c->pixel );
c->clearpixel = xmesa_color_to_pixel( c,
c->clearcolor[0],
c->clearcolor[1],
@@ -2106,7 +2149,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
}
else {
/* Detach */
- gl_make_current2( NULL, NULL, NULL );
+ _mesa_make_current2( NULL, NULL, NULL );
}
return GL_TRUE;
}
@@ -2165,12 +2208,12 @@ XMesaBuffer XMesaGetCurrentReadBuffer( void )
GLboolean XMesaForceCurrent(XMesaContext c)
{
if (c) {
- if (c->gl_ctx != gl_get_current_context()) {
- gl_make_current(c->gl_ctx, c->xm_buffer->gl_buffer);
+ if (c->gl_ctx != _mesa_get_current_context()) {
+ _mesa_make_current(c->gl_ctx, &c->xm_buffer->mesa_buffer);
}
}
else {
- gl_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL);
}
return GL_TRUE;
}
@@ -2179,7 +2222,7 @@ GLboolean XMesaForceCurrent(XMesaContext c)
GLboolean XMesaLoseCurrent(XMesaContext c)
{
(void) c;
- gl_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL);
return GL_TRUE;
}
@@ -2237,7 +2280,8 @@ GLboolean XMesaSetFXmode( GLint mode )
static void FXgetImage( XMesaBuffer b )
{
static unsigned short pixbuf[MAX_WIDTH];
- int x, y;
+ GLuint x, y;
+ int xpos, ypos;
XMesaWindow root;
unsigned int bw, depth, width, height;
XMesaContext xmesa = (XMesaContext) b->xm_context->gl_ctx->DriverCtx;
@@ -2252,7 +2296,7 @@ static void FXgetImage( XMesaBuffer b )
depth = b->frontbuffer->depth;
#else
XGetGeometry( xmesa->xm_visual->display, b->frontbuffer,
- &root, &x, &y, &width, &height, &bw, &depth);
+ &root, &xpos, &ypos, &width, &height, &bw, &depth);
#endif
if (b->width != width || b->height != height) {
b->width = MIN2((int)width, xmesa->xm_buffer->FXctx->width);
@@ -2360,16 +2404,12 @@ void XMesaSwapBuffers( XMesaBuffer b )
else
#endif
{
-#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
- XMesaDriSwapBuffers( b );
-#else
/*_glthread_LOCK_MUTEX(_xmesa_lock);*/
XMesaPutImage( b->xm_visual->display, b->frontbuffer,
b->cleargc,
b->backimage, 0, 0,
0, 0, b->width, b->height );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
-#endif
}
}
else {
@@ -2385,7 +2425,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
}
-#if !defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
+#if !defined(XFree86Server)
XSync( b->xm_visual->display, False );
#endif
}
@@ -2488,7 +2528,7 @@ GLboolean XMesaGetBackBuffer( XMesaBuffer b,
GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
GLint *bytesPerValue, void **buffer )
{
- if ((!b->gl_buffer) || (!b->gl_buffer->DepthBuffer)) {
+ if (!b->mesa_buffer.DepthBuffer) {
*width = 0;
*height = 0;
*bytesPerValue = 0;
@@ -2496,10 +2536,10 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
return GL_FALSE;
}
else {
- *width = b->gl_buffer->Width;
- *height = b->gl_buffer->Height;
+ *width = b->mesa_buffer.Width;
+ *height = b->mesa_buffer.Height;
*bytesPerValue = sizeof(GLdepth);
- *buffer = b->gl_buffer->DepthBuffer;
+ *buffer = b->mesa_buffer.DepthBuffer;
return GL_TRUE;
}
}
@@ -2522,7 +2562,7 @@ const char *XMesaGetString( XMesaContext c, int name )
{
(void) c;
if (name==XMESA_VERSION) {
- return "3.4.2";
+ return "3.5";
}
else if (name==XMESA_EXTENSIONS) {
return "";
@@ -2630,7 +2670,9 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
return p;
}
default:
- gl_problem(NULL, "Bad pixel format in XMesaDitherColor");
+ _mesa_problem(NULL, "Bad pixel format in XMesaDitherColor");
}
return 0;
}
+
+
diff --git a/xc/extras/Mesa/src/X/xm_dd.c b/xc/extras/Mesa/src/X/xm_dd.c
new file mode 100644
index 000000000..b60c1a0e6
--- /dev/null
+++ b/xc/extras/Mesa/src/X/xm_dd.c
@@ -0,0 +1,1044 @@
+/* $Id: xm_dd.c,v 1.2 2002/02/14 01:59:36 dawes Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * 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
+ * BRIAN PAUL 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 "glxheader.h"
+#include "context.h"
+#include "depth.h"
+#include "drawpix.h"
+#include "extensions.h"
+#include "macros.h"
+#include "mem.h"
+#include "mtypes.h"
+#include "state.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "xmesaP.h"
+#include "array_cache/acache.h"
+#include "swrast/s_context.h"
+#include "swrast/swrast.h"
+#include "swrast/s_alphabuf.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+
+/*
+ * Return the size (width,height of the current color buffer.
+ * This function should be called by the glViewport function because
+ * glViewport is often called when the window gets resized. We need to
+ * update some X/Mesa stuff when that happens.
+ * Output: width - width of buffer in pixels.
+ * height - height of buffer in pixels.
+ */
+static void
+get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ unsigned int winwidth, winheight;
+#ifndef XFree86Server
+ Window root;
+ int winx, winy;
+ unsigned int bw, d;
+
+ _glthread_LOCK_MUTEX(_xmesa_lock);
+ XGetGeometry( xmesa->display, xmesa->xm_buffer->frontbuffer, &root,
+ &winx, &winy, &winwidth, &winheight, &bw, &d );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
+#else
+
+ winwidth = xmesa->xm_buffer->frontbuffer->width;
+ winheight = xmesa->xm_buffer->frontbuffer->height;
+#endif
+
+ *width = winwidth;
+ *height = winheight;
+
+ if ( winwidth!=xmesa->xm_buffer->width
+ || winheight!=xmesa->xm_buffer->height) {
+ xmesa->xm_buffer->width = winwidth;
+ xmesa->xm_buffer->height = winheight;
+ xmesa_alloc_back_buffer( xmesa->xm_buffer );
+ }
+
+ /* Needed by FLIP macro */
+ xmesa->xm_buffer->bottom = (int) winheight - 1;
+
+ if (xmesa->xm_buffer->backimage) {
+ /* Needed by PIXELADDR1 macro */
+ xmesa->xm_buffer->ximage_width1
+ = xmesa->xm_buffer->backimage->bytes_per_line;
+ xmesa->xm_buffer->ximage_origin1
+ = (GLubyte *) xmesa->xm_buffer->backimage->data
+ + xmesa->xm_buffer->ximage_width1 * (winheight-1);
+
+ /* Needed by PIXELADDR2 macro */
+ xmesa->xm_buffer->ximage_width2
+ = xmesa->xm_buffer->backimage->bytes_per_line / 2;
+ xmesa->xm_buffer->ximage_origin2
+ = (GLushort *) xmesa->xm_buffer->backimage->data
+ + xmesa->xm_buffer->ximage_width2 * (winheight-1);
+
+ /* Needed by PIXELADDR3 macro */
+ xmesa->xm_buffer->ximage_width3
+ = xmesa->xm_buffer->backimage->bytes_per_line;
+ xmesa->xm_buffer->ximage_origin3
+ = (GLubyte *) xmesa->xm_buffer->backimage->data
+ + xmesa->xm_buffer->ximage_width3 * (winheight-1);
+
+ /* Needed by PIXELADDR4 macro */
+ xmesa->xm_buffer->ximage_width4 = xmesa->xm_buffer->backimage->width;
+ xmesa->xm_buffer->ximage_origin4
+ = (GLuint *) xmesa->xm_buffer->backimage->data
+ + xmesa->xm_buffer->ximage_width4 * (winheight-1);
+ }
+}
+
+
+static void
+finish( GLcontext *ctx )
+{
+#ifdef XFree86Server
+ /* NOT_NEEDED */
+#else
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ if (xmesa) {
+ _glthread_LOCK_MUTEX(_xmesa_lock);
+ XSync( xmesa->display, False );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ }
+#endif
+}
+
+
+static void
+flush( GLcontext *ctx )
+{
+#ifdef XFree86Server
+ /* NOT_NEEDED */
+#else
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ if (xmesa) {
+ _glthread_LOCK_MUTEX(_xmesa_lock);
+ XFlush( xmesa->display );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ }
+#endif
+}
+
+
+
+
+static GLboolean
+set_draw_buffer( GLcontext *ctx, GLenum mode )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ if (mode == GL_FRONT_LEFT) {
+ /* write to front buffer */
+ xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
+ xmesa_update_span_funcs(ctx);
+ return GL_TRUE;
+ }
+ else if (mode==GL_BACK_LEFT && xmesa->xm_buffer->db_state) {
+ /* write to back buffer */
+ if (xmesa->xm_buffer->backpixmap) {
+ xmesa->xm_buffer->buffer =
+ (XMesaDrawable)xmesa->xm_buffer->backpixmap;
+ }
+ else if (xmesa->xm_buffer->backimage) {
+ xmesa->xm_buffer->buffer = None;
+ }
+ else {
+ /* just in case there wasn't enough memory for back buffer */
+ xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
+ }
+ xmesa_update_span_funcs(ctx);
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+}
+
+
+void
+xmesa_set_read_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode )
+{
+ XMesaBuffer target;
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+
+ if (buffer == ctx->DrawBuffer) {
+ target = xmesa->xm_buffer;
+ xmesa->use_read_buffer = GL_FALSE;
+ }
+ else {
+ ASSERT(buffer == ctx->ReadBuffer);
+ target = xmesa->xm_read_buffer;
+ xmesa->use_read_buffer = GL_TRUE;
+ }
+
+ if (mode == GL_FRONT_LEFT) {
+ target->buffer = target->frontbuffer;
+ xmesa_update_span_funcs(ctx);
+ }
+ else if (mode==GL_BACK_LEFT && xmesa->xm_read_buffer->db_state) {
+ if (target->backpixmap) {
+ target->buffer = (XMesaDrawable)xmesa->xm_buffer->backpixmap;
+ }
+ else if (target->backimage) {
+ target->buffer = None;
+ }
+ else {
+ /* just in case there wasn't enough memory for back buffer */
+ target->buffer = target->frontbuffer;
+ }
+ xmesa_update_span_funcs(ctx);
+ }
+ else {
+ _mesa_problem(ctx, "invalid buffer in set_read_buffer() in xmesa2.c");
+ }
+}
+
+
+
+static void
+clear_index( GLcontext *ctx, GLuint index )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ xmesa->clearpixel = (unsigned long) index;
+ XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc,
+ (unsigned long) index );
+}
+
+
+static void
+clear_color( GLcontext *ctx, const GLchan color[4] )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ xmesa->clearcolor[0] = color[0];
+ xmesa->clearcolor[1] = color[1];
+ xmesa->clearcolor[2] = color[2];
+ xmesa->clearcolor[3] = color[3];
+ xmesa->clearpixel = xmesa_color_to_pixel( xmesa, color[0], color[1],
+ color[2], color[3],
+ xmesa->xm_visual->undithered_pf );
+ _glthread_LOCK_MUTEX(_xmesa_lock);
+ XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc,
+ xmesa->clearpixel );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
+}
+
+
+
+/* Set index mask ala glIndexMask */
+static void
+index_mask( GLcontext *ctx, GLuint mask )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ if (xmesa->xm_buffer->buffer != XIMAGE) {
+ unsigned long m;
+ if (mask==0xffffffff) {
+ m = ((unsigned long)~0L);
+ }
+ else {
+ m = (unsigned long) mask;
+ }
+ XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m );
+ }
+}
+
+
+/* Implements glColorMask() */
+static void
+color_mask(GLcontext *ctx,
+ GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask)
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ int xclass = GET_VISUAL_CLASS(xmesa->xm_visual);
+ (void) amask;
+
+ if (xmesa->xm_buffer->buffer != XIMAGE
+ && (xclass == TrueColor || xclass == DirectColor)) {
+ unsigned long m;
+ if (rmask && gmask && bmask) {
+ m = ((unsigned long)~0L);
+ }
+ else {
+ m = 0;
+ if (rmask) m |= GET_REDMASK(xmesa->xm_visual);
+ if (gmask) m |= GET_GREENMASK(xmesa->xm_visual);
+ if (bmask) m |= GET_BLUEMASK(xmesa->xm_visual);
+ }
+ XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m );
+ }
+}
+
+
+
+/**********************************************************************/
+/*** glClear implementations ***/
+/**********************************************************************/
+
+
+static void
+clear_front_pixmap( GLcontext *ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ if (all) {
+ XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->frontbuffer,
+ xmesa->xm_buffer->cleargc,
+ 0, 0,
+ xmesa->xm_buffer->width+1,
+ xmesa->xm_buffer->height+1 );
+ }
+ else {
+ XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->frontbuffer,
+ xmesa->xm_buffer->cleargc,
+ x, xmesa->xm_buffer->height - y - height,
+ width, height );
+ }
+}
+
+
+static void
+clear_back_pixmap( GLcontext *ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ if (all) {
+ XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->backpixmap,
+ xmesa->xm_buffer->cleargc,
+ 0, 0,
+ xmesa->xm_buffer->width+1,
+ xmesa->xm_buffer->height+1 );
+ }
+ else {
+ XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->backpixmap,
+ xmesa->xm_buffer->cleargc,
+ x, xmesa->xm_buffer->height - y - height,
+ width, height );
+ }
+}
+
+
+static void
+clear_8bit_ximage( GLcontext *ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ if (all) {
+ size_t n = xmesa->xm_buffer->backimage->bytes_per_line
+ * xmesa->xm_buffer->backimage->height;
+ MEMSET( xmesa->xm_buffer->backimage->data, xmesa->clearpixel, n );
+ }
+ else {
+ GLint i;
+ for (i=0;i<height;i++) {
+ GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y+i );
+ MEMSET( ptr, xmesa->clearpixel, width );
+ }
+ }
+}
+
+
+static void
+clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ if (all) {
+ GLint i, c16 = (xmesa->xm_buffer->backimage->bytes_per_line>>4)<<4;
+ GLubyte *ptr = (GLubyte *)xmesa->xm_buffer->backimage->data;
+ for (i=0; i<xmesa->xm_buffer->backimage->height; i++) {
+ GLint j;
+ GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
+ if (i&1) {
+ sptr += 16;
+ }
+ for (j=0; j<c16; j+=16) {
+ ptr[0] = sptr[0];
+ ptr[1] = sptr[1];
+ ptr[2] = sptr[2];
+ ptr[3] = sptr[3];
+ ptr[4] = sptr[4];
+ ptr[5] = sptr[5];
+ ptr[6] = sptr[6];
+ ptr[7] = sptr[7];
+ ptr[8] = sptr[8];
+ ptr[9] = sptr[9];
+ ptr[10] = sptr[10];
+ ptr[11] = sptr[11];
+ ptr[12] = sptr[12];
+ ptr[13] = sptr[13];
+ ptr[14] = sptr[14];
+ ptr[15] = sptr[15];
+ ptr += 16;
+ }
+ for (; j<xmesa->xm_buffer->backimage->bytes_per_line; j++) {
+ *ptr = sptr[j&15];
+ ptr++;
+ }
+ }
+ }
+ else {
+ GLint i;
+ for (i=y; i<y+height; i++) {
+ GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, i );
+ int j;
+ GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
+ if (i&1) {
+ sptr += 16;
+ }
+ for (j=x; j<x+width; j++) {
+ *ptr = sptr[j&15];
+ ptr++;
+ }
+ }
+ }
+}
+
+
+static void
+clear_16bit_ximage( GLcontext *ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ register GLuint pixel = (GLuint) xmesa->clearpixel;
+ if (xmesa->swapbytes) {
+ pixel = ((pixel >> 8) & 0x00ff) | ((pixel << 8) & 0xff00);
+ }
+ if (all) {
+ register GLuint n;
+ register GLuint *ptr4 = (GLuint *) xmesa->xm_buffer->backimage->data;
+ if ((pixel & 0xff) == ((pixel >> 8) & 0xff)) {
+ /* low and high bytes are equal so use memset() */
+ n = xmesa->xm_buffer->backimage->bytes_per_line
+ * xmesa->xm_buffer->height;
+ MEMSET( ptr4, pixel & 0xff, n );
+ }
+ else {
+ pixel = pixel | (pixel<<16);
+ n = xmesa->xm_buffer->backimage->bytes_per_line
+ * xmesa->xm_buffer->height / 4;
+ do {
+ *ptr4++ = pixel;
+ n--;
+ } while (n!=0);
+
+ if ((xmesa->xm_buffer->backimage->bytes_per_line *
+ xmesa->xm_buffer->height) & 0x2)
+ *(GLushort *)ptr4 = pixel & 0xffff;
+ }
+ }
+ else {
+ register int i, j;
+ for (j=0;j<height;j++) {
+ register GLushort *ptr2 = PIXELADDR2( xmesa->xm_buffer, x, y+j );
+ for (i=0;i<width;i++) {
+ *ptr2++ = pixel;
+ }
+ }
+ }
+}
+
+
+/* Optimized code provided by Nozomi Ytow <noz@xfree86.org> */
+static void
+clear_24bit_ximage( GLcontext *ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte r = xmesa->clearcolor[0];
+ const GLubyte g = xmesa->clearcolor[1];
+ const GLubyte b = xmesa->clearcolor[2];
+ register GLuint clearPixel;
+ if (xmesa->swapbytes) {
+ clearPixel = (b << 16) | (g << 8) | r;
+ }
+ else {
+ clearPixel = (r << 16) | (g << 8) | b;
+ }
+
+ if (all) {
+ if (r==g && g==b) {
+ /* same value for all three components (gray) */
+ const GLint w3 = xmesa->xm_buffer->width * 3;
+ const GLint h = xmesa->xm_buffer->height;
+ GLint i;
+ for (i = 0; i < h; i++) {
+ bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i);
+ MEMSET(ptr3, r, w3);
+ }
+ }
+ else {
+ /* the usual case */
+ const GLint w = xmesa->xm_buffer->width;
+ const GLint h = xmesa->xm_buffer->height;
+ GLint i, j;
+ for (i = 0; i < h; i++) {
+ bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i);
+ for (j = 0; j < w; j++) {
+ ptr3->r = r;
+ ptr3->g = g;
+ ptr3->b = b;
+ ptr3++;
+ }
+ }
+#if 0 /* this code doesn't work for all window widths */
+ register GLuint *ptr4 = (GLuint *) ptr3;
+ register GLuint px;
+ GLuint pixel4[3];
+ register GLuint *p = pixel4;
+ pixel4[0] = clearPixel | (clearPixel << 24);
+ pixel4[1] = (clearPixel << 16) | (clearPixel >> 8);
+ pixel4[2] = (clearPixel << 8) | (clearPixel >> 16);
+ switch (3 & (int)(ptr3 - (bgr_t*) ptr4)){
+ case 0:
+ break;
+ case 1:
+ px = *ptr4 & 0x00ffffff;
+ px |= pixel4[0] & 0xff000000;
+ *ptr4++ = px;
+ px = *ptr4 & 0xffff0000;
+ px |= pixel4[2] & 0x0000ffff;
+ *ptr4 = px;
+ if (0 == --n)
+ break;
+ case 2:
+ px = *ptr4 & 0x0000fffff;
+ px |= pixel4[1] & 0xffff0000;
+ *ptr4++ = px;
+ px = *ptr4 & 0xffffff00;
+ px |= pixel4[2] & 0x000000ff;
+ *ptr4 = px;
+ if (0 == --n)
+ break;
+ case 3:
+ px = *ptr4 & 0x000000ff;
+ px |= pixel4[2] & 0xffffff00;
+ *ptr4++ = px;
+ --n;
+ break;
+ }
+ while (n > 3) {
+ p = pixel4;
+ *ptr4++ = *p++;
+ *ptr4++ = *p++;
+ *ptr4++ = *p++;
+ n -= 4;
+ }
+ switch (n) {
+ case 3:
+ p = pixel4;
+ *ptr4++ = *p++;
+ *ptr4++ = *p++;
+ px = *ptr4 & 0xffffff00;
+ px |= clearPixel & 0xff;
+ *ptr4 = px;
+ break;
+ case 2:
+ p = pixel4;
+ *ptr4++ = *p++;
+ px = *ptr4 & 0xffff0000;
+ px |= *p & 0xffff;
+ *ptr4 = px;
+ break;
+ case 1:
+ px = *ptr4 & 0xff000000;
+ px |= *p & 0xffffff;
+ *ptr4 = px;
+ break;
+ case 0:
+ break;
+ }
+#endif
+ }
+ }
+ else {
+ /* only clear subrect of color buffer */
+ if (r==g && g==b) {
+ /* same value for all three components (gray) */
+ GLint j;
+ for (j=0;j<height;j++) {
+ bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j );
+ MEMSET(ptr3, r, 3 * width);
+ }
+ }
+ else {
+ /* non-gray clear color */
+ GLint i, j;
+ for (j = 0; j < height; j++) {
+ bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j );
+ for (i = 0; i < width; i++) {
+ ptr3->r = r;
+ ptr3->g = g;
+ ptr3->b = b;
+ ptr3++;
+ }
+ }
+#if 0 /* this code might not always (seems ptr3 always == ptr4) */
+ GLint j;
+ GLuint pixel4[3];
+ pixel4[0] = clearPixel | (clearPixel << 24);
+ pixel4[1] = (clearPixel << 16) | (clearPixel >> 8);
+ pixel4[2] = (clearPixel << 8) | (clearPixel >> 16);
+ for (j=0;j<height;j++) {
+ bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j );
+ register GLuint *ptr4 = (GLuint *)ptr3;
+ register GLuint *p, px;
+ GLuint w = width;
+ switch (3 & (int)(ptr3 - (bgr_t*) ptr4)){
+ case 0:
+ break;
+ case 1:
+ px = *ptr4 & 0x00ffffff;
+ px |= pixel4[0] & 0xff000000;
+ *ptr4++ = px;
+ px = *ptr4 & 0xffff0000;
+ px |= pixel4[2] & 0x0000ffff;
+ *ptr4 = px;
+ if (0 == --w)
+ break;
+ case 2:
+ px = *ptr4 & 0x0000fffff;
+ px |= pixel4[1] & 0xffff0000;
+ *ptr4++ = px;
+ px = *ptr4 & 0xffffff00;
+ px |= pixel4[2] & 0x000000ff;
+ *ptr4 = px;
+ if (0 == --w)
+ break;
+ case 3:
+ px = *ptr4 & 0x000000ff;
+ px |= pixel4[2] & 0xffffff00;
+ *ptr4++ = px;
+ --w;
+ break;
+ }
+ while (w > 3){
+ p = pixel4;
+ *ptr4++ = *p++;
+ *ptr4++ = *p++;
+ *ptr4++ = *p++;
+ w -= 4;
+ }
+ switch (w) {
+ case 3:
+ p = pixel4;
+ *ptr4++ = *p++;
+ *ptr4++ = *p++;
+ px = *ptr4 & 0xffffff00;
+ px |= *p & 0xff;
+ *ptr4 = px;
+ break;
+ case 2:
+ p = pixel4;
+ *ptr4++ = *p++;
+ px = *ptr4 & 0xffff0000;
+ px |= *p & 0xffff;
+ *ptr4 = px;
+ break;
+ case 1:
+ px = *ptr4 & 0xff000000;
+ px |= pixel4[0] & 0xffffff;
+ *ptr4 = px;
+ break;
+ case 0:
+ break;
+ }
+ }
+#endif
+ }
+ }
+}
+
+
+static void
+clear_32bit_ximage( GLcontext *ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ register GLuint pixel = (GLuint) xmesa->clearpixel;
+ if (xmesa->swapbytes) {
+ pixel = ((pixel >> 24) & 0x000000ff)
+ | ((pixel >> 8) & 0x0000ff00)
+ | ((pixel << 8) & 0x00ff0000)
+ | ((pixel << 24) & 0xff000000);
+ }
+ if (all) {
+ register GLint n = xmesa->xm_buffer->width * xmesa->xm_buffer->height;
+ register GLuint *ptr4 = (GLuint *) xmesa->xm_buffer->backimage->data;
+ if (pixel==0) {
+ MEMSET( ptr4, pixel, 4*n );
+ }
+ else {
+ do {
+ *ptr4++ = pixel;
+ n--;
+ } while (n!=0);
+ }
+ }
+ else {
+ register int i, j;
+ for (j=0;j<height;j++) {
+ register GLuint *ptr4 = PIXELADDR4( xmesa->xm_buffer, x, y+j );
+ for (i=0;i<width;i++) {
+ *ptr4++ = pixel;
+ }
+ }
+ }
+}
+
+
+static void
+clear_nbit_ximage( GLcontext *ctx, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+ if (all) {
+ register int i, j;
+ width = xmesa->xm_buffer->width;
+ height = xmesa->xm_buffer->height;
+ for (j=0;j<height;j++) {
+ for (i=0;i<width;i++) {
+ XMesaPutPixel( img, i, j, xmesa->clearpixel );
+ }
+ }
+ }
+ else {
+ /* TODO: optimize this */
+ register int i, j;
+ y = FLIP(xmesa->xm_buffer, y);
+ for (j=0;j<height;j++) {
+ for (i=0;i<width;i++) {
+ XMesaPutPixel( img, x+i, y-j, xmesa->clearpixel );
+ }
+ }
+ }
+}
+
+
+
+static void
+clear_buffers( GLcontext *ctx, GLbitfield mask,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
+
+ if ((mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) &&
+ xmesa->xm_buffer->mesa_buffer.UseSoftwareAlphaBuffers &&
+ ctx->Color.ColorMask[ACOMP]) {
+ _mesa_clear_alpha_buffers(ctx);
+ }
+
+ /* we can't handle color or index masking */
+ if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
+ if (mask & DD_FRONT_LEFT_BIT) {
+ ASSERT(xmesa->xm_buffer->front_clear_func);
+ (*xmesa->xm_buffer->front_clear_func)( ctx, all, x, y, width, height );
+ mask &= ~DD_FRONT_LEFT_BIT;
+ }
+ if (mask & DD_BACK_LEFT_BIT) {
+ ASSERT(xmesa->xm_buffer->back_clear_func);
+ (*xmesa->xm_buffer->back_clear_func)( ctx, all, x, y, width, height );
+ mask &= ~DD_BACK_LEFT_BIT;
+ }
+ }
+
+ if (mask)
+ _swrast_Clear( ctx, mask, all, x, y, width, height );
+}
+
+
+static void
+resize_buffers( GLcontext *ctx )
+{
+ _swrast_alloc_buffers( ctx );
+}
+
+#if 0
+/*
+ * This function implements glDrawPixels() with an XPutImage call when
+ * drawing to the front buffer (X Window drawable).
+ * The image format must be GL_BGRA to match the PF_8R8G8B pixel format.
+ * XXX top/bottom edge clipping is broken!
+ */
+static GLboolean
+drawpixels_8R8G8B( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xmesa->xm_buffer->buffer;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+ assert(dpy);
+ assert(buffer);
+ assert(gc);
+
+ /* XXX also check for pixel scale/bias/lookup/zooming! */
+ if (format == GL_BGRA && type == GL_UNSIGNED_BYTE) {
+ int dstX = x;
+ int dstY = y;
+ int w = width;
+ int h = height;
+ int srcX = unpack->SkipPixels;
+ int srcY = unpack->SkipRows;
+ if (_mesa_clip_pixelrect(ctx, &dstX, &dstY, &w, &h, &srcX, &srcY)) {
+ XMesaImage ximage;
+ MEMSET(&ximage, 0, sizeof(XMesaImage));
+ ximage.width = width;
+ ximage.height = height;
+ ximage.format = ZPixmap;
+ ximage.data = (char *) pixels + (height - 1) * width * 4;
+ ximage.byte_order = LSBFirst;
+ ximage.bitmap_unit = 32;
+ ximage.bitmap_bit_order = LSBFirst;
+ ximage.bitmap_pad = 32;
+ ximage.depth = 24;
+ ximage.bytes_per_line = -width * 4;
+ ximage.bits_per_pixel = 32;
+ ximage.red_mask = 0xff0000;
+ ximage.green_mask = 0x00ff00;
+ ximage.blue_mask = 0x0000ff;
+ dstY = FLIP(xmesa->xm_buffer,dstY) - height + 1;
+ XPutImage(dpy, buffer, gc, &ximage, srcX, srcY, dstX, dstY, w, h);
+ return GL_TRUE;
+ }
+ }
+ return GL_FALSE;
+}
+#endif
+
+
+
+static const GLubyte *
+get_string( GLcontext *ctx, GLenum name )
+{
+ (void) ctx;
+ switch (name) {
+ case GL_RENDERER:
+#ifdef XFree86Server
+ return (const GLubyte *) "Mesa GLX Indirect";
+#else
+ return (const GLubyte *) "Mesa X11";
+#endif
+ case GL_VENDOR:
+#ifdef XFree86Server
+ return (const GLubyte *) "Mesa project: www.mesa3d.org";
+#else
+ return NULL;
+#endif
+ default:
+ return NULL;
+ }
+}
+
+
+static void
+enable( GLcontext *ctx, GLenum pname, GLboolean state )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+
+ switch (pname) {
+ case GL_DITHER:
+ if (state)
+ xmesa->pixelformat = xmesa->xm_visual->dithered_pf;
+ else
+ xmesa->pixelformat = xmesa->xm_visual->undithered_pf;
+ break;
+ default:
+ ; /* silence compiler warning */
+ }
+}
+
+
+void xmesa_update_state( GLcontext *ctx, GLuint new_state )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+
+ /* Propogate statechange information to swrast and swrast_setup
+ * modules. The X11 driver has no internal GL-dependent state.
+ */
+ _swrast_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+
+
+ /* setup pointers to front and back buffer clear functions */
+ xmesa->xm_buffer->front_clear_func = clear_front_pixmap;
+ if (xmesa->xm_buffer->backpixmap != XIMAGE) {
+ xmesa->xm_buffer->back_clear_func = clear_back_pixmap;
+ }
+ else if (sizeof(GLushort)!=2 || sizeof(GLuint)!=4) {
+ xmesa->xm_buffer->back_clear_func = clear_nbit_ximage;
+ }
+ else switch (xmesa->xm_visual->BitsPerPixel) {
+ case 8:
+ if (xmesa->xm_visual->hpcr_clear_flag) {
+ xmesa->xm_buffer->back_clear_func = clear_HPCR_ximage;
+ }
+ else {
+ xmesa->xm_buffer->back_clear_func = clear_8bit_ximage;
+ }
+ break;
+ case 16:
+ xmesa->xm_buffer->back_clear_func = clear_16bit_ximage;
+ break;
+ case 24:
+ xmesa->xm_buffer->back_clear_func = clear_24bit_ximage;
+ break;
+ case 32:
+ xmesa->xm_buffer->back_clear_func = clear_32bit_ximage;
+ break;
+ default:
+ xmesa->xm_buffer->back_clear_func = clear_nbit_ximage;
+ break;
+ }
+
+ xmesa_update_span_funcs(ctx);
+}
+
+
+
+/* Setup pointers and other driver state that is constant for the life
+ * of a context.
+ */
+void xmesa_init_pointers( GLcontext *ctx )
+{
+ TNLcontext *tnl;
+
+ ctx->Driver.GetString = get_string;
+ ctx->Driver.GetBufferSize = get_buffer_size;
+ ctx->Driver.Flush = flush;
+ ctx->Driver.Finish = finish;
+
+ /* Software rasterizer pixel paths:
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.Clear = clear_buffers;
+ ctx->Driver.ResizeBuffersMESA = resize_buffers;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+
+ /* Software texture functions:
+ */
+ 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.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;
+
+ ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
+ ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
+ ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+
+
+ /* Statechange callbacks:
+ */
+ ctx->Driver.SetDrawBuffer = set_draw_buffer;
+ ctx->Driver.ClearIndex = clear_index;
+ ctx->Driver.ClearColor = clear_color;
+ ctx->Driver.IndexMask = index_mask;
+ ctx->Driver.ColorMask = color_mask;
+ ctx->Driver.Enable = enable;
+
+
+ /* Initialize the TNL driver interface:
+ */
+ tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
+
+ /* Install swsetup for tnl->Driver.Render.*:
+ */
+ _swsetup_Wakeup(ctx);
+
+ (void) DitherValues; /* silenced unused var warning */
+}
+
+
+
+
+
+#define XMESA_NEW_POINT (_NEW_POINT | \
+ _NEW_RENDERMODE | \
+ _SWRAST_NEW_RASTERMASK)
+
+#define XMESA_NEW_LINE (_NEW_LINE | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_DEPTH | \
+ _NEW_RENDERMODE | \
+ _SWRAST_NEW_RASTERMASK)
+
+#define XMESA_NEW_TRIANGLE (_NEW_POLYGON | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_DEPTH | \
+ _NEW_RENDERMODE | \
+ _SWRAST_NEW_RASTERMASK)
+
+
+/* Extend the software rasterizer with our line/point/triangle
+ * functions.
+ */
+void xmesa_register_swrast_functions( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT( ctx );
+
+ swrast->choose_point = xmesa_choose_point;
+ swrast->choose_line = xmesa_choose_line;
+ swrast->choose_triangle = xmesa_choose_triangle;
+
+ swrast->invalidate_point |= XMESA_NEW_POINT;
+ swrast->invalidate_line |= XMESA_NEW_LINE;
+ swrast->invalidate_triangle |= XMESA_NEW_TRIANGLE;
+}
diff --git a/xc/extras/Mesa/src/X/xmesa3.c b/xc/extras/Mesa/src/X/xm_line.c
index 67cbf2e39..0137c8b95 100644
--- a/xc/extras/Mesa/src/X/xmesa3.c
+++ b/xc/extras/Mesa/src/X/xm_line.c
@@ -1,20 +1,21 @@
-/* $XFree86: xc/extras/Mesa/src/X/xmesa3.c,v 1.11 2001/12/11 09:18:55 alanh Exp $ */
+/* $Id: xm_line.c,v 1.2 2002/02/14 01:59:36 dawes Exp $ */
+
/*
* Mesa 3-D graphics library
- * Version: 3.4
- *
+ * Version: 3.5
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* 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
@@ -25,8 +26,6 @@
/*
- * Mesa/X11 interface, part 3.
- *
* This file contains "accelerated" point, line, and triangle functions.
* It should be fairly easy to write new special-purpose point, line or
* triangle functions and hook them into this module.
@@ -37,10 +36,15 @@
#include "depth.h"
#include "macros.h"
#include "mmath.h"
-#include "vb.h"
-#include "types.h"
+#include "mtypes.h"
#include "xmesaP.h"
+/* Internal swrast includes:
+ */
+#include "swrast/s_depth.h"
+#include "swrast/s_points.h"
+#include "swrast/s_lines.h"
+#include "swrast/s_context.h"
/**********************************************************************/
@@ -51,76 +55,62 @@
/*
* Render an array of points into a pixmap, any pixel format.
*/
-static void draw_points_ANY_pixmap( GLcontext *ctx, GLuint first, GLuint last )
+#if 000
+/* XXX don't use this, it doesn't dither correctly */
+static void draw_points_ANY_pixmap( GLcontext *ctx, const SWvertex *vert )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
- struct vertex_buffer *VB = ctx->VB;
- register GLuint i;
-
- if (xmesa->xm_visual->gl_visual->RGBAflag) {
- /* RGB mode */
- for (i=first;i<last;i++) {
- if (VB->ClipMask[i]==0) {
- register int x, y;
- const GLubyte *color = VB->ColorPtr->data[i];
- unsigned long pixel = xmesa_color_to_pixel( xmesa,
- color[0], color[1], color[2], color[3], xmesa->pixelformat);
- GLfloat *win = VB->Win.data[i];
-
- if (IS_INF_OR_NAN(win[0] + win[1]))
- continue;
-
- XMesaSetForeground( dpy, gc, pixel );
- x = (GLint) win[0];
- y = FLIP( xmesa->xm_buffer, (GLint) win[1] );
- XMesaDrawPoint( dpy, buffer, gc, x, y);
- }
- }
+ XMesaGC gc = xmesa->xm_buffer->gc;
+
+ if (xmesa->xm_visual->mesa_visual.RGBAflag) {
+ register int x, y;
+ const GLubyte *color = vert->color;
+ unsigned long pixel = xmesa_color_to_pixel( xmesa,
+ color[0], color[1],
+ color[2], color[3],
+ xmesa->pixelformat);
+ XMesaSetForeground( dpy, gc, pixel );
+ x = (GLint) vert->win[0];
+ y = FLIP( xmesa->xm_buffer, (GLint) vert->win[1] );
+ XMesaDrawPoint( dpy, buffer, gc, x, y);
}
else {
/* Color index mode */
- for (i=first;i<=last;i++) {
- if (VB->ClipMask[i]==0) {
- register int x, y;
- GLfloat *win = VB->Win.data[i];
-
- if (IS_INF_OR_NAN(win[0] + win[1]))
- continue;
-
- XMesaSetForeground( dpy, gc, VB->IndexPtr->data[i] );
- x = (GLint) win[0];
- y = FLIP( xmesa->xm_buffer, (GLint) win[1] );
- XMesaDrawPoint( dpy, buffer, gc, x, y);
- }
- }
+ register int x, y;
+ XMesaSetForeground( dpy, gc, vert->index );
+ x = (GLint) vert->win[0];
+ y = FLIP( xmesa->xm_buffer, (GLint) vert->win[1] );
+ XMesaDrawPoint( dpy, buffer, gc, x, y);
}
}
+#endif
-
-/*
- * Analyze context state to see if we can provide a fast points drawing
- * function, like those in points.c. Otherwise, return NULL.
+/* Override the swrast point-selection function. Try to use one of
+ * our internal point functions, otherwise fall back to the standard
+ * swrast functions.
*/
-points_func xmesa_get_points_func( GLcontext *ctx )
+void xmesa_choose_point( GLcontext *ctx )
{
+#if 0
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-
- if (ctx->Point.Size==1.0F && !ctx->Point.SmoothFlag && ctx->RasterMask==0
- && !ctx->Texture.ReallyEnabled) {
- if (xmesa->xm_buffer->buffer==XIMAGE) {
- return (points_func)NULL; /*draw_points_ximage;*/
- }
- else {
- return draw_points_ANY_pixmap;
- }
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (ctx->RenderMode == GL_RENDER
+ && ctx->Point.Size == 1.0F && !ctx->Point.SmoothFlag
+ && swrast->_RasterMask == 0
+ && !ctx->Texture._ReallyEnabled
+ && xmesa->xm_buffer->buffer != XIMAGE) {
+ swrast->Point = draw_points_ANY_pixmap;
}
else {
- return (points_func)NULL;
+ _swrast_choose_point( ctx );
}
+#else
+ _swrast_choose_point( ctx );
+#endif
}
@@ -128,47 +118,16 @@ points_func xmesa_get_points_func( GLcontext *ctx )
/**********************************************************************/
/*** Line rendering ***/
/**********************************************************************/
-#if 0
-/*
- * Render a line into a pixmap, any pixel format.
- */
-static void flat_pixmap_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- struct vertex_buffer *VB = ctx->VB;
- register int x0, y0, x1, y1;
- XMesaGC gc;
- unsigned long pixel;
- if (xmesa->xm_visual->gl_visual->RGBAflag) {
- const GLubyte *color = VB->ColorPtr->data[pv];
- pixel = xmesa_color_to_pixel( xmesa, color[0], color[1], color[2], color[3],
- xmesa->pixelformat );
- }
- else {
- pixel = VB->IndexPtr->data[pv];
- }
- gc = xmesa->xm_buffer->gc2;
- XMesaSetForeground( xmesa->display, gc, pixel );
-
- x0 = (GLint) VB->Win.data[vert0][0];
- y0 = FLIP( xmesa->xm_buffer, (GLint) VB->Win.data[vert0][1] );
- x1 = (GLint) VB->Win.data[vert1][0];
- y1 = FLIP( xmesa->xm_buffer, (GLint) VB->Win.data[vert1][1] );
- XMesaDrawLine( xmesa->display, xmesa->xm_buffer->buffer, gc,
- x0, y0, x1, y1 );
-}
-#endif
/*
* Draw a flat-shaded, PF_TRUECOLOR line into an XImage.
*/
static void flat_TRUECOLOR_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
XMesaImage *img = xmesa->xm_buffer->backimage;
unsigned long pixel;
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
@@ -177,7 +136,7 @@ static void flat_TRUECOLOR_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel );
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -186,10 +145,10 @@ static void flat_TRUECOLOR_line( GLcontext *ctx,
* Draw a flat-shaded, PF_8A8B8G8R line into an XImage.
*/
static void flat_8A8B8G8R_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
@@ -198,7 +157,7 @@ static void flat_8A8B8G8R_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -206,10 +165,10 @@ static void flat_8A8B8G8R_line( GLcontext *ctx,
* Draw a flat-shaded, PF_8R8G8B line into an XImage.
*/
static void flat_8R8G8B_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
@@ -218,7 +177,7 @@ static void flat_8R8G8B_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -226,10 +185,10 @@ static void flat_8R8G8B_line( GLcontext *ctx,
* Draw a flat-shaded, PF_8R8G8B24 line into an XImage.
*/
static void flat_8R8G8B24_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
#define PIXEL_TYPE bgr_t
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -241,7 +200,7 @@ static void flat_8R8G8B24_line( GLcontext *ctx,
pixelPtr->b = color[BCOMP]; \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -249,10 +208,10 @@ static void flat_8R8G8B24_line( GLcontext *ctx,
* Draw a flat-shaded, PF_5R6G5B line into an XImage.
*/
static void flat_5R6G5B_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLushort
@@ -261,7 +220,7 @@ static void flat_5R6G5B_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -269,10 +228,10 @@ static void flat_5R6G5B_line( GLcontext *ctx,
* Draw a flat-shaded, PF_DITHER_5R6G5B line into an XImage.
*/
static void flat_DITHER_5R6G5B_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -280,7 +239,7 @@ static void flat_DITHER_5R6G5B_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -289,10 +248,10 @@ static void flat_DITHER_5R6G5B_line( GLcontext *ctx,
* Draw a flat-shaded, PF_DITHER 8-bit line into an XImage.
*/
static void flat_DITHER8_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLint r = color[0], g = color[1], b = color[2];
DITHER_SETUP;
@@ -303,7 +262,7 @@ static void flat_DITHER8_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -311,10 +270,10 @@ static void flat_DITHER8_line( GLcontext *ctx,
* Draw a flat-shaded, PF_LOOKUP 8-bit line into an XImage.
*/
static void flat_LOOKUP8_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLubyte pixel;
LOOKUP_SETUP;
pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
@@ -325,7 +284,7 @@ static void flat_LOOKUP8_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -333,10 +292,10 @@ static void flat_LOOKUP8_line( GLcontext *ctx,
* Draw a flat-shaded, PF_HPCR line into an XImage.
*/
static void flat_HPCR_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLint r = color[0], g = color[1], b = color[2];
#define INTERP_XY 1
@@ -346,7 +305,7 @@ static void flat_HPCR_line( GLcontext *ctx,
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -355,10 +314,10 @@ static void flat_HPCR_line( GLcontext *ctx,
* Draw a flat-shaded, Z-less, PF_TRUECOLOR line into an XImage.
*/
static void flat_TRUECOLOR_z_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
XMesaImage *img = xmesa->xm_buffer->backimage;
unsigned long pixel;
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
@@ -373,7 +332,7 @@ static void flat_TRUECOLOR_z_line( GLcontext *ctx,
XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel ); \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -381,10 +340,10 @@ static void flat_TRUECOLOR_z_line( GLcontext *ctx,
* Draw a flat-shaded, Z-less, PF_8A8B8G8R line into an XImage.
*/
static void flat_8A8B8G8R_z_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
#define INTERP_Z 1
@@ -399,7 +358,7 @@ static void flat_8A8B8G8R_z_line( GLcontext *ctx,
*pixelPtr = pixel; \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -407,10 +366,10 @@ static void flat_8A8B8G8R_z_line( GLcontext *ctx,
* Draw a flat-shaded, Z-less, PF_8R8G8B line into an XImage.
*/
static void flat_8R8G8B_z_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define INTERP_Z 1
@@ -425,7 +384,7 @@ static void flat_8R8G8B_z_line( GLcontext *ctx,
*pixelPtr = pixel; \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -433,10 +392,10 @@ static void flat_8R8G8B_z_line( GLcontext *ctx,
* Draw a flat-shaded, Z-less, PF_8R8G8B24 line into an XImage.
*/
static void flat_8R8G8B24_z_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@@ -452,7 +411,7 @@ static void flat_8R8G8B24_z_line( GLcontext *ctx,
pixelPtr->b = color[BCOMP]; \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -460,10 +419,10 @@ static void flat_8R8G8B24_z_line( GLcontext *ctx,
* Draw a flat-shaded, Z-less, PF_5R6G5B line into an XImage.
*/
static void flat_5R6G5B_z_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define INTERP_Z 1
@@ -477,7 +436,7 @@ static void flat_5R6G5B_z_line( GLcontext *ctx,
*zPtr = Z; \
*pixelPtr = pixel; \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -485,10 +444,10 @@ static void flat_5R6G5B_z_line( GLcontext *ctx,
* Draw a flat-shaded, Z-less, PF_DITHER_5R6G5B line into an XImage.
*/
static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@@ -501,7 +460,7 @@ static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx,
*zPtr = Z; \
PACK_TRUEDITHER(*pixelPtr, X, Y, color[0], color[1], color[2]); \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -509,10 +468,10 @@ static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx,
* Draw a flat-shaded, Z-less, PF_DITHER 8-bit line into an XImage.
*/
static void flat_DITHER8_z_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLint r = color[0], g = color[1], b = color[2];
DITHER_SETUP;
@@ -528,7 +487,7 @@ static void flat_DITHER8_z_line( GLcontext *ctx,
*zPtr = Z; \
*pixelPtr = (GLubyte) DITHER( X, Y, r, g, b); \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -536,10 +495,10 @@ static void flat_DITHER8_z_line( GLcontext *ctx,
* Draw a flat-shaded, Z-less, PF_LOOKUP 8-bit line into an XImage.
*/
static void flat_LOOKUP8_z_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLubyte pixel;
LOOKUP_SETUP;
pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
@@ -556,7 +515,7 @@ static void flat_LOOKUP8_z_line( GLcontext *ctx,
*pixelPtr = pixel; \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
@@ -564,10 +523,10 @@ static void flat_LOOKUP8_z_line( GLcontext *ctx,
* Draw a flat-shaded, Z-less, PF_HPCR line into an XImage.
*/
static void flat_HPCR_z_line( GLcontext *ctx,
- GLuint vert0, GLuint vert1, GLuint pv )
+ const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
+ const GLubyte *color = vert1->color;
GLint r = color[0], g = color[1], b = color[2];
#define INTERP_XY 1
@@ -583,115 +542,30 @@ static void flat_HPCR_z_line( GLcontext *ctx,
*pixelPtr = (GLubyte) DITHER_HPCR( X, Y, r, g, b); \
}
-#include "linetemp.h"
+#include "swrast/s_linetemp.h"
}
-#if 0
-/*
- * Examine ctx->Line attributes and set xmesa->xm_buffer->gc1
- * and xmesa->xm_buffer->gc2 appropriately.
- */
-static void setup_x_line_options( GLcontext *ctx )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- int i, state, state0, new_state, len, offs;
- int tbit;
- char *dptr;
- int n_segments = 0;
- char dashes[20];
- int line_width, line_style;
-
- /*** Line Stipple ***/
- if (ctx->Line.StippleFlag) {
- const int pattern = ctx->Line.StipplePattern;
-
- dptr = dashes;
- state0 = state = ((pattern & 1) != 0);
-
- /* Decompose the pattern */
- for (i=1,tbit=2,len=1;i<16;++i,tbit=(tbit<<1))
- {
- new_state = ((tbit & pattern) != 0);
- if (state != new_state)
- {
- *dptr++ = ctx->Line.StippleFactor * len;
- len = 1;
- state = new_state;
- }
- else
- ++len;
- }
- *dptr = ctx->Line.StippleFactor * len;
- n_segments = 1 + (dptr - dashes);
-
- /* ensure an even no. of segments, or X may toggle on/off for consecutive patterns */
- /* if (n_segments & 1) dashes [n_segments++] = 0; value of 0 not allowed in dash list */
-
- /* Handle case where line style starts OFF */
- if (state0 == 0)
- offs = dashes[0];
- else
- offs = 0;
-
-#if 0
-fprintf (stderr, "input pattern: 0x%04x, offset %d, %d segments:", pattern, offs, n_segments);
-for (i = 0; i < n_segments; i++)
-fprintf (stderr, " %d", dashes[i]);
-fprintf (stderr, "\n");
-#endif
-
- XMesaSetDashes( xmesa->display, xmesa->xm_buffer->gc1,
- offs, dashes, n_segments );
- XMesaSetDashes( xmesa->display, xmesa->xm_buffer->gc2,
- offs, dashes, n_segments );
-
- line_style = LineOnOffDash;
- }
- else {
- line_style = LineSolid;
- }
-
- /*** Line Width ***/
- line_width = (int) (ctx->Line.Width+0.5F);
- if (line_width < 2) {
- /* Use fast lines when possible */
- line_width = 0;
- }
- /*** Set GC attributes ***/
- XMesaSetLineAttributes( xmesa->display, xmesa->xm_buffer->gc1,
- line_width, line_style, CapButt, JoinBevel);
- XMesaSetLineAttributes( xmesa->display, xmesa->xm_buffer->gc2,
- line_width, line_style, CapButt, JoinBevel);
- XMesaSetFillStyle( xmesa->display, xmesa->xm_buffer->gc1, FillSolid );
- XMesaSetFillStyle( xmesa->display, xmesa->xm_buffer->gc2, FillSolid );
-}
-#endif
-
-
-/*
- * Analyze context state to see if we can provide a fast line drawing
- * function, like those in lines.c. Otherwise, return NULL.
- */
-line_func xmesa_get_line_func( GLcontext *ctx )
+static swrast_line_func get_line_func( GLcontext *ctx )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
(void) DitherValues; /* silence unused var warning */
(void) kernel1; /* silence unused var warning */
- if (ctx->Line.SmoothFlag) return (line_func)NULL;
- if (ctx->Texture.ReallyEnabled) return (line_func)NULL;
- if (ctx->Light.ShadeModel!=GL_FLAT) return (line_func)NULL;
- /* X line stippling doesn't match OpenGL stippling */
- if (ctx->Line.StippleFlag==GL_TRUE) return (line_func)NULL;
+ if (ctx->RenderMode != GL_RENDER) return (swrast_line_func) NULL;
+ if (ctx->Line.SmoothFlag) return (swrast_line_func) NULL;
+ if (ctx->Texture._ReallyEnabled) return (swrast_line_func) NULL;
+ if (ctx->Light.ShadeModel != GL_FLAT) return (swrast_line_func) NULL;
+ if (ctx->Line.StippleFlag) return (swrast_line_func) NULL;
if (xmesa->xm_buffer->buffer==XIMAGE
- && ctx->RasterMask==DEPTH_BIT
+ && swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
- && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
+ && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& ctx->Line.Width==1.0F) {
switch (xmesa->pixelformat) {
case PF_TRUECOLOR:
@@ -707,17 +581,17 @@ line_func xmesa_get_line_func( GLcontext *ctx )
case PF_DITHER_5R6G5B:
return flat_DITHER_5R6G5B_z_line;
case PF_DITHER:
- return (depth==8) ? flat_DITHER8_z_line : (line_func)NULL;
+ return (depth==8) ? flat_DITHER8_z_line : (swrast_line_func) NULL;
case PF_LOOKUP:
- return (depth==8) ? flat_LOOKUP8_z_line : (line_func)NULL;
+ return (depth==8) ? flat_LOOKUP8_z_line : (swrast_line_func) NULL;
case PF_HPCR:
return flat_HPCR_z_line;
default:
- return NULL;
+ return (swrast_line_func)NULL;
}
}
if (xmesa->xm_buffer->buffer==XIMAGE
- && ctx->RasterMask==0
+ && swrast->_RasterMask==0
&& ctx->Line.Width==1.0F) {
switch (xmesa->pixelformat) {
case PF_TRUECOLOR:
@@ -733,24 +607,27 @@ line_func xmesa_get_line_func( GLcontext *ctx )
case PF_DITHER_5R6G5B:
return flat_DITHER_5R6G5B_line;
case PF_DITHER:
- return (depth==8) ? flat_DITHER8_line : (line_func)NULL;
+ return (depth==8) ? flat_DITHER8_line : (swrast_line_func) NULL;
case PF_LOOKUP:
- return (depth==8) ? flat_LOOKUP8_line : (line_func)NULL;
+ return (depth==8) ? flat_LOOKUP8_line : (swrast_line_func) NULL;
case PF_HPCR:
return flat_HPCR_line;
default:
- return NULL;
+ return (swrast_line_func)NULL;
}
}
-#if 0
- /* XXX have to disable this because X's rasterization rules don't match
- * software Mesa's. This causes the linehv.c conformance test to fail.
- * In the future, we might provide a config option to enable this.
- */
- if (xmesa->xm_buffer->buffer!=XIMAGE && ctx->RasterMask==0) {
- setup_x_line_options( ctx );
- return flat_pixmap_line;
- }
-#endif
- return (line_func)NULL;
+
+ return (swrast_line_func) NULL;
+}
+
+/* Override for the swrast line-selection function. Try to use one
+ * of our internal line functions, otherwise fall back to the
+ * standard swrast functions.
+ */
+void xmesa_choose_line( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (!(swrast->Line = get_line_func( ctx )))
+ _swrast_choose_line( ctx );
}
diff --git a/xc/extras/Mesa/src/X/xmesa2.c b/xc/extras/Mesa/src/X/xm_span.c
index 17729fd1e..416f17568 100644
--- a/xc/extras/Mesa/src/X/xmesa2.c
+++ b/xc/extras/Mesa/src/X/xm_span.c
@@ -1,20 +1,21 @@
-/* $XFree86: xc/extras/Mesa/src/X/xmesa2.c,v 1.12 2001/11/08 04:00:11 tsi Exp $ */
+/* $Id: xm_span.c,v 1.2 2002/02/14 01:59:36 dawes Exp $ */
+
/*
* Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
* 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
@@ -24,13 +25,6 @@
*/
-/*
- * Mesa/X11 interface, part 2.
- *
- * This file contains the implementations of all the device driver functions.
- */
-
-
#include "glxheader.h"
#include "context.h"
#include "drawpix.h"
@@ -38,14 +32,11 @@
#include "state.h"
#include "depth.h"
#include "macros.h"
-#include "vb.h"
-#include "types.h"
+#include "mtypes.h"
#include "xmesaP.h"
#include "extensions.h"
-
-
-static void update_span_funcs( GLcontext *ctx );
+#include "swrast/swrast.h"
/*
@@ -132,906 +123,6 @@ static unsigned long read_pixel( XMesaDisplay *dpy,
-
-/*
- * Return the size (width,height of the current color buffer.
- * This function should be called by the glViewport function because
- * glViewport is often called when the window gets resized. We need to
- * update some X/Mesa stuff when that happens.
- * Output: width - width of buffer in pixels.
- * height - height of buffer in pixels.
- */
-static void get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- unsigned int winwidth, winheight;
-#ifndef XFree86Server
- Window root;
- int winx, winy;
- unsigned int bw, d;
-
- _glthread_LOCK_MUTEX(_xmesa_lock);
- XGetGeometry( xmesa->display, xmesa->xm_buffer->frontbuffer, &root,
- &winx, &winy, &winwidth, &winheight, &bw, &d );
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
-#else
-
- winwidth = xmesa->xm_buffer->frontbuffer->width;
- winheight = xmesa->xm_buffer->frontbuffer->height;
-#endif
-
- *width = winwidth;
- *height = winheight;
-
- if ( winwidth!=xmesa->xm_buffer->width
- || winheight!=xmesa->xm_buffer->height) {
- xmesa->xm_buffer->width = winwidth;
- xmesa->xm_buffer->height = winheight;
- xmesa_alloc_back_buffer( xmesa->xm_buffer );
- }
-
- /* Needed by FLIP macro */
- xmesa->xm_buffer->bottom = (int) winheight - 1;
-
- if (xmesa->xm_buffer->backimage) {
- /* Needed by PIXELADDR1 macro */
- xmesa->xm_buffer->ximage_width1
- = xmesa->xm_buffer->backimage->bytes_per_line;
- xmesa->xm_buffer->ximage_origin1
- = (GLubyte *) xmesa->xm_buffer->backimage->data
- + xmesa->xm_buffer->ximage_width1 * (winheight-1);
-
- /* Needed by PIXELADDR2 macro */
- xmesa->xm_buffer->ximage_width2
- = xmesa->xm_buffer->backimage->bytes_per_line / 2;
- xmesa->xm_buffer->ximage_origin2
- = (GLushort *) xmesa->xm_buffer->backimage->data
- + xmesa->xm_buffer->ximage_width2 * (winheight-1);
-
- /* Needed by PIXELADDR3 macro */
- xmesa->xm_buffer->ximage_width3
- = xmesa->xm_buffer->backimage->bytes_per_line;
- xmesa->xm_buffer->ximage_origin3
- = (GLubyte *) xmesa->xm_buffer->backimage->data
- + xmesa->xm_buffer->ximage_width3 * (winheight-1);
-
- /* Needed by PIXELADDR4 macro */
- xmesa->xm_buffer->ximage_width4 = xmesa->xm_buffer->backimage->width;
- xmesa->xm_buffer->ximage_origin4
- = (GLuint *) xmesa->xm_buffer->backimage->data
- + xmesa->xm_buffer->ximage_width4 * (winheight-1);
- }
-}
-
-
-static void finish( GLcontext *ctx )
-{
-#ifdef XFree86Server
- /* NOT_NEEDED */
-#else
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (xmesa) {
- _glthread_LOCK_MUTEX(_xmesa_lock);
- XSync( xmesa->display, False );
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
- }
-#endif
-}
-
-
-static void flush( GLcontext *ctx )
-{
-#ifdef XFree86Server
- /* NOT_NEEDED */
-#else
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (xmesa) {
- _glthread_LOCK_MUTEX(_xmesa_lock);
- XFlush( xmesa->display );
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
- }
-#endif
-}
-
-
-#if 0
-static GLboolean set_buffer( GLcontext *ctx, GLenum mode )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (mode == GL_FRONT_LEFT) {
- /* read/write front buffer */
- xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
- ctx->NewState |= NEW_RASTER_OPS;
- gl_update_state(ctx);
- return GL_TRUE;
- }
- else if (mode==GL_BACK_LEFT && xmesa->xm_buffer->db_state) {
- /* read/write back buffer */
- if (xmesa->xm_buffer->backpixmap) {
- xmesa->xm_buffer->buffer =
- (XMesaDrawable)xmesa->xm_buffer->backpixmap;
- }
- else if (xmesa->xm_buffer->backimage) {
- xmesa->xm_buffer->buffer = None;
- }
- else {
- /* just in case there wasn't enough memory for back buffer */
- xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
- }
- ctx->NewState |= NEW_RASTER_OPS;
- gl_update_state(ctx);
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-#endif
-
-
-static GLboolean set_draw_buffer( GLcontext *ctx, GLenum mode )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (mode == GL_FRONT_LEFT) {
- /* write to front buffer */
- xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
- update_span_funcs(ctx);
- return GL_TRUE;
- }
- else if (mode==GL_BACK_LEFT && xmesa->xm_buffer->db_state) {
- /* write to back buffer */
- if (xmesa->xm_buffer->backpixmap) {
- xmesa->xm_buffer->buffer =
- (XMesaDrawable)xmesa->xm_buffer->backpixmap;
- }
- else if (xmesa->xm_buffer->backimage) {
- xmesa->xm_buffer->buffer = None;
- }
- else {
- /* just in case there wasn't enough memory for back buffer */
- xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
- }
- update_span_funcs(ctx);
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-
-
-static void set_read_buffer( GLcontext *ctx, GLframebuffer *buffer,
- GLenum mode )
-{
- XMesaBuffer target;
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-
- if (buffer == ctx->DrawBuffer) {
- target = xmesa->xm_buffer;
- xmesa->use_read_buffer = GL_FALSE;
- }
- else {
- ASSERT(buffer == ctx->ReadBuffer);
- target = xmesa->xm_read_buffer;
- xmesa->use_read_buffer = GL_TRUE;
- }
-
- if (mode == GL_FRONT_LEFT) {
- target->buffer = target->frontbuffer;
- update_span_funcs(ctx);
- }
- else if (mode==GL_BACK_LEFT && xmesa->xm_read_buffer->db_state) {
- if (target->backpixmap) {
- target->buffer = (XMesaDrawable)xmesa->xm_buffer->backpixmap;
- }
- else if (target->backimage) {
- target->buffer = None;
- }
- else {
- /* just in case there wasn't enough memory for back buffer */
- target->buffer = target->frontbuffer;
- }
- update_span_funcs(ctx);
- }
- else {
- gl_problem(ctx, "invalid buffer in set_read_buffer() in xmesa2.c");
- }
-}
-
-
-
-static void clear_index( GLcontext *ctx, GLuint index )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- xmesa->clearpixel = (unsigned long) index;
- XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc,
- (unsigned long) index );
-}
-
-
-static void clear_color( GLcontext *ctx,
- GLubyte r, GLubyte g, GLubyte b, GLubyte a )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- xmesa->clearcolor[0] = r;
- xmesa->clearcolor[1] = g;
- xmesa->clearcolor[2] = b;
- xmesa->clearcolor[3] = a;
- xmesa->clearpixel = xmesa_color_to_pixel( xmesa, r, g, b, a,
- xmesa->xm_visual->undithered_pf );
- _glthread_LOCK_MUTEX(_xmesa_lock);
- XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc,
- xmesa->clearpixel );
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
-}
-
-
-static void clear_color_HPCR_ximage( GLcontext *ctx,
- GLubyte r, GLubyte g, GLubyte b, GLubyte a )
-{
- int i;
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- xmesa->clearcolor[0] = r;
- xmesa->clearcolor[1] = g;
- xmesa->clearcolor[2] = b;
- xmesa->clearcolor[3] = a;
-
- if (r == 0 && g == 0 && b == 0) {
- /* black is black */
- MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 ,
- sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern));
- }
- else {
- /* build clear pattern */
- for (i=0; i<16; i++) {
- xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] =
- DITHER_HPCR(i, 0, r, g, b);
- xmesa->xm_visual->hpcr_clear_ximage_pattern[1][i] =
- DITHER_HPCR(i, 1, r, g, b);
- }
- }
-}
-
-
-static void clear_color_HPCR_pixmap( GLcontext *ctx,
- GLubyte r, GLubyte g, GLubyte b, GLubyte a )
-{
- int i;
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- xmesa->clearcolor[0] = r;
- xmesa->clearcolor[1] = g;
- xmesa->clearcolor[2] = b;
- xmesa->clearcolor[3] = a;
-
-
- if (0x0==r && 0x0==g && 0x0==b) {
- /* black is black */
- for (i=0; i<16; i++) {
- XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, 0);
- XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, 0);
- }
- }
- else {
- for (i=0; i<16; i++) {
- XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, DITHER_HPCR(i, 0, r, g, b));
- XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, DITHER_HPCR(i, 1, r, g, b));
- }
- }
- /* change tile pixmap content */
- XMesaPutImage(xmesa->display,
- (XMesaDrawable)xmesa->xm_visual->hpcr_clear_pixmap,
- xmesa->xm_buffer->cleargc,
- xmesa->xm_visual->hpcr_clear_ximage, 0, 0, 0, 0, 16, 2);
-}
-
-/* Set current color index */
-static void set_index( GLcontext *ctx, GLuint index )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- unsigned long p = (unsigned long) index;
- xmesa->pixel = p;
- XMesaSetForeground( xmesa->display, xmesa->xm_buffer->gc1, p );
-}
-
-
-/* Set current drawing color */
-static void set_color( GLcontext *ctx,
- GLubyte r, GLubyte g, GLubyte b, GLubyte a )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- xmesa->red = r;
- xmesa->green = g;
- xmesa->blue = b;
- xmesa->alpha = a;
- xmesa->pixel = xmesa_color_to_pixel( xmesa, r, g, b, a, xmesa->pixelformat );;
- XMesaSetForeground( xmesa->display, xmesa->xm_buffer->gc1, xmesa->pixel );
-}
-
-
-
-/* Set index mask ala glIndexMask */
-static GLboolean index_mask( GLcontext *ctx, GLuint mask )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (xmesa->xm_buffer->buffer==XIMAGE) {
- return GL_FALSE;
- }
- else {
- unsigned long m;
- if (mask==0xffffffff) {
- m = ((unsigned long)~0L);
- }
- else {
- m = (unsigned long) mask;
- }
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->gc1, m );
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->gc2, m );
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m );
- return GL_TRUE;
- }
-}
-
-
-/* Implements glColorMask() */
-static GLboolean color_mask( GLcontext *ctx,
- GLboolean rmask, GLboolean gmask,
- GLboolean bmask, GLboolean amask )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- int xclass = GET_VISUAL_CLASS(xmesa->xm_visual);
- (void) amask;
-
- if (xmesa->xm_buffer->buffer!=XIMAGE
- && (xclass==TrueColor || xclass==DirectColor)) {
- unsigned long m;
- if (rmask && gmask && bmask) {
- m = ((unsigned long)~0L);
- }
- else {
- m = 0;
- if (rmask) m |= GET_REDMASK(xmesa->xm_visual);
- if (gmask) m |= GET_GREENMASK(xmesa->xm_visual);
- if (bmask) m |= GET_BLUEMASK(xmesa->xm_visual);
- }
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->gc1, m );
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->gc2, m );
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m );
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-
-
-/*
- * Set the pixel logic operation. Return GL_TRUE if the device driver
- * can perform the operation, otherwise return GL_FALSE. GL_COPY _must_
- * be operational, obviously.
- */
-static GLboolean logicop( GLcontext *ctx, GLenum op )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- int func;
- if ((xmesa->xm_buffer->buffer==XIMAGE) && op!=GL_COPY) {
- /* X can't do logic ops in Ximages, except for GL_COPY */
- return GL_FALSE;
- }
- switch (op) {
- case GL_CLEAR: func = GXclear; break;
- case GL_SET: func = GXset; break;
- case GL_COPY: func = GXcopy; break;
- case GL_COPY_INVERTED: func = GXcopyInverted; break;
- case GL_NOOP: func = GXnoop; break;
- case GL_INVERT: func = GXinvert; break;
- case GL_AND: func = GXand; break;
- case GL_NAND: func = GXnand; break;
- case GL_OR: func = GXor; break;
- case GL_NOR: func = GXnor; break;
- case GL_XOR: func = GXxor; break;
- case GL_EQUIV: func = GXequiv; break;
- case GL_AND_REVERSE: func = GXandReverse; break;
- case GL_AND_INVERTED: func = GXandInverted; break;
- case GL_OR_REVERSE: func = GXorReverse; break;
- case GL_OR_INVERTED: func = GXorInverted; break;
- default: return GL_FALSE;
- }
- _glthread_LOCK_MUTEX(_xmesa_lock);
- XMesaSetFunction( xmesa->display, xmesa->xm_buffer->gc1, func );
- XMesaSetFunction( xmesa->display, xmesa->xm_buffer->gc2, func );
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
- return GL_TRUE;
-}
-
-
-/*
- * Enable/disable dithering
- */
-static void dither( GLcontext *ctx, GLboolean enable )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (enable) {
- xmesa->pixelformat = xmesa->xm_visual->dithered_pf;
- }
- else {
- xmesa->pixelformat = xmesa->xm_visual->undithered_pf;
- }
-}
-
-
-
-/**********************************************************************/
-/*** glClear implementations ***/
-/**********************************************************************/
-
-
-static void
-clear_front_pixmap( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (all) {
- XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->frontbuffer,
- xmesa->xm_buffer->cleargc,
- 0, 0,
- xmesa->xm_buffer->width+1,
- xmesa->xm_buffer->height+1 );
- }
- else {
- XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->frontbuffer,
- xmesa->xm_buffer->cleargc,
- x, xmesa->xm_buffer->height - y - height,
- width, height );
- }
-}
-
-
-static void
-clear_back_pixmap( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (all) {
- XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->backpixmap,
- xmesa->xm_buffer->cleargc,
- 0, 0,
- xmesa->xm_buffer->width+1,
- xmesa->xm_buffer->height+1 );
- }
- else {
- XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->backpixmap,
- xmesa->xm_buffer->cleargc,
- x, xmesa->xm_buffer->height - y - height,
- width, height );
- }
-}
-
-
-static void
-clear_8bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (all) {
- size_t n = xmesa->xm_buffer->backimage->bytes_per_line
- * xmesa->xm_buffer->backimage->height;
- MEMSET( xmesa->xm_buffer->backimage->data, xmesa->clearpixel, n );
- }
- else {
- GLint i;
- for (i=0;i<height;i++) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y+i );
- MEMSET( ptr, xmesa->clearpixel, width );
- }
- }
-}
-
-
-static void
-clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (all) {
- GLint i, c16 = (xmesa->xm_buffer->backimage->bytes_per_line>>4)<<4;
- GLubyte *ptr = (GLubyte *)xmesa->xm_buffer->backimage->data;
- for (i=0; i<xmesa->xm_buffer->backimage->height; i++) {
- GLint j;
- GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
- if (i&1) {
- sptr += 16;
- }
- for (j=0; j<c16; j+=16) {
- ptr[0] = sptr[0];
- ptr[1] = sptr[1];
- ptr[2] = sptr[2];
- ptr[3] = sptr[3];
- ptr[4] = sptr[4];
- ptr[5] = sptr[5];
- ptr[6] = sptr[6];
- ptr[7] = sptr[7];
- ptr[8] = sptr[8];
- ptr[9] = sptr[9];
- ptr[10] = sptr[10];
- ptr[11] = sptr[11];
- ptr[12] = sptr[12];
- ptr[13] = sptr[13];
- ptr[14] = sptr[14];
- ptr[15] = sptr[15];
- ptr += 16;
- }
- for (; j<xmesa->xm_buffer->backimage->bytes_per_line; j++) {
- *ptr = sptr[j&15];
- ptr++;
- }
- }
- }
- else {
- GLint i;
- for (i=y; i<y+height; i++) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, i );
- int j;
- GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
- if (i&1) {
- sptr += 16;
- }
- for (j=x; j<x+width; j++) {
- *ptr = sptr[j&15];
- ptr++;
- }
- }
- }
-}
-
-
-static void
-clear_16bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- register GLuint pixel = (GLuint) xmesa->clearpixel;
- if (xmesa->swapbytes) {
- pixel = ((pixel >> 8) & 0x00ff) | ((pixel << 8) & 0xff00);
- }
- if (all) {
- register GLuint n;
- register GLuint *ptr4 = (GLuint *) xmesa->xm_buffer->backimage->data;
- if ((pixel & 0xff) == ((pixel >> 8) & 0xff)) {
- /* low and high bytes are equal so use memset() */
- n = xmesa->xm_buffer->backimage->bytes_per_line
- * xmesa->xm_buffer->height;
- MEMSET( ptr4, pixel & 0xff, n );
- }
- else {
- pixel = pixel | (pixel<<16);
- n = xmesa->xm_buffer->backimage->bytes_per_line
- * xmesa->xm_buffer->height / 4;
- do {
- *ptr4++ = pixel;
- n--;
- } while (n!=0);
-
- if ((xmesa->xm_buffer->backimage->bytes_per_line *
- xmesa->xm_buffer->height) & 0x2)
- *(GLushort *)ptr4 = pixel & 0xffff;
- }
- }
- else {
- register int i, j;
- for (j=0;j<height;j++) {
- register GLushort *ptr2 = PIXELADDR2( xmesa->xm_buffer, x, y+j );
- for (i=0;i<width;i++) {
- *ptr2++ = pixel;
- }
- }
- }
-}
-
-
-/* Optimized code provided by Nozomi Ytow <noz@xfree86.org> */
-static void
-clear_24bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte r = xmesa->clearcolor[0];
- const GLubyte g = xmesa->clearcolor[1];
- const GLubyte b = xmesa->clearcolor[2];
- register GLuint clearPixel;
- if (xmesa->swapbytes) {
- clearPixel = (b << 16) | (g << 8) | r;
- }
- else {
- clearPixel = (r << 16) | (g << 8) | b;
- }
-
- if (all) {
- if (r==g && g==b) {
- /* same value for all three components (gray) */
- const GLint w3 = xmesa->xm_buffer->width * 3;
- const GLint h = xmesa->xm_buffer->height;
- GLint i;
- for (i = 0; i < h; i++) {
- bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i);
- MEMSET(ptr3, r, w3);
- }
- }
- else {
- /* the usual case */
- const GLint w = xmesa->xm_buffer->width;
- const GLint h = xmesa->xm_buffer->height;
- GLint i, j;
- for (i = 0; i < h; i++) {
- bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i);
- for (j = 0; j < w; j++) {
- ptr3->r = r;
- ptr3->g = g;
- ptr3->b = b;
- ptr3++;
- }
- }
-#if 0 /* this code doesn't work for all window widths */
- register GLuint *ptr4 = (GLuint *) ptr3;
- register GLuint px;
- GLuint pixel4[3];
- register GLuint *p = pixel4;
- pixel4[0] = clearPixel | (clearPixel << 24);
- pixel4[1] = (clearPixel << 16) | (clearPixel >> 8);
- pixel4[2] = (clearPixel << 8) | (clearPixel >> 16);
- switch (3 & (int)(ptr3 - (bgr_t*) ptr4)){
- case 0:
- break;
- case 1:
- px = *ptr4 & 0x00ffffff;
- px |= pixel4[0] & 0xff000000;
- *ptr4++ = px;
- px = *ptr4 & 0xffff0000;
- px |= pixel4[2] & 0x0000ffff;
- *ptr4 = px;
- if (0 == --n)
- break;
- case 2:
- px = *ptr4 & 0x0000fffff;
- px |= pixel4[1] & 0xffff0000;
- *ptr4++ = px;
- px = *ptr4 & 0xffffff00;
- px |= pixel4[2] & 0x000000ff;
- *ptr4 = px;
- if (0 == --n)
- break;
- case 3:
- px = *ptr4 & 0x000000ff;
- px |= pixel4[2] & 0xffffff00;
- *ptr4++ = px;
- --n;
- break;
- }
- while (n > 3) {
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- n -= 4;
- }
- switch (n) {
- case 3:
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffffff00;
- px |= clearPixel & 0xff;
- *ptr4 = px;
- break;
- case 2:
- p = pixel4;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffff0000;
- px |= *p & 0xffff;
- *ptr4 = px;
- break;
- case 1:
- px = *ptr4 & 0xff000000;
- px |= *p & 0xffffff;
- *ptr4 = px;
- break;
- case 0:
- break;
- }
-#endif
- }
- }
- else {
- /* only clear subrect of color buffer */
- if (r==g && g==b) {
- /* same value for all three components (gray) */
- GLint j;
- for (j=0;j<height;j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j );
- MEMSET(ptr3, r, 3 * width);
- }
- }
- else {
- /* non-gray clear color */
- GLint i, j;
- for (j = 0; j < height; j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j );
- for (i = 0; i < width; i++) {
- ptr3->r = r;
- ptr3->g = g;
- ptr3->b = b;
- ptr3++;
- }
- }
-#if 0 /* this code might not always (seems ptr3 always == ptr4) */
- GLint j;
- GLuint pixel4[3];
- pixel4[0] = clearPixel | (clearPixel << 24);
- pixel4[1] = (clearPixel << 16) | (clearPixel >> 8);
- pixel4[2] = (clearPixel << 8) | (clearPixel >> 16);
- for (j=0;j<height;j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j );
- register GLuint *ptr4 = (GLuint *)ptr3;
- register GLuint *p, px;
- GLuint w = width;
- switch (3 & (int)(ptr3 - (bgr_t*) ptr4)){
- case 0:
- break;
- case 1:
- px = *ptr4 & 0x00ffffff;
- px |= pixel4[0] & 0xff000000;
- *ptr4++ = px;
- px = *ptr4 & 0xffff0000;
- px |= pixel4[2] & 0x0000ffff;
- *ptr4 = px;
- if (0 == --w)
- break;
- case 2:
- px = *ptr4 & 0x0000fffff;
- px |= pixel4[1] & 0xffff0000;
- *ptr4++ = px;
- px = *ptr4 & 0xffffff00;
- px |= pixel4[2] & 0x000000ff;
- *ptr4 = px;
- if (0 == --w)
- break;
- case 3:
- px = *ptr4 & 0x000000ff;
- px |= pixel4[2] & 0xffffff00;
- *ptr4++ = px;
- --w;
- break;
- }
- while (w > 3){
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- w -= 4;
- }
- switch (w) {
- case 3:
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffffff00;
- px |= *p & 0xff;
- *ptr4 = px;
- break;
- case 2:
- p = pixel4;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffff0000;
- px |= *p & 0xffff;
- *ptr4 = px;
- break;
- case 1:
- px = *ptr4 & 0xff000000;
- px |= pixel4[0] & 0xffffff;
- *ptr4 = px;
- break;
- case 0:
- break;
- }
- }
-#endif
- }
- }
-}
-
-
-static void
-clear_32bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- register GLuint pixel = (GLuint) xmesa->clearpixel;
- if (xmesa->swapbytes) {
- pixel = ((pixel >> 24) & 0x000000ff)
- | ((pixel >> 8) & 0x0000ff00)
- | ((pixel << 8) & 0x00ff0000)
- | ((pixel << 24) & 0xff000000);
- }
- if (all) {
- register GLint n = xmesa->xm_buffer->width * xmesa->xm_buffer->height;
- register GLuint *ptr4 = (GLuint *) xmesa->xm_buffer->backimage->data;
- if (pixel==0) {
- MEMSET( ptr4, pixel, 4*n );
- }
- else {
- do {
- *ptr4++ = pixel;
- n--;
- } while (n!=0);
- }
- }
- else {
- register int i, j;
- for (j=0;j<height;j++) {
- register GLuint *ptr4 = PIXELADDR4( xmesa->xm_buffer, x, y+j );
- for (i=0;i<width;i++) {
- *ptr4++ = pixel;
- }
- }
- }
-}
-
-
-static void
-clear_nbit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
- if (all) {
- register int i, j;
- width = xmesa->xm_buffer->width;
- height = xmesa->xm_buffer->height;
- for (j=0;j<height;j++) {
- for (i=0;i<width;i++) {
- XMesaPutPixel( img, i, j, xmesa->clearpixel );
- }
- }
- }
- else {
- /* TODO: optimize this */
- register int i, j;
- y = FLIP(xmesa->xm_buffer, y);
- for (j=0;j<height;j++) {
- for (i=0;i<width;i++) {
- XMesaPutPixel( img, x+i, y-j, xmesa->clearpixel );
- }
- }
- }
-}
-
-
-
-static GLbitfield
-clear_buffers( GLcontext *ctx, GLbitfield mask,
- GLboolean all, GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
-
- /* we can't handle color or index masking */
- if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
- if (*colorMask != 0xffffffff || ctx->Color.IndexMask != 0xffffffff)
- return mask;
- }
-
- if (mask & DD_FRONT_LEFT_BIT) {
- ASSERT(xmesa->xm_buffer->front_clear_func);
- (*xmesa->xm_buffer->front_clear_func)( ctx, all, x, y, width, height );
- }
- if (mask & DD_BACK_LEFT_BIT) {
- ASSERT(xmesa->xm_buffer->back_clear_func);
- (*xmesa->xm_buffer->back_clear_func)( ctx, all, x, y, width, height );
- }
- return mask & (~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
-}
-
-
-
/*
* The Mesa library needs to be able to draw pixels in a number of ways:
* 1. RGB vs Color Index
@@ -1093,7 +184,7 @@ static void write_span_TRUECOLOR_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1127,7 +218,7 @@ static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1161,7 +252,7 @@ static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1194,7 +285,7 @@ static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1228,7 +319,7 @@ static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1260,7 +351,7 @@ static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1292,7 +383,7 @@ static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1323,7 +414,7 @@ static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
register GLuint i;
@@ -1417,7 +508,7 @@ static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1448,7 +539,7 @@ static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
register GLuint i;
@@ -1547,7 +638,7 @@ static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1578,7 +669,7 @@ static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1611,7 +702,7 @@ static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1642,7 +733,7 @@ static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1676,7 +767,7 @@ static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
XDITHER_SETUP(y);
y = FLIP(xmesa->xm_buffer, y);
@@ -1707,7 +798,7 @@ static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
XDITHER_SETUP(y);
y = FLIP(xmesa->xm_buffer, y);
@@ -1738,7 +829,7 @@ static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
SETUP_1BIT;
y = FLIP(xmesa->xm_buffer, y);
@@ -1771,7 +862,7 @@ static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
SETUP_1BIT;
y = FLIP(xmesa->xm_buffer, y);
@@ -1804,7 +895,7 @@ static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1835,7 +926,7 @@ static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1866,7 +957,7 @@ static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
LOOKUP_SETUP;
y = FLIP(xmesa->xm_buffer, y);
@@ -1896,7 +987,7 @@ static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
LOOKUP_SETUP;
y = FLIP(xmesa->xm_buffer, y);
@@ -1927,7 +1018,7 @@ static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -1956,7 +1047,7 @@ static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -2416,10 +1507,11 @@ static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
register GLuint i;
register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ const GLint y2 = FLIP(xmesa->xm_buffer, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
- PACK_TRUEDITHER( ptr[i], x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
}
@@ -2431,16 +1523,16 @@ static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS )
n -= extraPixel;
for (i = 0; i < n; i += 2, x += 2) {
GLuint p0, p1;
- PACK_TRUEDITHER( p0, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- PACK_TRUEDITHER( p1, x+1, y, rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP] );
+ PACK_TRUEDITHER( p0, x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ PACK_TRUEDITHER( p1, x+1, y2, rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP] );
*ptr32++ = (p1 << 16) | p0;
}
if (extraPixel) {
- PACK_TRUEDITHER( ptr[n], x+n, y, rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]);
+ PACK_TRUEDITHER( ptr[n], x+n, y2, rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]);
}
#else
for (i = 0; i < n; i++, x++) {
- PACK_TRUEDITHER( ptr[i], x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
}
#endif
}
@@ -2946,7 +2038,7 @@ static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -2967,7 +2059,7 @@ static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -2988,7 +2080,7 @@ static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3008,7 +2100,7 @@ static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3027,7 +2119,7 @@ static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3046,7 +2138,7 @@ static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3065,7 +2157,7 @@ static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3086,7 +2178,7 @@ static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
DITHER_SETUP;
for (i=0;i<n;i++) {
@@ -3107,7 +2199,7 @@ static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
SETUP_1BIT;
for (i=0;i<n;i++) {
@@ -3128,7 +2220,7 @@ static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3148,7 +2240,7 @@ static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
LOOKUP_SETUP;
for (i=0;i<n;i++) {
@@ -3168,7 +2260,7 @@ static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3208,7 +2300,7 @@ static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
- PACK_TRUEDITHER(p, x[i], FLIP(xmesa->xm_buffer, y[i]), rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
}
}
@@ -3440,79 +2532,96 @@ static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS )
/**********************************************************************/
#define MONO_SPAN_ARGS const GLcontext *ctx, \
- GLuint n, GLint x, GLint y, const GLubyte mask[]
+ GLuint n, GLint x, GLint y, const GLchan color[4], \
+ const GLubyte mask[]
/*
- * Write a span of identical pixels to a pixmap. The pixel value is
- * the one set by DD.color() or DD.index().
+ * Write a span of identical pixels to a pixmap.
*/
static void write_span_mono_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc1;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+ const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
register GLuint i;
- register GLboolean write_all;
+ XMesaSetForeground( xmesa->display, gc, pixel );
y = FLIP(xmesa->xm_buffer, y);
- write_all = GL_TRUE;
- for (i=0;i<n;i++) {
- if (!mask[i]) {
- write_all = GL_FALSE;
- break;
- }
- }
- if (write_all) {
- XMesaFillRectangle( dpy, buffer, gc, (int) x, (int) y, n, 1 );
+
+ /* New code contributed by Jeff Epler and cleaned up by Keith
+ * Whitwell.
+ */
+ for (i = 0; i < n; ) {
+ GLuint start = i;
+
+ /* Identify and emit contiguous rendered pixels
+ */
+ while (i < n && mask[i])
+ i++;
+
+ if (start < i)
+ XMesaFillRectangle( dpy, buffer, gc,
+ (int)(x+start), (int) y,
+ (int)(i-start), 1);
+
+ /* Eat up non-rendered pixels
+ */
+ while (i < n && !mask[i])
+ i++;
}
- else {
-#if 0
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
- }
- }
-#else
- /* This version is usually faster. Contributed by Jeff Epler
- * and cleaned up by Keith Whitwell.
+}
+
+
+
+static void write_span_mono_index_pixmap( const GLcontext *ctx, GLuint n,
+ GLint x, GLint y, GLuint colorIndex,
+ const GLubyte mask[] )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xmesa->xm_buffer->buffer;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+ register GLuint i;
+ XMesaSetForeground( xmesa->display, gc, colorIndex );
+ y = FLIP(xmesa->xm_buffer, y);
+
+ for (i = 0 ; i < n ;) {
+ GLuint start = i;
+
+ /* Identify and emit contiguous rendered pixels
*/
- for (i = 0; i < n; ) {
- GLuint start = i;
- /* Identify and emit contiguous rendered pixels
- */
- for( ; i < n && mask[i]; i++)
- /* Nothing */;
- if (start < i)
- XMesaFillRectangle( dpy, buffer, gc,
- (int)(x+start), (int) y,
- (int)(i-start), 1);
- /* Eat up non-rendered pixels
- */
- for(; i < n && !mask[i]; i++)
- /* Nothing */;
- }
-#endif
+ while (i < n && mask[i])
+ i++;
+
+ if (start < i)
+ XMesaFillRectangle( dpy, buffer, gc,
+ (int)(x+start), (int) y,
+ (int)(i-start), 1);
+
+ /* Eat up non-rendered pixels
+ */
+ while (i < n && !mask[i])
+ i++;
}
}
+
/*
- * Write a span of PF_TRUEDITHER pixels to a pixmap. The pixel value is
- * the one set by DD.color() or DD.index().
+ * Write a span of PF_TRUEDITHER pixels to a pixmap.
*/
static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- register GLubyte r, g, b;
int yy = FLIP(xmesa->xm_buffer, y);
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++,x++) {
if (mask[i]) {
unsigned long p;
@@ -3525,22 +2634,18 @@ static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS )
/*
- * Write a span of PF_DITHER pixels to a pixmap. The pixel value is
- * the one set by DD.color() or DD.index().
+ * Write a span of PF_DITHER pixels to a pixmap.
*/
static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- register GLubyte r, g, b;
int yy = FLIP(xmesa->xm_buffer, y);
XDITHER_SETUP(yy);
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, XDITHER( x, r, g, b ) );
@@ -3551,21 +2656,17 @@ static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS )
/*
- * Write a span of PF_1BIT pixels to a pixmap. The pixel value is
- * the one set by DD.color() or DD.index().
+ * Write a span of PF_1BIT pixels to a pixmap.
*/
static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- register GLubyte r, g, b;
SETUP_1BIT;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
y = FLIP(xmesa->xm_buffer, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3577,36 +2678,50 @@ static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS )
/*
- * Write a span of identical pixels to an XImage. The pixel value is
- * the one set by DD.color() or DD.index().
+ * Write a span of identical pixels to an XImage.
*/
static void write_span_mono_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- register unsigned long p = xmesa->pixel;
+ const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
+ y = FLIP(xmesa->xm_buffer, y);
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x, y, pixel );
+ }
+ }
+}
+
+
+static void write_span_mono_index_ximage( const GLcontext *ctx, GLuint n,
+ GLint x, GLint y,
+ GLuint colorIndex,
+ const GLubyte mask[] )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+ register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
- XMesaPutPixel( img, x, y, p );
+ XMesaPutPixel( img, x, y, colorIndex );
}
}
}
/*
- * Write a span of identical PF_TRUEDITHER pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical PF_TRUEDITHER pixels to an XImage.
*/
static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaImage *img = xmesa->xm_buffer->backimage;
+ const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
GLuint i;
- GLint r = xmesa->red;
- GLint g = xmesa->green;
- GLint b = xmesa->blue;
y = FLIP(xmesa->xm_buffer, y);
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3619,51 +2734,49 @@ static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS )
/*
- * Write a span of identical 8A8B8G8R pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical 8A8B8G8R pixels to an XImage.
*/
static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- GLuint i, p, *ptr;
- p = (GLuint) xmesa->pixel;
+ GLuint i, *ptr;
+ const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
for (i=0;i<n;i++) {
if (mask[i]) {
- ptr[i] = p;
+ ptr[i] = pixel;
}
}
}
/*
- * Write a span of identical 8R8G8B pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical 8R8G8B pixels to an XImage.
*/
static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- GLuint i, p, *ptr;
- p = (GLuint) xmesa->pixel;
- ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ const GLuint pixel = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
+ GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- ptr[i] = p;
+ ptr[i] = pixel;
}
}
}
/*
- * Write a span of identical 8R8G8B pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical 8R8G8B pixels to an XImage.
*/
static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte r = (GLubyte) ((xmesa->pixel >> 16) & 0xff);
- const GLubyte g = (GLubyte) ((xmesa->pixel >> 8 ) & 0xff);
- const GLubyte b = (GLubyte) ((xmesa->pixel ) & 0xff);
+ const GLubyte r = color[RCOMP];
+ const GLubyte g = color[GCOMP];
+ const GLubyte b = color[BCOMP];
GLuint i;
bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x, y );
for (i=0;i<n;i++) {
@@ -3677,20 +2790,16 @@ static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS )
/*
- * Write a span of identical DITHER pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical DITHER pixels to an XImage.
*/
static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
- register GLuint i;
- register GLubyte r, g, b;
int yy = FLIP(xmesa->xm_buffer, y);
+ register GLuint i;
XDITHER_SETUP(yy);
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaPutPixel( img, x, yy, XDITHER( x, r, g, b ) );
@@ -3700,19 +2809,15 @@ static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS )
/*
- * Write a span of identical 8-bit DITHER pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical 8-bit DITHER pixels to an XImage.
*/
static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- register GLuint i;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
- register GLubyte r, g, b;
+ register GLuint i;
XDITHER_SETUP(y);
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++,x++) {
if (mask[i]) {
ptr[i] = (GLubyte) XDITHER( x, r, g, b );
@@ -3722,15 +2827,16 @@ static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS )
/*
- * Write a span of identical 8-bit LOOKUP pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical 8-bit LOOKUP pixels to an XImage.
*/
static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
register GLuint i;
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
- register GLubyte pixel = (GLubyte) xmesa->pixel;
+ GLubyte pixel;
+ LOOKUP_SETUP;
+ pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
ptr[i] = pixel;
@@ -3740,19 +2846,15 @@ static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS )
/*
- * Write a span of identical PF_1BIT pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical PF_1BIT pixels to an XImage.
*/
static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- register GLubyte r, g, b;
SETUP_1BIT;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
y = FLIP(xmesa->xm_buffer, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3763,18 +2865,14 @@ static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS )
/*
- * Write a span of identical HPCR pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical HPCR pixels to an XImage.
*/
static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- register GLuint i;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
- register GLubyte r, g, b;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
+ register GLuint i;
for (i=0;i<n;i++,x++) {
if (mask[i]) {
ptr[i] = DITHER_HPCR( x, y, r, g, b );
@@ -3784,15 +2882,14 @@ static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS )
/*
- * Write a span of identical 8-bit GRAYSCALE pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
*/
static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- GLuint i;
- GLubyte p = (GLubyte) xmesa->pixel;
+ const GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
GLubyte *ptr = (GLubyte *) PIXELADDR1( xmesa->xm_buffer,x,y);
+ GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
ptr[i] = p;
@@ -3803,17 +2900,14 @@ static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS )
/*
- * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
*/
static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
GLuint i;
- GLint r = xmesa->red;
- GLint g = xmesa->green;
- GLint b = xmesa->blue;
y = FLIP(xmesa->xm_buffer, y);
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3830,69 +2924,86 @@ static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS )
#define MONO_PIXEL_ARGS const GLcontext *ctx, \
GLuint n, const GLint x[], const GLint y[], \
- const GLubyte mask[]
+ const GLchan color[4], const GLubyte mask[]
/*
- * Write an array of identical pixels to a pixmap. The pixel value is
- * the one set by DD.color() or DD.index.
+ * Write an array of identical pixels to a pixmap.
*/
static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc1;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
+ const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
+ XMesaSetForeground( xmesa->display, gc, pixel );
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc,
+ (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ }
+ }
+}
+
+
+static void write_pixels_mono_index_pixmap(const GLcontext *ctx,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ GLuint colorIndex,
+ const GLubyte mask[] )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xmesa->xm_buffer->buffer;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+ register GLuint i;
+ XMesaSetForeground( xmesa->display, gc, colorIndex );
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaDrawPoint( dpy, buffer, gc,
+ (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
}
}
}
/*
- * Write an array of PF_TRUEDITHER pixels to a pixmap. The pixel value is
- * the one set by DD.color() or DD.index.
+ * Write an array of PF_TRUEDITHER pixels to a pixmap.
*/
static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- register GLubyte r, g, b;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
PACK_TRUEDITHER(p, x[i], y[i], r, g, b);
XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc,
+ (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
}
}
}
/*
- * Write an array of PF_DITHER pixels to a pixmap. The pixel value is
- * the one set by DD.color() or DD.index.
+ * Write an array of PF_DITHER pixels to a pixmap.
*/
static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- register GLubyte r, g, b;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
DITHER_SETUP;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, DITHER( x[i], y[i], r, g, b ) );
@@ -3903,21 +3014,17 @@ static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS )
/*
- * Write an array of PF_1BIT pixels to a pixmap. The pixel value is
- * the one set by DD.color() or DD.index.
+ * Write an array of PF_1BIT pixels to a pixmap.
*/
static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- register GLubyte r, g, b;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
SETUP_1BIT;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, DITHER_1BIT( x[i], y[i], r, g, b ) );
@@ -3928,18 +3035,34 @@ static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS )
/*
- * Write an array of identical pixels to an XImage. The pixel value is
- * the one set by DD.color() or DD.index.
+ * Write an array of identical pixels to an XImage.
*/
static void write_pixels_mono_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- register unsigned long p = xmesa->pixel;
+ const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
+ XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), pixel );
+ }
+ }
+}
+
+
+static void write_pixels_mono_index_ximage( const GLcontext *ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ GLuint colorIndex,
+ const GLubyte mask[] )
+{
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), colorIndex );
}
}
}
@@ -3947,16 +3070,13 @@ static void write_pixels_mono_ximage( MONO_PIXEL_ARGS )
/*
* Write an array of identical TRUEDITHER pixels to an XImage.
- * The pixel value is the one set by DD.color() or DD.index.
*/
static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- int r = xmesa->red;
- int g = xmesa->green;
- int b = xmesa->blue;
+ const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
@@ -3969,14 +3089,14 @@ static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS )
/*
- * Write an array of identical 8A8B8G8R pixels to an XImage. The pixel value
- * is the one set by DD.color().
+ * Write an array of identical 8A8B8G8R pixels to an XImage
*/
static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLuint p = PACK_8A8B8G8R(color[RCOMP], color[GCOMP],
+ color[BCOMP], color[ACOMP]);
register GLuint i;
- register GLuint p = (GLuint) xmesa->pixel;
for (i=0;i<n;i++) {
if (mask[i]) {
GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
@@ -3987,14 +3107,13 @@ static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS )
/*
- * Write an array of identical 8R8G8B pixels to an XImage. The pixel value
- * is the one set by DD.color().
+ * Write an array of identical 8R8G8B pixels to an XImage.
*/
static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
register GLuint i;
- register GLuint p = (GLuint) xmesa->pixel;
+ const GLuint p = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
@@ -4005,15 +3124,12 @@ static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS )
/*
- * Write an array of identical 8R8G8B pixels to an XImage. The pixel value
- * is the one set by DD.color().
+ * Write an array of identical 8R8G8B pixels to an XImage.
*/
static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte r = (GLubyte) ((xmesa->pixel >> 16) & 0xff);
- const GLubyte g = (GLubyte) ((xmesa->pixel >> 8 ) & 0xff);
- const GLubyte b = (GLubyte) ((xmesa->pixel ) & 0xff);
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -4027,19 +3143,15 @@ static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS )
/*
- * Write an array of identical PF_DITHER pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write an array of identical PF_DITHER pixels to an XImage.
*/
static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- register GLubyte r, g, b;
DITHER_SETUP;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), DITHER( x[i], y[i], r, g, b ) );
@@ -4049,18 +3161,14 @@ static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS )
/*
- * Write an array of identical 8-bit PF_DITHER pixels to an XImage. The
- * pixel value is the one set by DD.color().
+ * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
*/
static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- register GLubyte r, g, b;
DITHER_SETUP;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++) {
if (mask[i]) {
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
@@ -4071,14 +3179,15 @@ static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS )
/*
- * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage. The
- * pixel value is the one set by DD.color().
+ * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
*/
static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
register GLuint i;
- register GLubyte pixel = (GLubyte) xmesa->pixel;
+ GLubyte pixel;
+ LOOKUP_SETUP;
+ pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
@@ -4090,39 +3199,32 @@ static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS )
/*
- * Write an array of identical PF_1BIT pixels to an XImage. The pixel
- * value is the one set by DD.color().
+ * Write an array of identical PF_1BIT pixels to an XImage.
*/
static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- register GLubyte r, g, b;
SETUP_1BIT;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), DITHER_1BIT( x[i], y[i], r, g, b ));
+ XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
+ DITHER_1BIT( x[i], y[i], r, g, b ));
}
}
}
/*
- * Write an array of identical PF_HPCR pixels to an XImage. The
- * pixel value is the one set by DD.color().
+ * Write an array of identical PF_HPCR pixels to an XImage.
*/
static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- register GLubyte r, g, b;
- r = xmesa->red;
- g = xmesa->green;
- b = xmesa->blue;
for (i=0;i<n;i++) {
if (mask[i]) {
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
@@ -4133,14 +3235,13 @@ static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS )
/*
- * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage. The
- * pixel value is the one set by DD.color().
+ * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
*/
static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
register GLuint i;
- register GLubyte p = (GLubyte) xmesa->pixel;
+ register GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
@@ -4152,15 +3253,12 @@ static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS )
/*
* Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
- * The pixel value is the one set by DD.color() or DD.index.
*/
static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- int r = xmesa->red;
- int g = xmesa->green;
- int b = xmesa->blue;
for (i=0;i<n;i++) {
if (mask[i]) {
GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
@@ -4192,13 +3290,21 @@ static void write_span_index_pixmap( INDEX_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
- XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++,x++) {
+ XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
}
}
}
@@ -4212,7 +3318,7 @@ static void write_span_index8_pixmap( INDEX8_SPAN_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
y = FLIP(xmesa->xm_buffer, y);
if (mask) {
@@ -4321,7 +3427,7 @@ static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS )
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc2;
+ XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -4585,7 +3691,7 @@ static void read_color_span( const GLcontext *ctx,
}
break;
default:
- gl_problem(NULL,"Problem in DD.read_color_span (1)");
+ _mesa_problem(NULL,"Problem in DD.read_color_span (1)");
return;
}
}
@@ -4635,9 +3741,9 @@ static void read_color_span( const GLcontext *ctx,
const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
const GLushort *ptr2 = PIXELADDR2( source, x, y );
+ const GLuint *ptr4 = (const GLuint *) ptr2;
GLuint i;
#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
- const GLuint *ptr4 = (const GLuint *) ptr2;
GLuint extraPixel = (n & 1);
n -= extraPixel;
for (i = 0; i < n; i += 2) {
@@ -4776,7 +3882,7 @@ static void read_color_span( const GLcontext *ctx,
}
break;
default:
- gl_problem(NULL,"Problem in DD.read_color_span (2)");
+ _mesa_problem(NULL,"Problem in DD.read_color_span (2)");
return;
}
}
@@ -4951,7 +4057,7 @@ static void read_color_pixels( const GLcontext *ctx,
}
break;
default:
- gl_problem(NULL,"Problem in DD.read_color_pixels (1)");
+ _mesa_problem(NULL,"Problem in DD.read_color_pixels (1)");
return;
}
}
@@ -5068,99 +4174,75 @@ static void read_color_pixels( const GLcontext *ctx,
}
break;
default:
- gl_problem(NULL,"Problem in DD.read_color_pixels (1)");
+ _mesa_problem(NULL,"Problem in DD.read_color_pixels (1)");
return;
}
}
}
-
-#ifndef XFree86Server
-/*
- * This function implements glDrawPixels() with an XPutImage call when
- * drawing to the front buffer (X Window drawable).
- * The image format must be GL_BGRA to match the PF_8R8G8B pixel format.
- * XXX top/bottom edge clipping is broken!
- */
-static GLboolean
-drawpixels_8R8G8B( GLcontext *ctx,
- GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const struct gl_pixelstore_attrib *unpack,
- const GLvoid *pixels )
+static void
+clear_color_HPCR_ximage( GLcontext *ctx, const GLchan color[4] )
{
+ int i;
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc1;
- assert(dpy);
- assert(buffer);
- assert(gc);
-
- /* XXX also check for pixel scale/bias/lookup/zooming! */
- if (format == GL_BGRA && type == GL_UNSIGNED_BYTE) {
- int dstX = x;
- int dstY = y;
- int w = width;
- int h = height;
- int srcX = unpack->SkipPixels;
- int srcY = unpack->SkipRows;
- if (_mesa_clip_pixelrect(ctx, &dstX, &dstY, &w, &h, &srcX, &srcY)) {
- XMesaImage ximage;
- MEMSET(&ximage, 0, sizeof(XMesaImage));
- ximage.width = width;
- ximage.height = height;
- ximage.format = ZPixmap;
- ximage.data = (char *) pixels + (height - 1) * width * 4;
- ximage.byte_order = LSBFirst;
- ximage.bitmap_unit = 32;
- ximage.bitmap_bit_order = LSBFirst;
- ximage.bitmap_pad = 32;
- ximage.depth = 24;
- ximage.bytes_per_line = -width * 4;
- ximage.bits_per_pixel = 32;
- ximage.red_mask = 0xff0000;
- ximage.green_mask = 0x00ff00;
- ximage.blue_mask = 0x0000ff;
- dstY = FLIP(xmesa->xm_buffer,dstY) - height + 1;
- XPutImage(dpy, buffer, gc, &ximage, srcX, srcY, dstX, dstY, w, h);
- return GL_TRUE;
- }
- }
- return GL_FALSE;
-}
-#endif
+ COPY_4V(xmesa->clearcolor, color);
+ if (color[0] == 0 && color[1] == 0 && color[2] == 0) {
+ /* black is black */
+ MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 ,
+ sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern));
+ }
+ else {
+ /* build clear pattern */
+ for (i=0; i<16; i++) {
+ xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] =
+ DITHER_HPCR(i, 0, color[0], color[1], color[2]);
+ xmesa->xm_visual->hpcr_clear_ximage_pattern[1][i] =
+ DITHER_HPCR(i, 1, color[0], color[1], color[2]);
+ }
+ }
+}
-static const GLubyte *get_string( GLcontext *ctx, GLenum name )
+static void
+clear_color_HPCR_pixmap( GLcontext *ctx, const GLchan color[4] )
{
- (void) ctx;
- switch (name) {
- case GL_RENDERER:
-#ifdef XFree86Server
- return (const GLubyte *) "Mesa GLX Indirect";
-#else
- return (const GLubyte *) "Mesa X11";
-#endif
- case GL_VENDOR:
-#ifdef XFree86Server
- return (const GLubyte *) "VA Linux Systems, Inc.";
-#else
- return NULL;
-#endif
- default:
- return NULL;
+ int i;
+ const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+
+ COPY_4V(xmesa->clearcolor, color);
+
+ if (color[0] == 0 && color[1] == 0 && color[2] == 0) {
+ /* black is black */
+ for (i=0; i<16; i++) {
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, 0);
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, 0);
+ }
}
+ else {
+ for (i=0; i<16; i++) {
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0,
+ DITHER_HPCR(i, 0, color[0], color[1], color[2]));
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1,
+ DITHER_HPCR(i, 1, color[0], color[1], color[2]));
+ }
+ }
+ /* change tile pixmap content */
+ XMesaPutImage(xmesa->display,
+ (XMesaDrawable)xmesa->xm_visual->hpcr_clear_pixmap,
+ xmesa->xm_buffer->cleargc,
+ xmesa->xm_visual->hpcr_clear_ximage, 0, 0, 0, 0, 16, 2);
}
-static void update_span_funcs( GLcontext *ctx )
+
+void xmesa_update_span_funcs( GLcontext *ctx )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
int depth=GET_VISUAL_DEPTH(xmesa->xm_visual);
+ struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference( ctx );
/*
* These drawing functions depend on color buffer config:
@@ -5169,102 +4251,101 @@ static void update_span_funcs( GLcontext *ctx )
/* Writing to window or back pixmap */
switch (xmesa->pixelformat) {
case PF_INDEX:
- ctx->Driver.WriteCI32Span = write_span_index_pixmap;
- ctx->Driver.WriteCI8Span = write_span_index8_pixmap;
- ctx->Driver.WriteMonoCISpan = write_span_mono_pixmap;
- ctx->Driver.WriteCI32Pixels = write_pixels_index_pixmap;
- ctx->Driver.WriteMonoCIPixels = write_pixels_mono_pixmap;
+ dd->WriteCI32Span = write_span_index_pixmap;
+ dd->WriteCI8Span = write_span_index8_pixmap;
+ dd->WriteMonoCISpan = write_span_mono_index_pixmap;
+ dd->WriteCI32Pixels = write_pixels_index_pixmap;
+ dd->WriteMonoCIPixels = write_pixels_mono_index_pixmap;
break;
case PF_TRUECOLOR:
- ctx->Driver.WriteRGBASpan = write_span_TRUECOLOR_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_TRUECOLOR_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_TRUECOLOR_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ dd->WriteRGBASpan = write_span_TRUECOLOR_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_TRUECOLOR_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_TRUECOLOR_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
break;
case PF_TRUEDITHER:
- ctx->Driver.WriteRGBASpan = write_span_TRUEDITHER_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_TRUEDITHER_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_TRUEDITHER_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
+ dd->WriteRGBASpan = write_span_TRUEDITHER_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_TRUEDITHER_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
+ dd->WriteRGBAPixels = write_pixels_TRUEDITHER_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
break;
case PF_8A8B8G8R:
- ctx->Driver.WriteRGBASpan = write_span_8A8B8G8R_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_8A8B8G8R_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_8A8B8G8R_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ dd->WriteRGBASpan = write_span_8A8B8G8R_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8A8B8G8R_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8A8B8G8R_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
break;
case PF_8R8G8B:
- ctx->Driver.WriteRGBASpan = write_span_8R8G8B_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_8R8G8B_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_8R8G8B_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_pixmap;
- ctx->Driver.DrawPixels = NULL; /*drawpixels_8R8G8B;*/
+ dd->WriteRGBASpan = write_span_8R8G8B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
break;
case PF_8R8G8B24:
- ctx->Driver.WriteRGBASpan = write_span_8R8G8B24_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_8R8G8B24_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_8R8G8B24_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ dd->WriteRGBASpan = write_span_8R8G8B24_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B24_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B24_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
break;
case PF_5R6G5B:
- ctx->Driver.WriteRGBASpan = write_span_5R6G5B_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_5R6G5B_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_5R6G5B_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ dd->WriteRGBASpan = write_span_5R6G5B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_5R6G5B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_5R6G5B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
break;
case PF_DITHER_5R6G5B:
- ctx->Driver.WriteRGBASpan = write_span_DITHER_5R6G5B_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_DITHER_5R6G5B_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
+ dd->WriteRGBASpan = write_span_DITHER_5R6G5B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
+ dd->WriteRGBAPixels = write_pixels_DITHER_5R6G5B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
break;
case PF_DITHER:
- ctx->Driver.WriteRGBASpan = write_span_DITHER_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_DITHER_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_DITHER_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_DITHER_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_DITHER_pixmap;
+ dd->WriteRGBASpan = write_span_DITHER_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER_pixmap;
+ dd->WriteRGBAPixels = write_pixels_DITHER_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_pixmap;
break;
case PF_1BIT:
- ctx->Driver.WriteRGBASpan = write_span_1BIT_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_1BIT_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_1BIT_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_1BIT_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_1BIT_pixmap;
+ dd->WriteRGBASpan = write_span_1BIT_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_1BIT_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_1BIT_pixmap;
+ dd->WriteRGBAPixels = write_pixels_1BIT_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_1BIT_pixmap;
break;
case PF_HPCR:
- ctx->Driver.WriteRGBASpan = write_span_HPCR_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_HPCR_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_HPCR_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ dd->WriteRGBASpan = write_span_HPCR_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_HPCR_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_HPCR_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
if (xmesa->xm_visual->hpcr_clear_flag) {
- ctx->Driver.ClearColor = clear_color_HPCR_pixmap;
+ ctx->Driver.ClearColor = clear_color_HPCR_pixmap;
}
break;
case PF_LOOKUP:
- ctx->Driver.WriteRGBASpan = write_span_LOOKUP_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_LOOKUP_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_LOOKUP_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ dd->WriteRGBASpan = write_span_LOOKUP_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_LOOKUP_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_LOOKUP_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
break;
case PF_GRAYSCALE:
- ctx->Driver.WriteRGBASpan = write_span_GRAYSCALE_pixmap;
- ctx->Driver.WriteRGBSpan = write_span_rgb_GRAYSCALE_pixmap;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_pixmap;
- ctx->Driver.WriteRGBAPixels = write_pixels_GRAYSCALE_pixmap;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ dd->WriteRGBASpan = write_span_GRAYSCALE_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_GRAYSCALE_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_GRAYSCALE_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
break;
default:
- gl_problem(NULL,"Bad pixel format in xmesa_update_state (1)");
+ _mesa_problem(NULL,"Bad pixel format in xmesa_update_state (1)");
return;
}
}
@@ -5272,226 +4353,141 @@ static void update_span_funcs( GLcontext *ctx )
/* Writing to back XImage */
switch (xmesa->pixelformat) {
case PF_INDEX:
- ctx->Driver.WriteCI32Span = write_span_index_ximage;
+ dd->WriteCI32Span = write_span_index_ximage;
if (depth==8)
- ctx->Driver.WriteCI8Span = write_span_index8_ximage8;
+ dd->WriteCI8Span = write_span_index8_ximage8;
else
- ctx->Driver.WriteCI8Span = write_span_index8_ximage;
- ctx->Driver.WriteMonoCISpan = write_span_mono_ximage;
- ctx->Driver.WriteCI32Pixels = write_pixels_index_ximage;
- ctx->Driver.WriteMonoCIPixels = write_pixels_mono_ximage;
+ dd->WriteCI8Span = write_span_index8_ximage;
+ dd->WriteMonoCISpan = write_span_mono_index_ximage;
+ dd->WriteCI32Pixels = write_pixels_index_ximage;
+ dd->WriteMonoCIPixels = write_pixels_mono_index_ximage;
break;
case PF_TRUECOLOR:
/* Generic RGB */
- ctx->Driver.WriteRGBASpan = write_span_TRUECOLOR_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_TRUECOLOR_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_TRUECOLOR_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_ximage;
+ dd->WriteRGBASpan = write_span_TRUECOLOR_ximage;
+ dd->WriteRGBSpan = write_span_rgb_TRUECOLOR_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_TRUECOLOR_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
break;
case PF_TRUEDITHER:
- ctx->Driver.WriteRGBASpan = write_span_TRUEDITHER_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_TRUEDITHER_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_TRUEDITHER_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_TRUEDITHER_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_ximage;
+ dd->WriteRGBASpan = write_span_TRUEDITHER_ximage;
+ dd->WriteRGBSpan = write_span_rgb_TRUEDITHER_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_ximage;
+ dd->WriteRGBAPixels = write_pixels_TRUEDITHER_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_ximage;
break;
case PF_8A8B8G8R:
- ctx->Driver.WriteRGBASpan = write_span_8A8B8G8R_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_8A8B8G8R_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_8A8B8G8R_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_8A8B8G8R_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_8A8B8G8R_ximage;
+ dd->WriteRGBASpan = write_span_8A8B8G8R_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8A8B8G8R_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8A8B8G8R_ximage;
+ dd->WriteRGBAPixels = write_pixels_8A8B8G8R_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8A8B8G8R_ximage;
break;
case PF_8R8G8B:
- ctx->Driver.WriteRGBASpan = write_span_8R8G8B_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_8R8G8B_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_8R8G8B_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_8R8G8B_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_8R8G8B_ximage;
- ctx->Driver.DrawPixels = NULL;
+ dd->WriteRGBASpan = write_span_8R8G8B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8R8G8B_ximage;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8R8G8B_ximage;
break;
case PF_8R8G8B24:
- ctx->Driver.WriteRGBASpan = write_span_8R8G8B24_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_8R8G8B24_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_8R8G8B24_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_8R8G8B24_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_8R8G8B24_ximage;
+ dd->WriteRGBASpan = write_span_8R8G8B24_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B24_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8R8G8B24_ximage;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B24_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8R8G8B24_ximage;
break;
case PF_5R6G5B:
- ctx->Driver.WriteRGBASpan = write_span_5R6G5B_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_5R6G5B_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_5R6G5B_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_ximage;
+ dd->WriteRGBASpan = write_span_5R6G5B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_5R6G5B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_5R6G5B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
break;
case PF_DITHER_5R6G5B:
- ctx->Driver.WriteRGBASpan = write_span_DITHER_5R6G5B_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_DITHER_5R6G5B_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_DITHER_5R6G5B_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_DITHER_5R6G5B_ximage;
+ dd->WriteRGBASpan = write_span_DITHER_5R6G5B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER_5R6G5B_ximage;
+ dd->WriteRGBAPixels = write_pixels_DITHER_5R6G5B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_5R6G5B_ximage;
break;
case PF_DITHER:
if (depth==8) {
- ctx->Driver.WriteRGBASpan = write_span_DITHER8_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_DITHER8_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_DITHER8_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_DITHER8_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_DITHER8_ximage;
+ dd->WriteRGBASpan = write_span_DITHER8_ximage;
+ dd->WriteRGBSpan = write_span_rgb_DITHER8_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER8_ximage;
+ dd->WriteRGBAPixels = write_pixels_DITHER8_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER8_ximage;
}
else {
- ctx->Driver.WriteRGBASpan = write_span_DITHER_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_DITHER_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_DITHER_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_DITHER_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_DITHER_ximage;
+ dd->WriteRGBASpan = write_span_DITHER_ximage;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER_ximage;
+ dd->WriteRGBAPixels = write_pixels_DITHER_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_ximage;
}
break;
case PF_1BIT:
- ctx->Driver.WriteRGBASpan = write_span_1BIT_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_1BIT_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_1BIT_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_1BIT_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_1BIT_ximage;
+ dd->WriteRGBASpan = write_span_1BIT_ximage;
+ dd->WriteRGBSpan = write_span_rgb_1BIT_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_1BIT_ximage;
+ dd->WriteRGBAPixels = write_pixels_1BIT_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_1BIT_ximage;
break;
case PF_HPCR:
- ctx->Driver.WriteRGBASpan = write_span_HPCR_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_HPCR_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_HPCR_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_HPCR_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_HPCR_ximage;
+ dd->WriteRGBASpan = write_span_HPCR_ximage;
+ dd->WriteRGBSpan = write_span_rgb_HPCR_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_HPCR_ximage;
+ dd->WriteRGBAPixels = write_pixels_HPCR_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_HPCR_ximage;
if (xmesa->xm_visual->hpcr_clear_flag) {
ctx->Driver.ClearColor = clear_color_HPCR_ximage;
}
break;
case PF_LOOKUP:
if (depth==8) {
- ctx->Driver.WriteRGBASpan = write_span_LOOKUP8_ximage;
- ctx->Driver.WriteRGBSpan = write_rgb_LOOKUP8_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_LOOKUP8_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_LOOKUP8_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_LOOKUP8_ximage;
+ dd->WriteRGBASpan = write_span_LOOKUP8_ximage;
+ dd->WriteRGBSpan = write_rgb_LOOKUP8_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_LOOKUP8_ximage;
+ dd->WriteRGBAPixels = write_pixels_LOOKUP8_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_LOOKUP8_ximage;
}
else {
- ctx->Driver.WriteRGBASpan = write_span_LOOKUP_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_LOOKUP_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_LOOKUP_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_ximage;
+ dd->WriteRGBASpan = write_span_LOOKUP_ximage;
+ dd->WriteRGBSpan = write_span_rgb_LOOKUP_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_LOOKUP_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
}
break;
case PF_GRAYSCALE:
if (depth==8) {
- ctx->Driver.WriteRGBASpan = write_span_GRAYSCALE8_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_GRAYSCALE8_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_GRAYSCALE8_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_GRAYSCALE8_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_GRAYSCALE8_ximage;
+ dd->WriteRGBASpan = write_span_GRAYSCALE8_ximage;
+ dd->WriteRGBSpan = write_span_rgb_GRAYSCALE8_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_GRAYSCALE8_ximage;
+ dd->WriteRGBAPixels = write_pixels_GRAYSCALE8_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_GRAYSCALE8_ximage;
}
else {
- ctx->Driver.WriteRGBASpan = write_span_GRAYSCALE_ximage;
- ctx->Driver.WriteRGBSpan = write_span_rgb_GRAYSCALE_ximage;
- ctx->Driver.WriteMonoRGBASpan = write_span_mono_ximage;
- ctx->Driver.WriteRGBAPixels = write_pixels_GRAYSCALE_ximage;
- ctx->Driver.WriteMonoRGBAPixels = write_pixels_mono_ximage;
+ dd->WriteRGBASpan = write_span_GRAYSCALE_ximage;
+ dd->WriteRGBSpan = write_span_rgb_GRAYSCALE_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_GRAYSCALE_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
}
break;
default:
- gl_problem(NULL,"Bad pixel format in xmesa_update_state (2)");
+ _mesa_problem(NULL,"Bad pixel format in xmesa_update_state (2)");
return;
}
}
/* Pixel/span reading functions: */
- ctx->Driver.ReadCI32Span = read_index_span;
- ctx->Driver.ReadRGBASpan = read_color_span;
- ctx->Driver.ReadCI32Pixels = read_index_pixels;
- ctx->Driver.ReadRGBAPixels = read_color_pixels;
-}
-
-
-/*
- * Initialize all the DD.* function pointers depending on the color
- * buffer configuration. This is mainly called by XMesaMakeCurrent.
- */
-void xmesa_update_state( GLcontext *ctx )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- /*int depth=GET_VISUAL_DEPTH(xmesa->xm_visual);*/
-
- (void) DitherValues; /* silenced unused var warning */
-#ifndef XFree86Server
- (void) drawpixels_8R8G8B;
-#endif
-
- /*
- * Always the same:
- */
- ctx->Driver.GetString = get_string;
- ctx->Driver.UpdateState = xmesa_update_state;
- ctx->Driver.GetBufferSize = get_buffer_size;
- ctx->Driver.Flush = flush;
- ctx->Driver.Finish = finish;
-
- ctx->Driver.RenderStart = 0;
- ctx->Driver.RenderFinish = 0;
-
- ctx->Driver.SetDrawBuffer = set_draw_buffer;
- ctx->Driver.SetReadBuffer = set_read_buffer;
-
- ctx->Driver.Index = set_index;
- ctx->Driver.Color = set_color;
- ctx->Driver.ClearIndex = clear_index;
- ctx->Driver.ClearColor = clear_color;
- ctx->Driver.Clear = clear_buffers;
- ctx->Driver.IndexMask = index_mask;
- ctx->Driver.ColorMask = color_mask;
- ctx->Driver.LogicOp = logicop;
- ctx->Driver.Dither = dither;
-
- ctx->Driver.PointsFunc = xmesa_get_points_func( ctx );
- ctx->Driver.LineFunc = xmesa_get_line_func( ctx );
- ctx->Driver.TriangleFunc = xmesa_get_triangle_func( ctx );
-
-/* ctx->Driver.TriangleCaps = DD_TRI_CULL; */
-
- /* setup pointers to front and back buffer clear functions */
- /* XXX this bit of code could be moved to a one-time init */
- xmesa->xm_buffer->front_clear_func = clear_front_pixmap;
- if (xmesa->xm_buffer->backpixmap != XIMAGE) {
- /* back buffer is a pixmap */
- xmesa->xm_buffer->back_clear_func = clear_back_pixmap;
- }
- else if (sizeof(GLushort)!=2 || sizeof(GLuint)!=4) {
- /* Do this on Crays */
- xmesa->xm_buffer->back_clear_func = clear_nbit_ximage;
- }
- else {
- /* Do this on most machines */
- switch (xmesa->xm_visual->BitsPerPixel) {
- case 8:
- if (xmesa->xm_visual->hpcr_clear_flag) {
- xmesa->xm_buffer->back_clear_func = clear_HPCR_ximage;
- }
- else {
- xmesa->xm_buffer->back_clear_func = clear_8bit_ximage;
- }
- break;
- case 16:
- xmesa->xm_buffer->back_clear_func = clear_16bit_ximage;
- break;
- case 24:
- xmesa->xm_buffer->back_clear_func = clear_24bit_ximage;
- break;
- case 32:
- xmesa->xm_buffer->back_clear_func = clear_32bit_ximage;
- break;
- default:
- xmesa->xm_buffer->back_clear_func = clear_nbit_ximage;
- break;
- }
- }
+ dd->ReadCI32Span = read_index_span;
+ dd->ReadRGBASpan = read_color_span;
+ dd->ReadCI32Pixels = read_index_pixels;
+ dd->ReadRGBAPixels = read_color_pixels;
- update_span_funcs(ctx);
+ dd->SetReadBuffer = xmesa_set_read_buffer;
}
diff --git a/xc/extras/Mesa/src/X/xm_tri.c b/xc/extras/Mesa/src/X/xm_tri.c
new file mode 100644
index 000000000..8aa92f0f0
--- /dev/null
+++ b/xc/extras/Mesa/src/X/xm_tri.c
@@ -0,0 +1,1704 @@
+/* $Id: xm_tri.c,v 1.2 2002/02/14 01:59:36 dawes Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ *
+ * 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
+ * BRIAN PAUL 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.
+ */
+
+
+/*
+ * This file contains "accelerated" triangle functions. It should be
+ * fairly easy to write new special-purpose triangle functions and hook
+ * them into this module.
+ */
+
+
+#include "glxheader.h"
+#include "depth.h"
+#include "macros.h"
+#include "mmath.h"
+#include "mtypes.h"
+#include "xmesaP.h"
+
+/* Internal swrast includes:
+ */
+#include "swrast/s_context.h"
+#include "swrast/s_depth.h"
+#include "swrast/s_triangle.h"
+#include "swrast/s_trispan.h"
+
+
+
+/**********************************************************************/
+/*** Triangle rendering ***/
+/**********************************************************************/
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
+ */
+static void smooth_TRUECOLOR_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+
+#define RENDER_SPAN( span ) \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLuint i; \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p; \
+ PACK_TRUECOLOR(p, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(img, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
+ */
+static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
+ */
+static void smooth_8R8G8B_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
+ */
+static void smooth_8R8G8B24_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ PIXEL_TYPE *ptr = pRow + i; \
+ ptr->r = FixedToInt(span.red); \
+ ptr->g = FixedToInt(span.green); \
+ ptr->b = FixedToInt(span.blue); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
+ */
+static void smooth_TRUEDITHER_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p; \
+ PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(img, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
+ */
+static void smooth_5R6G5B_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = PACK_5R6G5B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
+ */
+static void smooth_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
+ */
+static void smooth_DITHER8_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ XDITHER_SETUP(y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red),\
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_DITHER triangle.
+ */
+static void smooth_DITHER_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ XDITHER_SETUP(y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p = XDITHER(x, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(img, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
+ */
+static void smooth_LOOKUP8_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ LOOKUP_SETUP; \
+ for (i = 0; i < span.count; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = LOOKUP(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+
+/*
+ * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
+ */
+static void smooth_HPCR_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
+ */
+static void flat_TRUECOLOR_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define SETUP_CODE \
+ unsigned long pixel; \
+ PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ XMesaPutPixel(img, x, y, pixel); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
+ */
+static void flat_8A8B8G8R_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ unsigned long p = PACK_8B8G8R( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, PF_8R8G8B triangle.
+ */
+static void flat_8R8G8B_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ unsigned long p = PACK_8R8G8B( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
+ */
+static void flat_8R8G8B24_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte *color = v2->color;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ PIXEL_TYPE *ptr = pRow + i; \
+ ptr->r = color[RCOMP]; \
+ ptr->g = color[GCOMP]; \
+ ptr->b = color[BCOMP]; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
+ */
+static void flat_TRUEDITHER_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p; \
+ PACK_TRUEDITHER(p, x, y, v2->color[0], \
+ v2->color[1], v2->color[2]); \
+ XMesaPutPixel(img, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, PF_5R6G5B triangle.
+ */
+static void flat_5R6G5B_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ unsigned long p = PACK_5R6G5B( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
+ */
+static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte *color = v2->color;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
+ color[GCOMP], color[BCOMP]); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
+ */
+static void flat_DITHER8_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, PF_DITHER triangle.
+ */
+static void flat_DITHER_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define SETUP_CODE \
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ FLAT_DITHER_ROW_SETUP(y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p = FLAT_DITHER(x); \
+ XMesaPutPixel(img, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
+ */
+static void flat_HPCR_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2];
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
+ */
+static void flat_LOOKUP8_z_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ LOOKUP_SETUP; \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2]; \
+ GLubyte p = LOOKUP(r,g,b);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = p; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
+ */
+static void smooth_TRUECOLOR_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define INTERP_RGB 1
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ unsigned long p; \
+ PACK_TRUECOLOR(p, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(img, x, y, p); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
+ */
+static void smooth_8A8B8G8R_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ } \
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
+ */
+static void smooth_8R8G8B_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
+ */
+static void smooth_8R8G8B24_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ PIXEL_TYPE *pixel = pRow; \
+ for (i = 0; i < span.count; i++, pixel++) { \
+ pixel->r = FixedToInt(span.red); \
+ pixel->g = FixedToInt(span.green); \
+ pixel->b = FixedToInt(span.blue); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
+ */
+static void smooth_TRUEDITHER_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define INTERP_RGB 1
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ unsigned long p; \
+ PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(img, x, y, p ); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
+ */
+static void smooth_5R6G5B_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ pRow[i] = (PIXEL_TYPE) PACK_5R6G5B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
+ */
+static void smooth_DITHER_5R6G5B_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
+ */
+static void smooth_DITHER8_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ XDITHER_SETUP(y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
+ */
+static void smooth_DITHER_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+
+#define INTERP_RGB 1
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ XDITHER_SETUP(y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ unsigned long p = XDITHER(x, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ XMesaPutPixel(img, x, y, p); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
+ */
+static void smooth_LOOKUP8_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ LOOKUP_SETUP; \
+ for (i = 0; i < span.count; i++) { \
+ pRow[i] = LOOKUP(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue));\
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
+ */
+static void smooth_HPCR_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
+ */
+static void flat_TRUECOLOR_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define SETUP_CODE \
+ unsigned long pixel; \
+ PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ XMesaPutPixel(img, x, y, pixel); \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
+ */
+static void flat_8A8B8G8R_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ unsigned long p = PACK_8B8G8R( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
+ */
+static void flat_8R8G8B_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ unsigned long p = PACK_8R8G8B( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
+ */
+static void flat_8R8G8B24_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte *color = v2->color;
+#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ PIXEL_TYPE *pixel = pRow; \
+ for (i = 0; i < span.count; i++, pixel++) { \
+ pixel->r = color[RCOMP]; \
+ pixel->g = color[GCOMP]; \
+ pixel->b = color[BCOMP]; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
+ */
+static void flat_TRUEDITHER_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ unsigned long p; \
+ PACK_TRUEDITHER(p, x, y, v2->color[0], \
+ v2->color[1], v2->color[2] ); \
+ XMesaPutPixel(img, x, y, p); \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
+ */
+static void flat_5R6G5B_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ unsigned long p = PACK_5R6G5B( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
+ */
+static void flat_DITHER_5R6G5B_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ const GLubyte *color = v2->color;
+#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
+ color[GCOMP], color[BCOMP]); \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
+ */
+static void flat_DITHER8_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
+ for (i = 0; i < span.count; i++, x++) { \
+ pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
+ */
+static void flat_DITHER_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ XMesaImage *img = xmesa->xm_buffer->backimage;
+#define SETUP_CODE \
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ FLAT_DITHER_ROW_SETUP(y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ unsigned long p = FLAT_DITHER(x); \
+ XMesaPutPixel(img, x, y, p ); \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
+ */
+static void flat_HPCR_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2];
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ for (i = 0; i < span.count; i++, x++) { \
+ pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+/*
+ * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
+ */
+static void flat_LOOKUP8_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define SETUP_CODE \
+ LOOKUP_SETUP; \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2]; \
+ GLubyte p = LOOKUP(r,g,b);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.count; i++) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ }
+
+#include "swrast/s_tritemp.h"
+}
+
+
+#ifdef DEBUG
+extern void _xmesa_print_triangle_func( swrast_tri_func triFunc );
+void _xmesa_print_triangle_func( swrast_tri_func triFunc )
+{
+ printf("XMesa tri func = ");
+ if (triFunc ==smooth_TRUECOLOR_z_triangle)
+ printf("smooth_TRUECOLOR_z_triangle\n");
+ else if (triFunc ==smooth_8A8B8G8R_z_triangle)
+ printf("smooth_8A8B8G8R_z_triangle\n");
+ else if (triFunc ==smooth_8R8G8B_z_triangle)
+ printf("smooth_8R8G8B_z_triangle\n");
+ else if (triFunc ==smooth_8R8G8B24_z_triangle)
+ printf("smooth_8R8G8B24_z_triangle\n");
+ else if (triFunc ==smooth_TRUEDITHER_z_triangle)
+ printf("smooth_TRUEDITHER_z_triangle\n");
+ else if (triFunc ==smooth_5R6G5B_z_triangle)
+ printf("smooth_5R6G5B_z_triangle\n");
+ else if (triFunc ==smooth_DITHER_5R6G5B_z_triangle)
+ printf("smooth_DITHER_5R6G5B_z_triangle\n");
+ else if (triFunc ==smooth_HPCR_z_triangle)
+ printf("smooth_HPCR_z_triangle\n");
+ else if (triFunc ==smooth_DITHER8_z_triangle)
+ printf("smooth_DITHER8_z_triangle\n");
+ else if (triFunc ==smooth_LOOKUP8_z_triangle)
+ printf("smooth_LOOKUP8_z_triangle\n");
+ else if (triFunc ==flat_TRUECOLOR_z_triangle)
+ printf("flat_TRUECOLOR_z_triangle\n");
+ else if (triFunc ==flat_8A8B8G8R_z_triangle)
+ printf("flat_8A8B8G8R_z_triangle\n");
+ else if (triFunc ==flat_8R8G8B_z_triangle)
+ printf("flat_8R8G8B_z_triangle\n");
+ else if (triFunc ==flat_8R8G8B24_z_triangle)
+ printf("flat_8R8G8B24_z_triangle\n");
+ else if (triFunc ==flat_TRUEDITHER_z_triangle)
+ printf("flat_TRUEDITHER_z_triangle\n");
+ else if (triFunc ==flat_5R6G5B_z_triangle)
+ printf("flat_5R6G5B_z_triangle\n");
+ else if (triFunc ==flat_DITHER_5R6G5B_z_triangle)
+ printf("flat_DITHER_5R6G5B_z_triangle\n");
+ else if (triFunc ==flat_HPCR_z_triangle)
+ printf("flat_HPCR_z_triangle\n");
+ else if (triFunc ==flat_DITHER8_z_triangle)
+ printf("flat_DITHER8_z_triangle\n");
+ else if (triFunc ==flat_LOOKUP8_z_triangle)
+ printf("flat_LOOKUP8_z_triangle\n");
+ else if (triFunc ==smooth_TRUECOLOR_triangle)
+ printf("smooth_TRUECOLOR_triangle\n");
+ else if (triFunc ==smooth_8A8B8G8R_triangle)
+ printf("smooth_8A8B8G8R_triangle\n");
+ else if (triFunc ==smooth_8R8G8B_triangle)
+ printf("smooth_8R8G8B_triangle\n");
+ else if (triFunc ==smooth_8R8G8B24_triangle)
+ printf("smooth_8R8G8B24_triangle\n");
+ else if (triFunc ==smooth_TRUEDITHER_triangle)
+ printf("smooth_TRUEDITHER_triangle\n");
+ else if (triFunc ==smooth_5R6G5B_triangle)
+ printf("smooth_5R6G5B_triangle\n");
+ else if (triFunc ==smooth_DITHER_5R6G5B_triangle)
+ printf("smooth_DITHER_5R6G5B_triangle\n");
+ else if (triFunc ==smooth_HPCR_triangle)
+ printf("smooth_HPCR_triangle\n");
+ else if (triFunc ==smooth_DITHER8_triangle)
+ printf("smooth_DITHER8_triangle\n");
+ else if (triFunc ==smooth_LOOKUP8_triangle)
+ printf("smooth_LOOKUP8_triangle\n");
+ else if (triFunc ==flat_TRUECOLOR_triangle)
+ printf("flat_TRUECOLOR_triangle\n");
+ else if (triFunc ==flat_TRUEDITHER_triangle)
+ printf("flat_TRUEDITHER_triangle\n");
+ else if (triFunc ==flat_8A8B8G8R_triangle)
+ printf("flat_8A8B8G8R_triangle\n");
+ else if (triFunc ==flat_8R8G8B_triangle)
+ printf("flat_8R8G8B_triangle\n");
+ else if (triFunc ==flat_8R8G8B24_triangle)
+ printf("flat_8R8G8B24_triangle\n");
+ else if (triFunc ==flat_5R6G5B_triangle)
+ printf("flat_5R6G5B_triangle\n");
+ else if (triFunc ==flat_DITHER_5R6G5B_triangle)
+ printf("flat_DITHER_5R6G5B_triangle\n");
+ else if (triFunc ==flat_HPCR_triangle)
+ printf("flat_HPCR_triangle\n");
+ else if (triFunc ==flat_DITHER8_triangle)
+ printf("flat_DITHER8_triangle\n");
+ else if (triFunc ==flat_LOOKUP8_triangle)
+ printf("flat_LOOKUP8_triangle\n");
+ else
+ printf("???\n");
+}
+#endif
+
+
+#ifdef DEBUG
+
+/* record the current triangle function name */
+static const char *triFuncName = NULL;
+
+#define USE(triFunc) \
+do { \
+ triFuncName = #triFunc; \
+ /*printf("%s\n", triFuncName);*/ \
+ return triFunc; \
+} while (0)
+
+#else
+
+#define USE(triFunc) return triFunc
+
+#endif
+
+
+static swrast_tri_func get_triangle_func( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+
+ (void) kernel1;
+
+#ifdef DEBUG
+ triFuncName = NULL;
+#endif
+
+ if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
+ if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
+ if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;
+
+ if (xmesa->xm_buffer->buffer==XIMAGE) {
+ if ( ctx->Light.ShadeModel==GL_SMOOTH
+ && swrast->_RasterMask==DEPTH_BIT
+ && ctx->Depth.Func==GL_LESS
+ && ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ switch (xmesa->pixelformat) {
+ case PF_TRUECOLOR:
+ USE(smooth_TRUECOLOR_z_triangle);
+ case PF_8A8B8G8R:
+ USE(smooth_8A8B8G8R_z_triangle);
+ case PF_8R8G8B:
+ USE(smooth_8R8G8B_z_triangle);
+ case PF_8R8G8B24:
+ USE(smooth_8R8G8B24_z_triangle);
+ case PF_TRUEDITHER:
+ USE(smooth_TRUEDITHER_z_triangle);
+ case PF_5R6G5B:
+ USE(smooth_5R6G5B_z_triangle);
+ case PF_DITHER_5R6G5B:
+ USE(smooth_DITHER_5R6G5B_z_triangle);
+ case PF_HPCR:
+ USE(smooth_HPCR_z_triangle);
+ case PF_DITHER:
+ if (depth == 8)
+ USE(smooth_DITHER8_z_triangle);
+ else
+ USE(smooth_DITHER_z_triangle);
+ break;
+ case PF_LOOKUP:
+ if (depth == 8)
+ USE(smooth_LOOKUP8_z_triangle);
+ else
+ return (swrast_tri_func) NULL;
+ default:
+ return (swrast_tri_func) NULL;
+ }
+ }
+ if ( ctx->Light.ShadeModel==GL_FLAT
+ && swrast->_RasterMask==DEPTH_BIT
+ && ctx->Depth.Func==GL_LESS
+ && ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ switch (xmesa->pixelformat) {
+ case PF_TRUECOLOR:
+ USE(flat_TRUECOLOR_z_triangle);
+ case PF_8A8B8G8R:
+ USE(flat_8A8B8G8R_z_triangle);
+ case PF_8R8G8B:
+ USE(flat_8R8G8B_z_triangle);
+ case PF_8R8G8B24:
+ USE(flat_8R8G8B24_z_triangle);
+ case PF_TRUEDITHER:
+ USE(flat_TRUEDITHER_z_triangle);
+ case PF_5R6G5B:
+ USE(flat_5R6G5B_z_triangle);
+ case PF_DITHER_5R6G5B:
+ USE(flat_DITHER_5R6G5B_z_triangle);
+ case PF_HPCR:
+ USE(flat_HPCR_z_triangle);
+ case PF_DITHER:
+ if (depth == 8)
+ USE(flat_DITHER8_z_triangle);
+ else
+ USE(flat_DITHER_z_triangle);
+ break;
+ case PF_LOOKUP:
+ if (depth == 8)
+ USE(flat_LOOKUP8_z_triangle);
+ else
+ return (swrast_tri_func) NULL;
+ default:
+ return (swrast_tri_func) NULL;
+ }
+ }
+ if ( swrast->_RasterMask==0 /* no depth test */
+ && ctx->Light.ShadeModel==GL_SMOOTH
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ switch (xmesa->pixelformat) {
+ case PF_TRUECOLOR:
+ USE(smooth_TRUECOLOR_triangle);
+ case PF_8A8B8G8R:
+ USE(smooth_8A8B8G8R_triangle);
+ case PF_8R8G8B:
+ USE(smooth_8R8G8B_triangle);
+ case PF_8R8G8B24:
+ USE(smooth_8R8G8B24_triangle);
+ case PF_TRUEDITHER:
+ USE(smooth_TRUEDITHER_triangle);
+ case PF_5R6G5B:
+ USE(smooth_5R6G5B_triangle);
+ case PF_DITHER_5R6G5B:
+ USE(smooth_DITHER_5R6G5B_triangle);
+ case PF_HPCR:
+ USE(smooth_HPCR_triangle);
+ case PF_DITHER:
+ if (depth == 8)
+ USE(smooth_DITHER8_triangle);
+ else
+ USE(smooth_DITHER_triangle);
+ break;
+ case PF_LOOKUP:
+ if (depth == 8)
+ USE(smooth_LOOKUP8_triangle);
+ else
+ return (swrast_tri_func) NULL;
+ default:
+ return (swrast_tri_func) NULL;
+ }
+ }
+
+ if ( swrast->_RasterMask==0 /* no depth test */
+ && ctx->Light.ShadeModel==GL_FLAT
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ switch (xmesa->pixelformat) {
+ case PF_TRUECOLOR:
+ USE(flat_TRUECOLOR_triangle);
+ case PF_TRUEDITHER:
+ USE(flat_TRUEDITHER_triangle);
+ case PF_8A8B8G8R:
+ USE(flat_8A8B8G8R_triangle);
+ case PF_8R8G8B:
+ USE(flat_8R8G8B_triangle);
+ case PF_8R8G8B24:
+ USE(flat_8R8G8B24_triangle);
+ case PF_5R6G5B:
+ USE(flat_5R6G5B_triangle);
+ case PF_DITHER_5R6G5B:
+ USE(flat_DITHER_5R6G5B_triangle);
+ case PF_HPCR:
+ USE(flat_HPCR_triangle);
+ case PF_DITHER:
+ if (depth == 8)
+ USE(flat_DITHER8_triangle);
+ else
+ USE(flat_DITHER_triangle);
+ break;
+ case PF_LOOKUP:
+ if (depth == 8)
+ USE(flat_LOOKUP8_triangle);
+ else
+ return (swrast_tri_func) NULL;
+ default:
+ return (swrast_tri_func) NULL;
+ }
+ }
+
+ return (swrast_tri_func) NULL;
+ }
+ else {
+ /* draw to pixmap */
+ return (swrast_tri_func) NULL;
+ }
+}
+
+
+/* Override for the swrast tri-selection function. Try to use one
+ * of our internal tri functions, otherwise fall back to the
+ * standard swrast functions.
+ */
+void xmesa_choose_triangle( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (!(swrast->Triangle = get_triangle_func( ctx )))
+ _swrast_choose_triangle( ctx );
+}
+
diff --git a/xc/extras/Mesa/src/X/xmesa4.c b/xc/extras/Mesa/src/X/xmesa4.c
deleted file mode 100644
index c4978f428..000000000
--- a/xc/extras/Mesa/src/X/xmesa4.c
+++ /dev/null
@@ -1,1695 +0,0 @@
-/* $XFree86: xc/extras/Mesa/src/X/xmesa4.c,v 1.10 2001/12/11 09:18:55 alanh Exp $ */
-/*
- * Mesa 3-D graphics library
- * Version: 3.4
- *
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
- * 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
- * BRIAN PAUL 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.
- */
-
-
-/*
- * Mesa/X11 interface, part 4.
- *
- * This file contains "accelerated" triangle functions. It should be
- * fairly easy to write new special-purpose triangle functions and hook
- * them into this module.
- */
-
-
-#include "glxheader.h"
-#include "depth.h"
-#include "macros.h"
-#include "mmath.h"
-#include "vb.h"
-#include "types.h"
-#include "xmesaP.h"
-
-
-
-
-/**********************************************************************/
-/*** Triangle rendering ***/
-/**********************************************************************/
-
-#if 0
-/*
- * Render a triangle into a pixmap, any pixel format, flat shaded and
- * no raster ops.
- */
-static void flat_pixmap_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- struct vertex_buffer *VB = ctx->VB;
- XMesaPoint p[3];
- XMesaGC gc;
-
- if (0 /*VB->MonoColor*/) {
- gc = xmesa->xm_buffer->gc1; /* use current color */
- }
- else {
- unsigned long pixel;
- if (xmesa->xm_visual->gl_visual->RGBAflag) {
- pixel = xmesa_color_to_pixel( xmesa,
- VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1],
- VB->ColorPtr->data[pv][2], VB->ColorPtr->data[pv][3],
- xmesa->pixelformat );
- }
- else {
- pixel = VB->IndexPtr->data[pv];
- }
- gc = xmesa->xm_buffer->gc2;
- XMesaSetForeground( xmesa->display, gc, pixel );
- }
- p[0].x = (GLint) (VB->Win.data[v0][0] + 0.5f);
- p[0].y = FLIP( xmesa->xm_buffer, (GLint) (VB->Win.data[v0][1] - 0.5f) );
- p[1].x = (GLint) (VB->Win.data[v1][0] + 0.5f);
- p[1].y = FLIP( xmesa->xm_buffer, (GLint) (VB->Win.data[v1][1] - 0.5f) );
- p[2].x = (GLint) (VB->Win.data[v2][0] + 0.5f);
- p[2].y = FLIP( xmesa->xm_buffer, (GLint) (VB->Win.data[v2][1] - 0.5f) );
- XMesaFillPolygon( xmesa->display, xmesa->xm_buffer->buffer, gc,
- p, 3, Convex, CoordModeOrigin );
-}
-#endif
-
-
-/*
- * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
- */
-static void smooth_TRUECOLOR_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer, Y); \
- GLint len = RIGHT-LEFT; \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- unsigned long p; \
- PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
- XMesaPutPixel( img, xx, yy, p ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-
-/*
- * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
- */
-static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
- */
-static void smooth_8R8G8B_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
- */
-static void smooth_8R8G8B24_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- PIXEL_TYPE *ptr = pRow + i; \
- ptr->r = FixedToInt(ffr); \
- ptr->g = FixedToInt(ffg); \
- ptr->b = FixedToInt(ffb); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
- */
-static void smooth_TRUEDITHER_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- unsigned long p; \
- PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- XMesaPutPixel( img, xx, yy, p ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
- */
-static void smooth_5R6G5B_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- DEPTH_TYPE z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = PACK_5R6G5B( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
- */
-static void smooth_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- PACK_TRUEDITHER(pRow[i], LEFT+i, Y, FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
- */
-static void smooth_DITHER8_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
- XDITHER_SETUP(yy); \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = (PIXEL_TYPE) XDITHER( xx, FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, depth-buffered, PF_DITHER triangle.
- */
-static void smooth_DITHER_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
- XDITHER_SETUP(yy); \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- unsigned long p = XDITHER( xx, FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- XMesaPutPixel( img, xx, yy, p ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
- */
-static void smooth_LOOKUP8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- LOOKUP_SETUP; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = LOOKUP( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-
-/*
- * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
- */
-static void smooth_HPCR_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = DITHER_HPCR( xx, yy, FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- zRow[i] = z; \
- } \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
- */
-static void flat_TRUECOLOR_z_triangle( GLcontext *ctx,
- GLuint v0, GLuint v1, GLuint v2,
- GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define SETUP_CODE \
- unsigned long pixel; \
- PACK_TRUECOLOR(pixel, VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2]);
-
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- XMesaPutPixel( img, xx, yy, pixel ); \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
- */
-static void flat_8A8B8G8R_z_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- unsigned long p = PACK_8B8G8R( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = (PIXEL_TYPE) p; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, PF_8R8G8B triangle.
- */
-static void flat_8R8G8B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- unsigned long p = PACK_8R8G8B( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = (PIXEL_TYPE) p; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
- */
-static void flat_8R8G8B24_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- PIXEL_TYPE *ptr = pRow+i; \
- ptr->r = color[RCOMP]; \
- ptr->g = color[GCOMP]; \
- ptr->b = color[BCOMP]; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
- */
-static void flat_TRUEDITHER_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- unsigned long p; \
- PACK_TRUEDITHER( p, xx, yy, VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] ); \
- XMesaPutPixel( img, xx, yy, p ); \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, PF_5R6G5B triangle.
- */
-static void flat_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- unsigned long p = PACK_5R6G5B( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- DEPTH_TYPE z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = (PIXEL_TYPE) p; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
- */
-static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- DEPTH_TYPE z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- PACK_TRUEDITHER(pRow[i], LEFT+i, Y, color[RCOMP], \
- color[GCOMP], color[BCOMP]); \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
- */
-static void flat_DITHER8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- FLAT_DITHER_SETUP( VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, len = RIGHT-LEFT; \
- FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = (PIXEL_TYPE) FLAT_DITHER(xx); \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, PF_DITHER triangle.
- */
-static void flat_DITHER_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define SETUP_CODE \
- FLAT_DITHER_SETUP( VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
- FLAT_DITHER_ROW_SETUP(yy); \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- unsigned long p = FLAT_DITHER(xx); \
- XMesaPutPixel( img, xx, yy, p ); \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
- */
-static void flat_HPCR_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- GLubyte r = VB->ColorPtr->data[pv][0]; \
- GLubyte g = VB->ColorPtr->data[pv][1]; \
- GLubyte b = VB->ColorPtr->data[pv][2];
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
- for (i=0;i<len;i++,xx++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
- */
-static void flat_LOOKUP8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define INTERP_Z 1
-#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- LOOKUP_SETUP; \
- GLubyte r = VB->ColorPtr->data[pv][0]; \
- GLubyte g = VB->ColorPtr->data[pv][1]; \
- GLubyte b = VB->ColorPtr->data[pv][2]; \
- GLubyte p = LOOKUP(r,g,b);
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint i, len = RIGHT-LEFT; \
- for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
- if (z < zRow[i]) { \
- pRow[i] = p; \
- zRow[i] = z; \
- } \
- ffz += fdzdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-
-/*
- * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
- */
-static void smooth_TRUECOLOR_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
- (void) pv;
-#define INTERP_RGB 1
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
- for (xx=LEFT;xx<RIGHT;xx++) { \
- unsigned long p; \
- PACK_TRUECOLOR(p, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb));\
- XMesaPutPixel( img, xx, yy, p ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
- */
-static void smooth_8A8B8G8R_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = PACK_8B8G8R( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
- */
-static void smooth_8R8G8B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = PACK_8R8G8B( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
- */
-static void smooth_8R8G8B24_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++) { \
- pixel->r = FixedToInt(ffr); \
- pixel->g = FixedToInt(ffg); \
- pixel->b = FixedToInt(ffb); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- pixel++; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
- */
-static void smooth_TRUEDITHER_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
- (void) pv;
-#define INTERP_RGB 1
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
- for (xx=LEFT;xx<RIGHT;xx++) { \
- unsigned long p; \
- PACK_TRUEDITHER( p, xx, yy, FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- XMesaPutPixel( img, xx, yy, p ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
- */
-static void smooth_5R6G5B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = (PIXEL_TYPE) PACK_5R6G5B( FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
- */
-static void smooth_DITHER_5R6G5B_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- PACK_TRUEDITHER(*pixel, xx, Y, FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
- */
-static void smooth_DITHER8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
- PIXEL_TYPE *pixel = pRow; \
- XDITHER_SETUP(yy); \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = (PIXEL_TYPE) XDITHER( xx, FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
- */
-static void smooth_DITHER_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
- (void) pv;
-#define INTERP_RGB 1
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
- XDITHER_SETUP(yy); \
- for (xx=LEFT;xx<RIGHT;xx++) { \
- unsigned long p = XDITHER( xx, FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- XMesaPutPixel( img, xx, yy, p ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
- */
-static void smooth_LOOKUP8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- LOOKUP_SETUP; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = LOOKUP( FixedToInt(ffr), FixedToInt(ffg), \
- FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-
-/*
- * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
- */
-static void smooth_HPCR_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- (void) pv;
-#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = DITHER_HPCR( xx, yy, FixedToInt(ffr), \
- FixedToInt(ffg), FixedToInt(ffb) ); \
- ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
- */
-static void flat_TRUECOLOR_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
-#define SETUP_CODE \
- unsigned long pixel; \
- PACK_TRUECOLOR(pixel, VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2]);
-
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
- for (xx=LEFT;xx<RIGHT;xx++) { \
- XMesaPutPixel( img, xx, yy, pixel ); \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
- */
-static void flat_8A8B8G8R_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- unsigned long p = PACK_8B8G8R( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = (PIXEL_TYPE) p; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
- */
-static void flat_8R8G8B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- unsigned long p = PACK_8R8G8B( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = (PIXEL_TYPE) p; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
- */
-static void flat_8R8G8B24_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++) { \
- pixel->r = color[RCOMP]; \
- pixel->g = color[GCOMP]; \
- pixel->b = color[BCOMP]; \
- pixel++; \
- } \
-}
-#include "tritemp.h"
-}
-
-/*
- * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
- */
-static void flat_TRUEDITHER_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
- for (xx=LEFT;xx<RIGHT;xx++) { \
- unsigned long p; \
- PACK_TRUEDITHER( p, xx, yy, VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] ); \
- XMesaPutPixel( img, xx, yy, p ); \
- } \
-}
-#include "tritemp.h"
-}
-
-
-
-/*
- * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
- */
-static void flat_5R6G5B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- unsigned long p = PACK_5R6G5B( VB->ColorPtr->data[pv][0], \
- VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = (PIXEL_TYPE) p; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
- */
-static void flat_DITHER_5R6G5B_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = ctx->VB->ColorPtr->data[pv];
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- PACK_TRUEDITHER(*pixel, xx, Y, color[RCOMP], \
- color[GCOMP], color[BCOMP]); \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
- */
-static void flat_DITHER8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- FLAT_DITHER_SETUP( VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, Y)); \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = (PIXEL_TYPE) FLAT_DITHER(xx); \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
- */
-static void flat_DITHER_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
-#define SETUP_CODE \
- FLAT_DITHER_SETUP( VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
-
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
- FLAT_DITHER_ROW_SETUP(yy); \
- for (xx=LEFT;xx<RIGHT;xx++) { \
- unsigned long p = FLAT_DITHER(xx); \
- XMesaPutPixel( img, xx, yy, p ); \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
- */
-static void flat_HPCR_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- GLubyte r = VB->ColorPtr->data[pv][0]; \
- GLubyte g = VB->ColorPtr->data[pv][1]; \
- GLubyte b = VB->ColorPtr->data[pv][2];
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = (PIXEL_TYPE) DITHER_HPCR( xx, yy, r, g, b ); \
- } \
-}
-#include "tritemp.h"
-}
-
-
-/*
- * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
- */
-static void flat_LOOKUP8_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
-#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define SETUP_CODE \
- LOOKUP_SETUP; \
- GLubyte r = VB->ColorPtr->data[pv][0]; \
- GLubyte g = VB->ColorPtr->data[pv][1]; \
- GLubyte b = VB->ColorPtr->data[pv][2]; \
- GLubyte p = LOOKUP(r,g,b);
-#define INNER_LOOP( LEFT, RIGHT, Y ) \
-{ \
- GLint xx; \
- PIXEL_TYPE *pixel = pRow; \
- for (xx=LEFT;xx<RIGHT;xx++,pixel++) { \
- *pixel = p; \
- } \
-}
-#include "tritemp.h"
-}
-
-
-
-#if 0
-/*
- * This function is called if we're about to render triangles into an
- * X window/pixmap. It sets the polygon stipple pattern if enabled.
- */
-static void setup_x_polygon_options( GLcontext *ctx )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- int fill_type;
-
- if (ctx->Polygon.StippleFlag) {
- if (xmesa->xm_buffer->stipple_pixmap == 0) {
- /* Allocate polygon stippling stuff once for this context. */
- XMesaBuffer b = xmesa->xm_buffer;
- b->stipple_pixmap = XMesaCreatePixmap( xmesa->display,
- b->buffer, 32, 32, 1 );
-#ifdef XFree86Server
- b->stipple_gc = CreateScratchGC(xmesa->display, 1);
-#else
- b->stipple_gc = XCreateGC(xmesa->display, b->stipple_pixmap, 0, NULL);
-#endif
- XMesaSetFunction(xmesa->display, b->stipple_gc, GXcopy);
- XMesaSetForeground(xmesa->display, b->stipple_gc, 1);
- XMesaSetBackground(xmesa->display, b->stipple_gc, 0);
- }
-
- /*
- * NOTE: We don't handle the following here!
- * GL_UNPACK_SWAP_BYTES
- * GL_UNPACK_LSB_FIRST
- */
- /* Copy Mesa stipple pattern to an XImage then to Pixmap */
- {
- XMesaImage *stipple_ximage;
- GLuint stipple[32];
- int i;
- int shift = xmesa->xm_buffer->height % 32;
- for (i=0;i<32;i++) {
- stipple[31-i] = ctx->PolygonStipple[(i+shift) % 32];
- }
-#ifdef XFree86Server
- stipple_ximage = XMesaCreateImage(1, 32, 32, (char *)stipple);
-#else
- stipple_ximage = XCreateImage( xmesa->display,
- xmesa->xm_visual->visinfo->visual,
- 1, ZPixmap, 0,
- (char *)stipple,
- 32, 32, 8, 0 );
- stipple_ximage->byte_order = LSBFirst;
- stipple_ximage->bitmap_bit_order = LSBFirst;
- stipple_ximage->bitmap_unit = 32;
-#endif
- XMesaPutImage( xmesa->display,
- (XMesaDrawable)xmesa->xm_buffer->stipple_pixmap,
- xmesa->xm_buffer->stipple_gc,
- stipple_ximage, 0, 0, 0, 0, 32, 32 );
- stipple_ximage->data = NULL;
- XMesaDestroyImage( stipple_ximage );
- }
-
- XMesaSetStipple( xmesa->display, xmesa->xm_buffer->gc1,
- xmesa->xm_buffer->stipple_pixmap );
- XMesaSetStipple( xmesa->display, xmesa->xm_buffer->gc2,
- xmesa->xm_buffer->stipple_pixmap );
- fill_type = FillStippled;
- }
- else {
- fill_type = FillSolid;
- }
-
- XMesaSetFillStyle( xmesa->display, xmesa->xm_buffer->gc1, fill_type );
- XMesaSetFillStyle( xmesa->display, xmesa->xm_buffer->gc2, fill_type );
-}
-#endif
-
-
-#ifdef DEBUG
-void
-_xmesa_print_triangle_func( triangle_func triFunc )
-{
- printf("XMesa tri func = ");
- if (triFunc ==smooth_TRUECOLOR_z_triangle)
- printf("smooth_TRUECOLOR_z_triangle\n");
- else if (triFunc ==smooth_8A8B8G8R_z_triangle)
- printf("smooth_8A8B8G8R_z_triangle\n");
- else if (triFunc ==smooth_8R8G8B_z_triangle)
- printf("smooth_8R8G8B_z_triangle\n");
- else if (triFunc ==smooth_8R8G8B24_z_triangle)
- printf("smooth_8R8G8B24_z_triangle\n");
- else if (triFunc ==smooth_TRUEDITHER_z_triangle)
- printf("smooth_TRUEDITHER_z_triangle\n");
- else if (triFunc ==smooth_5R6G5B_z_triangle)
- printf("smooth_5R6G5B_z_triangle\n");
- else if (triFunc ==smooth_DITHER_5R6G5B_z_triangle)
- printf("smooth_DITHER_5R6G5B_z_triangle\n");
- else if (triFunc ==smooth_HPCR_z_triangle)
- printf("smooth_HPCR_z_triangle\n");
- else if (triFunc ==smooth_DITHER8_z_triangle)
- printf("smooth_DITHER8_z_triangle\n");
- else if (triFunc ==smooth_LOOKUP8_z_triangle)
- printf("smooth_LOOKUP8_z_triangle\n");
- else if (triFunc ==flat_TRUECOLOR_z_triangle)
- printf("flat_TRUECOLOR_z_triangle\n");
- else if (triFunc ==flat_8A8B8G8R_z_triangle)
- printf("flat_8A8B8G8R_z_triangle\n");
- else if (triFunc ==flat_8R8G8B_z_triangle)
- printf("flat_8R8G8B_z_triangle\n");
- else if (triFunc ==flat_8R8G8B24_z_triangle)
- printf("flat_8R8G8B24_z_triangle\n");
- else if (triFunc ==flat_TRUEDITHER_z_triangle)
- printf("flat_TRUEDITHER_z_triangle\n");
- else if (triFunc ==flat_5R6G5B_z_triangle)
- printf("flat_5R6G5B_z_triangle\n");
- else if (triFunc ==flat_DITHER_5R6G5B_z_triangle)
- printf("flat_DITHER_5R6G5B_z_triangle\n");
- else if (triFunc ==flat_HPCR_z_triangle)
- printf("flat_HPCR_z_triangle\n");
- else if (triFunc ==flat_DITHER8_z_triangle)
- printf("flat_DITHER8_z_triangle\n");
- else if (triFunc ==flat_LOOKUP8_z_triangle)
- printf("flat_LOOKUP8_z_triangle\n");
- else if (triFunc ==smooth_TRUECOLOR_triangle)
- printf("smooth_TRUECOLOR_triangle\n");
- else if (triFunc ==smooth_8A8B8G8R_triangle)
- printf("smooth_8A8B8G8R_triangle\n");
- else if (triFunc ==smooth_8R8G8B_triangle)
- printf("smooth_8R8G8B_triangle\n");
- else if (triFunc ==smooth_8R8G8B24_triangle)
- printf("smooth_8R8G8B24_triangle\n");
- else if (triFunc ==smooth_TRUEDITHER_triangle)
- printf("smooth_TRUEDITHER_triangle\n");
- else if (triFunc ==smooth_5R6G5B_triangle)
- printf("smooth_5R6G5B_triangle\n");
- else if (triFunc ==smooth_DITHER_5R6G5B_triangle)
- printf("smooth_DITHER_5R6G5B_triangle\n");
- else if (triFunc ==smooth_HPCR_triangle)
- printf("smooth_HPCR_triangle\n");
- else if (triFunc ==smooth_DITHER8_triangle)
- printf("smooth_DITHER8_triangle\n");
- else if (triFunc ==smooth_LOOKUP8_triangle)
- printf("smooth_LOOKUP8_triangle\n");
- else if (triFunc ==flat_TRUECOLOR_triangle)
- printf("flat_TRUECOLOR_triangle\n");
- else if (triFunc ==flat_TRUEDITHER_triangle)
- printf("flat_TRUEDITHER_triangle\n");
- else if (triFunc ==flat_8A8B8G8R_triangle)
- printf("flat_8A8B8G8R_triangle\n");
- else if (triFunc ==flat_8R8G8B_triangle)
- printf("flat_8R8G8B_triangle\n");
- else if (triFunc ==flat_8R8G8B24_triangle)
- printf("flat_8R8G8B24_triangle\n");
- else if (triFunc ==flat_5R6G5B_triangle)
- printf("flat_5R6G5B_triangle\n");
- else if (triFunc ==flat_DITHER_5R6G5B_triangle)
- printf("flat_DITHER_5R6G5B_triangle\n");
- else if (triFunc ==flat_HPCR_triangle)
- printf("flat_HPCR_triangle\n");
- else if (triFunc ==flat_DITHER8_triangle)
- printf("flat_DITHER8_triangle\n");
- else if (triFunc ==flat_LOOKUP8_triangle)
- printf("flat_LOOKUP8_triangle\n");
-#if 0
- else if (triFunc ==flat_pixmap_triangle)
- printf("flat_pixmap_triangle\n");
-#endif
- else
- printf("???\n");
-}
-#endif
-
-
-triangle_func xmesa_get_triangle_func( GLcontext *ctx )
-{
- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
-
- (void) kernel1;
-
- if (ctx->Polygon.SmoothFlag) return (triangle_func)NULL;
- if (ctx->Texture.ReallyEnabled) return (triangle_func)NULL;
-
- if (xmesa->xm_buffer->buffer==XIMAGE) {
- if ( ctx->Light.ShadeModel==GL_SMOOTH
- && ctx->RasterMask==DEPTH_BIT
- && ctx->Depth.Func==GL_LESS
- && ctx->Depth.Mask==GL_TRUE
- && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- switch (xmesa->pixelformat) {
- case PF_TRUECOLOR:
- return smooth_TRUECOLOR_z_triangle;
- case PF_8A8B8G8R:
- return smooth_8A8B8G8R_z_triangle;
- case PF_8R8G8B:
- return smooth_8R8G8B_z_triangle;
- case PF_8R8G8B24:
- return smooth_8R8G8B24_z_triangle;
- case PF_TRUEDITHER:
- return smooth_TRUEDITHER_z_triangle;
- case PF_5R6G5B:
- return smooth_5R6G5B_z_triangle;
- case PF_DITHER_5R6G5B:
- return smooth_DITHER_5R6G5B_z_triangle;
- case PF_HPCR:
- return smooth_HPCR_z_triangle;
- case PF_DITHER:
- return (depth==8) ? smooth_DITHER8_z_triangle
- : smooth_DITHER_z_triangle;
- case PF_LOOKUP:
- return (depth==8) ? smooth_LOOKUP8_z_triangle : (triangle_func)NULL;
- default:
- return (triangle_func)NULL;
- }
- }
- if ( ctx->Light.ShadeModel==GL_FLAT
- && ctx->RasterMask==DEPTH_BIT
- && ctx->Depth.Func==GL_LESS
- && ctx->Depth.Mask==GL_TRUE
- && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- switch (xmesa->pixelformat) {
- case PF_TRUECOLOR:
- return flat_TRUECOLOR_z_triangle;
- case PF_8A8B8G8R:
- return flat_8A8B8G8R_z_triangle;
- case PF_8R8G8B:
- return flat_8R8G8B_z_triangle;
- case PF_8R8G8B24:
- return flat_8R8G8B24_z_triangle;
- case PF_TRUEDITHER:
- return flat_TRUEDITHER_z_triangle;
- case PF_5R6G5B:
- return flat_5R6G5B_z_triangle;
- case PF_DITHER_5R6G5B:
- return flat_DITHER_5R6G5B_z_triangle;
- case PF_HPCR:
- return flat_HPCR_z_triangle;
- case PF_DITHER:
- return (depth==8) ? flat_DITHER8_z_triangle
- : flat_DITHER_z_triangle;
- case PF_LOOKUP:
- return (depth==8) ? flat_LOOKUP8_z_triangle : (triangle_func)NULL;
- default:
- return (triangle_func)NULL;
- }
- }
- if ( ctx->RasterMask==0 /* no depth test */
- && ctx->Light.ShadeModel==GL_SMOOTH
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- switch (xmesa->pixelformat) {
- case PF_TRUECOLOR:
- return smooth_TRUECOLOR_triangle;
- case PF_8A8B8G8R:
- return smooth_8A8B8G8R_triangle;
- case PF_8R8G8B:
- return smooth_8R8G8B_triangle;
- case PF_8R8G8B24:
- return smooth_8R8G8B24_triangle;
- case PF_TRUEDITHER:
- return smooth_TRUEDITHER_triangle;
- case PF_5R6G5B:
- return smooth_5R6G5B_triangle;
- case PF_DITHER_5R6G5B:
- return smooth_DITHER_5R6G5B_triangle;
- case PF_HPCR:
- return smooth_HPCR_triangle;
- case PF_DITHER:
- return (depth==8) ? smooth_DITHER8_triangle
- : smooth_DITHER_triangle;
- case PF_LOOKUP:
- return (depth==8) ? smooth_LOOKUP8_triangle : (triangle_func)NULL;
- default:
- return (triangle_func)NULL;
- }
- }
-
- if ( ctx->RasterMask==0 /* no depth test */
- && ctx->Light.ShadeModel==GL_FLAT
- && ctx->Polygon.StippleFlag==GL_FALSE) {
- switch (xmesa->pixelformat) {
- case PF_TRUECOLOR:
- return flat_TRUECOLOR_triangle;
- case PF_TRUEDITHER:
- return flat_TRUEDITHER_triangle;
- case PF_8A8B8G8R:
- return flat_8A8B8G8R_triangle;
- case PF_8R8G8B:
- return flat_8R8G8B_triangle;
- case PF_8R8G8B24:
- return flat_8R8G8B24_triangle;
- case PF_5R6G5B:
- return flat_5R6G5B_triangle;
- case PF_DITHER_5R6G5B:
- return flat_DITHER_5R6G5B_triangle;
- case PF_HPCR:
- return flat_HPCR_triangle;
- case PF_DITHER:
- return (depth==8) ? flat_DITHER8_triangle
- : flat_DITHER_triangle;
- case PF_LOOKUP:
- return (depth==8) ? flat_LOOKUP8_triangle : (triangle_func)NULL;
- default:
- return (triangle_func)NULL;
- }
- }
-
- return (triangle_func)NULL;
- }
- else {
- /* draw to pixmap */
-#if 0
- /* XXX have to disable this because X's rasterization rules
- * don't match software Mesa's. This causes a buffer invariance
- * test failure in the conformance tests.
- * In the future, we might provide a config option to enable this.
- */
- if (ctx->Light.ShadeModel==GL_FLAT && ctx->RasterMask==0) {
- if (ctx->Color.DitherFlag && depth < 24)
- return NULL;
- setup_x_polygon_options( ctx );
- return flat_pixmap_triangle;
- }
-#endif
- return (triangle_func)NULL;
- }
-}
diff --git a/xc/extras/Mesa/src/X/xmesaP.h b/xc/extras/Mesa/src/X/xmesaP.h
index 6fd339c53..fe4e41765 100644
--- a/xc/extras/Mesa/src/X/xmesaP.h
+++ b/xc/extras/Mesa/src/X/xmesaP.h
@@ -1,20 +1,21 @@
+/* $Id: xmesaP.h,v 1.15 2002/02/14 01:59:36 dawes Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
- *
+ * Version: 3.5
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* 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
@@ -32,27 +33,15 @@
# include "GL/xf86glx.h"
# include "xf86glx_util.h"
#else
-# ifdef GLX_DIRECT_RENDERING
-# include "dri_mesa.h"
-# endif
# ifdef USE_XSHM
# include <X11/extensions/XShm.h>
# endif
#endif
#include "GL/xmesa.h"
-#include "types.h"
-#if defined(FX) && !defined(GLX_DIRECT_RENDERING)
+#include "mtypes.h"
+#if defined(FX)
#include "GL/fxmesa.h"
-#include "../FX/fxdrv.h"
-#endif
-
-
-#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
-# include "xdriP.h"
-#else
-# define DRI_DRAWABLE_ARG
-# define DRI_DRAWABLE_PARM
-# define DRI_CTX_ARG
+#include "FX/fxdrv.h"
#endif
@@ -74,10 +63,10 @@ typedef void (*clear_func)( GLcontext *ctx,
/*
- * "Derived" from gl_visual. Basically corresponds to an XVisualInfo.
+ * "Derived" from GLvisual. Basically corresponds to an XVisualInfo.
*/
struct xmesa_visual {
- GLvisual *gl_visual; /* Device independent visual parameters */
+ GLvisual mesa_visual; /* Device independent visual parameters */
XMesaDisplay *display; /* The X11 display */
#ifdef XFree86Server
GLint screen_depth; /* The depth of the screen */
@@ -126,7 +115,7 @@ struct xmesa_visual {
/*
- * "Derived" from gl_context. Basically corresponds to a GLXContext.
+ * "Derived" from __GLcontextRec. Basically corresponds to a GLXContext.
*/
struct xmesa_context {
GLcontext *gl_ctx; /* the core library context */
@@ -141,33 +130,24 @@ struct xmesa_context {
GLuint pixelformat; /* Current pixel format */
- GLubyte red, green, blue, alpha; /* current drawing color */
- unsigned long pixel; /* current drawing pixel value */
-
GLubyte clearcolor[4]; /* current clearing color */
unsigned long clearpixel; /* current clearing pixel value */
-
-#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
- __DRIcontextPrivate *driContextPriv; /* back pointer to DRI context
- * used for locking
- */
- void *private; /* device-specific private context */
-#endif
};
/*
- * "Derived" from gl_buffer. Basically corresponds to a GLXDrawable.
+ * "Derived" from GLframebuffer. Basically corresponds to a GLXDrawable.
*/
struct xmesa_buffer {
+ GLframebuffer mesa_buffer; /* depth, stencil, accum, etc buffers */
GLboolean wasCurrent; /* was ever the current buffer? */
- GLframebuffer *gl_buffer; /* depth, stencil, accum, etc buffers */
XMesaVisual xm_visual; /* the X/Mesa visual */
XMesaContext xm_context; /* the context associated with this buffer */
XMesaDisplay *display;
GLboolean pixmap_flag; /* is the buffer a Pixmap? */
+ GLboolean pbuffer_flag; /* is the buffer a Pbuffer? */
XMesaDrawable frontbuffer; /* either a window or pixmap */
XMesaPixmap backpixmap; /* back buffer Pixmap */
XMesaImage *backimage; /* back buffer simulated XImage */
@@ -208,8 +188,7 @@ struct xmesa_buffer {
XMesaPixmap stipple_pixmap; /* For polygon stippling */
XMesaGC stipple_gc; /* For polygon stippling */
- XMesaGC gc1; /* GC for infrequent color changes */
- XMesaGC gc2; /* GC for frequent color changes */
+ XMesaGC gc; /* scratch GC for span, line, tri drawing */
XMesaGC cleargc; /* GC for clearing the color buffer */
/* The following are here instead of in the XMesaVisual
@@ -232,14 +211,7 @@ struct xmesa_buffer {
unsigned long alloced_colors[256];
#endif
-#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
- __DRIdrawablePrivate *driDrawPriv; /* back pointer to DRI drawable
- * used for direct access to framebuffer
- */
- void *private; /* device-specific private drawable */
-#endif
-
-#if defined( FX ) && !defined(GLX_DIRECT_RENDERING)
+#if defined( FX )
/* For 3Dfx Glide only */
GLboolean FXisHackUsable; /* Can we render into window? */
GLboolean FXwindowHack; /* Are we rendering into a window? */
@@ -445,15 +417,15 @@ static GLushort DitherValues[16]; /* array of (up to) 16-bit pixel values */
static const short HPCR_DRGB[3][2][16] = {
{
{ 16, -4, 1,-11, 14, -6, 3, -9, 15, -5, 2,-10, 13, -7, 4, -8},
- {-15, 5, 0, 12,-13, 7, -2, 10,-14, 6, -1, 11,-12, 8, -3, 9}
+ {-15, 5, 0, 12,-13, 7, -2, 10,-14, 6, -1, 11,-12, 8, -3, 9}
},
{
{-11, 15, -7, 3, -8, 14, -4, 2,-10, 16, -6, 4, -9, 13, -5, 1},
- { 12,-14, 8, -2, 9,-13, 5, -1, 11,-15, 7, -3, 10,-12, 6, 0}
+ { 12,-14, 8, -2, 9,-13, 5, -1, 11,-15, 7, -3, 10,-12, 6, 0}
},
{
{ 6,-18, 26,-14, 2,-22, 30,-10, 8,-16, 28,-12, 4,-20, 32, -8},
- { -4, 20,-24, 16, 0, 24,-28, 12, -6, 18,-26, 14, -2, 22,-30, 10}
+ { -4, 20,-24, 16, 0, 24,-28, 12, -6, 18,-26, 14, -2, 22,-30, 10}
}
};
@@ -519,25 +491,33 @@ static int const kernel1[16] = {
*/
extern unsigned long
-xmesa_color_to_pixel( XMesaContext xmesa, GLubyte r, GLubyte g, GLubyte b, GLubyte a,
+xmesa_color_to_pixel( XMesaContext xmesa,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a,
GLuint pixelFormat );
extern void xmesa_alloc_back_buffer( XMesaBuffer b );
-extern void xmesa_update_state( GLcontext *ctx );
+extern void xmesa_init_pointers( GLcontext *ctx );
+extern void xmesa_update_state( GLcontext *ctx, GLuint new_state );
-extern points_func xmesa_get_points_func( GLcontext *ctx );
+extern void xmesa_update_span_funcs( GLcontext *ctx );
+
+/* Plugged into the software rasterizer. Try to use internal
+ * swrast-style point, line and triangle functions.
+ */
+extern void xmesa_choose_point( GLcontext *ctx );
+extern void xmesa_choose_line( GLcontext *ctx );
+extern void xmesa_choose_triangle( GLcontext *ctx );
-extern line_func xmesa_get_line_func( GLcontext *ctx );
-extern triangle_func xmesa_get_triangle_func( GLcontext *ctx );
+extern void xmesa_register_swrast_functions( GLcontext *ctx );
+
/* XXX this is a hack to implement shared display lists with 3Dfx */
extern XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v,
XMesaWindow w,
XMesaContext c
- DRI_DRAWABLE_ARG
);
/*
@@ -549,4 +529,7 @@ extern GLboolean XMesaForceCurrent(XMesaContext c);
extern GLboolean XMesaLoseCurrent(XMesaContext c);
extern void XMesaReset( void );
+extern void xmesa_set_read_buffer( GLcontext *ctx,
+ GLframebuffer *buffer, GLenum mode );
+
#endif