summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/common/driverfuncs.c11
-rw-r--r--src/mesa/drivers/dos/dmesa.c20
-rw-r--r--src/mesa/drivers/dri/common/depthtmp.h55
-rw-r--r--src/mesa/drivers/dri/common/drirenderbuffer.c96
-rw-r--r--src/mesa/drivers/dri/common/drirenderbuffer.h39
-rw-r--r--src/mesa/drivers/dri/common/spantmp.h54
-rw-r--r--src/mesa/drivers/dri/common/spantmp2.h105
-rw-r--r--src/mesa/drivers/dri/common/stenciltmp.h69
-rw-r--r--src/mesa/drivers/dri/fb/fb_dri.c172
-rw-r--r--src/mesa/drivers/dri/ffb/ffb_clear.c20
-rw-r--r--src/mesa/drivers/dri/ffb/ffb_state.c4
-rw-r--r--src/mesa/drivers/dri/ffb/ffb_xmesa.c4
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_span.c4
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_state.c8
-rw-r--r--src/mesa/drivers/dri/i810/i810context.c25
-rw-r--r--src/mesa/drivers/dri/i810/i810ioctl.c12
-rw-r--r--src/mesa/drivers/dri/i810/i810screen.c45
-rw-r--r--src/mesa/drivers/dri/i810/i810span.c53
-rw-r--r--src/mesa/drivers/dri/i810/i810span.h5
-rw-r--r--src/mesa/drivers/dri/i810/i810state.c6
-rw-r--r--src/mesa/drivers/dri/i830/i830_context.c17
-rw-r--r--src/mesa/drivers/dri/i830/i830_ioctl.c28
-rw-r--r--src/mesa/drivers/dri/i830/i830_screen.c74
-rw-r--r--src/mesa/drivers/dri/i830/i830_span.c91
-rw-r--r--src/mesa/drivers/dri/i830/i830_span.h5
-rw-r--r--src/mesa/drivers/dri/i830/i830_state.c8
-rw-r--r--src/mesa/drivers/dri/i915/i830_metaops.c6
-rw-r--r--src/mesa/drivers/dri/i915/i915_metaops.c6
-rw-r--r--src/mesa/drivers/dri/i915/intel_batchbuffer.c20
-rw-r--r--src/mesa/drivers/dri/i915/intel_context.c17
-rw-r--r--src/mesa/drivers/dri/i915/intel_ioctl.c26
-rw-r--r--src/mesa/drivers/dri/i915/intel_screen.c58
-rw-r--r--src/mesa/drivers/dri/i915/intel_span.c78
-rw-r--r--src/mesa/drivers/dri/i915/intel_span.h5
-rw-r--r--src/mesa/drivers/dri/i915/intel_state.c6
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_context.c8
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_dd.c3
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_ioctl.c12
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_lock.c2
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_screen.c50
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_span.c71
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_span.h5
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_state.c10
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.c82
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.h11
-rw-r--r--src/mesa/drivers/dri/mga/mgadd.c3
-rw-r--r--src/mesa/drivers/dri/mga/mgaioctl.c16
-rw-r--r--src/mesa/drivers/dri/mga/mgaspan.c59
-rw-r--r--src/mesa/drivers/dri/mga/mgaspan.h6
-rw-r--r--src/mesa/drivers/dri/mga/mgastate.c6
-rw-r--r--src/mesa/drivers/dri/r128/r128_context.c8
-rw-r--r--src/mesa/drivers/dri/r128/r128_dd.c3
-rw-r--r--src/mesa/drivers/dri/r128/r128_ioctl.c16
-rw-r--r--src/mesa/drivers/dri/r128/r128_lock.c2
-rw-r--r--src/mesa/drivers/dri/r128/r128_screen.c49
-rw-r--r--src/mesa/drivers/dri/r128/r128_span.c53
-rw-r--r--src/mesa/drivers/dri/r128/r128_span.h5
-rw-r--r--src/mesa/drivers/dri/r128/r128_state.c8
-rw-r--r--src/mesa/drivers/dri/r200/r200_context.c15
-rw-r--r--src/mesa/drivers/dri/r200/r200_ioctl.c16
-rw-r--r--src/mesa/drivers/dri/r200/r200_lock.c4
-rw-r--r--src/mesa/drivers/dri/r200/r200_screen.c61
-rw-r--r--src/mesa/drivers/dri/r200/r200_span.c66
-rw-r--r--src/mesa/drivers/dri/r200/r200_span.h5
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.c6
-rw-r--r--src/mesa/drivers/dri/radeon/Makefile1
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.c13
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_ioctl.c16
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_lock.c4
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_screen.c63
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_screen.h3
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_span.c65
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_span.h4
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_state.c6
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_context.h2
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_dd.c3
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_screen.h3
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_span.c61
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_state.c6
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_xmesa.c99
-rw-r--r--src/mesa/drivers/dri/savage/savage_init.h10
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c81
-rw-r--r--src/mesa/drivers/dri/savage/savagedd.c3
-rw-r--r--src/mesa/drivers/dri/savage/savageioctl.c16
-rw-r--r--src/mesa/drivers/dri/savage/savagespan.c74
-rw-r--r--src/mesa/drivers/dri/savage/savagespan.h9
-rw-r--r--src/mesa/drivers/dri/savage/savagestate.c6
-rw-r--r--src/mesa/drivers/dri/sis/sis_clear.c38
-rw-r--r--src/mesa/drivers/dri/sis/sis_context.c8
-rw-r--r--src/mesa/drivers/dri/sis/sis_dd.c11
-rw-r--r--src/mesa/drivers/dri/sis/sis_screen.c68
-rw-r--r--src/mesa/drivers/dri/sis/sis_span.c74
-rw-r--r--src/mesa/drivers/dri/sis/sis_span.h6
-rw-r--r--src/mesa/drivers/dri/sis/sis_state.c6
-rw-r--r--src/mesa/drivers/dri/sis/sis_tris.c2
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_context.c14
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_dd.c3
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_pixels.c4
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_render.c40
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_screen.c58
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_span.c146
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_span.h4
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_state.c10
-rw-r--r--src/mesa/drivers/dri/trident/trident_context.c74
-rw-r--r--src/mesa/drivers/dri/trident/trident_context.h10
-rw-r--r--src/mesa/drivers/dri/trident/trident_dd.c3
-rw-r--r--src/mesa/drivers/dri/trident/trident_state.c15
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.c26
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.h2
-rw-r--r--src/mesa/drivers/dri/unichrome/via_ioctl.c20
-rw-r--r--src/mesa/drivers/dri/unichrome/via_screen.c68
-rw-r--r--src/mesa/drivers/dri/unichrome/via_screen.h1
-rw-r--r--src/mesa/drivers/dri/unichrome/via_span.c64
-rw-r--r--src/mesa/drivers/dri/unichrome/via_span.h5
-rw-r--r--src/mesa/drivers/fbdev/glfbdev.c413
-rw-r--r--src/mesa/drivers/glide/fxdd.c6
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c472
-rw-r--r--src/mesa/drivers/svga/svgamesa8.c22
-rw-r--r--src/mesa/drivers/x11/fakeglx.c32
-rw-r--r--src/mesa/drivers/x11/glxheader.h1
-rw-r--r--src/mesa/drivers/x11/xm_api.c378
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c111
-rw-r--r--src/mesa/drivers/x11/xm_dd.c745
-rw-r--r--src/mesa/drivers/x11/xm_line.c129
-rw-r--r--src/mesa/drivers/x11/xm_span.c966
-rw-r--r--src/mesa/drivers/x11/xm_tri.c337
-rw-r--r--src/mesa/drivers/x11/xmesaP.h117
127 files changed, 4884 insertions, 2086 deletions
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 69cc919568..dcaaa9199f 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -27,7 +27,9 @@
#include "imports.h"
#include "buffers.h"
#include "context.h"
+#include "framebuffer.h"
#include "program.h"
+#include "renderbuffer.h"
#include "texcompress.h"
#include "texformat.h"
#include "teximage.h"
@@ -38,6 +40,7 @@
#endif
#if FEATURE_EXT_framebuffer_object
#include "fbobject.h"
+#include "texrender.h"
#endif
#include "driverfuncs.h"
@@ -62,7 +65,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->GetString = NULL; /* REQUIRED! */
driver->UpdateState = NULL; /* REQUIRED! */
driver->GetBufferSize = NULL; /* REQUIRED! */
- driver->ResizeBuffers = _swrast_alloc_buffers;
+ driver->ResizeBuffers = _mesa_resize_framebuffer;
driver->Error = NULL;
driver->Finish = NULL;
@@ -134,7 +137,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->ColorMaterial = NULL;
driver->CullFace = NULL;
driver->DrawBuffer = _swrast_DrawBuffer;
- driver->DrawBuffers = _swrast_DrawBuffers;
+ driver->DrawBuffers = NULL; /***_swrast_DrawBuffers;***/
driver->FrontFace = NULL;
driver->DepthFunc = NULL;
driver->DepthMask = NULL;
@@ -200,7 +203,9 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
#if FEATURE_EXT_framebuffer_object
driver->NewFramebuffer = _mesa_new_framebuffer;
- driver->NewRenderbuffer = _mesa_new_renderbuffer;
+ driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
+ driver->RenderbufferTexture = _mesa_renderbuffer_texture;
+ driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
#endif
/* T&L stuff */
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 9688dd95b2..d7c8477091 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -278,7 +278,8 @@ read_rgba_pixels (const GLcontext *ctx,
* Index
***************************************************************************/
static void
-write_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
+write_index_span (const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLuint index[], const GLubyte mask[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
@@ -302,7 +303,8 @@ write_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
static void
-write_index8_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
+write_index8_span (const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLubyte index[], const GLubyte mask[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
@@ -326,7 +328,7 @@ write_index8_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
static void
-write_mono_index_span (const GLcontext *ctx,
+write_mono_index_span (const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
GLuint colorIndex, const GLubyte mask[])
{
@@ -351,8 +353,8 @@ write_mono_index_span (const GLcontext *ctx,
static void
-read_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLuint index[])
+read_index_span (const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint index[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
GLuint i, offset;
@@ -366,7 +368,7 @@ read_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
static void
-write_index_pixels (const GLcontext *ctx,
+write_index_pixels (const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
const GLuint index[], const GLubyte mask[])
{
@@ -390,7 +392,7 @@ write_index_pixels (const GLcontext *ctx,
static void
-write_mono_index_pixels (const GLcontext *ctx,
+write_mono_index_pixels (const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
GLuint colorIndex, const GLubyte mask[])
{
@@ -414,9 +416,9 @@ write_mono_index_pixels (const GLcontext *ctx,
static void
-read_index_pixels (const GLcontext *ctx,
+read_index_pixels (const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
- GLuint index[], const GLubyte mask[])
+ GLuint index[], const GLubyte mask[])
{
const DMesaContext dmesa = (DMesaContext)ctx;
GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1;
diff --git a/src/mesa/drivers/dri/common/depthtmp.h b/src/mesa/drivers/dri/common/depthtmp.h
index ad26e6b891..74273165e4 100644
--- a/src/mesa/drivers/dri/common/depthtmp.h
+++ b/src/mesa/drivers/dri/common/depthtmp.h
@@ -1,5 +1,13 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/common/depthtmp.h,v 1.5 2001/03/21 16:14:20 dawes Exp $ */
+/*
+ * Notes:
+ * 1. These functions plug into the gl_renderbuffer structure.
+ * 2. The 'values' parameter always points to GLuint values, regardless of
+ * the actual Z buffer depth.
+ */
+
+
#ifndef DBG
#define DBG 0
#endif
@@ -20,12 +28,14 @@
#endif
static void TAG(WriteDepthSpan)( GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLdepth *depth,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values,
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLuint *depth = (const GLuint *) values;
GLint x1;
GLint n1;
LOCAL_DEPTH_VARS;
@@ -64,14 +74,31 @@ static void TAG(WriteDepthSpan)( GLcontext *ctx,
HW_WRITE_UNLOCK();
}
-#if !HAVE_HW_DEPTH_SPANS
+
+#if HAVE_HW_DEPTH_SPANS
+/* implement MonoWriteDepthSpan() in terms of WriteDepthSpan() */
+static void
+TAG(WriteMonoDepthSpan)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value, const GLubyte mask[] )
+{
+ const GLuint depthVal = *((GLuint *) value);
+ GLuint depths[MAX_WIDTH];
+ GLuint i;
+ for (i = 0; i < n; i++)
+ depths[i] = depthVal;
+ TAG(WriteDepthSpan)(ctx, rb, n, x, y, depths, mask);
+}
+#else
static void TAG(WriteMonoDepthSpan)( GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- const GLdepth depth,
- const GLubyte mask[] )
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value,
+ const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLuint depth = *((GLuint *) value);
GLint x1;
GLint n1;
LOCAL_DEPTH_VARS;
@@ -102,15 +129,18 @@ static void TAG(WriteMonoDepthSpan)( GLcontext *ctx,
}
#endif
+
static void TAG(WriteDepthPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n,
const GLint x[],
const GLint y[],
- const GLdepth depth[],
+ const void *values,
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLuint *depth = (const GLuint *) values;
GLuint i;
LOCAL_DEPTH_VARS;
@@ -141,11 +171,13 @@ static void TAG(WriteDepthPixels)( GLcontext *ctx,
/* Read depth spans and pixels
*/
static void TAG(ReadDepthSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- GLdepth depth[] )
+ void *values )
{
HW_READ_LOCK()
{
+ GLuint *depth = (GLuint *) values;
GLint x1, n1;
LOCAL_DEPTH_VARS;
@@ -172,12 +204,15 @@ static void TAG(ReadDepthSpan)( GLcontext *ctx,
HW_READ_UNLOCK();
}
-static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
+static void TAG(ReadDepthPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
const GLint x[], const GLint y[],
- GLdepth depth[] )
+ void *values )
{
HW_READ_LOCK()
{
+ GLuint *depth = (GLuint *) values;
GLuint i;
LOCAL_DEPTH_VARS;
diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.c b/src/mesa/drivers/dri/common/drirenderbuffer.c
new file mode 100644
index 0000000000..3d9574f0cf
--- /dev/null
+++ b/src/mesa/drivers/dri/common/drirenderbuffer.c
@@ -0,0 +1,96 @@
+
+#include "mtypes.h"
+#include "drirenderbuffer.h"
+#include "renderbuffer.h"
+#include "imports.h"
+
+
+/**
+ * This will get called when a window is resized.
+ * Just update width, height and internal format fields for now.
+ */
+static GLboolean
+driRenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+ return GL_TRUE;
+}
+
+
+/**
+ * Allocate a new driRenderbuffer object.
+ * Individual drivers are free to implement different versions of
+ * this function.
+ * \param format Either GL_RGBA, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24,
+ * GL_DEPTH_COMPONENT32, or GL_STENCIL_INDEX8_EXT (for now).
+ * \param cpp chars or bytes per pixel
+ * \param offset start of buffer with respect to framebuffer address
+ * \param pitch pixels per row
+ */
+driRenderbuffer *
+driNewRenderbuffer(GLenum format, GLint cpp, GLint offset, GLint pitch)
+{
+ driRenderbuffer *drb;
+
+ assert(format == GL_RGBA ||
+ format == GL_DEPTH_COMPONENT16 ||
+ format == GL_DEPTH_COMPONENT24 ||
+ format == GL_DEPTH_COMPONENT32 ||
+ format == GL_STENCIL_INDEX8_EXT);
+
+ assert(cpp > 0);
+ assert(pitch > 0);
+
+ drb = _mesa_calloc(sizeof(driRenderbuffer));
+ if (drb) {
+ const GLuint name = 0;
+
+ _mesa_init_renderbuffer(&drb->Base, name);
+
+ /* Make sure we're using a null-valued GetPointer routine */
+ assert(drb->Base.GetPointer(NULL, &drb->Base, 0, 0) == NULL);
+
+ drb->Base.InternalFormat = format;
+
+ if (format == GL_RGBA) {
+ /* Color */
+ drb->Base._BaseFormat = GL_RGBA;
+ drb->Base.DataType = GL_UNSIGNED_BYTE;
+ }
+ else if (format == GL_DEPTH_COMPONENT16) {
+ /* Depth */
+ drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+ /* we always Get/Put 32-bit Z values */
+ drb->Base.DataType = GL_UNSIGNED_INT;
+ }
+ else if (format == GL_DEPTH_COMPONENT24) {
+ /* Depth */
+ drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+ /* we always Get/Put 32-bit Z values */
+ drb->Base.DataType = GL_UNSIGNED_INT;
+ }
+ else {
+ /* Stencil */
+ ASSERT(format == GL_STENCIL_INDEX8);
+ drb->Base._BaseFormat = GL_STENCIL_INDEX;
+ drb->Base.DataType = GL_UNSIGNED_BYTE;
+ }
+
+ /* XXX if we were allocating a user-created renderbuffer, we'd have
+ * to fill in the ComponentSizes[] array too.
+ */
+
+ drb->Base.AllocStorage = driRenderbufferStorage;
+ /* using default Delete function */
+
+
+ /* DRI renderbuffer-specific fields: */
+ drb->offset = offset;
+ drb->pitch = pitch;
+ drb->cpp = cpp;
+ }
+ return drb;
+}
diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.h b/src/mesa/drivers/dri/common/drirenderbuffer.h
new file mode 100644
index 0000000000..627f1d41d9
--- /dev/null
+++ b/src/mesa/drivers/dri/common/drirenderbuffer.h
@@ -0,0 +1,39 @@
+
+/**
+ * A driRenderbuffer is dervied from gl_renderbuffer.
+ * It describes a color buffer (front or back), a depth buffer, or stencil
+ * buffer etc.
+ * Specific to DRI drivers are the offset and pitch fields.
+ */
+
+
+#ifndef DRIRENDERBUFFER_H
+#define DRIRENDERBUFFER_H
+
+#include "mtypes.h"
+
+typedef struct {
+ struct gl_renderbuffer Base;
+
+ /* Chars or bytes per pixel. If Z and Stencil are stored together this
+ * will typically be 32 whether this a depth or stencil renderbuffer.
+ */
+ GLint cpp;
+
+ /* Buffer position and pitch (row stride). Recall that for today's DRI
+ * drivers, we have statically allocated color/depth/stencil buffers.
+ * So this information describes the whole screen, not just a window.
+ * To address pixels in a window, we need to know the window's position
+ * and size with respect to the screen.
+ */
+ GLint offset; /* in bytes */
+ GLint pitch; /* in pixels */
+
+} driRenderbuffer;
+
+
+driRenderbuffer *
+driNewRenderbuffer(GLenum format, GLint cpp, GLint offset, GLint pitch);
+
+
+#endif /* DRIRENDERBUFFER_H */
diff --git a/src/mesa/drivers/dri/common/spantmp.h b/src/mesa/drivers/dri/common/spantmp.h
index 96f26333fc..b15bbb2577 100644
--- a/src/mesa/drivers/dri/common/spantmp.h
+++ b/src/mesa/drivers/dri/common/spantmp.h
@@ -56,13 +56,14 @@
#endif
-static void TAG(WriteRGBASpan)( const GLcontext *ctx,
+static void TAG(WriteRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- const GLubyte rgba[][4],
- const GLubyte mask[] )
+ const void *values, const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
GLint x1;
GLint n1;
LOCAL_VARS;
@@ -98,13 +99,14 @@ static void TAG(WriteRGBASpan)( const GLcontext *ctx,
HW_WRITE_UNLOCK();
}
-static void TAG(WriteRGBSpan)( const GLcontext *ctx,
+static void TAG(WriteRGBSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3],
- const GLubyte mask[] )
+ const void *values, const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
GLint x1;
GLint n1;
LOCAL_VARS;
@@ -136,15 +138,14 @@ static void TAG(WriteRGBSpan)( const GLcontext *ctx,
HW_WRITE_UNLOCK();
}
-static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
- GLuint n,
- const GLint x[],
- const GLint y[],
- const GLubyte rgba[][4],
- const GLubyte mask[] )
+static void TAG(WriteRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
GLuint i;
LOCAL_VARS;
@@ -183,13 +184,15 @@ static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
}
-static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
+static void TAG(WriteMonoRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- const GLchan color[4],
+ const void *value,
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte *color = (const GLubyte *) value;
GLint x1;
GLint n1;
LOCAL_VARS;
@@ -221,14 +224,16 @@ static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
}
-static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
+static void TAG(WriteMonoRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n,
- const GLint x[], const GLint y[],
- const GLchan color[],
- const GLubyte mask[] )
+ const GLint x[], const GLint y[],
+ const void *value,
+ const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte *color = (const GLubyte *) value;
GLuint i;
LOCAL_VARS;
INIT_MONO_PIXEL(p, color);
@@ -261,12 +266,14 @@ static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
}
-static void TAG(ReadRGBASpan)( const GLcontext *ctx,
+static void TAG(ReadRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- GLubyte rgba[][4])
+ void *values)
{
HW_READ_LOCK()
{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
GLint x1,n1;
LOCAL_VARS;
@@ -287,12 +294,15 @@ static void TAG(ReadRGBASpan)( const GLcontext *ctx,
}
-static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
+static void TAG(ReadRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[] )
+ void *values )
{
HW_READ_LOCK()
{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ const GLubyte *mask = NULL; /* remove someday */
GLuint i;
LOCAL_VARS;
diff --git a/src/mesa/drivers/dri/common/spantmp2.h b/src/mesa/drivers/dri/common/spantmp2.h
index fa737a9623..e15491d1ad 100644
--- a/src/mesa/drivers/dri/common/spantmp2.h
+++ b/src/mesa/drivers/dri/common/spantmp2.h
@@ -145,13 +145,14 @@
#include "x86/common_x86_asm.h"
#endif
-static void TAG(WriteRGBASpan)( const GLcontext *ctx,
+static void TAG(WriteRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- const GLubyte rgba[][4],
- const GLubyte mask[] )
+ const void *values, const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
GLint x1;
GLint n1;
LOCAL_VARS;
@@ -187,13 +188,14 @@ static void TAG(WriteRGBASpan)( const GLcontext *ctx,
HW_WRITE_UNLOCK();
}
-static void TAG(WriteRGBSpan)( const GLcontext *ctx,
+static void TAG(WriteRGBSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- const GLubyte rgb[][3],
- const GLubyte mask[] )
+ const void *values, const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
GLint x1;
GLint n1;
LOCAL_VARS;
@@ -225,15 +227,14 @@ static void TAG(WriteRGBSpan)( const GLcontext *ctx,
HW_WRITE_UNLOCK();
}
-static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
- GLuint n,
- const GLint x[],
- const GLint y[],
- const GLubyte rgba[][4],
- const GLubyte mask[] )
+static void TAG(WriteRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
GLint i;
LOCAL_VARS;
@@ -272,13 +273,14 @@ static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
}
-static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
+static void TAG(WriteMonoRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- const GLchan color[4],
- const GLubyte mask[] )
+ const void *value, const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte *color = (const GLubyte *) value;
GLint x1;
GLint n1;
LOCAL_VARS;
@@ -310,14 +312,16 @@ static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
}
-static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
+static void TAG(WriteMonoRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n,
const GLint x[], const GLint y[],
- const GLchan color[],
+ const void *value,
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte *color = (const GLubyte *) value;
GLint i;
LOCAL_VARS;
INIT_MONO_PIXEL(p, color);
@@ -350,12 +354,13 @@ static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
}
-static void TAG(ReadRGBASpan)( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- GLubyte rgba[][4])
+static void TAG(ReadRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, void *values)
{
HW_READ_LOCK()
{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
GLint x1,n1;
LOCAL_VARS;
@@ -381,9 +386,9 @@ static void TAG(ReadRGBASpan)( const GLcontext *ctx,
(SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)) || \
((SPANTMP_PIXEL_FMT == GL_RGB) && \
(SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)))
-static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- GLubyte rgba[][4])
+static void TAG2(ReadRGBASpan,_MMX)( GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4])
{
#ifndef USE_INNER_EMMS
/* The EMMS instruction is directly in-lined here because using GCC's
@@ -394,6 +399,7 @@ static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
HW_READ_LOCK()
{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
GLint x1,n1;
LOCAL_VARS;
@@ -429,12 +435,14 @@ static void TAG2(ReadRGBASpan,_MMX)( const GLcontext *ctx,
#if defined(USE_SSE_ASM) && \
(SPANTMP_PIXEL_FMT == GL_BGRA) && \
(SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
-static void TAG2(ReadRGBASpan,_SSE2)( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- GLubyte rgba[][4])
+static void TAG2(ReadRGBASpan,_SSE2)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values)
{
HW_READ_LOCK()
{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
GLint x1,n1;
LOCAL_VARS;
@@ -461,9 +469,10 @@ static void TAG2(ReadRGBASpan,_SSE2)( const GLcontext *ctx,
#if defined(USE_SSE_ASM) && \
(SPANTMP_PIXEL_FMT == GL_BGRA) && \
(SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
-static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- GLubyte rgba[][4])
+static void TAG2(ReadRGBASpan,_SSE)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values)
{
#ifndef USE_INNER_EMMS
/* The EMMS instruction is directly in-lined here because using GCC's
@@ -474,6 +483,7 @@ static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
HW_READ_LOCK()
{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
GLint x1,n1;
LOCAL_VARS;
@@ -501,12 +511,15 @@ static void TAG2(ReadRGBASpan,_SSE)( const GLcontext *ctx,
#endif
-static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
+static void TAG(ReadRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[] )
+ void *values )
{
HW_READ_LOCK()
{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ GLubyte *mask = NULL; /* remove someday */
GLint i;
LOCAL_VARS;
@@ -537,21 +550,21 @@ static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
HW_READ_UNLOCK();
}
-static void TAG(InitPointers)(struct swrast_device_driver *swdd)
+static void TAG(InitPointers)(struct gl_renderbuffer *rb)
{
- swdd->WriteRGBASpan = TAG(WriteRGBASpan);
- swdd->WriteRGBSpan = TAG(WriteRGBSpan);
- swdd->WriteMonoRGBASpan = TAG(WriteMonoRGBASpan);
- swdd->WriteRGBAPixels = TAG(WriteRGBAPixels);
- swdd->WriteMonoRGBAPixels = TAG(WriteMonoRGBAPixels);
- swdd->ReadRGBAPixels = TAG(ReadRGBAPixels);
+ rb->PutRow = TAG(WriteRGBASpan);
+ rb->PutRowRGB = TAG(WriteRGBSpan);
+ rb->PutMonoRow = TAG(WriteMonoRGBASpan);
+ rb->PutValues = TAG(WriteRGBAPixels);
+ rb->PutMonoValues = TAG(WriteMonoRGBAPixels);
+ rb->GetValues = TAG(ReadRGBAPixels);
#if defined(USE_SSE_ASM) && \
(SPANTMP_PIXEL_FMT == GL_BGRA) && \
(SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
if ( cpu_has_xmm2 ) {
- if (DBG) fprintf( stderr, "Using %s version of ReadRGBASpan\n", "SSE2" );
- swdd->ReadRGBASpan = TAG2(ReadRGBASpan, _SSE2);
+ if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "SSE2" );
+ rb->GetRow = TAG2(ReadRGBASpan, _SSE2);
}
else
#endif
@@ -559,8 +572,8 @@ static void TAG(InitPointers)(struct swrast_device_driver *swdd)
(SPANTMP_PIXEL_FMT == GL_BGRA) && \
(SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
if ( cpu_has_xmm ) {
- if (DBG) fprintf( stderr, "Using %s version of ReadRGBASpan\n", "SSE" );
- swdd->ReadRGBASpan = TAG2(ReadRGBASpan, _SSE);
+ if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "SSE" );
+ rb->GetRow = TAG2(ReadRGBASpan, _SSE);
}
else
#endif
@@ -570,14 +583,14 @@ static void TAG(InitPointers)(struct swrast_device_driver *swdd)
((SPANTMP_PIXEL_FMT == GL_RGB) && \
(SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)))
if ( cpu_has_mmx ) {
- if (DBG) fprintf( stderr, "Using %s version of ReadRGBASpan\n", "MMX" );
- swdd->ReadRGBASpan = TAG2(ReadRGBASpan, _MMX);
+ if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "MMX" );
+ rb->GetRow = TAG2(ReadRGBASpan, _MMX);
}
else
#endif
{
- if (DBG) fprintf( stderr, "Using %s version of ReadRGBASpan\n", "C" );
- swdd->ReadRGBASpan = TAG(ReadRGBASpan);
+ if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "C" );
+ rb->GetRow = TAG(ReadRGBASpan);
}
}
diff --git a/src/mesa/drivers/dri/common/stenciltmp.h b/src/mesa/drivers/dri/common/stenciltmp.h
index dfbe665407..ffcb1a4c1e 100644
--- a/src/mesa/drivers/dri/common/stenciltmp.h
+++ b/src/mesa/drivers/dri/common/stenciltmp.h
@@ -19,12 +19,13 @@
#endif
static void TAG(WriteStencilSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- const GLstencil *stencil,
- const GLubyte mask[] )
+ const void *values, const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte *stencil = (const GLubyte *) values;
GLint x1;
GLint n1;
LOCAL_STENCIL_VARS;
@@ -57,15 +58,57 @@ static void TAG(WriteStencilSpan)( GLcontext *ctx,
}
+static void TAG(WriteMonoStencilSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value,
+ const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte stencil = *((const GLubyte *) value);
+ GLint x1;
+ GLint n1;
+ LOCAL_STENCIL_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;n1>0;i++,x1++,n1--)
+ if (mask[i])
+ WRITE_STENCIL( x1, y, stencil );
+ }
+ else
+ {
+ for (;n1>0;i++,x1++,n1--)
+ WRITE_STENCIL( x1, y, stencil );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+
static void TAG(WriteStencilPixels)( GLcontext *ctx,
- GLuint n,
- const GLint x[],
- const GLint y[],
- const GLstencil stencil[],
- const GLubyte mask[] )
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
+ const GLubyte *stencil = (const GLubyte *) values;
GLuint i;
LOCAL_STENCIL_VARS;
@@ -91,11 +134,13 @@ static void TAG(WriteStencilPixels)( GLcontext *ctx,
/* Read stencil spans and pixels
*/
static void TAG(ReadStencilSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
- GLstencil stencil[])
+ void *values)
{
HW_READ_LOCK()
{
+ GLubyte *stencil = (GLubyte *) values;
GLint x1,n1;
LOCAL_STENCIL_VARS;
@@ -115,12 +160,14 @@ static void TAG(ReadStencilSpan)( GLcontext *ctx,
HW_READ_UNLOCK();
}
-static void TAG(ReadStencilPixels)( GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- GLstencil stencil[] )
+static void TAG(ReadStencilPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ void *values )
{
HW_READ_LOCK()
{
+ GLubyte *stencil = (GLubyte *) values;
GLuint i;
LOCAL_STENCIL_VARS;
diff --git a/src/mesa/drivers/dri/fb/fb_dri.c b/src/mesa/drivers/dri/fb/fb_dri.c
index 696bf9e2e1..dc049fddb5 100644
--- a/src/mesa/drivers/dri/fb/fb_dri.c
+++ b/src/mesa/drivers/dri/fb/fb_dri.c
@@ -44,9 +44,12 @@
#include "driver.h"
#include "drm.h"
#include "utils.h"
+#include "drirenderbuffer.h"
#include "buffers.h"
#include "extensions.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "array_cache/acache.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
@@ -153,10 +156,10 @@ set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
switch (bufferBit) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
fbdrawable->currentBuffer = fbdrawable->frontBuffer;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
fbdrawable->currentBuffer = fbdrawable->backBuffer;
break;
default:
@@ -171,7 +174,7 @@ init_core_functions( struct dd_function_table *functions )
{
functions->GetString = get_string;
functions->UpdateState = update_state;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetBufferSize = get_buffer_size;
functions->Viewport = viewport;
@@ -279,7 +282,67 @@ init_core_functions( struct dd_function_table *functions )
#define FETCH_CI_PIXEL(CI, P) \
CI = P[0]
- #include "swrast/s_spantemp.h"
+#include "swrast/s_spantemp.h"
+
+
+
+void
+fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ ASSERT(drb->Base.InternalFormat == GL_RGBA);
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = read_rgba_span_B5G6R5;
+ drb->Base.GetValues = read_rgba_pixels_B5G6R5;
+ drb->Base.PutRow = write_rgba_span_B5G6R5;
+ drb->Base.PutMonoRow = write_monorgba_span_B5G6R5;
+ drb->Base.PutRowRGB = write_rgb_span_B5G6R5;
+ drb->Base.PutValues = write_rgba_pixels_B5G6R5;
+ drb->Base.PutMonoValues = write_monorgba_pixels_B5G6R5;
+ }
+ else if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) {
+ drb->Base.GetRow = read_rgba_span_B5G5R5;
+ drb->Base.GetValues = read_rgba_pixels_B5G5R5;
+ drb->Base.PutRow = write_rgba_span_B5G5R5;
+ drb->Base.PutMonoRow = write_monorgba_span_B5G5R5;
+ drb->Base.PutRowRGB = write_rgb_span_B5G5R5;
+ drb->Base.PutValues = write_rgba_pixels_B5G5R5;
+ drb->Base.PutMonoValues = write_monorgba_pixels_B5G5R5;
+ }
+ else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8
+ && vis->alphaBits == 8) {
+ drb->Base.GetRow = read_rgba_span_B8G8R8A8;
+ drb->Base.GetValues = read_rgba_pixels_B8G8R8A8;
+ drb->Base.PutRow = write_rgba_span_B8G8R8A8;
+ drb->Base.PutMonoRow = write_monorgba_span_B8G8R8A8;
+ drb->Base.PutRowRGB = write_rgb_span_B8G8R8A8;
+ drb->Base.PutValues = write_rgba_pixels_B8G8R8A8;
+ drb->Base.PutMonoValues = write_monorgba_pixels_B8G8R8A8;
+ }
+ else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8
+ && vis->alphaBits == 0) {
+ drb->Base.GetRow = read_rgba_span_B8G8R8;
+ drb->Base.GetValues = read_rgba_pixels_B8G8R8;
+ drb->Base.PutRow = write_rgba_span_B8G8R8;
+ drb->Base.PutMonoRow = write_monorgba_span_B8G8R8;
+ drb->Base.PutRowRGB = write_rgb_span_B8G8R8;
+ drb->Base.PutValues = write_rgba_pixels_B8G8R8;
+ drb->Base.PutMonoValues = write_monorgba_pixels_B8G8R8;
+ }
+ else if (vis->indexBits == 8) {
+ drb->Base.GetRow = read_index_span_CI8;
+ drb->Base.GetValues = read_index_pixels_CI8;
+ drb->Base.PutRow = write_index_span_CI8;
+ drb->Base.PutMonoRow = write_monoindex_span_CI8;
+ drb->Base.PutValues = write_index_pixels_CI8;
+ drb->Base.PutMonoValues = write_monoindex_pixels_CI8;
+ }
+ }
+ else {
+ /* hardware z/stencil/etc someday */
+ }
+}
+
/* Initialize the driver specific screen private data.
@@ -377,60 +440,6 @@ fbCreateContext( const __GLcontextModes *glVisual,
struct swrast_device_driver *swdd;
swdd = _swrast_GetDeviceDriverReference( ctx );
swdd->SetBuffer = set_buffer;
- if (!glVisual->rgbMode) {
- swdd->WriteCI32Span = write_index32_span_CI8;
- swdd->WriteCI8Span = write_index8_span_CI8;
- swdd->WriteMonoCISpan = write_monoindex_span_CI8;
- swdd->WriteCI32Pixels = write_index_pixels_CI8;
- swdd->WriteMonoCIPixels = write_monoindex_pixels_CI8;
- swdd->ReadCI32Span = read_index_span_CI8;
- swdd->ReadCI32Pixels = read_index_pixels_CI8;
- }
- else if (glVisual->rgbBits == 24 &&
- glVisual->alphaBits == 0) {
- swdd->WriteRGBASpan = write_rgba_span_B8G8R8;
- swdd->WriteRGBSpan = write_rgb_span_B8G8R8;
- swdd->WriteMonoRGBASpan = write_monorgba_span_B8G8R8;
- swdd->WriteRGBAPixels = write_rgba_pixels_B8G8R8;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_B8G8R8;
- swdd->ReadRGBASpan = read_rgba_span_B8G8R8;
- swdd->ReadRGBAPixels = read_rgba_pixels_B8G8R8;
- }
- else if (glVisual->rgbBits == 32 &&
- glVisual->alphaBits == 8) {
- swdd->WriteRGBASpan = write_rgba_span_B8G8R8A8;
- swdd->WriteRGBSpan = write_rgb_span_B8G8R8A8;
- swdd->WriteMonoRGBASpan = write_monorgba_span_B8G8R8A8;
- swdd->WriteRGBAPixels = write_rgba_pixels_B8G8R8A8;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_B8G8R8A8;
- swdd->ReadRGBASpan = read_rgba_span_B8G8R8A8;
- swdd->ReadRGBAPixels = read_rgba_pixels_B8G8R8A8;
- }
- else if (glVisual->rgbBits == 16 &&
- glVisual->alphaBits == 0) {
- swdd->WriteRGBASpan = write_rgba_span_B5G6R5;
- swdd->WriteRGBSpan = write_rgb_span_B5G6R5;
- swdd->WriteMonoRGBASpan = write_monorgba_span_B5G6R5;
- swdd->WriteRGBAPixels = write_rgba_pixels_B5G6R5;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_B5G6R5;
- swdd->ReadRGBASpan = read_rgba_span_B5G6R5;
- swdd->ReadRGBAPixels = read_rgba_pixels_B5G6R5;
- }
- else if (glVisual->rgbBits == 15 &&
- glVisual->alphaBits == 0) {
- swdd->WriteRGBASpan = write_rgba_span_B5G5R5;
- swdd->WriteRGBSpan = write_rgb_span_B5G5R5;
- swdd->WriteMonoRGBASpan = write_monorgba_span_B5G5R5;
- swdd->WriteRGBAPixels = write_rgba_pixels_B5G5R5;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_B5G5R5;
- swdd->ReadRGBASpan = read_rgba_span_B5G5R5;
- swdd->ReadRGBAPixels = read_rgba_pixels_B5G5R5;
- }
- else {
- _mesa_printf("bad pixelformat rgb %d alpha %d\n",
- glVisual->rgbBits,
- glVisual->alphaBits );
- }
}
/* use default TCL pipeline */
@@ -454,7 +463,7 @@ fbDestroyContext( __DRIcontextPrivate *driContextPriv )
/* check if we're deleting the currently bound context */
if (fbmesa == current) {
- _mesa_make_current2(NULL, NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
/* Free fb context resources */
@@ -498,6 +507,7 @@ fbCreateBuffer( __DRIscreenPrivate *driScrnPriv,
if (!fbdrawable)
return 0;
+#if 0
fbdrawable->mesa_framebuffer = (void *)
_mesa_create_framebuffer( mesaVis,
swDepth,
@@ -509,6 +519,42 @@ fbCreateBuffer( __DRIscreenPrivate *driScrnPriv,
_mesa_free(fbdrawable);
return 0;
}
+#else
+ fbdrawable->mesa_framebuffer = _mesa_create_framebuffer(mesaVis);
+ if (!fbdrawable->mesa_framebuffer) {
+ _mesa_free(fbdrawable);
+ return 0;
+ }
+
+ /* XXX double-check these parameters (bpp vs cpp, etc) */
+ {
+ driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, spriv->bpp,
+ spriv->fbOrigin,
+ spriv->fbStride);
+ fbSetSpanFunctions(drb, mesaVis);
+ _mesa_add_renderbuffer(fbdrawable->mesa_framebuffer,
+ BUFFER_FRONT_LEFT, &drb->Base);
+ }
+ if (mesaVis->doubleBufferMode) {
+ /* XXX what are the correct origin/stride values? */
+ driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, spriv->bpp,
+ spriv->fbOrigin,
+ spriv->fbStride);
+ fbSetSpanFunctions(drb, mesaVis);
+ _mesa_add_renderbuffer(fbdrawable->mesa_framebuffer,
+ BUFFER_BACK_LEFT, &drb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fbdrawable->mesa_framebuffer,
+ GL_FALSE, /* color */
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha,
+ GL_FALSE /* aux */);
+
+#endif
+
driDrawPriv->driverPrivate = fbdrawable;
fbdrawable->frontBuffer = fbdrawable->currentBuffer = spriv->fbMap;
@@ -591,11 +637,11 @@ fbMakeCurrent( __DRIcontextPrivate *driContextPriv,
newFbCtx->dri.drawable = driDrawPriv;
- _mesa_make_current2( newFbCtx->glCtx,
- ((fbDrawablePtr)driDrawPriv->driverPrivate)->mesa_framebuffer,
- ((fbDrawablePtr)driReadPriv->driverPrivate)->mesa_framebuffer);
+ _mesa_make_current( newFbCtx->glCtx,
+ ((fbDrawablePtr)driDrawPriv->driverPrivate)->mesa_framebuffer,
+ ((fbDrawablePtr)driReadPriv->driverPrivate)->mesa_framebuffer);
} else {
- _mesa_make_current( 0, 0 );
+ _mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/ffb/ffb_clear.c b/src/mesa/drivers/dri/ffb/ffb_clear.c
index 2bb0eb047b..c63179149a 100644
--- a/src/mesa/drivers/dri/ffb/ffb_clear.c
+++ b/src/mesa/drivers/dri/ffb/ffb_clear.c
@@ -267,7 +267,7 @@ void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = fmesa->driDrawable;
- unsigned int stcmask = DD_STENCIL_BIT;
+ unsigned int stcmask = BUFFER_BIT_STENCIL;
#ifdef CLEAR_TRACE
fprintf(stderr, "ffbDDClear: mask(%08x) all(%d) "
@@ -277,7 +277,7 @@ void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS))
stcmask = 0;
- if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT | stcmask)) {
+ if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH | stcmask)) {
ffb_fbcPtr ffb = fmesa->regs;
unsigned int fbc, ppc;
@@ -288,20 +288,20 @@ void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
/* Y/X enables must be both on or both off. */
- if (mask & (DD_DEPTH_BIT | stcmask)) {
+ if (mask & (BUFFER_BIT_DEPTH | stcmask)) {
fbc |= (FFB_FBC_ZE_ON | FFB_FBC_YE_ON | FFB_FBC_WB_C);
} else
fbc |= FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF;
/* All RGB enables must be both on or both off. */
- if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
- if (mask & DD_FRONT_LEFT_BIT) {
+ if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
if (fmesa->back_buffer == 0)
fbc |= FFB_FBC_WB_B;
else
fbc |= FFB_FBC_WB_A;
}
- if (mask & DD_BACK_LEFT_BIT) {
+ if (mask & BUFFER_BIT_BACK_LEFT) {
if (fmesa->back_buffer == 0)
fbc |= FFB_FBC_WB_A;
else
@@ -321,9 +321,9 @@ void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
ffb->cmp = 0x80808080;
ffb->rop = FFB_ROP_NEW;
- if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT))
+ if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT))
ffb->fg = fmesa->clear_pixel;
- if (mask & DD_DEPTH_BIT)
+ if (mask & BUFFER_BIT_DEPTH)
ffb->constz = fmesa->clear_depth;
if (mask & stcmask)
ffb->consty = fmesa->clear_stencil;
@@ -344,8 +344,8 @@ void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
UNLOCK_HARDWARE(fmesa);
- mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT |
- DD_DEPTH_BIT | stcmask);
+ mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT |
+ BUFFER_BIT_DEPTH | stcmask);
}
if (mask)
diff --git a/src/mesa/drivers/dri/ffb/ffb_state.c b/src/mesa/drivers/dri/ffb/ffb_state.c
index 53d56d2043..48b58e0993 100644
--- a/src/mesa/drivers/dri/ffb/ffb_state.c
+++ b/src/mesa/drivers/dri/ffb/ffb_state.c
@@ -522,14 +522,14 @@ static void ffbDDSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
#endif
fbc &= ~(FFB_FBC_RB_MASK);
switch (bufferBit) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
if (fmesa->back_buffer == 0)
fbc |= FFB_FBC_RB_B;
else
fbc |= FFB_FBC_RB_A;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
if (fmesa->back_buffer == 0)
fbc |= FFB_FBC_RB_A;
else
diff --git a/src/mesa/drivers/dri/ffb/ffb_xmesa.c b/src/mesa/drivers/dri/ffb/ffb_xmesa.c
index 722b870f5e..cdaafac15f 100644
--- a/src/mesa/drivers/dri/ffb/ffb_xmesa.c
+++ b/src/mesa/drivers/dri/ffb/ffb_xmesa.c
@@ -515,8 +515,8 @@ ffbMakeCurrent(__DRIcontextPrivate *driContextPriv,
* we need to clear all the hw buffers.
*/
ffbDDClear(fmesa->glCtx,
- (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT |
- DD_DEPTH_BIT | DD_STENCIL_BIT),
+ (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT |
+ BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL),
1, 0, 0, 0, 0);
}
} else {
diff --git a/src/mesa/drivers/dri/gamma/gamma_span.c b/src/mesa/drivers/dri/gamma/gamma_span.c
index c953dfd08f..db61f1c777 100644
--- a/src/mesa/drivers/dri/gamma/gamma_span.c
+++ b/src/mesa/drivers/dri/gamma/gamma_span.c
@@ -268,10 +268,10 @@ static void gammaSetBuffer( GLcontext *ctx,
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
switch ( bufferBit ) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
gmesa->readOffset = 0;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
gmesa->readOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
break;
default:
diff --git a/src/mesa/drivers/dri/gamma/gamma_state.c b/src/mesa/drivers/dri/gamma/gamma_state.c
index 4d9d92fdb6..24a6b3672c 100644
--- a/src/mesa/drivers/dri/gamma/gamma_state.c
+++ b/src/mesa/drivers/dri/gamma/gamma_state.c
@@ -230,12 +230,12 @@ static void gammaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
#endif
- if (mask & DD_DEPTH_BIT) {
+ if (mask & BUFFER_BIT_DEPTH) {
/* Turn off writes the FB */
CHECK_DMA_BUFFER(gmesa, 1);
WRITE(gmesa->buf, FBWriteMode, FBWriteModeDisable);
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
/*
* Turn Rectangle2DControl off when the window is not clipped
@@ -349,13 +349,13 @@ static void gammaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
}
}
- if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
+ if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) {
int y = gmesa->driScreen->fbHeight - gmesa->driDrawable->y - gmesa->driDrawable->h;
int x = gmesa->driDrawable->x;
int w = gmesa->driDrawable->w;
int h = gmesa->driDrawable->h;
- mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
+ mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
if (x < 0) { w -= -x; x = 0; }
diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c
index bf1b2fc93c..aa4eb4be6e 100644
--- a/src/mesa/drivers/dri/i810/i810context.c
+++ b/src/mesa/drivers/dri/i810/i810context.c
@@ -38,6 +38,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "matrix.h"
#include "simple_list.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "imports.h"
#include "swrast/swrast.h"
@@ -245,7 +246,7 @@ i810CreateContext( const __GLcontextModes *mesaVis,
ctx->Const.PointSizeGranularity = 1.0;
ctx->Driver.GetBufferSize = i810BufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
ctx->Driver.GetString = i810GetString;
/* Who owns who?
@@ -384,11 +385,12 @@ void i810XMesaSetBackClipRects( i810ContextPtr imesa )
static void i810XMesaWindowMoved( i810ContextPtr imesa )
{
- switch (imesa->glCtx->Color._DrawDestMask[0]) {
- case DD_FRONT_LEFT_BIT:
+ /* Determine current color drawing buffer */
+ switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
i810XMesaSetFrontClipRects( imesa );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
i810XMesaSetBackClipRects( imesa );
break;
default:
@@ -424,16 +426,16 @@ i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
*/
imesa->driDrawable = driDrawPriv;
- _mesa_make_current2(imesa->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate);
+ _mesa_make_current(imesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
/* Are these necessary?
*/
i810XMesaWindowMoved( imesa );
}
else {
- _mesa_make_current(0,0);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
@@ -445,11 +447,12 @@ i810UpdatePageFlipping( i810ContextPtr imesa )
GLcontext *ctx = imesa->glCtx;
int front = 0;
- switch (ctx->Color._DrawDestMask[0]) {
- case DD_FRONT_LEFT_BIT:
+ /* Determine current color drawing buffer */
+ switch (ctx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
front = 1;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
front = 0;
break;
default:
diff --git a/src/mesa/drivers/dri/i810/i810ioctl.c b/src/mesa/drivers/dri/i810/i810ioctl.c
index 50ddd0976f..ba651555a6 100644
--- a/src/mesa/drivers/dri/i810/i810ioctl.c
+++ b/src/mesa/drivers/dri/i810/i810ioctl.c
@@ -63,20 +63,20 @@ static void i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
I810_FIREVERTICES( imesa );
- if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0U) {
+ if ((mask & BUFFER_BIT_FRONT_LEFT) && colorMask == ~0U) {
clear.flags |= I810_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0U) {
+ if ((mask & BUFFER_BIT_BACK_LEFT) && colorMask == ~0U) {
clear.flags |= I810_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if (mask & DD_DEPTH_BIT) {
+ if (mask & BUFFER_BIT_DEPTH) {
if (ctx->Depth.Mask)
clear.flags |= I810_DEPTH;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
if (clear.flags) {
diff --git a/src/mesa/drivers/dri/i810/i810screen.c b/src/mesa/drivers/dri/i810/i810screen.c
index 072bcd0318..f270df66b6 100644
--- a/src/mesa/drivers/dri/i810/i810screen.c
+++ b/src/mesa/drivers/dri/i810/i810screen.c
@@ -36,7 +36,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "glheader.h"
#include "imports.h"
#include "context.h"
+#include "framebuffer.h"
+#include "fbobject.h"
#include "matrix.h"
+#include "renderbuffer.h"
#include "simple_list.h"
#include "utils.h"
@@ -330,22 +333,64 @@ i810DestroyScreen(__DRIscreenPrivate *sPriv)
}
+/**
+ * Create a buffer which corresponds to the window.
+ */
static GLboolean
i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ i810ScreenPrivate *screen = (i810ScreenPrivate *) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer(mesaVis,
GL_FALSE, /* software depth buffer? */
mesaVis->stencilBits > 0,
mesaVis->accumRedBits > 0,
GL_FALSE /* s/w alpha planes */);
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ /*screen->frontOffset*/0, screen->backPitch);
+ i810SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ i810SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i810SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
diff --git a/src/mesa/drivers/dri/i810/i810span.c b/src/mesa/drivers/dri/i810/i810span.c
index eb32cb7c70..78b8265b70 100644
--- a/src/mesa/drivers/dri/i810/i810span.c
+++ b/src/mesa/drivers/dri/i810/i810span.c
@@ -123,13 +123,13 @@ static void i810SetBuffer(GLcontext *ctx, GLframebuffer *buffer,
(void) buffer;
switch(bufferBit) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
if ( imesa->sarea->pf_current_page == 1)
imesa->readMap = imesa->i810Screen->back.map;
else
imesa->readMap = (char*)imesa->driScreen->pFB;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
if ( imesa->sarea->pf_current_page == 1)
imesa->readMap = (char*)imesa->driScreen->pFB;
else
@@ -165,6 +165,7 @@ void i810InitSpanFuncs( GLcontext *ctx )
swdd->SetBuffer = i810SetBuffer;
+#if 0
swdd->WriteRGBASpan = i810WriteRGBASpan_565;
swdd->WriteRGBSpan = i810WriteRGBSpan_565;
swdd->WriteMonoRGBASpan = i810WriteMonoRGBASpan_565;
@@ -172,12 +173,60 @@ void i810InitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoRGBAPixels = i810WriteMonoRGBAPixels_565;
swdd->ReadRGBASpan = i810ReadRGBASpan_565;
swdd->ReadRGBAPixels = i810ReadRGBAPixels_565;
+#endif
+#if 0
swdd->ReadDepthSpan = i810ReadDepthSpan_16;
swdd->WriteDepthSpan = i810WriteDepthSpan_16;
swdd->ReadDepthPixels = i810ReadDepthPixels_16;
swdd->WriteDepthPixels = i810WriteDepthPixels_16;
+#endif
swdd->SpanRenderStart = i810SpanRenderStart;
swdd->SpanRenderFinish = i810SpanRenderFinish;
}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+i810SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ /* always 565 RGB */
+ drb->Base.GetRow = i810ReadRGBASpan_565;
+ drb->Base.GetValues = i810ReadRGBAPixels_565;
+ drb->Base.PutRow = i810WriteRGBASpan_565;
+ drb->Base.PutRowRGB = i810WriteRGBSpan_565;
+ drb->Base.PutMonoRow = i810WriteMonoRGBASpan_565;
+ drb->Base.PutValues = i810WriteRGBAPixels_565;
+ drb->Base.PutMonoValues = i810WriteMonoRGBAPixels_565;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = i810ReadDepthSpan_16;
+ drb->Base.GetValues = i810ReadDepthPixels_16;
+ drb->Base.PutRow = i810WriteDepthSpan_16;
+ drb->Base.PutMonoRow = i810WriteMonoDepthSpan_16;
+ drb->Base.PutValues = i810WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ /* should never get here */
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/i810/i810span.h b/src/mesa/drivers/dri/i810/i810span.h
index 545bce46a6..9aed253bd5 100644
--- a/src/mesa/drivers/dri/i810/i810span.h
+++ b/src/mesa/drivers/dri/i810/i810span.h
@@ -1,9 +1,14 @@
#ifndef _I810_SPAN_H
#define _I810_SPAN_H
+#include "drirenderbuffer.h"
+
extern void i810InitSpanFuncs( GLcontext *ctx );
extern void i810SpanRenderFinish( GLcontext *ctx );
extern void i810SpanRenderStart( GLcontext *ctx );
+extern void
+i810SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/dri/i810/i810state.c b/src/mesa/drivers/dri/i810/i810state.c
index 42df2e8b9e..ec9f07ada3 100644
--- a/src/mesa/drivers/dri/i810/i810state.c
+++ b/src/mesa/drivers/dri/i810/i810state.c
@@ -285,11 +285,11 @@ void i810DrawBuffer(GLcontext *ctx, GLenum mode )
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
front = 1;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
front = 0;
break;
default:
diff --git a/src/mesa/drivers/dri/i830/i830_context.c b/src/mesa/drivers/dri/i830/i830_context.c
index 082476f211..66c25ac0e6 100644
--- a/src/mesa/drivers/dri/i830/i830_context.c
+++ b/src/mesa/drivers/dri/i830/i830_context.c
@@ -42,6 +42,7 @@
#include "matrix.h"
#include "simple_list.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "imports.h"
#include "swrast/swrast.h"
@@ -305,7 +306,7 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
ctx->Const.PointSizeGranularity = 1.0;
ctx->Driver.GetBufferSize = i830BufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
ctx->Driver.GetString = i830DDGetString;
/* Who owns who? */
@@ -476,11 +477,11 @@ void i830XMesaSetBackClipRects( i830ContextPtr imesa )
static void i830XMesaWindowMoved( i830ContextPtr imesa )
{
- switch (imesa->glCtx->Color._DrawDestMask[0]) {
- case DD_FRONT_LEFT_BIT:
+ switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
i830XMesaSetFrontClipRects( imesa );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
i830XMesaSetBackClipRects( imesa );
break;
default:
@@ -527,11 +528,11 @@ GLboolean i830MakeCurrent(__DRIcontextPrivate *driContextPriv,
imesa->driReadable = driReadPriv;
- _mesa_make_current2(imesa->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate);
+ _mesa_make_current(imesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
} else {
- _mesa_make_current(0,0);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/i830/i830_ioctl.c b/src/mesa/drivers/dri/i830/i830_ioctl.c
index cad48db9df..cd0c143dfc 100644
--- a/src/mesa/drivers/dri/i830/i830_ioctl.c
+++ b/src/mesa/drivers/dri/i830/i830_ioctl.c
@@ -186,7 +186,7 @@ static void i830ClearWithTris(GLcontext *ctx, GLbitfield mask,
old_vertex_prim = imesa->hw_primitive;
imesa->hw_primitive = PRIM3D_TRIFAN;
- if(mask & DD_FRONT_LEFT_BIT) {
+ if(mask & BUFFER_BIT_FRONT_LEFT) {
GLuint tmp = sarea->ContextState[I830_CTXREG_ENABLES_2];
sarea->dirty |= (I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS |
@@ -248,7 +248,7 @@ static void i830ClearWithTris(GLcontext *ctx, GLbitfield mask,
i830FlushPrimsLocked( imesa );
}
- if(mask & DD_BACK_LEFT_BIT) {
+ if(mask & BUFFER_BIT_BACK_LEFT) {
GLuint tmp = sarea->ContextState[I830_CTXREG_ENABLES_2];
sarea->dirty |= (I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS |
@@ -311,7 +311,7 @@ static void i830ClearWithTris(GLcontext *ctx, GLbitfield mask,
i830FlushPrimsLocked( imesa );
}
- if(mask & DD_STENCIL_BIT) {
+ if(mask & BUFFER_BIT_STENCIL) {
GLuint s_mask = ctx->Stencil.WriteMask[0];
sarea->dirty |= (I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS |
@@ -433,40 +433,40 @@ static void i830Clear(GLcontext *ctx, GLbitfield mask, GLboolean all,
I830_FIREVERTICES( imesa );
- if (mask & DD_FRONT_LEFT_BIT) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
if(colorMask == ~0) {
clear.flags |= I830_FRONT;
} else {
- tri_mask |= DD_FRONT_LEFT_BIT;
+ tri_mask |= BUFFER_BIT_FRONT_LEFT;
}
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if (mask & DD_BACK_LEFT_BIT) {
+ if (mask & BUFFER_BIT_BACK_LEFT) {
if(colorMask == ~0) {
clear.flags |= I830_BACK;
} else {
- tri_mask |= DD_BACK_LEFT_BIT;
+ tri_mask |= BUFFER_BIT_BACK_LEFT;
}
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if (mask & DD_DEPTH_BIT) {
+ if (mask & BUFFER_BIT_DEPTH) {
clear.flags |= I830_DEPTH;
clear.clear_depthmask = imesa->depth_clear_mask;
clear.clear_depth = (GLuint)(ctx->Depth.Clear * imesa->ClearDepth);
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
- if((mask & DD_STENCIL_BIT) && imesa->hw_stencil) {
+ if((mask & BUFFER_BIT_STENCIL) && imesa->hw_stencil) {
if (ctx->Stencil.WriteMask[0] != 0xff) {
- tri_mask |= DD_STENCIL_BIT;
+ tri_mask |= BUFFER_BIT_STENCIL;
} else {
clear.flags |= I830_DEPTH;
clear.clear_depthmask |= imesa->stencil_clear_mask;
clear.clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;
}
- mask &= ~DD_STENCIL_BIT;
+ mask &= ~BUFFER_BIT_STENCIL;
}
/* First check for clears that need to happen with triangles */
diff --git a/src/mesa/drivers/dri/i830/i830_screen.c b/src/mesa/drivers/dri/i830/i830_screen.c
index 47a2ef64ac..82883d07f2 100644
--- a/src/mesa/drivers/dri/i830/i830_screen.c
+++ b/src/mesa/drivers/dri/i830/i830_screen.c
@@ -40,6 +40,8 @@
#include "context.h"
#include "matrix.h"
#include "simple_list.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "i830_screen.h"
#include "i830_dri.h"
@@ -54,6 +56,7 @@
#include "utils.h"
#include "xmlpool.h"
+#include "drirenderbuffer.h"
PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN
@@ -310,27 +313,94 @@ static void i830DestroyScreen(__DRIscreenPrivate *sPriv)
sPriv->private = NULL;
}
+
static GLboolean i830CreateBuffer(__DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ i830ScreenPrivate *screen = (i830ScreenPrivate *) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
- } else {
+ }
+ else {
#if 0
GLboolean swStencil = (mesaVis->stencilBits > 0 &&
mesaVis->depthBits != 24);
#else
GLboolean swStencil = mesaVis->stencilBits > 0;
#endif
+
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer(mesaVis,
GL_FALSE, /* software depth buffer? */
swStencil,
mesaVis->accumRedBits > 0,
GL_FALSE /* s/w alpha planes */);
-
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ /*screen->frontOffset*/0, screen->backPitch);
+ i830SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ i830SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i830SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ if (mesaVis->stencilBits == 8) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i830SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else {
+ /* not really 32-bit Z, but use GL_DEPTH_COMPONENT32 anyway */
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i830SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i830SetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+
return (driDrawPriv->driverPrivate != NULL);
}
}
diff --git a/src/mesa/drivers/dri/i830/i830_span.c b/src/mesa/drivers/dri/i830/i830_span.c
index 9076b34423..a17ec9b6ac 100644
--- a/src/mesa/drivers/dri/i830/i830_span.c
+++ b/src/mesa/drivers/dri/i830/i830_span.c
@@ -275,10 +275,10 @@ static void i830SetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
imesa->mesa_drawable = (colorBuffer == imesa->driDrawable->driverPrivate)
? imesa->driDrawable : imesa->driReadable;
- if (bufferBit == DD_FRONT_LEFT_BIT) {
+ if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
imesa->drawMap = (char *)imesa->driScreen->pFB;
imesa->readMap = (char *)imesa->driScreen->pFB;
- } else if (bufferBit == DD_BACK_LEFT_BIT) {
+ } else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
imesa->drawMap = imesa->i830Screen->back.map;
imesa->readMap = imesa->i830Screen->back.map;
} else {
@@ -316,6 +316,7 @@ void i830DDInitSpanFuncs( GLcontext *ctx )
switch (i830Screen->fbFormat) {
case DV_PF_555:
+#if 0
swdd->WriteRGBASpan = i830WriteRGBASpan_555;
swdd->WriteRGBSpan = i830WriteRGBSpan_555;
swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_555;
@@ -323,14 +324,15 @@ void i830DDInitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoRGBAPixels = i830WriteMonoRGBAPixels_555;
swdd->ReadRGBASpan = i830ReadRGBASpan_555;
swdd->ReadRGBAPixels = i830ReadRGBAPixels_555;
-
swdd->ReadDepthSpan = i830ReadDepthSpan_16;
swdd->WriteDepthSpan = i830WriteDepthSpan_16;
swdd->ReadDepthPixels = i830ReadDepthPixels_16;
swdd->WriteDepthPixels = i830WriteDepthPixels_16;
+#endif
break;
case DV_PF_565:
+#if 0
swdd->WriteRGBASpan = i830WriteRGBASpan_565;
swdd->WriteRGBSpan = i830WriteRGBSpan_565;
swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_565;
@@ -338,14 +340,15 @@ void i830DDInitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoRGBAPixels = i830WriteMonoRGBAPixels_565;
swdd->ReadRGBASpan = i830ReadRGBASpan_565;
swdd->ReadRGBAPixels = i830ReadRGBAPixels_565;
-
swdd->ReadDepthSpan = i830ReadDepthSpan_16;
swdd->WriteDepthSpan = i830WriteDepthSpan_16;
swdd->ReadDepthPixels = i830ReadDepthPixels_16;
swdd->WriteDepthPixels = i830WriteDepthPixels_16;
+#endif
break;
case DV_PF_8888:
+#if 0
swdd->WriteRGBASpan = i830WriteRGBASpan_8888;
swdd->WriteRGBSpan = i830WriteRGBSpan_8888;
swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_8888;
@@ -353,22 +356,26 @@ void i830DDInitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoRGBAPixels = i830WriteMonoRGBAPixels_8888;
swdd->ReadRGBASpan = i830ReadRGBASpan_8888;
swdd->ReadRGBAPixels = i830ReadRGBAPixels_8888;
+#endif
if(imesa->hw_stencil) {
+#if 0
swdd->ReadDepthSpan = i830ReadDepthSpan_24_8;
swdd->WriteDepthSpan = i830WriteDepthSpan_24_8;
swdd->ReadDepthPixels = i830ReadDepthPixels_24_8;
swdd->WriteDepthPixels = i830WriteDepthPixels_24_8;
-
swdd->WriteStencilSpan = i830WriteStencilSpan_24_8;
swdd->ReadStencilSpan = i830ReadStencilSpan_24_8;
swdd->WriteStencilPixels = i830WriteStencilPixels_24_8;
swdd->ReadStencilPixels = i830ReadStencilPixels_24_8;
+#endif
} else {
+#if 0
swdd->ReadDepthSpan = i830ReadDepthSpan_24;
swdd->WriteDepthSpan = i830WriteDepthSpan_24;
swdd->ReadDepthPixels = i830ReadDepthPixels_24;
swdd->WriteDepthPixels = i830WriteDepthPixels_24;
+#endif
}
break;
}
@@ -376,3 +383,77 @@ void i830DDInitSpanFuncs( GLcontext *ctx )
swdd->SpanRenderStart = i830SpanRenderStart;
swdd->SpanRenderFinish = i830SpanRenderFinish;
}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+i830SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) {
+ drb->Base.GetRow = i830ReadRGBASpan_555;
+ drb->Base.GetValues = i830ReadRGBAPixels_555;
+ drb->Base.PutRow = i830WriteRGBASpan_555;
+ drb->Base.PutRowRGB = i830WriteRGBSpan_555;
+ drb->Base.PutMonoRow = i830WriteMonoRGBASpan_555;
+ drb->Base.PutValues = i830WriteRGBAPixels_555;
+ drb->Base.PutMonoValues = i830WriteMonoRGBAPixels_555;
+ }
+ else if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = i830ReadRGBASpan_565;
+ drb->Base.GetValues = i830ReadRGBAPixels_565;
+ drb->Base.PutRow = i830WriteRGBASpan_565;
+ drb->Base.PutRowRGB = i830WriteRGBSpan_565;
+ drb->Base.PutMonoRow = i830WriteMonoRGBASpan_565;
+ drb->Base.PutValues = i830WriteRGBAPixels_565;
+ drb->Base.PutMonoValues = i830WriteMonoRGBAPixels_565;
+ }
+ else {
+ assert(vis->redBits == 8);
+ assert(vis->greenBits == 8);
+ assert(vis->blueBits == 8);
+ drb->Base.GetRow = i830ReadRGBASpan_8888;
+ drb->Base.GetValues = i830ReadRGBAPixels_8888;
+ drb->Base.PutRow = i830WriteRGBASpan_8888;
+ drb->Base.PutRowRGB = i830WriteRGBSpan_8888;
+ drb->Base.PutMonoRow = i830WriteMonoRGBASpan_8888;
+ drb->Base.PutValues = i830WriteRGBAPixels_8888;
+ drb->Base.PutMonoValues = i830WriteMonoRGBAPixels_8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = i830ReadDepthSpan_16;
+ drb->Base.GetValues = i830ReadDepthPixels_16;
+ drb->Base.PutRow = i830WriteDepthSpan_16;
+ drb->Base.PutMonoRow = i830WriteMonoDepthSpan_16;
+ drb->Base.PutValues = i830WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = i830ReadDepthSpan_24_8;
+ drb->Base.GetValues = i830ReadDepthPixels_24_8;
+ drb->Base.PutRow = i830WriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = i830WriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = i830WriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ /* not _really_ 32-bit Z */
+ drb->Base.GetRow = i830ReadDepthSpan_24;
+ drb->Base.GetValues = i830ReadDepthPixels_24;
+ drb->Base.PutRow = i830WriteDepthSpan_24;
+ drb->Base.PutMonoRow = i830WriteMonoDepthSpan_24;
+ drb->Base.PutValues = i830WriteDepthPixels_24;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = i830ReadStencilSpan_24_8;
+ drb->Base.GetValues = i830ReadStencilPixels_24_8;
+ drb->Base.PutRow = i830WriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = i830WriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = i830WriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/i830/i830_span.h b/src/mesa/drivers/dri/i830/i830_span.h
index 0135468ffa..4b83419718 100644
--- a/src/mesa/drivers/dri/i830/i830_span.h
+++ b/src/mesa/drivers/dri/i830/i830_span.h
@@ -38,9 +38,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef _I830_SPAN_H
#define _I830_SPAN_H
+#include "drirenderbuffer.h"
+
extern void i830DDInitSpanFuncs( GLcontext *ctx );
extern void i830SpanRenderFinish( GLcontext *ctx );
extern void i830SpanRenderStart( GLcontext *ctx );
+extern void
+i830SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/dri/i830/i830_state.c b/src/mesa/drivers/dri/i830/i830_state.c
index f8979c7018..6153485449 100644
--- a/src/mesa/drivers/dri/i830/i830_state.c
+++ b/src/mesa/drivers/dri/i830/i830_state.c
@@ -802,17 +802,17 @@ static void i830DrawBuffer(GLcontext *ctx, GLenum mode )
i830ContextPtr imesa = I830_CONTEXT(ctx);
/*
- * _DrawDestMask is easier to cope with than <mode>.
+ * _ColorDrawBufferMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
I830_FIREVERTICES(imesa);
I830_STATECHANGE(imesa, I830_UPLOAD_BUFFERS);
imesa->BufferSetup[I830_DESTREG_CBUFADDR] = imesa->i830Screen->fbOffset;
i830XMesaSetFrontClipRects( imesa );
FALLBACK( imesa, I830_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
I830_FIREVERTICES(imesa);
I830_STATECHANGE(imesa, I830_UPLOAD_BUFFERS);
imesa->BufferSetup[I830_DESTREG_CBUFADDR] =
diff --git a/src/mesa/drivers/dri/i915/i830_metaops.c b/src/mesa/drivers/dri/i915/i830_metaops.c
index 751d8e75ed..dd238378b0 100644
--- a/src/mesa/drivers/dri/i915/i830_metaops.c
+++ b/src/mesa/drivers/dri/i915/i830_metaops.c
@@ -386,7 +386,7 @@ i830ClearWithTris(intelContextPtr intel, GLbitfield mask,
* The active cliprects will be applied as for any other geometry.
*/
- if(mask & DD_FRONT_LEFT_BIT) {
+ if(mask & BUFFER_BIT_FRONT_LEFT) {
set_no_depth_stencil_write( i830 );
set_color_mask( i830, GL_TRUE );
set_draw_offset( i830, screen->frontOffset );
@@ -396,7 +396,7 @@ i830ClearWithTris(intelContextPtr intel, GLbitfield mask,
0, 0, 0, 0);
}
- if(mask & DD_BACK_LEFT_BIT) {
+ if(mask & BUFFER_BIT_BACK_LEFT) {
set_no_depth_stencil_write( i830 );
set_color_mask( i830, GL_TRUE );
set_draw_offset( i830, screen->backOffset );
@@ -407,7 +407,7 @@ i830ClearWithTris(intelContextPtr intel, GLbitfield mask,
0, 0, 0, 0);
}
- if(mask & DD_STENCIL_BIT) {
+ if(mask & BUFFER_BIT_STENCIL) {
set_stencil_replace( i830,
intel->ctx.Stencil.WriteMask[0],
intel->ctx.Stencil.Clear);
diff --git a/src/mesa/drivers/dri/i915/i915_metaops.c b/src/mesa/drivers/dri/i915/i915_metaops.c
index 3176c727d0..2e9063edf0 100644
--- a/src/mesa/drivers/dri/i915/i915_metaops.c
+++ b/src/mesa/drivers/dri/i915/i915_metaops.c
@@ -475,7 +475,7 @@ i915ClearWithTris(intelContextPtr intel, GLbitfield mask,
* The active cliprects will be applied as for any other geometry.
*/
- if (mask & DD_FRONT_LEFT_BIT) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
set_no_depth_stencil_write( i915 );
set_color_mask( i915, GL_TRUE );
set_draw_offset( i915, screen->frontOffset );
@@ -486,7 +486,7 @@ i915ClearWithTris(intelContextPtr intel, GLbitfield mask,
0, 0, 0, 0);
}
- if(mask & DD_BACK_LEFT_BIT) {
+ if (mask & BUFFER_BIT_BACK_LEFT) {
set_no_depth_stencil_write( i915 );
set_color_mask( i915, GL_TRUE );
set_draw_offset( i915, screen->backOffset );
@@ -497,7 +497,7 @@ i915ClearWithTris(intelContextPtr intel, GLbitfield mask,
0, 0, 0, 0);
}
- if(mask & DD_STENCIL_BIT) {
+ if (mask & BUFFER_BIT_STENCIL) {
set_stencil_replace( i915,
intel->ctx.Stencil.WriteMask[0],
intel->ctx.Stencil.Clear);
diff --git a/src/mesa/drivers/dri/i915/intel_batchbuffer.c b/src/mesa/drivers/dri/i915/intel_batchbuffer.c
index 2062c9079e..7c9ad87bed 100644
--- a/src/mesa/drivers/dri/i915/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i915/intel_batchbuffer.c
@@ -512,11 +512,11 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
clear_color = intel->ClearColor;
clear_depth = 0;
- if (flags & DD_DEPTH_BIT) {
+ if (flags & BUFFER_BIT_DEPTH) {
clear_depth = (GLuint)(ctx->Depth.Clear * intel->ClearDepth);
}
- if (flags & DD_STENCIL_BIT) {
+ if (flags & BUFFER_BIT_STENCIL) {
clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;
}
@@ -531,8 +531,8 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
XY_COLOR_BLT_WRITE_ALPHA |
XY_COLOR_BLT_WRITE_RGB);
D_CMD = XY_COLOR_BLT_CMD;
- if (flags & DD_DEPTH_BIT) D_CMD |= XY_COLOR_BLT_WRITE_RGB;
- if (flags & DD_STENCIL_BIT) D_CMD |= XY_COLOR_BLT_WRITE_ALPHA;
+ if (flags & BUFFER_BIT_DEPTH) D_CMD |= XY_COLOR_BLT_WRITE_RGB;
+ if (flags & BUFFER_BIT_STENCIL) D_CMD |= XY_COLOR_BLT_WRITE_ALPHA;
break;
default:
BR13 = (0xF0 << 16) | (pitch * cpp) | (1<<24);
@@ -552,9 +552,9 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
if ( intel->sarea->pf_current_page == 1 ) {
GLuint tmp = flags;
- flags &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
- if ( tmp & DD_FRONT_LEFT_BIT ) flags |= DD_BACK_LEFT_BIT;
- if ( tmp & DD_BACK_LEFT_BIT ) flags |= DD_FRONT_LEFT_BIT;
+ flags &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
+ if ( tmp & BUFFER_BIT_FRONT_LEFT ) flags |= BUFFER_BIT_BACK_LEFT;
+ if ( tmp & BUFFER_BIT_BACK_LEFT ) flags |= BUFFER_BIT_FRONT_LEFT;
}
for (i = 0 ; i < intel->numClipRects ; i++)
@@ -590,7 +590,7 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
b.y2 > intelScreen->height)
continue;
- if ( flags & DD_FRONT_LEFT_BIT ) {
+ if ( flags & BUFFER_BIT_FRONT_LEFT ) {
BEGIN_BATCH( 6);
OUT_BATCH( CMD );
OUT_BATCH( BR13 );
@@ -601,7 +601,7 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
ADVANCE_BATCH();
}
- if ( flags & DD_BACK_LEFT_BIT ) {
+ if ( flags & BUFFER_BIT_BACK_LEFT ) {
BEGIN_BATCH( 6);
OUT_BATCH( CMD );
OUT_BATCH( BR13 );
@@ -612,7 +612,7 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
ADVANCE_BATCH();
}
- if ( flags & (DD_STENCIL_BIT | DD_DEPTH_BIT) ) {
+ if ( flags & (BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH) ) {
BEGIN_BATCH( 6);
OUT_BATCH( D_CMD );
OUT_BATCH( BR13 );
diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
index 97e8933c21..0dabfad5ff 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -31,6 +31,7 @@
#include "matrix.h"
#include "simple_list.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "imports.h"
#include "swrast/swrast.h"
@@ -235,7 +236,7 @@ void intelInitDriverFunctions( struct dd_function_table *functions )
functions->Clear = intelClear;
functions->Finish = intelFinish;
functions->GetBufferSize = intelBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = intelGetString;
functions->UpdateState = intelInvalidateState;
functions->CopyColorTable = _swrast_CopyColorTable;
@@ -493,11 +494,11 @@ void intelSetBackClipRects( intelContextPtr intel )
void intelWindowMoved( intelContextPtr intel )
{
- switch (intel->ctx.Color._DrawDestMask[0]) {
- case DD_FRONT_LEFT_BIT:
+ switch (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
intelSetFrontClipRects( intel );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
intelSetBackClipRects( intel );
break;
default:
@@ -525,11 +526,11 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
intelWindowMoved( intel );
}
- _mesa_make_current2(&intel->ctx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate);
+ _mesa_make_current(&intel->ctx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
} else {
- _mesa_make_current(0,0);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/i915/intel_ioctl.c b/src/mesa/drivers/dri/i915/intel_ioctl.c
index 3662918dd8..9691627ebc 100644
--- a/src/mesa/drivers/dri/i915/intel_ioctl.c
+++ b/src/mesa/drivers/dri/i915/intel_ioctl.c
@@ -348,41 +348,41 @@ void intelClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
*/
intelFlush( &intel->ctx );
- if (mask & DD_FRONT_LEFT_BIT) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
if (colorMask == ~0) {
- blit_mask |= DD_FRONT_LEFT_BIT;
+ blit_mask |= BUFFER_BIT_FRONT_LEFT;
}
else {
- tri_mask |= DD_FRONT_LEFT_BIT;
+ tri_mask |= BUFFER_BIT_FRONT_LEFT;
}
}
- if (mask & DD_BACK_LEFT_BIT) {
+ if (mask & BUFFER_BIT_BACK_LEFT) {
if (colorMask == ~0) {
- blit_mask |= DD_BACK_LEFT_BIT;
+ blit_mask |= BUFFER_BIT_BACK_LEFT;
}
else {
- tri_mask |= DD_BACK_LEFT_BIT;
+ tri_mask |= BUFFER_BIT_BACK_LEFT;
}
}
- if (mask & DD_DEPTH_BIT) {
- blit_mask |= DD_DEPTH_BIT;
+ if (mask & BUFFER_BIT_DEPTH) {
+ blit_mask |= BUFFER_BIT_DEPTH;
}
- if (mask & DD_STENCIL_BIT) {
+ if (mask & BUFFER_BIT_STENCIL) {
if (!intel->hw_stencil) {
- swrast_mask |= DD_STENCIL_BIT;
+ swrast_mask |= BUFFER_BIT_STENCIL;
}
else if (ctx->Stencil.WriteMask[0] != 0xff) {
- tri_mask |= DD_STENCIL_BIT;
+ tri_mask |= BUFFER_BIT_STENCIL;
}
else {
- blit_mask |= DD_STENCIL_BIT;
+ blit_mask |= BUFFER_BIT_STENCIL;
}
}
- swrast_mask |= (mask & DD_ACCUM_BIT);
+ swrast_mask |= (mask & BUFFER_BIT_ACCUM);
if (blit_mask)
intelClearWithBlit( ctx, blit_mask, all, cx, cy, cw, ch );
diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
index 8236718477..06caa1a6be 100644
--- a/src/mesa/drivers/dri/i915/intel_screen.c
+++ b/src/mesa/drivers/dri/i915/intel_screen.c
@@ -27,7 +27,9 @@
#include "glheader.h"
#include "context.h"
+#include "framebuffer.h"
#include "matrix.h"
+#include "renderbuffer.h"
#include "simple_list.h"
#include "utils.h"
#include "xmlpool.h"
@@ -233,24 +235,78 @@ static void intelDestroyScreen(__DRIscreenPrivate *sPriv)
sPriv->private = NULL;
}
+
static GLboolean intelCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ intelScreenPrivate *screen = (intelScreenPrivate *) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
} else {
GLboolean swStencil = (mesaVis->stencilBits > 0 &&
mesaVis->depthBits != 24);
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer(mesaVis,
GL_FALSE, /* software depth buffer? */
swStencil,
mesaVis->accumRedBits > 0,
GL_FALSE /* s/w alpha planes */);
-
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ intelSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ intelSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ intelSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ intelSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ intelSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
diff --git a/src/mesa/drivers/dri/i915/intel_span.c b/src/mesa/drivers/dri/i915/intel_span.c
index 494022b295..7a051718aa 100644
--- a/src/mesa/drivers/dri/i915/intel_span.c
+++ b/src/mesa/drivers/dri/i915/intel_span.c
@@ -247,10 +247,10 @@ static void intelSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
GLuint bufferBit)
{
intelContextPtr intel = INTEL_CONTEXT(ctx);
- if (bufferBit == DD_FRONT_LEFT_BIT) {
+ if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
intel->drawMap = (char *)intel->driScreen->pFB;
intel->readMap = (char *)intel->driScreen->pFB;
- } else if (bufferBit == DD_BACK_LEFT_BIT) {
+ } else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
intel->drawMap = intel->intelScreen->back.map;
intel->readMap = intel->intelScreen->back.map;
} else {
@@ -288,6 +288,7 @@ void intelInitSpanFuncs( GLcontext *ctx )
switch (intelScreen->fbFormat) {
case DV_PF_555:
+#if 0
swdd->WriteRGBASpan = intelWriteRGBASpan_555;
swdd->WriteRGBSpan = intelWriteRGBSpan_555;
swdd->WriteMonoRGBASpan = intelWriteMonoRGBASpan_555;
@@ -295,14 +296,15 @@ void intelInitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoRGBAPixels = intelWriteMonoRGBAPixels_555;
swdd->ReadRGBASpan = intelReadRGBASpan_555;
swdd->ReadRGBAPixels = intelReadRGBAPixels_555;
-
swdd->ReadDepthSpan = intelReadDepthSpan_16;
swdd->WriteDepthSpan = intelWriteDepthSpan_16;
swdd->ReadDepthPixels = intelReadDepthPixels_16;
swdd->WriteDepthPixels = intelWriteDepthPixels_16;
+#endif
break;
case DV_PF_565:
+#if 0
swdd->WriteRGBASpan = intelWriteRGBASpan_565;
swdd->WriteRGBSpan = intelWriteRGBSpan_565;
swdd->WriteMonoRGBASpan = intelWriteMonoRGBASpan_565;
@@ -310,14 +312,15 @@ void intelInitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoRGBAPixels = intelWriteMonoRGBAPixels_565;
swdd->ReadRGBASpan = intelReadRGBASpan_565;
swdd->ReadRGBAPixels = intelReadRGBAPixels_565;
-
swdd->ReadDepthSpan = intelReadDepthSpan_16;
swdd->WriteDepthSpan = intelWriteDepthSpan_16;
swdd->ReadDepthPixels = intelReadDepthPixels_16;
swdd->WriteDepthPixels = intelWriteDepthPixels_16;
+#endif
break;
case DV_PF_8888:
+#if 0
swdd->WriteRGBASpan = intelWriteRGBASpan_8888;
swdd->WriteRGBSpan = intelWriteRGBSpan_8888;
swdd->WriteMonoRGBASpan = intelWriteMonoRGBASpan_8888;
@@ -325,7 +328,6 @@ void intelInitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoRGBAPixels = intelWriteMonoRGBAPixels_8888;
swdd->ReadRGBASpan = intelReadRGBASpan_8888;
swdd->ReadRGBAPixels = intelReadRGBAPixels_8888;
-
swdd->ReadDepthSpan = intelReadDepthSpan_24_8;
swdd->WriteDepthSpan = intelWriteDepthSpan_24_8;
swdd->ReadDepthPixels = intelReadDepthPixels_24_8;
@@ -335,9 +337,75 @@ void intelInitSpanFuncs( GLcontext *ctx )
swdd->ReadStencilSpan = intelReadStencilSpan_24_8;
swdd->WriteStencilPixels = intelWriteStencilPixels_24_8;
swdd->ReadStencilPixels = intelReadStencilPixels_24_8;
+#endif
break;
}
swdd->SpanRenderStart = intelSpanRenderStart;
swdd->SpanRenderFinish = intelSpanRenderFinish;
}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+intelSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) {
+ drb->Base.GetRow = intelReadRGBASpan_555;
+ drb->Base.GetValues = intelReadRGBAPixels_555;
+ drb->Base.PutRow = intelWriteRGBASpan_555;
+ drb->Base.PutRowRGB = intelWriteRGBSpan_555;
+ drb->Base.PutMonoRow = intelWriteMonoRGBASpan_555;
+ drb->Base.PutValues = intelWriteRGBAPixels_555;
+ drb->Base.PutMonoValues = intelWriteMonoRGBAPixels_555;
+ }
+ else if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = intelReadRGBASpan_565;
+ drb->Base.GetValues = intelReadRGBAPixels_565;
+ drb->Base.PutRow = intelWriteRGBASpan_565;
+ drb->Base.PutRowRGB = intelWriteRGBSpan_565;
+ drb->Base.PutMonoRow = intelWriteMonoRGBASpan_565;
+ drb->Base.PutValues = intelWriteRGBAPixels_565;
+ drb->Base.PutMonoValues = intelWriteMonoRGBAPixels_565;
+ }
+ else {
+ assert(vis->redBits == 8);
+ assert(vis->greenBits == 8);
+ assert(vis->blueBits == 8);
+ drb->Base.GetRow = intelReadRGBASpan_8888;
+ drb->Base.GetValues = intelReadRGBAPixels_8888;
+ drb->Base.PutRow = intelWriteRGBASpan_8888;
+ drb->Base.PutRowRGB = intelWriteRGBSpan_8888;
+ drb->Base.PutMonoRow = intelWriteMonoRGBASpan_8888;
+ drb->Base.PutValues = intelWriteRGBAPixels_8888;
+ drb->Base.PutMonoValues = intelWriteMonoRGBAPixels_8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = intelReadDepthSpan_16;
+ drb->Base.GetValues = intelReadDepthPixels_16;
+ drb->Base.PutRow = intelWriteDepthSpan_16;
+ drb->Base.PutMonoRow = intelWriteMonoDepthSpan_16;
+ drb->Base.PutValues = intelWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = intelReadDepthSpan_24_8;
+ drb->Base.GetValues = intelReadDepthPixels_24_8;
+ drb->Base.PutRow = intelWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = intelWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = intelWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = intelReadStencilSpan_24_8;
+ drb->Base.GetValues = intelReadStencilPixels_24_8;
+ drb->Base.PutRow = intelWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = intelWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = intelWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/i915/intel_span.h b/src/mesa/drivers/dri/i915/intel_span.h
index 3ff710b9c4..2d4f8589d0 100644
--- a/src/mesa/drivers/dri/i915/intel_span.h
+++ b/src/mesa/drivers/dri/i915/intel_span.h
@@ -28,9 +28,14 @@
#ifndef _INTEL_SPAN_H
#define _INTEL_SPAN_H
+#include "drirenderbuffer.h"
+
extern void intelInitSpanFuncs( GLcontext *ctx );
extern void intelSpanRenderFinish( GLcontext *ctx );
extern void intelSpanRenderStart( GLcontext *ctx );
+extern void
+intelSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/dri/i915/intel_state.c b/src/mesa/drivers/dri/i915/intel_state.c
index 76bfaec18f..db6a140d2d 100644
--- a/src/mesa/drivers/dri/i915/intel_state.c
+++ b/src/mesa/drivers/dri/i915/intel_state.c
@@ -170,12 +170,12 @@ static void intelDrawBuffer(GLcontext *ctx, GLenum mode )
intelScreenPrivate *screen = intel->intelScreen;
int front = 0;
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
front = 1;
FALLBACK( intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
front = 0;
FALLBACK( intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
diff --git a/src/mesa/drivers/dri/mach64/mach64_context.c b/src/mesa/drivers/dri/mach64/mach64_context.c
index 1978c5d615..8f508fa911 100644
--- a/src/mesa/drivers/dri/mach64/mach64_context.c
+++ b/src/mesa/drivers/dri/mach64/mach64_context.c
@@ -306,14 +306,14 @@ mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
mach64CalcViewport( newMach64Ctx->glCtx );
}
- _mesa_make_current2( newMach64Ctx->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_make_current( newMach64Ctx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
newMach64Ctx->new_state |= MACH64_NEW_CLIP;
} else {
- _mesa_make_current( 0, 0 );
+ _mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/mach64/mach64_dd.c b/src/mesa/drivers/dri/mach64/mach64_dd.c
index f1248bd8b7..c0bb8629fa 100644
--- a/src/mesa/drivers/dri/mach64/mach64_dd.c
+++ b/src/mesa/drivers/dri/mach64/mach64_dd.c
@@ -37,6 +37,7 @@
#include "context.h"
#include "utils.h"
+#include "framebuffer.h"
#define DRIVER_DATE "20030502"
@@ -126,7 +127,7 @@ static void mach64DDFinish( GLcontext *ctx )
void mach64InitDriverFuncs( struct dd_function_table *functions )
{
functions->GetBufferSize = mach64DDGetBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = mach64DDGetString;
functions->Finish = mach64DDFinish;
functions->Flush = mach64DDFlush;
diff --git a/src/mesa/drivers/dri/mach64/mach64_ioctl.c b/src/mesa/drivers/dri/mach64/mach64_ioctl.c
index 752aa6ef4a..1889dc2b93 100644
--- a/src/mesa/drivers/dri/mach64/mach64_ioctl.c
+++ b/src/mesa/drivers/dri/mach64/mach64_ioctl.c
@@ -683,19 +683,19 @@ static void mach64DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
mmesa->new_state = save_state & ~(MACH64_NEW_MASKS | MACH64_NEW_CLIP);
}
- if ( mask & DD_FRONT_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
flags |= MACH64_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if ( mask & DD_BACK_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
flags |= MACH64_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if ( ( mask & DD_DEPTH_BIT ) && ctx->Depth.Mask ) {
+ if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
flags |= MACH64_DEPTH;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
if ( mask )
diff --git a/src/mesa/drivers/dri/mach64/mach64_lock.c b/src/mesa/drivers/dri/mach64/mach64_lock.c
index ea926944ed..3d41d71b37 100644
--- a/src/mesa/drivers/dri/mach64/mach64_lock.c
+++ b/src/mesa/drivers/dri/mach64/mach64_lock.c
@@ -69,7 +69,7 @@ void mach64GetLock( mach64ContextPtr mmesa, GLuint flags )
if ( mmesa->lastStamp != dPriv->lastStamp ) {
mmesa->lastStamp = dPriv->lastStamp;
- if (mmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT)
+ if (mmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
mach64SetCliprects( mmesa->glCtx, GL_BACK_LEFT );
else
mach64SetCliprects( mmesa->glCtx, GL_FRONT_LEFT );
diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c
index c5806adc3d..471ae1648e 100644
--- a/src/mesa/drivers/dri/mach64/mach64_screen.c
+++ b/src/mesa/drivers/dri/mach64/mach64_screen.c
@@ -33,9 +33,12 @@
#include "mach64_ioctl.h"
#include "mach64_tris.h"
#include "mach64_vb.h"
+#include "mach64_span.h"
#include "context.h"
#include "imports.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "utils.h"
#include "vblank.h"
@@ -355,6 +358,7 @@ mach64DestroyScreen( __DRIscreenPrivate *driScreen )
driScreen->private = NULL;
}
+
/* Create and initialize the Mesa and driver specific pixmap buffer
* data.
*/
@@ -364,16 +368,62 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ mach64ScreenPtr screen = (mach64ScreenPtr) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer( mesaVis,
GL_FALSE, /* software depth buffer? */
mesaVis->stencilBits > 0,
mesaVis->accumRedBits > 0,
mesaVis->alphaBits > 0 );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ mach64SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ mach64SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mach64SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mach64SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
diff --git a/src/mesa/drivers/dri/mach64/mach64_span.c b/src/mesa/drivers/dri/mach64/mach64_span.c
index 3e553a9094..12849eebe0 100644
--- a/src/mesa/drivers/dri/mach64/mach64_span.c
+++ b/src/mesa/drivers/dri/mach64/mach64_span.c
@@ -200,15 +200,15 @@ static void mach64DDSetBuffer( GLcontext *ctx,
mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
switch ( bufferBit ) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
- fprintf(stderr,"%s: DD_FRONT_LEFT_BIT\n", __FUNCTION__);
+ fprintf(stderr,"%s: BUFFER_BIT_FRONT_LEFT\n", __FUNCTION__);
mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->frontOffset;
mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->frontPitch;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
- fprintf(stderr,"%s: DD_BACK_LEFT_BIT\n", __FUNCTION__);
+ fprintf(stderr,"%s: BUFFER_BIT_BACK_LEFT\n", __FUNCTION__);
mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->backOffset;
mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->backPitch;
break;
@@ -220,12 +220,14 @@ static void mach64DDSetBuffer( GLcontext *ctx,
void mach64DDInitSpanFuncs( GLcontext *ctx )
{
+#if 0
mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+#endif
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
swdd->SetBuffer = mach64DDSetBuffer;
-
+#if 0
switch ( mmesa->mach64Screen->cpp ) {
case 2:
swdd->WriteRGBASpan = mach64WriteRGBASpan_RGB565;
@@ -251,13 +253,15 @@ void mach64DDInitSpanFuncs( GLcontext *ctx )
default:
break;
}
+#endif
/* Depth buffer is always 16 bit */
+#if 0
swdd->ReadDepthSpan = mach64ReadDepthSpan_16;
swdd->WriteDepthSpan = mach64WriteDepthSpan_16;
swdd->ReadDepthPixels = mach64ReadDepthPixels_16;
swdd->WriteDepthPixels = mach64WriteDepthPixels_16;
-
+#endif
/* No hardware stencil buffer */
swdd->ReadStencilSpan = NULL;
swdd->WriteStencilSpan = NULL;
@@ -272,3 +276,58 @@ void mach64DDInitSpanFuncs( GLcontext *ctx )
swdd->ReadCI32Span = NULL;
swdd->ReadCI32Pixels = NULL;
}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+mach64SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = mach64ReadRGBASpan_RGB565;
+ drb->Base.GetValues = mach64ReadRGBAPixels_RGB565;
+ drb->Base.PutRow = mach64WriteRGBASpan_RGB565;
+ drb->Base.PutRowRGB = mach64WriteRGBSpan_RGB565;
+ drb->Base.PutMonoRow = mach64WriteMonoRGBASpan_RGB565;
+ drb->Base.PutValues = mach64WriteRGBAPixels_RGB565;
+ drb->Base.PutMonoValues = mach64WriteMonoRGBAPixels_RGB565;
+ }
+ else {
+ drb->Base.GetRow = mach64ReadRGBASpan_ARGB8888;
+ drb->Base.GetValues = mach64ReadRGBAPixels_ARGB8888;
+ drb->Base.PutRow = mach64WriteRGBASpan_ARGB8888;
+ drb->Base.PutRowRGB = mach64WriteRGBSpan_ARGB8888;
+ drb->Base.PutMonoRow = mach64WriteMonoRGBASpan_ARGB8888;
+ drb->Base.PutValues = mach64WriteRGBAPixels_ARGB8888;
+ drb->Base.PutMonoValues = mach64WriteMonoRGBAPixels_ARGB8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = mach64ReadDepthSpan_16;
+ drb->Base.GetValues = mach64ReadDepthPixels_16;
+ drb->Base.PutRow = mach64WriteDepthSpan_16;
+ drb->Base.PutMonoRow = mach64WriteMonoDepthSpan_16;
+ drb->Base.PutValues = mach64WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ /* never */
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ /* never */
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/mach64/mach64_span.h b/src/mesa/drivers/dri/mach64/mach64_span.h
index b83ac7c721..0f4c766477 100644
--- a/src/mesa/drivers/dri/mach64/mach64_span.h
+++ b/src/mesa/drivers/dri/mach64/mach64_span.h
@@ -31,6 +31,11 @@
#ifndef __MACH64_SPAN_H__
#define __MACH64_SPAN_H__
+#include "drirenderbuffer.h"
+
extern void mach64DDInitSpanFuncs( GLcontext *ctx );
+extern void
+mach64SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/dri/mach64/mach64_state.c b/src/mesa/drivers/dri/mach64/mach64_state.c
index ea55124d91..d9b5725a63 100644
--- a/src/mesa/drivers/dri/mach64/mach64_state.c
+++ b/src/mesa/drivers/dri/mach64/mach64_state.c
@@ -732,18 +732,18 @@ static void mach64DDDrawBuffer( GLcontext *ctx, GLenum mode )
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE );
mach64SetCliprects( ctx, GL_FRONT_LEFT );
if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
- fprintf(stderr,"%s: DD_FRONT_LEFT_BIT\n", __FUNCTION__);
+ fprintf(stderr,"%s: BUFFER_BIT_FRONT_LEFT\n", __FUNCTION__);
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE );
mach64SetCliprects( ctx, GL_BACK_LEFT );
if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
- fprintf(stderr,"%s: DD_BACK_LEFT_BIT\n", __FUNCTION__);
+ fprintf(stderr,"%s: BUFFER_BIT_BACK_LEFT\n", __FUNCTION__);
break;
default:
/* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c
index 9a3b331e8c..6312997ce6 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.c
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.c
@@ -34,6 +34,8 @@
#include "matrix.h"
#include "simple_list.h"
#include "imports.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
@@ -55,7 +57,6 @@
#include "mga_xmesa.h"
#include "mga_dri.h"
-
#include "utils.h"
#include "vblank.h"
@@ -721,6 +722,8 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ mgaScreenPrivate *screen = (mgaScreenPrivate *) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
@@ -728,12 +731,81 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
GLboolean swStencil = (mesaVis->stencilBits > 0 &&
mesaVis->depthBits != 24);
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer(mesaVis,
GL_FALSE, /* software depth buffer? */
swStencil,
mesaVis->accumRedBits > 0,
mesaVis->alphaBits > 0 );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ mgaSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ mgaSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ /* XXX is this right? */
+ if (mesaVis->stencilBits) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ }
+ else if (mesaVis->depthBits == 32) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
@@ -799,12 +871,12 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
mmesa->driReadable = driReadPriv;
- _mesa_make_current2(mmesa->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate);
+ _mesa_make_current(mmesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
}
else {
- _mesa_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.h b/src/mesa/drivers/dri/mga/mga_xmesa.h
index f78f806c77..51cc129580 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.h
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.h
@@ -83,6 +83,17 @@ typedef struct mga_screen_private_s {
} mgaScreenPrivate;
+/**
+ * mgaRenderbuffer, derived from Mesa's gl_renderbuffer
+ */
+typedef struct {
+ struct gl_renderbuffer Base;
+ /* XXX per-window info should go here */
+ int foo, bar;
+} mgaRenderbuffer;
+
+
+
#include "mgacontext.h"
extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags );
diff --git a/src/mesa/drivers/dri/mga/mgadd.c b/src/mesa/drivers/dri/mga/mgadd.c
index e8436f2384..7310641efa 100644
--- a/src/mesa/drivers/dri/mga/mgadd.c
+++ b/src/mesa/drivers/dri/mga/mgadd.c
@@ -28,6 +28,7 @@
#include "mtypes.h"
+#include "framebuffer.h"
#include "mm.h"
#include "mgacontext.h"
@@ -92,6 +93,6 @@ static void mgaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
void mgaInitDriverFuncs( struct dd_function_table *functions )
{
functions->GetBufferSize = mgaBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = mgaGetString;
}
diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c
index 097fcd6cbd..29c06dcbbc 100644
--- a/src/mesa/drivers/dri/mga/mgaioctl.c
+++ b/src/mesa/drivers/dri/mga/mgaioctl.c
@@ -175,30 +175,30 @@ mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
FLUSH_BATCH( mmesa );
- if ( mask & DD_FRONT_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
flags |= MGA_FRONT;
color_mask = mmesa->setup.plnwt;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if ( mask & DD_BACK_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
flags |= MGA_BACK;
color_mask = mmesa->setup.plnwt;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if ( (mask & DD_DEPTH_BIT) && ctx->Depth.Mask ) {
+ if ( (mask & BUFFER_BIT_DEPTH) && ctx->Depth.Mask ) {
flags |= MGA_DEPTH;
clear_depth = (mmesa->ClearDepth & mmesa->depth_clear_mask);
depth_mask |= mmesa->depth_clear_mask;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
- if ( (mask & DD_STENCIL_BIT) && mmesa->hw_stencil ) {
+ if ( (mask & BUFFER_BIT_STENCIL) && mmesa->hw_stencil ) {
flags |= MGA_DEPTH;
clear_depth |= (ctx->Stencil.Clear & mmesa->stencil_clear_mask);
depth_mask |= mmesa->stencil_clear_mask;
- mask &= ~DD_STENCIL_BIT;
+ mask &= ~BUFFER_BIT_STENCIL;
}
if ( flags ) {
diff --git a/src/mesa/drivers/dri/mga/mgaspan.c b/src/mesa/drivers/dri/mga/mgaspan.c
index 4b2c5cd682..4279dfd95b 100644
--- a/src/mesa/drivers/dri/mga/mgaspan.c
+++ b/src/mesa/drivers/dri/mga/mgaspan.c
@@ -204,9 +204,9 @@ static void mgaDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
unsigned int offset;
- assert((bufferBit == DD_FRONT_LEFT_BIT) || (bufferBit == DD_BACK_LEFT_BIT));
+ assert((bufferBit == BUFFER_BIT_FRONT_LEFT) || (bufferBit == BUFFER_BIT_BACK_LEFT));
- offset = (bufferBit == DD_FRONT_LEFT_BIT)
+ offset = (bufferBit == BUFFER_BIT_FRONT_LEFT)
? mmesa->mgaScreen->frontOffset
: mmesa->mgaScreen->backOffset;
@@ -237,15 +237,17 @@ void mgaDDInitSpanFuncs( GLcontext *ctx )
switch (mmesa->mgaScreen->cpp) {
case 2:
+#if 0
mgaInitPointers_565( swdd );
-
swdd->ReadDepthSpan = mgaReadDepthSpan_16;
swdd->WriteDepthSpan = mgaWriteDepthSpan_16;
swdd->ReadDepthPixels = mgaReadDepthPixels_16;
swdd->WriteDepthPixels = mgaWriteDepthPixels_16;
+#endif
break;
case 4:
+#if 0
mgaInitPointers_8888( swdd );
if (!mmesa->hw_stencil) {
@@ -264,6 +266,57 @@ void mgaDDInitSpanFuncs( GLcontext *ctx )
swdd->ReadStencilPixels = mgaReadStencilPixels_24_8;
swdd->WriteStencilPixels = mgaWriteStencilPixels_24_8;
}
+#endif
break;
}
}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+mgaSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ mgaInitPointers_565(&drb->Base);
+ }
+ else {
+ mgaInitPointers_8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = mgaReadDepthSpan_16;
+ drb->Base.GetValues = mgaReadDepthPixels_16;
+ drb->Base.PutRow = mgaWriteDepthSpan_16;
+ drb->Base.PutMonoRow = mgaWriteMonoDepthSpan_16;
+ drb->Base.PutValues = mgaWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = mgaReadDepthSpan_24_8;
+ drb->Base.GetValues = mgaReadDepthPixels_24_8;
+ drb->Base.PutRow = mgaWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = mgaWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = mgaWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ drb->Base.GetRow = mgaReadDepthSpan_32;
+ drb->Base.GetValues = mgaReadDepthPixels_32;
+ drb->Base.PutRow = mgaWriteDepthSpan_32;
+ drb->Base.PutMonoRow = mgaWriteMonoDepthSpan_32;
+ drb->Base.PutValues = mgaWriteDepthPixels_32;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = mgaReadStencilSpan_24_8;
+ drb->Base.GetValues = mgaReadStencilPixels_24_8;
+ drb->Base.PutRow = mgaWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = mgaWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = mgaWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/mga/mgaspan.h b/src/mesa/drivers/dri/mga/mgaspan.h
index 80583daca2..f133a51c08 100644
--- a/src/mesa/drivers/dri/mga/mgaspan.h
+++ b/src/mesa/drivers/dri/mga/mgaspan.h
@@ -29,6 +29,12 @@
#ifndef _MGA_SPAN_H
#define _MGA_SPAN_H
+#include "drirenderbuffer.h"
+
extern void mgaDDInitSpanFuncs( GLcontext *ctx );
+extern void
+mgaSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+
#endif
diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c
index 69cc0f33a7..72d5c9fb08 100644
--- a/src/mesa/drivers/dri/mga/mgastate.c
+++ b/src/mesa/drivers/dri/mga/mgastate.c
@@ -825,15 +825,15 @@ static void mgaDDDrawBuffer(GLcontext *ctx, GLenum mode )
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset;
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
mmesa->draw_buffer = MGA_FRONT;
mgaXMesaSetFrontClipRects( mmesa );
FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
mmesa->setup.dstorg = mmesa->mgaScreen->backOffset;
mmesa->draw_buffer = MGA_BACK;
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c
index 2f417d9097..587cd0496b 100644
--- a/src/mesa/drivers/dri/r128/r128_context.c
+++ b/src/mesa/drivers/dri/r128/r128_context.c
@@ -337,13 +337,13 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags );
newR128Ctx->driDrawable = driDrawPriv;
- _mesa_make_current2( newR128Ctx->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_make_current( newR128Ctx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
} else {
- _mesa_make_current( 0, 0 );
+ _mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/r128/r128_dd.c b/src/mesa/drivers/dri/r128/r128_dd.c
index 22b68467ac..59480b25d8 100644
--- a/src/mesa/drivers/dri/r128/r128_dd.c
+++ b/src/mesa/drivers/dri/r128/r128_dd.c
@@ -40,6 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "swrast/swrast.h"
#include "context.h"
+#include "framebuffer.h"
#include "utils.h"
@@ -140,7 +141,7 @@ static void r128Finish( GLcontext *ctx )
void r128InitDriverFuncs( struct dd_function_table *functions )
{
functions->GetBufferSize = r128GetBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = r128GetString;
functions->Finish = r128Finish;
functions->Flush = r128Flush;
diff --git a/src/mesa/drivers/dri/r128/r128_ioctl.c b/src/mesa/drivers/dri/r128/r128_ioctl.c
index 2ae0f6fa6b..fc017329ca 100644
--- a/src/mesa/drivers/dri/r128/r128_ioctl.c
+++ b/src/mesa/drivers/dri/r128/r128_ioctl.c
@@ -429,25 +429,25 @@ static void r128Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
rmesa->new_state = save_state & ~R128_NEW_MASKS;
}
- if ( mask & DD_FRONT_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
flags |= R128_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if ( mask & DD_BACK_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
flags |= R128_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if ( ( mask & DD_DEPTH_BIT ) && ctx->Depth.Mask ) {
+ if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
flags |= R128_DEPTH;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
#if 0
/* FIXME: Add stencil support */
- if ( mask & DD_STENCIL_BIT ) {
+ if ( mask & BUFFER_BIT_STENCIL ) {
flags |= DRM_R128_DEPTH_BUFFER;
- mask &= ~DD_STENCIL_BIT;
+ mask &= ~BUFFER_BIT_STENCIL;
}
#endif
diff --git a/src/mesa/drivers/dri/r128/r128_lock.c b/src/mesa/drivers/dri/r128/r128_lock.c
index f4b43d56c1..ea4ccfb2ec 100644
--- a/src/mesa/drivers/dri/r128/r128_lock.c
+++ b/src/mesa/drivers/dri/r128/r128_lock.c
@@ -52,7 +52,7 @@ r128UpdatePageFlipping( r128ContextPtr rmesa )
rmesa->doPageFlip = rmesa->sarea->pfAllowPageFlip;
- use_back = (rmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT);
+ use_back = (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT);
use_back ^= (rmesa->sarea->pfCurrentPage == 1);
if ( R128_DEBUG & DEBUG_VERBOSE_API )
diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c
index 6bef391e96..bd0585b773 100644
--- a/src/mesa/drivers/dri/r128/r128_screen.c
+++ b/src/mesa/drivers/dri/r128/r128_screen.c
@@ -37,10 +37,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_context.h"
#include "r128_ioctl.h"
+#include "r128_span.h"
#include "r128_tris.h"
#include "context.h"
#include "imports.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "utils.h"
#include "vblank.h"
@@ -260,16 +263,62 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ r128ScreenPtr screen = (r128ScreenPtr) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer( mesaVis,
GL_FALSE, /* software depth buffer? */
mesaVis->stencilBits > 0,
mesaVis->accumRedBits > 0,
mesaVis->alphaBits > 0 );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ r128SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ r128SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r128SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r128SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
diff --git a/src/mesa/drivers/dri/r128/r128_span.c b/src/mesa/drivers/dri/r128/r128_span.c
index 457e371edc..b59706118e 100644
--- a/src/mesa/drivers/dri/r128/r128_span.c
+++ b/src/mesa/drivers/dri/r128/r128_span.c
@@ -335,7 +335,7 @@ static void r128DDSetBuffer( GLcontext *ctx,
r128ContextPtr rmesa = R128_CONTEXT(ctx);
switch ( bufferBit ) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
if ( rmesa->sarea->pfCurrentPage == 1 ) {
rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->backPitch;
@@ -344,7 +344,7 @@ static void r128DDSetBuffer( GLcontext *ctx,
rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->frontPitch;
}
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
if ( rmesa->sarea->pfCurrentPage == 1 ) {
rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset;
rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->frontPitch;
@@ -368,11 +368,15 @@ void r128DDInitSpanFuncs( GLcontext *ctx )
switch ( rmesa->r128Screen->cpp ) {
case 2:
+#if 0
r128InitPointers_RGB565( swdd );
+#endif
break;
case 4:
+#if 0
r128InitPointers_ARGB8888( swdd );
+#endif
break;
default:
@@ -381,17 +385,21 @@ void r128DDInitSpanFuncs( GLcontext *ctx )
switch ( rmesa->glCtx->Visual.depthBits ) {
case 16:
+#if 0
swdd->ReadDepthSpan = r128ReadDepthSpan_16;
swdd->WriteDepthSpan = r128WriteDepthSpan_16;
swdd->ReadDepthPixels = r128ReadDepthPixels_16;
swdd->WriteDepthPixels = r128WriteDepthPixels_16;
+#endif
break;
case 24:
+#if 0
swdd->ReadDepthSpan = r128ReadDepthSpan_24_8;
swdd->WriteDepthSpan = r128WriteDepthSpan_24_8;
swdd->ReadDepthPixels = r128ReadDepthPixels_24_8;
swdd->WriteDepthPixels = r128WriteDepthPixels_24_8;
+#endif
break;
default:
@@ -406,3 +414,44 @@ void r128DDInitSpanFuncs( GLcontext *ctx )
swdd->ReadCI32Span = NULL;
swdd->ReadCI32Pixels = NULL;
}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+r128SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ r128InitPointers_RGB565(&drb->Base);
+ }
+ else {
+ r128InitPointers_ARGB8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = r128ReadDepthSpan_16;
+ drb->Base.GetValues = r128ReadDepthPixels_16;
+ drb->Base.PutRow = r128WriteDepthSpan_16;
+ drb->Base.PutMonoRow = r128WriteMonoDepthSpan_16;
+ drb->Base.PutValues = r128WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = r128ReadDepthSpan_24_8;
+ drb->Base.GetValues = r128ReadDepthPixels_24_8;
+ drb->Base.PutRow = r128WriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = r128WriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = r128WriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/r128/r128_span.h b/src/mesa/drivers/dri/r128/r128_span.h
index 03de567b32..fd7c2d1394 100644
--- a/src/mesa/drivers/dri/r128/r128_span.h
+++ b/src/mesa/drivers/dri/r128/r128_span.h
@@ -36,6 +36,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __R128_SPAN_H__
#define __R128_SPAN_H__
+#include "drirenderbuffer.h"
+
extern void r128DDInitSpanFuncs( GLcontext *ctx );
+extern void
+r128SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c
index 320865c67b..29f490da89 100644
--- a/src/mesa/drivers/dri/r128/r128_state.c
+++ b/src/mesa/drivers/dri/r128/r128_state.c
@@ -714,13 +714,13 @@ static void r128DDDrawBuffer( GLcontext *ctx, GLenum mode )
FLUSH_BATCH( rmesa );
/*
- * _DrawDestMask is easier to cope with than <mode>.
+ * _ColorDrawBufferMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
default:
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index de373ecc86..2b6827ef43 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -40,6 +40,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "imports.h"
#include "matrix.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "state.h"
#include "swrast/swrast.h"
@@ -192,7 +193,7 @@ static const struct tnl_pipeline_stage *r200_pipeline[] = {
static void r200InitDriverFuncs( struct dd_function_table *functions )
{
functions->GetBufferSize = r200GetBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = r200GetString;
functions->Error = NULL;
@@ -455,7 +456,9 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
/* plug in a few more device driver functions */
/* XXX these should really go right after _mesa_init_driver_functions() */
r200InitPixelFuncs( ctx );
+#if 0
r200InitSpanFuncs( ctx );
+#endif
r200InitTnlFuncs( ctx );
r200InitState( rmesa );
r200InitSwtcl( ctx );
@@ -533,7 +536,7 @@ void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
/* check if we're deleting the currently bound context */
if (rmesa == current) {
R200_FIREVERTICES( rmesa );
- _mesa_make_current2(NULL, NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
/* Free r200 context resources */
@@ -642,9 +645,9 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
r200UpdateViewportOffset( newCtx->glCtx );
}
- _mesa_make_current2( newCtx->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_make_current( newCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
if (newCtx->vb.enabled)
r200VtxfmtMakeCurrent( newCtx->glCtx );
@@ -655,7 +658,7 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
} else {
if (R200_DEBUG & DEBUG_DRI)
fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
- _mesa_make_current( NULL, NULL );
+ _mesa_make_current( NULL, NULL, NULL );
}
if (R200_DEBUG & DEBUG_DRI)
diff --git a/src/mesa/drivers/dri/r200/r200_ioctl.c b/src/mesa/drivers/dri/r200/r200_ioctl.c
index ff2acdb7b1..ad43158d64 100644
--- a/src/mesa/drivers/dri/r200/r200_ioctl.c
+++ b/src/mesa/drivers/dri/r200/r200_ioctl.c
@@ -600,26 +600,26 @@ static void r200Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
r200Flush( ctx );
- if ( mask & DD_FRONT_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
flags |= RADEON_FRONT;
color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if ( mask & DD_BACK_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
flags |= RADEON_BACK;
color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if ( mask & DD_DEPTH_BIT ) {
+ if ( mask & BUFFER_BIT_DEPTH ) {
flags |= RADEON_DEPTH;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
- if ( (mask & DD_STENCIL_BIT) && rmesa->state.stencil.hwBuffer ) {
+ if ( (mask & BUFFER_BIT_STENCIL) && rmesa->state.stencil.hwBuffer ) {
flags |= RADEON_STENCIL;
- mask &= ~DD_STENCIL_BIT;
+ mask &= ~BUFFER_BIT_STENCIL;
}
if ( mask ) {
diff --git a/src/mesa/drivers/dri/r200/r200_lock.c b/src/mesa/drivers/dri/r200/r200_lock.c
index 72b57ae5dc..9b82c18d1f 100644
--- a/src/mesa/drivers/dri/r200/r200_lock.c
+++ b/src/mesa/drivers/dri/r200/r200_lock.c
@@ -53,7 +53,7 @@ r200UpdatePageFlipping( r200ContextPtr rmesa )
int use_back;
rmesa->doPageFlip = rmesa->sarea->pfState;
- use_back = (rmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT);
+ use_back = (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT);
use_back ^= (rmesa->sarea->pfCurrentPage == 1);
if (use_back) {
@@ -101,7 +101,7 @@ void r200GetLock( r200ContextPtr rmesa, GLuint flags )
if ( rmesa->lastStamp != dPriv->lastStamp ) {
r200UpdatePageFlipping( rmesa );
- if (rmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT)
+ if (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
r200SetCliprects( rmesa, GL_BACK_LEFT );
else
r200SetCliprects( rmesa, GL_FRONT_LEFT );
diff --git a/src/mesa/drivers/dri/r200/r200_screen.c b/src/mesa/drivers/dri/r200/r200_screen.c
index a8302a44b0..d6024121b5 100644
--- a/src/mesa/drivers/dri/r200/r200_screen.c
+++ b/src/mesa/drivers/dri/r200/r200_screen.c
@@ -40,14 +40,18 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "glheader.h"
#include "imports.h"
#include "context.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#define STANDALONE_MMIO
#include "r200_screen.h"
#include "r200_context.h"
#include "r200_ioctl.h"
+#include "r200_span.h"
#include "radeon_macros.h"
#include "radeon_reg.h"
+#include "drirenderbuffer.h"
#include "utils.h"
#include "vblank.h"
#include "GL/internal/dri_interface.h"
@@ -525,10 +529,9 @@ r200InitDriver( __DRIscreenPrivate *sPriv )
}
-
/**
* Create and initialize the Mesa and driver specific pixmap buffer
- * data.
+ * data. This is called to setup rendering to a particular window.
*
* \todo This function (and its interface) will need to be updated to support
* pbuffers.
@@ -539,6 +542,8 @@ r200CreateBuffer( __DRIscreenPrivate *driScrnPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ r200ScreenPtr screen = (r200ScreenPtr) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
@@ -548,12 +553,64 @@ r200CreateBuffer( __DRIscreenPrivate *driScrnPriv,
const GLboolean swAccum = mesaVis->accumRedBits > 0;
const GLboolean swStencil = mesaVis->stencilBits > 0 &&
mesaVis->depthBits != 24;
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer( mesaVis,
swDepth,
swStencil,
swAccum,
swAlpha );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ r200SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ r200SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r200SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r200SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r200SetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha,
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
diff --git a/src/mesa/drivers/dri/r200/r200_span.c b/src/mesa/drivers/dri/r200/r200_span.c
index f2868cb2d2..09a9a440a8 100644
--- a/src/mesa/drivers/dri/r200/r200_span.c
+++ b/src/mesa/drivers/dri/r200/r200_span.c
@@ -47,7 +47,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define DBG 0
#define LOCAL_VARS \
- r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
r200ScreenPtr r200Screen = rmesa->r200Screen; \
__DRIscreenPrivate *sPriv = rmesa->dri.screen; \
__DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
@@ -55,7 +55,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
GLuint height = dPriv->h; \
char *buf = (char *)(sPriv->pFB + \
rmesa->state.color.drawOffset + \
- (dPriv->x * r200Screen->cpp) + \
+ (dPriv->x * r200Screen->cpp) + \
(dPriv->y * pitch)); \
char *read_buf = (char *)(sPriv->pFB + \
rmesa->state.pixel.readOffset + \
@@ -65,14 +65,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(void) read_buf; (void) buf; (void) p
#define LOCAL_DEPTH_VARS \
- r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
r200ScreenPtr r200Screen = rmesa->r200Screen; \
__DRIscreenPrivate *sPriv = rmesa->dri.screen; \
__DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
GLuint height = dPriv->h; \
GLuint xo = dPriv->x; \
GLuint yo = dPriv->y; \
- char *buf = (char *)(sPriv->pFB + r200Screen->depthOffset); \
+ char *buf = (char *)(sPriv->pFB + r200Screen->depthOffset); \
(void) buf
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
@@ -212,6 +212,7 @@ static GLuint r200_mba_z16( r200ContextPtr rmesa, GLint x, GLint y )
/* 16-bit depth buffer functions
*/
+
#define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + r200_mba_z16( rmesa, _x + xo, _y + yo )) = d;
@@ -221,8 +222,10 @@ static GLuint r200_mba_z16( r200ContextPtr rmesa, GLint x, GLint y )
#define TAG(x) r200##x##_16
#include "depthtmp.h"
+
/* 24 bit depth, 8 bit stencil depthbuffer functions
*/
+
#define WRITE_DEPTH( _x, _y, d ) \
do { \
GLuint offset = r200_mba_z32( rmesa, _x + xo, _y + yo ); \
@@ -279,7 +282,7 @@ static void r200SetBuffer( GLcontext *ctx,
r200ContextPtr rmesa = R200_CONTEXT(ctx);
switch ( bufferBit ) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
if ( rmesa->doPageFlip && rmesa->sarea->pfCurrentPage == 1 ) {
rmesa->state.pixel.readOffset = rmesa->r200Screen->backOffset;
rmesa->state.pixel.readPitch = rmesa->r200Screen->backPitch;
@@ -292,7 +295,7 @@ static void r200SetBuffer( GLcontext *ctx,
rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
}
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
if ( rmesa->doPageFlip && rmesa->sarea->pfCurrentPage == 1 ) {
rmesa->state.pixel.readOffset = rmesa->r200Screen->frontOffset;
rmesa->state.pixel.readPitch = rmesa->r200Screen->frontPitch;
@@ -358,11 +361,15 @@ void r200InitSpanFuncs( GLcontext *ctx )
switch ( rmesa->r200Screen->cpp ) {
case 2:
+#if 0
r200InitPointers_RGB565( swdd );
+#endif
break;
case 4:
+#if 0
r200InitPointers_ARGB8888( swdd );
+#endif
break;
default:
@@ -371,22 +378,25 @@ void r200InitSpanFuncs( GLcontext *ctx )
switch ( rmesa->glCtx->Visual.depthBits ) {
case 16:
+#if 0
swdd->ReadDepthSpan = r200ReadDepthSpan_16;
swdd->WriteDepthSpan = r200WriteDepthSpan_16;
swdd->ReadDepthPixels = r200ReadDepthPixels_16;
swdd->WriteDepthPixels = r200WriteDepthPixels_16;
+#endif
break;
case 24:
+#if 0
swdd->ReadDepthSpan = r200ReadDepthSpan_24_8;
swdd->WriteDepthSpan = r200WriteDepthSpan_24_8;
swdd->ReadDepthPixels = r200ReadDepthPixels_24_8;
swdd->WriteDepthPixels = r200WriteDepthPixels_24_8;
-
swdd->ReadStencilSpan = r200ReadStencilSpan_24_8;
swdd->WriteStencilSpan = r200WriteStencilSpan_24_8;
swdd->ReadStencilPixels = r200ReadStencilPixels_24_8;
swdd->WriteStencilPixels = r200WriteStencilPixels_24_8;
+#endif
break;
default:
@@ -396,3 +406,45 @@ void r200InitSpanFuncs( GLcontext *ctx )
swdd->SpanRenderStart = r200SpanRenderStart;
swdd->SpanRenderFinish = r200SpanRenderFinish;
}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+r200SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ r200InitPointers_RGB565(&drb->Base);
+ }
+ else {
+ r200InitPointers_ARGB8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = r200ReadDepthSpan_16;
+ drb->Base.GetValues = r200ReadDepthPixels_16;
+ drb->Base.PutRow = r200WriteDepthSpan_16;
+ drb->Base.PutMonoRow = r200WriteMonoDepthSpan_16;
+ drb->Base.PutValues = r200WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = r200ReadDepthSpan_24_8;
+ drb->Base.GetValues = r200ReadDepthPixels_24_8;
+ drb->Base.PutRow = r200WriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = r200WriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = r200WriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = r200ReadStencilSpan_24_8;
+ drb->Base.GetValues = r200ReadStencilPixels_24_8;
+ drb->Base.PutRow = r200WriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = r200WriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = r200WriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/r200/r200_span.h b/src/mesa/drivers/dri/r200/r200_span.h
index 9ddf245b63..8b99095592 100644
--- a/src/mesa/drivers/dri/r200/r200_span.h
+++ b/src/mesa/drivers/dri/r200/r200_span.h
@@ -36,6 +36,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __R200_SPAN_H__
#define __R200_SPAN_H__
+#include "drirenderbuffer.h"
+
extern void r200InitSpanFuncs( GLcontext *ctx );
+extern void
+r200SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index b0b0c88900..93f6dfc6d7 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -1796,12 +1796,12 @@ static void r200DrawBuffer( GLcontext *ctx, GLenum mode )
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE );
r200SetCliprects( rmesa, GL_FRONT_LEFT );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE );
r200SetCliprects( rmesa, GL_BACK_LEFT );
break;
diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile
index b9f9186f59..af5f203f3c 100644
--- a/src/mesa/drivers/dri/radeon/Makefile
+++ b/src/mesa/drivers/dri/radeon/Makefile
@@ -16,6 +16,7 @@ COMMON_SOURCES = \
../common/vblank.c \
../common/xmlconfig.c \
../common/dri_util.c \
+ ../common/drirenderbuffer.c \
../common/glcontextmodes.c
DRIVER_SOURCES = \
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index 037ea0f003..60eecc741c 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -42,6 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "imports.h"
#include "matrix.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
@@ -182,7 +183,7 @@ static const struct tnl_pipeline_stage *radeon_pipeline[] = {
static void radeonInitDriverFuncs( struct dd_function_table *functions )
{
functions->GetBufferSize = radeonGetBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = radeonGetString;
}
@@ -491,7 +492,7 @@ void radeonDestroyContext( __DRIcontextPrivate *driContextPriv )
/* check if we're deleting the currently bound context */
if (rmesa == current) {
RADEON_FIREVERTICES( rmesa );
- _mesa_make_current2(NULL, NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
/* Free radeon context resources */
@@ -603,9 +604,9 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
radeonUpdateViewportOffset( newCtx->glCtx );
}
- _mesa_make_current2( newCtx->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_make_current( newCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
if (newCtx->vb.enabled)
radeonVtxfmtMakeCurrent( newCtx->glCtx );
@@ -613,7 +614,7 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
} else {
if (RADEON_DEBUG & DEBUG_DRI)
fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
- _mesa_make_current( NULL, NULL );
+ _mesa_make_current( NULL, NULL, NULL );
}
if (RADEON_DEBUG & DEBUG_DRI)
diff --git a/src/mesa/drivers/dri/radeon/radeon_ioctl.c b/src/mesa/drivers/dri/radeon/radeon_ioctl.c
index cf7e9a8b27..3e1fc4baff 100644
--- a/src/mesa/drivers/dri/radeon/radeon_ioctl.c
+++ b/src/mesa/drivers/dri/radeon/radeon_ioctl.c
@@ -1048,26 +1048,26 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
radeonFlush( ctx );
- if ( mask & DD_FRONT_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
flags |= RADEON_FRONT;
color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if ( mask & DD_BACK_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
flags |= RADEON_BACK;
color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if ( mask & DD_DEPTH_BIT ) {
+ if ( mask & BUFFER_BIT_DEPTH ) {
flags |= RADEON_DEPTH;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
- if ( (mask & DD_STENCIL_BIT) && rmesa->state.stencil.hwBuffer ) {
+ if ( (mask & BUFFER_BIT_STENCIL) && rmesa->state.stencil.hwBuffer ) {
flags |= RADEON_STENCIL;
- mask &= ~DD_STENCIL_BIT;
+ mask &= ~BUFFER_BIT_STENCIL;
}
if ( mask ) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_lock.c b/src/mesa/drivers/dri/radeon/radeon_lock.c
index 7dab02e6b5..bb121fc587 100644
--- a/src/mesa/drivers/dri/radeon/radeon_lock.c
+++ b/src/mesa/drivers/dri/radeon/radeon_lock.c
@@ -56,7 +56,7 @@ radeonUpdatePageFlipping( radeonContextPtr rmesa )
rmesa->doPageFlip = rmesa->sarea->pfState;
- use_back = (rmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT);
+ use_back = (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT);
use_back ^= (rmesa->sarea->pfCurrentPage == 1);
if ( RADEON_DEBUG & DEBUG_VERBOSE )
@@ -108,7 +108,7 @@ void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
if ( rmesa->lastStamp != dPriv->lastStamp ) {
radeonUpdatePageFlipping( rmesa );
- if (rmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT)
+ if (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
radeonSetCliprects( rmesa, GL_BACK_LEFT );
else
radeonSetCliprects( rmesa, GL_FRONT_LEFT );
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index cfba884638..edc9244366 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -38,15 +38,20 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "glheader.h"
#include "imports.h"
+#include "mtypes.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#define STANDALONE_MMIO
#include "radeon_context.h"
#include "radeon_screen.h"
#include "radeon_macros.h"
+#include "radeon_span.h"
#include "utils.h"
#include "context.h"
#include "vblank.h"
+#include "drirenderbuffer.h"
#include "GL/internal/dri_interface.h"
@@ -451,10 +456,8 @@ radeonInitDriver( __DRIscreenPrivate *sPriv )
}
-
/**
- * Create and initialize the Mesa and driver specific pixmap buffer
- * data.
+ * Create the Mesa framebuffer and renderbuffers for a given window/drawable.
*
* \todo This function (and its interface) will need to be updated to support
* pbuffers.
@@ -465,6 +468,8 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ radeonScreenPtr screen = (radeonScreenPtr) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
@@ -474,12 +479,64 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
const GLboolean swAccum = mesaVis->accumRedBits > 0;
const GLboolean swStencil = mesaVis->stencilBits > 0 &&
mesaVis->depthBits != 24;
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer( mesaVis,
swDepth,
swStencil,
swAccum,
swAlpha );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ radeonSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ radeonSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ radeonSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ radeonSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ radeonSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha,
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h
index b7ad8c0769..b9cbeaac33 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.h
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.h
@@ -100,7 +100,4 @@ typedef struct {
driOptionCache optionCache;
} radeonScreenRec, *radeonScreenPtr;
-extern radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv );
-extern void radeonDestroyScreen( __DRIscreenPrivate *sPriv );
-
#endif /* __RADEON_SCREEN_H__ */
diff --git a/src/mesa/drivers/dri/radeon/radeon_span.c b/src/mesa/drivers/dri/radeon/radeon_span.c
index 38ba5a50e5..9315543c15 100644
--- a/src/mesa/drivers/dri/radeon/radeon_span.c
+++ b/src/mesa/drivers/dri/radeon/radeon_span.c
@@ -313,7 +313,7 @@ static void radeonSetBuffer( GLcontext *ctx,
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
switch ( bufferBit ) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
if ( rmesa->sarea->pfCurrentPage == 1 ) {
rmesa->state.pixel.readOffset = rmesa->radeonScreen->backOffset;
rmesa->state.pixel.readPitch = rmesa->radeonScreen->backPitch;
@@ -326,7 +326,7 @@ static void radeonSetBuffer( GLcontext *ctx,
rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
}
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
if ( rmesa->sarea->pfCurrentPage == 1 ) {
rmesa->state.pixel.readOffset = rmesa->radeonScreen->frontOffset;
rmesa->state.pixel.readPitch = rmesa->radeonScreen->frontPitch;
@@ -375,6 +375,7 @@ void radeonInitSpanFuncs( GLcontext *ctx )
switch ( rmesa->radeonScreen->cpp ) {
case 2:
+#if 0
swdd->WriteRGBASpan = radeonWriteRGBASpan_RGB565;
swdd->WriteRGBSpan = radeonWriteRGBSpan_RGB565;
swdd->WriteMonoRGBASpan = radeonWriteMonoRGBASpan_RGB565;
@@ -382,9 +383,11 @@ void radeonInitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoRGBAPixels = radeonWriteMonoRGBAPixels_RGB565;
swdd->ReadRGBASpan = radeonReadRGBASpan_RGB565;
swdd->ReadRGBAPixels = radeonReadRGBAPixels_RGB565;
+#endif
break;
case 4:
+#if 0
swdd->WriteRGBASpan = radeonWriteRGBASpan_ARGB8888;
swdd->WriteRGBSpan = radeonWriteRGBSpan_ARGB8888;
swdd->WriteMonoRGBASpan = radeonWriteMonoRGBASpan_ARGB8888;
@@ -392,6 +395,7 @@ void radeonInitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoRGBAPixels = radeonWriteMonoRGBAPixels_ARGB8888;
swdd->ReadRGBASpan = radeonReadRGBASpan_ARGB8888;
swdd->ReadRGBAPixels = radeonReadRGBAPixels_ARGB8888;
+#endif
break;
default:
@@ -400,13 +404,16 @@ void radeonInitSpanFuncs( GLcontext *ctx )
switch ( rmesa->glCtx->Visual.depthBits ) {
case 16:
+#if 0
swdd->ReadDepthSpan = radeonReadDepthSpan_16;
swdd->WriteDepthSpan = radeonWriteDepthSpan_16;
swdd->ReadDepthPixels = radeonReadDepthPixels_16;
swdd->WriteDepthPixels = radeonWriteDepthPixels_16;
+#endif
break;
case 24:
+#if 0
swdd->ReadDepthSpan = radeonReadDepthSpan_24_8;
swdd->WriteDepthSpan = radeonWriteDepthSpan_24_8;
swdd->ReadDepthPixels = radeonReadDepthPixels_24_8;
@@ -416,6 +423,7 @@ void radeonInitSpanFuncs( GLcontext *ctx )
swdd->WriteStencilSpan = radeonWriteStencilSpan_24_8;
swdd->ReadStencilPixels = radeonReadStencilPixels_24_8;
swdd->WriteStencilPixels = radeonWriteStencilPixels_24_8;
+#endif
break;
default:
@@ -425,3 +433,56 @@ void radeonInitSpanFuncs( GLcontext *ctx )
swdd->SpanRenderStart = radeonSpanRenderStart;
swdd->SpanRenderFinish = radeonSpanRenderFinish;
}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+radeonSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = radeonReadRGBASpan_RGB565;
+ drb->Base.GetValues = radeonReadRGBAPixels_RGB565;
+ drb->Base.PutRow = radeonWriteRGBASpan_RGB565;
+ drb->Base.PutRowRGB = radeonWriteRGBSpan_RGB565;
+ drb->Base.PutMonoRow = radeonWriteMonoRGBASpan_RGB565;
+ drb->Base.PutValues = radeonWriteRGBAPixels_RGB565;
+ drb->Base.PutMonoValues = radeonWriteMonoRGBAPixels_RGB565;
+ }
+ else {
+ drb->Base.GetRow = radeonReadRGBASpan_ARGB8888;
+ drb->Base.GetValues = radeonReadRGBAPixels_ARGB8888;
+ drb->Base.PutRow = radeonWriteRGBASpan_ARGB8888;
+ drb->Base.PutRowRGB = radeonWriteRGBSpan_ARGB8888;
+ drb->Base.PutMonoRow = radeonWriteMonoRGBASpan_ARGB8888;
+ drb->Base.PutValues = radeonWriteRGBAPixels_ARGB8888;
+ drb->Base.PutMonoValues = radeonWriteMonoRGBAPixels_ARGB8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = radeonReadDepthSpan_16;
+ drb->Base.GetValues = radeonReadDepthPixels_16;
+ drb->Base.PutRow = radeonWriteDepthSpan_16;
+ drb->Base.PutMonoRow = radeonWriteMonoDepthSpan_16;
+ drb->Base.PutValues = radeonWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = radeonReadDepthSpan_24_8;
+ drb->Base.GetValues = radeonReadDepthPixels_24_8;
+ drb->Base.PutRow = radeonWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = radeonWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = radeonWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = radeonReadStencilSpan_24_8;
+ drb->Base.GetValues = radeonReadStencilPixels_24_8;
+ drb->Base.PutRow = radeonWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = radeonWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = radeonWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/radeon/radeon_span.h b/src/mesa/drivers/dri/radeon/radeon_span.h
index 097af4b1bf..13b308e1c4 100644
--- a/src/mesa/drivers/dri/radeon/radeon_span.h
+++ b/src/mesa/drivers/dri/radeon/radeon_span.h
@@ -37,6 +37,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __RADEON_SPAN_H__
#define __RADEON_SPAN_H__
+#include "drirenderbuffer.h"
+
extern void radeonInitSpanFuncs( GLcontext *ctx );
+extern void radeonSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index 532458ebf4..3a491f5ded 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1661,12 +1661,12 @@ static void radeonDrawBuffer( GLcontext *ctx, GLenum mode )
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE );
radeonSetCliprects( rmesa, GL_FRONT_LEFT );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE );
radeonSetCliprects( rmesa, GL_BACK_LEFT );
break;
diff --git a/src/mesa/drivers/dri/s3v/s3v_context.h b/src/mesa/drivers/dri/s3v/s3v_context.h
index 1c0bca3fb8..b94fee6a8e 100644
--- a/src/mesa/drivers/dri/s3v/s3v_context.h
+++ b/src/mesa/drivers/dri/s3v/s3v_context.h
@@ -16,6 +16,7 @@
#include "mtypes.h"
#include "drm.h"
#include "mm.h"
+#include "drirenderbuffer.h"
/* Flags for context */
#define S3V_FRONT_BUFFER 0x00000001
@@ -162,6 +163,7 @@ void s3vGetLock( s3vContextPtr vmesa, GLuint flags );
void s3vInitExtensions( GLcontext *ctx );
void s3vInitDriverFuncs( GLcontext *ctx );
void s3vInitSpanFuncs( GLcontext *ctx );
+void s3vSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
void s3vInitState( s3vContextPtr vmesa );
void s3vInitHW( s3vContextPtr vmesa );
void s3vInitStateFuncs( GLcontext *ctx );
diff --git a/src/mesa/drivers/dri/s3v/s3v_dd.c b/src/mesa/drivers/dri/s3v/s3v_dd.c
index 3346c86a0c..2c8e230f3e 100644
--- a/src/mesa/drivers/dri/s3v/s3v_dd.c
+++ b/src/mesa/drivers/dri/s3v/s3v_dd.c
@@ -10,6 +10,7 @@
#endif
#include "context.h"
+#include "framebuffer.h"
#include "swrast/swrast.h"
#define S3V_DATE "20020207"
@@ -96,7 +97,7 @@ void s3vInitDriverFuncs( GLcontext *ctx )
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
/* Swrast hooks for imaging extensions:
*/
diff --git a/src/mesa/drivers/dri/s3v/s3v_screen.h b/src/mesa/drivers/dri/s3v/s3v_screen.h
index bbbffbb8e1..0c4f69efac 100644
--- a/src/mesa/drivers/dri/s3v/s3v_screen.h
+++ b/src/mesa/drivers/dri/s3v/s3v_screen.h
@@ -2,6 +2,8 @@
* Author: Max Lingua <sunmax@libero.it>
*/
+#include "mtypes.h"
+
typedef struct _s3vRegion {
drm_handle_t handle;
drmSize size;
@@ -34,3 +36,4 @@ typedef struct {
int textureSize;
int logTextureGranularity;
} s3vScreenRec, *s3vScreenPtr;
+
diff --git a/src/mesa/drivers/dri/s3v/s3v_span.c b/src/mesa/drivers/dri/s3v/s3v_span.c
index 6266d37105..e4a48ebfc8 100644
--- a/src/mesa/drivers/dri/s3v/s3v_span.c
+++ b/src/mesa/drivers/dri/s3v/s3v_span.c
@@ -232,10 +232,10 @@ static void s3vSetBuffer( GLcontext *ctx, GLframebuffer *colorBuffer,
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
switch ( bufferBit ) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
vmesa->drawOffset = vmesa->readOffset = 0;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
vmesa->drawOffset = vmesa->readOffset = vmesa->driScreen->fbHeight *
vmesa->driScreen->fbWidth *
vmesa->s3vScreen->cpp;
@@ -251,6 +251,7 @@ void s3vInitSpanFuncs( GLcontext *ctx )
swdd->SetBuffer = s3vSetBuffer;
+#if 0
switch ( vmesa->s3vScreen->cpp ) {
case 2:
swdd->WriteRGBASpan = s3vWriteRGBASpan_RGB555;
@@ -279,14 +280,17 @@ void s3vInitSpanFuncs( GLcontext *ctx )
default:
break;
}
+#endif
switch ( vmesa->glCtx->Visual.depthBits ) {
case 15:
case 16:
+#if 0
swdd->ReadDepthSpan = s3vReadDepthSpan_16;
swdd->WriteDepthSpan = s3vWriteDepthSpan_16;
swdd->ReadDepthPixels = s3vReadDepthPixels_16;
swdd->WriteDepthPixels = s3vWriteDepthPixels_16;
+#endif
break;
#if 0
@@ -307,3 +311,56 @@ void s3vInitSpanFuncs( GLcontext *ctx )
break;
}
}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+s3vSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = s3vReadRGBASpan_RGB555;
+ drb->Base.GetValues = s3vReadRGBAPixels_RGB555;
+ drb->Base.PutRow = s3vWriteRGBASpan_RGB555;
+ drb->Base.PutRowRGB = s3vWriteRGBSpan_RGB555;
+ drb->Base.PutMonoRow = s3vWriteMonoRGBASpan_RGB555;
+ drb->Base.PutValues = s3vWriteRGBAPixels_RGB555;
+ drb->Base.PutMonoValues = s3vWriteMonoRGBAPixels_RGB555;
+ }
+ else {
+ drb->Base.GetRow = s3vReadRGBASpan_ARGB8888;
+ drb->Base.GetValues = s3vReadRGBAPixels_ARGB8888;
+ drb->Base.PutRow = s3vWriteRGBASpan_ARGB8888;
+ drb->Base.PutRowRGB = s3vWriteRGBSpan_ARGB8888;
+ drb->Base.PutMonoRow = s3vWriteMonoRGBASpan_ARGB8888;
+ drb->Base.PutValues = s3vWriteRGBAPixels_ARGB8888;
+ drb->Base.PutMonoValues = s3vWriteMonoRGBAPixels_ARGB8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = s3vReadDepthSpan_16;
+ drb->Base.GetValues = s3vReadDepthPixels_16;
+ drb->Base.PutRow = s3vWriteDepthSpan_16;
+ drb->Base.PutMonoRow = s3vWriteMonoDepthSpan_16;
+ drb->Base.PutValues = s3vWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/s3v/s3v_state.c b/src/mesa/drivers/dri/s3v/s3v_state.c
index f92859d4ed..84aaf4c5b1 100644
--- a/src/mesa/drivers/dri/s3v/s3v_state.c
+++ b/src/mesa/drivers/dri/s3v/s3v_state.c
@@ -117,8 +117,8 @@ static void s3vDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
DMAOUT(vmesa->DestXY);
DMAFINISH();
- if (mask & DD_DEPTH_BIT) { /* depth */
- DEBUG(("DD_DEPTH_BIT\n"));
+ if (mask & BUFFER_BIT_DEPTH) { /* depth */
+ DEBUG(("BUFFER_BIT_DEPTH\n"));
_stride = ((cw+31)&~31) * 2;
@@ -142,7 +142,7 @@ static void s3vDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
DMAFINISH();
DEBUG(("vmesa->ClearDepth = 0x%x\n", vmesa->ClearDepth));
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
if (!vmesa->NotClipped) {
diff --git a/src/mesa/drivers/dri/s3v/s3v_xmesa.c b/src/mesa/drivers/dri/s3v/s3v_xmesa.c
index 84072b1471..61d4cbccbd 100644
--- a/src/mesa/drivers/dri/s3v/s3v_xmesa.c
+++ b/src/mesa/drivers/dri/s3v/s3v_xmesa.c
@@ -7,6 +7,8 @@
#include "context.h"
#include "matrix.h"
#include "s3v_dri.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
@@ -57,10 +59,13 @@ s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ s3vScreenPtr screen = (s3vScreenPtr) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer(mesaVis,
GL_FALSE, /* software depth buffer? */
@@ -68,6 +73,58 @@ s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
mesaVis->accumRedBits > 0,
mesaVis->alphaBits > 0
);
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ s3vSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ s3vSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ s3vSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ s3vSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ /* no h/w stencil yet?
+ if (mesaVis->stencilBits > 0) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
+ s3vSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+ */
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
@@ -205,7 +262,7 @@ s3vMakeCurrent(__DRIcontextPrivate *driContextPriv,
*/
/*
- _mesa_make_current2( newVirgeCtx->glCtx,
+ _mesa_make_current( newVirgeCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
@@ -221,13 +278,11 @@ s3vMakeCurrent(__DRIcontextPrivate *driContextPriv,
WRITE(newVirgeCtx->buf, S3VWindow, newVirgeCtx->Window);
#endif
-
-
newVirgeCtx->new_state |= S3V_NEW_WINDOW; /* FIXME */
- _mesa_make_current2( newVirgeCtx->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_make_current( newVirgeCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
if (!newVirgeCtx->glCtx->Viewport.Width) {
_mesa_set_viewport(newVirgeCtx->glCtx, 0, 0,
@@ -245,23 +300,23 @@ s3vMakeCurrent(__DRIcontextPrivate *driContextPriv,
newVirgeCtx->new_state |= S3V_NEW_CLIP;
- if (1) {
- cx = dPriv->x;
- cw = dPriv->w;
- cy = dPriv->y;
- ch = dPriv->h;
- }
-
- x1 = y1 = 0;
- x2 = cw-1;
- y2 = ch-1;
-
-/* src_stride = vmesa->s3vScreen->w * vmesa->s3vScreen->cpp;
- dest_stride = ((x2+31)&~31) * vmesa->s3vScreen->cpp; */
- src_stride = vmesa->driScreen->fbWidth * 2;
- dest_stride = ((x2+31)&~31) * 2;
+ if (1) {
+ cx = dPriv->x;
+ cw = dPriv->w;
+ cy = dPriv->y;
+ ch = dPriv->h;
+ }
+
+ x1 = y1 = 0;
+ x2 = cw-1;
+ y2 = ch-1;
+
+ /* src_stride = vmesa->s3vScreen->w * vmesa->s3vScreen->cpp;
+ dest_stride = ((x2+31)&~31) * vmesa->s3vScreen->cpp; */
+ src_stride = vmesa->driScreen->fbWidth * 2;
+ dest_stride = ((x2+31)&~31) * 2;
} else {
- _mesa_make_current( 0, 0 );
+ _mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/savage/savage_init.h b/src/mesa/drivers/dri/savage/savage_init.h
index 9cf8e66b7c..0dec397b7b 100644
--- a/src/mesa/drivers/dri/savage/savage_init.h
+++ b/src/mesa/drivers/dri/savage/savage_init.h
@@ -80,6 +80,16 @@ typedef struct {
} savageScreenPrivate;
+/**
+ * savageRenderbuffer, derived from Mesa's gl_renderbuffer
+ */
+typedef struct {
+ struct gl_renderbuffer Base;
+ /* XXX per-window info should go here */
+ int foo, bar;
+} savageRenderbuffer;
+
+
#include "savagecontext.h"
extern void savageGetLock( savageContextPtr imesa, GLuint flags );
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index 485bc77458..aeb314681e 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -29,7 +29,8 @@
#include "savagecontext.h"
#include "context.h"
#include "matrix.h"
-
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "simple_list.h"
#include "utils.h"
@@ -588,25 +589,85 @@ savageDestroyContext(__DRIcontextPrivate *driContextPriv)
}
}
+
static GLboolean
savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap)
{
+ savageScreenPrivate *screen = (savageScreenPrivate *) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24;
- driDrawPriv->driverPrivate = (void *)
+#if 0
+ driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer(mesaVis,
GL_FALSE, /* software depth buffer? */
swStencil,
mesaVis->accumRedBits > 0,
mesaVis->alphaBits > 0 );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+ /*
+ * XXX: this value needs to be set according to the config file
+ * setting. But we don't get that until we create a rendering
+ * context!!!!
+ */
+ GLboolean float_depth = GL_FALSE;
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->aperturePitch);
+ savageSetSpanFunctions(frontRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->aperturePitch);
+ savageSetSpanFunctions(backRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
- return (driDrawPriv->driverPrivate != NULL);
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->aperturePitch);
+ savageSetSpanFunctions(depthRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->aperturePitch);
+ savageSetSpanFunctions(depthRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->aperturePitch);
+ savageSetSpanFunctions(stencilRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
}
}
@@ -670,11 +731,11 @@ static void savageXMesaWindowMoved( savageContextPtr imesa )
if (0)
fprintf(stderr, "savageXMesaWindowMoved\n\n");
- switch (imesa->glCtx->Color._DrawDestMask[0]) {
- case DD_FRONT_LEFT_BIT:
+ switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
savageXMesaSetFrontClipRects( imesa );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
savageXMesaSetBackClipRects( imesa );
break;
default:
@@ -742,15 +803,15 @@ savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
imesa->mesa_drawable = driDrawPriv;
imesa->dirty = ~0;
- _mesa_make_current2(imesa->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate);
+ _mesa_make_current(imesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
savageXMesaWindowMoved( imesa );
}
else
{
- _mesa_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/savage/savagedd.c b/src/mesa/drivers/dri/savage/savagedd.c
index 639b335be7..72d7d33ce3 100644
--- a/src/mesa/drivers/dri/savage/savagedd.c
+++ b/src/mesa/drivers/dri/savage/savagedd.c
@@ -24,6 +24,7 @@
#include "mtypes.h"
+#include "framebuffer.h"
#include <stdio.h>
@@ -113,6 +114,6 @@ static void savageBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *heigh
void savageDDInitDriverFuncs( GLcontext *ctx )
{
ctx->Driver.GetBufferSize = savageBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
ctx->Driver.GetString = savageDDGetString;
}
diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c
index e68f58cccf..30d008e1be 100644
--- a/src/mesa/drivers/dri/savage/savageioctl.c
+++ b/src/mesa/drivers/dri/savage/savageioctl.c
@@ -367,28 +367,28 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
flags = 0;
- if (mask & DD_FRONT_LEFT_BIT) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
flags |= SAVAGE_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if (mask & DD_BACK_LEFT_BIT) {
+ if (mask & BUFFER_BIT_BACK_LEFT) {
flags |= SAVAGE_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) {
+ if ((mask & BUFFER_BIT_DEPTH) && ctx->Depth.Mask) {
flags |= SAVAGE_DEPTH;
depthMask |=
(imesa->savageScreen->zpp == 2) ? 0xffffffff : 0x00ffffff;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
- if((mask & DD_STENCIL_BIT) && imesa->hw_stencil)
+ if((mask & BUFFER_BIT_STENCIL) && imesa->hw_stencil)
{
flags |= SAVAGE_DEPTH;
depthMask |= 0xff000000;
- mask &= ~DD_STENCIL_BIT;
+ mask &= ~BUFFER_BIT_STENCIL;
}
savageFlushVertices(imesa);
diff --git a/src/mesa/drivers/dri/savage/savagespan.c b/src/mesa/drivers/dri/savage/savagespan.c
index 4fad537ba6..acdfde097b 100644
--- a/src/mesa/drivers/dri/savage/savagespan.c
+++ b/src/mesa/drivers/dri/savage/savagespan.c
@@ -230,9 +230,9 @@ static void savageDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
char *map;
- assert((bufferBit == DD_FRONT_LEFT_BIT) || (bufferBit == DD_BACK_LEFT_BIT));
+ assert((bufferBit == BUFFER_BIT_FRONT_LEFT) || (bufferBit == BUFFER_BIT_BACK_LEFT));
- map = (bufferBit == DD_FRONT_LEFT_BIT)
+ map = (bufferBit == BUFFER_BIT_FRONT_LEFT)
? imesa->apertureBase[TARGET_FRONT]
: imesa->apertureBase[TARGET_BACK];
@@ -306,15 +306,18 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
swdd->SetBuffer = savageDDSetBuffer;
+#if 0
switch (imesa->savageScreen->cpp)
{
case 2: savageInitPointers_565( swdd ); break;
case 4: savageInitPointers_8888( swdd );
}
+#endif
switch (imesa->savageScreen->zpp)
{
case 2:
+#if 0
if (imesa->float_depth) {
swdd->ReadDepthSpan = savageReadDepthSpan_16f;
swdd->WriteDepthSpan = savageWriteDepthSpan_16f;
@@ -328,9 +331,10 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
swdd->ReadDepthPixels = savageReadDepthPixels_16;
swdd->WriteDepthPixels = savageWriteDepthPixels_16;
}
-
+#endif
break;
- case 4:
+ case 4:
+#if 0
if (imesa->float_depth) {
swdd->ReadDepthSpan = savageReadDepthSpan_8_24f;
swdd->WriteDepthSpan = savageWriteDepthSpan_8_24f;
@@ -348,6 +352,7 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
swdd->WriteStencilSpan = savageWriteStencilSpan_8_24;
swdd->ReadStencilPixels = savageReadStencilPixels_8_24;
swdd->WriteStencilPixels = savageWriteStencilPixels_8_24;
+#endif
break;
}
@@ -369,3 +374,64 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
ctx->Driver.DrawPixels = savageDrawPixels;
ctx->Driver.ReadPixels = savageReadPixels;
}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
+ GLboolean float_depth)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ savageInitPointers_565(&drb->Base);
+ }
+ else {
+ savageInitPointers_8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ if (float_depth) {
+ drb->Base.GetRow = savageReadDepthSpan_16f;
+ drb->Base.GetValues = savageReadDepthPixels_16f;
+ drb->Base.PutRow = savageWriteDepthSpan_16f;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_16f;
+ drb->Base.PutValues = savageWriteDepthPixels_16f;
+ }
+ else {
+ drb->Base.GetRow = savageReadDepthSpan_16;
+ drb->Base.GetValues = savageReadDepthPixels_16;
+ drb->Base.PutRow = savageWriteDepthSpan_16;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_16;
+ drb->Base.PutValues = savageWriteDepthPixels_16;
+ }
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ if (float_depth) {
+ drb->Base.GetRow = savageReadDepthSpan_8_24f;
+ drb->Base.GetValues = savageReadDepthPixels_8_24f;
+ drb->Base.PutRow = savageWriteDepthSpan_8_24f;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_8_24f;
+ drb->Base.PutValues = savageWriteDepthPixels_8_24f;
+ }
+ else {
+ drb->Base.GetRow = savageReadDepthSpan_8_24;
+ drb->Base.GetValues = savageReadDepthPixels_8_24;
+ drb->Base.PutRow = savageWriteDepthSpan_8_24;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_8_24;
+ drb->Base.PutValues = savageWriteDepthPixels_8_24;
+ }
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = savageReadStencilSpan_8_24;
+ drb->Base.GetValues = savageReadStencilPixels_8_24;
+ drb->Base.PutRow = savageWriteStencilSpan_8_24;
+ drb->Base.PutMonoRow = savageWriteMonoStencilSpan_8_24;
+ drb->Base.PutValues = savageWriteStencilPixels_8_24;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/savage/savagespan.h b/src/mesa/drivers/dri/savage/savagespan.h
index cb3a1b52fd..f6a312e820 100644
--- a/src/mesa/drivers/dri/savage/savagespan.h
+++ b/src/mesa/drivers/dri/savage/savagespan.h
@@ -25,8 +25,16 @@
#ifndef _SAVAGE_SPAN_H
#define _SAVAGE_SPAN_H
+#include "drirenderbuffer.h"
+
+
extern void savageDDInitSpanFuncs( GLcontext *ctx );
+extern void
+savageSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis,
+ GLboolean float_depth);
+
+
/*
* Savage 16-bit float depth format with zExpOffset=16:
* 4 bit unsigned exponent, 12 bit mantissa
@@ -125,4 +133,5 @@ static __inline GLdouble savageDecodeFloat24( GLuint x )
}
#undef _1
+
#endif
diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c
index 7b58c817a2..567b979733 100644
--- a/src/mesa/drivers/dri/savage/savagestate.c
+++ b/src/mesa/drivers/dri/savage/savagestate.c
@@ -644,8 +644,8 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
imesa->IsDouble = GL_FALSE;
imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->frontOffset>>11;
@@ -653,7 +653,7 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
savageXMesaSetFrontClipRects( imesa );
FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
imesa->IsDouble = GL_TRUE;
imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
imesa->NotFirstFrame = GL_FALSE;
diff --git a/src/mesa/drivers/dri/sis/sis_clear.c b/src/mesa/drivers/dri/sis/sis_clear.c
index 7ed7103293..ef4b561ca5 100644
--- a/src/mesa/drivers/dri/sis/sis_clear.c
+++ b/src/mesa/drivers/dri/sis/sis_clear.c
@@ -119,9 +119,9 @@ sisDDClear( GLcontext * ctx, GLbitfield mask, GLboolean all,
/* Mask out any non-existent buffers */
if (ctx->Visual.depthBits == 0 || !ctx->Depth.Mask)
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
if (ctx->Visual.stencilBits == 0)
- mask &= ~DD_STENCIL_BIT;
+ mask &= ~BUFFER_BIT_STENCIL;
LOCK_HARDWARE();
@@ -132,21 +132,21 @@ sisDDClear( GLcontext * ctx, GLbitfield mask, GLboolean all,
/* XXX: Appears to be broken with stencil. */
if ((smesa->current.hwCapEnable2 & (MASK_AlphaMaskWriteEnable |
MASK_ColorMaskWriteEnable) &&
- (mask & (DD_BACK_LEFT_BIT | DD_FRONT_LEFT_BIT)) != 0) ||
- (ctx->Stencil.WriteMask[0] < 0xff && (mask & DD_STENCIL_BIT) != 0) )
+ (mask & (BUFFER_BIT_BACK_LEFT | BUFFER_BIT_FRONT_LEFT)) != 0) ||
+ (ctx->Stencil.WriteMask[0] < 0xff && (mask & BUFFER_BIT_STENCIL) != 0) )
{
mask = sis_3D_Clear( ctx, mask, x1, y1, width1, height1 );
}
- if ( mask & DD_FRONT_LEFT_BIT || mask & DD_BACK_LEFT_BIT) {
+ if ( mask & BUFFER_BIT_FRONT_LEFT || mask & BUFFER_BIT_BACK_LEFT) {
sis_clear_color_buffer( ctx, mask, x1, y1, width1, height1 );
- mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
+ mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
}
- if (mask & (DD_DEPTH_BIT | DD_STENCIL_BIT)) {
+ if (mask & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) {
if (smesa->depthbuffer != NULL)
sis_clear_z_stencil_buffer( ctx, mask, x1, y1, width1, height1 );
- mask &= ~(DD_DEPTH_BIT | DD_STENCIL_BIT);
+ mask &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
}
UNLOCK_HARDWARE();
@@ -204,9 +204,9 @@ sis_3D_Clear( GLcontext * ctx, GLbitfield mask,
int count;
drm_clip_rect_t *pExtents;
- bClrColor = (mask & (DD_BACK_LEFT_BIT | DD_FRONT_LEFT_BIT)) != 0;
- bClrDepth = (mask & DD_DEPTH_BIT) != 0;
- bClrStencil = (mask & DD_STENCIL_BIT) != 0;
+ bClrColor = (mask & (BUFFER_BIT_BACK_LEFT | BUFFER_BIT_FRONT_LEFT)) != 0;
+ bClrDepth = (mask & BUFFER_BIT_DEPTH) != 0;
+ bClrStencil = (mask & BUFFER_BIT_STENCIL) != 0;
if (smesa->GlobalFlag & GFLAG_RENDER_STATES)
sis_update_render_state( smesa );
@@ -252,7 +252,7 @@ sis_3D_Clear( GLcontext * ctx, GLbitfield mask,
dirtyflags |= GFLAG_STENCILSETTING;
}
- if (mask & DD_FRONT_LEFT_BIT) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
pExtents = smesa->driDrawable->pClipRects;
count = smesa->driDrawable->numClipRects;
} else {
@@ -321,14 +321,14 @@ sis_3D_Clear( GLcontext * ctx, GLbitfield mask,
mEndPrimitive();
- /* If DD_FRONT_LEFT_BIT is set, we've only cleared the front buffer so far */
- if ((mask & DD_FRONT_LEFT_BIT) != 0 && (mask & DD_BACK_LEFT_BIT) != 0)
- sis_3D_Clear( ctx, DD_BACK_LEFT_BIT, x, y, width, height );
+ /* If BUFFER_BIT_FRONT_LEFT is set, we've only cleared the front buffer so far */
+ if ((mask & BUFFER_BIT_FRONT_LEFT) != 0 && (mask & BUFFER_BIT_BACK_LEFT) != 0)
+ sis_3D_Clear( ctx, BUFFER_BIT_BACK_LEFT, x, y, width, height );
smesa->GlobalFlag |= dirtyflags;
- return mask & ~(DD_DEPTH_BIT | DD_STENCIL_BIT | DD_BACK_LEFT_BIT |
- DD_FRONT_LEFT_BIT);
+ return mask & ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL | BUFFER_BIT_BACK_LEFT |
+ BUFFER_BIT_FRONT_LEFT);
}
static void
@@ -368,7 +368,7 @@ sis_clear_color_buffer( GLcontext *ctx, GLenum mask, GLint x, GLint y,
ENGPACKET stEngPacket;
/* Clear back buffer */
- if (mask & DD_BACK_LEFT_BIT) {
+ if (mask & BUFFER_BIT_BACK_LEFT) {
smesa->cbClearPacket.stdwDestPos.wY = y;
smesa->cbClearPacket.stdwDestPos.wX = x;
smesa->cbClearPacket.stdwDim.wWidth = (GLshort) width;
@@ -378,7 +378,7 @@ sis_clear_color_buffer( GLcontext *ctx, GLenum mask, GLint x, GLint y,
sis_bitblt_clear_cmd( smesa, &smesa->cbClearPacket );
}
- if ((mask & DD_FRONT_LEFT_BIT) == 0)
+ if ((mask & BUFFER_BIT_FRONT_LEFT) == 0)
return;
/* Clear front buffer */
diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c
index 3b23b7df4e..ac7fb56dbe 100644
--- a/src/mesa/drivers/dri/sis/sis_context.c
+++ b/src/mesa/drivers/dri/sis/sis_context.c
@@ -306,14 +306,14 @@ sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
newSisCtx->driDrawable = driDrawPriv;
- _mesa_make_current2( newSisCtx->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_make_current( newSisCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
sisUpdateBufferSize( newSisCtx );
sisUpdateClipping( newSisCtx->glCtx );
} else {
- _mesa_make_current( 0, 0 );
+ _mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/sis/sis_dd.c b/src/mesa/drivers/dri/sis/sis_dd.c
index 4049a106b6..4e64c17b3d 100644
--- a/src/mesa/drivers/dri/sis/sis_dd.c
+++ b/src/mesa/drivers/dri/sis/sis_dd.c
@@ -41,6 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "sis_tris.h"
#include "swrast/swrast.h"
+#include "framebuffer.h"
#include "utils.h"
@@ -172,9 +173,9 @@ sisUpdateBufferSize( sisContextPtr smesa )
void
sisInitDriverFuncs( struct dd_function_table *functions )
{
- functions->GetBufferSize = sisGetBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
- functions->GetString = sisGetString;
- functions->Finish = sisFinish;
- functions->Flush = sisFlush;
+ functions->GetBufferSize = sisGetBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetString = sisGetString;
+ functions->Finish = sisFinish;
+ functions->Flush = sisFlush;
}
diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c
index 8ef6765dc3..ccfa959c9a 100644
--- a/src/mesa/drivers/dri/sis/sis_screen.c
+++ b/src/mesa/drivers/dri/sis/sis_screen.c
@@ -34,10 +34,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "context.h"
#include "utils.h"
#include "imports.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "sis_context.h"
#include "sis_dri.h"
#include "sis_lock.h"
+#include "sis_span.h"
#include "xmlpool.h"
@@ -196,6 +199,7 @@ sisDestroyScreen( __DRIscreenPrivate *sPriv )
sPriv->private = NULL;
}
+
/* Create and initialize the Mesa and driver specific pixmap buffer
* data.
*/
@@ -205,15 +209,79 @@ sisCreateBuffer( __DRIscreenPrivate *driScrnPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ sisScreenPtr screen = (sisScreenPtr) driScrnPriv->private;
+
if (isPixmap)
return GL_FALSE; /* not implemented */
+#if 0
driDrawPriv->driverPrivate = (void *)_mesa_create_framebuffer(
mesaVis,
GL_FALSE, /* software depth buffer? */
mesaVis->stencilBits > 0,
mesaVis->accumRedBits > 0,
mesaVis->alphaBits > 0 ); /* XXX */
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ /* XXX double-check the Offset/Pitch parameters! */
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 32) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ /* no h/w stencil?
+ if (mesaVis->stencilBits > 0) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
+ sisSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+ */
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+
return (driDrawPriv->driverPrivate != NULL);
}
diff --git a/src/mesa/drivers/dri/sis/sis_span.c b/src/mesa/drivers/dri/sis/sis_span.c
index 8f4b3af62e..abf3d652c0 100644
--- a/src/mesa/drivers/dri/sis/sis_span.c
+++ b/src/mesa/drivers/dri/sis/sis_span.c
@@ -205,11 +205,11 @@ static void sisDDSetBuffer( GLcontext *ctx,
sisContextPtr smesa = SIS_CONTEXT(ctx);
switch ( bufferBit ) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
smesa->drawOffset = smesa->readOffset = smesa->frontOffset;
smesa->drawPitch = smesa->readPitch = smesa->frontPitch;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
smesa->drawOffset = smesa->readOffset = smesa->backOffset;
smesa->drawPitch = smesa->readPitch = smesa->backPitch;
break;
@@ -246,6 +246,7 @@ sisDDInitSpanFuncs( GLcontext *ctx )
switch (smesa->zFormat)
{
case SiS_ZFORMAT_Z16:
+#if 0
swdd->ReadDepthSpan = sisReadDepthSpan_16;
swdd->ReadDepthPixels = sisReadDepthPixels_16;
swdd->WriteDepthSpan = sisWriteDepthSpan_16;
@@ -255,8 +256,10 @@ sisDDInitSpanFuncs( GLcontext *ctx )
swdd->ReadStencilPixels = NULL;
swdd->WriteStencilSpan = NULL;
swdd->WriteStencilPixels = NULL;
+#endif
break;
case SiS_ZFORMAT_Z32:
+#if 0
swdd->ReadDepthSpan = sisReadDepthSpan_32;
swdd->ReadDepthPixels = sisReadDepthPixels_32;
swdd->WriteDepthSpan = sisWriteDepthSpan_32;
@@ -266,8 +269,10 @@ sisDDInitSpanFuncs( GLcontext *ctx )
swdd->ReadStencilPixels = NULL;
swdd->WriteStencilSpan = NULL;
swdd->WriteStencilPixels = NULL;
+#endif
break;
case SiS_ZFORMAT_S8Z24:
+#if 0
swdd->ReadDepthSpan = sisReadDepthSpan_24_8;
swdd->ReadDepthPixels = sisReadDepthPixels_24_8;
swdd->WriteDepthSpan = sisWriteDepthSpan_24_8;
@@ -277,9 +282,11 @@ sisDDInitSpanFuncs( GLcontext *ctx )
swdd->ReadStencilPixels = sisReadStencilPixels_24_8;
swdd->WriteStencilSpan = sisWriteStencilSpan_24_8;
swdd->WriteStencilPixels = sisWriteStencilPixels_24_8;
+#endif
break;
}
+#if 0
switch ( smesa->bytesPerPixel )
{
case 2:
@@ -312,7 +319,70 @@ sisDDInitSpanFuncs( GLcontext *ctx )
swdd->WriteMonoCIPixels = NULL;
swdd->ReadCI32Span = NULL;
swdd->ReadCI32Pixels = NULL;
+#endif
swdd->SpanRenderStart = sisSpanRenderStart;
swdd->SpanRenderFinish = sisSpanRenderFinish;
}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+sisSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = sisReadRGBASpan_565;
+ drb->Base.GetValues = sisReadRGBAPixels_565;
+ drb->Base.PutRow = sisWriteRGBASpan_565;
+ drb->Base.PutRowRGB = sisWriteRGBSpan_565;
+ drb->Base.PutMonoRow = sisWriteMonoRGBASpan_565;
+ drb->Base.PutValues = sisWriteRGBAPixels_565;
+ drb->Base.PutMonoValues = sisWriteMonoRGBAPixels_565;
+ }
+ else {
+ drb->Base.GetRow = sisReadRGBASpan_8888;
+ drb->Base.GetValues = sisReadRGBAPixels_8888;
+ drb->Base.PutRow = sisWriteRGBASpan_8888;
+ drb->Base.PutRowRGB = sisWriteRGBSpan_8888;
+ drb->Base.PutMonoRow = sisWriteMonoRGBASpan_8888;
+ drb->Base.PutValues = sisWriteRGBAPixels_8888;
+ drb->Base.PutMonoValues = sisWriteMonoRGBAPixels_8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = sisReadDepthSpan_16;
+ drb->Base.GetValues = sisReadDepthPixels_16;
+ drb->Base.PutRow = sisWriteDepthSpan_16;
+ drb->Base.PutMonoRow = sisWriteMonoDepthSpan_16;
+ drb->Base.PutValues = sisWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = sisReadDepthSpan_24_8;
+ drb->Base.GetValues = sisReadDepthPixels_24_8;
+ drb->Base.PutRow = sisWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = sisWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = sisWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ drb->Base.GetRow = sisReadDepthSpan_32;
+ drb->Base.GetValues = sisReadDepthPixels_32;
+ drb->Base.PutRow = sisWriteDepthSpan_32;
+ drb->Base.PutMonoRow = sisWriteMonoDepthSpan_32;
+ drb->Base.PutValues = sisWriteDepthPixels_32;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = sisReadStencilSpan_24_8;
+ drb->Base.GetValues = sisReadStencilPixels_24_8;
+ drb->Base.PutRow = sisWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = sisWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = sisWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/sis/sis_span.h b/src/mesa/drivers/dri/sis/sis_span.h
index c9760e4d26..7c73bc6d3a 100644
--- a/src/mesa/drivers/dri/sis/sis_span.h
+++ b/src/mesa/drivers/dri/sis/sis_span.h
@@ -32,9 +32,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __SIS_SPAN_H__
#define __SIS_SPAN_H__
+#include "drirenderbuffer.h"
+
+
extern void sisSpanRenderStart( GLcontext *ctx );
extern void sisSpanRenderFinish( GLcontext *ctx );
extern void sisDDInitSpanFuncs( GLcontext *ctx );
+extern void
+sisSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c
index b269d694b0..db58e9090b 100644
--- a/src/mesa/drivers/dri/sis/sis_state.c
+++ b/src/mesa/drivers/dri/sis/sis_state.c
@@ -529,9 +529,9 @@ void sisDDDrawBuffer( GLcontext *ctx, GLenum mode )
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
- case DD_BACK_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ case BUFFER_BIT_BACK_LEFT:
FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
default:
diff --git a/src/mesa/drivers/dri/sis/sis_tris.c b/src/mesa/drivers/dri/sis/sis_tris.c
index 45a92e5e92..3af70cf653 100644
--- a/src/mesa/drivers/dri/sis/sis_tris.c
+++ b/src/mesa/drivers/dri/sis/sis_tris.c
@@ -805,7 +805,7 @@ static void sisRenderStart( GLcontext *ctx )
GLuint AGPParseSet = smesa->AGPParseSet;
GLboolean tex_fallback = GL_FALSE;
- if (ctx->Color._DrawDestMask[0] == DD_FRONT_LEFT_BIT &&
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT &&
smesa->driDrawable->numClipRects != 0)
{
multipass_cliprect(ctx, 0);
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c
index 2a9e23a1a6..654ada5980 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_context.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_context.c
@@ -634,9 +634,9 @@ tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
/* Need to call _mesa_make_current2() in order to make sure API
* dispatch is set correctly.
*/
- _mesa_make_current2( newCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_make_current( newCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
return GL_TRUE;
}
/* [dBorca] tunnel2 requires this */
@@ -667,11 +667,11 @@ tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
UNLOCK_HARDWARE( newFx );
}
- _mesa_make_current2( newCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_make_current( newCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
} else {
- _mesa_make_current( 0, 0 );
+ _mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_dd.c b/src/mesa/drivers/dri/tdfx/tdfx_dd.c
index 34e4babcf5..02fbace5be 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_dd.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_dd.c
@@ -43,6 +43,7 @@
#include "context.h"
#include "enums.h"
+#include "framebuffer.h"
#include "swrast/swrast.h"
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
@@ -257,7 +258,7 @@ void tdfxDDInitDriverFuncs( const __GLcontextModes *visual,
functions->GetString = tdfxDDGetString;
functions->GetBufferSize = tdfxDDGetBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
/* Accelerated paths
*/
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c b/src/mesa/drivers/dri/tdfx/tdfx_pixels.c
index 7ec6302cf1..6592ecccfb 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_pixels.c
@@ -175,7 +175,7 @@ tdfx_bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py,
SCISSOR_BIT |
STENCIL_BIT |
MASKING_BIT |
- ALPHABUF_BIT | MULTI_DRAW_BIT)) return GL_FALSE;
+ MULTI_DRAW_BIT)) return GL_FALSE;
if (ctx->Scissor.Enabled) {
/* This is a bit tricky, but by carefully adjusting the px, py,
@@ -339,7 +339,7 @@ tdfx_bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py,
SCISSOR_BIT |
STENCIL_BIT |
MASKING_BIT |
- ALPHABUF_BIT | MULTI_DRAW_BIT)) return GL_FALSE;
+ MULTI_DRAW_BIT)) return GL_FALSE;
if (ctx->Scissor.Enabled) {
/* This is a bit tricky, but by carefully adjusting the px, py,
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_render.c b/src/mesa/drivers/dri/tdfx/tdfx_render.c
index 3ce91b9257..56f5f147ee 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_render.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_render.c
@@ -51,7 +51,7 @@ static void tdfxClear( GLcontext *ctx,
GLint x, GLint y, GLint width, GLint height )
{
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
- GLbitfield softwareMask = mask & (DD_ACCUM_BIT);
+ GLbitfield softwareMask = mask & (BUFFER_BIT_ACCUM);
const GLuint stencil_size =
fxMesa->haveHwStencil ? fxMesa->glCtx->Visual.stencilBits : 0;
@@ -67,14 +67,14 @@ static void tdfxClear( GLcontext *ctx,
}
/* we can't clear accum buffers */
- mask &= ~(DD_ACCUM_BIT);
+ mask &= ~(BUFFER_BIT_ACCUM);
- if (mask & DD_STENCIL_BIT) {
+ if (mask & BUFFER_BIT_STENCIL) {
if (!fxMesa->haveHwStencil || ctx->Stencil.WriteMask[0] != 0xff) {
/* Napalm seems to have trouble with stencil write masks != 0xff */
/* do stencil clear in software */
- mask &= ~(DD_STENCIL_BIT);
- softwareMask |= DD_STENCIL_BIT;
+ mask &= ~(BUFFER_BIT_STENCIL);
+ softwareMask |= BUFFER_BIT_STENCIL;
}
}
@@ -82,8 +82,8 @@ static void tdfxClear( GLcontext *ctx,
/* can only do color masking if running in 24/32bpp on Napalm */
if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] ||
ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) {
- softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
- mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
+ softwareMask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT));
+ mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
}
}
@@ -94,7 +94,7 @@ static void tdfxClear( GLcontext *ctx,
* in the OGL state.
*/
LOCK_HARDWARE(fxMesa);
- if (mask & DD_STENCIL_BIT) {
+ if (mask & BUFFER_BIT_STENCIL) {
fxMesa->Glide.grStencilMask(/*ctx->Stencil.WriteMask*/ 0xff);
/* set stencil ref value = desired clear value */
fxMesa->Glide.grStencilFunc(GR_CMP_ALWAYS,
@@ -119,8 +119,8 @@ static void tdfxClear( GLcontext *ctx,
* This could probably be done fancier but doing each possible case
* explicitly is less error prone.
*/
- switch (mask & ~DD_STENCIL_BIT) {
- case DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
+ switch (mask & ~BUFFER_BIT_STENCIL) {
+ case BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH:
/* back buffer & depth */
FX_grColorMaskv_NoLock(ctx, true4); /* work around Voodoo3 bug */
fxMesa->Glide.grDepthMask(FXTRUE);
@@ -139,7 +139,7 @@ static void tdfxClear( GLcontext *ctx,
fxMesa->Glide.grDepthMask(FXFALSE);
}
break;
- case DD_FRONT_LEFT_BIT | DD_DEPTH_BIT:
+ case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_DEPTH:
/* XXX it appears that the depth buffer isn't cleared when
* glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set.
* This is a work-around/
@@ -173,7 +173,7 @@ static void tdfxClear( GLcontext *ctx,
fxMesa->Glide.grDepthMask(FXFALSE);
}
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
/* back buffer only */
fxMesa->Glide.grDepthMask(FXFALSE);
fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
@@ -190,7 +190,7 @@ static void tdfxClear( GLcontext *ctx,
fxMesa->Glide.grDepthMask(FXTRUE);
}
break;
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
/* front buffer only */
fxMesa->Glide.grDepthMask(FXFALSE);
fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
@@ -207,7 +207,7 @@ static void tdfxClear( GLcontext *ctx,
fxMesa->Glide.grDepthMask(FXTRUE);
}
break;
- case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT:
/* front and back */
fxMesa->Glide.grDepthMask(FXFALSE);
fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
@@ -234,7 +234,7 @@ static void tdfxClear( GLcontext *ctx,
fxMesa->Glide.grDepthMask(FXTRUE);
}
break;
- case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
+ case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH:
/* clear front */
fxMesa->Glide.grDepthMask(FXFALSE);
fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
@@ -263,7 +263,7 @@ static void tdfxClear( GLcontext *ctx,
fxMesa->Glide.grDepthMask(FXFALSE);
}
break;
- case DD_DEPTH_BIT:
+ case BUFFER_BIT_DEPTH:
/* just the depth buffer */
fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
FX_grColorMaskv_NoLock(ctx, false4);
@@ -278,14 +278,14 @@ static void tdfxClear( GLcontext *ctx,
fxMesa->Color.ClearAlpha,
fxMesa->Depth.Clear);
FX_grColorMaskv_NoLock(ctx, true4);
- if (ctx->Color._DrawDestMask[0] & DD_FRONT_LEFT_BIT)
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT)
fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
if (!ctx->Depth.Test || !ctx->Depth.Mask)
fxMesa->Glide.grDepthMask(FXFALSE);
break;
default:
/* clear no color buffers or depth buffer but might clear stencil */
- if (stencil_size > 0 && (mask & DD_STENCIL_BIT)) {
+ if (stencil_size > 0 && (mask & BUFFER_BIT_STENCIL)) {
/* XXX need this RenderBuffer call to work around Glide bug */
fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
fxMesa->Glide.grDepthMask(FXFALSE);
@@ -298,14 +298,14 @@ static void tdfxClear( GLcontext *ctx,
fxMesa->Glide.grDepthMask(FXTRUE);
}
FX_grColorMaskv_NoLock(ctx, true4);
- if (ctx->Color._DrawDestMask[0] & DD_FRONT_LEFT_BIT)
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT)
fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
}
}
}
END_CLIP_LOOP(fxMesa);
- if (fxMesa->haveHwStencil && (mask & DD_STENCIL_BIT)) {
+ if (fxMesa->haveHwStencil && (mask & BUFFER_BIT_STENCIL)) {
/* We changed the stencil state above. Signal that we need to
* upload it again.
*/
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c
index 7896811d99..500d5d3f3d 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c
@@ -38,9 +38,11 @@
#include "tdfx_context.h"
#include "tdfx_lock.h"
#include "tdfx_vb.h"
+#include "tdfx_span.h"
#include "tdfx_tris.h"
#include "utils.h"
-
+#include "framebuffer.h"
+#include "renderbuffer.h"
#ifdef DEBUG_LOCKING
char *prevLockFile = 0;
@@ -137,16 +139,70 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ tdfxScreenPrivate *screen = (tdfxScreenPrivate *) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer( mesaVis,
GL_FALSE, /* software depth buffer? */
mesaVis->stencilBits > 0,
mesaVis->accumRedBits > 0,
GL_FALSE /* software alpha channel? */ );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->fbOffset, screen->width);
+ tdfxSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA8, screen->cpp,
+ screen->backOffset, screen->width);
+ tdfxSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->width);
+ tdfxSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->width);
+ tdfxSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->width);
+ tdfxSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ GL_FALSE, /*swStencil,*/
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_span.c b/src/mesa/drivers/dri/tdfx/tdfx_span.c
index 1bcec63413..1fab811b74 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_span.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_span.c
@@ -596,11 +596,13 @@ GetFbParams(tdfxContextPtr fxMesa,
PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value); \
} while (0)
+
static void
-tdfxDDWriteDepthSpan(GLcontext * ctx,
- GLuint n, GLint x, GLint y, const GLdepth depth[],
+tdfxDDWriteDepthSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, const void *values,
const GLubyte mask[])
{
+ const GLuint *depth = (const GLuint *) values;
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
GLint bottom = fxMesa->y_offset + fxMesa->height - 1;
GLuint depth_size = fxMesa->glCtx->Visual.depthBits;
@@ -833,9 +835,24 @@ tdfxDDWriteDepthSpan(GLcontext * ctx,
}
static void
-tdfxDDReadDepthSpan(GLcontext * ctx,
- GLuint n, GLint x, GLint y, GLdepth depth[])
+tdfxDDWriteMonoDepthSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, const void *value,
+ const GLubyte mask[])
{
+ GLuint depthVal = *((GLuint *) value);
+ GLuint depths[MAX_WIDTH];
+ GLuint i;
+ for (i = 0; i < n; i++)
+ depths[i] = depthVal;
+ tdfxDDWriteDepthSpan(ctx, rb, n, x, y, depths, mask);
+}
+
+
+static void
+tdfxDDReadDepthSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, void *values)
+{
+ GLuint *depth = (GLuint *) values;
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
@@ -936,10 +953,11 @@ tdfxDDReadDepthSpan(GLcontext * ctx,
static void
-tdfxDDWriteDepthPixels(GLcontext * ctx,
+tdfxDDWriteDepthPixels(GLcontext * ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
- const GLdepth depth[], const GLubyte mask[])
+ const void *values, const GLubyte mask[])
{
+ const GLuint *depth = (const GLuint *) values;
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
@@ -1018,9 +1036,10 @@ tdfxDDWriteDepthPixels(GLcontext * ctx,
static void
-tdfxDDReadDepthPixels(GLcontext * ctx, GLuint n,
- const GLint x[], const GLint y[], GLdepth depth[])
+tdfxDDReadDepthPixels(GLcontext * ctx, struct gl_renderbuffer *rb, GLuint n,
+ const GLint x[], const GLint y[], void *values)
{
+ GLuint *depth = (GLuint *) values;
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
@@ -1104,9 +1123,11 @@ tdfxDDReadDepthPixels(GLcontext * ctx, GLuint n,
#define BUILD_ZS(z, s) (((s) << 24) | (z))
static void
-write_stencil_span(GLcontext * ctx, GLuint n, GLint x, GLint y,
- const GLstencil stencil[], const GLubyte mask[])
+write_stencil_span(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[])
{
+ const GLubyte *stencil = (const GLubyte *) values;
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
GrLfbInfo_t info;
GrLfbInfo_t backBufferInfo;
@@ -1161,9 +1182,25 @@ write_stencil_span(GLcontext * ctx, GLuint n, GLint x, GLint y,
static void
-read_stencil_span(GLcontext * ctx, GLuint n, GLint x, GLint y,
- GLstencil stencil[])
+write_mono_stencil_span(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value, const GLubyte mask[])
{
+ GLbyte stencilVal = *((GLbyte *) value);
+ GLbyte stencils[MAX_WIDTH];
+ GLuint i;
+ for (i = 0; i < n; i++)
+ stencils[i] = stencilVal;
+ write_stencil_span(ctx, rb, n, x, y, stencils, mask);
+}
+
+
+static void
+read_stencil_span(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values)
+{
+ GLubyte *stencil = (GLubyte *) values;
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
GrLfbInfo_t info;
GrLfbInfo_t backBufferInfo;
@@ -1211,10 +1248,11 @@ read_stencil_span(GLcontext * ctx, GLuint n, GLint x, GLint y,
static void
-write_stencil_pixels(GLcontext * ctx, GLuint n,
- const GLint x[], const GLint y[],
- const GLstencil stencil[], const GLubyte mask[])
+write_stencil_pixels(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[])
{
+ const GLubyte *stencil = (const GLubyte *) values;
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
GrLfbInfo_t info;
GrLfbInfo_t backBufferInfo;
@@ -1249,9 +1287,11 @@ write_stencil_pixels(GLcontext * ctx, GLuint n,
static void
-read_stencil_pixels(GLcontext * ctx, GLuint n, const GLint x[],
- const GLint y[], GLstencil stencil[])
+read_stencil_pixels(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ void *values)
{
+ GLubyte *stencil = (GLubyte *) values;
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
GrLfbInfo_t info;
GrLfbInfo_t backBufferInfo;
@@ -1315,10 +1355,10 @@ static void tdfxDDSetBuffer( GLcontext *ctx,
(void) buffer;
switch ( bufferBit ) {
- case DD_FRONT_LEFT_BIT:
+ case BUFFER_BIT_FRONT_LEFT:
fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
break;
default:
@@ -1337,6 +1377,7 @@ void tdfxDDInitSpanFuncs( GLcontext *ctx )
swdd->SetBuffer = tdfxDDSetBuffer;
+#if 0
if ( VISUAL_EQUALS_RGBA(ctx->Visual, 5, 6, 5, 0) )
{
/* 16bpp mode */
@@ -1374,19 +1415,23 @@ void tdfxDDInitSpanFuncs( GLcontext *ctx )
{
abort();
}
+#endif
if ( fxMesa->haveHwStencil ) {
+#if 0
swdd->WriteStencilSpan = write_stencil_span;
swdd->ReadStencilSpan = read_stencil_span;
swdd->WriteStencilPixels = write_stencil_pixels;
swdd->ReadStencilPixels = read_stencil_pixels;
+#endif
}
+#if 0
swdd->WriteDepthSpan = tdfxDDWriteDepthSpan;
swdd->WriteDepthPixels = tdfxDDWriteDepthPixels;
swdd->ReadDepthSpan = tdfxDDReadDepthSpan;
swdd->ReadDepthPixels = tdfxDDReadDepthPixels;
-
+#endif
swdd->WriteCI8Span = NULL;
swdd->WriteCI32Span = NULL;
swdd->WriteMonoCISpan = NULL;
@@ -1398,3 +1443,64 @@ void tdfxDDInitSpanFuncs( GLcontext *ctx )
swdd->SpanRenderStart = tdfxSpanRenderStart;
swdd->SpanRenderFinish = tdfxSpanRenderFinish;
}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+tdfxSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = tdfxReadRGBASpan_RGB565;
+ drb->Base.GetValues = tdfxReadRGBAPixels_RGB565;
+ drb->Base.PutRow = tdfxWriteRGBASpan_RGB565;
+ drb->Base.PutRowRGB = tdfxWriteRGBSpan_RGB565;
+ drb->Base.PutMonoRow = tdfxWriteMonoRGBASpan_RGB565;
+ drb->Base.PutValues = tdfxWriteRGBAPixels_RGB565;
+ drb->Base.PutMonoValues = tdfxWriteMonoRGBAPixels_RGB565;
+ }
+ else if (vis->redBits == 8 && vis->greenBits == 8
+ && vis->blueBits == 8 && vis->alphaBits == 0) {
+ drb->Base.GetRow = tdfxReadRGBASpan_RGB888;
+ drb->Base.GetValues = tdfxReadRGBAPixels_RGB888;
+ drb->Base.PutRow = tdfxWriteRGBASpan_RGB888;
+ drb->Base.PutRowRGB = tdfxWriteRGBSpan_RGB888;
+ drb->Base.PutMonoRow = tdfxWriteMonoRGBASpan_RGB888;
+ drb->Base.PutValues = tdfxWriteRGBAPixels_RGB888;
+ drb->Base.PutMonoValues = tdfxWriteMonoRGBAPixels_RGB888;
+ }
+ else if (vis->redBits == 8 && vis->greenBits == 8
+ && vis->blueBits == 8 && vis->alphaBits == 8) {
+ drb->Base.GetRow = tdfxReadRGBASpan_ARGB8888;
+ drb->Base.GetValues = tdfxReadRGBAPixels_ARGB8888;
+ drb->Base.PutRow = tdfxWriteRGBASpan_ARGB8888;
+ drb->Base.PutRowRGB = tdfxWriteRGBSpan_ARGB8888;
+ drb->Base.PutMonoRow = tdfxWriteMonoRGBASpan_ARGB8888;
+ drb->Base.PutValues = tdfxWriteRGBAPixels_ARGB8888;
+ drb->Base.PutMonoValues = tdfxWriteMonoRGBAPixels_ARGB8888;
+ }
+ else {
+ _mesa_problem(NULL, "problem in tdfxSetSpanFunctions");
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16 ||
+ drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = tdfxDDReadDepthSpan;
+ drb->Base.GetValues = tdfxDDReadDepthPixels;
+ drb->Base.PutRow = tdfxDDWriteDepthSpan;
+ drb->Base.PutMonoRow = tdfxDDWriteMonoDepthSpan;
+ drb->Base.PutValues = tdfxDDWriteDepthPixels;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = read_stencil_span;
+ drb->Base.GetValues = read_stencil_pixels;
+ drb->Base.PutRow = write_stencil_span;
+ drb->Base.PutMonoRow = write_mono_stencil_span;
+ drb->Base.PutValues = write_stencil_pixels;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_span.h b/src/mesa/drivers/dri/tdfx/tdfx_span.h
index a95aad5dbf..62044144f0 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_span.h
+++ b/src/mesa/drivers/dri/tdfx/tdfx_span.h
@@ -39,7 +39,11 @@
#define __TDFX_SPAN_H__
#include "context.h"
+#include "drirenderbuffer.h"
extern void tdfxDDInitSpanFuncs( GLcontext *ctx );
+extern void
+tdfxSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.c b/src/mesa/drivers/dri/tdfx/tdfx_state.c
index cb3c1059bc..85d99bb05e 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_state.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_state.c
@@ -377,7 +377,7 @@ static void tdfxUpdateZMode( GLcontext *ctx )
mask = FXFALSE; /* zbuffer is not touched */
}
- fxMesa->Depth.Clear = (FxU32) (ctx->DepthMaxF * ctx->Depth.Clear);
+ fxMesa->Depth.Clear = (FxU32) (ctx->DrawBuffer->_DepthMaxF * ctx->Depth.Clear);
if ( fxMesa->Depth.Bias != bias ) {
fxMesa->Depth.Bias = bias;
@@ -1034,15 +1034,15 @@ static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode )
FLUSH_BATCH( fxMesa );
/*
- * _DrawDestMask is easier to cope with than <mode>.
+ * _ColorDrawBufferMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
fxMesa->new_state |= TDFX_NEW_RENDER;
FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
fxMesa->new_state |= TDFX_NEW_RENDER;
FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
diff --git a/src/mesa/drivers/dri/trident/trident_context.c b/src/mesa/drivers/dri/trident/trident_context.c
index cbf2d1df56..744f384c62 100644
--- a/src/mesa/drivers/dri/trident/trident_context.c
+++ b/src/mesa/drivers/dri/trident/trident_context.c
@@ -39,11 +39,14 @@
#include "simple_list.h"
#include "matrix.h"
#include "extensions.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
#endif
#include "simple_list.h"
#include "mm.h"
+#include "drirenderbuffer.h"
#include "drivers/common/driverfuncs.h"
#include "dri_util.h"
@@ -197,10 +200,13 @@ tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ tridentScreenPtr screen = (tridentScreenPtr) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer(mesaVis,
GL_FALSE, /* software depth buffer? */
@@ -208,6 +214,66 @@ tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
mesaVis->accumRedBits > 0,
mesaVis->alphaBits > 0
);
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ /*
+ tridentSetSpanFunctions(frontRb, mesaVis);
+ */
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ /*
+ tridentSetSpanFunctions(backRb, mesaVis);
+ */
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ /*
+ tridentSetSpanFunctions(depthRb, mesaVis);
+ */
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ /*
+ tridentSetSpanFunctions(depthRb, mesaVis);
+ */
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ /* no h/w stencil?
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
+ tridentSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+ */
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
@@ -265,16 +331,16 @@ tridentMakeCurrent(__DRIcontextPrivate *driContextPriv,
newCtx->drawOffset = newCtx->tridentScreen->backOffset;
newCtx->drawPitch = newCtx->tridentScreen->backPitch;
- _mesa_make_current2( newCtx->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_make_current( newCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
if (!newCtx->glCtx->Viewport.Width) {
_mesa_set_viewport(newCtx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
} else {
- _mesa_make_current( 0, 0 );
+ _mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/trident/trident_context.h b/src/mesa/drivers/dri/trident/trident_context.h
index 74a3acb2ce..7ebb5f2049 100644
--- a/src/mesa/drivers/dri/trident/trident_context.h
+++ b/src/mesa/drivers/dri/trident/trident_context.h
@@ -117,6 +117,16 @@ typedef struct {
tridentRegionRec mmio;
} tridentScreenRec, *tridentScreenPtr;
+/**
+ * tridentRenderbuffer, derived from Mesa's gl_renderbuffer
+ */
+typedef struct {
+ struct gl_renderbuffer Base;
+ /* XXX per-window info should go here */
+ int foo, bar;
+} tridentRenderbuffer;
+
+
struct trident_context {
GLcontext *glCtx; /* Mesa context */
diff --git a/src/mesa/drivers/dri/trident/trident_dd.c b/src/mesa/drivers/dri/trident/trident_dd.c
index 390e6d8e41..8c3af20016 100644
--- a/src/mesa/drivers/dri/trident/trident_dd.c
+++ b/src/mesa/drivers/dri/trident/trident_dd.c
@@ -32,6 +32,7 @@
#include "swrast/swrast.h"
#include "context.h"
+#include "framebuffer.h"
#define TRIDENT_DATE "20041223"
@@ -115,7 +116,7 @@ void tridentDDInitDriverFuncs( GLcontext *ctx )
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
/* Swrast hooks for imaging extensions:
*/
diff --git a/src/mesa/drivers/dri/trident/trident_state.c b/src/mesa/drivers/dri/trident/trident_state.c
index 2b9323f991..76b2a8ef3c 100644
--- a/src/mesa/drivers/dri/trident/trident_state.c
+++ b/src/mesa/drivers/dri/trident/trident_state.c
@@ -30,6 +30,7 @@
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
+#include "framebuffer.h"
#define TRIDENTPACKCOLOR332(r, g, b) \
(((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
@@ -165,19 +166,19 @@ static void tridentDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
if ( tmesa->new_state )
tridentDDUpdateHWState( ctx );
- if ( mask & DD_FRONT_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
flags |= DRM_TRIDENT_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if ( mask & DD_BACK_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
flags |= DRM_TRIDENT_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if ( ( mask & DD_DEPTH_BIT ) && ctx->Depth.Mask ) {
+ if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
flags |= DRM_TRIDENT_DEPTH;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
LOCK_HARDWARE(tmesa);
@@ -543,7 +544,7 @@ void tridentDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
/* Swrast hooks for imaging extensions:
*/
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
index 6d11502504..8bbcaccf69 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.c
+++ b/src/mesa/drivers/dri/unichrome/via_context.c
@@ -36,6 +36,7 @@
#include "state.h"
#include "simple_list.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
@@ -220,12 +221,17 @@ calculate_buffer_parameters( struct via_context *vmesa )
}
-void viaReAllocateBuffers(GLframebuffer *drawbuffer)
+void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
+ GLuint width, GLuint height)
{
- GET_CURRENT_CONTEXT(ctx);
struct via_context *vmesa = VIA_CONTEXT(ctx);
+#if 0
_swrast_alloc_buffers( drawbuffer );
+#else
+ _mesa_resize_framebuffer(ctx, drawbuffer, width, height);
+#endif
+
calculate_buffer_parameters( vmesa );
}
@@ -581,7 +587,7 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv)
/* check if we're deleting the currently bound context */
if (vmesa == current) {
VIA_FLUSH_DMA(vmesa);
- _mesa_make_current2(NULL, NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
if (vmesa) {
@@ -622,8 +628,8 @@ void viaXMesaWindowMoved(struct via_context *vmesa)
if (!dPriv)
return;
- switch (vmesa->glCtx->Color._DrawDestMask[0]) {
- case DD_FRONT_LEFT_BIT:
+ switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
if (dPriv->numBackClipRects == 0) {
vmesa->numClipRects = dPriv->numClipRects;
vmesa->pClipRects = dPriv->pClipRects;
@@ -633,7 +639,7 @@ void viaXMesaWindowMoved(struct via_context *vmesa)
vmesa->pClipRects = dPriv->pBackClipRects;
}
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
vmesa->numClipRects = dPriv->numClipRects;
vmesa->pClipRects = dPriv->pClipRects;
break;
@@ -700,9 +706,9 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
}
- _mesa_make_current2(vmesa->glCtx,
- (GLframebuffer *)driDrawPriv->driverPrivate,
- (GLframebuffer *)driReadPriv->driverPrivate);
+ _mesa_make_current(vmesa->glCtx,
+ (GLframebuffer *)driDrawPriv->driverPrivate,
+ (GLframebuffer *)driReadPriv->driverPrivate);
viaXMesaWindowMoved(vmesa);
ctx->Driver.Scissor(vmesa->glCtx,
@@ -712,7 +718,7 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
vmesa->glCtx->Scissor.Height);
}
else {
- _mesa_make_current(0,0);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h
index 9db382d49c..c1de1df8a9 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.h
+++ b/src/mesa/drivers/dri/unichrome/via_context.h
@@ -386,7 +386,7 @@ extern void viaEmitHwStateLocked(struct via_context *vmesa);
extern void viaEmitScissorValues(struct via_context *vmesa, int box_nr, int emit);
extern void viaXMesaSetBackClipRects(struct via_context *vmesa);
extern void viaXMesaSetFrontClipRects(struct via_context *vmesa);
-extern void viaReAllocateBuffers(GLframebuffer *drawbuffer);
+extern void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer, GLuint width, GLuint height);
extern void viaXMesaWindowMoved(struct via_context *vmesa);
extern GLboolean viaTexCombineState(struct via_context *vmesa,
diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.c b/src/mesa/drivers/dri/unichrome/via_ioctl.c
index b9997be1ef..651c5f6e31 100644
--- a/src/mesa/drivers/dri/unichrome/via_ioctl.c
+++ b/src/mesa/drivers/dri/unichrome/via_ioctl.c
@@ -214,31 +214,31 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
VIA_FLUSH_DMA(vmesa);
- if (mask & DD_FRONT_LEFT_BIT) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
flag |= VIA_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if (mask & DD_BACK_LEFT_BIT) {
+ if (mask & BUFFER_BIT_BACK_LEFT) {
flag |= VIA_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if (mask & DD_DEPTH_BIT) {
+ if (mask & BUFFER_BIT_DEPTH) {
flag |= VIA_DEPTH;
clear_depth = (GLuint)(ctx->Depth.Clear * vmesa->ClearDepth);
clear_depth_mask &= ~vmesa->depth_clear_mask;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
- if (mask & DD_STENCIL_BIT) {
+ if (mask & BUFFER_BIT_STENCIL) {
if (vmesa->have_hw_stencil) {
if (ctx->Stencil.WriteMask[0] == 0xff) {
flag |= VIA_DEPTH;
clear_depth &= ~0xff;
clear_depth |= (ctx->Stencil.Clear & 0xff);
clear_depth_mask &= ~vmesa->stencil_clear_mask;
- mask &= ~DD_STENCIL_BIT;
+ mask &= ~BUFFER_BIT_STENCIL;
}
else {
if (VIA_DEBUG & DEBUG_2D)
@@ -252,9 +252,9 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
if (vmesa->viaScreen->bytesPerPixel == 2 &&
vmesa->ClearMask & 0xf0000000) {
if (flag & VIA_FRONT)
- mask |= DD_FRONT_LEFT_BIT;
+ mask |= BUFFER_BIT_FRONT_LEFT;
if (flag & VIA_BACK)
- mask |= DD_BACK_LEFT_BIT;
+ mask |= BUFFER_BIT_BACK_LEFT;
flag &= ~(VIA_FRONT | VIA_BACK);
}
diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c
index dbe7a38c3d..e302011665 100644
--- a/src/mesa/drivers/dri/unichrome/via_screen.c
+++ b/src/mesa/drivers/dri/unichrome/via_screen.c
@@ -28,6 +28,8 @@
#include "dri_util.h"
#include "glheader.h"
#include "context.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "matrix.h"
#include "simple_list.h"
#include "vblank.h"
@@ -212,12 +214,15 @@ viaDestroyScreen(__DRIscreenPrivate *sPriv)
sPriv->private = NULL;
}
+
static GLboolean
viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap)
{
+ viaScreenPrivate *screen = (viaScreenPrivate *) driScrnPriv->private;
+
GLboolean swStencil = (mesaVis->stencilBits > 0 &&
mesaVis->depthBits != 24);
@@ -238,13 +243,74 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
return GL_FALSE;
}
else {
+#if 0
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer(mesaVis,
GL_FALSE, /* software depth buffer? */
swStencil,
mesaVis->accumRedBits > 0,
GL_FALSE /* s/w alpha planes */);
-
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ /* XXX check/fix the offset/pitch parameters! */
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ 0, screen->width);
+ viaSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ 0, screen->width);
+ viaSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ 0, screen->width);
+ viaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ 0, screen->width);
+ viaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 32) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp,
+ 0, screen->width);
+ viaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ /* no h/w stencil?
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ viaSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+ */
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
return (driDrawPriv->driverPrivate != NULL);
}
}
diff --git a/src/mesa/drivers/dri/unichrome/via_screen.h b/src/mesa/drivers/dri/unichrome/via_screen.h
index 01613eac21..8239960a63 100644
--- a/src/mesa/drivers/dri/unichrome/via_screen.h
+++ b/src/mesa/drivers/dri/unichrome/via_screen.h
@@ -72,6 +72,7 @@ typedef struct {
driOptionCache optionCache;
} viaScreenPrivate;
+
extern GLboolean
viaCreateContext(const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
diff --git a/src/mesa/drivers/dri/unichrome/via_span.c b/src/mesa/drivers/dri/unichrome/via_span.c
index e5e25f08c1..0fbac9b506 100644
--- a/src/mesa/drivers/dri/unichrome/via_span.c
+++ b/src/mesa/drivers/dri/unichrome/via_span.c
@@ -178,10 +178,10 @@ static void viaSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
{
struct via_context *vmesa = VIA_CONTEXT(ctx);
- if (bufferBit == DD_FRONT_LEFT_BIT) {
+ if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
vmesa->drawBuffer = vmesa->readBuffer = &vmesa->front;
}
- else if (bufferBit == DD_BACK_LEFT_BIT) {
+ else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
vmesa->drawBuffer = vmesa->readBuffer = &vmesa->back;
}
else {
@@ -207,10 +207,13 @@ void viaSpanRenderFinish( GLcontext *ctx )
void viaInitSpanFuncs(GLcontext *ctx)
{
+#if 0
struct via_context *vmesa = VIA_CONTEXT(ctx);
+#endif
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
swdd->SetBuffer = viaSetBuffer;
+#if 0
if (vmesa->viaScreen->bitsPerPixel == 16) {
viaInitPointers_565( swdd );
}
@@ -220,7 +223,8 @@ void viaInitSpanFuncs(GLcontext *ctx)
else {
assert(0);
}
-
+#endif
+#if 0
if (vmesa->glCtx->Visual.depthBits == 16) {
swdd->ReadDepthSpan = viaReadDepthSpan_16;
swdd->WriteDepthSpan = viaWriteDepthSpan_16;
@@ -247,11 +251,12 @@ void viaInitSpanFuncs(GLcontext *ctx)
swdd->ReadDepthPixels = viaReadDepthPixels_32;
swdd->WriteDepthPixels = viaWriteDepthPixels_32;
}
+#endif
swdd->SpanRenderStart = viaSpanRenderStart;
swdd->SpanRenderFinish = viaSpanRenderFinish;
-
+#if 0
swdd->WriteCI8Span = NULL;
swdd->WriteCI32Span = NULL;
swdd->WriteMonoCISpan = NULL;
@@ -259,4 +264,55 @@ void viaInitSpanFuncs(GLcontext *ctx)
swdd->WriteMonoCIPixels = NULL;
swdd->ReadCI32Span = NULL;
swdd->ReadCI32Pixels = NULL;
+#endif
+}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+viaSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ viaInitPointers_565(&drb->Base);
+ }
+ else {
+ viaInitPointers_8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = viaReadDepthSpan_16;
+ drb->Base.GetValues = viaReadDepthPixels_16;
+ drb->Base.PutRow = viaWriteDepthSpan_16;
+ drb->Base.PutMonoRow = viaWriteMonoDepthSpan_16;
+ drb->Base.PutValues = viaWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = viaReadDepthSpan_24_8;
+ drb->Base.GetValues = viaReadDepthPixels_24_8;
+ drb->Base.PutRow = viaWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = viaWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = viaWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ drb->Base.GetRow = viaReadDepthSpan_32;
+ drb->Base.GetValues = viaReadDepthPixels_32;
+ drb->Base.PutRow = viaWriteDepthSpan_32;
+ drb->Base.PutMonoRow = viaWriteMonoDepthSpan_32;
+ drb->Base.PutValues = viaWriteDepthPixels_32;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = viaReadStencilSpan_24_8;
+ drb->Base.GetValues = viaReadStencilPixels_24_8;
+ drb->Base.PutRow = viaWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = viaWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = viaWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
}
diff --git a/src/mesa/drivers/dri/unichrome/via_span.h b/src/mesa/drivers/dri/unichrome/via_span.h
index 71b3f82c03..c3bd24b0e7 100644
--- a/src/mesa/drivers/dri/unichrome/via_span.h
+++ b/src/mesa/drivers/dri/unichrome/via_span.h
@@ -25,8 +25,13 @@
#ifndef _VIA_SPAN_H
#define _VIA_SPAN_H
+#include "drirenderbuffer.h"
+
extern void viaInitSpanFuncs(GLcontext *ctx);
extern void viaSpanRenderStart( GLcontext *ctx );
extern void viaSpanRenderFinish( GLcontext *ctx );
+extern void
+viaSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
diff --git a/src/mesa/drivers/fbdev/glfbdev.c b/src/mesa/drivers/fbdev/glfbdev.c
index 4068216d44..c8d9375b62 100644
--- a/src/mesa/drivers/fbdev/glfbdev.c
+++ b/src/mesa/drivers/fbdev/glfbdev.c
@@ -46,7 +46,10 @@
#include "buffers.h"
#include "context.h"
#include "extensions.h"
+#include "fbobject.h"
+#include "framebuffer.h"
#include "imports.h"
+#include "renderbuffer.h"
#include "texformat.h"
#include "teximage.h"
#include "texstore.h"
@@ -84,15 +87,8 @@ struct GLFBDevBufferRec {
GLFBDevVisualPtr visual;
struct fb_fix_screeninfo fix;
struct fb_var_screeninfo var;
- void *frontStart;
- void *backStart;
- size_t size;
+ size_t size; /* color buffer size in bytes */
GLuint bytesPerPixel;
- GLuint rowStride; /* in bytes */
- GLubyte *frontBottom; /* pointer to last row */
- GLubyte *backBottom; /* pointer to last row */
- GLubyte *curBottom; /* = frontBottom or backBottom */
- GLboolean mallocBackBuffer;
};
/*
@@ -106,6 +102,16 @@ struct GLFBDevContextRec {
GLFBDevBufferPtr curBuffer;
};
+/*
+ * Derived from Mesa's gl_renderbuffer class.
+ */
+struct GLFBDevRenderbufferRec {
+ struct gl_renderbuffer Base;
+ GLubyte *bottom; /* pointer to last row */
+ GLuint rowStride; /* in bytes */
+ GLboolean mallocedBuffer;
+};
+
#define GLFBDEV_CONTEXT(CTX) ((GLFBDevContextPtr) (CTX))
@@ -144,7 +150,7 @@ update_state( GLcontext *ctx, GLuint new_state )
static void
get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
- const GLFBDevBufferPtr fbdevbuffer = (GLFBDevBufferPtr) buffer;
+ const GLFBDevBufferPtr fbdevbuffer = GLFBDEV_BUFFER(buffer);
*width = fbdevbuffer->var.xres_virtual;
*height = fbdevbuffer->var.yres_virtual;
}
@@ -162,19 +168,7 @@ viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
static void
set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
{
- GLFBDevContextPtr fbdevctx = GLFBDEV_CONTEXT(ctx);
- GLFBDevBufferPtr fbdevbuf = GLFBDEV_BUFFER(buffer);
- fbdevctx->curBuffer = fbdevbuf;
- switch (bufferBit) {
- case DD_FRONT_LEFT_BIT:
- fbdevbuf->curBottom = fbdevbuf->frontBottom;
- break;
- case DD_BACK_LEFT_BIT:
- fbdevbuf->curBottom = fbdevbuf->backBottom;
- break;
- default:
- _mesa_problem(ctx, "bad bufferBit in set_buffer()");
- }
+ /* this is a no-op when using the new gl_renderbuffer span functions. */
}
@@ -184,96 +178,102 @@ set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
/* 24-bit BGR */
#define NAME(PREFIX) PREFIX##_B8G8R8
+#define FORMAT GL_RGBA8
#define SPAN_VARS \
- const GLFBDevContextPtr fbdevctx = GLFBDEV_CONTEXT(ctx); \
- const GLFBDevBufferPtr fbdevbuf = fbdevctx->curBuffer;
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
#define INIT_PIXEL_PTR(P, X, Y) \
- GLubyte *P = fbdevbuf->curBottom - (Y) * fbdevbuf->rowStride + (X) * 3
+ GLubyte *P = frb->bottom - (Y) * frb->rowStride + (X) * 3
#define INC_PIXEL_PTR(P) P += 3
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- P[0] = B; P[1] = G; P[2] = R
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- P[0] = B; P[1] = G; P[2] = R
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- R = P[2]; G = P[1]; B = P[0]; A = CHAN_MAX
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[BCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[RCOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[ACOMP] = CHAN_MAX
-#include "swrast/s_spantemp.h"
+#include "swrast/s_spantemp2.h"
/* 32-bit BGRA */
#define NAME(PREFIX) PREFIX##_B8G8R8A8
+#define FORMAT GL_RGBA8
#define SPAN_VARS \
- const GLFBDevContextPtr fbdevctx = GLFBDEV_CONTEXT(ctx); \
- const GLFBDevBufferPtr fbdevbuf = fbdevctx->curBuffer;
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
#define INIT_PIXEL_PTR(P, X, Y) \
- GLubyte *P = fbdevbuf->curBottom - (Y) * fbdevbuf->rowStride + (X) * 4
+ GLubyte *P = frb->bottom - (Y) * frb->rowStride + (X) * 4
#define INC_PIXEL_PTR(P) P += 4
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- P[0] = B; P[1] = G; P[2] = R; P[3] = 255
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- P[0] = B; P[1] = G; P[2] = R; P[3] = A
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- R = P[2]; G = P[1]; B = P[0]; A = P[3]
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[BCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[RCOMP]; \
+ DST[3] = VALUE[ACOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[ACOMP] = SRC[3]
-#include "swrast/s_spantemp.h"
+#include "swrast/s_spantemp2.h"
/* 16-bit BGR (XXX implement dithering someday) */
#define NAME(PREFIX) PREFIX##_B5G6R5
+#define FORMAT GL_RGBA8
#define SPAN_VARS \
- const GLFBDevContextPtr fbdevctx = GLFBDEV_CONTEXT(ctx); \
- const GLFBDevBufferPtr fbdevbuf = fbdevctx->curBuffer;
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
#define INIT_PIXEL_PTR(P, X, Y) \
- GLushort *P = (GLushort *) (fbdevbuf->curBottom - (Y) * fbdevbuf->rowStride + (X) * 2)
+ GLushort *P = (GLushort *) (frb->bottom - (Y) * frb->rowStride + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- R = ( (((*P) >> 8) & 0xf8) | (((*P) >> 11) & 0x7) ); \
- G = ( (((*P) >> 3) & 0xfc) | (((*P) >> 5) & 0x3) ); \
- B = ( (((*P) << 3) & 0xf8) | (((*P) ) & 0x7) ); \
- A = CHAN_MAX
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 8) | (((VALUE[GCOMP]) & 0xfc) << 3) | ((VALUE[BCOMP]) >> 3) )
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = ( (((SRC[0]) >> 8) & 0xf8) | (((SRC[0]) >> 11) & 0x7) ); \
+ DST[GCOMP] = ( (((SRC[0]) >> 3) & 0xfc) | (((SRC[0]) >> 5) & 0x3) ); \
+ DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \
+ DST[ACOMP] = CHAN_MAX
-#include "swrast/s_spantemp.h"
+#include "swrast/s_spantemp2.h"
/* 15-bit BGR (XXX implement dithering someday) */
#define NAME(PREFIX) PREFIX##_B5G5R5
+#define FORMAT GL_RGBA8
#define SPAN_VARS \
- const GLFBDevContextPtr fbdevctx = GLFBDEV_CONTEXT(ctx); \
- const GLFBDevBufferPtr fbdevbuf = fbdevctx->curBuffer;
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
#define INIT_PIXEL_PTR(P, X, Y) \
- GLushort *P = (GLushort *) (fbdevbuf->curBottom - (Y) * fbdevbuf->rowStride + (X) * 2)
+ GLushort *P = (GLushort *) (frb->bottom - (Y) * frb->rowStride + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- *P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- *P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- R = ( (((*P) >> 7) & 0xf8) | (((*P) >> 10) & 0x7) ); \
- G = ( (((*P) >> 2) & 0xf8) | (((*P) >> 5) & 0x7) ); \
- B = ( (((*P) << 3) & 0xf8) | (((*P) ) & 0x7) ); \
- A = CHAN_MAX
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 7) | (((VALUE[GCOMP]) & 0xf8) << 2) | ((VALUE[BCOMP]) >> 3) )
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = ( (((SRC[0]) >> 7) & 0xf8) | (((SRC[0]) >> 10) & 0x7) ); \
+ DST[GCOMP] = ( (((SRC[0]) >> 2) & 0xf8) | (((SRC[0]) >> 5) & 0x7) ); \
+ DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \
+ DST[ACOMP] = CHAN_MAX
-#include "swrast/s_spantemp.h"
+#include "swrast/s_spantemp2.h"
/* 8-bit color index */
#define NAME(PREFIX) PREFIX##_CI8
+#define FORMAT GL_COLOR_INDEX8_EXT
#define SPAN_VARS \
- const GLFBDevContextPtr fbdevctx = GLFBDEV_CONTEXT(ctx); \
- const GLFBDevBufferPtr fbdevbuf = fbdevctx->curBuffer;
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
#define INIT_PIXEL_PTR(P, X, Y) \
- GLubyte *P = fbdevbuf->curBottom - (Y) * fbdevbuf->rowStride + (X)
+ GLubyte *P = frb->bottom - (Y) * frb->rowStride + (X)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_CI_PIXEL(P, CI) \
- P[0] = CI
-#define FETCH_CI_PIXEL(CI, P) \
- CI = P[0]
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ *DST = VALUE[0]
+#define FETCH_PIXEL(DST, SRC) \
+ DST = SRC[0]
+
+#include "swrast/s_spantemp2.h"
+
+
-#include "swrast/s_spantemp.h"
/**********************************************************************/
/* Public API functions */
@@ -294,30 +294,30 @@ glFBDevGetString( int str )
}
-const void *
+const GLFBDevProc
glFBDevGetProcAddress( const char *procName )
{
struct name_address {
const char *name;
- const void *func;
+ const GLFBDevProc func;
};
static const struct name_address functions[] = {
- { "glFBDevGetString", (void *) glFBDevGetString },
- { "glFBDevGetProcAddress", (void *) glFBDevGetProcAddress },
- { "glFBDevCreateVisual", (void *) glFBDevCreateVisual },
- { "glFBDevDestroyVisual", (void *) glFBDevDestroyVisual },
- { "glFBDevGetVisualAttrib", (void *) glFBDevGetVisualAttrib },
- { "glFBDevCreateBuffer", (void *) glFBDevCreateBuffer },
- { "glFBDevDestroyBuffer", (void *) glFBDevDestroyBuffer },
- { "glFBDevGetBufferAttrib", (void *) glFBDevGetBufferAttrib },
- { "glFBDevGetCurrentDrawBuffer", (void *) glFBDevGetCurrentDrawBuffer },
- { "glFBDevGetCurrentReadBuffer", (void *) glFBDevGetCurrentReadBuffer },
- { "glFBDevSwapBuffers", (void *) glFBDevSwapBuffers },
- { "glFBDevCreateContext", (void *) glFBDevCreateContext },
- { "glFBDevDestroyContext", (void *) glFBDevDestroyContext },
- { "glFBDevGetContextAttrib", (void *) glFBDevGetContextAttrib },
- { "glFBDevGetCurrentContext", (void *) glFBDevGetCurrentContext },
- { "glFBDevMakeCurrent", (void *) glFBDevMakeCurrent },
+ { "glFBDevGetString", (GLFBDevProc) glFBDevGetString },
+ { "glFBDevGetProcAddress", (GLFBDevProc) glFBDevGetProcAddress },
+ { "glFBDevCreateVisual", (GLFBDevProc) glFBDevCreateVisual },
+ { "glFBDevDestroyVisual", (GLFBDevProc) glFBDevDestroyVisual },
+ { "glFBDevGetVisualAttrib", (GLFBDevProc) glFBDevGetVisualAttrib },
+ { "glFBDevCreateBuffer", (GLFBDevProc) glFBDevCreateBuffer },
+ { "glFBDevDestroyBuffer", (GLFBDevProc) glFBDevDestroyBuffer },
+ { "glFBDevGetBufferAttrib", (GLFBDevProc) glFBDevGetBufferAttrib },
+ { "glFBDevGetCurrentDrawBuffer", (GLFBDevProc) glFBDevGetCurrentDrawBuffer },
+ { "glFBDevGetCurrentReadBuffer", (GLFBDevProc) glFBDevGetCurrentReadBuffer },
+ { "glFBDevSwapBuffers", (GLFBDevProc) glFBDevSwapBuffers },
+ { "glFBDevCreateContext", (GLFBDevProc) glFBDevCreateContext },
+ { "glFBDevDestroyContext", (GLFBDevProc) glFBDevDestroyContext },
+ { "glFBDevGetContextAttrib", (GLFBDevProc) glFBDevGetContextAttrib },
+ { "glFBDevGetCurrentContext", (GLFBDevProc) glFBDevGetCurrentContext },
+ { "glFBDevMakeCurrent", (GLFBDevProc) glFBDevMakeCurrent },
{ NULL, NULL }
};
const struct name_address *entry;
@@ -326,7 +326,7 @@ glFBDevGetProcAddress( const char *procName )
return entry->func;
}
}
- return (const void *)_glapi_get_proc_address(procName);
+ return _glapi_get_proc_address(procName);
}
@@ -477,12 +477,101 @@ glFBDevDestroyVisual( GLFBDevVisualPtr visual )
int
glFBDevGetVisualAttrib( const GLFBDevVisualPtr visual, int attrib)
{
+ /* XXX unfinished */
(void) visual;
(void) attrib;
return -1;
}
+static void
+delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
+ if (frb->mallocedBuffer) {
+ _mesa_free(frb->Base.Data);
+ }
+ _mesa_free(frb);
+}
+
+
+static GLboolean
+renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ /* no-op: the renderbuffer storage is allocated just once when it's
+ * created. Never resized or reallocated.
+ */
+ return GL_TRUE;
+}
+
+
+static struct GLFBDevRenderbufferRec *
+new_glfbdev_renderbuffer(void *bufferStart, int pixelFormat)
+{
+ struct GLFBDevRenderbufferRec *rb = CALLOC_STRUCT(GLFBDevRenderbufferRec);
+ if (rb) {
+ GLuint name = 0;
+ _mesa_init_renderbuffer(&rb->Base, name);
+
+ rb->Base.Delete = delete_renderbuffer;
+ rb->Base.AllocStorage = renderbuffer_storage;
+
+ if (pixelFormat == PF_B8G8R8) {
+ rb->Base.GetRow = get_row_B8G8R8;
+ rb->Base.GetValues = get_values_B8G8R8;
+ rb->Base.PutRow = put_row_B8G8R8;
+ rb->Base.PutMonoRow = put_mono_row_B8G8R8;
+ rb->Base.PutValues = put_values_B8G8R8;
+ rb->Base.PutMonoValues = put_mono_values_B8G8R8;
+ }
+ else if (pixelFormat == PF_B8G8R8A8) {
+ rb->Base.GetRow = get_row_B8G8R8A8;
+ rb->Base.GetValues = get_values_B8G8R8A8;
+ rb->Base.PutRow = put_row_B8G8R8A8;
+ rb->Base.PutMonoRow = put_mono_row_B8G8R8A8;
+ rb->Base.PutValues = put_values_B8G8R8A8;
+ rb->Base.PutMonoValues = put_mono_values_B8G8R8A8;
+ }
+ else if (pixelFormat == PF_B5G6R5) {
+ rb->Base.GetRow = get_row_B5G6R5;
+ rb->Base.GetValues = get_values_B5G6R5;
+ rb->Base.PutRow = put_row_B5G6R5;
+ rb->Base.PutMonoRow = put_mono_row_B5G6R5;
+ rb->Base.PutValues = put_values_B5G6R5;
+ rb->Base.PutMonoValues = put_mono_values_B5G6R5;
+ }
+ else if (pixelFormat == PF_B5G5R5) {
+ rb->Base.GetRow = get_row_B5G5R5;
+ rb->Base.GetValues = get_values_B5G5R5;
+ rb->Base.PutRow = put_row_B5G5R5;
+ rb->Base.PutMonoRow = put_mono_row_B5G5R5;
+ rb->Base.PutValues = put_values_B5G5R5;
+ rb->Base.PutMonoValues = put_mono_values_B5G5R5;
+ }
+ else if (pixelFormat == PF_CI8) {
+ rb->Base.GetRow = get_row_CI8;
+ rb->Base.GetValues = get_values_CI8;
+ rb->Base.PutRow = put_row_CI8;
+ rb->Base.PutMonoRow = put_mono_row_CI8;
+ rb->Base.PutValues = put_values_CI8;
+ rb->Base.PutMonoValues = put_mono_values_CI8;
+ }
+
+ if (pixelFormat == PF_CI8) {
+ rb->Base.InternalFormat = GL_COLOR_INDEX8_EXT;
+ rb->Base._BaseFormat = GL_COLOR_INDEX;
+ }
+ else {
+ rb->Base.InternalFormat = GL_RGBA;
+ rb->Base._BaseFormat = GL_RGBA;
+ }
+ rb->Base.DataType = GL_UNSIGNED_BYTE;
+ rb->Base.Data = bufferStart;
+ }
+ return rb;
+}
+
GLFBDevBufferPtr
glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo,
@@ -490,6 +579,7 @@ glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo,
const GLFBDevVisualPtr visual,
void *frontBuffer, void *backBuffer, size_t size )
{
+ struct GLFBDevRenderbufferRec *frontrb, *backrb;
GLFBDevBufferPtr buf;
ASSERT(visual);
@@ -512,45 +602,56 @@ glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo,
if (!buf)
return NULL;
- _mesa_initialize_framebuffer(&buf->glframebuffer, &visual->glvisual,
+ /* basic framebuffer setup */
+ _mesa_initialize_framebuffer(&buf->glframebuffer, &visual->glvisual);
+ /* add front renderbuffer */
+ frontrb = new_glfbdev_renderbuffer(frontBuffer, visual->pixelFormat);
+ _mesa_add_renderbuffer(&buf->glframebuffer, BUFFER_FRONT_LEFT,
+ &frontrb->Base);
+ /* add back renderbuffer */
+ if (visual->glvisual.doubleBufferMode) {
+ backrb = new_glfbdev_renderbuffer(backBuffer, visual->pixelFormat);
+ _mesa_add_renderbuffer(&buf->glframebuffer, BUFFER_BACK_LEFT,
+ &backrb->Base);
+ }
+ /* add software renderbuffers */
+ _mesa_add_soft_renderbuffers(&buf->glframebuffer,
+ GL_FALSE, /* color */
visual->glvisual.haveDepthBuffer,
visual->glvisual.haveStencilBuffer,
visual->glvisual.haveAccumBuffer,
- GL_FALSE);
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux bufs */);
+
+
buf->fix = *fixInfo; /* struct assignment */
buf->var = *varInfo; /* struct assignment */
buf->visual = visual; /* ptr assignment */
- buf->frontStart = frontBuffer;
buf->size = size;
buf->bytesPerPixel = visual->var.bits_per_pixel / 8;
- buf->rowStride = visual->var.xres_virtual * buf->bytesPerPixel;
- buf->frontBottom = (GLubyte *) buf->frontStart
- + (visual->var.yres_virtual - 1) * buf->rowStride;
+ frontrb->rowStride = visual->var.xres_virtual * buf->bytesPerPixel;
+ frontrb->bottom = (GLubyte *) frontrb->Base.Data
+ + (visual->var.yres_virtual - 1) * frontrb->rowStride;
if (visual->glvisual.doubleBufferMode) {
- if (backBuffer) {
- buf->backStart = backBuffer;
- buf->mallocBackBuffer = GL_FALSE;
- }
- else {
- buf->backStart = _mesa_malloc(size);
- if (!buf->backStart) {
+ if (!backBuffer) {
+ /* malloc a back buffer */
+ backrb->Base.Data = _mesa_malloc(size);
+ if (!backrb->Base.Data) {
_mesa_free_framebuffer_data(&buf->glframebuffer);
_mesa_free(buf);
return NULL;
}
- buf->mallocBackBuffer = GL_TRUE;
+ backrb->mallocedBuffer = GL_TRUE;
}
- buf->backBottom = (GLubyte *) buf->backStart
- + (visual->var.yres_virtual - 1) * buf->rowStride;
- buf->curBottom = buf->backBottom;
+ backrb->rowStride = frontrb->rowStride;
+ backrb->bottom = (GLubyte *) backrb->Base.Data
+ + (visual->var.yres_virtual - 1) * backrb->rowStride;
}
else {
- buf->backStart = NULL;
- buf->mallocBackBuffer = GL_FALSE;
- buf->backBottom = NULL;
- buf->curBottom = buf->frontBottom;
+ backrb->bottom = NULL;
+ backrb->rowStride = 0;
}
return buf;
@@ -567,9 +668,6 @@ glFBDevDestroyBuffer( GLFBDevBufferPtr buffer )
if (buffer == curDraw || buffer == curRead) {
glFBDevMakeCurrent( NULL, NULL, NULL);
}
- if (buffer->mallocBackBuffer) {
- _mesa_free(buffer->backStart);
- }
/* free the software depth, stencil, accum buffers */
_mesa_free_framebuffer_data(&buffer->glframebuffer);
_mesa_free(buffer);
@@ -612,6 +710,10 @@ void
glFBDevSwapBuffers( GLFBDevBufferPtr buffer )
{
GLFBDevContextPtr fbdevctx = glFBDevGetCurrentContext();
+ struct GLFBDevRenderbufferRec *frontrb = (struct GLFBDevRenderbufferRec *)
+ buffer->glframebuffer.Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+ struct GLFBDevRenderbufferRec *backrb = (struct GLFBDevRenderbufferRec *)
+ buffer->glframebuffer.Attachment[BUFFER_BACK_LEFT].Renderbuffer;
if (!buffer || !buffer->visual->glvisual.doubleBufferMode)
return;
@@ -622,9 +724,9 @@ glFBDevSwapBuffers( GLFBDevBufferPtr buffer )
_mesa_notifySwapBuffers(&fbdevctx->glcontext);
}
- ASSERT(buffer->frontStart);
- ASSERT(buffer->backStart);
- _mesa_memcpy(buffer->frontStart, buffer->backStart, buffer->size);
+ ASSERT(frontrb->Base.Data);
+ ASSERT(backrb->Base.Data);
+ _mesa_memcpy(frontrb->Base.Data, backrb->Base.Data, buffer->size);
}
@@ -670,54 +772,15 @@ glFBDevCreateContext( const GLFBDevVisualPtr visual, GLFBDevContextPtr share )
struct swrast_device_driver *swdd;
swdd = _swrast_GetDeviceDriverReference( glctx );
swdd->SetBuffer = set_buffer;
- if (visual->pixelFormat == PF_B8G8R8) {
- swdd->WriteRGBASpan = write_rgba_span_B8G8R8;
- swdd->WriteRGBSpan = write_rgb_span_B8G8R8;
- swdd->WriteMonoRGBASpan = write_monorgba_span_B8G8R8;
- swdd->WriteRGBAPixels = write_rgba_pixels_B8G8R8;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_B8G8R8;
- swdd->ReadRGBASpan = read_rgba_span_B8G8R8;
- swdd->ReadRGBAPixels = read_rgba_pixels_B8G8R8;
- }
- else if (visual->pixelFormat == PF_B8G8R8A8) {
- swdd->WriteRGBASpan = write_rgba_span_B8G8R8A8;
- swdd->WriteRGBSpan = write_rgb_span_B8G8R8A8;
- swdd->WriteMonoRGBASpan = write_monorgba_span_B8G8R8A8;
- swdd->WriteRGBAPixels = write_rgba_pixels_B8G8R8A8;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_B8G8R8A8;
- swdd->ReadRGBASpan = read_rgba_span_B8G8R8A8;
- swdd->ReadRGBAPixels = read_rgba_pixels_B8G8R8A8;
- }
- else if (visual->pixelFormat == PF_B5G6R5) {
- swdd->WriteRGBASpan = write_rgba_span_B5G6R5;
- swdd->WriteRGBSpan = write_rgb_span_B5G6R5;
- swdd->WriteMonoRGBASpan = write_monorgba_span_B5G6R5;
- swdd->WriteRGBAPixels = write_rgba_pixels_B5G6R5;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_B5G6R5;
- swdd->ReadRGBASpan = read_rgba_span_B5G6R5;
- swdd->ReadRGBAPixels = read_rgba_pixels_B5G6R5;
- }
- else if (visual->pixelFormat == PF_B5G5R5) {
- swdd->WriteRGBASpan = write_rgba_span_B5G5R5;
- swdd->WriteRGBSpan = write_rgb_span_B5G5R5;
- swdd->WriteMonoRGBASpan = write_monorgba_span_B5G5R5;
- swdd->WriteRGBAPixels = write_rgba_pixels_B5G5R5;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_B5G5R5;
- swdd->ReadRGBASpan = read_rgba_span_B5G5R5;
- swdd->ReadRGBAPixels = read_rgba_pixels_B5G5R5;
- }
- else if (visual->pixelFormat == PF_CI8) {
- swdd->WriteCI32Span = write_index32_span_CI8;
- swdd->WriteCI8Span = write_index8_span_CI8;
- swdd->WriteMonoCISpan = write_monoindex_span_CI8;
- swdd->WriteCI32Pixels = write_index_pixels_CI8;
- swdd->WriteMonoCIPixels = write_monoindex_pixels_CI8;
- swdd->ReadCI32Span = read_index_span_CI8;
- swdd->ReadCI32Pixels = read_index_pixels_CI8;
- }
- else {
- _mesa_printf("bad pixelformat: %d\n", visual->pixelFormat);
- }
+
+ /* no longer used */
+ swdd->WriteRGBASpan = NULL;
+ swdd->WriteRGBSpan = NULL;
+ swdd->WriteMonoRGBASpan = NULL;
+ swdd->WriteRGBAPixels = NULL;
+ swdd->WriteMonoRGBAPixels = NULL;
+ swdd->ReadRGBASpan = NULL;
+ swdd->ReadRGBAPixels = NULL;
}
/* use default TCL pipeline */
@@ -740,7 +803,7 @@ glFBDevDestroyContext( GLFBDevContextPtr context )
if (context) {
if (fbdevctx == context) {
/* destroying current context */
- _mesa_make_current2(NULL, NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
_mesa_notifyDestroy(&context->glcontext);
}
_mesa_free_context_data(&context->glcontext);
@@ -780,16 +843,16 @@ glFBDevMakeCurrent( GLFBDevContextPtr context,
context->visual != readBuffer->visual) {
return 0;
}
- _mesa_make_current2( &context->glcontext,
- &drawBuffer->glframebuffer,
- &readBuffer->glframebuffer );
+ _mesa_make_current( &context->glcontext,
+ &drawBuffer->glframebuffer,
+ &readBuffer->glframebuffer );
context->drawBuffer = drawBuffer;
context->readBuffer = readBuffer;
context->curBuffer = drawBuffer;
}
else {
/* unbind */
- _mesa_make_current2( NULL, NULL, NULL );
+ _mesa_make_current( NULL, NULL, NULL );
}
return 1;
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index 4ab4b6421f..50022ee548 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -441,7 +441,6 @@ fxDDDrawBitmap2 (GLcontext *ctx, GLint px, GLint py,
/*CLIP_BIT |*/ /* clipping ok, below */
STENCIL_BIT |
MASKING_BIT |
- ALPHABUF_BIT | /* nope! see 565 span kludge */
MULTI_DRAW_BIT |
OCCLUSION_BIT | /* nope! at least not yet */
TEXTURE_BIT |
@@ -605,7 +604,6 @@ fxDDDrawBitmap4 (GLcontext *ctx, GLint px, GLint py,
/*CLIP_BIT |*/ /* clipping ok, below */
STENCIL_BIT |
/*MASKING_BIT |*/ /* masking ok, we're in 32bpp */
- /*ALPHABUF_BIT |*//* alpha ok, we're in 32bpp */
MULTI_DRAW_BIT |
OCCLUSION_BIT | /* nope! at least not yet */
TEXTURE_BIT |
@@ -1089,7 +1087,6 @@ fxDDDrawPixels555 (GLcontext * ctx, GLint x, GLint y,
/*CLIP_BIT |*/ /* clipping ok, below */
STENCIL_BIT |
MASKING_BIT |
- ALPHABUF_BIT |
MULTI_DRAW_BIT |
OCCLUSION_BIT | /* nope! at least not yet */
TEXTURE_BIT |
@@ -1224,7 +1221,6 @@ fxDDDrawPixels565 (GLcontext * ctx, GLint x, GLint y,
/*CLIP_BIT |*/ /* clipping ok, below */
STENCIL_BIT |
MASKING_BIT |
- ALPHABUF_BIT |
MULTI_DRAW_BIT |
OCCLUSION_BIT | /* nope! at least not yet */
TEXTURE_BIT |
@@ -1359,7 +1355,6 @@ fxDDDrawPixels565_rev (GLcontext * ctx, GLint x, GLint y,
/*CLIP_BIT |*/ /* clipping ok, below */
STENCIL_BIT |
MASKING_BIT |
- ALPHABUF_BIT |
MULTI_DRAW_BIT |
OCCLUSION_BIT | /* nope! at least not yet */
TEXTURE_BIT |
@@ -1494,7 +1489,6 @@ fxDDDrawPixels8888 (GLcontext * ctx, GLint x, GLint y,
/*CLIP_BIT |*/ /* clipping ok, below */
STENCIL_BIT |
/*MASKING_BIT |*/ /* masking ok, we're in 32bpp */
- /*ALPHABUF_BIT |*//* alpha ok, we're in 32bpp */
MULTI_DRAW_BIT |
OCCLUSION_BIT | /* nope! at least not yet */
TEXTURE_BIT |
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 7aa5673256..9eb0fcd983 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -35,20 +35,13 @@
#include "glheader.h"
#include "GL/osmesa.h"
-#include "buffers.h"
-#include "bufferobj.h"
#include "context.h"
-#include "colormac.h"
-#include "depth.h"
#include "extensions.h"
+#include "framebuffer.h"
+#include "fbobject.h"
#include "imports.h"
-#include "macros.h"
-#include "matrix.h"
#include "mtypes.h"
-#include "texformat.h"
-#include "texobj.h"
-#include "teximage.h"
-#include "texstore.h"
+#include "renderbuffer.h"
#include "array_cache/acache.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
@@ -133,10 +126,14 @@ set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
{
/* separate read buffer not supported */
ASSERT(buffer == ctx->DrawBuffer);
- ASSERT(bufferBit == DD_FRONT_LEFT_BIT);
+ ASSERT(bufferBit == BUFFER_BIT_FRONT_LEFT);
}
+/*
+ * Just return the current buffer size.
+ * There's no window to track the size of.
+ */
static void
get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
@@ -151,194 +148,150 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
-static void
-clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
- const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
-
- /* sanity check - we only have a front-left buffer */
- ASSERT((mask & (DD_FRONT_RIGHT_BIT |
- DD_BACK_LEFT_BIT |
- DD_BACK_RIGHT_BIT)) == 0);
-
- /* use optimized clear for common cases (clear whole buffer to black) */
- if (mask & DD_FRONT_LEFT_BIT) {
- if (osmesa->format == OSMESA_COLOR_INDEX) {
- if (ctx->Color.ClearIndex == 0 &&
- ctx->Color.IndexMask == (GLuint) ~0 &&
- osmesa->rowlength == osmesa->width &&
- all) {
- /* clear whole buffer to zeros */
- _mesa_bzero(osmesa->buffer,
- osmesa->width * osmesa->height * sizeof(GLchan));
- mask &= ~DD_FRONT_LEFT_BIT;
- }
- }
- else {
- /* RGB[A] format */
- if (*colorMask == 0xffffffff &&
- ctx->Color.ClearColor[0] == 0.0F &&
- ctx->Color.ClearColor[1] == 0.0F &&
- ctx->Color.ClearColor[2] == 0.0F &&
- ctx->Color.ClearColor[3] == 0.0F &&
- osmesa->rowlength == osmesa->width &&
- all) {
- GLint bytesPerPixel;
- /* clear whole buffer to black */
- if (osmesa->format == OSMESA_RGBA ||
- osmesa->format == OSMESA_BGRA ||
- osmesa->format == OSMESA_ARGB)
- bytesPerPixel = 4 * sizeof(GLchan);
- else if (osmesa->format == OSMESA_RGB ||
- osmesa->format == OSMESA_BGR)
- bytesPerPixel = 3 * sizeof(GLchan);
- else if (osmesa->format == OSMESA_RGB_565)
- bytesPerPixel = sizeof(GLushort);
- else {
- _mesa_problem(ctx, "bad pixel format in osmesa_clear()");
- return;
- }
- _mesa_bzero(osmesa->buffer,
- bytesPerPixel * osmesa->width * osmesa->height);
- mask &= ~DD_FRONT_LEFT_BIT;
- }
- }
- }
-
- if (mask) {
- /* software fallback (spans) for everything else. */
- _swrast_Clear(ctx, mask, all, x, y, width, height);
- }
-}
-
-
/**********************************************************************/
/***** Read/write spans/arrays of pixels *****/
/**********************************************************************/
-
/* RGBA */
#define NAME(PREFIX) PREFIX##_RGBA
+#define FORMAT GL_RGBA
#define SPAN_VARS \
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
#define INIT_PIXEL_PTR(P, X, Y) \
GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 4
#if CHAN_TYPE == GL_FLOAT
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- P[0] = MAX2((R), 0.0F); \
- P[1] = MAX2((G), 0.0F); \
- P[2] = MAX2((B), 0.0F); \
- P[3] = CHAN_MAXF
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- P[0] = MAX2((R), 0.0F); \
- P[1] = MAX2((G), 0.0F); \
- P[2] = MAX2((B), 0.0F); \
- P[3] = CLAMP((A), 0.0F, CHAN_MAXF)
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = MAX2((VALUE[RCOMP]), 0.0F); \
+ DST[1] = MAX2((VALUE[GCOMP]), 0.0F); \
+ DST[2] = MAX2((VALUE[BCOMP]), 0.0F); \
+ DST[3] = CLAMP((VALUE[ACOMP]), 0.0F, CHAN_MAXF)
#else
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- P[0] = R; P[1] = G; P[2] = B; P[3] = CHAN_MAX
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- P[0] = R; P[1] = G; P[2] = B; P[3] = A
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[BCOMP]; \
+ DST[3] = VALUE[ACOMP]
#endif
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- R = P[0]; G = P[1]; B = P[2]; A = P[3]
-#include "swrast/s_spantemp.h"
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[0]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[2]; \
+ DST[BCOMP] = SRC[3]
+#include "swrast/s_spantemp2.h"
/* BGRA */
#define NAME(PREFIX) PREFIX##_BGRA
+#define FORMAT GL_RGBA
#define SPAN_VARS \
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
#define INIT_PIXEL_PTR(P, X, Y) \
GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 4
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- P[2] = R; P[1] = G; P[0] = B; P[3] = CHAN_MAX
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- P[2] = R; P[1] = G; P[0] = B; P[3] = A
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- R = P[2]; G = P[1]; B = P[0]; A = P[3]
-#include "swrast/s_spantemp.h"
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[2] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[0] = VALUE[BCOMP]; \
+ DST[3] = VALUE[ACOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[BCOMP] = SRC[3]
+#include "swrast/s_spantemp2.h"
/* ARGB */
#define NAME(PREFIX) PREFIX##_ARGB
+#define FORMAT GL_RGBA
#define SPAN_VARS \
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
#define INIT_PIXEL_PTR(P, X, Y) \
GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 4
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- P[1] = R; P[2] = G; P[3] = B; P[0] = CHAN_MAX
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- P[1] = R; P[2] = G; P[3] = B; P[0] = A
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- R = P[1]; G = P[2]; B = P[3]; A = P[0]
-#include "swrast/s_spantemp.h"
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[1] = VALUE[RCOMP]; \
+ DST[2] = VALUE[GCOMP]; \
+ DST[3] = VALUE[BCOMP]; \
+ DST[0] = VALUE[ACOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[1]; \
+ DST[GCOMP] = SRC[2]; \
+ DST[BCOMP] = SRC[3]; \
+ DST[BCOMP] = SRC[0]
+#include "swrast/s_spantemp2.h"
/* RGB */
#define NAME(PREFIX) PREFIX##_RGB
+#define FORMAT GL_RGBA
#define SPAN_VARS \
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
#define INIT_PIXEL_PTR(P, X, Y) \
- GLchan *P = osmesa->rowaddr[Y] + 3 * (X)
+ GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 3
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- P[0] = R; P[1] = G; P[2] = B
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- P[0] = R; P[1] = G; P[2] = B
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- R = P[0]; G = P[1]; B = P[2]; A = CHAN_MAX
-#include "swrast/s_spantemp.h"
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[BCOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[0]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[2]; \
+ DST[BCOMP] = CHAN_MAX
+#include "swrast/s_spantemp2.h"
/* BGR */
#define NAME(PREFIX) PREFIX##_BGR
+#define FORMAT GL_RGBA
#define SPAN_VARS \
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
#define INIT_PIXEL_PTR(P, X, Y) \
- GLchan *P = osmesa->rowaddr[Y] + 3 * (X)
+ GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
#define INC_PIXEL_PTR(P) P += 3
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- P[0] = B; P[1] = G; P[2] = R
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- P[0] = B; P[1] = G; P[2] = R
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- B = P[0]; G = P[1]; R = P[2]; A = CHAN_MAX
-#include "swrast/s_spantemp.h"
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[2] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[0] = VALUE[BCOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[BCOMP] = CHAN_MAX
+#include "swrast/s_spantemp2.h"
/* 16-bit BGR */
#if CHAN_TYPE == GL_UNSIGNED_BYTE
#define NAME(PREFIX) PREFIX##_RGB_565
+#define FORMAT GL_RGBA
#define SPAN_VARS \
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
#define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) osmesa->rowaddr[Y] + (X)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
- *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
-#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
- *P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
-#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
- R = ( (((*P) >> 8) & 0xf8) | (((*P) >> 11) & 0x7) ); \
- G = ( (((*P) >> 3) & 0xfc) | (((*P) >> 5) & 0x3) ); \
- B = ( (((*P) << 3) & 0xf8) | (((*P) ) & 0x7) ); \
- A = CHAN_MAX
-#include "swrast/s_spantemp.h"
-#endif
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ *DST = ( (((VALUE[RCOMP]) & 0xf8) << 8) | (((VALUE[GCOMP]) & 0xfc) << 3) | ((VALUE[BCOMP]) >> 3) )
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = ( (((*SRC) >> 8) & 0xf8) | (((*SRC) >> 11) & 0x7) ); \
+ DST[GCOMP] = ( (((*SRC) >> 3) & 0xfc) | (((*SRC) >> 5) & 0x3) ); \
+ DST[BCOMP] = ( (((*SRC) << 3) & 0xf8) | (((*SRC) ) & 0x7) ); \
+ DST[ACOMP] = CHAN_MAX
+#include "swrast/s_spantemp2.h"
+#endif /* CHAN_TYPE == GL_UNSIGNED_BYTE */
/* color index */
#define NAME(PREFIX) PREFIX##_CI
+#define FORMAT GL_COLOR_INDEX8_EXT
#define SPAN_VARS \
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
#define INIT_PIXEL_PTR(P, X, Y) \
- GLchan *P = osmesa->rowaddr[Y] + (X)
+ GLubyte *P = osmesa->rowaddr[Y] + (X)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_CI_PIXEL(P, CI) \
- P[0] = CI
-#define FETCH_CI_PIXEL(CI, P) \
- CI = P[0]
-#include "swrast/s_spantemp.h"
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ *DST = VALUE[0]
+#define FETCH_PIXEL(DST, SRC) \
+ DST = SRC[0]
+#include "swrast/s_spantemp2.h"
+
+
/**********************************************************************/
@@ -631,102 +584,121 @@ osmesa_choose_line( GLcontext *ctx )
_SWRAST_NEW_RASTERMASK)
-/* one-time, per-context initialization */
+/**
+ * Don't use _mesa_delete_renderbuffer since we can't free rb->Data.
+ */
static void
-hook_in_driver_functions( GLcontext *ctx )
+osmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
{
- OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
- SWcontext *swrast = SWRAST_CONTEXT( ctx );
- struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- ASSERT((void *) osmesa == (void *) ctx->DriverCtx);
-
- /* use default TCL pipeline */
- tnl->Driver.RunPipeline = _tnl_run_pipeline;
-
- swdd->SetBuffer = set_buffer;
-
- /* RGB(A) span/pixel functions */
- if (osmesa->format == OSMESA_RGB) {
- swdd->WriteRGBASpan = write_rgba_span_RGB;
- swdd->WriteRGBSpan = write_rgb_span_RGB;
- swdd->WriteMonoRGBASpan = write_monorgba_span_RGB;
- swdd->WriteRGBAPixels = write_rgba_pixels_RGB;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB;
- swdd->ReadRGBASpan = read_rgba_span_RGB;
- swdd->ReadRGBAPixels = read_rgba_pixels_RGB;
+ _mesa_free(rb);
+}
+
+
+/**
+ * Allocate renderbuffer storage. We don't actually allocate any storage
+ * since we're using a user-provided buffer.
+ * Just set up all the gl_renderbuffer methods.
+ */
+static GLboolean
+osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+
+ if (osmesa->format == OSMESA_RGBA) {
+ rb->GetRow = get_row_RGBA;
+ rb->GetValues = get_values_RGBA;
+ rb->PutRow = put_row_RGBA;
+ rb->PutMonoRow = put_mono_row_RGBA;
+ rb->PutValues = put_values_RGBA;
+ rb->PutMonoValues = put_mono_values_RGBA;
+ }
+ else if (osmesa->format == OSMESA_BGRA) {
+ rb->GetRow = get_row_BGRA;
+ rb->GetValues = get_values_BGRA;
+ rb->PutRow = put_row_BGRA;
+ rb->PutMonoRow = put_mono_row_BGRA;
+ rb->PutValues = put_values_BGRA;
+ rb->PutMonoValues = put_mono_values_BGRA;
+ }
+ else if (osmesa->format == OSMESA_ARGB) {
+ rb->GetRow = get_row_ARGB;
+ rb->GetValues = get_values_ARGB;
+ rb->PutRow = put_row_ARGB;
+ rb->PutMonoRow = put_mono_row_ARGB;
+ rb->PutValues = put_values_ARGB;
+ rb->PutMonoValues = put_mono_values_ARGB;
+ }
+ else if (osmesa->format == OSMESA_RGB) {
+ rb->GetRow = get_row_RGB;
+ rb->GetValues = get_values_RGB;
+ rb->PutRow = put_row_RGB;
+ rb->PutMonoRow = put_mono_row_RGB;
+ rb->PutValues = put_values_RGB;
+ rb->PutMonoValues = put_mono_values_RGB;
}
else if (osmesa->format == OSMESA_BGR) {
- swdd->WriteRGBASpan = write_rgba_span_BGR;
- swdd->WriteRGBSpan = write_rgb_span_BGR;
- swdd->WriteMonoRGBASpan = write_monorgba_span_BGR;
- swdd->WriteRGBAPixels = write_rgba_pixels_BGR;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_BGR;
- swdd->ReadRGBASpan = read_rgba_span_BGR;
- swdd->ReadRGBAPixels = read_rgba_pixels_BGR;
+ rb->GetRow = get_row_BGR;
+ rb->GetValues = get_values_BGR;
+ rb->PutRow = put_row_BGR;
+ rb->PutMonoRow = put_mono_row_BGR;
+ rb->PutValues = put_values_BGR;
+ rb->PutMonoValues = put_mono_values_BGR;
}
#if CHAN_TYPE == GL_UNSIGNED_BYTE
else if (osmesa->format == OSMESA_RGB_565) {
- swdd->WriteRGBASpan = write_rgba_span_RGB_565;
- swdd->WriteRGBSpan = write_rgb_span_RGB_565;
- swdd->WriteMonoRGBASpan = write_monorgba_span_RGB_565;
- swdd->WriteRGBAPixels = write_rgba_pixels_RGB_565;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGB_565;
- swdd->ReadRGBASpan = read_rgba_span_RGB_565;
- swdd->ReadRGBAPixels = read_rgba_pixels_RGB_565;
+ rb->GetRow = get_row_RGB_565;
+ rb->GetValues = get_values_RGB_565;
+ rb->PutRow = put_row_RGB_565;
+ rb->PutMonoRow = put_mono_row_RGB_565;
+ rb->PutValues = put_values_RGB_565;
+ rb->PutMonoValues = put_mono_values_RGB_565;
}
#endif
- else if (osmesa->format == OSMESA_RGBA) {
- swdd->WriteRGBASpan = write_rgba_span_RGBA;
- swdd->WriteRGBSpan = write_rgb_span_RGBA;
- swdd->WriteMonoRGBASpan = write_monorgba_span_RGBA;
- swdd->WriteRGBAPixels = write_rgba_pixels_RGBA;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_RGBA;
- swdd->ReadRGBASpan = read_rgba_span_RGBA;
- swdd->ReadRGBAPixels = read_rgba_pixels_RGBA;
- }
- else if (osmesa->format == OSMESA_BGRA) {
- swdd->WriteRGBASpan = write_rgba_span_BGRA;
- swdd->WriteRGBSpan = write_rgb_span_BGRA;
- swdd->WriteMonoRGBASpan = write_monorgba_span_BGRA;
- swdd->WriteRGBAPixels = write_rgba_pixels_BGRA;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_BGRA;
- swdd->ReadRGBASpan = read_rgba_span_BGRA;
- swdd->ReadRGBAPixels = read_rgba_pixels_BGRA;
- }
- else if (osmesa->format == OSMESA_ARGB) {
- swdd->WriteRGBASpan = write_rgba_span_ARGB;
- swdd->WriteRGBSpan = write_rgb_span_ARGB;
- swdd->WriteMonoRGBASpan = write_monorgba_span_ARGB;
- swdd->WriteRGBAPixels = write_rgba_pixels_ARGB;
- swdd->WriteMonoRGBAPixels = write_monorgba_pixels_ARGB;
- swdd->ReadRGBASpan = read_rgba_span_ARGB;
- swdd->ReadRGBAPixels = read_rgba_pixels_ARGB;
- }
else if (osmesa->format == OSMESA_COLOR_INDEX) {
- swdd->WriteCI32Span = write_index32_span_CI;
- swdd->WriteCI8Span = write_index8_span_CI;
- swdd->WriteMonoCISpan = write_monoindex_span_CI;
- swdd->WriteCI32Pixels = write_index_pixels_CI;
- swdd->WriteMonoCIPixels = write_monoindex_pixels_CI;
- swdd->ReadCI32Span = read_index_span_CI;
- swdd->ReadCI32Pixels = read_index_pixels_CI;
+ rb->GetRow = get_row_CI;
+ rb->GetValues = get_values_CI;
+ rb->PutRow = put_row_CI;
+ rb->PutMonoRow = put_mono_row_CI;
+ rb->PutValues = put_values_CI;
+ rb->PutMonoValues = put_mono_values_CI;
}
else {
- _mesa_problem(ctx, "bad pixel format in osmesa_update_state!\n");
+ _mesa_problem(ctx, "bad pixel format in osmesa renderbuffer_storage");
}
- /* Extend the software rasterizer with our optimized line and triangle
- * drawin functions.
- */
- swrast->choose_line = osmesa_choose_line;
- swrast->choose_triangle = osmesa_choose_triangle;
- swrast->invalidate_line |= OSMESA_NEW_LINE;
- swrast->invalidate_triangle |= OSMESA_NEW_TRIANGLE;
+ return GL_TRUE;
}
+/**
+ * Allocate a new renderbuffer tpo describe the user-provided color buffer.
+ */
+static struct gl_renderbuffer *
+new_osmesa_renderbuffer(GLenum format)
+{
+ struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer);
+ if (rb) {
+ const GLuint name = 0;
+ _mesa_init_renderbuffer(rb, name);
+
+ rb->Delete = osmesa_delete_renderbuffer;
+ rb->AllocStorage = osmesa_renderbuffer_storage;
+
+ if (format == OSMESA_COLOR_INDEX) {
+ rb->_BaseFormat = GL_COLOR_INDEX;
+ rb->InternalFormat = GL_COLOR_INDEX;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ }
+ else {
+ rb->_BaseFormat = GL_RGBA;
+ rb->InternalFormat = GL_RGBA;
+ rb->DataType = CHAN_TYPE;
+ }
+ }
+ return rb;
+}
+
/**********************************************************************/
@@ -901,7 +873,6 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
return NULL;
}
-
osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context);
if (osmesa) {
osmesa->gl_visual = _mesa_create_visual( rgbmode,
@@ -931,7 +902,6 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
functions.GetString = get_string;
functions.UpdateState = osmesa_update_state;
functions.GetBufferSize = get_buffer_size;
- functions.Clear = clear;
if (!_mesa_initialize_context(&osmesa->mesa,
osmesa->gl_visual,
@@ -948,18 +918,24 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
_mesa_enable_1_4_extensions(&(osmesa->mesa));
_mesa_enable_1_5_extensions(&(osmesa->mesa));
- osmesa->gl_buffer = _mesa_create_framebuffer( osmesa->gl_visual,
- (GLboolean) ( osmesa->gl_visual->depthBits > 0 ),
- (GLboolean) ( osmesa->gl_visual->stencilBits > 0 ),
- (GLboolean) ( osmesa->gl_visual->accumRedBits > 0 ),
- GL_FALSE /* s/w alpha */ );
-
+ osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual);
if (!osmesa->gl_buffer) {
_mesa_destroy_visual( osmesa->gl_visual );
_mesa_free_context_data( &osmesa->mesa );
FREE(osmesa);
return NULL;
}
+
+ _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT,
+ new_osmesa_renderbuffer(format));
+ _mesa_add_soft_renderbuffers(osmesa->gl_buffer,
+ GL_FALSE, /* color */
+ osmesa->gl_visual->haveDepthBuffer,
+ osmesa->gl_visual->haveStencilBuffer,
+ osmesa->gl_visual->haveAccumBuffer,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */ );
+
osmesa->format = format;
osmesa->buffer = NULL;
osmesa->width = 0;
@@ -979,6 +955,9 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
/* Initialize the software rasterizer and helper modules. */
{
GLcontext *ctx = &osmesa->mesa;
+ SWcontext *swrast;
+ struct swrast_device_driver *swdd;
+ TNLcontext *tnl;
if (!_swrast_CreateContext( ctx ) ||
!_ac_CreateContext( ctx ) ||
@@ -991,7 +970,31 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
}
_swsetup_Wakeup( ctx );
- hook_in_driver_functions( ctx );
+
+ /* use default TCL pipeline */
+ tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
+
+ swdd = _swrast_GetDeviceDriverReference( ctx );
+ swdd->SetBuffer = set_buffer;
+
+ /* no longer used */
+ swdd->WriteRGBASpan = NULL;
+ swdd->WriteRGBSpan = NULL;
+ swdd->WriteMonoRGBASpan = NULL;
+ swdd->WriteRGBAPixels = NULL;
+ swdd->WriteMonoRGBAPixels = NULL;
+ swdd->ReadRGBASpan = NULL;
+ swdd->ReadRGBAPixels = NULL;
+
+ /* Extend the software rasterizer with our optimized line and triangle
+ * drawing functions.
+ */
+ swrast = SWRAST_CONTEXT( ctx );
+ swrast->choose_line = osmesa_choose_line;
+ swrast->choose_triangle = osmesa_choose_triangle;
+ swrast->invalidate_line |= OSMESA_NEW_LINE;
+ swrast->invalidate_triangle |= OSMESA_NEW_TRIANGLE;
}
}
return osmesa;
@@ -1117,7 +1120,7 @@ OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
ctx->height = height;
osmesa_update_state( &ctx->mesa, 0 );
- _mesa_make_current( &ctx->mesa, ctx->gl_buffer );
+ _mesa_make_current( &ctx->mesa, ctx->gl_buffer, ctx->gl_buffer );
if (ctx->userRowLength)
ctx->rowlength = ctx->userRowLength;
@@ -1127,7 +1130,10 @@ OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
compute_row_addresses( ctx );
/* this will make ensure we recognize the new buffer size */
+ _mesa_resize_framebuffer(&ctx->mesa, ctx->gl_buffer, width, height);
+#if 00
_mesa_ResizeBuffersMESA();
+#endif
/* Added by Gerk Huisma: */
_tnl_MakeCurrent( &ctx->mesa, ctx->mesa.DrawBuffer,
@@ -1225,7 +1231,13 @@ GLAPI GLboolean GLAPIENTRY
OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
GLint *bytesPerValue, void **buffer )
{
- if ((!c->gl_buffer) || (!c->gl_buffer->DepthBuffer)) {
+ struct gl_renderbuffer *rb = NULL;
+
+ if (c->gl_buffer)
+ rb = c->gl_buffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+
+ if (!rb || !rb->Data) {
+ /*if ((!c->gl_buffer) || (!c->gl_buffer->DepthBuffer)) {*/
*width = 0;
*height = 0;
*bytesPerValue = 0;
@@ -1239,7 +1251,7 @@ OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
*bytesPerValue = sizeof(GLushort);
else
*bytesPerValue = sizeof(GLuint);
- *buffer = c->gl_buffer->DepthBuffer;
+ *buffer = rb->Data;
return GL_TRUE;
}
}
diff --git a/src/mesa/drivers/svga/svgamesa8.c b/src/mesa/drivers/svga/svgamesa8.c
index 29fd4070b3..fd880ef85a 100644
--- a/src/mesa/drivers/svga/svgamesa8.c
+++ b/src/mesa/drivers/svga/svgamesa8.c
@@ -1,4 +1,4 @@
-/* $Id: svgamesa8.c,v 1.8 2001/02/06 00:03:48 brianp Exp $ */
+/* $Id: svgamesa8.c,v 1.9 2005/05/04 20:11:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -98,7 +98,8 @@ void __clear8( GLcontext *ctx, GLbitfield mask, GLboolean all,
_swrast_Clear( ctx, mask, all, x, y, width, height );
}
-void __write_ci32_span8( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+void __write_ci32_span8( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLuint index[], const GLubyte mask[] )
{
int i;
@@ -109,7 +110,8 @@ void __write_ci32_span8( const GLcontext *ctx, GLuint n, GLint x, GLint y,
}
}
-void __write_ci8_span8( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+void __write_ci8_span8( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLubyte index[], const GLubyte mask[] )
{
int i;
@@ -121,8 +123,8 @@ void __write_ci8_span8( const GLcontext *ctx, GLuint n, GLint x, GLint y,
}
}
-void __write_mono_ci_span8( const GLcontext *ctx, GLuint n,
- GLint x, GLint y,
+void __write_mono_ci_span8( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
GLuint colorIndex, const GLubyte mask[] )
{
int i;
@@ -133,7 +135,7 @@ void __write_mono_ci_span8( const GLcontext *ctx, GLuint n,
}
}
-void __read_ci32_span8( const GLcontext *ctx,
+void __read_ci32_span8( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y, GLuint index[])
{
int i;
@@ -142,7 +144,7 @@ void __read_ci32_span8( const GLcontext *ctx,
}
}
-void __write_ci32_pixels8( const GLcontext *ctx,
+void __write_ci32_pixels8( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
const GLuint index[], const GLubyte mask[] )
{
@@ -155,8 +157,8 @@ void __write_ci32_pixels8( const GLcontext *ctx,
}
-void __write_mono_ci_pixels8( const GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
+void __write_mono_ci_pixels8( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
GLuint colorIndex, const GLubyte mask[] )
{
int i;
@@ -167,7 +169,7 @@ void __write_mono_ci_pixels8( const GLcontext *ctx, GLuint n,
}
}
-void __read_ci32_pixels8( const GLcontext *ctx,
+void __read_ci32_pixels8( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
GLuint index[], const GLubyte mask[] )
{
diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index b0cb52846a..e4dbc5acd9 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -417,11 +417,8 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo )
GL_TRUE, /* double */
GL_FALSE, /* stereo */
zBits,
- 8 * sizeof(GLstencil),
- 0 * sizeof(GLaccum), /* r */
- 0 * sizeof(GLaccum), /* g */
- 0 * sizeof(GLaccum), /* b */
- 0 * sizeof(GLaccum), /* a */
+ STENCIL_BITS,
+ 0, 0, 0, 0, /* accum bits */
0, /* level */
0 /* numAux */
);
@@ -436,11 +433,11 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo )
GL_TRUE, /* double */
GL_FALSE, /* stereo */
zBits,
- 8 * sizeof(GLstencil),
- 8 * sizeof(GLaccum), /* r */
- 8 * sizeof(GLaccum), /* g */
- 8 * sizeof(GLaccum), /* b */
- 8 * sizeof(GLaccum), /* a */
+ STENCIL_BITS,
+ ACCUM_BITS, /* r */
+ ACCUM_BITS, /* g */
+ ACCUM_BITS, /* b */
+ ACCUM_BITS, /* a */
0, /* level */
0 /* numAux */
);
@@ -1231,6 +1228,11 @@ static XVisualInfo *
Fake_glXChooseVisual( Display *dpy, int screen, int *list )
{
XMesaVisual xmvis = choose_visual(dpy, screen, list, GL_FALSE);
+ {
+ int x;
+ glXGetConfig(dpy, xmvis->vishandle, GLX_RED_SIZE, &x);
+ }
+
if (xmvis) {
#if 0
return xmvis->vishandle;
@@ -1418,7 +1420,7 @@ Fake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
if (!b) {
return 0;
}
- return b->frontbuffer;
+ return b->frontxrb->pixmap;
}
@@ -1444,7 +1446,7 @@ Fake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
if (!b) {
return 0;
}
- return b->frontbuffer;
+ return b->frontxrb->pixmap;
}
@@ -2096,7 +2098,7 @@ Fake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
/* A GLXPbuffer handle must be an X Drawable because that's what
* glXMakeCurrent takes.
*/
- return (GLXPbuffer) xmbuf->frontbuffer;
+ return (GLXPbuffer) xmbuf->frontxrb->pixmap;
}
@@ -2357,7 +2359,7 @@ Fake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixm
{
XMesaVisual xmvis = (XMesaVisual) config;
XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0);
- return xmbuf->frontbuffer; /* need to return an X ID */
+ return xmbuf->frontxrb->pixmap; /* need to return an X ID */
}
@@ -2451,7 +2453,7 @@ Fake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
/* A GLXPbuffer handle must be an X Drawable because that's what
* glXMakeCurrent takes.
*/
- return (GLXPbuffer) xmbuf->frontbuffer;
+ return (GLXPbuffer) xmbuf->frontxrb->pixmap;
}
diff --git a/src/mesa/drivers/x11/glxheader.h b/src/mesa/drivers/x11/glxheader.h
index b583400389..42637f4c14 100644
--- a/src/mesa/drivers/x11/glxheader.h
+++ b/src/mesa/drivers/x11/glxheader.h
@@ -67,5 +67,4 @@ struct timespec;
struct itimerspec;
-
#endif /*GLX_HEADER*/
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 0e1f5c58ed..99beb5c501 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -65,11 +65,13 @@
#include "xmesaP.h"
#include "context.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "glthread.h"
#include "imports.h"
#include "matrix.h"
#include "mtypes.h"
#include "macros.h"
+#include "renderbuffer.h"
#include "texformat.h"
#include "texobj.h"
#include "texstore.h"
@@ -278,7 +280,7 @@ static int bits_per_pixel( XMesaVisual xmv )
/* grab the bits/pixel value */
bitsPerPixel = img->bits_per_pixel;
/* free the XImage */
- FREE( img->data );
+ _mesa_free( img->data );
img->data = NULL;
XMesaDestroyImage( img );
return bitsPerPixel;
@@ -343,18 +345,7 @@ alloc_xmesa_buffer(XMesaVisual vis, BufferType type, XMesaColormap cmap)
b->type = type;
b->cmap = cmap;
- _mesa_initialize_framebuffer(&b->mesa_buffer,
- &vis->mesa_visual,
- vis->mesa_visual.depthBits > 0,
- vis->mesa_visual.stencilBits > 0,
- vis->mesa_visual.accumRedBits +
- vis->mesa_visual.accumGreenBits +
- vis->mesa_visual.accumBlueBits > 0,
- vis->mesa_visual.alphaBits > 0
- /*v->mesa_visual.numAuxBuffers > 0*/ );
- /* XXX hack */
- if (vis->mesa_visual.numAuxBuffers > 0)
- b->mesa_buffer.UseSoftwareAuxBuffers = GL_TRUE;
+ _mesa_initialize_framebuffer(&b->mesa_buffer, &vis->mesa_visual);
/* determine back buffer implementation */
if (vis->mesa_visual.doubleBufferMode) {
@@ -369,6 +360,30 @@ alloc_xmesa_buffer(XMesaVisual vis, BufferType type, XMesaColormap cmap)
b->db_state = 0;
}
+ /* Allocate the framebuffer's renderbuffers */
+ assert(!b->mesa_buffer.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+ assert(!b->mesa_buffer.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+
+ /* front renderbuffer */
+ b->frontxrb = xmesa_new_renderbuffer(NULL, 0, vis->mesa_visual.rgbMode);
+ _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_FRONT_LEFT,
+ &b->frontxrb->Base);
+
+ /* back renderbuffer */
+ if (vis->mesa_visual.doubleBufferMode) {
+ b->backxrb =xmesa_new_renderbuffer(NULL, 0, vis->mesa_visual.rgbMode);
+ _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_BACK_LEFT,
+ &b->backxrb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(&b->mesa_buffer,
+ GL_FALSE, /* color */
+ vis->mesa_visual.haveDepthBuffer,
+ vis->mesa_visual.haveStencilBuffer,
+ vis->mesa_visual.haveAccumBuffer,
+ vis->mesa_visual.alphaBits > 0,
+ vis->mesa_visual.numAuxBuffers > 0 );
+
/* insert into linked list */
b->Next = XMesaBufferList;
XMesaBufferList = b;
@@ -426,7 +441,11 @@ static void free_xmesa_buffer(int client, XMesaBuffer buffer)
}
_mesa_free_framebuffer_data(&buffer->mesa_buffer);
- FREE(buffer);
+ /* delete front/back renderbuffers */
+ buffer->frontxrb->Base.Delete(&(buffer->frontxrb->Base));
+ if (buffer->backxrb)
+ buffer->backxrb->Base.Delete(&(buffer->backxrb->Base));
+ _mesa_free(buffer);
return;
}
@@ -473,12 +492,13 @@ static int bitcount( unsigned long n )
-/*
+/**
* Allocate a shared memory XImage back buffer for the given XMesaBuffer.
* Return: GL_TRUE if success, GL_FALSE if error
*/
#ifndef XFree86Server
-static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
+static GLboolean
+alloc_shm_back_buffer(XMesaBuffer b, GLuint width, GLuint height)
{
#ifdef USE_XSHM
/*
@@ -490,40 +510,40 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
GC gc;
int (*old_handler)( XMesaDisplay *, XErrorEvent * );
- if (b->mesa_buffer.Width == 0 || b->mesa_buffer.Height == 0) {
+ if (width == 0 || height == 0) {
/* this will be true the first time we're called on 'b' */
return GL_FALSE;
}
- b->backimage = XShmCreateImage(b->xm_visual->display,
- b->xm_visual->visinfo->visual,
- b->xm_visual->visinfo->depth,
- ZPixmap, NULL, &b->shminfo,
- b->mesa_buffer.Width, b->mesa_buffer.Height);
- if (b->backimage == NULL) {
+ b->backxrb->ximage = XShmCreateImage(b->xm_visual->display,
+ b->xm_visual->visinfo->visual,
+ b->xm_visual->visinfo->depth,
+ ZPixmap, NULL, &b->shminfo,
+ width, height);
+ if (b->backxrb->ximage == NULL) {
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (XShmCreateImage), disabling.");
b->shm = 0;
return GL_FALSE;
}
- b->shminfo.shmid = shmget( IPC_PRIVATE, b->backimage->bytes_per_line
- * b->backimage->height, IPC_CREAT|0777 );
+ b->shminfo.shmid = shmget( IPC_PRIVATE, b->backxrb->ximage->bytes_per_line
+ * b->backxrb->ximage->height, IPC_CREAT|0777 );
if (b->shminfo.shmid < 0) {
_mesa_warning(NULL, "shmget failed while allocating back buffer");
- XDestroyImage( b->backimage );
- b->backimage = NULL;
+ XDestroyImage( b->backxrb->ximage );
+ b->backxrb->ximage = NULL;
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmget), disabling.");
b->shm = 0;
return GL_FALSE;
}
- b->shminfo.shmaddr = b->backimage->data
+ b->shminfo.shmaddr = b->backxrb->ximage->data
= (char*)shmat( b->shminfo.shmid, 0, 0 );
if (b->shminfo.shmaddr == (char *) -1) {
_mesa_warning(NULL, "shmat() failed while allocating back buffer");
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmctl( b->shminfo.shmid, IPC_RMID, 0 );
- b->backimage = NULL;
+ b->backxrb->ximage = NULL;
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmat), disabling.");
b->shm = 0;
return GL_FALSE;
@@ -540,10 +560,10 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
/* we are on a remote display, this error is normal, don't print it */
XFlush( b->xm_visual->display );
mesaXErrorFlag = 0;
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmdt( b->shminfo.shmaddr );
shmctl( b->shminfo.shmid, IPC_RMID, 0 );
- b->backimage = NULL;
+ b->backxrb->ximage = NULL;
b->shm = 0;
(void) XSetErrorHandler( old_handler );
return GL_FALSE;
@@ -552,43 +572,23 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
shmctl( b->shminfo.shmid, IPC_RMID, 0 ); /* nobody else needs it */
/* Finally, try an XShmPutImage to be really sure the extension works */
- gc = XCreateGC( b->xm_visual->display, b->frontbuffer, 0, NULL );
- XShmPutImage( b->xm_visual->display, b->frontbuffer, gc,
- b->backimage, 0, 0, 0, 0, 1, 1 /*one pixel*/, False );
+ gc = XCreateGC( b->xm_visual->display, b->frontxrb->pixmap, 0, NULL );
+ XShmPutImage( b->xm_visual->display, b->frontxrb->pixmap, gc,
+ b->backxrb->ximage, 0, 0, 0, 0, 1, 1 /*one pixel*/, False );
XSync( b->xm_visual->display, False );
XFreeGC( b->xm_visual->display, gc );
(void) XSetErrorHandler( old_handler );
if (mesaXErrorFlag) {
XFlush( b->xm_visual->display );
mesaXErrorFlag = 0;
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmdt( b->shminfo.shmaddr );
shmctl( b->shminfo.shmid, IPC_RMID, 0 );
- b->backimage = NULL;
+ b->backxrb->ximage = NULL;
b->shm = 0;
return GL_FALSE;
}
- if (b->backimage) {
- int height = b->backimage->height;
- /* Needed by PIXELADDR1 macro */
- b->ximage_width1 = b->backimage->bytes_per_line;
- b->ximage_origin1 = (GLubyte *) b->backimage->data
- + b->ximage_width1 * (height-1);
- /* Needed by PIXELADDR2 macro */
- b->ximage_width2 = b->backimage->bytes_per_line / 2;
- b->ximage_origin2 = (GLushort *) b->backimage->data
- + b->ximage_width2 * (height-1);
- /* Needed by PIXELADDR3 macro */
- b->ximage_width3 = b->backimage->bytes_per_line;
- b->ximage_origin3 = (GLubyte *) b->backimage->data
- + b->ximage_width3 * (height-1);
- /* Needed by PIXELADDR4 macro */
- b->ximage_width4 = b->backimage->width;
- b->ximage_origin4 = (GLuint *) b->backimage->data
- + b->ximage_width4 * (height-1);
- }
-
return GL_TRUE;
#else
/* Can't compile XSHM support */
@@ -603,77 +603,73 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
* Setup an off-screen pixmap or Ximage to use as the back buffer.
* Input: b - the X/Mesa buffer
*/
-void xmesa_alloc_back_buffer( XMesaBuffer b )
+void
+xmesa_alloc_back_buffer( XMesaBuffer b, GLuint width, GLuint height )
{
- if (b->db_state==BACK_XIMAGE) {
- /* Deallocate the old backimage, if any */
- if (b->backimage) {
+ if (width == 0 || height == 0)
+ return;
+
+ if (b->db_state == BACK_XIMAGE) {
+ /* Deallocate the old backxrb->ximage, if any */
+ if (b->backxrb->ximage) {
#if defined(USE_XSHM) && !defined(XFree86Server)
if (b->shm) {
XShmDetach( b->xm_visual->display, &b->shminfo );
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmdt( b->shminfo.shmaddr );
}
else
#endif
- XMesaDestroyImage( b->backimage );
- b->backimage = NULL;
+ XMesaDestroyImage( b->backxrb->ximage );
+ b->backxrb->ximage = NULL;
}
/* Allocate new back buffer */
#ifdef XFree86Server
{
/* Allocate a regular XImage for the back buffer. */
- b->backimage = XMesaCreateImage(b->xm_visual->BitsPerPixel,
- b->mesa_buffer.Width,
- b->mesa_buffer.Height, NULL);
+ b->backxrb->ximage = XMesaCreateImage(b->xm_visual->BitsPerPixel,
+ width, height, NULL);
#else
- if (b->shm==0 || alloc_shm_back_buffer(b)==GL_FALSE) {
+ if (b->shm == 0 || !alloc_shm_back_buffer(b, width, height)) {
/* Allocate a regular XImage for the back buffer. */
- b->backimage = XCreateImage( b->xm_visual->display,
+ b->backxrb->ximage = XCreateImage( b->xm_visual->display,
b->xm_visual->visinfo->visual,
GET_VISUAL_DEPTH(b->xm_visual),
ZPixmap, 0, /* format, offset */
NULL,
- b->mesa_buffer.Width,
- b->mesa_buffer.Height,
+ width, height,
8, 0 ); /* pad, bytes_per_line */
#endif
- if (!b->backimage) {
+ if (!b->backxrb->ximage) {
_mesa_warning(NULL, "alloc_back_buffer: XCreateImage failed.");
}
- b->backimage->data = (char *) MALLOC( b->backimage->height
- * b->backimage->bytes_per_line );
- if (!b->backimage->data) {
+ b->backxrb->ximage->data = (char *) MALLOC( b->backxrb->ximage->height
+ * b->backxrb->ximage->bytes_per_line );
+ if (!b->backxrb->ximage->data) {
_mesa_warning(NULL, "alloc_back_buffer: MALLOC failed.");
- XMesaDestroyImage( b->backimage );
- b->backimage = NULL;
+ XMesaDestroyImage( b->backxrb->ximage );
+ b->backxrb->ximage = NULL;
}
}
- b->backpixmap = None;
+ b->backxrb->pixmap = None;
+ b->backxrb->ximage = b->backxrb->ximage;
}
else if (b->db_state==BACK_PIXMAP) {
- XMesaPixmap old_pixmap = b->backpixmap;
- int width = b->mesa_buffer.Width, height = b->mesa_buffer.Height;
-
if (!width)
width = 1;
if (!height)
height = 1;
/* Free the old back pixmap */
- if (b->backpixmap) {
- XMesaFreePixmap( b->xm_visual->display, b->backpixmap );
+ if (b->backxrb->pixmap) {
+ XMesaFreePixmap( b->xm_visual->display, b->backxrb->pixmap );
}
/* Allocate new back pixmap */
- b->backpixmap = XMesaCreatePixmap( b->xm_visual->display, b->frontbuffer,
+ b->backxrb->pixmap = XMesaCreatePixmap( b->xm_visual->display, b->frontxrb->pixmap,
width, height,
GET_VISUAL_DEPTH(b->xm_visual) );
- b->backimage = NULL;
- /* update other references to backpixmap */
- if (b->buffer==(XMesaDrawable)old_pixmap) {
- b->buffer = (XMesaDrawable)b->backpixmap;
- }
+ b->backxrb->ximage = NULL;
}
}
@@ -747,7 +743,7 @@ noFaultXAllocColor( int client,
|| prevCmapSize != cmapSize || !ctable) {
/* free previously cached color table */
if (ctable)
- FREE(ctable);
+ _mesa_free(ctable);
/* Get the color table from X */
ctable = (XMesaColor *) MALLOC(cmapSize * sizeof(XMesaColor));
assert(ctable);
@@ -803,8 +799,8 @@ noFaultXAllocColor( int client,
*alloced = 0;
}
#ifdef XFree86Server
- FREE(ppixIn);
- FREE(ctable);
+ _mesa_free(ppixIn);
+ _mesa_free(ctable);
#else
/* don't free table, save it for next time */
#endif
@@ -1208,6 +1204,9 @@ static GLboolean initialize_visual_and_buffer( int client,
XMesaDrawable window,
XMesaColormap cmap )
{
+#if NEW_RENDERBUFFER
+ struct xmesa_renderbuffer *front_xrb, *back_xrb;
+#endif
#ifndef XFree86Server
XGCValues gcvalues;
#endif
@@ -1216,6 +1215,16 @@ static GLboolean initialize_visual_and_buffer( int client,
assert(b->xm_visual == v);
}
+#if NEW_RENDERBUFFER
+ if (b) {
+ front_xrb = b->frontxrb;
+ back_xrb = b->backxrb;
+ }
+ else {
+ front_xrb = back_xrb = NULL;
+ }
+#endif
+
/* Save true bits/pixel */
v->BitsPerPixel = bits_per_pixel(v);
assert(v->BitsPerPixel > 0);
@@ -1280,7 +1289,7 @@ static GLboolean initialize_visual_and_buffer( int client,
if (b && window) {
/* Do window-specific initializations */
- b->frontbuffer = window;
+ b->frontxrb->pixmap = window;
/* Setup for single/double buffering */
if (v->mesa_visual.doubleBufferMode) {
@@ -1288,17 +1297,7 @@ static GLboolean initialize_visual_and_buffer( int client,
#ifndef XFree86Server
b->shm = check_for_xshm( v->display );
#endif
- xmesa_alloc_back_buffer( b );
- if (b->db_state==BACK_PIXMAP) {
- b->buffer = (XMesaDrawable)b->backpixmap;
- }
- else {
- b->buffer = XIMAGE;
- }
- }
- else {
- /* Single Buffered */
- b->buffer = b->frontbuffer;
+ xmesa_alloc_back_buffer(b, b->mesa_buffer.Width, b->mesa_buffer.Height);
}
/* X11 graphics contexts */
@@ -1340,7 +1339,7 @@ static GLboolean initialize_visual_and_buffer( int client,
* Initialize whole stuff
* Patch contributed by Jacques Leroy March 8, 1998.
*/
- if (v->hpcr_clear_flag && b->buffer!=XIMAGE) {
+ if (v->hpcr_clear_flag && back_xrb->pixmap) {
int i;
for (i=0; i<16; i++)
{
@@ -1380,9 +1379,11 @@ static GLboolean initialize_visual_and_buffer( int client,
* Convert an RGBA color to a pixel value.
*/
unsigned long
-xmesa_color_to_pixel( XMesaContext xmesa, GLubyte r, GLubyte g, GLubyte b, GLubyte a,
- GLuint pixelFormat)
+xmesa_color_to_pixel(GLcontext *ctx,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a,
+ GLuint pixelFormat)
{
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
switch (pixelFormat) {
case PF_Index:
return 0;
@@ -1428,7 +1429,7 @@ xmesa_color_to_pixel( XMesaContext xmesa, GLubyte r, GLubyte g, GLubyte b, GLuby
return p;
}
default:
- _mesa_problem(NULL, "Bad pixel format in xmesa_color_to_pixel");
+ _mesa_problem(ctx, "Bad pixel format in xmesa_color_to_pixel");
}
return 0;
}
@@ -1536,14 +1537,14 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
*/
v->display = display;
- /* Save a copy of the XVisualInfo struct because the user may XFREE()
+ /* Save a copy of the XVisualInfo struct because the user may X_mesa_free()
* the struct but we may need some of the information contained in it
* at a later time.
*/
#ifndef XFree86Server
v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo));
if(!v->visinfo) {
- FREE(v);
+ _mesa_free(v);
return NULL;
}
MEMCPY(v->visinfo, visinfo, sizeof(*visinfo));
@@ -1647,9 +1648,9 @@ void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v )
void XMesaDestroyVisual( XMesaVisual v )
{
#ifndef XFree86Server
- FREE(v->visinfo);
+ _mesa_free(v->visinfo);
#endif
- FREE(v);
+ _mesa_free(v);
}
@@ -1687,7 +1688,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual,
share_list ? &(share_list->mesa) : (GLcontext *) NULL,
&functions, (void *) c)) {
- FREE(c);
+ _mesa_free(c);
return NULL;
}
@@ -1707,8 +1708,6 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
/* finish up xmesa context initializations */
c->swapbytes = CHECK_BYTE_ORDER(v) ? GL_FALSE : GL_TRUE;
c->xm_visual = v;
- c->xm_draw_buffer = NULL; /* set later by XMesaMakeCurrent */
- c->xm_read_buffer = NULL; /* set later by XMesaMakeCurrent */
c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */
c->display = v->display;
c->pixelformat = v->dithered_pf; /* Dithering is enabled by default */
@@ -1740,8 +1739,10 @@ void XMesaDestroyContext( XMesaContext c )
{
GLcontext *mesaCtx = &c->mesa;
#ifdef FX
- if (c->xm_draw_buffer && c->xm_buffer->FXctx)
- fxMesaDestroyContext(c->xm_draw_buffer->FXctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(mesaCtx->DrawBuffer);
+
+ if (xmbuf && xmbuf->FXctx)
+ fxMesaDestroyContext(xmbuf->FXctx);
#endif
_swsetup_DestroyContext( mesaCtx );
_swrast_DestroyContext( mesaCtx );
@@ -1864,7 +1865,7 @@ XMesaCreateWindowBuffer2(XMesaVisual v, XMesaWindow w, XMesaContext c)
if ((hw == GR_SSTTYPE_VOODOO) || (hw == GR_SSTTYPE_Voodoo2)) {
b->FXctx = fxMesaCreateBestContext(0, b->mesa_buffer.Width,
b->mesa_buffer.Height, attribs);
- if ((v->undithered_pf!=PF_Index) && (b->backimage)) {
+ if ((v->undithered_pf!=PF_Index) && (b->backxrb->ximage)) {
b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE;
if (b->FXctx && (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')) {
b->FXwindowHack = GL_TRUE;
@@ -1989,27 +1990,27 @@ void XMesaDestroyBuffer( XMesaBuffer b )
int client = 0;
#ifdef XFree86Server
- if (b->frontbuffer)
- client = CLIENT_ID(b->frontbuffer->id);
+ if (b->frontxrb->pixmap)
+ client = CLIENT_ID(b->frontxrb->pixmap->id);
#endif
if (b->gc) XMesaFreeGC( b->xm_visual->display, b->gc );
if (b->cleargc) XMesaFreeGC( b->xm_visual->display, b->cleargc );
if (b->swapgc) XMesaFreeGC( b->xm_visual->display, b->swapgc );
- if (b->backimage) {
+ if (b->backxrb->ximage) {
#if defined(USE_XSHM) && !defined(XFree86Server)
if (b->shm) {
XShmDetach( b->xm_visual->display, &b->shminfo );
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmdt( b->shminfo.shmaddr );
}
else
#endif
- XMesaDestroyImage( b->backimage );
+ XMesaDestroyImage( b->backxrb->ximage );
}
- if (b->backpixmap) {
- XMesaFreePixmap( b->xm_visual->display, b->backpixmap );
+ if (b->backxrb->pixmap) {
+ XMesaFreePixmap( b->xm_visual->display, b->backxrb->pixmap );
if (b->xm_visual->hpcr_clear_flag) {
XMesaFreePixmap( b->xm_visual->display,
b->xm_visual->hpcr_clear_pixmap );
@@ -2017,7 +2018,7 @@ void XMesaDestroyBuffer( XMesaBuffer b )
}
}
if (b->rowimage) {
- FREE( b->rowimage->data );
+ _mesa_free( b->rowimage->data );
b->rowimage->data = NULL;
XMesaDestroyImage( b->rowimage );
}
@@ -2050,49 +2051,45 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
if (drawBuffer->FXctx) {
fxMesaMakeCurrent(drawBuffer->FXctx);
- c->xm_draw_buffer = drawBuffer;
- c->xm_read_buffer = readBuffer;
c->xm_buffer = drawBuffer;
return GL_TRUE;
}
#endif
if (&(c->mesa) == _mesa_get_current_context()
- && c->xm_draw_buffer == drawBuffer
- && c->xm_read_buffer == readBuffer
- && c->xm_draw_buffer->wasCurrent) {
+ && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer
+ && c->mesa.ReadBuffer == &readBuffer->mesa_buffer
+ && ((XMesaBuffer) c->mesa.DrawBuffer)->wasCurrent) {
/* same context and buffer, do nothing */
return GL_TRUE;
}
- c->xm_draw_buffer = drawBuffer;
- c->xm_read_buffer = readBuffer;
c->xm_buffer = drawBuffer;
- _mesa_make_current2(&(c->mesa),
- &drawBuffer->mesa_buffer,
- &readBuffer->mesa_buffer);
+ _mesa_make_current(&(c->mesa),
+ &drawBuffer->mesa_buffer,
+ &readBuffer->mesa_buffer);
if (c->xm_visual->mesa_visual.rgbMode) {
/*
* Must recompute and set these pixel values because colormap
* can be different for different windows.
*/
- c->clearpixel = xmesa_color_to_pixel( c,
+ c->clearpixel = xmesa_color_to_pixel( &c->mesa,
c->clearcolor[0],
c->clearcolor[1],
c->clearcolor[2],
c->clearcolor[3],
c->xm_visual->undithered_pf);
- XMesaSetForeground(c->display, c->xm_draw_buffer->cleargc, c->clearpixel);
+ XMesaSetForeground(c->display, drawBuffer->cleargc, c->clearpixel);
}
/* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */
- c->xm_draw_buffer->wasCurrent = GL_TRUE;
+ drawBuffer->wasCurrent = GL_TRUE;
}
else {
/* Detach */
- _mesa_make_current2( NULL, NULL, NULL );
+ _mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
}
@@ -2125,8 +2122,8 @@ XMesaBuffer XMesaGetCurrentBuffer( void )
{
GET_CURRENT_CONTEXT(ctx);
if (ctx) {
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- return xmesa->xm_draw_buffer;
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ return xmbuf;
}
else {
return 0;
@@ -2139,8 +2136,7 @@ XMesaBuffer XMesaGetCurrentReadBuffer( void )
{
GET_CURRENT_CONTEXT(ctx);
if (ctx) {
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- return xmesa->xm_read_buffer;
+ return (XMesaBuffer) (ctx->ReadBuffer);
}
else {
return 0;
@@ -2152,11 +2148,11 @@ GLboolean XMesaForceCurrent(XMesaContext c)
{
if (c) {
if (&(c->mesa) != _mesa_get_current_context()) {
- _mesa_make_current(&(c->mesa), &c->xm_draw_buffer->mesa_buffer);
+ _mesa_make_current(&c->mesa, c->mesa.DrawBuffer, c->mesa.ReadBuffer);
}
}
else {
- _mesa_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
}
@@ -2165,7 +2161,7 @@ GLboolean XMesaForceCurrent(XMesaContext c)
GLboolean XMesaLoseCurrent(XMesaContext c)
{
(void) c;
- _mesa_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
return GL_TRUE;
}
@@ -2193,17 +2189,17 @@ GLboolean XMesaSetFXmode( GLint mode )
* oh, this is sooo wrong: ctx above is
* really an fxMesaContext, not an XMesaContext
*/
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
if (mode == XMESA_FX_WINDOW) {
- if (xmesa->xm_draw_buffer->FXisHackUsable) {
+ if (xmbuf->FXisHackUsable) {
FX_grSstControl(GR_CONTROL_DEACTIVATE);
- xmesa->xm_draw_buffer->FXwindowHack = GL_TRUE;
+ xmbuf->FXwindowHack = GL_TRUE;
return GL_TRUE;
}
}
else if (mode == XMESA_FX_FULLSCREEN) {
FX_grSstControl(GR_CONTROL_ACTIVATE);
- xmesa->xm_draw_buffer->FXwindowHack = GL_FALSE;
+ xmbuf->FXwindowHack = GL_FALSE;
return GL_TRUE;
}
else {
@@ -2235,13 +2231,13 @@ static void FXgetImage( XMesaBuffer b )
XMesaContext xmesa = XMESA_CONTEXT(ctx);
#ifdef XFree86Server
- x = b->frontbuffer->x;
- y = b->frontbuffer->y;
- width = b->frontbuffer->width;
- height = b->frontbuffer->height;
- depth = b->frontbuffer->depth;
+ x = b->frontxrb->pixmap->x;
+ y = b->frontxrb->pixmap->y;
+ width = b->frontxrb->pixmap->width;
+ height = b->frontxrb->pixmap->height;
+ depth = b->frontxrb->pixmap->depth;
#else
- XGetGeometry( b->xm_visual->display, b->frontbuffer,
+ XGetGeometry( b->xm_visual->display, b->frontxrb->pixmap,
&root, &xpos, &ypos, &width, &height, &bw, &depth);
#endif
if (b->mesa_buffer.Width != width || b->mesa_buffer.Height != height) {
@@ -2249,29 +2245,29 @@ static void FXgetImage( XMesaBuffer b )
b->mesa_buffer.Height = MIN2((int)height, b->FXctx->height);
if (b->mesa_buffer.Width & 1)
b->mesa_buffer.Width--; /* prevent odd width */
- xmesa_alloc_back_buffer( b );
+ xmesa_alloc_back_buffer(b, b->mesa_buffer.Width, b->mesa_buffer.Height);
}
/* [dBorca] we're always in the right GR_COLORFORMAT... aren't we? */
/* grLfbWriteColorFormat(GR_COLORFORMAT_ARGB); */
if (b->xm_visual->undithered_pf==PF_5R6G5B) {
/* Special case: 16bpp RGB */
- grLfbReadRegion( GR_BUFFER_FRONTBUFFER, /* src buffer */
+ grLfbReadRegion( GR_BUFFER_FRONTXRB->PIXMAP, /* src buffer */
0, b->FXctx->height - b->mesa_buffer.Height, /*pos*/
b->mesa_buffer.Width, b->mesa_buffer.Height, /* size */
b->mesa_buffer.Width * sizeof(GLushort), /* stride */
- b->backimage->data); /* dest buffer */
+ b->backxrb->ximage->data); /* dest buffer */
}
else if (b->xm_visual->dithered_pf==PF_Dither
&& GET_VISUAL_DEPTH(b->xm_visual)==8) {
/* Special case: 8bpp RGB */
for (y=0;y<b->mesa_buffer.Height;y++) {
- GLubyte *ptr = (GLubyte*) b->backimage->data
- + b->backimage->bytes_per_line * y;
+ GLubyte *ptr = (GLubyte*) b->backxrb->ximage->data
+ + b->backxrb->ximage->bytes_per_line * y;
XDITHER_SETUP(y);
/* read row from 3Dfx frame buffer */
- grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
+ grLfbReadRegion( GR_BUFFER_FRONTXRB->PIXMAP,
0, b->FXctx->height-(b->mesa_buffer.Height-y),
b->mesa_buffer.Width, 1,
0,
@@ -2290,7 +2286,7 @@ static void FXgetImage( XMesaBuffer b )
/* General case: slow! */
for (y=0;y<b->mesa_buffer.Height;y++) {
/* read row from 3Dfx frame buffer */
- grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
+ grLfbReadRegion( GR_BUFFER_FRONTXRB->PIXMAP,
0, b->FXctx->height-(b->mesa_buffer.Height-y),
b->mesa_buffer.Width, 1,
0,
@@ -2298,8 +2294,8 @@ static void FXgetImage( XMesaBuffer b )
/* write to XImage back buffer */
for (x=0;x<b->mesa_buffer.Width;x++) {
- XMesaPutPixel(b->backimage,x,y,
- xmesa_color_to_pixel(xmesa,
+ XMesaPutPixel(b->backxrb->ximage,x,y,
+ xmesa_color_to_pixel(&c->mesa,
(pixbuf[x] & 0xf800) >> 8,
(pixbuf[x] & 0x07e0) >> 3,
(pixbuf[x] & 0x001f) << 3,
@@ -2338,14 +2334,14 @@ void XMesaSwapBuffers( XMesaBuffer b )
return;
}
#endif
- if (b->backimage) {
+ if (b->backxrb->ximage) {
/* Copy Ximage from host's memory to server's window */
#if defined(USE_XSHM) && !defined(XFree86Server)
if (b->shm) {
/*_glthread_LOCK_MUTEX(_xmesa_lock);*/
- XShmPutImage( b->xm_visual->display, b->frontbuffer,
+ XShmPutImage( b->xm_visual->display, b->frontxrb->pixmap,
b->swapgc,
- b->backimage, 0, 0,
+ b->backxrb->ximage, 0, 0,
0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
False );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
@@ -2354,9 +2350,9 @@ void XMesaSwapBuffers( XMesaBuffer b )
#endif
{
/*_glthread_LOCK_MUTEX(_xmesa_lock);*/
- XMesaPutImage( b->xm_visual->display, b->frontbuffer,
+ XMesaPutImage( b->xm_visual->display, b->frontxrb->pixmap,
b->swapgc,
- b->backimage, 0, 0,
+ b->backxrb->ximage, 0, 0,
0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
@@ -2365,8 +2361,8 @@ void XMesaSwapBuffers( XMesaBuffer b )
/* Copy pixmap to window on server */
/*_glthread_LOCK_MUTEX(_xmesa_lock);*/
XMesaCopyArea( b->xm_visual->display,
- b->backpixmap, /* source drawable */
- b->frontbuffer, /* dest. drawable */
+ b->backxrb->pixmap, /* source drawable */
+ b->frontxrb->pixmap, /* dest. drawable */
b->swapgc,
0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
0, 0 /* dest region */
@@ -2405,14 +2401,14 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
return;
}
#endif
- if (b->backimage) {
+ if (b->backxrb->ximage) {
/* Copy Ximage from host's memory to server's window */
#if defined(USE_XSHM) && !defined(XFree86Server)
if (b->shm) {
/* XXX assuming width and height aren't too large! */
- XShmPutImage( b->xm_visual->display, b->frontbuffer,
+ XShmPutImage( b->xm_visual->display, b->frontxrb->pixmap,
b->swapgc,
- b->backimage, x, yTop,
+ b->backxrb->ximage, x, yTop,
x, yTop, width, height, False );
/* wait for finished event??? */
}
@@ -2420,17 +2416,17 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
#endif
{
/* XXX assuming width and height aren't too large! */
- XMesaPutImage( b->xm_visual->display, b->frontbuffer,
+ XMesaPutImage( b->xm_visual->display, b->frontxrb->pixmap,
b->swapgc,
- b->backimage, x, yTop,
+ b->backxrb->ximage, x, yTop,
x, yTop, width, height );
}
}
else {
/* Copy pixmap to window on server */
XMesaCopyArea( b->xm_visual->display,
- b->backpixmap, /* source drawable */
- b->frontbuffer, /* dest. drawable */
+ b->backxrb->pixmap, /* source drawable */
+ b->frontxrb->pixmap, /* dest. drawable */
b->swapgc,
x, yTop, width, height, /* source region */
x, yTop /* dest region */
@@ -2454,8 +2450,8 @@ GLboolean XMesaGetBackBuffer( XMesaBuffer b,
XMesaImage **ximage )
{
if (b->db_state) {
- if (pixmap) *pixmap = b->backpixmap;
- if (ximage) *ximage = b->backimage;
+ if (pixmap) *pixmap = b->backxrb->pixmap;
+ if (ximage) *ximage = b->backxrb->ximage;
return GL_TRUE;
}
else {
@@ -2477,7 +2473,9 @@ GLboolean XMesaGetBackBuffer( XMesaBuffer b,
GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
GLint *bytesPerValue, void **buffer )
{
- if (!b->mesa_buffer.DepthBuffer) {
+ struct gl_renderbuffer *rb
+ = b->mesa_buffer.Attachment[BUFFER_DEPTH].Renderbuffer;
+ if (!rb || !rb->Data) {
*width = 0;
*height = 0;
*bytesPerValue = 0;
@@ -2489,7 +2487,7 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
*height = b->mesa_buffer.Height;
*bytesPerValue = b->mesa_buffer.Visual.depthBits <= 16
? sizeof(GLushort) : sizeof(GLuint);
- *buffer = b->mesa_buffer.DepthBuffer;
+ *buffer = rb->Data;
return GL_TRUE;
}
}
@@ -2528,7 +2526,7 @@ XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy, XMesaDrawable d )
{
XMesaBuffer b;
for (b=XMesaBufferList; b; b=b->Next) {
- if (b->frontbuffer==d && b->display==dpy) {
+ if (b->frontxrb->pixmap==d && b->display==dpy) {
return b;
}
}
@@ -2546,12 +2544,12 @@ void XMesaGarbageCollect( void )
XMesaBuffer b, next;
for (b=XMesaBufferList; b; b=next) {
next = b->Next;
- if (b->display && b->frontbuffer && b->type == WINDOW) {
+ if (b->display && b->frontxrb->pixmap && b->type == WINDOW) {
#ifdef XFree86Server
/* NOT_NEEDED */
#else
XSync(b->display, False);
- if (!window_exists( b->display, b->frontbuffer )) {
+ if (!window_exists( b->display, b->frontxrb->pixmap )) {
/* found a dead window, free the ancillary info */
XMesaDestroyBuffer( b );
}
@@ -2574,6 +2572,7 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
GLfloat red, GLfloat green,
GLfloat blue, GLfloat alpha )
{
+ GLcontext *ctx = &xmesa->mesa;
GLint r = (GLint) (red * 255.0F);
GLint g = (GLint) (green * 255.0F);
GLint b = (GLint) (blue * 255.0F);
@@ -2634,7 +2633,8 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
*/
void XMesaResizeBuffers( XMesaBuffer b )
{
- xmesa_resize_buffers( &(b->mesa_buffer) );
-
+#if OLD_RENDERBUFFER && 0
+ xmesa_resize_buffers(ctx, &(b->mesa_buffer), 0, 0 );
+#endif
}
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
new file mode 100644
index 0000000000..9f481aaba1
--- /dev/null
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -0,0 +1,111 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glxheader.h"
+#include "GL/xmesa.h"
+#include "xmesaP.h"
+#include "imports.h"
+#include "renderbuffer.h"
+
+
+static void
+xmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+ /* XXX this routine should really delete the attached ximage, etc. */
+}
+
+
+/**
+ * Reallocate renderbuffer storage.
+ * This is called when the window's resized. It'll get called once for
+ * the front color renderbuffer and again for the back color renderbuffer.
+ */
+static GLboolean
+xmesa_alloc_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+
+ if (xrb->ximage) {
+ /* Needed by PIXELADDR1 macro */
+ xrb->width1 = xrb->ximage->bytes_per_line;
+ xrb->origin1 = (GLubyte *) xrb->ximage->data + xrb->width1 * (height - 1);
+
+ /* Needed by PIXELADDR2 macro */
+ xrb->width2 = xrb->ximage->bytes_per_line / 2;
+ xrb->origin2 = (GLushort *) xrb->ximage->data + xrb->width2 * (height - 1);
+
+ /* Needed by PIXELADDR3 macro */
+ xrb->width3 = xrb->ximage->bytes_per_line;
+ xrb->origin3 = (GLubyte *) xrb->ximage->data + xrb->width3 * (height - 1);
+
+ /* Needed by PIXELADDR4 macro */
+ xrb->width4 = xrb->ximage->width;
+ xrb->origin4 = (GLuint *) xrb->ximage->data + xrb->width4 * (height - 1);
+ }
+ else {
+ assert(xrb->pixmap);
+ }
+
+ /* for the FLIP macro: */
+ xrb->bottom = height - 1;
+
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+
+ return GL_TRUE;
+}
+
+
+struct xmesa_renderbuffer *
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode)
+{
+ struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
+ if (xrb) {
+ GLuint name = 0;
+ _mesa_init_renderbuffer(&xrb->Base, name);
+
+ xrb->Base.Delete = xmesa_delete_renderbuffer;
+ xrb->Base.AllocStorage = xmesa_alloc_storage;
+
+ if (rgbMode) {
+ xrb->Base.InternalFormat = GL_RGBA;
+ xrb->Base._BaseFormat = GL_RGBA;
+ xrb->Base.DataType = GL_UNSIGNED_BYTE;
+ }
+ else {
+ xrb->Base.InternalFormat = GL_COLOR_INDEX;
+ xrb->Base._BaseFormat = GL_COLOR_INDEX;
+ xrb->Base.DataType = GL_UNSIGNED_INT;
+ }
+ xrb->Base.ComponentSizes[0] = 0; /* XXX fix? */
+ }
+ return xrb;
+}
+
+
+
+
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index 0588694ace..f9eb877db9 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -31,6 +31,7 @@
#include "depth.h"
#include "drawpix.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "macros.h"
#include "image.h"
#include "imports.h"
@@ -43,9 +44,7 @@
#include "xmesaP.h"
#include "array_cache/acache.h"
#include "swrast/swrast.h"
-#include "swrast/s_auxbuffer.h"
#include "swrast/s_context.h"
-#include "swrast/s_alphabuf.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
@@ -106,8 +105,8 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
unsigned int winwidth, winheight;
#ifdef XFree86Server
/* XFree86 GLX renderer */
- winwidth = MIN2(xmBuffer->frontbuffer->width, MAX_WIDTH);
- winheight = MIN2(xmBuffer->frontbuffer->height, MAX_HEIGHT);
+ winwidth = MIN2(xmBuffer->frontxrb->pixmap->width, MAX_WIDTH);
+ winheight = MIN2(xmBuffer->frontxrb->pixmap->height, MAX_HEIGHT);
#else
Window root;
int winx, winy;
@@ -115,7 +114,7 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
_glthread_LOCK_MUTEX(_xmesa_lock);
XSync(xmBuffer->xm_visual->display, 0); /* added for Chromium */
- XGetGeometry( xmBuffer->xm_visual->display, xmBuffer->frontbuffer, &root,
+ XGetGeometry( xmBuffer->xm_visual->display, xmBuffer->frontxrb->pixmap, &root,
&winx, &winy, &winwidth, &winheight, &bw, &d );
_glthread_UNLOCK_MUTEX(_xmesa_lock);
#endif
@@ -152,29 +151,36 @@ finish_or_flush( GLcontext *ctx )
void
xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
{
+#if 000
/* We can make this cast since the XMesaBuffer wraps GLframebuffer.
* GLframebuffer is the first member in a XMesaBuffer struct.
*/
XMesaBuffer target = (XMesaBuffer) buffer;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+#if NEW_RENDERBUFFER
+ if (buffer->Name != 0)
+ return;
+#endif
+
/* This assignment tells the span/point/line/triangle functions
* which XMesaBuffer to use.
*/
- xmesa->xm_buffer = target;
+ /* xmesa->xm_buffer = target;*/
/*
* Now determine front vs back color buffer.
*/
- if (bufferBit == DD_FRONT_LEFT_BIT) {
- target->buffer = target->frontbuffer;
+ if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
+ target->buffer = target->frontxrb->pixmap;
+ printf("set get/put!\n");
xmesa_update_span_funcs(ctx);
}
- else if (bufferBit == DD_BACK_LEFT_BIT) {
+ else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
ASSERT(target->db_state);
- if (target->backpixmap) {
+ if (target->backxrb->pixmap) {
/* back buffer is a pixmap */
- target->buffer = (XMesaDrawable) target->backpixmap;
+ target->buffer = (XMesaDrawable) target->backxrb->pixmap;
}
else if (target->backimage) {
/* back buffer is an XImage */
@@ -182,17 +188,19 @@ xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
}
else {
/* No back buffer!!!! Must be out of memory, use front buffer */
- target->buffer = target->frontbuffer;
+ target->buffer = target->frontxrb->pixmap;
}
+ printf("set get/put!\n");
xmesa_update_span_funcs(ctx);
}
- else if (bufferBit & (DD_AUX0_BIT | DD_AUX1_BIT | DD_AUX2_BIT | DD_AUX3_BIT)) {
- _swrast_use_aux_buffer(ctx, buffer, bufferBit);
+ else if (bufferBit & (BUFFER_BIT_AUX0 | BUFFER_BIT_AUX1 | BUFFER_BIT_AUX2 | BUFFER_BIT_AUX3)) {
+ /*_swrast_use_aux_buffer(ctx, buffer, bufferBit);*/
}
else {
_mesa_problem(ctx, "invalid buffer 0x%x in set_buffer() in xm_dd.c");
return;
}
+#endif
}
@@ -200,31 +208,37 @@ xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
static void
clear_index( GLcontext *ctx, GLuint index )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- xmesa->clearpixel = (unsigned long) index;
- XMesaSetForeground( xmesa->display, xmesa->xm_draw_buffer->cleargc,
- (unsigned long) index );
+ if (ctx->DrawBuffer->Name == 0) {
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ xmesa->clearpixel = (unsigned long) index;
+ XMesaSetForeground( xmesa->display, xmbuf->cleargc, (unsigned long) index );
+ }
}
static void
clear_color( GLcontext *ctx, const GLfloat color[4] )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
- CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
- CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
- CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
- xmesa->clearpixel = xmesa_color_to_pixel( xmesa,
- xmesa->clearcolor[0],
- xmesa->clearcolor[1],
- xmesa->clearcolor[2],
- xmesa->clearcolor[3],
- xmesa->xm_visual->undithered_pf );
- _glthread_LOCK_MUTEX(_xmesa_lock);
- XMesaSetForeground( xmesa->display, xmesa->xm_draw_buffer->cleargc,
- xmesa->clearpixel );
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ if (ctx->DrawBuffer->Name == 0) {
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+ xmesa->clearpixel = xmesa_color_to_pixel( ctx,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2],
+ xmesa->clearcolor[3],
+ xmesa->xm_visual->undithered_pf );
+ _glthread_LOCK_MUTEX(_xmesa_lock);
+ XMesaSetForeground( xmesa->display, xmbuf->cleargc,
+ xmesa->clearpixel );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ }
}
@@ -234,7 +248,9 @@ static void
index_mask( GLcontext *ctx, GLuint mask )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- if (xmesa->xm_draw_buffer->buffer != XIMAGE) {
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ /* not sure this conditional is really needed */
+ if (xmbuf->backxrb && xmbuf->backxrb->pixmap) {
unsigned long m;
if (mask==0xffffffff) {
m = ((unsigned long)~0L);
@@ -242,8 +258,8 @@ index_mask( GLcontext *ctx, GLuint mask )
else {
m = (unsigned long) mask;
}
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->cleargc, m );
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->gc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->gc, m );
}
}
@@ -254,6 +270,7 @@ color_mask(GLcontext *ctx,
GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
const int xclass = xmesa->xm_visual->mesa_visual.visualType;
(void) amask;
@@ -268,8 +285,8 @@ color_mask(GLcontext *ctx,
if (gmask) m |= GET_GREENMASK(xmesa->xm_visual);
if (bmask) m |= GET_BLUEMASK(xmesa->xm_visual);
}
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->cleargc, m );
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->gc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->gc, m );
}
}
@@ -280,62 +297,45 @@ color_mask(GLcontext *ctx,
/**********************************************************************/
+/**
+ * Clear the front or back color buffer, if it's implemented with a pixmap.
+ */
static void
-clear_front_pixmap( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_pixmap(GLcontext *ctx, struct xmesa_renderbuffer *xrb, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- if (all) {
- XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->frontbuffer,
- xmesa->xm_draw_buffer->cleargc,
- 0, 0,
- xmesa->xm_draw_buffer->mesa_buffer.Width + 1,
- xmesa->xm_draw_buffer->mesa_buffer.Height + 1 );
- }
- else {
- XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->frontbuffer,
- xmesa->xm_draw_buffer->cleargc,
- x, xmesa->xm_draw_buffer->mesa_buffer.Height - y - height,
- width, height );
- }
-}
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ assert(xrb->pixmap == xmbuf->backxrb->pixmap ||
+ xrb->pixmap == xmbuf->frontxrb->pixmap);
-static void
-clear_back_pixmap( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
if (all) {
- XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap,
- xmesa->xm_draw_buffer->cleargc,
- 0, 0,
- xmesa->xm_draw_buffer->mesa_buffer.Width + 1,
- xmesa->xm_draw_buffer->mesa_buffer.Height + 1 );
+ XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc,
+ 0, 0, xrb->Base.Width + 1, xrb->Base.Height + 1 );
}
else {
- XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap,
- xmesa->xm_draw_buffer->cleargc,
- x, xmesa->xm_draw_buffer->mesa_buffer.Height - y - height,
+ XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc,
+ x, xrb->Base.Height - y - height,
width, height );
}
}
static void
-clear_8bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_8bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
if (all) {
- size_t n = xmesa->xm_draw_buffer->backimage->bytes_per_line
- * xmesa->xm_draw_buffer->backimage->height;
- MEMSET( xmesa->xm_draw_buffer->backimage->data, xmesa->clearpixel, n );
+ const size_t n = xrb->ximage->bytes_per_line * xrb->Base.Height;
+ MEMSET( xrb->ximage->data, xmesa->clearpixel, n );
}
else {
GLint i;
for (i=0;i<height;i++) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_draw_buffer, x, y+i );
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x, y + i);
MEMSET( ptr, xmesa->clearpixel, width );
}
}
@@ -343,14 +343,15 @@ clear_8bit_ximage( GLcontext *ctx, GLboolean all,
static void
-clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_HPCR_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
if (all) {
- GLint i, c16 = (xmesa->xm_draw_buffer->backimage->bytes_per_line>>4)<<4;
- GLubyte *ptr = (GLubyte *)xmesa->xm_draw_buffer->backimage->data;
- for (i=0; i<xmesa->xm_draw_buffer->backimage->height; i++) {
+ GLint i, c16 = (xrb->ximage->bytes_per_line>>4)<<4;
+ GLubyte *ptr = (GLubyte *) xrb->ximage->data;
+ for (i = 0; i < xrb->Base.Height; i++) {
GLint j;
GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
if (i&1) {
@@ -375,7 +376,7 @@ clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
ptr[15] = sptr[15];
ptr += 16;
}
- for (; j<xmesa->xm_draw_buffer->backimage->bytes_per_line; j++) {
+ for (; j < xrb->ximage->bytes_per_line; j++) {
*ptr = sptr[j&15];
ptr++;
}
@@ -384,9 +385,9 @@ clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
else {
GLint i;
for (i=y; i<y+height; i++) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_draw_buffer, x, i );
+ GLubyte *ptr = PIXEL_ADDR1( xrb, x, i );
int j;
- GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
+ const GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
if (i&1) {
sptr += 16;
}
@@ -400,41 +401,40 @@ clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
static void
-clear_16bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_16bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint pixel = (GLuint) xmesa->clearpixel;
+
if (xmesa->swapbytes) {
pixel = ((pixel >> 8) & 0x00ff) | ((pixel << 8) & 0xff00);
}
+
if (all) {
- register GLuint n;
- register GLuint *ptr4 = (GLuint *) xmesa->xm_draw_buffer->backimage->data;
+ GLuint *ptr4 = (GLuint *) xrb->ximage->data;
if ((pixel & 0xff) == ((pixel >> 8) & 0xff)) {
/* low and high bytes are equal so use memset() */
- n = xmesa->xm_draw_buffer->backimage->bytes_per_line
- * xmesa->xm_draw_buffer->mesa_buffer.Height;
+ const GLuint n = xrb->ximage->bytes_per_line * xrb->Base.Height;
MEMSET( ptr4, pixel & 0xff, n );
}
else {
+ const GLuint n = xrb->ximage->bytes_per_line * xrb->Base.Height / 4;
+ GLuint i;
pixel = pixel | (pixel<<16);
- n = xmesa->xm_draw_buffer->backimage->bytes_per_line
- * xmesa->xm_draw_buffer->mesa_buffer.Height / 4;
- do {
- *ptr4++ = pixel;
- n--;
- } while (n!=0);
-
- if ((xmesa->xm_draw_buffer->backimage->bytes_per_line *
- xmesa->xm_draw_buffer->mesa_buffer.Height) & 0x2)
+ for (i = 0; i < n; i++) {
+ ptr4[i] = pixel;
+ }
+ ptr4 += n;
+ /* might be one last GLushort to set */
+ if ((xrb->ximage->bytes_per_line * xrb->Base.Height) & 0x2)
*(GLushort *)ptr4 = pixel & 0xffff;
}
}
else {
- register int i, j;
+ GLint i, j;
for (j=0;j<height;j++) {
- register GLushort *ptr2 = PIXELADDR2( xmesa->xm_draw_buffer, x, y+j );
+ GLushort *ptr2 = PIXEL_ADDR2(xrb, x, y + j);
for (i=0;i<width;i++) {
*ptr2++ = pixel;
}
@@ -445,41 +445,32 @@ clear_16bit_ximage( GLcontext *ctx, GLboolean all,
/* Optimized code provided by Nozomi Ytow <noz@xfree86.org> */
static void
-clear_24bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_24bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = xmesa->clearcolor[0];
const GLubyte g = xmesa->clearcolor[1];
const GLubyte b = xmesa->clearcolor[2];
-#if 0 /* See below */
- register GLuint clearPixel;
- if (xmesa->swapbytes) {
- clearPixel = (b << 16) | (g << 8) | r;
- }
- else {
- clearPixel = (r << 16) | (g << 8) | b;
- }
-#endif
if (all) {
- if (r==g && g==b) {
+ if (r == g && g == b) {
/* same value for all three components (gray) */
- const GLint w3 = xmesa->xm_draw_buffer->mesa_buffer.Width * 3;
- const GLint h = xmesa->xm_draw_buffer->mesa_buffer.Height;
+ const GLint w3 = xrb->Base.Width * 3;
+ const GLint h = xrb->Base.Height;
GLint i;
for (i = 0; i < h; i++) {
- bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i);
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, 0, i);
MEMSET(ptr3, r, w3);
}
}
else {
/* the usual case */
- const GLint w = xmesa->xm_draw_buffer->mesa_buffer.Width;
- const GLint h = xmesa->xm_draw_buffer->mesa_buffer.Height;
+ const GLint w = xrb->Base.Width;
+ const GLint h = xrb->Base.Height;
GLint i, j;
for (i = 0; i < h; i++) {
- bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i);
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, 0, i);
for (j = 0; j < w; j++) {
ptr3->r = r;
ptr3->g = g;
@@ -487,83 +478,15 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all,
ptr3++;
}
}
-#if 0 /* this code doesn't work for all window widths */
- register GLuint *ptr4 = (GLuint *) ptr3;
- register GLuint px;
- GLuint pixel4[3];
- register GLuint *p = pixel4;
- pixel4[0] = clearPixel | (clearPixel << 24);
- pixel4[1] = (clearPixel << 16) | (clearPixel >> 8);
- pixel4[2] = (clearPixel << 8) | (clearPixel >> 16);
- switch (3 & (int)(ptr3 - (bgr_t*) ptr4)){
- case 0:
- break;
- case 1:
- px = *ptr4 & 0x00ffffff;
- px |= pixel4[0] & 0xff000000;
- *ptr4++ = px;
- px = *ptr4 & 0xffff0000;
- px |= pixel4[2] & 0x0000ffff;
- *ptr4 = px;
- if (0 == --n)
- break;
- case 2:
- px = *ptr4 & 0x0000fffff;
- px |= pixel4[1] & 0xffff0000;
- *ptr4++ = px;
- px = *ptr4 & 0xffffff00;
- px |= pixel4[2] & 0x000000ff;
- *ptr4 = px;
- if (0 == --n)
- break;
- case 3:
- px = *ptr4 & 0x000000ff;
- px |= pixel4[2] & 0xffffff00;
- *ptr4++ = px;
- --n;
- break;
- }
- while (n > 3) {
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- n -= 4;
- }
- switch (n) {
- case 3:
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffffff00;
- px |= clearPixel & 0xff;
- *ptr4 = px;
- break;
- case 2:
- p = pixel4;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffff0000;
- px |= *p & 0xffff;
- *ptr4 = px;
- break;
- case 1:
- px = *ptr4 & 0xff000000;
- px |= *p & 0xffffff;
- *ptr4 = px;
- break;
- case 0:
- break;
- }
-#endif
}
}
else {
/* only clear subrect of color buffer */
- if (r==g && g==b) {
+ if (r == g && g == b) {
/* same value for all three components (gray) */
GLint j;
for (j=0;j<height;j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j );
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
MEMSET(ptr3, r, 3 * width);
}
}
@@ -571,7 +494,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all,
/* non-gray clear color */
GLint i, j;
for (j = 0; j < height; j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j );
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
for (i = 0; i < width; i++) {
ptr3->r = r;
ptr3->g = g;
@@ -579,115 +502,43 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all,
ptr3++;
}
}
-#if 0 /* this code might not always (seems ptr3 always == ptr4) */
- GLint j;
- GLuint pixel4[3];
- pixel4[0] = clearPixel | (clearPixel << 24);
- pixel4[1] = (clearPixel << 16) | (clearPixel >> 8);
- pixel4[2] = (clearPixel << 8) | (clearPixel >> 16);
- for (j=0;j<height;j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j );
- register GLuint *ptr4 = (GLuint *)ptr3;
- register GLuint *p, px;
- GLuint w = width;
- switch (3 & (int)(ptr3 - (bgr_t*) ptr4)){
- case 0:
- break;
- case 1:
- px = *ptr4 & 0x00ffffff;
- px |= pixel4[0] & 0xff000000;
- *ptr4++ = px;
- px = *ptr4 & 0xffff0000;
- px |= pixel4[2] & 0x0000ffff;
- *ptr4 = px;
- if (0 == --w)
- break;
- case 2:
- px = *ptr4 & 0x0000fffff;
- px |= pixel4[1] & 0xffff0000;
- *ptr4++ = px;
- px = *ptr4 & 0xffffff00;
- px |= pixel4[2] & 0x000000ff;
- *ptr4 = px;
- if (0 == --w)
- break;
- case 3:
- px = *ptr4 & 0x000000ff;
- px |= pixel4[2] & 0xffffff00;
- *ptr4++ = px;
- --w;
- break;
- }
- while (w > 3){
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- w -= 4;
- }
- switch (w) {
- case 3:
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffffff00;
- px |= *p & 0xff;
- *ptr4 = px;
- break;
- case 2:
- p = pixel4;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffff0000;
- px |= *p & 0xffff;
- *ptr4 = px;
- break;
- case 1:
- px = *ptr4 & 0xff000000;
- px |= pixel4[0] & 0xffffff;
- *ptr4 = px;
- break;
- case 0:
- break;
- }
- }
-#endif
}
}
}
static void
-clear_32bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_32bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint pixel = (GLuint) xmesa->clearpixel;
+
if (xmesa->swapbytes) {
pixel = ((pixel >> 24) & 0x000000ff)
| ((pixel >> 8) & 0x0000ff00)
| ((pixel << 8) & 0x00ff0000)
| ((pixel << 24) & 0xff000000);
}
+
if (all) {
- register GLint n = xmesa->xm_draw_buffer->mesa_buffer.Width
- * xmesa->xm_draw_buffer->mesa_buffer.Height;
- register GLuint *ptr4 = (GLuint *) xmesa->xm_draw_buffer->backimage->data;
- if (pixel==0) {
- MEMSET( ptr4, pixel, 4*n );
+ const GLuint n = xrb->Base.Width * xrb->Base.Height;
+ GLuint *ptr4 = (GLuint *) xrb->ximage->data;
+ if (pixel == 0) {
+ _mesa_memset(ptr4, pixel, 4 * n);
}
else {
- do {
- *ptr4++ = pixel;
- n--;
- } while (n!=0);
+ GLuint i;
+ for (i = 0; i < n; i++)
+ ptr4[i] = pixel;
}
}
else {
- register int i, j;
- for (j=0;j<height;j++) {
- register GLuint *ptr4 = PIXELADDR4( xmesa->xm_draw_buffer, x, y+j );
- for (i=0;i<width;i++) {
- *ptr4++ = pixel;
+ GLint i, j;
+ for (j = 0; j < height; j++) {
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y + j);
+ for (i = 0; i < width; i++) {
+ ptr4[i] = pixel;
}
}
}
@@ -695,18 +546,18 @@ clear_32bit_ximage( GLcontext *ctx, GLboolean all,
static void
-clear_nbit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_nbit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- XMesaImage *img = xmesa->xm_draw_buffer->backimage;
- register int i, j;
+ XMesaImage *img = xrb->ximage;
+ GLint i, j;
/* We can ignore 'all' here - x, y, width, height are always right */
(void) all;
/* TODO: optimize this */
- y = FLIP(xmesa->xm_draw_buffer, y);
+ y = YFLIP(xrb, y);
for (j = 0; j < height; j++) {
for (i = 0; i < width; i++) {
XMesaPutPixel(img, x+i, y-j, xmesa->clearpixel);
@@ -720,78 +571,62 @@ static void
clear_buffers( GLcontext *ctx, GLbitfield mask,
GLboolean all, GLint x, GLint y, GLint width, GLint height )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
-
- if ((mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) &&
- xmesa->xm_draw_buffer->mesa_buffer.UseSoftwareAlphaBuffers &&
- ctx->Color.ColorMask[ACOMP]) {
- _swrast_clear_alpha_buffers(ctx);
- }
-
- /* we can't handle color or index masking */
- if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
- if (mask & DD_FRONT_LEFT_BIT) {
- ASSERT(xmesa->xm_draw_buffer->front_clear_func);
- (*xmesa->xm_draw_buffer->front_clear_func)( ctx, all, x, y, width, height );
- mask &= ~DD_FRONT_LEFT_BIT;
- }
- if (mask & DD_BACK_LEFT_BIT) {
- ASSERT(xmesa->xm_draw_buffer->back_clear_func);
- (*xmesa->xm_draw_buffer->back_clear_func)( ctx, all, x, y, width, height );
- mask &= ~DD_BACK_LEFT_BIT;
+ if (ctx->DrawBuffer->Name == 0) {
+ /* this is a window system framebuffer */
+ const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
+ XMesaBuffer b = (XMesaBuffer) ctx->DrawBuffer;
+
+ /* we can't handle color or index masking */
+ if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ /* clear front color buffer */
+ if (b->frontxrb == (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) {
+ /* renderbuffer is not wrapped - great! */
+ b->frontxrb->clearFunc(ctx, b->frontxrb, all, x, y,
+ width, height);
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+ else {
+ /* we can't directly clear an alpha-wrapped color buffer */
+ }
+ }
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ /* clear back color buffer */
+ if (b->backxrb == (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer) {
+ /* renderbuffer is not wrapped - great! */
+ b->backxrb->clearFunc(ctx, b->backxrb, all, x, y,
+ width, height);
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+ }
}
}
-
if (mask)
_swrast_Clear( ctx, mask, all, x, y, width, height );
}
-/*
- * When we detect that the user has resized the window this function will
- * get called. Here we'll reallocate the back buffer, depth buffer,
- * stencil buffer etc. to match the new window size.
- * The buffer->Width and buffer->Height values will indicate the new size.
+/**
+ * Called by ctx->Driver.ResizeBuffers()
+ * Resize the front/back colorbuffers to match the latest window size.
*/
void
-xmesa_resize_buffers( GLframebuffer *buffer )
+xmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint width, GLuint height)
{
- int height = (int) buffer->Height;
/* We can do this cast because the first field in the XMesaBuffer
* struct is a GLframebuffer struct. If this weren't true, we'd
* need a pointer from the GLframebuffer to the XMesaBuffer.
*/
XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
- xmesa_alloc_back_buffer( xmBuffer );
-
- /* Needed by FLIP macro */
- xmBuffer->bottom = height - 1;
+ xmesa_alloc_back_buffer(xmBuffer, width, height);
- if (xmBuffer->backimage) {
- /* Needed by PIXELADDR1 macro */
- xmBuffer->ximage_width1 = xmBuffer->backimage->bytes_per_line;
- xmBuffer->ximage_origin1 = (GLubyte *) xmBuffer->backimage->data
- + xmBuffer->ximage_width1 * (height-1);
-
- /* Needed by PIXELADDR2 macro */
- xmBuffer->ximage_width2 = xmBuffer->backimage->bytes_per_line / 2;
- xmBuffer->ximage_origin2 = (GLushort *) xmBuffer->backimage->data
- + xmBuffer->ximage_width2 * (height-1);
-
- /* Needed by PIXELADDR3 macro */
- xmBuffer->ximage_width3 = xmBuffer->backimage->bytes_per_line;
- xmBuffer->ximage_origin3 = (GLubyte *) xmBuffer->backimage->data
- + xmBuffer->ximage_width3 * (height-1);
-
- /* Needed by PIXELADDR4 macro */
- xmBuffer->ximage_width4 = xmBuffer->backimage->width;
- xmBuffer->ximage_origin4 = (GLuint *) xmBuffer->backimage->data
- + xmBuffer->ximage_width4 * (height-1);
- }
-
- _swrast_alloc_buffers( buffer );
+#if NEW_RENDERBUFFER
+ _mesa_resize_framebuffer(ctx, buffer, width, height);
+#endif
}
@@ -810,11 +645,14 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
+ struct xmesa_renderbuffer *xrb
+ = (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
- const XMesaDrawable buffer = xmesa->xm_draw_buffer->buffer;
- const XMesaGC gc = xmesa->xm_draw_buffer->gc;
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ const XMesaGC gc = xmbuf->gc;
ASSERT(dpy);
ASSERT(gc);
@@ -824,7 +662,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
if (swrast->NewState)
_swrast_validate_derived( ctx );
- if (buffer && /* buffer != 0 means it's a Window or Pixmap */
+ if (xrb->pixmap &&
format == GL_BGRA &&
type == GL_UNSIGNED_BYTE &&
(swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
@@ -882,8 +720,8 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
ximage.bits_per_pixel = 32;
/* it seems we don't need to set the ximage.red/green/blue_mask fields */
/* flip Y axis for dest position */
- dstY = FLIP(xmesa->xm_draw_buffer, dstY) - h + 1;
- XPutImage(dpy, buffer, gc, &ximage, 0, 0, dstX, dstY, w, h);
+ dstY = YFLIP(xrb, dstY) - h + 1;
+ XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
}
if (unpack->BufferObj->Name) {
@@ -913,11 +751,13 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
+ struct xmesa_renderbuffer *xrb
+ = (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0];
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
- const XMesaDrawable buffer = xmesa->xm_draw_buffer->buffer;
- const XMesaGC gc = xmesa->xm_draw_buffer->gc;
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ const XMesaGC gc = xmbuf->gc;
ASSERT(dpy);
ASSERT(gc);
@@ -926,7 +766,7 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
if (swrast->NewState)
_swrast_validate_derived( ctx );
- if (buffer && /* buffer != 0 means it's a Window or Pixmap */
+ if (xrb->pixmap &&
format == GL_RGB &&
type == GL_UNSIGNED_SHORT_5_6_5 &&
!ctx->Color.DitherFlag && /* no dithering */
@@ -985,8 +825,8 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
ximage.bits_per_pixel = 16;
/* it seems we don't need to set the ximage.red/green/blue_mask fields */
/* flip Y axis for dest position */
- dstY = FLIP(xmesa->xm_draw_buffer, dstY) - h + 1;
- XPutImage(dpy, buffer, gc, &ximage, 0, 0, dstX, dstY, w, h);
+ dstY = YFLIP(xrb, dstY) - h + 1;
+ XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
}
if (unpack->BufferObj->Name) {
@@ -1016,9 +856,11 @@ xmesa_CopyPixels( GLcontext *ctx,
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
- const XMesaDrawable drawBuffer = xmesa->xm_draw_buffer->buffer;
- const XMesaDrawable readBuffer = xmesa->xm_read_buffer->buffer;
- const XMesaGC gc = xmesa->xm_draw_buffer->gc;
+ const XMesaGC gc = ((XMesaBuffer) ctx->DrawBuffer)->gc;
+ struct xmesa_renderbuffer *srcXrb = (struct xmesa_renderbuffer *)
+ ctx->ReadBuffer->_ColorReadBuffer;
+ struct xmesa_renderbuffer *dstXrb = (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->_ColorDrawBuffers[0][0];
ASSERT(dpy);
ASSERT(gc);
@@ -1028,8 +870,8 @@ xmesa_CopyPixels( GLcontext *ctx,
if (ctx->Color.DrawBuffer[0] == GL_FRONT &&
ctx->Pixel.ReadBuffer == GL_FRONT &&
- drawBuffer && /* buffer != 0 means it's a Window or Pixmap */
- readBuffer &&
+ srcXrb->pixmap &&
+ dstXrb->pixmap &&
type == GL_COLOR &&
(swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
@@ -1038,9 +880,9 @@ xmesa_CopyPixels( GLcontext *ctx,
/* Note: we don't do any special clipping work here. We could,
* but X will do it for us.
*/
- srcy = FLIP(xmesa->xm_read_buffer, srcy) - height + 1;
- desty = FLIP(xmesa->xm_draw_buffer, desty) - height + 1;
- XCopyArea(dpy, readBuffer, drawBuffer, gc,
+ srcy = YFLIP(srcXrb, srcy) - height + 1;
+ desty = YFLIP(dstXrb, desty) - height + 1;
+ XCopyArea(dpy, srcXrb->pixmap, dstXrb->pixmap, gc,
srcx, srcy, width, height, destx, desty);
}
else {
@@ -1100,9 +942,89 @@ enable( GLcontext *ctx, GLenum pname, GLboolean state )
}
-void xmesa_update_state( GLcontext *ctx, GLuint new_state )
+static void
+clear_color_HPCR_ximage( GLcontext *ctx, const GLfloat color[4] )
+{
+ int i;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+
+ if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
+ /* black is black */
+ MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 ,
+ sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern));
+ }
+ else {
+ /* build clear pattern */
+ for (i=0; i<16; i++) {
+ xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] =
+ DITHER_HPCR(i, 0,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]);
+ xmesa->xm_visual->hpcr_clear_ximage_pattern[1][i] =
+ DITHER_HPCR(i, 1,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]);
+ }
+ }
+}
+
+
+static void
+clear_color_HPCR_pixmap( GLcontext *ctx, const GLfloat color[4] )
+{
+ int i;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+
+ if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
+ /* black is black */
+ for (i=0; i<16; i++) {
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, 0);
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, 0);
+ }
+ }
+ else {
+ for (i=0; i<16; i++) {
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0,
+ DITHER_HPCR(i, 0,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]));
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1,
+ DITHER_HPCR(i, 1,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]));
+ }
+ }
+ /* change tile pixmap content */
+ XMesaPutImage(xmesa->display,
+ (XMesaDrawable)xmesa->xm_visual->hpcr_clear_pixmap,
+ XMESA_BUFFER(ctx->DrawBuffer)->cleargc,
+ xmesa->xm_visual->hpcr_clear_ximage, 0, 0, 0, 0, 16, 2);
+}
+
+
+/**
+ * Called when the driver should update it's state, based on the new_state
+ * flags.
+ */
+void
+xmesa_update_state( GLcontext *ctx, GLuint new_state )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *front_xrb, *back_xrb;
/* Propagate statechange information to swrast and swrast_setup
* modules. The X11 driver has no internal GL-dependent state.
@@ -1112,40 +1034,76 @@ void xmesa_update_state( GLcontext *ctx, GLuint new_state )
_tnl_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
+ if (ctx->DrawBuffer->Name != 0)
+ return;
- /* setup pointers to front and back buffer clear functions */
- xmesa->xm_draw_buffer->front_clear_func = clear_front_pixmap;
- if (xmesa->xm_draw_buffer->backpixmap != XIMAGE) {
- xmesa->xm_draw_buffer->back_clear_func = clear_back_pixmap;
+ front_xrb = XMESA_BUFFER(ctx->DrawBuffer)->frontxrb;
+ if (front_xrb) {
+ /* XXX check for relevant new_state flags */
+ xmesa_set_renderbuffer_funcs(front_xrb, xmesa->pixelformat,
+ xmesa->xm_visual->BitsPerPixel);
+ /* setup pointers to front and back buffer clear functions */
+ front_xrb->clearFunc = clear_pixmap;
}
- else {
- switch (xmesa->xm_visual->BitsPerPixel) {
- case 8:
- if (xmesa->xm_visual->hpcr_clear_flag) {
- xmesa->xm_draw_buffer->back_clear_func = clear_HPCR_ximage;
- }
- else {
- xmesa->xm_draw_buffer->back_clear_func = clear_8bit_ximage;
+
+ back_xrb = XMESA_BUFFER(ctx->DrawBuffer)->backxrb;
+ if (back_xrb) {
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+
+ /* XXX check for relevant new_state flags */
+ xmesa_set_renderbuffer_funcs(back_xrb, xmesa->pixelformat,
+ xmesa->xm_visual->BitsPerPixel);
+
+ if (xmbuf->backxrb->pixmap) {
+ back_xrb->clearFunc = clear_pixmap;
+ }
+ else {
+ switch (xmesa->xm_visual->BitsPerPixel) {
+ case 8:
+ if (xmesa->xm_visual->hpcr_clear_flag) {
+ back_xrb->clearFunc = clear_HPCR_ximage;
+ }
+ else {
+ back_xrb->clearFunc = clear_8bit_ximage;
+ }
+ break;
+ case 16:
+ back_xrb->clearFunc = clear_16bit_ximage;
+ break;
+ case 24:
+ back_xrb->clearFunc = clear_24bit_ximage;
+ break;
+ case 32:
+ back_xrb->clearFunc = clear_32bit_ximage;
+ break;
+ default:
+ back_xrb->clearFunc = clear_nbit_ximage;
+ break;
}
- break;
- case 16:
- xmesa->xm_draw_buffer->back_clear_func = clear_16bit_ximage;
- break;
- case 24:
- xmesa->xm_draw_buffer->back_clear_func = clear_24bit_ximage;
- break;
- case 32:
- xmesa->xm_draw_buffer->back_clear_func = clear_32bit_ximage;
- break;
- default:
- xmesa->xm_draw_buffer->back_clear_func = clear_nbit_ximage;
- break;
}
}
- if (ctx->Color._DrawDestMask[0] & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
+#if OLD_RENDERBUFFER && 0
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) {
xmesa_update_span_funcs(ctx);
}
+#endif
+
+ if (xmesa->xm_visual->hpcr_clear_flag) {
+ /* this depends on whether we're drawing to the front or back buffer */
+ /* XXX FIX THIS! */
+#if 0
+ if (pixmap) {
+ ctx->Driver.ClearColor = clear_color_HPCR_pixmap;
+ }
+ else {
+ ctx->Driver.ClearColor = clear_color_HPCR_ximage;
+ }
+#else
+ (void) clear_color_HPCR_pixmap;
+ (void) clear_color_HPCR_ximage;
+#endif
+ }
}
@@ -1208,17 +1166,36 @@ choose_tex_format( GLcontext *ctx, GLint internalFormat,
/**
* Called by glViewport.
* This is a good time for us to poll the current X window size and adjust
- * our ancillary (back color, depth, stencil, etc) buffers to match the
- * current window size. Remember, we have no opportunity to respond to
- * conventional X Resize/StructureNotify events since the X driver has no
- * event loop. Thus, we poll.
+ * our renderbuffers to match the current window size.
+ * Remember, we have no opportunity to respond to conventional
+ * X Resize/StructureNotify events since the X driver has no event loop.
+ * Thus, we poll.
* Note that this trick isn't fool-proof. If the application never calls
* glViewport, our notion of the current window size may be incorrect.
*/
static void
xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
+#if 1
+ struct gl_framebuffer *fb = ctx->WinSysDrawBuffer;
+ GLuint newWidth, newHeight;
+
+ /*
+ printf("%s before %d x %d\n", __FUNCTION__, fb->Width, fb->Height);
+ */
+
+ get_buffer_size(fb, &newWidth, &newHeight);
+ if (newWidth != fb->Width || newHeight != fb->Height) {
+ xmesa_resize_buffers(ctx, fb, newWidth, newHeight);
+ ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
+ }
+ /*
+ printf("%s after %d x %d\n", __FUNCTION__, fb->Width, fb->Height);
+ */
+#else
+ /* This also works: */
_mesa_ResizeBuffersMESA();
+#endif
}
diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c
index 24e09ce344..43de9a98ab 100644
--- a/src/mesa/drivers/x11/xm_line.c
+++ b/src/mesa/drivers/x11/xm_line.c
@@ -70,7 +70,7 @@ static void draw_points_ANY_pixmap( GLcontext *ctx, const SWvertex *vert )
xmesa->pixelformat);
XMesaSetForeground( dpy, gc, pixel );
x = (GLint) vert->win[0];
- y = FLIP( xmesa->xm_buffer, (GLint) vert->win[1] );
+ y = YFLIP( xrb, (GLint) vert->win[1] );
XMesaDrawPoint( dpy, buffer, gc, x, y);
}
else {
@@ -78,7 +78,7 @@ static void draw_points_ANY_pixmap( GLcontext *ctx, const SWvertex *vert )
register int x, y;
XMesaSetForeground( dpy, gc, vert->index );
x = (GLint) vert->win[0];
- y = FLIP( xmesa->xm_buffer, (GLint) vert->win[1] );
+ y = YFLIP( xrb, (GLint) vert->win[1] );
XMesaDrawPoint( dpy, buffer, gc, x, y);
}
}
@@ -117,18 +117,22 @@ void xmesa_choose_point( GLcontext *ctx )
/**********************************************************************/
+#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
+ (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]
+
+
/*
* Draw a flat-shaded, PF_TRUECOLOR line into an XImage.
*/
#define NAME flat_TRUECOLOR_line
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
unsigned long pixel; \
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
#define CLIP_HACK 1
-#define PLOT(X,Y) XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel );
+#define PLOT(X,Y) XMesaPutPixel(xrb->ximage, X, YFLIP(xrb, Y), pixel );
#include "swrast/s_linetemp.h"
@@ -138,12 +142,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8A8B8G8R_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -155,12 +159,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8A8R8G8B_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -172,12 +176,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8R8G8B_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -189,11 +193,11 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8R8G8B24_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color;
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) { \
pixelPtr->r = color[RCOMP]; \
@@ -209,12 +213,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_5R6G5B_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -226,11 +230,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_DITHER_5R6G5B_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color;
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
#include "swrast/s_linetemp.h"
@@ -243,13 +248,13 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_DITHER8_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLint r = color[0], g = color[1], b = color[2]; \
DITHER_SETUP;
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
#include "swrast/s_linetemp.h"
@@ -261,14 +266,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_LOOKUP8_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLubyte pixel; \
LOOKUP_SETUP; \
pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -280,12 +285,13 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_HPCR_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color; \
GLint r = color[0], g = color[1], b = color[2];
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
#include "swrast/s_linetemp.h"
@@ -298,9 +304,9 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_TRUECOLOR_z_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color; \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
unsigned long pixel; \
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
#define INTERP_Z 1
@@ -309,7 +315,7 @@ void xmesa_choose_point( GLcontext *ctx )
#define PLOT(X,Y) \
if (Z < *zPtr) { \
*zPtr = Z; \
- XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel ); \
+ XMesaPutPixel(xrb->ximage, X, YFLIP(xrb, Y), pixel); \
}
#include "swrast/s_linetemp.h"
@@ -320,14 +326,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8A8B8G8R_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -343,14 +349,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8A8R8G8B_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -366,14 +372,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8R8G8B_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -389,13 +395,13 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8R8G8B24_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -413,14 +419,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_5R6G5B_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -436,13 +442,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_DITHER_5R6G5B_z_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -458,15 +465,15 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_DITHER8_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLint r = color[0], g = color[1], b = color[2]; \
DITHER_SETUP;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -482,7 +489,7 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_LOOKUP8_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLubyte pixel; \
LOOKUP_SETUP; \
@@ -490,8 +497,8 @@ void xmesa_choose_point( GLcontext *ctx )
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -507,14 +514,15 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_HPCR_z_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color; \
GLint r = color[0], g = color[1], b = color[2];
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -530,8 +538,11 @@ static swrast_line_func get_line_func( GLcontext *ctx )
XMesaContext xmesa = XMESA_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->_ColorDrawBuffers[0][0];
- if ((ctx->Color._DrawDestMask[0] & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) ==0)
+ if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
+ & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
return (swrast_line_func) NULL;
if (ctx->RenderMode != GL_RENDER) return (swrast_line_func) NULL;
if (ctx->Line.SmoothFlag) return (swrast_line_func) NULL;
@@ -540,7 +551,7 @@ static swrast_line_func get_line_func( GLcontext *ctx )
if (ctx->Line.StippleFlag) return (swrast_line_func) NULL;
if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
- if (xmesa->xm_buffer->buffer==XIMAGE
+ if (xrb->ximage
&& swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
@@ -571,7 +582,7 @@ static swrast_line_func get_line_func( GLcontext *ctx )
return (swrast_line_func)NULL;
}
}
- if (xmesa->xm_buffer->buffer==XIMAGE
+ if (xrb->ximage
&& swrast->_RasterMask==0
&& ctx->Line.Width==1.0F) {
switch (xmesa->pixelformat) {
diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c
index b3b5970bdf..88dbb0d0b3 100644
--- a/src/mesa/drivers/x11/xm_span.c
+++ b/src/mesa/drivers/x11/xm_span.c
@@ -164,10 +164,12 @@ static unsigned long read_pixel( XMesaDisplay *dpy,
#define RGBA_SPAN_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, \
CONST GLubyte rgba[][4], const GLubyte mask[]
#define RGB_SPAN_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, \
CONST GLubyte rgb[][3], const GLubyte mask[]
@@ -181,12 +183,13 @@ static unsigned long read_pixel( XMesaDisplay *dpy,
static void write_span_TRUECOLOR_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -216,11 +219,12 @@ static void write_span_TRUECOLOR_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -250,11 +254,12 @@ static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS )
static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -283,11 +288,12 @@ static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -317,11 +323,12 @@ static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS )
static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -349,11 +356,12 @@ static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -380,11 +388,12 @@ static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS )
static void write_span_8A8R8G8B_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -412,11 +421,12 @@ static void write_span_8A8R8G8B_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_8A8R8G8B_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -444,11 +454,12 @@ static void write_span_rgb_8A8R8G8B_pixmap( RGB_SPAN_ARGS )
static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -475,10 +486,11 @@ static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS )
static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
register GLuint i;
for (i=0;i<n;i++,x++) {
@@ -569,11 +581,12 @@ static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -600,10 +613,11 @@ static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS )
static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
register GLuint i;
for (i=0;i<n;i++,x++) {
@@ -699,11 +713,12 @@ static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS )
static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -730,11 +745,12 @@ static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS )
static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -763,11 +779,12 @@ static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -794,11 +811,12 @@ static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS )
static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -828,12 +846,13 @@ static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS )
static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
XDITHER_SETUP(y);
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -859,12 +878,13 @@ static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
XDITHER_SETUP(y);
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -890,12 +910,13 @@ static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS )
static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -923,12 +944,13 @@ static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -956,11 +978,12 @@ static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS )
static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -987,11 +1010,12 @@ static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1018,12 +1042,13 @@ static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS )
static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
LOOKUP_SETUP;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1048,12 +1073,13 @@ static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
LOOKUP_SETUP;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1079,11 +1105,12 @@ static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS )
static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1108,11 +1135,12 @@ static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1137,9 +1165,10 @@ static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS )
static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1166,9 +1195,10 @@ static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1195,9 +1225,10 @@ static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS )
static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1224,9 +1255,10 @@ static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1252,9 +1284,9 @@ static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS )
*/
static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1276,9 +1308,9 @@ static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1299,9 +1331,9 @@ static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS )
*/
static void write_span_8A8R8G8B_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1323,9 +1355,9 @@ static void write_span_8A8R8G8B_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1347,9 +1379,9 @@ static void write_span_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS )
*/
static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1370,9 +1402,9 @@ static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLubyte *ptr = (GLubyte *) PIXELADDR3( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = (GLubyte *) PIXEL_ADDR3(xrb, x, y );
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1520,9 +1552,9 @@ static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1544,9 +1576,9 @@ static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS )
*/
static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLubyte *ptr = (GLubyte *) PIXELADDR3( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = (GLubyte *) PIXEL_ADDR3(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1575,9 +1607,9 @@ static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS )
*/
static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1614,10 +1646,12 @@ static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
- const GLint y2 = FLIP(xmesa->xm_buffer, y);
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
+ const GLint y2 = YFLIP(xrb, y);
+ ASSERT(xrb->ximage);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1654,9 +1688,9 @@ static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1693,9 +1727,10 @@ static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS )
*/
static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y );
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1733,9 +1768,10 @@ static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS )
static void write_span_DITHER_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
XDITHER_SETUP(yy);
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -1759,9 +1795,10 @@ static void write_span_DITHER_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
XDITHER_SETUP(yy);
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -1786,8 +1823,9 @@ static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS )
static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
XDITHER_SETUP(y);
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -1807,8 +1845,9 @@ static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
XDITHER_SETUP(y);
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -1834,10 +1873,11 @@ static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS )
static void write_span_1BIT_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1859,10 +1899,11 @@ static void write_span_1BIT_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1883,9 +1924,10 @@ static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS )
*/
static void write_span_HPCR_ximage( RGBA_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1907,9 +1949,10 @@ static void write_span_HPCR_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1932,10 +1975,11 @@ static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS )
static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
LOOKUP_SETUP;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1958,10 +2002,11 @@ static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
LOOKUP_SETUP;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1983,9 +2028,10 @@ static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS )
*/
static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
LOOKUP_SETUP;
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -2003,14 +2049,12 @@ static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS )
}
-static void write_rgb_LOOKUP8_ximage( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- CONST GLubyte rgb[][3],
- const GLubyte mask[] )
+static void write_rgb_LOOKUP8_ximage( RGB_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
LOOKUP_SETUP;
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -2036,9 +2080,10 @@ static void write_rgb_LOOKUP8_ximage( const GLcontext *ctx,
static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -2061,9 +2106,10 @@ static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -2085,9 +2131,10 @@ static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS )
*/
static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -2109,9 +2156,10 @@ static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -2136,6 +2184,7 @@ static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS )
#define RGBA_PIXEL_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, const GLint x[], const GLint y[], \
CONST GLubyte rgba[][4], const GLubyte mask[]
@@ -2146,6 +2195,7 @@ static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS )
static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2155,7 +2205,7 @@ static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS )
unsigned long p;
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2167,6 +2217,7 @@ static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2176,7 +2227,7 @@ static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS )
unsigned long p;
PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2188,6 +2239,7 @@ static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2196,7 +2248,7 @@ static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2207,6 +2259,7 @@ static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_8A8R8G8B_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2215,7 +2268,7 @@ static void write_pixels_8A8R8G8B_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2226,6 +2279,7 @@ static void write_pixels_8A8R8G8B_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2233,7 +2287,7 @@ static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2245,6 +2299,7 @@ static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2252,7 +2307,7 @@ static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2264,6 +2319,7 @@ static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2271,7 +2327,7 @@ static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2283,6 +2339,7 @@ static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2292,7 +2349,7 @@ static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
unsigned long p;
PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2304,6 +2361,7 @@ static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2313,7 +2371,7 @@ static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
DITHER(x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2325,6 +2383,7 @@ static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2334,7 +2393,7 @@ static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
DITHER_1BIT( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2346,6 +2405,7 @@ static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2354,7 +2414,7 @@ static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
DITHER_HPCR( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2366,6 +2426,7 @@ static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2374,7 +2435,7 @@ static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2386,6 +2447,7 @@ static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2393,7 +2455,7 @@ static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2405,13 +2467,14 @@ static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
}
}
}
@@ -2423,13 +2486,14 @@ static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
}
}
}
@@ -2440,11 +2504,11 @@ static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
*ptr = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
}
}
@@ -2455,11 +2519,11 @@ static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_8A8R8G8B_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i]);
*ptr = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
}
}
@@ -2471,11 +2535,11 @@ static void write_pixels_8A8R8G8B_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i]);
*ptr = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2487,11 +2551,11 @@ static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x[i], y[i] );
+ bgr_t *ptr = PIXEL_ADDR3(xrb, x[i], y[i] );
ptr->r = rgba[i][RCOMP];
ptr->g = rgba[i][GCOMP];
ptr->b = rgba[i][BCOMP];
@@ -2505,11 +2569,11 @@ static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
+ GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
*ptr = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2521,11 +2585,12 @@ static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
+ GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
PACK_TRUEDITHER( *ptr, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2538,12 +2603,13 @@ static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
DITHER_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
DITHER( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
}
}
@@ -2555,12 +2621,13 @@ static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
DITHER_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = (GLubyte) DITHER( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2573,12 +2640,13 @@ static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
DITHER_1BIT( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
}
}
@@ -2590,11 +2658,12 @@ static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = (GLubyte) DITHER_HPCR( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2607,12 +2676,13 @@ static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
LOOKUP_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), LOOKUP(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), LOOKUP(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
}
}
}
@@ -2623,12 +2693,13 @@ static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
LOOKUP_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = (GLubyte) LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2641,11 +2712,12 @@ static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
}
}
@@ -2657,11 +2729,12 @@ static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x[i], y[i] );
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i] );
*ptr = (GLubyte) GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2675,6 +2748,7 @@ static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS )
/**********************************************************************/
#define MONO_SPAN_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, const GLchan color[4], \
const GLubyte mask[]
@@ -2685,6 +2759,7 @@ static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS )
static void write_span_mono_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2692,7 +2767,7 @@ static void write_span_mono_pixmap( MONO_SPAN_ARGS )
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
register GLuint i;
XMesaSetForeground( xmesa->display, gc, pixel );
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
/* New code contributed by Jeff Epler and cleaned up by Keith
* Whitwell.
@@ -2719,17 +2794,19 @@ static void write_span_mono_pixmap( MONO_SPAN_ARGS )
-static void write_span_mono_index_pixmap( const GLcontext *ctx, GLuint n,
- GLint x, GLint y, GLuint colorIndex,
- const GLubyte mask[] )
+static void
+write_span_mono_index_pixmap( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint colorIndex,
+ const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
XMesaSetForeground( xmesa->display, gc, colorIndex );
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i = 0 ; i < n ;) {
GLuint start = i;
@@ -2759,12 +2836,13 @@ static void write_span_mono_index_pixmap( const GLcontext *ctx, GLuint n,
static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
unsigned long p;
@@ -2782,12 +2860,13 @@ static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS )
static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
XDITHER_SETUP(yy);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -2804,13 +2883,14 @@ static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS )
static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, DITHER_1BIT( x, y, r, g, b ) );
@@ -2826,11 +2906,12 @@ static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS )
static void write_span_mono_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaPutPixel( img, x, y, pixel );
@@ -2839,15 +2920,16 @@ static void write_span_mono_ximage( MONO_SPAN_ARGS )
}
-static void write_span_mono_index_ximage( const GLcontext *ctx, GLuint n,
- GLint x, GLint y,
- GLuint colorIndex,
- const GLubyte mask[] )
+static void
+write_span_mono_index_ximage( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint colorIndex,
+ const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaPutPixel( img, x, y, colorIndex );
@@ -2862,10 +2944,11 @@ static void write_span_mono_index_ximage( const GLcontext *ctx, GLuint n,
static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
@@ -2881,11 +2964,12 @@ static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
GLuint i, *ptr;
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ ptr = PIXEL_ADDR4(xrb, x, y );
for (i=0;i<n;i++) {
if (mask[i]) {
ptr[i] = pixel;
@@ -2898,11 +2982,12 @@ static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_8A8R8G8B_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
GLuint i, *ptr;
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ ptr = PIXEL_ADDR4(xrb, x, y );
for (i=0;i<n;i++) {
if (mask[i]) {
ptr[i] = pixel;
@@ -2916,9 +3001,9 @@ static void write_span_mono_8A8R8G8B_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLuint pixel = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x, y );
GLuint i;
for (i=0;i<n;i++) {
if (!mask || mask[i]) {
@@ -2933,12 +3018,12 @@ static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP];
const GLubyte g = color[GCOMP];
const GLubyte b = color[BCOMP];
GLuint i;
- bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x, y );
+ bgr_t *ptr = PIXEL_ADDR3(xrb, x, y );
for (i=0;i<n;i++) {
if (mask[i]) {
ptr[i].r = r;
@@ -2955,9 +3040,10 @@ static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS )
static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
register GLuint i;
XDITHER_SETUP(yy);
for (i=0;i<n;i++,x++) {
@@ -2973,9 +3059,10 @@ static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
register GLuint i;
XDITHER_SETUP(y);
for (i=0;i<n;i++,x++) {
@@ -2991,9 +3078,10 @@ static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
GLubyte pixel;
LOOKUP_SETUP;
pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
@@ -3011,11 +3099,12 @@ static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS )
static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaPutPixel( img, x, y, DITHER_1BIT( x, y, r, g, b ) );
@@ -3029,9 +3118,10 @@ static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
register GLuint i;
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3046,9 +3136,10 @@ static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
- GLubyte *ptr = (GLubyte *) PIXELADDR1( xmesa->xm_buffer,x,y);
+ GLubyte *ptr = (GLubyte *) PIXEL_ADDR1(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3064,11 +3155,12 @@ static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y );
const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++) {
if (mask[i]) {
PACK_TRUEDITHER(ptr[i], x+i, y, r, g, b);
@@ -3083,6 +3175,7 @@ static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS )
/**********************************************************************/
#define MONO_PIXEL_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, const GLint x[], const GLint y[], \
const GLchan color[4], const GLubyte mask[]
@@ -3092,6 +3185,7 @@ static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS )
static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3102,19 +3196,19 @@ static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaDrawPoint( dpy, buffer, gc,
- (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
-static void write_pixels_mono_index_pixmap(const GLcontext *ctx,
- GLuint n,
- const GLint x[], const GLint y[],
- GLuint colorIndex,
- const GLubyte mask[] )
+static void
+write_pixels_mono_index_pixmap(const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint colorIndex, const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3123,7 +3217,7 @@ static void write_pixels_mono_index_pixmap(const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaDrawPoint( dpy, buffer, gc,
- (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3135,6 +3229,7 @@ static void write_pixels_mono_index_pixmap(const GLcontext *ctx,
static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3146,7 +3241,7 @@ static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS )
PACK_TRUEDITHER(p, x[i], y[i], r, g, b);
XMesaSetForeground( dpy, gc, p );
XMesaDrawPoint( dpy, buffer, gc,
- (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3158,6 +3253,7 @@ static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS )
static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3167,7 +3263,7 @@ static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, DITHER( x[i], y[i], r, g, b ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3179,6 +3275,7 @@ static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS )
static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3188,7 +3285,7 @@ static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, DITHER_1BIT( x[i], y[i], r, g, b ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3200,29 +3297,32 @@ static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS )
static void write_pixels_mono_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), pixel );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), pixel );
}
}
}
-static void write_pixels_mono_index_ximage( const GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- GLuint colorIndex,
- const GLubyte mask[] )
+static void
+write_pixels_mono_index_ximage(const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint colorIndex, const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), colorIndex );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), colorIndex );
}
}
}
@@ -3234,14 +3334,15 @@ static void write_pixels_mono_index_ximage( const GLcontext *ctx, GLuint n,
static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
- PACK_TRUEDITHER(p, x[i], FLIP(xmesa->xm_buffer, y[i]), r, g, b);
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
+ PACK_TRUEDITHER(p, x[i], YFLIP(xrb, y[i]), r, g, b);
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
}
}
}
@@ -3253,13 +3354,13 @@ static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLuint p = PACK_8A8B8G8R(color[RCOMP], color[GCOMP],
color[BCOMP], color[ACOMP]);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
*ptr = p;
}
}
@@ -3270,13 +3371,13 @@ static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_8A8R8G8B_ximage( MONO_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLuint p = PACK_8A8R8G8B(color[RCOMP], color[GCOMP],
color[BCOMP], color[ACOMP]);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
*ptr = p;
}
}
@@ -3287,12 +3388,12 @@ static void write_pixels_mono_8A8R8G8B_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
const GLuint p = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
*ptr = p;
}
}
@@ -3304,12 +3405,12 @@ static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x[i], y[i] );
+ bgr_t *ptr = PIXEL_ADDR3(xrb, x[i], y[i] );
ptr->r = r;
ptr->g = g;
ptr->b = b;
@@ -3324,13 +3425,14 @@ static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS )
static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
DITHER_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), DITHER( x[i], y[i], r, g, b ) );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), DITHER( x[i], y[i], r, g, b ) );
}
}
}
@@ -3341,13 +3443,14 @@ static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
DITHER_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = (GLubyte) DITHER( x[i], y[i], r, g, b );
}
}
@@ -3359,6 +3462,7 @@ static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
GLubyte pixel;
@@ -3366,7 +3470,7 @@ static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS )
pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = pixel;
}
}
@@ -3380,13 +3484,14 @@ static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS )
static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
DITHER_1BIT( x[i], y[i], r, g, b ));
}
}
@@ -3398,12 +3503,13 @@ static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = DITHER_HPCR( x[i], y[i], r, g, b );
}
}
@@ -3415,12 +3521,13 @@ static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
register GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = p;
}
}
@@ -3432,12 +3539,13 @@ static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
+ GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
PACK_TRUEDITHER(*ptr, x[i], y[i], r, g, b);
}
}
@@ -3449,11 +3557,11 @@ static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS )
/*** Write INDEX SPAN functions ***/
/**********************************************************************/
-#define INDEX_SPAN_ARGS const GLcontext *ctx, \
+#define INDEX_SPAN_ARGS const GLcontext *ctx, struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, const GLuint index[], \
const GLubyte mask[]
-#define INDEX8_SPAN_ARGS const GLcontext *ctx, \
+#define INDEX8_SPAN_ARGS const GLcontext *ctx, struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, const GLubyte index[], \
const GLubyte mask[]
@@ -3464,11 +3572,12 @@ static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS )
static void write_span_index_pixmap( INDEX_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3492,11 +3601,12 @@ static void write_span_index_pixmap( INDEX_SPAN_ARGS )
static void write_span_index8_pixmap( INDEX8_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3520,9 +3630,10 @@ static void write_span_index8_pixmap( INDEX8_SPAN_ARGS )
static void write_span_index_ximage( INDEX_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3544,6 +3655,8 @@ static void write_span_index_ximage( INDEX_SPAN_ARGS )
static void write_span_index8_ximage( INDEX8_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ y = YFLIP(xrb, y);
if (mask) {
GLuint i;
for (i=0;i<n;i++) {
@@ -3565,8 +3678,8 @@ static void write_span_index8_ximage( INDEX8_SPAN_ARGS )
*/
static void write_span_index8_ximage8( INDEX8_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GLubyte *dst = PIXELADDR1( xmesa->xm_buffer,x,y);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ GLubyte *dst = PIXEL_ADDR1(xrb, x, y);
if (mask) {
GLuint i;
for (i=0;i<n;i++) {
@@ -3587,6 +3700,7 @@ static void write_span_index8_ximage8( INDEX8_SPAN_ARGS )
/**********************************************************************/
#define INDEX_PIXELS_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, const GLint x[], const GLint y[], \
const GLuint index[], const GLubyte mask[]
@@ -3597,6 +3711,7 @@ static void write_span_index8_ximage8( INDEX8_SPAN_ARGS )
static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3604,7 +3719,7 @@ static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3616,11 +3731,12 @@ static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS )
static void write_pixels_index_ximage( INDEX_PIXELS_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), (unsigned long) index[i] );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), (unsigned long) index[i] );
}
}
}
@@ -3651,7 +3767,7 @@ clip_for_xgetimage(XMesaContext xmesa, GLuint *n, GLint *x, GLint *y)
GLint dx, dy;
if (source->type == PBUFFER || source->type == PIXMAP)
return 0;
- XTranslateCoordinates(xmesa->display, source->buffer, rootWin,
+ XTranslateCoordinates(xmesa->display, source->frontbuffer, rootWin,
*x, *y, &dx, &dy, &child);
if (dx >= screenWidth) {
/* totally clipped on right */
@@ -3680,14 +3796,16 @@ clip_for_xgetimage(XMesaContext xmesa, GLuint *n, GLint *x, GLint *y)
/*
* Read a horizontal span of color-index pixels.
*/
-static void read_index_span( const GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLuint index[] )
+static void
+read_index_span(const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint index[])
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaBuffer source = xmesa->xm_buffer;
GLuint i;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
if (source->buffer) {
#ifndef XFree86Server
@@ -3735,11 +3853,12 @@ static void read_index_span( const GLcontext *ctx,
/*
* Read a horizontal span of color pixels.
*/
-static void read_color_span( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- GLubyte rgba[][4] )
+static void
+read_color_span( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLubyte rgba[][4] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaBuffer source = xmesa->xm_buffer;
if (source->buffer) {
@@ -3751,11 +3870,11 @@ static void read_color_span( const GLcontext *ctx,
span->data = (char *)MALLOC(span->height * span->bytes_per_line);
error = (!span->data);
(*xmesa->display->GetImage)(source->buffer,
- x, FLIP(source, y), n, 1, ZPixmap,
+ x, YFLIP(xrb, y), n, 1, ZPixmap,
~0L, (pointer)span->data);
#else
int k;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
k = clip_for_xgetimage(xmesa, &n, &x, &y);
if (k < 0)
return;
@@ -3952,7 +4071,7 @@ static void read_color_span( const GLcontext *ctx,
GLint bShift = xmesa->xm_visual->bshift;
XMesaImage *img = source->backimage;
GLuint i;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++) {
unsigned long p;
p = XMesaGetPixel( img, x+i, y );
@@ -3969,7 +4088,7 @@ static void read_color_span( const GLcontext *ctx,
const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
- const GLushort *ptr2 = PIXELADDR2( source, x, y );
+ const GLushort *ptr2 = PIXEL_ADDR2(xrb, x, y);
GLuint i;
#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
const GLuint *ptr4 = (const GLuint *) ptr2;
@@ -4013,7 +4132,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_8A8B8G8R:
{
- const GLuint *ptr4 = PIXELADDR4( source, x, y );
+ const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
GLuint p4 = *ptr4++;
@@ -4026,7 +4145,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_8A8R8G8B:
{
- const GLuint *ptr4 = PIXELADDR4( source, x, y );
+ const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
GLuint p4 = *ptr4++;
@@ -4039,7 +4158,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_8R8G8B:
{
- const GLuint *ptr4 = PIXELADDR4( source, x, y );
+ const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
GLuint p4 = *ptr4++;
@@ -4052,7 +4171,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_8R8G8B24:
{
- const bgr_t *ptr3 = PIXELADDR3( source, x, y );
+ const bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
rgba[i][RCOMP] = ptr3[i].r;
@@ -4064,7 +4183,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_HPCR:
{
- const GLubyte *ptr1 = PIXELADDR1( source, x, y );
+ const GLubyte *ptr1 = PIXEL_ADDR1(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
GLubyte p = *ptr1++;
@@ -4083,7 +4202,7 @@ static void read_color_span( const GLcontext *ctx,
const GLubyte *gTable = source->pixel_to_g;
const GLubyte *bTable = source->pixel_to_b;
if (GET_VISUAL_DEPTH(xmesa->xm_visual)==8) {
- GLubyte *ptr1 = PIXELADDR1( source, x, y );
+ GLubyte *ptr1 = PIXEL_ADDR1(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
unsigned long p = *ptr1++;
@@ -4096,7 +4215,7 @@ static void read_color_span( const GLcontext *ctx,
else {
XMesaImage *img = source->backimage;
GLuint i;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
unsigned long p = XMesaGetPixel( img, x, y );
rgba[i][RCOMP] = rTable[p];
@@ -4112,7 +4231,7 @@ static void read_color_span( const GLcontext *ctx,
XMesaImage *img = source->backimage;
int bitFlip = xmesa->xm_visual->bitFlip;
GLuint i;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
unsigned long p;
p = XMesaGetPixel( img, x, y ) ^ bitFlip;
@@ -4135,11 +4254,13 @@ static void read_color_span( const GLcontext *ctx,
/*
* Read an array of color index pixels.
*/
-static void read_index_pixels( const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLuint indx[], const GLubyte mask[] )
+static void
+read_index_pixels( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint indx[], const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
XMesaBuffer source = xmesa->xm_buffer;
@@ -4148,7 +4269,7 @@ static void read_index_pixels( const GLcontext *ctx,
if (mask[i]) {
indx[i] = (GLuint) read_pixel( xmesa->display,
source->buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
}
}
}
@@ -4156,7 +4277,7 @@ static void read_index_pixels( const GLcontext *ctx,
XMesaImage *img = source->backimage;
for (i=0;i<n;i++) {
if (mask[i]) {
- indx[i] = (GLuint) XMesaGetPixel( img, x[i], FLIP(source, y[i]) );
+ indx[i] = (GLuint) XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) );
}
}
}
@@ -4164,10 +4285,12 @@ static void read_index_pixels( const GLcontext *ctx,
-static void read_color_pixels( const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[] )
+static void
+read_color_pixels( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4], const GLubyte mask[] )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaDisplay *dpy = xmesa->xm_visual->display;
register GLuint i;
@@ -4193,7 +4316,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
@@ -4206,7 +4329,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ( p & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
rgba[i][BCOMP] = (GLubyte) ((p >> 16) & 0xff);
@@ -4218,7 +4341,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
@@ -4230,7 +4353,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
@@ -4242,7 +4365,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
@@ -4255,7 +4378,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ( p & 0xE0 );
rgba[i][GCOMP] = (GLubyte) ((p & 0x1C) << 3);
rgba[i][BCOMP] = (GLubyte) ((p & 0x03) << 6);
@@ -4274,7 +4397,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = rTable[p];
rgba[i][GCOMP] = gTable[p];
rgba[i][BCOMP] = bTable[p];
@@ -4289,7 +4412,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i])) ^ bitFlip;
+ x[i], YFLIP(xrb, y[i])) ^ bitFlip;
rgba[i][RCOMP] = (GLubyte) (p * 255);
rgba[i][GCOMP] = (GLubyte) (p * 255);
rgba[i][BCOMP] = (GLubyte) (p * 255);
@@ -4304,6 +4427,7 @@ static void read_color_pixels( const GLcontext *ctx,
}
}
else if (source->backimage) {
+ /* Read from XImage back buffer */
switch (xmesa->pixelformat) {
case PF_Truecolor:
case PF_Dither_True:
@@ -4323,7 +4447,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
- p = XMesaGetPixel( img, x[i], FLIP(source, y[i]) );
+ p = XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
@@ -4335,7 +4459,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_8A8B8G8R:
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr4 = PIXELADDR4( source, x[i], y[i] );
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x[i], y[i]);
GLuint p4 = *ptr4;
rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
@@ -4347,7 +4471,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_8A8R8G8B:
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr4 = PIXELADDR4( source, x[i], y[i] );
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x[i], y[i]);
GLuint p4 = *ptr4;
rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
@@ -4359,7 +4483,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_8R8G8B:
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr4 = PIXELADDR4( source, x[i], y[i] );
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x[i], y[i]);
GLuint p4 = *ptr4;
rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
@@ -4371,7 +4495,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_8R8G8B24:
for (i=0;i<n;i++) {
if (mask[i]) {
- bgr_t *ptr3 = PIXELADDR3( source, x[i], y[i] );
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, x[i], y[i]);
rgba[i][RCOMP] = ptr3->r;
rgba[i][GCOMP] = ptr3->g;
rgba[i][BCOMP] = ptr3->b;
@@ -4382,7 +4506,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_HPCR:
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr1 = PIXELADDR1( source, x[i], y[i] );
+ GLubyte *ptr1 = PIXEL_ADDR1(xrb, x[i], y[i]);
GLubyte p = *ptr1;
rgba[i][RCOMP] = p & 0xE0;
rgba[i][GCOMP] = (p & 0x1C) << 3;
@@ -4402,7 +4526,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
- p = XMesaGetPixel( img, x[i], FLIP(source, y[i]) );
+ p = XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = rTable[p];
rgba[i][GCOMP] = gTable[p];
rgba[i][BCOMP] = bTable[p];
@@ -4418,7 +4542,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
- p = XMesaGetPixel( img, x[i], FLIP(source, y[i]) ) ^ bitFlip;
+ p = XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) ) ^ bitFlip;
rgba[i][RCOMP] = (GLubyte) (p * 255);
rgba[i][GCOMP] = (GLubyte) (p * 255);
rgba[i][BCOMP] = (GLubyte) (p * 255);
@@ -4516,6 +4640,25 @@ void xmesa_update_span_funcs( GLcontext *ctx )
int depth=GET_VISUAL_DEPTH(xmesa->xm_visual);
struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference( ctx );
+ if (ctx->DrawBuffer->Name != 0) {
+ /* drawing to user framebuffer */
+ dd->WriteCI32Span = NULL;
+ dd->WriteCI8Span = NULL;
+ dd->WriteMonoCISpan = NULL;
+ dd->WriteCI32Pixels = NULL;
+ dd->WriteMonoCIPixels = NULL;
+ dd->WriteRGBASpan = NULL;
+ dd->WriteRGBSpan = NULL;
+ dd->WriteMonoRGBASpan = NULL;
+ dd->WriteRGBAPixels = NULL;
+ dd->WriteMonoRGBAPixels = NULL;
+ dd->ReadCI32Span = NULL;
+ dd->ReadRGBASpan = NULL;
+ dd->ReadCI32Pixels = NULL;
+ dd->ReadRGBAPixels = NULL;
+ return;
+ }
+
/*
* These drawing functions depend on color buffer config:
*/
@@ -4624,7 +4767,7 @@ void xmesa_update_span_funcs( GLcontext *ctx )
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
break;
default:
- _mesa_problem(NULL,"Bad pixel format in xmesa_update_state (1)");
+ _mesa_problem(ctx, "Bad pixel format in xmesa_update_state (1)");
return;
}
}
@@ -4764,7 +4907,7 @@ void xmesa_update_span_funcs( GLcontext *ctx )
}
break;
default:
- _mesa_problem(NULL,"Bad pixel format in xmesa_update_state (2)");
+ _mesa_problem(ctx, "Bad pixel format in xmesa_update_state (2)");
return;
}
}
@@ -4775,3 +4918,380 @@ void xmesa_update_span_funcs( GLcontext *ctx )
dd->ReadCI32Pixels = read_index_pixels;
dd->ReadRGBAPixels = read_color_pixels;
}
+
+
+#if 000
+/**
+ * Initialize the renderbuffer's PutRow, GetRow, etc. functions
+ */
+static void
+xmesa_set_renderbuffer_funcs(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean pixmap, enum pixel_format pixelformat)
+{
+#if 0
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+
+#endif
+
+ switch (pixelformat) {
+ case PF_Index:
+ if (pixmap) {
+ /*
+ dd->WriteCI32Span = write_span_index_pixmap;
+ dd->WriteCI8Span = write_span_index8_pixmap;
+ dd->WriteMonoCISpan = write_span_mono_index_pixmap;
+ dd->WriteCI32Pixels = write_pixels_index_pixmap;
+ dd->WriteMonoCIPixels = write_pixels_mono_index_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Truecolor:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_TRUECOLOR_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_TRUECOLOR_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_TRUECOLOR_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Dither_True:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_TRUEDITHER_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_TRUEDITHER_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
+ dd->WriteRGBAPixels = write_pixels_TRUEDITHER_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_8A8B8G8R:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_8A8B8G8R_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8A8B8G8R_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8A8B8G8R_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_8A8R8G8B:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_8A8R8G8B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8A8R8G8B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8A8R8G8B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_8R8G8B:
+ /*
+ dd->WriteRGBASpan = write_span_8R8G8B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_8R8G8B_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_8R8G8B_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ break;
+ case PF_8R8G8B24:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_8R8G8B24_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B24_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B24_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_5R6G5B:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_5R6G5B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_5R6G5B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_5R6G5B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Dither_5R6G5B:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_DITHER_5R6G5B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
+ dd->WriteRGBAPixels = write_pixels_DITHER_5R6G5B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Dither:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_DITHER_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER_pixmap;
+ dd->WriteRGBAPixels = write_pixels_DITHER_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_1Bit:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_1BIT_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_1BIT_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_1BIT_pixmap;
+ dd->WriteRGBAPixels = write_pixels_1BIT_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_1BIT_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_HPCR:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_HPCR_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_HPCR_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_HPCR_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ ctx->Driver.ClearColor = clear_color_HPCR_pixmap;
+ }
+ break;
+ case PF_Lookup:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_LOOKUP_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_LOOKUP_pixmap;
+ dd->WriteRGBAPixels = write_pixels_LOOKUP_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Grayscale:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_GRAYSCALE_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_GRAYSCALE_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_GRAYSCALE_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad pixel format in xmesa_update_state (1)");
+ return;
+ }
+
+#if 0000
+#if 0
+ /* Generic RGB */
+ dd->WriteRGBASpan = write_span_TRUECOLOR_ximage;
+ dd->WriteRGBSpan = write_span_rgb_TRUECOLOR_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_TRUECOLOR_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
+#endif
+ break;
+ case PF_Dither_True:
+#if 0
+ dd->WriteRGBASpan = write_span_TRUEDITHER_ximage;
+ dd->WriteRGBSpan = write_span_rgb_TRUEDITHER_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_ximage;
+ dd->WriteRGBAPixels = write_pixels_TRUEDITHER_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_ximage;
+#endif
+ break;
+ case PF_8A8B8G8R:
+#if 0
+ dd->WriteRGBASpan = write_span_8A8B8G8R_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8A8B8G8R_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8A8B8G8R_ximage;
+ dd->WriteRGBAPixels = write_pixels_8A8B8G8R_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8A8B8G8R_ximage;
+#endif
+ break;
+ case PF_8A8R8G8B:
+#if 0
+ dd->WriteRGBASpan = write_span_8A8R8G8B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8A8R8G8B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8A8R8G8B_ximage;
+ dd->WriteRGBAPixels = write_pixels_8A8R8G8B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8A8R8G8B_ximage;
+#endif
+ break;
+ case PF_8R8G8B:
+#if 0
+ dd->WriteRGBASpan = write_span_8R8G8B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8R8G8B_ximage;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8R8G8B_ximage;
+#endif
+ break;
+ case PF_8R8G8B24:
+#if 0
+ dd->WriteRGBASpan = write_span_8R8G8B24_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B24_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8R8G8B24_ximage;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B24_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8R8G8B24_ximage;
+#endif
+ break;
+ case PF_5R6G5B:
+#if 0
+ dd->WriteRGBASpan = write_span_5R6G5B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_5R6G5B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_5R6G5B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
+#endif
+ break;
+ case PF_Dither_5R6G5B:
+#if 0
+ dd->WriteRGBASpan = write_span_DITHER_5R6G5B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER_5R6G5B_ximage;
+ dd->WriteRGBAPixels = write_pixels_DITHER_5R6G5B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_5R6G5B_ximage;
+#endif
+ break;
+ case PF_Dither:
+#if 0
+ if (depth==8) {
+ dd->WriteRGBASpan = write_span_DITHER8_ximage;
+ dd->WriteRGBSpan = write_span_rgb_DITHER8_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER8_ximage;
+ dd->WriteRGBAPixels = write_pixels_DITHER8_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER8_ximage;
+ }
+ else {
+ dd->WriteRGBASpan = write_span_DITHER_ximage;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER_ximage;
+ dd->WriteRGBAPixels = write_pixels_DITHER_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_ximage;
+ }
+#endif
+ break;
+ case PF_1Bit:
+#if 0
+ dd->WriteRGBASpan = write_span_1BIT_ximage;
+ dd->WriteRGBSpan = write_span_rgb_1BIT_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_1BIT_ximage;
+ dd->WriteRGBAPixels = write_pixels_1BIT_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_1BIT_ximage;
+#endif
+ break;
+ case PF_HPCR:
+#if 0
+ dd->WriteRGBASpan = write_span_HPCR_ximage;
+ dd->WriteRGBSpan = write_span_rgb_HPCR_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_HPCR_ximage;
+ dd->WriteRGBAPixels = write_pixels_HPCR_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_HPCR_ximage;
+ if (xmesa->xm_visual->hpcr_clear_flag) {
+ ctx->Driver.ClearColor = clear_color_HPCR_ximage;
+ }
+#endif
+ break;
+ case PF_Lookup:
+#if 0
+ if (depth==8) {
+ dd->WriteRGBASpan = write_span_LOOKUP8_ximage;
+ dd->WriteRGBSpan = write_rgb_LOOKUP8_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_LOOKUP8_ximage;
+ dd->WriteRGBAPixels = write_pixels_LOOKUP8_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_LOOKUP8_ximage;
+ }
+ else {
+ dd->WriteRGBASpan = write_span_LOOKUP_ximage;
+ dd->WriteRGBSpan = write_span_rgb_LOOKUP_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_LOOKUP_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
+ }
+#endif
+ break;
+ case PF_Grayscale:
+#if 0
+ if (depth==8) {
+ dd->WriteRGBASpan = write_span_GRAYSCALE8_ximage;
+ dd->WriteRGBSpan = write_span_rgb_GRAYSCALE8_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_GRAYSCALE8_ximage;
+ dd->WriteRGBAPixels = write_pixels_GRAYSCALE8_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_GRAYSCALE8_ximage;
+ }
+ else {
+ dd->WriteRGBASpan = write_span_GRAYSCALE_ximage;
+ dd->WriteRGBSpan = write_span_rgb_GRAYSCALE_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_GRAYSCALE_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
+ }
+#endif
+ break;
+ default:
+ _mesa_problem(ctx, "Bad pixel format in xmesa_update_state (2)");
+ return;
+ }
+ }
+#endif
+
+
+ /* Pixel/span reading functions: */
+#if 0
+ rb->ReadCI32Span = read_index_span;
+ dd->ReadRGBASpan = read_color_span;
+ dd->ReadCI32Pixels = read_index_pixels;
+ dd->ReadRGBAPixels = read_color_pixels;
+#else
+ rb->GetRow = get_row_color;
+ rb->GetValues = get_values_color;
+#endif
+}
+
+#endif
+
diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c
index 8fd22ccf4e..8b5c39392a 100644
--- a/src/mesa/drivers/x11/xm_tri.c
+++ b/src/mesa/drivers/x11/xm_tri.c
@@ -44,6 +44,9 @@
#include "swrast/s_triangle.h"
+#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
+ (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]
+
/**********************************************************************/
/*** Triangle rendering ***/
@@ -59,10 +62,10 @@
#define INTERP_RGB 1
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
GLuint i; \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
@@ -70,7 +73,7 @@
unsigned long p; \
PACK_TRUECOLOR(p, FixedToInt(span.red), \
FixedToInt(span.green), FixedToInt(span.blue)); \
- XMesaPutPixel(img, x, y, p); \
+ XMesaPutPixel(xrb->ximage, x, y, p); \
zRow[i] = z; \
} \
span.red += span.redStep; \
@@ -91,12 +94,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
-
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -123,11 +125,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
@@ -155,11 +157,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
@@ -187,11 +189,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -221,17 +223,17 @@
#define INTERP_RGB 1
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
unsigned long p; \
PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
FixedToInt(span.green), FixedToInt(span.blue)); \
- XMesaPutPixel(img, x, y, p); \
+ XMesaPutPixel(xrb->ximage, x, y, p); \
zRow[i] = z; \
} \
span.red += span.redStep; \
@@ -250,11 +252,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -280,14 +282,15 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -311,14 +314,14 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
XDITHER_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
@@ -344,11 +347,11 @@
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
XDITHER_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
@@ -374,11 +377,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
LOOKUP_SETUP; \
@@ -405,14 +408,15 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -437,12 +441,13 @@
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
unsigned long pixel; \
PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -461,13 +466,12 @@
#define NAME flat_8A8B8G8R_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- unsigned long p = PACK_8B8G8R( v2->color[0], \
- v2->color[1], v2->color[2] );
+ GET_XRB(xrb); \
+ GLuint p = PACK_8B8G8R( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -488,13 +492,12 @@
#define NAME flat_8A8R8G8B_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- unsigned long p = PACK_8R8G8B( v2->color[0], \
- v2->color[1], v2->color[2] );
+ GET_XRB(xrb); \
+ GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -515,13 +518,12 @@
#define NAME flat_8R8G8B_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- unsigned long p = PACK_8R8G8B( v2->color[0], \
- v2->color[1], v2->color[2] );
+ GET_XRB(xrb); \
+ GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -529,9 +531,12 @@
if (z < zRow[i]) { \
pRow[i] = (PIXEL_TYPE) p; \
zRow[i] = z; \
+ if (span.y == 100) printf("pass\n");\
} \
+ else if (span.y == 100) printf("fail\n");\
span.z += span.zStep; \
}
+
#include "swrast/s_tritemp.h"
@@ -542,11 +547,11 @@
#define NAME flat_8R8G8B24_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = v2->color;
#define RENDER_SPAN( span ) \
GLuint i; \
@@ -573,10 +578,11 @@
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -598,13 +604,12 @@
#define NAME flat_5R6G5B_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- unsigned long p = PACK_5R6G5B( v2->color[0], \
- v2->color[1], v2->color[2] );
+ GET_XRB(xrb); \
+ GLushort p = PACK_5R6G5B( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -625,15 +630,16 @@
#define NAME flat_DITHER_5R6G5B_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = v2->color;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -653,16 +659,16 @@
#define NAME flat_DITHER8_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
- FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ FLAT_DITHER_ROW_SETUP(YFLIP(xrb, y)); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -682,12 +688,12 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
FLAT_DITHER_ROW_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
@@ -708,17 +714,18 @@
#define NAME flat_HPCR_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
GLubyte r = v2->color[0]; \
GLubyte g = v2->color[1]; \
GLubyte b = v2->color[2];
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -737,11 +744,11 @@
#define NAME flat_LOOKUP8_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
LOOKUP_SETUP; \
GLubyte r = v2->color[0]; \
GLubyte g = v2->color[1]; \
@@ -768,10 +775,11 @@
#define INTERP_RGB 1
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p; \
PACK_TRUECOLOR(p, FixedToInt(span.red), \
@@ -790,11 +798,11 @@
*/
#define NAME smooth_8A8B8G8R_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -813,11 +821,11 @@
*/
#define NAME smooth_8A8R8G8B_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -836,11 +844,11 @@
*/
#define NAME smooth_8R8G8B_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -859,11 +867,11 @@
*/
#define NAME smooth_8R8G8B24_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
PIXEL_TYPE *pixel = pRow; \
@@ -886,10 +894,11 @@
#define INTERP_RGB 1
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p; \
PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
@@ -908,11 +917,11 @@
*/
#define NAME smooth_5R6G5B_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -931,14 +940,15 @@
*/
#define NAME smooth_DITHER_5R6G5B_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
FixedToInt(span.green), FixedToInt(span.blue)); \
@@ -955,14 +965,14 @@
*/
#define NAME smooth_DITHER8_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
XDITHER_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red), \
@@ -981,11 +991,11 @@
#define NAME smooth_DITHER_triangle
#define INTERP_RGB 1
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
XDITHER_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p = XDITHER(x, FixedToInt(span.red), \
@@ -1004,11 +1014,11 @@
*/
#define NAME smooth_LOOKUP8_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
LOOKUP_SETUP; \
@@ -1028,14 +1038,15 @@
*/
#define NAME smooth_HPCR_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
FixedToInt(span.green), FixedToInt(span.blue)); \
@@ -1053,12 +1064,13 @@
#define NAME flat_TRUECOLOR_triangle
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
unsigned long pixel; \
PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
XMesaPutPixel(img, x, y, pixel); \
}
@@ -1070,11 +1082,11 @@
* XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
*/
#define NAME flat_8A8B8G8R_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
unsigned long p = PACK_8B8G8R( v2->color[0], \
v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
@@ -1090,11 +1102,11 @@
* XImage, flat, NON-depth-buffered, PF_8A8R8G8B triangle.
*/
#define NAME flat_8A8R8G8B_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
unsigned long p = PACK_8R8G8B( v2->color[0], \
v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
@@ -1110,11 +1122,11 @@
* XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
*/
#define NAME flat_8R8G8B_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
unsigned long p = PACK_8R8G8B( v2->color[0], \
v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
@@ -1130,11 +1142,11 @@
* XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
*/
#define NAME flat_8R8G8B24_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = v2->color;
#define RENDER_SPAN( span ) \
GLuint i; \
@@ -1154,10 +1166,11 @@
#define NAME flat_TRUEDITHER_triangle
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p; \
PACK_TRUEDITHER(p, x, y, v2->color[0], \
@@ -1172,11 +1185,11 @@
* XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
*/
#define NAME flat_5R6G5B_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
unsigned long p = PACK_5R6G5B( v2->color[0], \
v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
@@ -1192,15 +1205,16 @@
* XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
*/
#define NAME flat_DITHER_5R6G5B_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = v2->color;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
color[GCOMP], color[BCOMP]); \
@@ -1213,16 +1227,16 @@
* XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
*/
#define NAME flat_DITHER8_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
- FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ FLAT_DITHER_ROW_SETUP(YFLIP(xrb, y)); \
for (i = 0; i < span.end; i++, x++) { \
pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
}
@@ -1235,12 +1249,12 @@
*/
#define NAME flat_DITHER_triangle
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
FLAT_DITHER_ROW_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p = FLAT_DITHER(x); \
@@ -1254,17 +1268,18 @@
* XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
*/
#define NAME flat_HPCR_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
GLubyte r = v2->color[0]; \
GLubyte g = v2->color[1]; \
GLubyte b = v2->color[2];
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
}
@@ -1276,11 +1291,11 @@
* XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
*/
#define NAME flat_LOOKUP8_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
LOOKUP_SETUP; \
GLubyte r = v2->color[0]; \
GLubyte g = v2->color[1]; \
@@ -1417,12 +1432,16 @@ static swrast_tri_func get_triangle_func( GLcontext *ctx )
SWcontext *swrast = SWRAST_CONTEXT(ctx);
XMesaContext xmesa = XMESA_CONTEXT(ctx);
int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ return NULL;
#ifdef DEBUG
triFuncName = NULL;
#endif
- if ((ctx->Color._DrawDestMask[0] & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) ==0)
+ if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
+ & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
return (swrast_tri_func) NULL;
if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
@@ -1432,7 +1451,7 @@ static swrast_tri_func get_triangle_func( GLcontext *ctx )
ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
return (swrast_tri_func) NULL;
- if (xmesa->xm_buffer->buffer==XIMAGE) {
+ if (xrb->ximage) {
if ( ctx->Light.ShadeModel==GL_SMOOTH
&& swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 43712ff21f..8e6c9dd48a 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -52,8 +52,11 @@ typedef struct {
} bgr_t;
+struct xmesa_renderbuffer;
+
+
/* Function pointer for clearing color buffers */
-typedef void (*clear_func)( GLcontext *ctx,
+typedef void (*ClearFunc)( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
GLboolean all, GLint x, GLint y,
GLint width, GLint height );
@@ -131,8 +134,6 @@ struct xmesa_visual {
struct xmesa_context {
GLcontext mesa; /* the core library context (containment) */
XMesaVisual xm_visual; /* Describes the buffers */
- XMesaBuffer xm_draw_buffer; /* current draw framebuffer */
- XMesaBuffer xm_read_buffer; /* current read framebuffer */
XMesaBuffer xm_buffer; /* current span/point/line/triangle buffer */
XMesaDisplay *display; /* == xm_visual->display */
@@ -155,6 +156,30 @@ typedef enum {
} BufferType;
+struct xmesa_renderbuffer
+{
+ struct gl_renderbuffer Base; /* Base class */
+
+ XMesaDrawable pixmap; /* Either an X Window ID (front color buf) */
+ /* or X Pixmap ID (back color buf) */
+
+ XMesaImage *ximage; /* The back buffer, if not using a Pixmap */
+
+ GLubyte *origin1; /* used for PIXEL_ADDR1 macro */
+ GLint width1;
+ GLushort *origin2; /* used for PIXEL_ADDR2 macro */
+ GLint width2;
+ GLubyte *origin3; /* used for PIXEL_ADDR3 macro */
+ GLint width3;
+ GLuint *origin4; /* used for PIXEL_ADDR4 macro */
+ GLint width4;
+
+ GLint bottom; /* used for FLIP macro */
+
+ ClearFunc clearFunc;
+};
+
+
/*
* "Derived" from GLframebuffer. Basically corresponds to a GLXDrawable.
*/
@@ -166,12 +191,9 @@ struct xmesa_buffer {
XMesaDisplay *display;
BufferType type; /* window, pixmap, pbuffer or glxwindow */
- XMesaDrawable frontbuffer; /* either a window or pixmap */
- XMesaPixmap backpixmap; /* back buffer Pixmap */
- XMesaImage *backimage; /* back buffer simulated XImage */
- XMesaDrawable buffer; /* the current buffer, either equal to */
- /* frontbuffer, backpixmap or XIMAGE (None) */
+ struct xmesa_renderbuffer *frontxrb; /* front color renderbuffer */
+ struct xmesa_renderbuffer *backxrb; /* back color renderbuffer */
XMesaColormap cmap; /* the X colormap */
@@ -192,17 +214,6 @@ struct xmesa_buffer {
#endif
XMesaImage *rowimage; /* Used for optimized span writing */
-
- GLint bottom; /* used for FLIP macro below */
- GLubyte *ximage_origin1; /* used for PIXELADDR1 macro */
- GLint ximage_width1;
- GLushort *ximage_origin2; /* used for PIXELADDR2 macro */
- GLint ximage_width2;
- GLubyte *ximage_origin3; /* used for PIXELADDR3 macro */
- GLint ximage_width3;
- GLuint *ximage_origin4; /* used for PIXELADDR4 macro */
- GLint ximage_width4;
-
XMesaPixmap stipple_pixmap; /* For polygon stippling */
XMesaGC stipple_gc; /* For polygon stippling */
@@ -237,23 +248,15 @@ struct xmesa_buffer {
fxMesaContext FXctx;
#endif
- /* functions for clearing the front and back color buffers */
- clear_func front_clear_func;
- clear_func back_clear_func;
-
struct xmesa_buffer *Next; /* Linked list pointer: */
};
-
-/* Values for xmesa->dest: */
+/* Values for xmesa->db_state: */
#define FRONT_PIXMAP 1
#define BACK_PIXMAP 2
#define BACK_XIMAGE 4
-/* Special value for X Drawable variables to indicate use of XImage instead */
-#define XIMAGE None
-
/*
* If pixelformat==PF_TRUECOLOR:
@@ -341,7 +344,7 @@ extern const int xmesa_kernel8[DITH_DY * DITH_DX];
/* Dither for random X,Y */
#define DITHER_SETUP \
int __d; \
- unsigned long *ctable = xmesa->xm_buffer->color_table;
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table;
#define DITHER( X, Y, R, G, B ) \
(__d = xmesa_kernel8[(((Y)&3)<<2) | ((X)&3)], \
@@ -352,7 +355,7 @@ extern const int xmesa_kernel8[DITH_DY * DITH_DX];
/* Dither for random X, fixed Y */
#define XDITHER_SETUP(Y) \
int __d; \
- unsigned long *ctable = xmesa->xm_buffer->color_table; \
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \
const int *kernel = &xmesa_kernel8[ ((Y)&3) << 2 ];
#define XDITHER( X, R, G, B ) \
@@ -370,7 +373,7 @@ extern const int xmesa_kernel8[DITH_DY * DITH_DX];
#define FLAT_DITHER_SETUP( R, G, B ) \
GLushort ditherValues[16]; \
{ \
- unsigned long *ctable = xmesa->xm_buffer->color_table; \
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \
int msdr = (DITH_N*((DITH_R)-1)+1) * (R); \
int msdg = (DITH_N*((DITH_G)-1)+1) * (G); \
int msdb = (DITH_N*((DITH_B)-1)+1) * (B); \
@@ -395,7 +398,7 @@ extern const int xmesa_kernel8[DITH_DY * DITH_DX];
#define _dither_lookup(C, c) (((unsigned)((DITH_N * (C - 1) + 1) * c)) >> 12)
#define LOOKUP_SETUP \
- unsigned long *ctable = xmesa->xm_buffer->color_table
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table
#define LOOKUP( R, G, B ) \
ctable[DITH_MIX(_dither_lookup(DITH_R, (R)), \
@@ -438,31 +441,31 @@ extern const int xmesa_kernel1[16];
/*
* If pixelformat==PF_GRAYSCALE:
*/
-#define GRAY_RGB( R, G, B ) xmesa->xm_buffer->color_table[((R) + (G) + (B))/3]
+#define GRAY_RGB( R, G, B ) XMESA_BUFFER(ctx->DrawBuffer)->color_table[((R) + (G) + (B))/3]
/*
* Converts a GL window Y coord to an X window Y coord:
*/
-#define FLIP(BUFFER, Y) ((BUFFER)->bottom-(Y))
+#define YFLIP(XRB, Y) ((XRB)->bottom - (Y))
/*
- * Return the address of a 1, 2 or 4-byte pixel in the back XImage:
+ * Return the address of a 1, 2 or 4-byte pixel in the buffer's XImage:
* X==0 is left, Y==0 is bottom.
*/
-#define PIXELADDR1( BUFFER, X, Y ) \
- ( (BUFFER)->ximage_origin1 - (Y) * (BUFFER)->ximage_width1 + (X) )
+#define PIXEL_ADDR1(XRB, X, Y) \
+ ( (XRB)->origin1 - (Y) * (XRB)->width1 + (X) )
-#define PIXELADDR2( BUFFER, X, Y ) \
- ( (BUFFER)->ximage_origin2 - (Y) * (BUFFER)->ximage_width2 + (X) )
+#define PIXEL_ADDR2(XRB, X, Y) \
+ ( (XRB)->origin2 - (Y) * (XRB)->width2 + (X) )
-#define PIXELADDR3( BUFFER, X, Y ) \
- ( (bgr_t *) ( (BUFFER)->ximage_origin3 - (Y) * (BUFFER)->ximage_width3 + 3 * (X) ))
+#define PIXEL_ADDR3(XRB, X, Y) \
+ ( (bgr_t *) ( (XRB)->origin3 - (Y) * (XRB)->width3 + 3 * (X) ))
-#define PIXELADDR4( BUFFER, X, Y ) \
- ( (BUFFER)->ximage_origin4 - (Y) * (BUFFER)->ximage_width4 + (X) )
+#define PIXEL_ADDR4(XRB, X, Y) \
+ ( (XRB)->origin4 - (Y) * (XRB)->width4 + (X) )
@@ -471,7 +474,13 @@ extern const int xmesa_kernel1[16];
* Return pointer to XMesaContext corresponding to a Mesa GLcontext.
* Since we're using structure containment, it's just a cast!.
*/
-#define XMESA_CONTEXT(MESACTX) (XMesaContext) (MESACTX)
+#define XMESA_CONTEXT(MESACTX) ((XMesaContext) (MESACTX))
+
+/*
+ * Return pointer to XMesaBuffer corresponding to a Mesa GLframebuffer.
+ * Since we're using structure containment, it's just a cast!.
+ */
+#define XMESA_BUFFER(MESABUFF) ((XMesaBuffer) (MESABUFF))
@@ -479,21 +488,29 @@ extern const int xmesa_kernel1[16];
* External functions:
*/
+extern struct xmesa_renderbuffer *
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode);
+
extern unsigned long
-xmesa_color_to_pixel( XMesaContext xmesa,
+xmesa_color_to_pixel( GLcontext *ctx,
GLubyte r, GLubyte g, GLubyte b, GLubyte a,
GLuint pixelFormat );
-extern void xmesa_alloc_back_buffer( XMesaBuffer b );
+extern void
+xmesa_alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height);
-extern void xmesa_resize_buffers( GLframebuffer *buffer );
+extern void xmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint width, GLuint height);
extern void xmesa_init_driver_functions( XMesaVisual xmvisual,
struct dd_function_table *driver );
extern void xmesa_update_state( GLcontext *ctx, GLuint new_state );
-extern void xmesa_update_span_funcs( GLcontext *ctx );
+extern void
+xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb,
+ enum pixel_format pixelformat, GLint depth);
+
extern void xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer,
GLuint bufferBit );