#define LOCAL_VARS \
+ GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER; \
GLuint pitch = info.strideInBytes; \
GLuint height = fxMesa->height; \
char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \
GrLfbInfo_t info; \
info.size = sizeof(GrLfbInfo_t); \
if ( grLfbLock( GR_LFB_WRITE_ONLY, \
- fxMesa->currentFB, LFB_MODE, \
+ currentFB, LFB_MODE, \
GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
#define HW_WRITE_UNLOCK() \
- grLfbUnlock( GR_LFB_WRITE_ONLY, fxMesa->currentFB ); \
+ grLfbUnlock( GR_LFB_WRITE_ONLY, currentFB ); \
}
#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, \
+ if ( grLfbLock( GR_LFB_READ_ONLY, currentFB, \
LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
#define HW_READ_UNLOCK() \
- grLfbUnlock( GR_LFB_READ_ONLY, fxMesa->currentFB ); \
+ grLfbUnlock( GR_LFB_READ_ONLY, currentFB ); \
}
#define HW_WRITE_CLIPLOOP() \
do { \
- int _nc = 1; /* numcliprects */ \
- /* [dBorca] Hack alert: */ \
/* remember, we need to flip the scissor, too */ \
/* is it better to do it inside fxDDScissor? */ \
- while (_nc--) { \
- const int minx = fxMesa->clipMinX; \
- const int maxy = Y_FLIP(fxMesa->clipMinY); \
- const int maxx = fxMesa->clipMaxX; \
- const int miny = Y_FLIP(fxMesa->clipMaxY);
+ const int minx = fxMesa->clipMinX; \
+ const int maxy = Y_FLIP(fxMesa->clipMinY); \
+ const int maxx = fxMesa->clipMaxX; \
+ const int miny = Y_FLIP(fxMesa->clipMaxY);
#define HW_READ_CLIPLOOP() \
do { \
- int _nc = 1; /* numcliprects */ \
- /* [dBorca] Hack alert: */ \
/* remember, we need to flip the scissor, too */ \
/* is it better to do it inside fxDDScissor? */ \
- while (_nc--) { \
- const int minx = fxMesa->clipMinX; \
- const int maxy = Y_FLIP(fxMesa->clipMinY); \
- const int maxx = fxMesa->clipMaxX; \
- const int miny = Y_FLIP(fxMesa->clipMaxY);
+ const int minx = fxMesa->clipMinX; \
+ const int maxy = Y_FLIP(fxMesa->clipMinY); \
+ const int maxx = fxMesa->clipMaxX; \
+ const int miny = Y_FLIP(fxMesa->clipMaxY);
#define HW_ENDCLIPLOOP() \
- } \
} while (0)
#undef BYTESPERPIXEL
#define BYTESPERPIXEL 2
+#define VALUE_TYPE GLushort
+
#define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d
#undef BYTESPERPIXEL
#define BYTESPERPIXEL 4
+#define VALUE_TYPE GLuint
+
#define WRITE_DEPTH( _x, _y, d ) \
*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8
* since OpenGL says obscured pixels have undefined values.
*/
static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx,
+ struct gl_renderbuffer *rb,
GLuint n,
GLint x, GLint y,
GLubyte rgba[][4])
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
GrLfbInfo_t info;
info.size = sizeof(GrLfbInfo_t);
- if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB,
+ if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
const GLint winX = 0;
const GLint winY = fxMesa->height - 1;
rgba[n][3] = (pixel & 0x8000) ? 255 : 0;
}
- grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
}
}
* since OpenGL says obscured pixels have undefined values.
*/
static void fxReadRGBASpan_RGB565 (const GLcontext * ctx,
+ struct gl_renderbuffer *rb,
GLuint n,
GLint x, GLint y,
GLubyte rgba[][4])
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
GrLfbInfo_t info;
info.size = sizeof(GrLfbInfo_t);
- if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB,
+ if (grLfbLock(GR_LFB_READ_ONLY, currentFB,
GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
const GLint winX = 0;
const GLint winY = fxMesa->height - 1;
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+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);
+ grLfbUnlock(GR_LFB_READ_ONLY, currentFB);
}
}
* since OpenGL says obscured pixels have undefined values.
*/
static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx,
+ struct gl_renderbuffer *rb,
GLuint n,
GLint x, GLint y,
GLubyte rgba[][4])
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrBuffer_t currentFB = GR_BUFFER_BACKBUFFER;
GLuint i;
- grLfbReadRegion(fxMesa->currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
+ grLfbReadRegion(currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
for (i = 0; i < n; i++) {
GLubyte c = rgba[i][0];
rgba[i][0] = rgba[i][2];
/***** Depth functions (optimized) *****/
/************************************************************************/
-void
-fxReadDepthSpan_Z16(GLcontext * ctx,
- GLuint n, GLint x, GLint y, GLdepth depth[])
+static void
+fxReadDepthSpan_Z16(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint depth[])
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
GLint bottom = fxMesa->height - 1;
GLuint i;
if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(...)\n", __FUNCTION__);
+ fprintf(stderr, "fxReadDepthSpan_Z16(...)\n");
}
grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
}
-void
-fxReadDepthSpan_Z24(GLcontext * ctx,
- GLuint n, GLint x, GLint y, GLdepth depth[])
+static void
+fxReadDepthSpan_Z24(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint depth[])
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
GLint bottom = fxMesa->height - 1;
GLuint i;
if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(...)\n", __FUNCTION__);
+ fprintf(stderr, "fxReadDepthSpan_Z24(...)\n");
}
grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth);
/***** Stencil functions (optimized) *****/
/************************************************************************/
-void fxWriteStencilSpan (GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLstencil stencil[], const GLubyte mask[])
+static void
+fxWriteStencilSpan (GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLstencil stencil[], const GLubyte mask[])
{
/*
* XXX todo
*/
}
-void
-fxReadStencilSpan(GLcontext * ctx,
+static void
+fxReadStencilSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y, GLstencil stencil[])
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
GLuint i;
if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(...)\n", __FUNCTION__);
+ fprintf(stderr, "fxReadStencilSpan(...)\n");
}
grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, zs32);
}
}
-void fxWriteStencilPixels (GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- const GLstencil stencil[],
- const GLubyte mask[])
+static void
+fxWriteStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLstencil stencil[],
+ const GLubyte mask[])
{
/*
* XXX todo
*/
}
-void fxReadStencilPixels (GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- GLstencil stencil[])
+static void
+fxReadStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
+ const GLint x[], const GLint y[],
+ GLstencil stencil[])
{
/*
* XXX todo
}
-
-/*
- * This function is called to specify which buffer to read and write
- * for software rasterization (swrast) fallbacks. This doesn't necessarily
- * correspond to glDrawBuffer() or glReadBuffer() calls.
- */
-static void
-fxDDSetBuffer(GLcontext * ctx, GLframebuffer * buffer, GLuint bufferBit)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- (void) buffer;
-
- if (TDFX_DEBUG & VERBOSE_DRIVER) {
- fprintf(stderr, "%s(%x)\n", __FUNCTION__, (int)bufferBit);
- }
-
- if (bufferBit == FRONT_LEFT_BIT) {
- fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
- grRenderBuffer(fxMesa->currentFB);
- }
- else if (bufferBit == BACK_LEFT_BIT) {
- fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
- grRenderBuffer(fxMesa->currentFB);
- }
-}
-
-
-/************************************************************************/
-
-
-
void
fxSetupDDSpanPointers(GLcontext * ctx)
{
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
fxMesaContext fxMesa = FX_CONTEXT(ctx);
- swdd->SetBuffer = fxDDSetBuffer;
-
switch (fxMesa->colDepth) {
case 15:
swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB1555;