From 2cdd699a77f7801b1e37b72108a33fa95354e67a Mon Sep 17 00:00:00 2001 From: Kendall Bennett Date: Wed, 8 Oct 2003 01:53:30 +0000 Subject: [PATCH] More SciTech SNAP specific changes to glheader.h. Also modified the macros in swrast/s_spantemp.h to allow dithering to be used in the SNAP drivers. --- src/mesa/drivers/dri/fb/fb_dri.c | 18 +++++++++--------- src/mesa/drivers/osmesa/osmesa.c | 28 ++++++++++++++-------------- src/mesa/main/glheader.h | 18 +++++++++++------- src/mesa/math/m_debug_util.h | 2 ++ src/mesa/swrast/s_spantemp.h | 26 ++++++++++++++++---------- 5 files changed, 52 insertions(+), 40 deletions(-) diff --git a/src/mesa/drivers/dri/fb/fb_dri.c b/src/mesa/drivers/dri/fb/fb_dri.c index 945a78f2d0f..794e3d1fc8c 100644 --- a/src/mesa/drivers/dri/fb/fb_dri.c +++ b/src/mesa/drivers/dri/fb/fb_dri.c @@ -1,4 +1,4 @@ -/* $Id: fb_dri.c,v 1.1 2003/08/06 18:11:57 keithw Exp $ */ +/* $Id: fb_dri.c,v 1.2 2003/10/08 01:53:30 kendallb Exp $ */ /* * Mesa 3-D graphics library @@ -212,9 +212,9 @@ init_core_functions( GLcontext *ctx ) #define INIT_PIXEL_PTR(P, X, Y) \ GLubyte *P = (char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 3 #define INC_PIXEL_PTR(P) P += 3 -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ P[0] = B; P[1] = G; P[2] = R -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ P[0] = B; P[1] = G; P[2] = R #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ R = P[2]; G = P[1]; B = P[0]; A = CHAN_MAX @@ -230,9 +230,9 @@ init_core_functions( GLcontext *ctx ) #define INIT_PIXEL_PTR(P, X, Y) \ GLubyte *P = (char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 4; #define INC_PIXEL_PTR(P) P += 4 -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ P[0] = B; P[1] = G; P[2] = R; P[3] = 255 -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ P[0] = B; P[1] = G; P[2] = R; P[3] = A #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ R = P[2]; G = P[1]; B = P[0]; A = P[3] @@ -248,9 +248,9 @@ init_core_functions( GLcontext *ctx ) #define INIT_PIXEL_PTR(P, X, Y) \ GLushort *P = (GLushort *) ((char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 2) #define INC_PIXEL_PTR(P) P += 1 -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) ) -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) ) #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ R = ( (((*P) >> 8) & 0xf8) | (((*P) >> 11) & 0x7) ); \ @@ -269,9 +269,9 @@ init_core_functions( GLcontext *ctx ) #define INIT_PIXEL_PTR(P, X, Y) \ GLushort *P = (GLushort *) ((char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 2) #define INC_PIXEL_PTR(P) P += 1 -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ *P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) ) -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ *P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) ) #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ R = ( (((*P) >> 7) & 0xf8) | (((*P) >> 10) & 0x7) ); \ diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 396f9af6b05..4fd58f20273 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -226,20 +226,20 @@ clear( GLcontext *ctx, GLbitfield mask, GLboolean all, GLchan *P = osmesa->rowaddr[Y] + 4 * (X) #define INC_PIXEL_PTR(P) P += 4 #if CHAN_TYPE == GL_FLOAT -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ P[0] = MAX2((R), 0.0F); \ P[1] = MAX2((G), 0.0F); \ P[2] = MAX2((B), 0.0F); \ P[3] = CHAN_MAXF -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ P[0] = MAX2((R), 0.0F); \ P[1] = MAX2((G), 0.0F); \ P[2] = MAX2((B), 0.0F); \ P[3] = CLAMP((A), 0.0F, CHAN_MAXF) #else -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ P[0] = R; P[1] = G; P[2] = B; P[3] = CHAN_MAX -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ P[0] = R; P[1] = G; P[2] = B; P[3] = A #endif #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ @@ -253,9 +253,9 @@ clear( GLcontext *ctx, GLbitfield mask, GLboolean all, #define INIT_PIXEL_PTR(P, X, Y) \ GLchan *P = osmesa->rowaddr[Y] + 4 * (X) #define INC_PIXEL_PTR(P) P += 4 -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ P[2] = R; P[1] = G; P[0] = B; P[3] = CHAN_MAX -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ P[2] = R; P[1] = G; P[0] = B; P[3] = A #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ R = P[2]; G = P[1]; B = P[0]; A = P[3] @@ -268,9 +268,9 @@ clear( GLcontext *ctx, GLbitfield mask, GLboolean all, #define INIT_PIXEL_PTR(P, X, Y) \ GLchan *P = osmesa->rowaddr[Y] + 4 * (X) #define INC_PIXEL_PTR(P) P += 4 -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ P[1] = R; P[2] = G; P[3] = B; P[0] = CHAN_MAX -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ P[1] = R; P[2] = G; P[3] = B; P[0] = A #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ R = P[1]; G = P[2]; B = P[3]; A = P[0] @@ -283,9 +283,9 @@ clear( GLcontext *ctx, GLbitfield mask, GLboolean all, #define INIT_PIXEL_PTR(P, X, Y) \ GLchan *P = osmesa->rowaddr[Y] + 4 * (X) #define INC_PIXEL_PTR(P) P += 4 -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ P[0] = R; P[1] = G; P[2] = B -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ P[0] = R; P[1] = G; P[2] = B #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ R = P[0]; G = P[1]; B = P[2]; A = CHAN_MAX @@ -298,9 +298,9 @@ clear( GLcontext *ctx, GLbitfield mask, GLboolean all, #define INIT_PIXEL_PTR(P, X, Y) \ GLchan *P = osmesa->rowaddr[Y] + 4 * (X) #define INC_PIXEL_PTR(P) P += 4 -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ P[0] = B; P[1] = G; P[2] = R -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ P[0] = B; P[1] = G; P[2] = R #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ B = P[0]; G = P[1]; R = P[2]; A = CHAN_MAX @@ -314,9 +314,9 @@ clear( GLcontext *ctx, GLbitfield mask, GLboolean all, #define INIT_PIXEL_PTR(P, X, Y) \ GLushort *P = (GLushort *) osmesa->rowaddr[Y] + (X) #define INC_PIXEL_PTR(P) P += 1 -#define STORE_RGB_PIXEL(P, R, G, B) \ +#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \ *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) ) -#define STORE_RGBA_PIXEL(P, R, G, B, A) \ +#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \ *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) ) #define FETCH_RGBA_PIXEL(R, G, B, A, P) \ R = ( (((*P) >> 8) & 0xf8) | (((*P) >> 11) & 0x7) ); \ diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index 0f93539a81b..d7defcd1545 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -75,12 +75,16 @@ #endif -#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP) # define __WIN32__ # define finite _finite #endif -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) +#if defined(__WATCOMC__) +# define finite _finite +#endif + +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) # pragma warning( disable : 4068 ) /* unknown pragma */ # pragma warning( disable : 4710 ) /* function 'foo' not inlined */ # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ @@ -113,7 +117,7 @@ # endif # define GLWINAPI __stdcall # define GLWINAPIV __cdecl -#elif !defined(__SCITECH_SNAP__) +#elif !defined(BUILD_FOR_SNAP) /* non-Windows compilation */ # define GLAPI extern # define GLAPIENTRY @@ -127,7 +131,7 @@ /* compatibility guard so we don't need to change client code */ -#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP) #if 0 # define CALLBACK GLCALLBACK typedef void *HGLRC; @@ -142,7 +146,7 @@ typedef unsigned long COLORREF; #define GL_GLEXT_PROTOTYPES -#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) +#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(BUILD_FOR_SNAP) # define WGL_FONT_LINES 0 # define WGL_FONT_POLYGONS 1 #ifndef _GNU_H_WINDOWS32_FUNCTIONS @@ -196,7 +200,7 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC #ifndef CAPI -#ifdef WIN32 +#if defined(WIN32) && !defined(BUILD_FOR_SNAP) #define CAPI _cdecl #else #define CAPI @@ -278,7 +282,7 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC #endif -#if defined(__SCITECH_SNAP__) && defined(CHECKED) +#if defined(BUILD_FOR_SNAP) && defined(CHECKED) # define ASSERT(X) _CHECK(X) #elif defined(DEBUG) # define ASSERT(X) assert(X) diff --git a/src/mesa/math/m_debug_util.h b/src/mesa/math/m_debug_util.h index 9b89c90e36a..9df84301f10 100644 --- a/src/mesa/math/m_debug_util.h +++ b/src/mesa/math/m_debug_util.h @@ -268,6 +268,8 @@ enum { NIL = 0, ONE = 1, NEG = -1, VAR = 2 }; # define ALIGN16 __attribute__ ((aligned (16))) #elif defined(__MSC__) # define ALIGN16 __declspec(align(16)) /* GH: Does this work? */ +#elif defined(__WATCOMC__) +# define ALIGN16 /* Watcom does not support this */ #else # warning "ALIGN16 will not 16-byte align!\n" # define ALIGN16 diff --git a/src/mesa/swrast/s_spantemp.h b/src/mesa/swrast/s_spantemp.h index c48b35b90a8..df08f14760a 100644 --- a/src/mesa/swrast/s_spantemp.h +++ b/src/mesa/swrast/s_spantemp.h @@ -33,9 +33,15 @@ * SPAN_VARS to declare any local variables * INIT_PIXEL_PTR(P, X, Y) to initialize a pointer to a pixel * INC_PIXEL_PTR(P) to increment a pixel pointer by one pixel - * STORE_RGB_PIXEL(P, R, G, B) to store RGB values in pixel P - * STORE_RGBA_PIXEL(P, R, G, B, A) to store RGBA values in pixel P + * STORE_RGB_PIXEL(P, X, Y, R, G, B) to store RGB values in pixel P + * STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) to store RGBA values in pixel P * FETCH_RGBA_PIXEL(R, G, B, A, P) to fetch RGBA values from pixel P + * + * Note that in the above STORE_RGBx_PIXEL macros, we also pass in the (X,Y) + * coordinates for the pixels to be stored, which enables dithering in 8-bit + * and 15/16-bit display modes. Most undithered modes or 24/32-bit display + * modes will simply ignore the passed in (X,Y) values. + * * For color index mode: * STORE_CI_PIXEL(P, CI) to store a color index in pixel P * FETCH_CI_PIXEL(CI, P) to fetch a pixel index from pixel P @@ -56,7 +62,7 @@ NAME(write_rgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y, if (mask) { for (i = 0; i < n; i++) { if (mask[i]) { - STORE_RGBA_PIXEL(pixel, rgba[i][RCOMP], rgba[i][GCOMP], + STORE_RGBA_PIXEL(pixel, x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP]); } INC_PIXEL_PTR(pixel); @@ -64,7 +70,7 @@ NAME(write_rgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y, } else { for (i = 0; i < n; i++) { - STORE_RGBA_PIXEL(pixel, rgba[i][RCOMP], rgba[i][GCOMP], + STORE_RGBA_PIXEL(pixel, x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP]); INC_PIXEL_PTR(pixel); } @@ -83,7 +89,7 @@ NAME(write_rgb_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y, if (mask) { for (i = 0; i < n; i++) { if (mask[i]) { - STORE_RGB_PIXEL(pixel, rgb[i][RCOMP], rgb[i][GCOMP], + STORE_RGB_PIXEL(pixel, x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]); } INC_PIXEL_PTR(pixel); @@ -91,7 +97,7 @@ NAME(write_rgb_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y, } else { for (i = 0; i < n; i++) { - STORE_RGB_PIXEL(pixel, rgb[i][RCOMP], rgb[i][GCOMP], + STORE_RGB_PIXEL(pixel, x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]); INC_PIXEL_PTR(pixel); } @@ -110,7 +116,7 @@ NAME(write_monorgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y, if (mask) { for (i = 0; i < n; i++) { if (mask[i]) { - STORE_RGBA_PIXEL(pixel, color[RCOMP], color[GCOMP], + STORE_RGBA_PIXEL(pixel, x+i, y, color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP]); } INC_PIXEL_PTR(pixel); @@ -118,7 +124,7 @@ NAME(write_monorgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y, } else { for (i = 0; i < n; i++) { - STORE_RGBA_PIXEL(pixel, color[RCOMP], color[GCOMP], + STORE_RGBA_PIXEL(pixel, x+i, y, color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP]); INC_PIXEL_PTR(pixel); } @@ -138,7 +144,7 @@ NAME(write_rgba_pixels)( const GLcontext *ctx, GLuint n, for (i = 0; i < n; i++) { if (mask[i]) { INIT_PIXEL_PTR(pixel, x[i], y[i]); - STORE_RGBA_PIXEL(pixel, rgba[i][RCOMP], rgba[i][GCOMP], + STORE_RGBA_PIXEL(pixel, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP]); } } @@ -157,7 +163,7 @@ NAME(write_monorgba_pixels)( const GLcontext *ctx, for (i = 0; i < n; i++) { if (mask[i]) { INIT_PIXEL_PTR(pixel, x[i], y[i]); - STORE_RGBA_PIXEL(pixel, color[RCOMP], color[GCOMP], + STORE_RGBA_PIXEL(pixel, x[i], y[i], color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP]); } } -- 2.30.2