diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2003-07-17 14:50:11 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2003-07-17 14:50:11 +0000 |
commit | c19cbb58cd2862393d67b62a5fc523b6fa1ac9a6 (patch) | |
tree | 46e79f545a67ad9c47d43685ec2092b21a6e1cda /src | |
parent | 6dc85575000127630489b407c50a4b3ea87c9acb (diff) |
more DOS updates from Daniel Borca
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dos/dmesa.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxapi.c | 41 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxdd.c | 222 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxddspan.c | 257 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxdrv.h | 6 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxglidew.c | 21 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxglidew.h | 13 |
7 files changed, 540 insertions, 23 deletions
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c index 9ec0036176..92381307c2 100644 --- a/src/mesa/drivers/dos/dmesa.c +++ b/src/mesa/drivers/dos/dmesa.c @@ -1452,6 +1452,8 @@ DMesaVisual DMesaCreateVisual (GLint width, 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); @@ -1534,6 +1536,7 @@ DMesaContext DMesaCreateContext (DMesaVisual visual, _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);
/* you probably have to do a bunch of other initializations here. */ c->visual = visual; diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c index a1fdf1dc87..bb87565296 100644 --- a/src/mesa/drivers/glide/fxapi.c +++ b/src/mesa/drivers/glide/fxapi.c @@ -1,4 +1,4 @@ -/* $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 @@ -283,6 +283,8 @@ fxMesaCreateContext(GLuint win, 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"); @@ -295,6 +297,9 @@ fxMesaCreateContext(GLuint win, i = 0; while (attribList[i] != FXMESA_NONE) { switch (attribList[i]) { + case FXMESA_COLORDEPTH: + colDepth = attribList[++i]; + break; case FXMESA_DOUBLEBUFFER: doubleBuffer = GL_TRUE; break; @@ -379,12 +384,42 @@ fxMesaCreateContext(GLuint win, 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"; @@ -497,7 +532,7 @@ fxMesaCreateContext(GLuint win, 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 */ diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index f20b1147f8..81d3754e42 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1,4 +1,8 @@ -/* $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 @@ -66,6 +70,14 @@ GLubyte FX_PixelToR[0x10000]; 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. @@ -89,9 +101,10 @@ fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder) 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; @@ -581,6 +594,190 @@ fxDDReadPixels(GLcontext * ctx, GLint x, GLint y, } } +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 @@ -804,7 +1001,7 @@ fxDDInitExtensions(GLcontext * ctx) { 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"); @@ -1009,7 +1206,20 @@ fxSetupDDPointers(GLcontext * ctx) 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; diff --git a/src/mesa/drivers/glide/fxddspan.c b/src/mesa/drivers/glide/fxddspan.c index 04d832d8d9..e106ce291e 100644 --- a/src/mesa/drivers/glide/fxddspan.c +++ b/src/mesa/drivers/glide/fxddspan.c @@ -1,4 +1,9 @@ -/* $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 @@ -42,6 +47,7 @@ #if defined(FX) #include "fxdrv.h" +#include "fxglidew.h" #include "swrast/swrast.h" #ifdef _MSC_VER @@ -347,6 +353,69 @@ read_R5G6B5_span(const GLcontext * ctx, 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 *****/ @@ -424,6 +493,68 @@ read_R5G6B5_pixels(const GLcontext * ctx, } +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 *****/ @@ -465,6 +596,35 @@ fxDDWriteDepthSpan(GLcontext * ctx, 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[]) { @@ -484,6 +644,21 @@ fxDDReadDepthSpan(GLcontext * ctx, } +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, @@ -511,6 +686,30 @@ 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[]) { @@ -532,6 +731,26 @@ fxDDReadDepthPixels(GLcontext * ctx, GLuint n, } +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 */ @@ -573,14 +792,36 @@ fxSetupDDSpanPointers(GLcontext * ctx) 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; + } + } } diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index c7e1b5aa7a..56d76634fb 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -1,4 +1,4 @@ -/* $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 @@ -334,6 +334,8 @@ extern GLubyte FX_PixelToR[0x10000]; 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 *); @@ -440,6 +442,8 @@ struct tfxMesaContext int clipMaxX; int clipMinY; int clipMaxY; + + int colDepth; }; diff --git a/src/mesa/drivers/glide/fxglidew.c b/src/mesa/drivers/glide/fxglidew.c index e45dfabcec..950dfdbc86 100644 --- a/src/mesa/drivers/glide/fxglidew.c +++ b/src/mesa/drivers/glide/fxglidew.c @@ -1,4 +1,4 @@ -/* $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 @@ -386,6 +386,13 @@ FX_grSstQueryHardware(GrHwConfiguration * config) 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; @@ -428,15 +435,25 @@ FX_grSstQueryHardware(GrHwConfiguration * c) /* 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, diff --git a/src/mesa/drivers/glide/fxglidew.h b/src/mesa/drivers/glide/fxglidew.h index 1efe150140..1ef3451d92 100644 --- a/src/mesa/drivers/glide/fxglidew.h +++ b/src/mesa/drivers/glide/fxglidew.h @@ -1,4 +1,4 @@ -/* $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 @@ -42,7 +42,9 @@ */ #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 @@ -117,6 +119,9 @@ typedef struct GrVoodooConfig_St 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; @@ -140,7 +145,7 @@ GrAT3DConfig_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 @@ -474,10 +479,12 @@ extern void FX_grGammaCorrectionValue(float val); #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); |