summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/glide/fxddspan.c
diff options
context:
space:
mode:
authorDaniel Borca <[email protected]>2003-10-09 15:12:20 +0000
committerDaniel Borca <[email protected]>2003-10-09 15:12:20 +0000
commitd9f1e453ea775f2394d6e9cf0d307ab4e5334fec (patch)
treeb9d276dea2af818cfe5727a00ffc188ec0e7207b /src/mesa/drivers/glide/fxddspan.c
parentbcb3957b6c22caf35d9b300440648c3e656e8b4c (diff)
Reorganized combiners. Added optimized span functions.
Diffstat (limited to 'src/mesa/drivers/glide/fxddspan.c')
-rw-r--r--src/mesa/drivers/glide/fxddspan.c726
1 files changed, 312 insertions, 414 deletions
diff --git a/src/mesa/drivers/glide/fxddspan.c b/src/mesa/drivers/glide/fxddspan.c
index 460126e86b1..c7d5021923a 100644
--- a/src/mesa/drivers/glide/fxddspan.c
+++ b/src/mesa/drivers/glide/fxddspan.c
@@ -1,11 +1,4 @@
-/* Hack alert:
- * The performance hit is disastruous for SPAN functions.
- * Should we use SpanRenderStart / SpanRenderFinish in `swrast.h'
- * for locking / unlocking the LFB?
- * Optimize and check endianess for `read_R8G8B8_pixels'
- */
-
-/* $Id: fxddspan.c,v 1.25 2003/10/02 17:36:44 brianp Exp $ */
+/* $Id: fxddspan.c,v 1.26 2003/10/09 15:12:21 dborca Exp $ */
/*
* Mesa 3-D graphics library
@@ -54,16 +47,6 @@
#include "fxglidew.h"
#include "swrast/swrast.h"
-#ifdef _MSC_VER
-#ifdef _WIN32
-#pragma warning( disable : 4090 4022 )
-/* 4101 : "different 'const' qualifier"
- * 4022 : "pointer mistmatch for actual parameter 'n'
- */
-#endif
-#endif
-
-
#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
@@ -91,435 +74,316 @@
/************************************************************************/
/***** Span functions *****/
/************************************************************************/
+#define TDFXPACKCOLOR1555( r, g, b, a ) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+#define TDFXPACKCOLOR565( r, g, b ) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+#define TDFXPACKCOLOR8888( r, g, b, a ) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+/************************************************************************/
-static void
-fxDDWriteRGBASpan(const GLcontext * ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte rgba[][4], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLuint i;
- GLint bottom = fxMesa->height - 1;
+#define DBG 0
+
+
+#define LOCAL_VARS \
+ GLuint pitch = info.strideInBytes; \
+ GLuint height = fxMesa->height; \
+ char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \
+ GLuint p; \
+ (void) buf; (void) p;
+
+#define CLIPPIXEL( _x, _y ) ( _x >= minx && _x < maxx && \
+ _y >= miny && _y < maxy )
- if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(...)\n", __FUNCTION__);
- }
+#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
+ if ( _y < miny || _y >= maxy ) { \
+ _n1 = 0, _x1 = x; \
+ } else { \
+ _n1 = _n; \
+ _x1 = _x; \
+ if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx;\
+ if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
+ }
- if (mask) {
- int span = 0;
+#define Y_FLIP(_y) (height - _y - 1)
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- ++span;
- }
- else {
- if (span > 0) {
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x + i - span,
- bottom - y,
- /* GR_LFB_SRC_FMT_8888, */ span, /*1, */ 0,
- (void *) rgba[i - span]);
- span = 0;
- }
- }
- }
+#define HW_WRITE_LOCK() \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GrLfbInfo_t info; \
+ info.size = sizeof(GrLfbInfo_t); \
+ if ( grLfbLock( GR_LFB_WRITE_ONLY, \
+ fxMesa->currentFB, LFB_MODE, \
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
+
+#define HW_WRITE_UNLOCK() \
+ grLfbUnlock( GR_LFB_WRITE_ONLY, fxMesa->currentFB ); \
+ }
- if (span > 0)
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x + n - span, bottom - y,
- /* GR_LFB_SRC_FMT_8888, */ span, /*1, */ 0,
- (void *) rgba[n - span]);
- }
- else
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x, bottom - y, /* GR_LFB_SRC_FMT_8888, */
- n, /* 1, */ 0, (void *) rgba);
-}
+#define HW_READ_LOCK() \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GrLfbInfo_t info; \
+ info.size = sizeof(GrLfbInfo_t); \
+ if ( grLfbLock( GR_LFB_READ_ONLY, fxMesa->currentFB, \
+ LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
+#define HW_READ_UNLOCK() \
+ grLfbUnlock( GR_LFB_READ_ONLY, fxMesa->currentFB ); \
+ }
-static void
-fxDDWriteRGBSpan(const GLcontext * ctx,
- GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLuint i;
- GLint bottom = fxMesa->height - 1;
- GLubyte rgba[MAX_WIDTH][4];
+#define HW_WRITE_CLIPLOOP() \
+ do { \
+ int _nc = 1; /* numcliprects */ \
+ while (_nc--) { \
+ const int minx = fxMesa->clipMinX; \
+ const int miny = fxMesa->clipMinY; \
+ const int maxx = fxMesa->clipMaxX; \
+ const int maxy = fxMesa->clipMaxY;
- if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(...)\n", __FUNCTION__);
- }
+#define HW_READ_CLIPLOOP() \
+ do { \
+ int _nc = 1; /* numcliprects */ \
+ while (_nc--) { \
+ const int minx = fxMesa->clipMinX; \
+ const int miny = fxMesa->clipMinY; \
+ const int maxx = fxMesa->clipMaxX; \
+ const int maxy = fxMesa->clipMaxY;
- if (mask) {
- int span = 0;
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- rgba[span][RCOMP] = rgb[i][0];
- rgba[span][GCOMP] = rgb[i][1];
- rgba[span][BCOMP] = rgb[i][2];
- rgba[span][ACOMP] = 255;
- ++span;
- }
- else {
- if (span > 0) {
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x + i - span,
- bottom - y,
- /*GR_LFB_SRC_FMT_8888, */ span, /* 1, */ 0,
- (void *) rgba);
- span = 0;
- }
- }
- }
- if (span > 0)
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x + n - span, bottom - y,
- /*GR_LFB_SRC_FMT_8888, */ span, /* 1, */ 0,
- (void *) rgba);
- }
- else {
- for (i = 0; i < n; i++) {
- rgba[i][RCOMP] = rgb[i][0];
- rgba[i][GCOMP] = rgb[i][1];
- rgba[i][BCOMP] = rgb[i][2];
- rgba[i][ACOMP] = 255;
- }
+/* 16 bit, ARGB1555 color spanline and pixel functions */
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x, bottom - y, /* GR_LFB_SRC_FMT_8888, */
- n, /* 1, */ 0, (void *) rgba);
- }
-}
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_1555
+#undef BYTESPERPIXEL
+#define BYTESPERPIXEL 2
-static void
-fxDDWriteMonoRGBASpan(const GLcontext * ctx,
- GLuint n, GLint x, GLint y,
- const GLchan color[4], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLuint i;
- GLint bottom = fxMesa->height - 1;
- GLuint data[MAX_WIDTH];
- GrColor_t gColor = FXCOLOR4(color);
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR1555( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] )
- if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(...)\n", __FUNCTION__);
- }
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
+ TDFXPACKCOLOR1555( r, g, b, a )
- if (mask) {
- int span = 0;
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- data[span] = (GLuint) gColor;
- ++span;
- }
- else {
- if (span > 0) {
- writeRegionClipped(fxMesa, fxMesa->currentFB, x + i - span,
- bottom - y, GR_LFB_SRC_FMT_8888, span, 1, 0,
- (void *) data);
- span = 0;
- }
- }
- }
+#define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
+ rgba[0] = FX_rgb_scale_5[(p >> 10) & 0x1F]; \
+ rgba[1] = FX_rgb_scale_5[(p >> 5) & 0x1F]; \
+ rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \
+ rgba[3] = (p & 0x8000) ? 255 : 0; \
+ } while (0)
- if (span > 0)
- writeRegionClipped(fxMesa, fxMesa->currentFB, x + n - span,
- bottom - y, GR_LFB_SRC_FMT_8888, span, 1, 0,
- (void *) data);
- }
- else {
- for (i = 0; i < n; i++) {
- data[i] = (GLuint) gColor;
- }
+#define TAG(x) tdfx##x##_ARGB1555
+#include "../dri/common/spantmp.h"
- writeRegionClipped(fxMesa, fxMesa->currentFB, x, bottom - y,
- GR_LFB_SRC_FMT_8888, n, 1, 0, (void *) data);
- }
-}
+/* 16 bit, RGB565 color spanline and pixel functions */
+
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_565
+
+#undef BYTESPERPIXEL
+#define BYTESPERPIXEL 2
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR565( color[RCOMP], color[GCOMP], color[BCOMP] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
+ TDFXPACKCOLOR565( r, g, b )
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
-#if 0
-static void
-fxDDReadRGBASpan(const GLcontext * ctx,
- GLuint n, GLint x, GLint y, GLubyte rgba[][4])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLushort data[MAX_WIDTH];
- GLuint i;
- GLint bottom = fxMesa->height - 1;
+#define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
+ rgba[0] = FX_rgb_scale_5[(p >> 11) & 0x1F]; \
+ rgba[1] = FX_rgb_scale_6[(p >> 5) & 0x3F]; \
+ rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \
+ rgba[3] = 0xff; \
+ } while (0)
- if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(...)\n", __FUNCTION__);
- }
+#define TAG(x) tdfx##x##_RGB565
+#include "../dri/common/spantmp.h"
- assert(n < MAX_WIDTH);
- FX_grLfbReadRegion(fxMesa->currentFB, x, bottom - y, n, 1, 0, data);
+/* 32 bit, ARGB8888 color spanline and pixel functions */
- for (i = 0; i < n; i++) {
- GLushort pixel = data[i];
- rgba[i][RCOMP] = FX_PixelToR[pixel];
- rgba[i][GCOMP] = FX_PixelToG[pixel];
- rgba[i][BCOMP] = FX_PixelToB[pixel];
- rgba[i][ACOMP] = 255;
- }
-}
-#endif
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_8888
+#undef BYTESPERPIXEL
+#define BYTESPERPIXEL 4
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR8888( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
+ TDFXPACKCOLOR8888( r, g, b, a )
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLuint p = *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
+ rgba[0] = (p >> 16) & 0xff; \
+ rgba[1] = (p >> 8) & 0xff; \
+ rgba[2] = (p >> 0) & 0xff; \
+ rgba[3] = (p >> 24) & 0xff; \
+ } while (0)
+
+#define TAG(x) tdfx##x##_ARGB8888
+#include "../dri/common/spantmp.h"
+
+
+/************************************************************************/
+/***** Span functions (optimized) *****/
+/************************************************************************/
/*
- * Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects
+ * 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_R5G6B5_span(const GLcontext * ctx,
- GLuint n, GLint x, GLint y, GLubyte rgba[][4])
+static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx,
+ GLuint n,
+ GLint x, GLint y,
+ GLubyte rgba[][4])
{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- 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];
- GLuint pixel0 = pixel & 0xffff;
- GLuint pixel1 = pixel >> 16;
- rgba[i][RCOMP] = FX_PixelToR[pixel0];
- rgba[i][GCOMP] = FX_PixelToG[pixel0];
- rgba[i][BCOMP] = FX_PixelToB[pixel0];
- rgba[i][ACOMP] = 255;
- rgba[i + 1][RCOMP] = FX_PixelToR[pixel1];
- rgba[i + 1][GCOMP] = FX_PixelToG[pixel1];
- rgba[i + 1][BCOMP] = FX_PixelToB[pixel1];
- rgba[i + 1][ACOMP] = 255;
- }
- if (extraPixel) {
- GLushort pixel = data16[n];
- rgba[n][RCOMP] = FX_PixelToR[pixel];
- rgba[n][GCOMP] = FX_PixelToG[pixel];
- rgba[n][BCOMP] = FX_PixelToB[pixel];
- rgba[n][ACOMP] = 255;
- }
-
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ info.size = sizeof(GrLfbInfo_t);
+ 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 GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
+ (winY - y) * info.strideInBytes +
+ (winX + x) * 2);
+ 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][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
+ rgba[i][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
+ rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
+ rgba[i][3] = (pixel & 0x8000) ? 255 : 0;
+ rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 26) & 0x1F];
+ rgba[i+1][1] = FX_rgb_scale_5[(pixel >> 21) & 0x1F];
+ rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
+ rgba[i+1][3] = (pixel & 0x80000000) ? 255 : 0;
+ }
+ if (extraPixel) {
+ GLushort pixel = data16[n];
+ rgba[n][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
+ rgba[n][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
+ rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
+ rgba[n][3] = (pixel & 0x8000) ? 255 : 0;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
}
/*
- * Read a span of 15-bit RGB pixels. Note, we don't worry about cliprects
+ * Read a span of 16-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])
+static void fxReadRGBASpan_RGB565 (const GLcontext * ctx,
+ GLuint n,
+ GLint x, GLint y,
+ GLubyte rgba[][4])
{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- 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;
- }
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ info.size = sizeof(GrLfbInfo_t);
+ 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 GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
+ (winY - y) * info.strideInBytes +
+ (winX + x) * 2);
+ 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];
+#if 0
+ GLuint pixel0 = pixel & 0xffff;
+ GLuint pixel1 = pixel >> 16;
+ rgba[i][RCOMP] = FX_PixelToR[pixel0];
+ rgba[i][GCOMP] = FX_PixelToG[pixel0];
+ rgba[i][BCOMP] = FX_PixelToB[pixel0];
+ rgba[i][ACOMP] = 255;
+ rgba[i + 1][RCOMP] = FX_PixelToR[pixel1];
+ rgba[i + 1][GCOMP] = FX_PixelToG[pixel1];
+ rgba[i + 1][BCOMP] = FX_PixelToB[pixel1];
+ rgba[i + 1][ACOMP] = 255;
+#else
+ rgba[i][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
+ rgba[i][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
+ rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
+ rgba[i][3] = 255;
+ rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 27) & 0x1F];
+ rgba[i+1][1] = FX_rgb_scale_6[(pixel >> 21) & 0x3F];
+ rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
+ rgba[i+1][3] = 255;
+#endif
+ }
+ if (extraPixel) {
+ GLushort pixel = data16[n];
+#if 0
+ rgba[n][RCOMP] = FX_PixelToR[pixel];
+ rgba[n][GCOMP] = FX_PixelToG[pixel];
+ rgba[n][BCOMP] = FX_PixelToB[pixel];
+ rgba[n][ACOMP] = 255;
+#else
+ rgba[n][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
+ rgba[n][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
+ rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
+ rgba[n][3] = 255;
+#endif
+ }
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
}
/*
* 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 = FX_CONTEXT(ctx);
- BEGIN_BOARD_LOCK();
- grLfbReadRegion(fxMesa->currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
- END_BOARD_LOCK();
-}
-
-
-/************************************************************************/
-/***** Pixel functions *****/
-/************************************************************************/
-
-static void
-fxDDWriteRGBAPixels(const GLcontext * ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLubyte rgba[][4], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLuint i;
- GLint bottom = fxMesa->height - 1;
-
- if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(...)\n", __FUNCTION__);
- }
-
- for (i = 0; i < n; i++)
- if (mask[i])
- LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i], bottom - y[i],
- 1, 1, (void *) rgba[i]);
-}
-
-static void
-fxDDWriteMonoRGBAPixels(const GLcontext * ctx,
- GLuint n, const GLint x[], const GLint y[],
- const GLchan color[4], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLuint i;
- GLint bottom = fxMesa->height - 1;
- GrColor_t gColor = FXCOLOR4(color);
-
- if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(...)\n", __FUNCTION__);
- }
-
- for (i = 0; i < n; i++)
- if (mask[i])
- writeRegionClipped(fxMesa, fxMesa->currentFB, x[i], bottom - y[i],
- GR_LFB_SRC_FMT_8888, 1, 1, 0, (void *) &gColor);
-}
-
-
-static void
-read_R5G6B5_pixels(const GLcontext * ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- 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_PixelToR[pixel];
- rgba[i][GCOMP] = FX_PixelToG[pixel];
- rgba[i][BCOMP] = FX_PixelToB[pixel];
- rgba[i][ACOMP] = 255;
- }
- }
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
- }
- END_BOARD_LOCK();
-}
-
-
-static void read_R5G5B5_pixels (const GLcontext * ctx,
- GLuint n,
- const GLint x[], const GLint y[],
- GLubyte rgba[][4],
- const GLubyte mask[])
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- 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[])
+static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx,
+ GLuint n,
+ GLint x, GLint y,
+ GLubyte rgba[][4])
{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- 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();
+ /* Hack alert: WRONG! */
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ grLfbReadRegion(fxMesa->currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
}
-
/************************************************************************/
/***** Depth functions *****/
/************************************************************************/
@@ -753,45 +617,79 @@ void
fxSetupDDSpanPointers(GLcontext * ctx)
{
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
swdd->SetBuffer = fxDDSetBuffer;
- swdd->WriteRGBASpan = fxDDWriteRGBASpan;
- swdd->WriteRGBSpan = fxDDWriteRGBSpan;
- swdd->WriteMonoRGBASpan = fxDDWriteMonoRGBASpan;
- swdd->WriteRGBAPixels = fxDDWriteRGBAPixels;
- swdd->WriteMonoRGBAPixels = fxDDWriteMonoRGBAPixels;
-
- /* swdd->ReadRGBASpan =fxDDReadRGBASpan; */
- {
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
switch (fxMesa->colDepth) {
case 15:
- swdd->ReadRGBASpan = read_R5G5B5_span;
- swdd->ReadRGBAPixels = read_R5G5B5_pixels;
+ swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB1555;
+ swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB1555;
+ swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB1555;
+ swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB1555;
+ swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB1555;
+ swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB1555;
+ swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB1555;
+
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->WriteRGBASpan = tdfxWriteRGBASpan_RGB565;
+ swdd->WriteRGBSpan = tdfxWriteRGBSpan_RGB565;
+ swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_RGB565;
+ swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB565;
+ swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB565;
+ swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_RGB565;
+ swdd->ReadRGBAPixels = tdfxReadRGBAPixels_RGB565;
+
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->WriteRGBASpan = tdfxWriteRGBASpan_ARGB8888;
+ swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB8888;
+ swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB8888;
+ swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB8888;
+ swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB8888;
+ swdd->ReadRGBASpan = tdfxReadRGBASpan_ARGB8888;
+ swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB8888;
+
swdd->WriteDepthSpan = fxDDWriteDepth32Span;
swdd->WriteDepthPixels = fxDDWriteDepth32Pixels;
swdd->ReadDepthSpan = fxDDReadDepth32Span;
swdd->ReadDepthPixels = fxDDReadDepth32Pixels;
break;
}
- }
+
+#if 0
+ if ( fxMesa->haveHwStencil ) {
+ swdd->WriteStencilSpan = write_stencil_span;
+ swdd->ReadStencilSpan = read_stencil_span;
+ swdd->WriteStencilPixels = write_stencil_pixels;
+ swdd->ReadStencilPixels = read_stencil_pixels;
+ }
+
+ swdd->WriteDepthSpan = tdfxDDWriteDepthSpan;
+ swdd->WriteDepthPixels = tdfxDDWriteDepthPixels;
+ swdd->ReadDepthSpan = tdfxDDReadDepthSpan;
+ swdd->ReadDepthPixels = tdfxDDReadDepthPixels;
+
+ swdd->WriteCI8Span = NULL;
+ swdd->WriteCI32Span = NULL;
+ swdd->WriteMonoCISpan = NULL;
+ swdd->WriteCI32Pixels = NULL;
+ swdd->WriteMonoCIPixels = NULL;
+ swdd->ReadCI32Span = NULL;
+ swdd->ReadCI32Pixels = NULL;
+
+ swdd->SpanRenderStart = tdfxSpanRenderStart; /* BEGIN_BOARD_LOCK */
+ swdd->SpanRenderFinish = tdfxSpanRenderFinish; /* END_BOARD_LOCK */
+#endif
}