#define FXMESA_DEPTH_SIZE 12 /* followed by an integer */
#define FXMESA_STENCIL_SIZE 13 /* followed by an integer */
#define FXMESA_ACCUM_SIZE 14 /* followed by an integer */
+#define FXMESA_COLORDEPTH 20 /* followed by an integer */
if (stencilSize > 0) { fx_attrib[i++] = FXMESA_STENCIL_SIZE; fx_attrib[i++] = stencilSize; }
if (accumSize > 0) { fx_attrib[i++] = FXMESA_ACCUM_SIZE; fx_attrib[i++] = accumSize; }
if (alphaFlag) { fx_attrib[i++] = FXMESA_ALPHA_SIZE; fx_attrib[i++] = 1; }
+ fx_attrib[i++] = FXMESA_COLORDEPTH;
+ fx_attrib[i++] = colDepth;
fx_attrib[i] = FXMESA_NONE;
return (DMesaVisual)fxMesaCreateBestContext(-1, width, height, fx_attrib);
_mesa_enable_sw_extensions((GLcontext *)c);
_mesa_enable_1_3_extensions((GLcontext *)c);
_mesa_enable_1_4_extensions((GLcontext *)c);
+ _mesa_enable_1_5_extensions((GLcontext *)c);\r
/* you probably have to do a bunch of other initializations here. */
c->visual = visual;
-/* $Id: fxapi.c,v 1.35 2002/10/24 23:57:23 brianp Exp $ */
+/* $Id: fxapi.c,v 1.36 2003/07/17 14:50:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
char *errorstr;
GLboolean useBGR;
char *system = NULL;
+ GLuint pixFmt, colDepth = 16;
+ GLint redBits, greenBits, blueBits, alphaBits;
if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr, "fxmesa: fxMesaCreateContext() Start\n");
i = 0;
while (attribList[i] != FXMESA_NONE) {
switch (attribList[i]) {
+ case FXMESA_COLORDEPTH:
+ colDepth = attribList[++i];
+ break;
case FXMESA_DOUBLEBUFFER:
doubleBuffer = GL_TRUE;
break;
fxMesa->board = glbCurrentBoard;
- fxMesa->glideContext = FX_grSstWinOpen((FxU32) win, res, ref,
+ switch (fxMesa->colDepth = colDepth) {
+ case 15:
+ redBits = 5;
+ greenBits = 5;
+ blueBits = 5;
+ alphaBits = 1;
+ pixFmt = 4; /* GR_PIXFMT_ARGB_1555 */
+ break;
+ case 16:
+ redBits = 5;
+ greenBits = 6;
+ blueBits = 5;
+ alphaBits = 0;
+ pixFmt = 3; /* GR_PIXFMT_ARGB_565 */
+ break;
+ case 32:
+ redBits = 8;
+ greenBits = 8;
+ blueBits = 8;
+ alphaBits = 8;
+ pixFmt = 5; /* GR_PIXFMT_ARGB_8888 */
+ break;
+ default:
+ errorstr = "pixelFormat";
+ goto errorhandler;
+ }
+
+
+ fxMesa->glideContext = FX_grSstWinOpen(&glbHWConfig.SSTs[glbCurrentBoard],
+ (FxU32)win, res, ref,
#ifdef FXMESA_USE_ARGB
GR_COLORFORMAT_ARGB,
#else
GR_COLORFORMAT_ABGR,
#endif
+ pixFmt,
GR_ORIGIN_LOWER_LEFT, 2, aux);
if (!fxMesa->glideContext) {
errorstr = "grSstWinOpen";
fxMesa->glVis = _mesa_create_visual(GL_TRUE, /* RGB mode */
doubleBuffer, GL_FALSE, /* stereo */
- 5, 6, 5, 0, /* RGBA bits */
+ redBits, greenBits, blueBits, alphaBits, /* RGBA bits */
0, /* index bits */
depthSize, /* depth_size */
stencilSize, /* stencil_size */
-/* $Id: fxdd.c,v 1.97 2003/06/16 14:30:57 brianp Exp $ */
+/* Hack alert:
+ * fxDDReadPixels888 does not convert 8A8R8G8B into 5R5G5B
+ */
+
+/* $Id: fxdd.c,v 1.98 2003/07/17 14:50:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLubyte FX_PixelToG[0x10000];
GLubyte FX_PixelToB[0x10000];
+/* lookup table for scaling 5 bit colors up to 8 bits */
+GLuint FX_rgb_scale_5[32] = {
+ 0, 8, 16, 25, 33, 41, 49, 58,
+ 66, 74, 82, 90, 99, 107, 115, 123,
+ 132, 140, 148, 156, 165, 173, 181, 189,
+ 197, 206, 214, 222, 230, 239, 247, 255
+};
+
/*
* Initialize the FX_PixelTo{RGB} arrays.
g = (pixel & 0x07E0) >> 3;
b = (pixel & 0x001F) << 3;
}
- r = r * 255 / 0xF8; /* fill in low-order bits */
- g = g * 255 / 0xFC;
- b = b * 255 / 0xF8;
+ /* fill in low-order bits with proper rounding */
+ r = (GLuint)(((double)r * 255. / 0xF8) + 0.5);
+ g = (GLuint)(((double)g * 255. / 0xFC) + 0.5);
+ b = (GLuint)(((double)b * 255. / 0xF8) + 0.5);
FX_PixelToR[pixel] = r;
FX_PixelToG[pixel] = g;
FX_PixelToB[pixel] = b;
}
}
+static void fxDDReadPixels555 (GLcontext * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *dstImage)
+{
+ if (ctx->_ImageTransferState) {
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+ else {
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrLfbInfo_t info;
+
+ BEGIN_BOARD_LOCK();
+ if (grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_ANY,
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+ const GLushort *src = (const GLushort *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x);
+ GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage,
+ width, height, format,
+ type, 0, 0, 0);
+ GLint dstStride =
+ _mesa_image_row_stride(packing, width, format, type);
+
+ if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ /* convert 5R5G5B into 8R8G8B */
+ GLint row, col;
+ const GLint halfWidth = width >> 1;
+ const GLint extraPixel = (width & 1);
+ for (row = 0; row < height; row++) {
+ GLubyte *d = dst;
+ for (col = 0; col < halfWidth; col++) {
+ const GLuint pixel = ((const GLuint *) src)[col];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 21) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 26) & 0x1f];
+ }
+ if (extraPixel) {
+ GLushort pixel = src[width - 1];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ /* convert 5R6G5B into 8R8G8B8A */
+ GLint row, col;
+ const GLint halfWidth = width >> 1;
+ const GLint extraPixel = (width & 1);
+ for (row = 0; row < height; row++) {
+ GLubyte *d = dst;
+ for (col = 0; col < halfWidth; col++) {
+ const GLuint pixel = ((const GLuint *) src)[col];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ *d++ = (pixel & 0x8000) ? 255 : 0;
+ *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 21) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 26) & 0x1f];
+ *d++ = (pixel & 0x80000000) ? 255 : 0;
+ }
+ if (extraPixel) {
+ const GLushort pixel = src[width - 1];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ *d++ = (pixel & 0x8000) ? 255 : 0;
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
+ /* directly memcpy 5R5G5B pixels into client's buffer */
+ const GLint widthInBytes = width * 2;
+ GLint row;
+ for (row = 0; row < height; row++) {
+ MEMCPY(dst, src, widthInBytes);
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ else {
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ END_BOARD_LOCK();
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+ }
+}
+
+static void fxDDReadPixels888 (GLcontext * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *dstImage)
+{
+ if (ctx->_ImageTransferState) {
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+ else {
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrLfbInfo_t info;
+
+ BEGIN_BOARD_LOCK();
+ if (grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_ANY,
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ const GLint srcStride = info.strideInBytes / 4; /* stride in GLuints */
+ const GLuint *src = (const GLuint *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x);
+ GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage,
+ width, height, format,
+ type, 0, 0, 0);
+ GLint dstStride =
+ _mesa_image_row_stride(packing, width, format, type);
+
+ if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ /* convert 8A8R8G8B into 8R8G8B */
+ GLint row, col;
+ for (row = 0; row < height; row++) {
+ GLubyte *d = dst;
+ for (col = 0; col < width; col++) {
+ const GLuint pixel = ((const GLuint *) src)[col];
+ *d++ = pixel >> 16;
+ *d++ = pixel >> 8;
+ *d++ = pixel;
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ /* directly memcpy 8A8R8G8B pixels into client's buffer */
+ const GLint widthInBytes = width * 4;
+ GLint row;
+ for (row = 0; row < height; row++) {
+ MEMCPY(dst, src, widthInBytes);
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
+ /* convert 8A8R8G8B into 5R5G5B */
+ }
+ else {
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ END_BOARD_LOCK();
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+ }
+}
static void
{
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- _mesa_add_extension(ctx, GL_TRUE, "3DFX_set_global_palette", 0);
+ /*_mesa_add_extension(ctx, GL_TRUE, "3DFX_set_global_palette", 0);*/
_mesa_enable_extension(ctx, "GL_EXT_point_parameters");
_mesa_enable_extension(ctx, "GL_EXT_paletted_texture");
_mesa_enable_extension(ctx, "GL_EXT_texture_lod_bias");
ctx->Driver.Bitmap = fxDDDrawBitmap;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = fxDDReadPixels;
+ {
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ switch (fxMesa->colDepth) {
+ case 15:
+ ctx->Driver.ReadPixels = fxDDReadPixels555;
+ break;
+ case 16:
+ ctx->Driver.ReadPixels = fxDDReadPixels;
+ break;
+ case 32:
+ ctx->Driver.ReadPixels = fxDDReadPixels888;
+ break;
+ }
+ }
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.Finish = fxDDFinish;
ctx->Driver.Flush = NULL;
-/* $Id: fxddspan.c,v 1.22 2002/11/04 20:29:04 brianp Exp $ */
+/* Hack alert:
+ * Depth32 functions won't compile with Glide2
+ * Optimize and check endianess for `read_R8G8B8_pixels'
+ */
+
+/* $Id: fxddspan.c,v 1.23 2003/07/17 14:50:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
#if defined(FX)
#include "fxdrv.h"
+#include "fxglidew.h"
#include "swrast/swrast.h"
#ifdef _MSC_VER
END_BOARD_LOCK();
}
+/*
+ * Read a span of 15-bit RGB pixels. Note, we don't worry about cliprects
+ * since OpenGL says obscured pixels have undefined values.
+ */
+static void read_R5G5B5_span (const GLcontext * ctx,
+ GLuint n,
+ GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrLfbInfo_t info;
+ BEGIN_BOARD_LOCK();
+ if (grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+ const GLushort *data16 = (const GLushort *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x);
+ const GLuint *data32 = (const GLuint *) data16;
+ GLuint i, j;
+ GLuint extraPixel = (n & 1);
+ n -= extraPixel;
+ for (i = j = 0; i < n; i += 2, j++) {
+ GLuint pixel = data32[j];
+ rgba[i][RCOMP] = FX_rgb_scale_5[ pixel & 0x1f];
+ rgba[i][GCOMP] = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ rgba[i][BCOMP] = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ rgba[i][ACOMP] = (pixel & 0x8000) ? 255 : 0;
+ rgba[i + 1][RCOMP] = FX_rgb_scale_5[(pixel >> 16) & 0x1f];
+ rgba[i + 1][GCOMP] = FX_rgb_scale_5[(pixel >> 21) & 0x1f];
+ rgba[i + 1][BCOMP] = FX_rgb_scale_5[(pixel >> 26) & 0x1f];
+ rgba[i + 1][ACOMP] = (pixel & 0x80000000) ? 255 : 0;
+ }
+ if (extraPixel) {
+ GLushort pixel = data16[n];
+ rgba[n][RCOMP] = FX_rgb_scale_5[ pixel & 0x1f];
+ rgba[n][GCOMP] = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ rgba[n][BCOMP] = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ rgba[n][ACOMP] = (pixel & 0x8000) ? 255 : 0;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+}
+
+/*
+ * Read a span of 32-bit RGB pixels. Note, we don't worry about cliprects
+ * since OpenGL says obscured pixels have undefined values.
+ */
+static void read_R8G8B8_span (const GLcontext * ctx,
+ GLuint n,
+ GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ BEGIN_BOARD_LOCK();
+ FX_grLfbReadRegion(fxMesa->currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
+ END_BOARD_LOCK();
+}
+
/************************************************************************/
/***** Pixel functions *****/
}
+static void read_R5G5B5_pixels (const GLcontext * ctx,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ GLubyte rgba[][4],
+ const GLubyte mask[])
+{
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrLfbInfo_t info;
+ BEGIN_BOARD_LOCK();
+ if (grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ const GLushort *data16 = (const GLushort *) info.lfbPtr
+ + (winY - y[i]) * srcStride + (winX + x[i]);
+ const GLushort pixel = *data16;
+ rgba[i][RCOMP] = FX_rgb_scale_5[ pixel & 0x1f];
+ rgba[i][GCOMP] = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ rgba[i][BCOMP] = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ rgba[i][ACOMP] = (pixel & 0x8000) ? 255 : 0;
+ }
+ }
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+}
+
+
+static void
+read_R8G8B8_pixels(const GLcontext * ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4], const GLubyte mask[])
+{
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GrLfbInfo_t info;
+ BEGIN_BOARD_LOCK();
+ if (grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint srcStride = info.strideInBytes / 4; /* stride in GLuints */
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ const GLuint *data32 = (const GLuint *) info.lfbPtr
+ + (winY - y[i]) * srcStride + (winX + x[i]);
+ const GLuint pixel = *data32;
+ *(GLuint *)&rgba[i][0] = pixel;
+ }
+ }
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+}
+
+
/************************************************************************/
/***** Depth functions *****/
}
+void
+fxDDWriteDepth32Span(GLcontext * ctx,
+ GLuint n, GLint x, GLint y, const GLdepth depth[],
+ const GLubyte mask[])
+{
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLint bottom = fxMesa->height - 1;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteDepth32Span(...)\n");
+ }
+
+
+ if (mask) {
+ GLint i;
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
+ GR_LFBWRITEMODE_Z32, 1, 1, 0, (void *) &depth[i]);
+ }
+ }
+ }
+ else {
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
+ GR_LFBWRITEMODE_Z32, n, 1, 0, (void *) depth);
+ }
+}
+
+
void
fxDDReadDepthSpan(GLcontext * ctx,
GLuint n, GLint x, GLint y, GLdepth depth[])
}
+void
+fxDDReadDepth32Span(GLcontext * ctx,
+ GLuint n, GLint x, GLint y, GLdepth depth[])
+{
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLint bottom = fxMesa->height - 1;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadDepth32Span(...)\n");
+ }
+
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth);
+}
+
+
void
fxDDWriteDepthPixels(GLcontext * ctx,
}
+void
+fxDDWriteDepth32Pixels(GLcontext * ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLdepth depth[], const GLubyte mask[])
+{
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLint bottom = fxMesa->height - 1;
+ GLuint i;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteDepth32Pixels(...)\n");
+ }
+
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ int xpos = x[i];
+ int ypos = bottom - y[i];
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
+ GR_LFBWRITEMODE_Z32, 1, 1, 0, (void *) &depth[i]);
+ }
+ }
+}
+
+
void
fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
const GLint x[], const GLint y[], GLdepth depth[])
}
+void
+fxDDReadDepth32Pixels(GLcontext * ctx, GLuint n,
+ const GLint x[], const GLint y[], GLdepth depth[])
+{
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ GLint bottom = fxMesa->height - 1;
+ GLuint i;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadDepth32Pixels(...)\n");
+ }
+
+ for (i = 0; i < n; i++) {
+ int xpos = x[i];
+ int ypos = bottom - y[i];
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &depth[i]);
+ }
+}
+
+
/* Set the buffer used for reading */
/* XXX support for separate read/draw buffers hasn't been tested */
swdd->WriteRGBAPixels = fxDDWriteRGBAPixels;
swdd->WriteMonoRGBAPixels = fxDDWriteMonoRGBAPixels;
- swdd->WriteDepthSpan = fxDDWriteDepthSpan;
- swdd->WriteDepthPixels = fxDDWriteDepthPixels;
- swdd->ReadDepthSpan = fxDDReadDepthSpan;
- swdd->ReadDepthPixels = fxDDReadDepthPixels;
-
/* swdd->ReadRGBASpan =fxDDReadRGBASpan; */
- swdd->ReadRGBASpan = read_R5G6B5_span;
- swdd->ReadRGBAPixels = read_R5G6B5_pixels;
+ {
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ switch (fxMesa->colDepth) {
+ case 15:
+ swdd->ReadRGBASpan = read_R5G5B5_span;
+ swdd->ReadRGBAPixels = read_R5G5B5_pixels;
+ swdd->WriteDepthSpan = fxDDWriteDepthSpan;
+ swdd->WriteDepthPixels = fxDDWriteDepthPixels;
+ swdd->ReadDepthSpan = fxDDReadDepthSpan;
+ swdd->ReadDepthPixels = fxDDReadDepthPixels;
+ break;
+ case 16:
+ swdd->ReadRGBASpan = read_R5G6B5_span;
+ swdd->ReadRGBAPixels = read_R5G6B5_pixels;
+ swdd->WriteDepthSpan = fxDDWriteDepthSpan;
+ swdd->WriteDepthPixels = fxDDWriteDepthPixels;
+ swdd->ReadDepthSpan = fxDDReadDepthSpan;
+ swdd->ReadDepthPixels = fxDDReadDepthPixels;
+ break;
+ case 32:
+ swdd->ReadRGBASpan = read_R8G8B8_span;
+ swdd->ReadRGBAPixels = read_R8G8B8_pixels;
+ swdd->WriteDepthSpan = fxDDWriteDepth32Span;
+ swdd->WriteDepthPixels = fxDDWriteDepth32Pixels;
+ swdd->ReadDepthSpan = fxDDReadDepth32Span;
+ swdd->ReadDepthPixels = fxDDReadDepth32Pixels;
+ break;
+ }
+ }
}
-/* $Id: fxdrv.h,v 1.56 2003/01/08 21:32:33 brianp Exp $ */
+/* $Id: fxdrv.h,v 1.57 2003/07/17 14:50:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
extern GLubyte FX_PixelToG[0x10000];
extern GLubyte FX_PixelToB[0x10000];
+/* lookup table for scaling 5 bit colors up to 8 bits */
+GLuint FX_rgb_scale_5[32];
typedef void (*fx_tri_func) (fxMesaContext, GrVertex *, GrVertex *, GrVertex *);
typedef void (*fx_line_func) (fxMesaContext, GrVertex *, GrVertex *);
int clipMaxX;
int clipMinY;
int clipMaxY;
+
+ int colDepth;
};
-/* $Id: fxglidew.c,v 1.19 2001/09/23 16:50:01 brianp Exp $ */
+/* $Id: fxglidew.c,v 1.20 2003/07/17 14:50:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
grGet(GR_REVISION_TMU, 4, &result);
config->SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRev = result;
}
+
+ {
+ const char *extension = grGetString(GR_EXTENSION);
+ if (strstr(extension, " PIXEXT ")) {
+ config->SSTs[i].sstBoard.VoodooConfig.gExt.grSstWinOpen = grGetProcAddress("grSstWinOpenExt");
+ }
+ }
}
END_BOARD_LOCK();
return 1;
/* It appears to me that this function is needed either way. */
FX_GrContext_t
-FX_grSstWinOpen(FxU32 hWnd,
+FX_grSstWinOpen(struct SstCard_St *c,
+ FxU32 hWnd,
GrScreenResolution_t screen_resolution,
GrScreenRefresh_t refresh_rate,
GrColorFormat_t color_format,
+ GrPixelFormat_t pixel_format,
GrOriginLocation_t origin_location,
int nColBuffers, int nAuxBuffers)
{
FX_GrContext_t i;
BEGIN_BOARD_LOCK();
+ if ((c->type == GR_SSTTYPE_VOODOO) && c->sstBoard.VoodooConfig.gExt.grSstWinOpen) {
+ i = c->sstBoard.VoodooConfig.gExt.grSstWinOpen(hWnd,
+ screen_resolution,
+ refresh_rate,
+ color_format, origin_location,
+ pixel_format,
+ nColBuffers, nAuxBuffers);
+ } else
i = grSstWinOpen(hWnd,
screen_resolution,
refresh_rate,
-/* $Id: fxglidew.h,v 1.13 2001/09/23 16:50:01 brianp Exp $ */
+/* $Id: fxglidew.h,v 1.14 2003/07/17 14:50:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
*/
#if !defined(FX_GLIDE3)
typedef FxU32 FX_GrContext_t; /* Not used in Glide2 */
+typedef FxU32 GrPixelFormat_t;
#else
+#include <g3ext.h>
typedef GrContext_t FX_GrContext_t;
#endif
int fbiRev; /* Rev of Pixelfx chip */
int nTexelfx; /* How many texelFX chips are there? */
FxBool sliDetect; /* Is it a scan-line interleaved board? */
+ struct { /* Glide extensions */
+ GrProc grSstWinOpen;
+ } gExt;
GrTMUConfig_t tmuConfig[GLIDE_NUM_TMU]; /* Configuration of the Texelfx chips */
}
GrVoodooConfig_t;
typedef struct
{
int num_sst; /* # of HW units in the system */
- struct
+ struct SstCard_St
{
GrSstType type; /* Which hardware is it? */
union SstBoard_u
#endif
-extern FX_GrContext_t FX_grSstWinOpen(FxU32 hWnd,
+extern FX_GrContext_t FX_grSstWinOpen(struct SstCard_St *c,
+ FxU32 hWnd,
GrScreenResolution_t screen_resolution,
GrScreenRefresh_t refresh_rate,
GrColorFormat_t color_format,
+ GrPixelFormat_t pixel_format,
GrOriginLocation_t origin_location,
int nColBuffers, int nAuxBuffers);