summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2001-03-19 02:25:35 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2001-03-19 02:25:35 +0000
commit709892459922a32096fe9dd8261d0d92337bb02f (patch)
tree87782215d4531207c97b236a5dfa0d15c45aef8a /src/mesa/swrast
parentd9bf6ccce9f5fea22d6a478c4afafea3c3c525c5 (diff)
Split driver struct into swrast/tnl/core components.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_aatriangle.c4
-rw-r--r--src/mesa/swrast/s_accum.c32
-rw-r--r--src/mesa/swrast/s_bitmap.c9
-rw-r--r--src/mesa/swrast/s_blend.c4
-rw-r--r--src/mesa/swrast/s_buffers.c32
-rw-r--r--src/mesa/swrast/s_context.c31
-rw-r--r--src/mesa/swrast/s_context.h19
-rw-r--r--src/mesa/swrast/s_copypix.c40
-rw-r--r--src/mesa/swrast/s_depth.c31
-rw-r--r--src/mesa/swrast/s_drawpix.c36
-rw-r--r--src/mesa/swrast/s_logic.c11
-rw-r--r--src/mesa/swrast/s_masking.c10
-rw-r--r--src/mesa/swrast/s_readpix.c32
-rw-r--r--src/mesa/swrast/s_span.c29
-rw-r--r--src/mesa/swrast/s_stencil.c58
-rw-r--r--src/mesa/swrast/s_triangle.c15
-rw-r--r--src/mesa/swrast/swrast.h258
17 files changed, 502 insertions, 149 deletions
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index 1de030c776..df2182a0f0 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_aatriangle.c,v 1.9 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_aatriangle.c,v 1.10 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -395,7 +395,7 @@ spec_multitex_aa_tri(GLcontext *ctx,
/*
- * Examine GL state and set ctx->Driver.TriangleFunc to an
+ * Examine GL state and set swrast->Triangle to an
* appropriate antialiased triangle rasterizer function.
*/
void
diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c
index 240992066e..d93396677f 100644
--- a/src/mesa/swrast/s_accum.c
+++ b/src/mesa/swrast/s_accum.c
@@ -1,4 +1,4 @@
-/* $Id: s_accum.c,v 1.8 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_accum.c,v 1.9 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -312,8 +312,8 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
if (value == 0.0F)
return;
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ ctx->Pixel.DriverReadBuffer );
/* May have to leave optimized accum buffer mode */
if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
@@ -321,7 +321,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
if (swrast->_IntegerAccumMode && value != swrast->_IntegerAccumScaler)
rescale_accum(ctx);
- RENDER_START(ctx);
+ RENDER_START(swrast,ctx);
if (swrast->_IntegerAccumMode) {
/* simply add integer color values into accum buffer */
@@ -364,14 +364,14 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
}
}
/* restore read buffer = draw buffer (the default) */
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
- RENDER_FINISH(ctx);
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
+ ctx->Color.DriverDrawBuffer );
+ RENDER_FINISH(swrast,ctx);
break;
case GL_LOAD:
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ ctx->Pixel.DriverReadBuffer );
/* This is a change to go into optimized accum buffer mode */
if (value > 0.0 && value <= 1.0) {
@@ -387,7 +387,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
swrast->_IntegerAccumScaler = 0.0;
}
- RENDER_START(ctx);
+ RENDER_START(swrast,ctx);
if (swrast->_IntegerAccumMode) {
/* just copy values into accum buffer */
GLint j;
@@ -429,9 +429,9 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
}
/* restore read buffer = draw buffer (the default) */
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
ctx->Color.DriverDrawBuffer );
- RENDER_FINISH(ctx);
+ RENDER_FINISH(swrast,ctx);
break;
case GL_RETURN:
@@ -439,7 +439,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
if (swrast->_IntegerAccumMode && value != 1.0)
rescale_accum(ctx);
- RENDER_START(ctx);
+ RENDER_START(swrast,ctx);
if (swrast->_IntegerAccumMode && swrast->_IntegerAccumScaler > 0) {
/* build lookup table to avoid many floating point multiplies */
static GLchan multTable[32768];
@@ -471,7 +471,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
if (colorMask != 0xffffffff) {
_mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba );
}
- (*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
+ (*swrast->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
(const GLchan (*)[4])rgba, NULL );
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
&& ctx->Color.ColorMask[ACOMP]) {
@@ -503,7 +503,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
if (colorMask != 0xffffffff) {
_mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba );
}
- (*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
+ (*swrast->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
(const GLchan (*)[4])rgba, NULL );
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
&& ctx->Color.ColorMask[ACOMP]) {
@@ -513,7 +513,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
ypos++;
}
}
- RENDER_FINISH(ctx);
+ RENDER_FINISH(swrast,ctx);
break;
default:
diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c
index 243219b75c..d22579c02f 100644
--- a/src/mesa/swrast/s_bitmap.c
+++ b/src/mesa/swrast/s_bitmap.c
@@ -1,4 +1,4 @@
-/* $Id: s_bitmap.c,v 1.6 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_bitmap.c,v 1.7 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -45,7 +45,8 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
const struct gl_pixelstore_attrib *unpack,
const GLubyte *bitmap )
{
- struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct pixel_buffer *PB = swrast->PB;
GLint row, col;
GLdepth fragZ;
GLfixed fogCoord;
@@ -53,6 +54,8 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
ASSERT(ctx->RenderMode == GL_RENDER);
ASSERT(bitmap);
+ RENDER_START(swrast,ctx);
+
if (SWRAST_CONTEXT(ctx)->NewState)
_swrast_validate_derived( ctx );
@@ -124,4 +127,6 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
}
_mesa_flush_pb(ctx);
+
+ RENDER_FINISH(swrast,ctx);
}
diff --git a/src/mesa/swrast/s_blend.c b/src/mesa/swrast/s_blend.c
index 3e15ae5deb..73ca3d1c52 100644
--- a/src/mesa/swrast/s_blend.c
+++ b/src/mesa/swrast/s_blend.c
@@ -1,4 +1,4 @@
-/* $Id: s_blend.c,v 1.6 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_blend.c,v 1.7 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -660,7 +660,7 @@ _mesa_blend_pixels( GLcontext *ctx,
}
/* Read pixels from current color buffer */
- (*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
+ (*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c
index 003e469559..409c3f6442 100644
--- a/src/mesa/swrast/s_buffers.c
+++ b/src/mesa/swrast/s_buffers.c
@@ -1,4 +1,4 @@
-/* $Id: s_buffers.c,v 1.7 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_buffers.c,v 1.8 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,6 +31,7 @@
#include "s_accum.h"
#include "s_alphabuf.h"
+#include "s_context.h"
#include "s_depth.h"
#include "s_masking.h"
#include "s_stencil.h"
@@ -44,6 +45,7 @@
static void
clear_color_buffer_with_masking( GLcontext *ctx )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLint x = ctx->DrawBuffer->_Xmin;
const GLint y = ctx->DrawBuffer->_Ymin;
const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
@@ -66,7 +68,7 @@ clear_color_buffer_with_masking( GLcontext *ctx )
rgba[j][ACOMP] = a;
}
_mesa_mask_rgba_span( ctx, width, x, y + i, rgba );
- (*ctx->Driver.WriteRGBASpan)( ctx, width, x, y + i,
+ (*swrast->Driver.WriteRGBASpan)( ctx, width, x, y + i,
(CONST GLchan (*)[4]) rgba, NULL );
}
}
@@ -81,7 +83,7 @@ clear_color_buffer_with_masking( GLcontext *ctx )
span[j] = ctx->Color.ClearIndex;
}
_mesa_mask_index_span( ctx, width, x, y + i, span );
- (*ctx->Driver.WriteCI32Span)( ctx, width, x, y + i, span, mask );
+ (*swrast->Driver.WriteCI32Span)( ctx, width, x, y + i, span, mask );
}
}
}
@@ -94,6 +96,7 @@ clear_color_buffer_with_masking( GLcontext *ctx )
static void
clear_color_buffer(GLcontext *ctx)
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLint x = ctx->DrawBuffer->_Xmin;
const GLint y = ctx->DrawBuffer->_Ymin;
const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
@@ -117,7 +120,7 @@ clear_color_buffer(GLcontext *ctx)
span[i][ACOMP] = a;
}
for (i = 0; i < height; i++) {
- (*ctx->Driver.WriteRGBASpan)( ctx, width, x, y + i,
+ (*swrast->Driver.WriteRGBASpan)( ctx, width, x, y + i,
(CONST GLchan (*)[4]) span, NULL );
}
}
@@ -131,7 +134,7 @@ clear_color_buffer(GLcontext *ctx)
GLint i;
MEMSET(span, ctx->Color.ClearIndex, width);
for (i = 0; i < height; i++) {
- (*ctx->Driver.WriteCI8Span)( ctx, width, x, y + i, span, NULL );
+ (*swrast->Driver.WriteCI8Span)( ctx, width, x, y + i, span, NULL );
}
}
else {
@@ -142,7 +145,7 @@ clear_color_buffer(GLcontext *ctx)
span[i] = ctx->Color.ClearIndex;
}
for (i = 0; i < height; i++) {
- (*ctx->Driver.WriteCI32Span)( ctx, width, x, y + i, span, NULL );
+ (*swrast->Driver.WriteCI32Span)( ctx, width, x, y + i, span, NULL );
}
}
}
@@ -158,6 +161,7 @@ clear_color_buffer(GLcontext *ctx)
static void
clear_color_buffers(GLcontext *ctx)
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
GLuint bufferBit;
@@ -166,19 +170,19 @@ clear_color_buffers(GLcontext *ctx)
if (bufferBit & ctx->Color.DrawDestMask) {
if (bufferBit == FRONT_LEFT_BIT) {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
- (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
+ (void) (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
}
else if (bufferBit == FRONT_RIGHT_BIT) {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
- (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
+ (void) (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
}
else if (bufferBit == BACK_LEFT_BIT) {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
- (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_LEFT);
+ (void) (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_LEFT);
}
else {
(void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
- (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
+ (void) (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
}
if (colorMask != 0xffffffff) {
@@ -192,7 +196,7 @@ clear_color_buffers(GLcontext *ctx)
/* restore default read/draw buffers */
(void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer );
- (void) (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer );
+ (void) (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer );
}
@@ -202,7 +206,7 @@ _swrast_Clear( GLcontext *ctx, GLbitfield mask,
GLboolean all,
GLint x, GLint y, GLint width, GLint height )
{
-
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
#ifdef DEBUG
{
GLbitfield legalBits = DD_FRONT_LEFT_BIT |
@@ -216,7 +220,7 @@ _swrast_Clear( GLcontext *ctx, GLbitfield mask,
}
#endif
- RENDER_START(ctx);
+ RENDER_START(swrast,ctx);
/* do software clearing here */
if (mask) {
@@ -233,7 +237,7 @@ _swrast_Clear( GLcontext *ctx, GLbitfield mask,
_mesa_clear_alpha_buffers( ctx );
}
- RENDER_FINISH(ctx);
+ RENDER_FINISH(swrast,ctx);
}
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index ffcdc718c2..20090bdb12 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,4 +1,4 @@
-/* $Id: s_context.c,v 1.17 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_context.c,v 1.18 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -316,6 +316,27 @@ _swrast_invalidate_state( GLcontext *ctx, GLuint new_state )
if (new_state & _SWRAST_NEW_TEXTURE_SAMPLE_FUNC)
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
swrast->TextureSample[i] = _swrast_validate_texture_sample;
+
+
+ if (ctx->Visual.rgbMode) {
+ ASSERT(swrast->Driver.WriteRGBASpan);
+ ASSERT(swrast->Driver.WriteRGBSpan);
+ ASSERT(swrast->Driver.WriteMonoRGBASpan);
+ ASSERT(swrast->Driver.WriteRGBAPixels);
+ ASSERT(swrast->Driver.WriteMonoRGBAPixels);
+ ASSERT(swrast->Driver.ReadRGBASpan);
+ ASSERT(swrast->Driver.ReadRGBAPixels);
+ }
+ else {
+ ASSERT(swrast->Driver.WriteCI32Span);
+ ASSERT(swrast->Driver.WriteCI8Span);
+ ASSERT(swrast->Driver.WriteMonoCISpan);
+ ASSERT(swrast->Driver.WriteCI32Pixels);
+ ASSERT(swrast->Driver.WriteMonoCIPixels);
+ ASSERT(swrast->Driver.ReadCI32Span);
+ ASSERT(swrast->Driver.ReadCI32Pixels);
+ }
+
}
@@ -471,6 +492,14 @@ _swrast_DestroyContext( GLcontext *ctx )
}
+struct swrast_device_driver *
+_swrast_GetDeviceDriverReference( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ return &swrast->Driver;
+}
+
+
void
_swrast_print_vertex( GLcontext *ctx, const SWvertex *v )
{
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 7449cb2896..3bf9616d51 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -1,4 +1,4 @@
-/* $Id: s_context.h,v 1.7 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_context.h,v 1.8 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -100,6 +100,10 @@ typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *,
typedef struct
{
+ /* Driver interface:
+ */
+ struct swrast_device_driver Driver;
+
/* Configuration mechanisms to make software rasterizer match
* characteristics of the hardware rasterizer (if present):
*/
@@ -170,6 +174,19 @@ _swrast_validate_derived( GLcontext *ctx );
#define SWRAST_CONTEXT(ctx) ((SWcontext *)ctx->swrast_context)
+#define RENDER_START(SWctx, GLctx) \
+ do { \
+ if ((SWctx)->Driver.SpanRenderStart) { \
+ (*(SWctx)->Driver.SpanRenderStart)(GLctx); \
+ } \
+ } while (0)
+
+#define RENDER_FINISH(SWctx, GLctx) \
+ do { \
+ if ((SWctx)->Driver.SpanRenderFinish) { \
+ (*(SWctx)->Driver.SpanRenderFinish)(GLctx); \
+ } \
+ } while (0)
#endif
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index 1a8c0a069c..f85af995d3 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -1,4 +1,4 @@
-/* $Id: s_copypix.c,v 1.15 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_copypix.c,v 1.16 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -96,6 +96,7 @@ static void
copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty)
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLdepth zspan[MAX_WIDTH];
GLboolean quick_draw;
GLint row;
@@ -147,7 +148,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
dest = tmpImage;
if (changeBuffer) {
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT)
ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontLeftAlpha;
@@ -176,7 +177,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* read from the draw buffer again (in case of blending) */
if (changeBuffer) {
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
ctx->Color.DriverDrawBuffer );
ctx->ReadBuffer->Alpha = saveReadAlpha;
}
@@ -277,7 +278,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
dy = desty + row;
if (quick_draw && dy >= 0 && dy < ctx->DrawBuffer->Height) {
- (*ctx->Driver.WriteRGBASpan)( ctx, width, destx, dy,
+ (*swrast->Driver.WriteRGBASpan)( ctx, width, destx, dy,
(const GLchan (*)[4])rgba, NULL );
}
else if (zoom) {
@@ -300,6 +301,7 @@ static void
copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty)
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLdepth zspan[MAX_WIDTH];
GLchan rgba[MAX_WIDTH][4];
GLchan *tmpImage,*p;
@@ -357,7 +359,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer
|| ctx->DrawBuffer != ctx->ReadBuffer;
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
if (overlapping) {
@@ -369,7 +371,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
p = tmpImage;
if (changeBuffer) {
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT)
ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontLeftAlpha;
@@ -402,7 +404,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
else {
/* get from framebuffer */
if (changeBuffer) {
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT) {
ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontLeftAlpha;
@@ -422,7 +424,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (changeBuffer) {
/* read from the draw buffer again (in case of blending) */
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
ctx->Color.DriverDrawBuffer );
ctx->ReadBuffer->Alpha = saveReadAlpha;
}
@@ -521,7 +523,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
if (quick_draw && dy >= 0 && dy < ctx->DrawBuffer->Height) {
- (*ctx->Driver.WriteRGBASpan)( ctx, width, destx, dy,
+ (*swrast->Driver.WriteRGBASpan)( ctx, width, destx, dy,
(const GLchan (*)[4])rgba, NULL );
}
else if (zoom) {
@@ -534,7 +536,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
/* Restore pixel source to be the draw buffer (for blending, etc) */
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
ctx->Color.DriverDrawBuffer );
if (overlapping)
@@ -546,6 +548,7 @@ static void copy_ci_pixels( GLcontext *ctx,
GLint srcx, GLint srcy, GLint width, GLint height,
GLint destx, GLint desty )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLdepth zspan[MAX_WIDTH];
GLuint *tmpImage,*p;
GLint sy, dy, stepy;
@@ -584,7 +587,7 @@ static void copy_ci_pixels( GLcontext *ctx,
changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer
|| ctx->DrawBuffer != ctx->ReadBuffer;
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
if (overlapping) {
@@ -596,7 +599,7 @@ static void copy_ci_pixels( GLcontext *ctx,
}
p = tmpImage;
if (changeBuffer) {
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
}
for (j = 0; j < height; j++, ssy += stepy) {
@@ -618,7 +621,7 @@ static void copy_ci_pixels( GLcontext *ctx,
}
else {
if (changeBuffer) {
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer );
}
_mesa_read_index_span( ctx, ctx->ReadBuffer, width, srcx, sy, indexes );
@@ -626,7 +629,7 @@ static void copy_ci_pixels( GLcontext *ctx,
if (changeBuffer) {
/* set read buffer back to draw buffer (in case of logicops) */
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
ctx->Color.DriverDrawBuffer );
}
@@ -646,7 +649,7 @@ static void copy_ci_pixels( GLcontext *ctx,
}
/* Restore pixel source to be the draw buffer (for blending, etc) */
- (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
+ (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
ctx->Color.DriverDrawBuffer );
if (overlapping)
@@ -860,7 +863,10 @@ _swrast_CopyPixels( GLcontext *ctx,
GLint destx, GLint desty,
GLenum type )
{
- if (SWRAST_CONTEXT(ctx)->NewState)
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ RENDER_START(swrast,ctx);
+
+ if (swrast->NewState)
_swrast_validate_derived( ctx );
if (type == GL_COLOR && ctx->Visual.rgbMode) {
@@ -878,4 +884,6 @@ _swrast_CopyPixels( GLcontext *ctx,
else {
_mesa_error( ctx, GL_INVALID_ENUM, "glCopyPixels" );
}
+
+ RENDER_FINISH(swrast,ctx);
}
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 19101a24c4..5001081ae0 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -1,4 +1,4 @@
-/* $Id: s_depth.c,v 1.8 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_depth.c,v 1.9 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -538,14 +538,15 @@ GLuint
_mesa_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], GLubyte mask[] )
{
- if (ctx->Driver.ReadDepthSpan) {
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ if (swrast->Driver.ReadDepthSpan) {
/* hardware-based depth buffer */
GLdepth zbuffer[MAX_WIDTH];
GLuint passed;
- (*ctx->Driver.ReadDepthSpan)(ctx, n, x, y, zbuffer);
+ (*swrast->Driver.ReadDepthSpan)(ctx, n, x, y, zbuffer);
passed = depth_test_span32(ctx, n, x, y, zbuffer, z, mask);
- assert(ctx->Driver.WriteDepthSpan);
- (*ctx->Driver.WriteDepthSpan)(ctx, n, x, y, zbuffer, mask);
+ assert(swrast->Driver.WriteDepthSpan);
+ (*swrast->Driver.WriteDepthSpan)(ctx, n, x, y, zbuffer, mask);
return passed;
}
else {
@@ -1297,16 +1298,17 @@ _mesa_depth_test_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] )
{
- if (ctx->Driver.ReadDepthPixels) {
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ if (swrast->Driver.ReadDepthPixels) {
/* read depth values from hardware Z buffer */
GLdepth zbuffer[PB_SIZE];
- (*ctx->Driver.ReadDepthPixels)(ctx, n, x, y, zbuffer);
+ (*swrast->Driver.ReadDepthPixels)(ctx, n, x, y, zbuffer);
hardware_depth_test_pixels( ctx, n, zbuffer, z, mask );
/* update hardware Z buffer with new values */
- assert(ctx->Driver.WriteDepthPixels);
- (*ctx->Driver.WriteDepthPixels)(ctx, n, x, y, zbuffer, mask );
+ assert(swrast->Driver.WriteDepthPixels);
+ (*swrast->Driver.WriteDepthPixels)(ctx, n, x, y, zbuffer, mask );
}
else {
/* software depth testing */
@@ -1334,6 +1336,8 @@ void
_mesa_read_depth_span( GLcontext *ctx,
GLint n, GLint x, GLint y, GLdepth depth[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
if (y < 0 || y >= ctx->DrawBuffer->Height ||
x + (GLint) n <= 0 || x >= ctx->DrawBuffer->Width) {
/* span is completely outside framebuffer */
@@ -1380,9 +1384,9 @@ _mesa_read_depth_span( GLcontext *ctx,
}
}
}
- else if (ctx->Driver.ReadDepthSpan) {
+ else if (swrast->Driver.ReadDepthSpan) {
/* read from hardware depth buffer */
- (*ctx->Driver.ReadDepthSpan)( ctx, n, x, y, depth );
+ (*swrast->Driver.ReadDepthSpan)( ctx, n, x, y, depth );
}
else {
/* no depth buffer */
@@ -1405,6 +1409,7 @@ void
_mesa_read_depth_span_float( GLcontext *ctx,
GLint n, GLint x, GLint y, GLfloat depth[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLfloat scale = 1.0F / ctx->DepthMaxF;
if (y < 0 || y >= ctx->DrawBuffer->Height ||
@@ -1452,12 +1457,12 @@ _mesa_read_depth_span_float( GLcontext *ctx,
}
}
}
- else if (ctx->Driver.ReadDepthSpan) {
+ else if (swrast->Driver.ReadDepthSpan) {
/* read from hardware depth buffer */
GLdepth d[MAX_WIDTH];
GLint i;
assert(n <= MAX_WIDTH);
- (*ctx->Driver.ReadDepthSpan)( ctx, n, x, y, d );
+ (*swrast->Driver.ReadDepthSpan)( ctx, n, x, y, d );
for (i = 0; i < n; i++) {
depth[i] = d[i] * scale;
}
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 925d5dba6e..cfc1383a63 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: s_drawpix.c,v 1.14 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_drawpix.c,v 1.15 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -100,6 +100,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels)
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
const struct gl_pixelstore_attrib *unpack = &ctx->Unpack;
GLchan rgb[MAX_WIDTH][3];
GLchan rgba[MAX_WIDTH][4];
@@ -210,7 +211,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
/* no zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
- (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(CONST GLchan (*)[4]) src, NULL);
src += rowLength * 4;
destY++;
@@ -221,7 +222,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row=0; row<drawHeight; row++) {
destY--;
- (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(CONST GLchan (*)[4]) src, NULL);
src += rowLength * 4;
}
@@ -247,7 +248,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
GLint row;
for (row=0; row<drawHeight; row++) {
- (*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
(CONST GLchan (*)[3]) src, NULL);
src += rowLength * 3;
destY++;
@@ -258,7 +259,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row=0; row<drawHeight; row++) {
destY--;
- (*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
(CONST GLchan (*)[3]) src, NULL);
src += rowLength * 3;
}
@@ -292,7 +293,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
rgb[i][1] = src[i];
rgb[i][2] = src[i];
}
- (*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
(CONST GLchan (*)[3]) rgb, NULL);
src += rowLength;
destY++;
@@ -310,7 +311,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
rgb[i][2] = src[i];
}
destY--;
- (*ctx->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
(CONST GLchan (*)[3]) rgb, NULL);
src += rowLength;
}
@@ -353,7 +354,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
rgba[i][2] = *ptr++;
rgba[i][3] = *ptr++;
}
- (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(CONST GLchan (*)[4]) rgba, NULL);
src += rowLength*2;
destY++;
@@ -373,7 +374,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
rgba[i][3] = *ptr++;
}
destY--;
- (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(CONST GLchan (*)[4]) rgba, NULL);
src += rowLength*2;
}
@@ -410,7 +411,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
for (row=0; row<drawHeight; row++) {
ASSERT(drawWidth < MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
- (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(const GLchan (*)[4]) rgba,
NULL);
src += rowLength;
@@ -425,7 +426,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
ASSERT(drawWidth < MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
destY--;
- (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(CONST GLchan (*)[4]) rgba,
NULL);
src += rowLength;
@@ -452,7 +453,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
for (row=0; row<drawHeight; row++) {
- (*ctx->Driver.WriteCI8Span)(ctx, drawWidth, destX, destY,
+ (*swrast->Driver.WriteCI8Span)(ctx, drawWidth, destX, destY,
src, NULL);
src += rowLength;
destY++;
@@ -703,6 +704,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
const struct gl_pixelstore_attrib *unpack = &ctx->Unpack;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
@@ -830,7 +832,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
}
if (quickDraw) {
- (*ctx->Driver.WriteRGBASpan)( ctx, width, x, y,
+ (*swrast->Driver.WriteRGBASpan)( ctx, width, x, y,
(CONST GLchan (*)[]) rgba, NULL);
}
else if (zoom) {
@@ -862,11 +864,15 @@ _swrast_DrawPixels( GLcontext *ctx,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
(void) unpack;
- if (SWRAST_CONTEXT(ctx)->NewState)
+
+ if (swrast->NewState)
_swrast_validate_derived( ctx );
+ RENDER_START(swrast,ctx);
+
switch (format) {
case GL_STENCIL_INDEX:
draw_stencil_pixels( ctx, x, y, width, height, type, pixels );
@@ -896,4 +902,6 @@ _swrast_DrawPixels( GLcontext *ctx,
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glDrawPixels(format)" );
}
+
+ RENDER_FINISH(swrast,ctx);
}
diff --git a/src/mesa/swrast/s_logic.c b/src/mesa/swrast/s_logic.c
index 399a8e8a76..2d763c7833 100644
--- a/src/mesa/swrast/s_logic.c
+++ b/src/mesa/swrast/s_logic.c
@@ -1,4 +1,4 @@
-/* $Id: s_logic.c,v 1.5 2001/03/12 00:48:42 gareth Exp $ */
+/* $Id: s_logic.c,v 1.6 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -169,9 +169,10 @@ void
_mesa_logicop_ci_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLuint index[], const GLubyte mask[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint dest[MAX_WIDTH];
/* Read dest values from frame buffer */
- (*ctx->Driver.ReadCI32Span)( ctx, n, x, y, dest );
+ (*swrast->Driver.ReadCI32Span)( ctx, n, x, y, dest );
index_logicop( ctx, n, index, dest, mask );
}
@@ -186,9 +187,10 @@ _mesa_logicop_ci_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint index[], const GLubyte mask[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint dest[PB_SIZE];
/* Read dest values from frame buffer */
- (*ctx->Driver.ReadCI32Pixels)( ctx, n, x, y, dest, mask );
+ (*swrast->Driver.ReadCI32Pixels)( ctx, n, x, y, dest, mask );
index_logicop( ctx, n, index, dest, mask );
}
@@ -352,8 +354,9 @@ _mesa_logicop_rgba_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan dest[PB_SIZE][4];
- (*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
+ (*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
diff --git a/src/mesa/swrast/s_masking.c b/src/mesa/swrast/s_masking.c
index 7cacd1de38..b4433b2bc7 100644
--- a/src/mesa/swrast/s_masking.c
+++ b/src/mesa/swrast/s_masking.c
@@ -1,4 +1,4 @@
-/* $Id: s_masking.c,v 1.4 2001/03/12 00:48:42 gareth Exp $ */
+/* $Id: s_masking.c,v 1.5 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -91,6 +91,7 @@ _mesa_mask_rgba_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan dest[PB_SIZE][4];
GLuint i;
@@ -101,7 +102,7 @@ _mesa_mask_rgba_pixels( GLcontext *ctx,
GLuint *rgba32 = (GLuint *) rgba;
GLuint *dest32 = (GLuint *) dest;
- (*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
+ (*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
@@ -117,7 +118,7 @@ _mesa_mask_rgba_pixels( GLcontext *ctx,
const GLint bMask = ctx->Color.ColorMask[BCOMP];
const GLint aMask = ctx->Color.ColorMask[ACOMP];
- (*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
+ (*swrast->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
@@ -165,11 +166,12 @@ _mesa_mask_index_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint index[], const GLubyte mask[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint i;
GLuint fbindexes[PB_SIZE];
GLuint msrc, mdest;
- (*ctx->Driver.ReadCI32Pixels)( ctx, n, x, y, fbindexes, mask );
+ (*swrast->Driver.ReadCI32Pixels)( ctx, n, x, y, fbindexes, mask );
msrc = ctx->Color.IndexMask;
mdest = ~msrc;
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index a24c44bebe..d95bba64c8 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -1,4 +1,4 @@
-/* $Id: s_readpix.c,v 1.10 2001/03/12 00:48:42 gareth Exp $ */
+/* $Id: s_readpix.c,v 1.11 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -53,6 +53,7 @@ read_index_pixels( GLcontext *ctx,
GLenum type, GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLint i, readWidth;
/* error checking */
@@ -61,8 +62,8 @@ read_index_pixels( GLcontext *ctx,
return;
}
- ASSERT(ctx->Driver.SetReadBuffer);
- (*ctx->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer,
+ ASSERT(swrast->Driver.SetReadBuffer);
+ (*swrast->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer,
ctx->Pixel.DriverReadBuffer);
readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
@@ -72,7 +73,7 @@ read_index_pixels( GLcontext *ctx,
GLuint index[MAX_WIDTH];
GLvoid *dest;
- (*ctx->Driver.ReadCI32Span)(ctx, readWidth, x, y + i, index);
+ (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y + i, index);
dest = _mesa_image_address(packing, pixels, width, height,
GL_COLOR_INDEX, type, 0, i, 0);
@@ -81,7 +82,7 @@ read_index_pixels( GLcontext *ctx,
&ctx->Pack, ctx->_ImageTransferState);
}
- (*ctx->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer,
+ (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer,
ctx->Color.DriverDrawBuffer);
}
@@ -221,6 +222,7 @@ read_fast_rgba_pixels( GLcontext *ctx,
GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* can't do scale, bias, mapping, etc */
if (ctx->_ImageTransferState)
return GL_FALSE;
@@ -283,7 +285,7 @@ read_fast_rgba_pixels( GLcontext *ctx,
+ (skipRows * rowLength + skipPixels) * 4;
GLint row;
for (row=0; row<readHeight; row++) {
- (*ctx->Driver.ReadRGBASpan)(ctx, readWidth, srcX, srcY,
+ (*swrast->Driver.ReadRGBASpan)(ctx, readWidth, srcX, srcY,
(GLchan (*)[4]) dest);
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) {
_mesa_read_alpha_span(ctx, readWidth, srcX, srcY,
@@ -313,15 +315,16 @@ read_rgba_pixels( GLcontext *ctx,
GLenum format, GLenum type, GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLint readWidth;
- (*ctx->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer);
+ (*swrast->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer);
/* Try optimized path first */
if (read_fast_rgba_pixels( ctx, x, y, width, height,
format, type, pixels, packing )) {
- (*ctx->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
+ (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
return; /* done! */
}
@@ -387,7 +390,7 @@ read_rgba_pixels( GLcontext *ctx,
}
else {
GLuint index[MAX_WIDTH];
- (*ctx->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
+ (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset !=0 ) {
_mesa_map_ci(ctx, readWidth, index);
}
@@ -433,7 +436,7 @@ read_rgba_pixels( GLcontext *ctx,
}
else {
GLuint index[MAX_WIDTH];
- (*ctx->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
+ (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset != 0) {
_mesa_map_ci(ctx, readWidth, index);
}
@@ -465,7 +468,7 @@ read_rgba_pixels( GLcontext *ctx,
}
}
- (*ctx->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
+ (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
}
@@ -477,11 +480,14 @@ _swrast_ReadPixels( GLcontext *ctx,
const struct gl_pixelstore_attrib *pack,
GLvoid *pixels )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
(void) pack;
- if (SWRAST_CONTEXT(ctx)->NewState)
+ if (swrast->NewState)
_swrast_validate_derived( ctx );
+ RENDER_START(swrast,ctx);
+
switch (format) {
case GL_COLOR_INDEX:
read_index_pixels(ctx, x, y, width, height, type, pixels, &ctx->Pack);
@@ -509,4 +515,6 @@ _swrast_ReadPixels( GLcontext *ctx,
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glReadPixels(format)" );
}
+
+ RENDER_FINISH(swrast,ctx);
}
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index e7659d51a7..d26b042187 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1,4 +1,4 @@
-/* $Id: s_span.c,v 1.11 2001/03/12 00:48:42 gareth Exp $ */
+/* $Id: s_span.c,v 1.12 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -127,6 +127,7 @@ static void multi_write_index_span( GLcontext *ctx, GLuint n,
GLint x, GLint y, const GLuint indexes[],
const GLubyte mask[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint bufferBit;
if (ctx->Color.DrawBuffer == GL_NONE)
@@ -158,7 +159,7 @@ static void multi_write_index_span( GLcontext *ctx, GLuint n,
else if (ctx->Color.IndexMask != 0xffffffff) {
_mesa_mask_index_span( ctx, n, x, y, indexTmp );
}
- (*ctx->Driver.WriteCI32Span)( ctx, n, x, y, indexTmp, mask );
+ (*swrast->Driver.WriteCI32Span)( ctx, n, x, y, indexTmp, mask );
}
}
@@ -261,7 +262,7 @@ void _mesa_write_index_span( GLcontext *ctx,
}
/* write pixels */
- (*ctx->Driver.WriteCI32Span)( ctx, n, x, y, index, mask );
+ (*swrast->Driver.WriteCI32Span)( ctx, n, x, y, index, mask );
}
}
@@ -350,7 +351,7 @@ void _mesa_write_monoindex_span( GLcontext *ctx,
else if (ctx->Color.IndexMask != 0xffffffff) {
_mesa_mask_index_span( ctx, n, x, y, indexes );
}
- (*ctx->Driver.WriteCI32Span)( ctx, n, x, y, indexes, mask );
+ (*swrast->Driver.WriteCI32Span)( ctx, n, x, y, indexes, mask );
}
}
else {
@@ -366,7 +367,7 @@ void _mesa_write_monoindex_span( GLcontext *ctx,
}
else {
/* normal situation: draw to exactly one buffer */
- (*ctx->Driver.WriteMonoCISpan)( ctx, n, x, y, index, mask );
+ (*swrast->Driver.WriteMonoCISpan)( ctx, n, x, y, index, mask );
}
}
}
@@ -426,7 +427,7 @@ static void multi_write_rgba_span( GLcontext *ctx, GLuint n,
_mesa_mask_rgba_span( ctx, n, x, y, rgbaTmp );
}
- (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y,
+ (*swrast->Driver.WriteRGBASpan)( ctx, n, x, y,
(const GLchan (*)[4]) rgbaTmp, mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, n, x, y,
@@ -553,7 +554,7 @@ void _mesa_write_rgba_span( GLcontext *ctx,
}
/* write pixels */
- (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y,
+ (*swrast->Driver.WriteRGBASpan)( ctx, n, x, y,
(const GLchan (*)[4]) rgba,
write_all ? Null : mask );
@@ -693,7 +694,7 @@ void _mesa_write_monocolor_span( GLcontext *ctx,
}
/* write pixels */
- (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y,
+ (*swrast->Driver.WriteRGBASpan)( ctx, n, x, y,
(const GLchan (*)[4]) rgba,
write_all ? Null : mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
@@ -718,7 +719,7 @@ void _mesa_write_monocolor_span( GLcontext *ctx,
(const GLchan (*)[4]) rgba, mask );
}
else {
- (*ctx->Driver.WriteMonoRGBASpan)( ctx, n, x, y, color, mask );
+ (*swrast->Driver.WriteMonoRGBASpan)( ctx, n, x, y, color, mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_mono_alpha_span( ctx, n, x, y, (GLchan) color[ACOMP],
write_all ? Null : mask );
@@ -887,7 +888,7 @@ void _mesa_write_texture_span( GLcontext *ctx,
_mesa_mask_rgba_span( ctx, n, x, y, rgba );
}
- (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLchan (*)[4])rgba,
+ (*swrast->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLchan (*)[4])rgba,
write_all ? Null : mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, n, x, y, (const GLchan (*)[4]) rgba,
@@ -1042,7 +1043,7 @@ _mesa_write_multitexture_span( GLcontext *ctx,
_mesa_mask_rgba_span( ctx, n, x, y, rgba );
}
- (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLchan (*)[4])rgba,
+ (*swrast->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLchan (*)[4])rgba,
write_all ? Null : mask );
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, n, x, y, (const GLchan (*)[4])rgba,
@@ -1061,6 +1062,7 @@ void _mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
GLuint n, GLint x, GLint y,
GLchan rgba[][4] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (y < 0 || y >= buffer->Height
|| x + (GLint) n < 0 || x >= buffer->Width) {
/* completely above, below, or right */
@@ -1096,7 +1098,7 @@ void _mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
length = (GLint) n;
}
- (*ctx->Driver.ReadRGBASpan)( ctx, length, x + skip, y, rgba + skip );
+ (*swrast->Driver.ReadRGBASpan)( ctx, length, x + skip, y, rgba + skip );
if (buffer->UseSoftwareAlphaBuffers) {
_mesa_read_alpha_span( ctx, length, x + skip, y, rgba + skip );
}
@@ -1113,6 +1115,7 @@ void _mesa_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
void _mesa_read_index_span( GLcontext *ctx, GLframebuffer *buffer,
GLuint n, GLint x, GLint y, GLuint indx[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (y < 0 || y >= buffer->Height
|| x + (GLint) n < 0 || x >= buffer->Width) {
/* completely above, below, or right */
@@ -1147,6 +1150,6 @@ void _mesa_read_index_span( GLcontext *ctx, GLframebuffer *buffer,
length = (GLint) n;
}
- (*ctx->Driver.ReadCI32Span)( ctx, length, skip + x, y, indx + skip );
+ (*swrast->Driver.ReadCI32Span)( ctx, length, skip + x, y, indx + skip );
}
}
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index af782aa785..2b7bb91f73 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -1,4 +1,4 @@
-/* $Id: s_stencil.c,v 1.10 2001/03/12 00:48:42 gareth Exp $ */
+/* $Id: s_stencil.c,v 1.11 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -505,6 +505,7 @@ GLboolean
_mesa_stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], GLubyte mask[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLstencil stencilRow[MAX_WIDTH];
GLstencil *stencil;
GLboolean result;
@@ -513,10 +514,10 @@ _mesa_stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
ASSERT(n <= MAX_WIDTH);
/* Get initial stencil values */
- if (ctx->Driver.WriteStencilSpan) {
- ASSERT(ctx->Driver.ReadStencilSpan);
+ if (swrast->Driver.WriteStencilSpan) {
+ ASSERT(swrast->Driver.ReadStencilSpan);
/* Get stencil values from the hardware stencil buffer */
- (*ctx->Driver.ReadStencilSpan)(ctx, n, x, y, stencilRow);
+ (*swrast->Driver.ReadStencilSpan)(ctx, n, x, y, stencilRow);
stencil = stencilRow;
}
else {
@@ -527,9 +528,9 @@ _mesa_stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
/* do all the stencil/depth testing/updating */
result = stencil_and_ztest_span( ctx, n, x, y, z, stencil, mask );
- if (ctx->Driver.WriteStencilSpan) {
+ if (swrast->Driver.WriteStencilSpan) {
/* Write updated stencil values into hardware stencil buffer */
- (ctx->Driver.WriteStencilSpan)(ctx, n, x, y, stencil, mask );
+ (swrast->Driver.WriteStencilSpan)(ctx, n, x, y, stencil, mask );
}
return result;
@@ -556,7 +557,7 @@ apply_stencil_op_to_pixels( const GLcontext *ctx,
const GLstencil invmask = (GLstencil) (~ctx->Stencil.WriteMask);
GLuint i;
- ASSERT(!ctx->Driver.WriteStencilSpan); /* software stencil buffer only! */
+ ASSERT(!SWRAST_CONTEXT(ctx)->Driver.WriteStencilSpan); /* software stencil buffer only! */
switch (oper) {
case GL_KEEP:
@@ -722,7 +723,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
GLboolean allfail = GL_FALSE;
- ASSERT(!ctx->Driver.WriteStencilSpan); /* software stencil buffer only! */
+ ASSERT(!SWRAST_CONTEXT(ctx)->Driver.WriteStencilSpan); /* software stencil buffer only! */
/*
* Perform stencil test. The results of this operation are stored
@@ -910,16 +911,17 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth z[], GLubyte mask[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
ASSERT(ctx->Stencil.Enabled);
ASSERT(n <= PB_SIZE);
- if (ctx->Driver.WriteStencilPixels) {
+ if (swrast->Driver.WriteStencilPixels) {
/*** Hardware stencil buffer ***/
GLstencil stencil[PB_SIZE];
GLubyte origMask[PB_SIZE];
- ASSERT(ctx->Driver.ReadStencilPixels);
- (*ctx->Driver.ReadStencilPixels)(ctx, n, x, y, stencil);
+ ASSERT(swrast->Driver.ReadStencilPixels);
+ (*swrast->Driver.ReadStencilPixels)(ctx, n, x, y, stencil);
MEMCPY(origMask, mask, n * sizeof(GLubyte));
@@ -954,7 +956,7 @@ _mesa_stencil_and_ztest_pixels( GLcontext *ctx,
}
/* Write updated stencil values into hardware stencil buffer */
- (ctx->Driver.WriteStencilPixels)(ctx, n, x, y, stencil, origMask);
+ (swrast->Driver.WriteStencilPixels)(ctx, n, x, y, stencil, origMask);
return GL_TRUE;
}
@@ -1011,6 +1013,7 @@ void
_mesa_read_stencil_span( GLcontext *ctx,
GLint n, GLint x, GLint y, GLstencil stencil[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (y < 0 || y >= ctx->DrawBuffer->Height ||
x + n <= 0 || x >= ctx->DrawBuffer->Width) {
/* span is completely outside framebuffer */
@@ -1033,8 +1036,8 @@ _mesa_read_stencil_span( GLcontext *ctx,
ASSERT(n >= 0);
- if (ctx->Driver.ReadStencilSpan) {
- (*ctx->Driver.ReadStencilSpan)( ctx, (GLuint) n, x, y, stencil );
+ if (swrast->Driver.ReadStencilSpan) {
+ (*swrast->Driver.ReadStencilSpan)( ctx, (GLuint) n, x, y, stencil );
}
else if (ctx->DrawBuffer->Stencil) {
const GLstencil *s = STENCIL_ADDRESS( x, y );
@@ -1061,6 +1064,7 @@ void
_mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
const GLstencil stencil[] )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (y < 0 || y >= ctx->DrawBuffer->Height ||
x + n <= 0 || x >= ctx->DrawBuffer->Width) {
/* span is completely outside framebuffer */
@@ -1081,8 +1085,8 @@ _mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
return;
}
- if (ctx->Driver.WriteStencilSpan) {
- (*ctx->Driver.WriteStencilSpan)( ctx, n, x, y, stencil, NULL );
+ if (swrast->Driver.WriteStencilSpan) {
+ (*swrast->Driver.WriteStencilSpan)( ctx, n, x, y, stencil, NULL );
}
else if (ctx->DrawBuffer->Stencil) {
GLstencil *s = STENCIL_ADDRESS( x, y );
@@ -1212,8 +1216,9 @@ clear_software_stencil_buffer( GLcontext *ctx )
static void
clear_hardware_stencil_buffer( GLcontext *ctx )
{
- ASSERT(ctx->Driver.WriteStencilSpan);
- ASSERT(ctx->Driver.ReadStencilSpan);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ ASSERT(swrast->Driver.WriteStencilSpan);
+ ASSERT(swrast->Driver.ReadStencilSpan);
if (ctx->Scissor.Enabled) {
/* clear scissor region only */
@@ -1228,11 +1233,11 @@ clear_hardware_stencil_buffer( GLcontext *ctx )
const GLstencil clearVal = (ctx->Stencil.Clear & mask);
GLstencil stencil[MAX_WIDTH];
GLint i;
- (*ctx->Driver.ReadStencilSpan)(ctx, width, x, y, stencil);
+ (*swrast->Driver.ReadStencilSpan)(ctx, width, x, y, stencil);
for (i = 0; i < width; i++) {
stencil[i] = (stencil[i] & invMask) | clearVal;
}
- (*ctx->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
+ (*swrast->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
}
}
else {
@@ -1243,7 +1248,7 @@ clear_hardware_stencil_buffer( GLcontext *ctx )
stencil[i] = ctx->Stencil.Clear;
}
for (y = ctx->DrawBuffer->_Ymin; y < ctx->DrawBuffer->_Ymax; y++) {
- (*ctx->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
+ (*swrast->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
}
}
}
@@ -1261,11 +1266,11 @@ clear_hardware_stencil_buffer( GLcontext *ctx )
for (y = 0; y < height; y++) {
GLstencil stencil[MAX_WIDTH];
GLint i;
- (*ctx->Driver.ReadStencilSpan)(ctx, width, x, y, stencil);
+ (*swrast->Driver.ReadStencilSpan)(ctx, width, x, y, stencil);
for (i = 0; i < width; i++) {
stencil[i] = (stencil[i] & invMask) | clearVal;
}
- (*ctx->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
+ (*swrast->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
}
}
else {
@@ -1279,7 +1284,7 @@ clear_hardware_stencil_buffer( GLcontext *ctx )
stencil[i] = ctx->Stencil.Clear;
}
for (y = 0; y < height; y++) {
- (*ctx->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
+ (*swrast->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
}
}
}
@@ -1293,8 +1298,9 @@ clear_hardware_stencil_buffer( GLcontext *ctx )
void
_mesa_clear_stencil_buffer( GLcontext *ctx )
{
- if (ctx->Driver.WriteStencilSpan) {
- ASSERT(ctx->Driver.ReadStencilSpan);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ if (swrast->Driver.WriteStencilSpan) {
+ ASSERT(swrast->Driver.ReadStencilSpan);
clear_hardware_stencil_buffer(ctx);
}
else {
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 4bf83d6bf2..066cab2f16 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.19 2001/03/17 17:43:05 keithw Exp $ */
+/* $Id: s_triangle.c,v 1.20 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -26,12 +26,11 @@
/*
- * Triangle rasterizers
- * When the device driver doesn't implement triangle rasterization Mesa
- * will use these functions to draw triangles.
+ * When the device driver doesn't implement triangle rasterization it
+ * can hook in _swrast_Triangle, which eventually calls one of these
+ * functions to draw triangles.
*/
-
#include "glheader.h"
#include "context.h"
#include "colormac.h"
@@ -244,6 +243,7 @@ static void simple_textured_triangle( GLcontext *ctx,
#define S_SCALE twidth
#define T_SCALE theight
#define SETUP_CODE \
+ SWcontext *swrast = SWRAST_CONTEXT(ctx); \
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
GLint b = obj->BaseLevel; \
GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
@@ -276,7 +276,7 @@ static void simple_textured_triangle( GLcontext *ctx,
ffs += fdsdx; \
fft += fdtdx; \
} \
- (*ctx->Driver.WriteRGBSpan)( ctx, n, LEFT, Y, \
+ (*swrast->Driver.WriteRGBSpan)( ctx, n, LEFT, Y, \
(CONST GLchan (*)[3]) rgb, NULL ); \
} \
}
@@ -304,6 +304,7 @@ static void simple_z_textured_triangle( GLcontext *ctx,
#define S_SCALE twidth
#define T_SCALE theight
#define SETUP_CODE \
+ SWcontext *swrast = SWRAST_CONTEXT(ctx); \
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
GLint b = obj->BaseLevel; \
GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
@@ -347,7 +348,7 @@ static void simple_z_textured_triangle( GLcontext *ctx,
ffs += fdsdx; \
fft += fdtdx; \
} \
- (*ctx->Driver.WriteRGBSpan)( ctx, n, LEFT, Y, \
+ (*swrast->Driver.WriteRGBSpan)( ctx, n, LEFT, Y, \
(CONST GLchan (*)[3]) rgb, mask ); \
} \
}
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index eaea8cd7e8..76453cdaef 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -1,4 +1,4 @@
-/* $Id: swrast.h,v 1.11 2001/03/12 00:48:42 gareth Exp $ */
+/* $Id: swrast.h,v 1.12 2001/03/19 02:25:36 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -67,6 +67,7 @@ typedef struct {
} SWvertex;
+struct swrast_device_driver;
/* These are the public-access functions exported from swrast.
@@ -80,7 +81,10 @@ _swrast_CreateContext( GLcontext *ctx );
extern void
_swrast_DestroyContext( GLcontext *ctx );
-
+/* Get a (non-const) reference to the device driver struct for swrast.
+ */
+extern struct swrast_device_driver *
+_swrast_GetDeviceDriverReference( GLcontext *ctx );
extern void
_swrast_Bitmap( GLcontext *ctx,
@@ -168,4 +172,254 @@ _swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value );
extern void
_swrast_print_vertex( GLcontext *ctx, const SWvertex *v );
+
+/*
+ * Imaging fallbacks (a better solution should be found, perhaps
+ * moving all the imaging fallback code to a new module)
+ */
+void
+_swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width,
+ GLsizei height);
+void
+_swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width);
+void
+_swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width);
+void
+_swrast_CopyColorTable( GLcontext *ctx,
+ GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width);
+
+
+/*
+ * Texture fallbacks, Brian Paul. Could also live in a new module
+ * with the rest of the texture store fallbacks?
+ */
+extern void
+_swrast_copy_teximage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLint border);
+
+extern void
+_swrast_copy_teximage2d(GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLint border);
+
+
+extern void
+_swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint x, GLint y, GLsizei width);
+
+extern void
+_swrast_copy_texsubimage2d(GLcontext *ctx,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height);
+
+extern void
+_swrast_copy_texsubimage3d(GLcontext *ctx,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height);
+
+
+
+/* The driver interface for the software rasterizer. Unless otherwise
+ * noted, all functions are mandatory.
+ */
+struct swrast_device_driver {
+
+ void (*SetReadBuffer)( GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLenum buffer );
+ /*
+ * Specifies the current buffer for span/pixel reading.
+ * colorBuffer will be one of:
+ * GL_FRONT_LEFT - this buffer always exists
+ * GL_BACK_LEFT - when double buffering
+ * GL_FRONT_RIGHT - when using stereo
+ * GL_BACK_RIGHT - when using stereo and double buffering
+ */
+
+
+ /***
+ *** Functions for synchronizing access to the framebuffer:
+ ***/
+
+ void (*SpanRenderStart)(GLcontext *ctx);
+ void (*SpanRenderFinish)(GLcontext *ctx);
+ /* OPTIONAL.
+ *
+ * Called before and after all rendering operations, including DrawPixels,
+ * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
+ * These are a suitable place for grabbing/releasing hardware locks.
+ *
+ * NOTE: The swrast triangle/line/point routines *DO NOT* call
+ * these functions. Locking in that case must be organized by the
+ * driver by other mechanisms.
+ */
+
+ /***
+ *** Functions for writing pixels to the frame buffer:
+ ***/
+
+ void (*WriteRGBASpan)( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ CONST GLchan rgba[][4], const GLubyte mask[] );
+ void (*WriteRGBSpan)( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ CONST GLchan rgb[][3], const GLubyte mask[] );
+ /* Write a horizontal run of RGBA or RGB pixels.
+ * If mask is NULL, draw all pixels.
+ * If mask is not null, only draw pixel [i] when mask [i] is true.
+ */
+
+ void (*WriteMonoRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLchan color[4], const GLubyte mask[] );
+ /* Write a horizontal run of RGBA pixels all with the same color.
+ */
+
+ void (*WriteRGBAPixels)( const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ CONST GLchan rgba[][4], const GLubyte mask[] );
+ /* Write array of RGBA pixels at random locations.
+ */
+
+ void (*WriteMonoRGBAPixels)( const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLchan color[4], const GLubyte mask[] );
+ /* Write an array of mono-RGBA pixels at random locations.
+ */
+
+ void (*WriteCI32Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLuint index[], const GLubyte mask[] );
+ void (*WriteCI8Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLubyte index[], const GLubyte mask[] );
+ /* Write a horizontal run of CI pixels. One function is for 32bpp
+ * indexes and the other for 8bpp pixels (the common case). You mus
+ * implement both for color index mode.
+ */
+
+ void (*WriteMonoCISpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLuint colorIndex, const GLubyte mask[] );
+ /* Write a horizontal run of color index pixels using the color index
+ * last specified by the Index() function.
+ */
+
+ void (*WriteCI32Pixels)( const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLuint index[], const GLubyte mask[] );
+ /*
+ * Write a random array of CI pixels.
+ */
+
+ void (*WriteMonoCIPixels)( const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint colorIndex, const GLubyte mask[] );
+ /* Write a random array of color index pixels using the color index
+ * last specified by the Index() function.
+ */
+
+
+ /***
+ *** Functions to read pixels from frame buffer:
+ ***/
+
+ void (*ReadCI32Span)( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y, GLuint index[] );
+ /* Read a horizontal run of color index pixels.
+ */
+
+ void (*ReadRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLchan rgba[][4] );
+ /* Read a horizontal run of RGBA pixels.
+ */
+
+ void (*ReadCI32Pixels)( const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint indx[], const GLubyte mask[] );
+ /* Read a random array of CI pixels.
+ */
+
+ void (*ReadRGBAPixels)( const GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLchan rgba[][4], const GLubyte mask[] );
+ /* Read a random array of RGBA pixels.
+ */
+
+
+
+ /***
+ *** For supporting hardware Z buffers:
+ *** Either ALL or NONE of these functions must be implemented!
+ *** NOTE that Each depth value is a 32-bit GLuint. If the depth
+ *** buffer is less than 32 bits deep then the extra upperbits are zero.
+ ***/
+
+ void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLdepth depth[], const GLubyte mask[] );
+ /* Write a horizontal span of values into the depth buffer. Only write
+ * depth[i] value if mask[i] is nonzero.
+ */
+
+ void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLdepth depth[] );
+ /* Read a horizontal span of values from the depth buffer.
+ */
+
+
+ void (*WriteDepthPixels)( GLcontext *ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth depth[], const GLubyte mask[] );
+ /* Write an array of randomly positioned depth values into the
+ * depth buffer. Only write depth[i] value if mask[i] is nonzero.
+ */
+
+ void (*ReadDepthPixels)( GLcontext *ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ GLdepth depth[] );
+ /* Read an array of randomly positioned depth values from the depth buffer.
+ */
+
+
+
+ /***
+ *** For supporting hardware stencil buffers:
+ *** Either ALL or NONE of these functions must be implemented!
+ ***/
+
+ void (*WriteStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLstencil stencil[], const GLubyte mask[] );
+ /* Write a horizontal span of stencil values into the stencil buffer.
+ * If mask is NULL, write all stencil values.
+ * Else, only write stencil[i] if mask[i] is non-zero.
+ */
+
+ void (*ReadStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLstencil stencil[] );
+ /* Read a horizontal span of stencil values from the stencil buffer.
+ */
+
+ void (*WriteStencilPixels)( GLcontext *ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLstencil stencil[],
+ const GLubyte mask[] );
+ /* Write an array of stencil values into the stencil buffer.
+ * If mask is NULL, write all stencil values.
+ * Else, only write stencil[i] if mask[i] is non-zero.
+ */
+
+ void (*ReadStencilPixels)( GLcontext *ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ GLstencil stencil[] );
+ /* Read an array of stencil values from the stencil buffer.
+ */
+};
+
+
+
#endif