summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-05-04 20:11:35 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-05-04 20:11:35 +0000
commite4b2356c07d31fbeeabb13b2fb47db703b473080 (patch)
treed8b7f1c7c9e7c84d84349485f942dd205dd4c16d /src/mesa
parentebef61f5c0950572f9c6a81b08f447957461675c (diff)
Major check-in of changes for GL_EXT_framebuffer_object extension.
Main driver impacts: - new code for creating the Mesa GLframebuffer - new span/pixel read/write code Some drivers not yet updated/tested.
Diffstat (limited to 'src/mesa')
-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
-rw-r--r--src/mesa/main/accum.c19
-rw-r--r--src/mesa/main/attrib.c7
-rw-r--r--src/mesa/main/blend.c2
-rw-r--r--src/mesa/main/bufferobj.c2
-rw-r--r--src/mesa/main/buffers.c548
-rw-r--r--src/mesa/main/buffers.h7
-rw-r--r--src/mesa/main/config.h13
-rw-r--r--src/mesa/main/context.c241
-rw-r--r--src/mesa/main/context.h36
-rw-r--r--src/mesa/main/dd.h15
-rw-r--r--src/mesa/main/depth.c5
-rw-r--r--src/mesa/main/dlist.c13
-rw-r--r--src/mesa/main/enable.c21
-rw-r--r--src/mesa/main/extensions.c2
-rw-r--r--src/mesa/main/fbobject.c379
-rw-r--r--src/mesa/main/fbobject.h141
-rw-r--r--src/mesa/main/framebuffer.c513
-rw-r--r--src/mesa/main/framebuffer.h67
-rw-r--r--src/mesa/main/get.c114
-rw-r--r--src/mesa/main/get_gen.py54
-rw-r--r--src/mesa/main/matrix.c16
-rw-r--r--src/mesa/main/mtypes.h297
-rw-r--r--src/mesa/main/pixel.c2
-rw-r--r--src/mesa/main/polygon.c3
-rw-r--r--src/mesa/main/rastpos.c2
-rw-r--r--src/mesa/main/renderbuffer.c1863
-rw-r--r--src/mesa/main/renderbuffer.h84
-rw-r--r--src/mesa/main/state.c4
-rw-r--r--src/mesa/main/texformat.c67
-rw-r--r--src/mesa/main/texformat_tmp.h730
-rw-r--r--src/mesa/main/texrender.c197
-rw-r--r--src/mesa/main/texrender.h12
-rw-r--r--src/mesa/main/texstore.c31
-rw-r--r--src/mesa/sources10
-rw-r--r--src/mesa/swrast/s_accum.c802
-rw-r--r--src/mesa/swrast/s_accum.h11
-rw-r--r--src/mesa/swrast/s_alphabuf.c332
-rw-r--r--src/mesa/swrast/s_alphabuf.h80
-rw-r--r--src/mesa/swrast/s_auxbuffer.c129
-rw-r--r--src/mesa/swrast/s_auxbuffer.h41
-rw-r--r--src/mesa/swrast/s_blend.c26
-rw-r--r--src/mesa/swrast/s_blend.h12
-rw-r--r--src/mesa/swrast/s_buffers.c370
-rw-r--r--src/mesa/swrast/s_context.c35
-rw-r--r--src/mesa/swrast/s_context.h3
-rw-r--r--src/mesa/swrast/s_copypix.c82
-rw-r--r--src/mesa/swrast/s_depth.c912
-rw-r--r--src/mesa/swrast/s_depth.h22
-rw-r--r--src/mesa/swrast/s_drawpix.c128
-rw-r--r--src/mesa/swrast/s_feedback.c13
-rw-r--r--src/mesa/swrast/s_imaging.c34
-rw-r--r--src/mesa/swrast/s_linetemp.h3
-rw-r--r--src/mesa/swrast/s_logic.c588
-rw-r--r--src/mesa/swrast/s_logic.h13
-rw-r--r--src/mesa/swrast/s_masking.c80
-rw-r--r--src/mesa/swrast/s_masking.h23
-rw-r--r--src/mesa/swrast/s_nvfragprog.c10
-rw-r--r--src/mesa/swrast/s_readpix.c91
-rw-r--r--src/mesa/swrast/s_span.c459
-rw-r--r--src/mesa/swrast/s_span.h6
-rw-r--r--src/mesa/swrast/s_spantemp.h117
-rw-r--r--src/mesa/swrast/s_stencil.c417
-rw-r--r--src/mesa/swrast/s_stencil.h16
-rw-r--r--src/mesa/swrast/s_texstore.c8
-rw-r--r--src/mesa/swrast/s_triangle.c28
-rw-r--r--src/mesa/swrast/s_tritemp.h9
-rw-r--r--src/mesa/swrast/swrast.h87
-rw-r--r--src/mesa/swrast_setup/ss_tritmp.h2
-rw-r--r--src/mesa/tnl_dd/t_dd_tritmp.h9
196 files changed, 11189 insertions, 6296 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 );
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index 315bd33b61..c1346bab4c 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2003 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"),
@@ -63,6 +63,19 @@ _mesa_Accum( GLenum op, GLfloat value )
return;
}
+ switch (op) {
+ case GL_ADD:
+ case GL_MULT:
+ case GL_ACCUM:
+ case GL_LOAD:
+ case GL_RETURN:
+ /* OK */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)");
+ return;
+ }
+
if (ctx->NewState)
_mesa_update_state( ctx );
@@ -89,6 +102,8 @@ _mesa_Accum( GLenum op, GLfloat value )
ctx->Driver.Accum( ctx, op, value, xpos, ypos, width, height );
}
+
+
void
_mesa_init_accum( GLcontext *ctx )
{
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index d45593cc99..da6011c1ce 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -833,8 +833,13 @@ _mesa_PopAttrib(void)
(GLboolean) (color->ColorMask[1] != 0),
(GLboolean) (color->ColorMask[2] != 0),
(GLboolean) (color->ColorMask[3] != 0));
+#if 0
_mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers,
color->DrawBuffer);
+#else
+ _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
+ color->DrawBuffer, NULL);
+#endif
_mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
_mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef);
_mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled);
@@ -992,6 +997,8 @@ _mesa_PopAttrib(void)
break;
case GL_PIXEL_MODE_BIT:
MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) );
+ /* XXX what other pixel state needs to be set by function calls? */
+ _mesa_ReadBuffer(ctx->Pixel.ReadBuffer);
ctx->NewState |= _NEW_PIXEL;
break;
case GL_POINT_BIT:
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 8fadef61b4..61b2b17c0c 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -570,11 +570,9 @@ void _mesa_init_color( GLcontext * ctx )
if (ctx->Visual.doubleBufferMode) {
ctx->Color.DrawBuffer[0] = GL_BACK;
- ctx->Color._DrawDestMask[0] = DD_BACK_LEFT_BIT;
}
else {
ctx->Color.DrawBuffer[0] = GL_FRONT;
- ctx->Color._DrawDestMask[0] = DD_FRONT_LEFT_BIT;
}
}
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 185d841f81..07b2341ff7 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -900,7 +900,7 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
switch (pname) {
case GL_BUFFER_SIZE_ARB:
- *params = bufObj->Size;
+ *params = (GLint) bufObj->Size;
break;
case GL_BUFFER_USAGE_ARB:
*params = bufObj->Usage;
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 41a1fdb7cc..12f58ff662 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -29,16 +29,15 @@
#include "glheader.h"
-#include "imports.h"
#include "buffers.h"
#include "colormac.h"
#include "context.h"
-#include "depth.h"
#include "enums.h"
#include "fbobject.h"
-#include "stencil.h"
#include "state.h"
-#include "mtypes.h"
+
+
+#define BAD_MASK ~0u
#if _HAVE_FULL_GL
@@ -133,12 +132,12 @@ _mesa_Clear( GLbitfield mask )
_mesa_update_state( ctx ); /* update _Xmin, etc */
}
- if (ctx->RenderMode==GL_RENDER) {
+ if (ctx->RenderMode == GL_RENDER) {
const GLint x = ctx->DrawBuffer->_Xmin;
const GLint y = ctx->DrawBuffer->_Ymin;
const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
- GLbitfield ddMask;
+ GLbitfield bufferMask;
/* don't clear depth buffer if depth writing disabled */
if (!ctx->Depth.Mask)
@@ -146,20 +145,31 @@ _mesa_Clear( GLbitfield mask )
/* Build the bitmask to send to device driver's Clear function.
* Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4
- * of the FRONT/BACK_LEFT/RIGHT_BIT flags.
+ * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the
+ * BUFFER_BIT_COLORn flags.
*/
- ddMask = 0;
- if (mask & GL_COLOR_BUFFER_BIT)
- ddMask |= ctx->Color._DrawDestMask[0];
- if ((mask & GL_DEPTH_BUFFER_BIT) && ctx->Visual.depthBits > 0)
- ddMask |= GL_DEPTH_BUFFER_BIT;
- if ((mask & GL_STENCIL_BUFFER_BIT) && ctx->Visual.stencilBits > 0)
- ddMask |= GL_STENCIL_BUFFER_BIT;
- if ((mask & GL_ACCUM_BUFFER_BIT) && ctx->Visual.accumRedBits > 0)
- ddMask |= GL_ACCUM_BUFFER_BIT;
+ bufferMask = 0;
+ if (mask & GL_COLOR_BUFFER_BIT) {
+ bufferMask |= ctx->DrawBuffer->_ColorDrawBufferMask[0];
+ }
+
+ if ((mask & GL_DEPTH_BUFFER_BIT)
+ && ctx->DrawBuffer->Visual.haveDepthBuffer) {
+ bufferMask |= BUFFER_BIT_DEPTH;
+ }
+
+ if ((mask & GL_STENCIL_BUFFER_BIT)
+ && ctx->DrawBuffer->Visual.haveStencilBuffer) {
+ bufferMask |= BUFFER_BIT_STENCIL;
+ }
+
+ if ((mask & GL_ACCUM_BUFFER_BIT)
+ && ctx->DrawBuffer->Visual.haveAccumBuffer) {
+ bufferMask |= BUFFER_BIT_ACCUM;
+ }
ASSERT(ctx->Driver.Clear);
- ctx->Driver.Clear( ctx, ddMask, (GLboolean) !ctx->Scissor.Enabled,
+ ctx->Driver.Clear( ctx, bufferMask, (GLboolean) !ctx->Scissor.Enabled,
x, y, width, height );
}
}
@@ -167,27 +177,41 @@ _mesa_Clear( GLbitfield mask )
/**
- * Return bitmask of DD_* flags indicating which color buffers are
- * available to the rendering context;
+ * Return bitmask of BUFFER_BIT_* flags indicating which color buffers are
+ * available to the rendering context.
+ * This depends on the framebuffer we're writing to. For window system
+ * framebuffers we look at the framebuffer's visual. But for user-
+ * create framebuffers we look at the number of supported color attachments.
*/
static GLuint
-supported_buffer_bitmask(const GLcontext *ctx)
+supported_buffer_bitmask(const GLcontext *ctx, GLuint framebufferID)
{
- GLuint mask = DD_FRONT_LEFT_BIT; /* always have this */
+ GLuint mask = 0x0;
GLint i;
- if (ctx->Visual.stereoMode) {
- mask |= DD_FRONT_RIGHT_BIT;
- if (ctx->Visual.doubleBufferMode) {
- mask |= DD_BACK_LEFT_BIT | DD_BACK_RIGHT_BIT;
+ if (framebufferID > 0) {
+ /* A user-created renderbuffer */
+ ASSERT(ctx->Extensions.EXT_framebuffer_object);
+ for (i = 0; i < ctx->Const.MaxColorAttachments; i++) {
+ mask |= (BUFFER_BIT_COLOR0 << i);
}
}
- else if (ctx->Visual.doubleBufferMode) {
- mask |= DD_BACK_LEFT_BIT;
- }
+ else {
+ /* A window system renderbuffer */
+ mask = BUFFER_BIT_FRONT_LEFT; /* always have this */
+ if (ctx->Visual.stereoMode) {
+ mask |= BUFFER_BIT_FRONT_RIGHT;
+ if (ctx->Visual.doubleBufferMode) {
+ mask |= BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT;
+ }
+ }
+ else if (ctx->Visual.doubleBufferMode) {
+ mask |= BUFFER_BIT_BACK_LEFT;
+ }
- for (i = 0; i < ctx->Visual.numAuxBuffers; i++) {
- mask |= (DD_AUX0_BIT << i);
+ for (i = 0; i < ctx->Visual.numAuxBuffers; i++) {
+ mask |= (BUFFER_BIT_AUX0 << i);
+ }
}
return mask;
@@ -196,45 +220,53 @@ supported_buffer_bitmask(const GLcontext *ctx)
/**
* Helper routine used by glDrawBuffer and glDrawBuffersARB.
- * Given a GLenum naming (a) color buffer(s), return the corresponding
- * bitmask of DD_* flags.
+ * Given a GLenum naming one or more color buffers (such as
+ * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
*/
static GLuint
draw_buffer_enum_to_bitmask(GLenum buffer)
{
switch (buffer) {
- case GL_FRONT:
- return DD_FRONT_LEFT_BIT | DD_FRONT_RIGHT_BIT;
- case GL_BACK:
- return DD_BACK_LEFT_BIT | DD_BACK_RIGHT_BIT;
case GL_NONE:
return 0;
+ case GL_FRONT:
+ return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT;
+ case GL_BACK:
+ return BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT;
case GL_RIGHT:
- return DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT;
+ return BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT;
case GL_FRONT_RIGHT:
- return DD_FRONT_RIGHT_BIT;
+ return BUFFER_BIT_FRONT_RIGHT;
case GL_BACK_RIGHT:
- return DD_BACK_RIGHT_BIT;
+ return BUFFER_BIT_BACK_RIGHT;
case GL_BACK_LEFT:
- return DD_BACK_LEFT_BIT;
+ return BUFFER_BIT_BACK_LEFT;
case GL_FRONT_AND_BACK:
- return DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT
- | DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT;
+ return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT
+ | BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT;
case GL_LEFT:
- return DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT;
+ return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT;
case GL_FRONT_LEFT:
- return DD_FRONT_LEFT_BIT;
+ return BUFFER_BIT_FRONT_LEFT;
case GL_AUX0:
- return DD_AUX0_BIT;
+ return BUFFER_BIT_AUX0;
case GL_AUX1:
- return DD_AUX1_BIT;
+ return BUFFER_BIT_AUX1;
case GL_AUX2:
- return DD_AUX2_BIT;
+ return BUFFER_BIT_AUX2;
case GL_AUX3:
- return DD_AUX3_BIT;
+ return BUFFER_BIT_AUX3;
+ case GL_COLOR_ATTACHMENT0_EXT:
+ return BUFFER_BIT_COLOR0;
+ case GL_COLOR_ATTACHMENT1_EXT:
+ return BUFFER_BIT_COLOR1;
+ case GL_COLOR_ATTACHMENT2_EXT:
+ return BUFFER_BIT_COLOR2;
+ case GL_COLOR_ATTACHMENT3_EXT:
+ return BUFFER_BIT_COLOR3;
default:
/* error */
- return ~0;
+ return BAD_MASK;
}
}
@@ -249,43 +281,48 @@ read_buffer_enum_to_bitmask(GLenum buffer)
{
switch (buffer) {
case GL_FRONT:
- return DD_FRONT_LEFT_BIT;
+ return BUFFER_BIT_FRONT_LEFT;
case GL_BACK:
- return DD_BACK_LEFT_BIT;
+ return BUFFER_BIT_BACK_LEFT;
case GL_RIGHT:
- return DD_FRONT_RIGHT_BIT;
+ return BUFFER_BIT_FRONT_RIGHT;
case GL_FRONT_RIGHT:
- return DD_FRONT_RIGHT_BIT;
+ return BUFFER_BIT_FRONT_RIGHT;
case GL_BACK_RIGHT:
- return DD_BACK_RIGHT_BIT;
+ return BUFFER_BIT_BACK_RIGHT;
case GL_BACK_LEFT:
- return DD_BACK_LEFT_BIT;
+ return BUFFER_BIT_BACK_LEFT;
case GL_LEFT:
- return DD_FRONT_LEFT_BIT;
+ return BUFFER_BIT_FRONT_LEFT;
case GL_FRONT_LEFT:
- return DD_FRONT_LEFT_BIT;
+ return BUFFER_BIT_FRONT_LEFT;
case GL_AUX0:
- return DD_AUX0_BIT;
+ return BUFFER_BIT_AUX0;
case GL_AUX1:
- return DD_AUX1_BIT;
+ return BUFFER_BIT_AUX1;
case GL_AUX2:
- return DD_AUX2_BIT;
+ return BUFFER_BIT_AUX2;
case GL_AUX3:
- return DD_AUX3_BIT;
+ return BUFFER_BIT_AUX3;
+ case GL_COLOR_ATTACHMENT0_EXT:
+ return BUFFER_BIT_COLOR0;
+ case GL_COLOR_ATTACHMENT1_EXT:
+ return BUFFER_BIT_COLOR1;
+ case GL_COLOR_ATTACHMENT2_EXT:
+ return BUFFER_BIT_COLOR2;
+ case GL_COLOR_ATTACHMENT3_EXT:
+ return BUFFER_BIT_COLOR3;
default:
/* error */
- return ~0;
+ return BAD_MASK;
}
}
-
/**
* Specify which color buffers to draw into.
*
- * \param mode color buffer combination.
- *
- * \sa glDrawBuffer().
+ * \param buffer color buffer, such as GL_LEFT or GL_FRONT_AND_BACK.
*
* Flushes the vertices and verifies the parameter and updates the
* gl_colorbuffer_attrib::_DrawDestMask bitfield. Marks new color state in
@@ -293,160 +330,180 @@ read_buffer_enum_to_bitmask(GLenum buffer)
* dd_function_table::DrawBuffer callback.
*/
void GLAPIENTRY
-_mesa_DrawBuffer( GLenum mode )
+_mesa_DrawBuffer(GLenum buffer)
{
+ GLuint bufferID;
+ GLuint destMask;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(mode));
+ if (MESA_VERBOSE & VERBOSE_API) {
+ _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+ }
- if (ctx->Extensions.EXT_framebuffer_object && ctx->CurrentFramebuffer) {
- /* Set drawbuffer for a framebuffer object */
- if (mode == GL_NONE) {
- ctx->CurrentFramebuffer->DrawBuffer[0] = mode;
- }
- else {
- const GLint k = mode - GL_COLOR_ATTACHMENT0_EXT;
- if (k >= 0 && k < ctx->Const.MaxColorAttachments) {
- /* XXX check that the attachment point's Type != GL_NONE */
- ctx->CurrentFramebuffer->DrawBuffer[0] = mode;
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(mode)");
- return;
- }
- }
+ bufferID = ctx->DrawBuffer->Name;
+
+ if (buffer == GL_NONE) {
+ destMask = 0x0;
}
else {
- /* conventional behaviour */
- /* Do error checking and compute the _DrawDestMask bitfield. */
- GLenum destMask, supportedMask;
-
- destMask = draw_buffer_enum_to_bitmask(mode);
- if (destMask == ~0u) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(mode)");
+ const GLuint supportedMask = supported_buffer_bitmask(ctx, bufferID);
+ destMask = draw_buffer_enum_to_bitmask(buffer);
+ if (destMask == BAD_MASK) {
+ /* totally bogus buffer */
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(buffer)");
return;
}
-
- supportedMask = supported_buffer_bitmask(ctx);
destMask &= supportedMask;
-
- if (destMask == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(mode)");
+ if (destMask == 0x0) {
+ /* none of the named color buffers exist! */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(buffer)");
return;
}
-
- ctx->Color.DrawBuffer[0] = mode;
- ctx->Color._DrawDestMask[0] = destMask;
- ctx->NewState |= _NEW_COLOR;
}
- /*
- * Call device driver function.
- */
- if (ctx->Driver.DrawBuffer)
- (*ctx->Driver.DrawBuffer)(ctx, mode);
+ /* if we get here, there's no error so set new state */
+ _mesa_drawbuffers(ctx, 1, &buffer, &destMask);
}
/**
* Called by glDrawBuffersARB; specifies the destination color buffers
* for N fragment program color outputs.
+ *
+ * XXX This function is called by _mesa_PopAttrib() and we need to do
+ * some more work to deal with the current framebuffer binding state!
*/
void GLAPIENTRY
_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers)
{
+ GLint output;
+ GLuint usedBufferMask, supportedMask;
+ GLuint bufferID;
+ GLuint destMask[MAX_DRAW_BUFFERS];
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ if (!ctx->Extensions.ARB_draw_buffers) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffersARB");
+ return;
+ }
if (n < 1 || n > (GLsizei) ctx->Const.MaxDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)" );
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)");
return;
}
- if (ctx->Extensions.EXT_framebuffer_object && ctx->CurrentFramebuffer) {
- /* Set drawbuffers for a framebuffer object */
- GLint i;
- GLuint usedAttachments = 0x0;
- for (i = 0; i < n; i++) {
- if (buffers[i] == GL_NONE) {
- /* OK */
- ctx->CurrentFramebuffer->DrawBuffer[i] = GL_NONE;
- }
- else {
- const GLint k = buffers[i] - GL_COLOR_ATTACHMENT0_EXT;
- if (k >= 0 && k < ctx->Const.MaxColorAttachments) {
- /* XXX check that the attachment point's Type != GL_NONE */
- if ((1 << k) & usedAttachments) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawBuffersARB(duplicated attachment)");
- return;
- }
- usedAttachments |= (1 << k);
- ctx->CurrentFramebuffer->DrawBuffer[i] = buffers[i];
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(mode)");
- return;
- }
- }
- }
+ bufferID = ctx->DrawBuffer->Name;
+
+ supportedMask = supported_buffer_bitmask(ctx, bufferID);
+ usedBufferMask = 0x0;
- /* set remaining color outputs to NONE */
- for (i = n; i < ctx->Const.MaxDrawBuffers; i++) {
- ctx->CurrentFramebuffer->DrawBuffer[i] = GL_NONE;
+ /* complicated error checking... */
+ for (output = 0; output < n; output++) {
+ if (buffers[output] == GL_NONE) {
+ destMask[output] = 0x0;
}
- }
- else {
- /* Conventional operation */
- GLint i;
- GLuint usedBufferMask, supportedMask;
-
- supportedMask = supported_buffer_bitmask(ctx);
- usedBufferMask = 0;
- for (i = 0; i < n; i++) {
- GLuint destMask = draw_buffer_enum_to_bitmask(buffers[i]);
- if (destMask == ~0u ) {
+ else {
+ destMask[output] = draw_buffer_enum_to_bitmask(buffers[output]);
+ if (destMask[output] == BAD_MASK
+ || _mesa_bitcount(destMask[output]) > 1) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)");
return;
}
- destMask &= supportedMask;
- if (destMask == 0) {
+ destMask[output] &= supportedMask;
+ if (destMask[output] == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawBuffersARB(unsupported buffer)");
return;
}
- if (destMask & usedBufferMask) {
+ if (destMask[output] & usedBufferMask) {
/* can't specify a dest buffer more than once! */
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDrawBuffersARB(duplicated buffer)");
return;
}
+
/* update bitmask */
- usedBufferMask |= destMask;
- /* save state */
- ctx->Color.DrawBuffer[i] = buffers[i];
- ctx->Color._DrawDestMask[i] = destMask;
+ usedBufferMask |= destMask[output];
}
+ }
+
+ /* OK, if we get here, there were no errors so set the new state */
+ _mesa_drawbuffers(ctx, n, buffers, destMask);
+}
+
- /* set remaining color outputs to NONE */
- for (i = n; i < ctx->Const.MaxDrawBuffers; i++) {
- ctx->Color.DrawBuffer[i] = GL_NONE;
- ctx->Color._DrawDestMask[i] = 0;
+/**
+ * Set color output state. Traditionally, there was only one color
+ * output, but fragment programs can now have several distinct color
+ * outputs (see GL_ARB_draw_buffers). This function sets the state
+ * for one such color output.
+ */
+static void
+set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, GLuint destMask)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+ ASSERT(output < ctx->Const.MaxDrawBuffers);
+
+ fb->ColorDrawBuffer[output] = buffer;
+ fb->_ColorDrawBufferMask[output] = destMask;
+
+ if (fb->Name == 0) {
+ /* Set traditional state var */
+ ctx->Color.DrawBuffer[output] = buffer;
+ }
+
+ /* not really needed, will be set later */
+ fb->_NumColorDrawBuffers[output] = 0;
+}
+
+
+/**
+ * Helper routine used by _mesa_DrawBuffer, _mesa_DrawBuffersARB and
+ * _mesa_PopAttrib to set drawbuffer state.
+ */
+void
+_mesa_drawbuffers(GLcontext *ctx, GLsizei n, const GLenum *buffers,
+ const GLuint *destMask)
+{
+ GLuint mask[MAX_DRAW_BUFFERS];
+ GLint output;
+
+ if (!destMask) {
+ /* compute destMask values now */
+ const GLuint bufferID = ctx->DrawBuffer->Name;
+ const GLuint supportedMask = supported_buffer_bitmask(ctx, bufferID);
+ for (output = 0; output < n; output++) {
+ mask[output] = draw_buffer_enum_to_bitmask(buffers[output]);
+ ASSERT(mask[output] != BAD_MASK);
+ mask[output] &= supportedMask;
}
+ destMask = mask;
+ }
+
+ for (output = 0; output < n; output++) {
+ set_color_output(ctx, output, buffers[output], destMask[output]);
+ }
- ctx->NewState |= _NEW_COLOR;
+ /* set remaining color outputs to NONE */
+ for (output = n; output < ctx->Const.MaxDrawBuffers; output++) {
+ set_color_output(ctx, output, GL_NONE, 0x0);
}
+ ctx->NewState |= _NEW_COLOR;
+
/*
* Call device driver function.
*/
if (ctx->Driver.DrawBuffers)
- (*ctx->Driver.DrawBuffers)(ctx, n, buffers);
+ ctx->Driver.DrawBuffers(ctx, n, buffers);
+ else if (ctx->Driver.DrawBuffer)
+ ctx->Driver.DrawBuffer(ctx, buffers[0]);
}
+
/**
* Set the color buffer source for reading pixels.
*
@@ -454,60 +511,53 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers)
*
* \sa glReadBuffer().
*
- * Verifies the parameter and updates gl_pixel_attrib::_ReadSrcMask. Marks
- * new pixel state in __GLcontextRec::NewState and notifies the driver via
- * dd_function_table::ReadBuffer.
*/
void GLAPIENTRY
-_mesa_ReadBuffer( GLenum mode )
+_mesa_ReadBuffer(GLenum buffer)
{
+ struct gl_framebuffer *fb;
+ GLuint srcMask, supportedMask;
+ GLuint bufferID;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ fb = ctx->ReadBuffer;
+ bufferID = fb->Name;
+
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(mode));
+ _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
- if (ctx->Extensions.EXT_framebuffer_object && ctx->CurrentFramebuffer) {
- /* Set readbuffer for a framebuffer object */
- if (mode == GL_NONE) {
- ctx->CurrentFramebuffer->ReadBuffer = mode;
- }
- else {
- const GLint k = mode - GL_COLOR_ATTACHMENT0_EXT;
- if (k >= 0 && k < ctx->Const.MaxColorAttachments) {
- /* XXX check that the attachment point's Type != GL_NONE */
- ctx->CurrentFramebuffer->ReadBuffer = mode;
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(mode)");
- return;
- }
- }
+ if (bufferID > 0 && buffer == GL_NONE) {
+ /* legal! */
+ srcMask = 0x0;
}
else {
- /* conventional operation */
- GLuint srcMask, supportedMask;
-
- srcMask = read_buffer_enum_to_bitmask(mode);
- if (srcMask == ~0u) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(mode)");
+ /* general case */
+ srcMask = read_buffer_enum_to_bitmask(buffer);
+ if (srcMask == BAD_MASK) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(buffer)");
return;
}
- supportedMask = supported_buffer_bitmask(ctx);
+ supportedMask = supported_buffer_bitmask(ctx, bufferID);
if ((srcMask & supportedMask) == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(mode)");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(buffer)");
return;
}
- ctx->Pixel._ReadSrcMask = srcMask;
- ctx->Pixel.ReadBuffer = mode;
- ctx->NewState |= _NEW_PIXEL;
}
+ if (bufferID == 0) {
+ ctx->Pixel.ReadBuffer = buffer;
+ }
+ fb->ColorReadBuffer = buffer;
+ fb->_ColorReadBufferMask = srcMask;
+
+ ctx->NewState |= _NEW_PIXEL;
+
/*
* Call device driver function.
*/
if (ctx->Driver.ReadBuffer)
- (*ctx->Driver.ReadBuffer)(ctx, mode);
+ (*ctx->Driver.ReadBuffer)(ctx, buffer);
}
@@ -524,53 +574,51 @@ _mesa_ReadBuffer( GLenum mode )
* \note This function may be called from within Mesa or called by the
* user directly (see the GL_MESA_resize_buffers extension).
*/
+#if OLD_RENDERBUFFER
+/* THIS FUNCTION IS OBSOLETE!!!
+ * See _mesa_resize_framebuffer
+ */
+#endif
void GLAPIENTRY
_mesa_ResizeBuffersMESA( void )
{
GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
+
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glResizeBuffersMESA\n");
- if (ctx) {
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
-
- if (ctx->DrawBuffer) {
- GLuint buf_width, buf_height;
- GLframebuffer *buffer = ctx->DrawBuffer;
-
- /* ask device driver for size of output buffer */
- (*ctx->Driver.GetBufferSize)( buffer, &buf_width, &buf_height );
+ if (ctx->DrawBuffer && ctx->DrawBuffer->Name == 0) {
+ GLuint newWidth, newHeight;
+ GLframebuffer *buffer = ctx->DrawBuffer;
- /* see if size of device driver's color buffer (window) has changed */
- if (buffer->Width == buf_width && buffer->Height == buf_height)
- return; /* size is as expected */
+ /* ask device driver for size of output buffer */
+ ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight );
- buffer->Width = buf_width;
- buffer->Height = buf_height;
-
- ctx->Driver.ResizeBuffers( buffer );
+ /* see if size of device driver's color buffer (window) has changed */
+ if (buffer->Width != newWidth || buffer->Height != newHeight) {
+ if (ctx->Driver.ResizeBuffers)
+ ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight );
}
+ }
- if (ctx->ReadBuffer && ctx->ReadBuffer != ctx->DrawBuffer) {
- GLuint buf_width, buf_height;
- GLframebuffer *buffer = ctx->ReadBuffer;
-
- /* ask device driver for size of read buffer */
- (*ctx->Driver.GetBufferSize)( buffer, &buf_width, &buf_height );
-
- /* see if size of device driver's color buffer (window) has changed */
- if (buffer->Width == buf_width && buffer->Height == buf_height)
- return; /* size is as expected */
+ if (ctx->ReadBuffer && ctx->ReadBuffer != ctx->DrawBuffer
+ && ctx->ReadBuffer->Name == 0) {
+ GLuint newWidth, newHeight;
+ GLframebuffer *buffer = ctx->ReadBuffer;
- buffer->Width = buf_width;
- buffer->Height = buf_height;
+ /* ask device driver for size of read buffer */
+ ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight );
- ctx->Driver.ResizeBuffers( buffer );
+ /* see if size of device driver's color buffer (window) has changed */
+ if (buffer->Width != newWidth || buffer->Height != newHeight) {
+ if (ctx->Driver.ResizeBuffers)
+ ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight );
}
-
- ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
}
+
+ ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
}
@@ -642,56 +690,6 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
/**********************************************************************/
-/** \name State management */
-/*@{*/
-
-
-/**
- * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields.
- * These values are computed from the buffer's width and height and
- * the scissor box, if it's enabled.
- * \param ctx the GL context.
- */
-void
-_mesa_update_draw_buffer_bounds(GLcontext *ctx)
-{
- GLframebuffer *buffer = ctx->DrawBuffer;
-
- buffer->_Xmin = 0;
- buffer->_Ymin = 0;
- buffer->_Xmax = buffer->Width;
- buffer->_Ymax = buffer->Height;
-
- if (ctx->Scissor.Enabled) {
- if (ctx->Scissor.X > buffer->_Xmin) {
- buffer->_Xmin = ctx->Scissor.X;
- }
- if (ctx->Scissor.Y > buffer->_Ymin) {
- buffer->_Ymin = ctx->Scissor.Y;
- }
- if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) {
- buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width;
- }
- if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) {
- buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height;
- }
- /* finally, check for empty region */
- if (buffer->_Xmin > buffer->_Xmax) {
- buffer->_Xmin = buffer->_Xmax;
- }
- if (buffer->_Ymin > buffer->_Ymax) {
- buffer->_Ymin = buffer->_Ymax;
- }
- }
-
- ASSERT(buffer->_Xmin <= buffer->_Xmax);
- ASSERT(buffer->_Ymin <= buffer->_Ymax);
-}
-
-/*@}*/
-
-
-/**********************************************************************/
/** \name Initialization */
/*@{*/
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index c436e6bf51..0c7f68ee79 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -52,6 +52,10 @@ _mesa_DrawBuffer( GLenum mode );
extern void GLAPIENTRY
_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers);
+extern void
+_mesa_drawbuffers(GLcontext *ctx, GLsizei n, const GLenum *buffers,
+ const GLuint *destMask);
+
extern void GLAPIENTRY
_mesa_ReadBuffer( GLenum mode );
@@ -65,9 +69,6 @@ extern void GLAPIENTRY
_mesa_SampleCoverageARB(GLclampf value, GLboolean invert);
extern void
-_mesa_update_draw_buffer_bounds(GLcontext *ctx);
-
-extern void
_mesa_init_scissor(GLcontext *ctx);
extern void
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 801c10b081..456f8ce76a 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -5,9 +5,9 @@
/*
* 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"),
@@ -71,7 +71,7 @@
/** Maximum pixel map lookup table size */
#define MAX_PIXEL_MAP_TABLE 256
-/** Maximum Number of auxillary color buffers */
+/** Maximum number of auxillary color buffers */
#define MAX_AUX_BUFFERS 4
/** Maximum order (degree) of curves */
@@ -223,7 +223,7 @@
/** For GL_EXT_framebuffer_object */
/*@{*/
-#define MAX_COLOR_ATTACHMENTS 4
+#define MAX_COLOR_ATTACHMENTS 8
/*@}*/
@@ -322,4 +322,9 @@
#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
+/* XXX these are temporary */
+#define NEW_RENDERBUFFER 1
+#define OLD_RENDERBUFFER 1
+
+
#endif /* CONFIG_H */
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 087cc64c33..eb2f2e0c81 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -91,6 +91,7 @@
#include "eval.h"
#include "enums.h"
#include "extensions.h"
+#include "fbobject.h"
#include "feedback.h"
#include "fog.h"
#include "get.h"
@@ -492,13 +493,12 @@ _mesa_create_visual( GLboolean rgbFlag,
/**
* Makes some sanity checks and fills in the fields of the
- * GLvisual structure with the given parameters.
- *
+ * GLvisual object with the given parameters. If the caller needs
+ * to set additional fields, he should just probably init the whole GLvisual
+ * object himself.
* \return GL_TRUE on success, or GL_FALSE on failure.
*
* \sa _mesa_create_visual() above for the parameter description.
- *
- * \note Need to add params for level and numAuxBuffers (at least)
*/
GLboolean
_mesa_initialize_visual( GLvisual *vis,
@@ -520,28 +520,22 @@ _mesa_initialize_visual( GLvisual *vis,
{
assert(vis);
- /* This is to catch bad values from device drivers not updated for
- * Mesa 3.3. Some device drivers just passed 1. That's a REALLY
- * bad value now (a 1-bit depth buffer!?!).
- */
- assert(depthBits == 0 || depthBits > 1);
-
if (depthBits < 0 || depthBits > 32) {
return GL_FALSE;
}
- if (stencilBits < 0 || stencilBits > (GLint) (8 * sizeof(GLstencil))) {
+ if (stencilBits < 0 || stencilBits > STENCIL_BITS) {
return GL_FALSE;
}
- if (accumRedBits < 0 || accumRedBits > (GLint) (8 * sizeof(GLaccum))) {
+ if (accumRedBits < 0 || accumRedBits > ACCUM_BITS) {
return GL_FALSE;
}
- if (accumGreenBits < 0 || accumGreenBits > (GLint) (8 * sizeof(GLaccum))) {
+ if (accumGreenBits < 0 || accumGreenBits > ACCUM_BITS) {
return GL_FALSE;
}
- if (accumBlueBits < 0 || accumBlueBits > (GLint) (8 * sizeof(GLaccum))) {
+ if (accumBlueBits < 0 || accumBlueBits > ACCUM_BITS) {
return GL_FALSE;
}
- if (accumAlphaBits < 0 || accumAlphaBits > (GLint) (8 * sizeof(GLaccum))) {
+ if (accumAlphaBits < 0 || accumAlphaBits > ACCUM_BITS) {
return GL_FALSE;
}
@@ -553,14 +547,16 @@ _mesa_initialize_visual( GLvisual *vis,
vis->greenBits = greenBits;
vis->blueBits = blueBits;
vis->alphaBits = alphaBits;
+ vis->rgbBits = redBits + greenBits + blueBits;
vis->indexBits = indexBits;
vis->depthBits = depthBits;
- vis->accumRedBits = (accumRedBits > 0) ? (8 * sizeof(GLaccum)) : 0;
- vis->accumGreenBits = (accumGreenBits > 0) ? (8 * sizeof(GLaccum)) : 0;
- vis->accumBlueBits = (accumBlueBits > 0) ? (8 * sizeof(GLaccum)) : 0;
- vis->accumAlphaBits = (accumAlphaBits > 0) ? (8 * sizeof(GLaccum)) : 0;
- vis->stencilBits = (stencilBits > 0) ? (8 * sizeof(GLstencil)) : 0;
+ vis->stencilBits = stencilBits;
+
+ vis->accumRedBits = accumRedBits;
+ vis->accumGreenBits = accumGreenBits;
+ vis->accumBlueBits = accumBlueBits;
+ vis->accumAlphaBits = accumAlphaBits;
vis->haveAccumBuffer = accumRedBits > 0;
vis->haveDepthBuffer = depthBits > 0;
@@ -569,6 +565,7 @@ _mesa_initialize_visual( GLvisual *vis,
vis->numAuxBuffers = 0;
vis->level = 0;
vis->pixmapMode = 0;
+ vis->sampleBuffers = numSamples > 0 ? 1 : 0;
vis->samples = numSamples;
return GL_TRUE;
@@ -592,160 +589,6 @@ _mesa_destroy_visual( GLvisual *vis )
/**********************************************************************/
-/** \name GL Framebuffer allocation/destruction */
-/**********************************************************************/
-/*@{*/
-
-/**
- * Allocate a GLframebuffer structure and initializes it via
- * _mesa_initialize_framebuffer().
- *
- * A GLframebuffer is a structure which encapsulates the depth, stencil and
- * accum buffers and related parameters.
- *
- * Note that the actual depth/stencil/accum/etc buffers are not allocated
- * at this time. It's up to the device driver and/or swrast module to
- * allocate them as needed.
- *
- * \param visual a GLvisual pointer (we copy the struct contents)
- * \param softwareDepth create/use a software depth buffer?
- * \param softwareStencil create/use a software stencil buffer?
- * \param softwareAccum create/use a software accum buffer?
- * \param softwareAlpha create/use a software alpha buffer?
- *
- * \return pointer to new GLframebuffer struct or NULL if error.
- *
- * \note Need to add softwareAuxBuffers parameter.
- */
-GLframebuffer *
-_mesa_create_framebuffer( const GLvisual *visual,
- GLboolean softwareDepth,
- GLboolean softwareStencil,
- GLboolean softwareAccum,
- GLboolean softwareAlpha )
-{
- GLframebuffer *buffer = CALLOC_STRUCT(gl_frame_buffer);
- assert(visual);
- if (buffer) {
- _mesa_initialize_framebuffer(buffer, visual,
- softwareDepth, softwareStencil,
- softwareAccum, softwareAlpha );
- }
- return buffer;
-}
-
-
-/**
- * Makes some sanity checks and fills in the fields of the
- * GLframebuffer structure with the given parameters.
- *
- * \sa _mesa_create_framebuffer() above for the parameter description.
- */
-void
-_mesa_initialize_framebuffer( GLframebuffer *buffer,
- const GLvisual *visual,
- GLboolean softwareDepth,
- GLboolean softwareStencil,
- GLboolean softwareAccum,
- GLboolean softwareAlpha )
-{
- GLboolean softwareAux = GL_FALSE;
- assert(buffer);
- assert(visual);
-
- _mesa_bzero(buffer, sizeof(GLframebuffer));
-
- /* sanity checks */
- if (softwareDepth ) {
- assert(visual->depthBits > 0);
- }
- if (softwareStencil) {
- assert(visual->stencilBits > 0);
- }
- if (softwareAccum) {
- assert(visual->rgbMode);
- assert(visual->accumRedBits > 0);
- assert(visual->accumGreenBits > 0);
- assert(visual->accumBlueBits > 0);
- }
- if (softwareAlpha) {
- assert(visual->rgbMode);
- assert(visual->alphaBits > 0);
- }
-
- buffer->Visual = *visual;
- buffer->UseSoftwareDepthBuffer = softwareDepth;
- buffer->UseSoftwareStencilBuffer = softwareStencil;
- buffer->UseSoftwareAccumBuffer = softwareAccum;
- buffer->UseSoftwareAlphaBuffers = softwareAlpha;
- buffer->UseSoftwareAuxBuffers = softwareAux;
-}
-
-
-/**
- * Free a framebuffer struct and its buffers.
- *
- * Calls _mesa_free_framebuffer_data() and frees the structure.
- */
-void
-_mesa_destroy_framebuffer( GLframebuffer *buffer )
-{
- if (buffer) {
- _mesa_free_framebuffer_data(buffer);
- FREE(buffer);
- }
-}
-
-
-/**
- * Free the data hanging off of \p buffer, but not \p buffer itself.
- *
- * \param buffer framebuffer.
- *
- * Frees all the buffers associated with the structure.
- */
-void
-_mesa_free_framebuffer_data( GLframebuffer *buffer )
-{
- if (!buffer)
- return;
-
- if (buffer->UseSoftwareDepthBuffer && buffer->DepthBuffer) {
- MESA_PBUFFER_FREE( buffer->DepthBuffer );
- buffer->DepthBuffer = NULL;
- }
- if (buffer->UseSoftwareAccumBuffer && buffer->Accum) {
- MESA_PBUFFER_FREE( buffer->Accum );
- buffer->Accum = NULL;
- }
- if (buffer->UseSoftwareStencilBuffer && buffer->Stencil) {
- MESA_PBUFFER_FREE( buffer->Stencil );
- buffer->Stencil = NULL;
- }
- if (buffer->UseSoftwareAlphaBuffers){
- if (buffer->FrontLeftAlpha) {
- MESA_PBUFFER_FREE( buffer->FrontLeftAlpha );
- buffer->FrontLeftAlpha = NULL;
- }
- if (buffer->BackLeftAlpha) {
- MESA_PBUFFER_FREE( buffer->BackLeftAlpha );
- buffer->BackLeftAlpha = NULL;
- }
- if (buffer->FrontRightAlpha) {
- MESA_PBUFFER_FREE( buffer->FrontRightAlpha );
- buffer->FrontRightAlpha = NULL;
- }
- if (buffer->BackRightAlpha) {
- MESA_PBUFFER_FREE( buffer->BackRightAlpha );
- buffer->BackRightAlpha = NULL;
- }
- }
-}
-
-/*@}*/
-
-
-/**********************************************************************/
/** \name Context allocation, initialization, destroying
*
* The purpose of the most initialization functions here is to provide the
@@ -1552,6 +1395,8 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->Visual = *visual;
ctx->DrawBuffer = NULL;
ctx->ReadBuffer = NULL;
+ ctx->WinSysDrawBuffer = NULL;
+ ctx->WinSysReadBuffer = NULL;
/* Plug in driver functions and context pointer here.
* This is important because when we call alloc_shared_state() below
@@ -1662,7 +1507,7 @@ _mesa_free_context_data( GLcontext *ctx )
{
/* if we're destroying the current context, unbind it first */
if (ctx == _mesa_get_current_context()) {
- _mesa_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
_mesa_free_lighting_data( ctx );
@@ -1878,20 +1723,6 @@ check_compatible(const GLcontext *ctx, const GLframebuffer *buffer)
/**
- * Set the current context, binding the given frame buffer to the context.
- *
- * \param newCtx new GL context.
- * \param buffer framebuffer.
- *
- * Calls _mesa_make_current2() with \p buffer as read and write framebuffer.
- */
-void
-_mesa_make_current( GLcontext *newCtx, GLframebuffer *buffer )
-{
- _mesa_make_current2( newCtx, buffer, buffer );
-}
-
-/**
* Bind the given context to the given draw-buffer and read-buffer and
* make it the current context for this thread.
*
@@ -1911,11 +1742,11 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *buffer )
* troubleshooting.
*/
void
-_mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
- GLframebuffer *readBuffer )
+_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer )
{
if (MESA_VERBOSE)
- _mesa_debug(newCtx, "_mesa_make_current2()\n");
+ _mesa_debug(newCtx, "_mesa_make_current()\n");
/* Check that the context's and framebuffer's visuals are compatible.
*/
@@ -1936,7 +1767,6 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
_glapi_set_context((void *) newCtx);
ASSERT(_mesa_get_current_context() == newCtx);
-
if (!newCtx) {
_glapi_set_dispatch(NULL); /* none current */
}
@@ -1945,8 +1775,21 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
if (drawBuffer && readBuffer) {
/* TODO: check if newCtx and buffer's visual match??? */
+
+#if NEW_RENDERBUFFER
+ ASSERT(drawBuffer->Name == 0);
+ ASSERT(readBuffer->Name == 0);
+ newCtx->WinSysDrawBuffer = drawBuffer;
+ newCtx->WinSysReadBuffer = readBuffer;
+ /* don't replace user-buffer bindings with window system buffer */
+ if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
+ newCtx->DrawBuffer = drawBuffer;
+ newCtx->ReadBuffer = readBuffer;
+ }
+#else
newCtx->DrawBuffer = drawBuffer;
newCtx->ReadBuffer = readBuffer;
+#endif
newCtx->NewState |= _NEW_BUFFERS;
#if _HAVE_FULL_GL
@@ -1956,9 +1799,9 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
/* ask device driver for size of the buffer */
(*newCtx->Driver.GetBufferSize)(drawBuffer, &bufWidth, &bufHeight);
/* set initial buffer size */
- drawBuffer->Width = bufWidth;
- drawBuffer->Height = bufHeight;
- newCtx->Driver.ResizeBuffers( drawBuffer );
+ if (newCtx->Driver.ResizeBuffers)
+ newCtx->Driver.ResizeBuffers(newCtx, drawBuffer,
+ bufWidth, bufHeight);
drawBuffer->Initialized = GL_TRUE;
}
@@ -1968,9 +1811,9 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
/* ask device driver for size of the buffer */
(*newCtx->Driver.GetBufferSize)(readBuffer, &bufWidth, &bufHeight);
/* set initial buffer size */
- readBuffer->Width = bufWidth;
- readBuffer->Height = bufHeight;
- newCtx->Driver.ResizeBuffers( readBuffer );
+ if (newCtx->Driver.ResizeBuffers)
+ newCtx->Driver.ResizeBuffers(newCtx, readBuffer,
+ bufWidth, bufHeight);
readBuffer->Initialized = GL_TRUE;
}
#endif
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 4b041edc6d..8b7e7c9952 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -99,34 +99,6 @@ _mesa_destroy_visual( GLvisual *vis );
/**********************************************************************/
-/** \name Create/destroy a GLframebuffer. */
-/*@{*/
-
-extern GLframebuffer *
-_mesa_create_framebuffer( const GLvisual *visual,
- GLboolean softwareDepth,
- GLboolean softwareStencil,
- GLboolean softwareAccum,
- GLboolean softwareAlpha );
-
-extern void
-_mesa_initialize_framebuffer( GLframebuffer *fb,
- const GLvisual *visual,
- GLboolean softwareDepth,
- GLboolean softwareStencil,
- GLboolean softwareAccum,
- GLboolean softwareAlpha );
-
-extern void
-_mesa_free_framebuffer_data( GLframebuffer *buffer );
-
-extern void
-_mesa_destroy_framebuffer( GLframebuffer *buffer );
-
-/*@}*/
-
-
-/**********************************************************************/
/** \name Create/destroy a GLcontext. */
/*@{*/
@@ -155,12 +127,8 @@ _mesa_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
extern void
-_mesa_make_current( GLcontext *ctx, GLframebuffer *buffer );
-
-
-extern void
-_mesa_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer,
- GLframebuffer *readBuffer );
+_mesa_make_current( GLcontext *ctx, GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer );
extern GLboolean
_mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare);
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 1d9d366014..3746e4685c 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -75,12 +75,10 @@ struct dd_function_table {
GLuint *width, GLuint *height );
/**
- * Resize the driver's depth/stencil/accum/back buffers to match the
- * size given in the GLframebuffer struct.
- *
- * This is typically called when Mesa detects that a window size has changed.
+ * Resize the given framebuffer to the given size.
*/
- void (*ResizeBuffers)( GLframebuffer *buffer );
+ void (*ResizeBuffers)( GLcontext *ctx, GLframebuffer *fb,
+ GLuint width, GLuint height);
/**
* Called whenever an error is generated.
@@ -795,6 +793,13 @@ struct dd_function_table {
/*@{*/
struct gl_framebuffer * (*NewFramebuffer)(GLcontext *ctx, GLuint name);
struct gl_renderbuffer * (*NewRenderbuffer)(GLcontext *ctx, GLuint name);
+ void (*FramebufferRenderbuffer)(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb);
+ void (*RenderbufferTexture)(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset);
/*@}*/
#endif
diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c
index 6c60222096..aca471a06c 100644
--- a/src/mesa/main/depth.c
+++ b/src/mesa/main/depth.c
@@ -162,13 +162,15 @@ void _mesa_init_depth( GLcontext * ctx )
ctx->Depth.Mask = GL_TRUE;
ctx->Depth.OcclusionTest = GL_FALSE;
+ /* XXX this is now per-framebuffer state */
+#if 00
/* Z buffer stuff */
if (ctx->Visual.depthBits == 0) {
/* Special case. Even if we don't have a depth buffer we need
* good values for DepthMax for Z vertex transformation purposes
* and for per-fragment fog computation.
*/
- ctx->DepthMax = 1 << 16;
+ ctx->DepthMax = (1 << 16) - 1;
ctx->DepthMaxF = (GLfloat) ctx->DepthMax;
}
else if (ctx->Visual.depthBits < 32) {
@@ -183,4 +185,5 @@ void _mesa_init_depth( GLcontext * ctx )
ctx->DepthMaxF = (GLfloat) ctx->DepthMax;
}
ctx->MRD = 1.0; /* Minimum resolvable depth value, for polygon offset */
+#endif
}
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index effdb7702a..2541d5c4af 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -2850,7 +2850,8 @@ static void GLAPIENTRY save_PolygonOffset( GLfloat factor, GLfloat units )
static void GLAPIENTRY save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
{
GET_CURRENT_CONTEXT(ctx);
- save_PolygonOffset(factor, ctx->DepthMaxF * bias);
+ /* XXX mult by DepthMaxF here??? */
+ save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias);
}
@@ -7422,14 +7423,6 @@ static void GLAPIENTRY exec_UnlockArraysEXT( void )
ctx->Exec->UnlockArraysEXT( );
}
-static void GLAPIENTRY exec_ResizeBuffersMESA( void )
-{
- GET_CURRENT_CONTEXT(ctx);
- FLUSH_VERTICES(ctx, 0);
- ctx->Exec->ResizeBuffersMESA( );
-}
-
-
static void GLAPIENTRY exec_ClientActiveTextureARB( GLenum target )
{
GET_CURRENT_CONTEXT(ctx);
@@ -7847,7 +7840,7 @@ _mesa_init_dlist_table( struct _glapi_table *table )
table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT;
/* 196. GL_MESA_resize_buffers */
- table->ResizeBuffersMESA = exec_ResizeBuffersMESA;
+ table->ResizeBuffersMESA = _mesa_ResizeBuffersMESA;
/* 197. GL_MESA_window_pos */
table->WindowPos2dMESA = save_WindowPos2dMESA;
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index f53ae05d17..671db68ce8 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -301,7 +301,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
break;
case GL_DEPTH_TEST:
- if (state && ctx->Visual.depthBits==0) {
+ if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
_mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
return;
}
@@ -575,7 +575,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
ctx->Texture.SharedPalette = state;
break;
case GL_STENCIL_TEST:
- if (state && ctx->Visual.stencilBits==0) {
+ if (state && ctx->DrawBuffer->Visual.stencilBits == 0) {
_mesa_warning(ctx,
"glEnable(GL_STENCIL_TEST) but no stencil buffer");
return;
@@ -591,7 +591,8 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT;
if (state)
newenabled |= TEXTURE_1D_BIT;
- if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
@@ -603,7 +604,8 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT;
if (state)
newenabled |= TEXTURE_2D_BIT;
- if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
@@ -615,7 +617,8 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT;
if (state)
newenabled |= TEXTURE_3D_BIT;
- if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
@@ -777,7 +780,8 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
CHECK_EXTENSION(ARB_texture_cube_map, cap);
if (state)
newenabled |= TEXTURE_CUBE_BIT;
- if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
@@ -938,7 +942,8 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
CHECK_EXTENSION(NV_texture_rectangle, cap);
if (state)
newenabled |= TEXTURE_RECT_BIT;
- if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->Enabled = newenabled;
@@ -972,7 +977,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_EXT_depth_bounds_test */
case GL_DEPTH_BOUNDS_TEST_EXT:
CHECK_EXTENSION(EXT_depth_bounds_test, cap);
- if (state && ctx->Visual.depthBits==0) {
+ if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
_mesa_warning(ctx,
"glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
return;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 5bbceb5ab7..150492e7c3 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -227,7 +227,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
ctx->Extensions.EXT_convolution = GL_TRUE;
ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
ctx->Extensions.EXT_fog_coord = GL_TRUE;
- /*ctx->Extensions.EXT_framebuffer_object = GL_TRUE;*/
+ ctx->Extensions.EXT_framebuffer_object = GL_TRUE; /*FALSE;*/
ctx->Extensions.EXT_histogram = GL_TRUE;
ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
ctx->Extensions.EXT_paletted_texture = GL_TRUE;
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 3480beaa47..beaf4ed942 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -31,7 +31,9 @@
#include "context.h"
#include "fbobject.h"
+#include "framebuffer.h"
#include "hash.h"
+#include "renderbuffer.h"
#include "teximage.h"
#include "texstore.h"
@@ -95,103 +97,6 @@ lookup_framebuffer(GLcontext *ctx, GLuint id)
/**
- * Allocate a new gl_framebuffer.
- * This is the default function for ctx->Driver.NewFramebuffer().
- */
-struct gl_framebuffer *
-_mesa_new_framebuffer(GLcontext *ctx, GLuint name)
-{
- struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer);
- if (fb) {
- fb->Name = name;
- fb->RefCount = 1;
- fb->Delete = _mesa_delete_framebuffer;
- }
- return fb;
-}
-
-
-/**
- * Delete a gl_framebuffer.
- * This is the default function for framebuffer->Delete().
- */
-void
-_mesa_delete_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
-{
- (void) ctx;
- _mesa_free(fb);
-}
-
-
-/**
- * Allocate the actual storage for a renderbuffer with the given format
- * and dimensions.
- * This is the default function for gl_renderbuffer->AllocStorage().
- * All incoming parameters will have already been checked for errors.
- * If memory allocate fails, the function must call
- * _mesa_error(GL_OUT_OF_MEMORY) and then return.
- * \return GL_TRUE for success, GL_FALSE for failure.
- */
-static GLboolean
-alloc_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
- GLenum internalFormat, GLuint width, GLuint height)
-{
- /* First, free any existing storage */
- if (rb->Data) {
- _mesa_free(rb->Data);
- }
-
- /* Now, allocate new storage */
- rb->Data = _mesa_malloc(width * height * 4); /* XXX fix size! */
- if (rb->Data == NULL) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRenderbufferStorageEXT");
- return GL_FALSE;
- }
-
- /* We set these fields now if the allocation worked */
- rb->Width = width;
- rb->Height = height;
- rb->InternalFormat = internalFormat;
-
- return GL_TRUE;
-}
-
-
-/**
- * Allocate a new gl_renderbuffer.
- * This is the default function for ctx->Driver.NewRenderbuffer().
- */
-struct gl_renderbuffer *
-_mesa_new_renderbuffer(GLcontext *ctx, GLuint name)
-{
- struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer);
- if (rb) {
- rb->Name = name;
- rb->RefCount = 1;
- rb->Delete = _mesa_delete_renderbuffer;
- rb->AllocStorage = alloc_renderbuffer_storage;
- /* other fields are zero */
- }
- return rb;
-}
-
-
-/**
- * Delete a gl_framebuffer.
- * This is the default function for framebuffer->Delete().
- */
-void
-_mesa_delete_renderbuffer(GLcontext *ctx, struct gl_renderbuffer *rb)
-{
- (void) ctx;
- if (rb->Data) {
- _mesa_free(rb->Data);
- }
- _mesa_free(rb);
-}
-
-
-/**
* Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding
* gl_renderbuffer_attachment object.
*/
@@ -221,11 +126,11 @@ get_attachment(GLcontext *ctx, struct gl_framebuffer *fb, GLenum attachment)
if (i >= ctx->Const.MaxColorAttachments) {
return NULL;
}
- return &fb->ColorAttachment[i];
+ return &fb->Attachment[BUFFER_COLOR0 + i];
case GL_DEPTH_ATTACHMENT_EXT:
- return &fb->DepthAttachment;
+ return &fb->Attachment[BUFFER_DEPTH];
case GL_STENCIL_ATTACHMENT_EXT:
- return &fb->StencilAttachment;
+ return &fb->Attachment[BUFFER_STENCIL];
default:
return NULL;
}
@@ -236,12 +141,17 @@ get_attachment(GLcontext *ctx, struct gl_framebuffer *fb, GLenum attachment)
* Remove any texture or renderbuffer attached to the given attachment
* point. Update reference counts, etc.
*/
-static void
-remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
+void
+_mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
{
if (att->Type == GL_TEXTURE) {
ASSERT(att->Texture);
- ASSERT(!att->Renderbuffer);
+ if (att->Renderbuffer) {
+ /* delete/remove the 'wrapper' renderbuffer */
+ /* XXX do we really want to do this??? */
+ att->Renderbuffer->Delete(att->Renderbuffer);
+ att->Renderbuffer = NULL;
+ }
att->Texture->RefCount--;
if (att->Texture->RefCount == 0) {
ctx->Driver.DeleteTexture(ctx, att->Texture);
@@ -253,7 +163,7 @@ remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
ASSERT(!att->Texture);
att->Renderbuffer->RefCount--;
if (att->Renderbuffer->RefCount == 0) {
- att->Renderbuffer->Delete(ctx, att->Renderbuffer);
+ att->Renderbuffer->Delete(att->Renderbuffer);
}
att->Renderbuffer = NULL;
}
@@ -266,13 +176,13 @@ remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
* Bind a texture object to an attachment point.
* The previous binding, if any, will be removed first.
*/
-static void
-set_texture_attachment(GLcontext *ctx,
- struct gl_renderbuffer_attachment *att,
- struct gl_texture_object *texObj,
- GLenum texTarget, GLuint level, GLuint zoffset)
+void
+_mesa_set_texture_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset)
{
- remove_attachment(ctx, att);
+ _mesa_remove_attachment(ctx, att);
att->Type = GL_TEXTURE;
att->Texture = texObj;
att->TextureLevel = level;
@@ -284,6 +194,7 @@ set_texture_attachment(GLcontext *ctx,
}
att->Zoffset = zoffset;
att->Complete = GL_FALSE;
+
texObj->RefCount++;
/* XXX when we attach to a texture, we should probably set the
@@ -297,12 +208,12 @@ set_texture_attachment(GLcontext *ctx,
* Bind a renderbuffer to an attachment point.
* The previous binding, if any, will be removed first.
*/
-static void
-set_renderbuffer_attachment(GLcontext *ctx,
- struct gl_renderbuffer_attachment *att,
- struct gl_renderbuffer *rb)
+void
+_mesa_set_renderbuffer_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb)
{
- remove_attachment(ctx, att);
+ _mesa_remove_attachment(ctx, att);
att->Type = GL_RENDERBUFFER_EXT;
att->Renderbuffer = rb;
att->Texture = NULL; /* just to be safe */
@@ -312,6 +223,26 @@ set_renderbuffer_attachment(GLcontext *ctx,
/**
+ * Fallback for ctx->Driver.FramebufferRenderbuffer()
+ * Sets a framebuffer attachment to a particular renderbuffer.
+ * The framebuffer in question is ctx->DrawBuffer.
+ * \sa _mesa_renderbuffer_texture
+ */
+void
+_mesa_framebuffer_renderbuffer(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb)
+{
+ if (rb) {
+ _mesa_set_renderbuffer_attachment(ctx, att, rb);
+ }
+ else {
+ _mesa_remove_attachment(ctx, att);
+ }
+}
+
+
+/**
* Test if an attachment point is complete and update its Complete field.
* \param format if GL_COLOR, this is a color attachment point,
* if GL_DEPTH, this is a depth component attachment point,
@@ -326,15 +257,15 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
/* assume complete */
att->Complete = GL_TRUE;
- if (att->Type == GL_NONE)
- return; /* complete */
-
/* Look for reasons why the attachment might be incomplete */
if (att->Type == GL_TEXTURE) {
- struct gl_texture_object *texObj = att->Texture;
+ const struct gl_texture_object *texObj = att->Texture;
struct gl_texture_image *texImage;
- assert(texObj);
+ if (!texObj) {
+ att->Complete = GL_FALSE;
+ return;
+ }
texImage = texObj->Image[att->CubeMapFace][att->TextureLevel];
if (!texImage) {
@@ -351,13 +282,14 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
}
if (format == GL_COLOR) {
- if (texImage->Format != GL_RGB && texImage->Format != GL_RGBA) {
+ if (texImage->TexFormat->BaseFormat != GL_RGB &&
+ texImage->TexFormat->BaseFormat != GL_RGBA) {
att->Complete = GL_FALSE;
return;
}
}
else if (format == GL_DEPTH) {
- if (texImage->Format != GL_DEPTH_COMPONENT) {
+ if (texImage->TexFormat->BaseFormat != GL_DEPTH_COMPONENT) {
att->Complete = GL_FALSE;
return;
}
@@ -368,9 +300,7 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
return;
}
}
- else {
- assert(att->Type == GL_RENDERBUFFER_EXT);
-
+ else if (att->Type == GL_RENDERBUFFER_EXT) {
if (att->Renderbuffer->Width < 1 || att->Renderbuffer->Height < 1) {
att->Complete = GL_FALSE;
return;
@@ -396,53 +326,58 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
}
}
}
+ else {
+ ASSERT(att->Type == GL_NONE);
+ /* complete */
+ return;
+ }
}
/**
* Test if the given framebuffer object is complete and update its
* Status field with the results.
+ * Also update the framebuffer's Width and Height fields if the
+ * framebuffer is complete.
*/
-static void
-test_framebuffer_completeness(GLcontext *ctx,
- struct gl_framebuffer *fb)
+void
+_mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb)
{
- GLint i;
GLuint numImages, width = 0, height = 0;
GLenum intFormat = GL_NONE;
-
- /* Set to COMPLETE status, then try to find reasons for being incomplete */
- fb->Status = GL_FRAMEBUFFER_COMPLETE_EXT;
+ GLuint w = 0, h = 0;
+ GLint i;
numImages = 0;
+ fb->Width = 0;
+ fb->Height = 0;
/* Start at -2 to more easily loop over all attachment points */
- for (i = -2; i < ctx->Const.MaxColorAttachments; i++) {
+ for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) {
struct gl_renderbuffer_attachment *att;
- GLuint w, h;
GLenum f;
if (i == -2) {
- att = &fb->DepthAttachment;
+ att = &fb->Attachment[BUFFER_DEPTH];
test_attachment_completeness(ctx, GL_DEPTH, att);
if (!att->Complete) {
- fb->Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
return;
}
}
else if (i == -1) {
- att = &fb->StencilAttachment;
+ att = &fb->Attachment[BUFFER_STENCIL];
test_attachment_completeness(ctx, GL_STENCIL, att);
if (!att->Complete) {
- fb->Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
return;
}
}
else {
- att = &fb->ColorAttachment[i];
+ att = &fb->Attachment[BUFFER_COLOR0 + i];
test_attachment_completeness(ctx, GL_COLOR, att);
if (!att->Complete) {
- fb->Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
return;
}
}
@@ -474,57 +409,63 @@ test_framebuffer_completeness(GLcontext *ctx,
else {
/* check that width, height, format are same */
if (w != width || h != height) {
- fb->Status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT;
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT;
return;
}
- if (i >= 0 && f != intFormat) {
- fb->Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT;
+ if (intFormat != GL_NONE && f != intFormat) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT;
return;
}
-
}
}
/* Check that all DrawBuffers are present */
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
- if (fb->DrawBuffer[i] != GL_NONE) {
- struct gl_renderbuffer_attachment *att
- = get_attachment(ctx, fb, fb->DrawBuffer[i]);
+ if (fb->ColorDrawBuffer[i] != GL_NONE) {
+ const struct gl_renderbuffer_attachment *att
+ = get_attachment(ctx, fb, fb->ColorDrawBuffer[i]);
+ assert(att);
if (att->Type == GL_NONE) {
- fb->Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT;
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT;
return;
}
}
}
/* Check that the ReadBuffer is present */
- if (fb->ReadBuffer != GL_NONE) {
- struct gl_renderbuffer_attachment *att
- = get_attachment(ctx, fb, fb->ReadBuffer);
+ if (fb->ColorReadBuffer != GL_NONE) {
+ const struct gl_renderbuffer_attachment *att
+ = get_attachment(ctx, fb, fb->ColorReadBuffer);
+ assert(att);
if (att->Type == GL_NONE) {
- fb->Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT;
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT;
return;
}
}
if (numImages == 0) {
- fb->Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
return;
}
-}
+ /*
+ * If we get here, the framebuffer is complete!
+ */
+ fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
+ fb->Width = w;
+ fb->Height = h;
+}
GLboolean GLAPIENTRY
_mesa_IsRenderbufferEXT(GLuint renderbuffer)
{
- const struct gl_renderbuffer *rb;
GET_CURRENT_CONTEXT(ctx);
-
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
-
- rb = lookup_renderbuffer(ctx, renderbuffer);
- return rb ? GL_TRUE : GL_FALSE;
+ if (renderbuffer && lookup_renderbuffer(ctx, renderbuffer))
+ return GL_TRUE;
+ else
+ return GL_FALSE;
}
@@ -535,6 +476,7 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
if (target != GL_RENDERBUFFER_EXT) {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -568,7 +510,7 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
if (oldRb) {
oldRb->RefCount--;
if (oldRb->RefCount == 0) {
- oldRb->Delete(ctx, oldRb);
+ oldRb->Delete(oldRb);
}
}
@@ -600,7 +542,7 @@ _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers)
*/
rb->RefCount--;
if (rb->RefCount == 0) {
- rb->Delete(ctx, rb);
+ rb->Delete(rb);
}
}
}
@@ -694,6 +636,7 @@ _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
if (target != GL_RENDERBUFFER_EXT) {
_mesa_error(ctx, GL_INVALID_ENUM, "glRenderbufferStorageEXT(target)");
@@ -741,6 +684,9 @@ _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
rb->_BaseFormat = GL_NONE;
}
+ /*
+ test_framebuffer_completeness(ctx, fb);
+ */
/* XXX if this renderbuffer is attached anywhere, invalidate attachment
* points???
*/
@@ -787,23 +733,23 @@ _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
GLboolean GLAPIENTRY
_mesa_IsFramebufferEXT(GLuint framebuffer)
{
- const struct gl_framebuffer *fb;
GET_CURRENT_CONTEXT(ctx);
-
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
-
- fb = lookup_framebuffer(ctx, framebuffer);
- return fb ? GL_TRUE : GL_FALSE;
+ if (framebuffer && lookup_framebuffer(ctx, framebuffer))
+ return GL_TRUE;
+ else
+ return GL_FALSE;
}
void GLAPIENTRY
_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
{
- struct gl_framebuffer *newFb, *oldFb;
+ struct gl_framebuffer *newFb, *newReadFb, *oldFb;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
if (target != GL_FRAMEBUFFER_EXT) {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -812,6 +758,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
}
if (framebuffer) {
+ /* Binding a user-created framebuffer object */
newFb = lookup_framebuffer(ctx, framebuffer);
if (newFb == &DummyFramebuffer) {
/* ID was reserved, but no real framebuffer object made yet */
@@ -827,22 +774,29 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
_mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb);
}
newFb->RefCount++;
+ newReadFb = newFb;
}
else {
- newFb = NULL;
+ /* Binding the window system framebuffer (which was originally set
+ * with MakeCurrent).
+ */
+ newFb = ctx->WinSysDrawBuffer;
+ newReadFb = ctx->WinSysReadBuffer;
}
- oldFb = ctx->CurrentFramebuffer;
- if (oldFb) {
+ oldFb = ctx->DrawBuffer;
+ if (oldFb) { /* AND oldFb->Name != 0 */
oldFb->RefCount--;
if (oldFb->RefCount == 0) {
- oldFb->Delete(ctx, oldFb);
+ oldFb->Delete(oldFb);
}
}
ASSERT(newFb != &DummyFramebuffer);
- ctx->CurrentFramebuffer = newFb;
+ /* Note, we set both the GL_DRAW_BUFFER and GL_READ_BUFFER state: */
+ ctx->DrawBuffer = newFb;
+ ctx->ReadBuffer = newReadFb;
}
@@ -859,6 +813,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
struct gl_framebuffer *fb;
fb = lookup_framebuffer(ctx, framebuffers[i]);
if (fb) {
+ ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]);
/* remove from hash table immediately, to free the ID */
_mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]);
@@ -868,7 +823,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
*/
fb->RefCount--;
if (fb->RefCount == 0) {
- fb->Delete(ctx, fb);
+ fb->Delete(fb);
}
}
}
@@ -913,20 +868,20 @@ _mesa_CheckFramebufferStatusEXT(GLenum target)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FRAMEBUFFER_STATUS_ERROR_EXT);
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
if (target != GL_FRAMEBUFFER_EXT) {
_mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)");
- return GL_FRAMEBUFFER_STATUS_ERROR_EXT;
+ return 0; /* formerly GL_FRAMEBUFFER_STATUS_ERROR_EXT */
}
- if (!ctx->CurrentFramebuffer) {
+ if (ctx->DrawBuffer->Name == 0) {
/* The window system / default framebuffer is always complete */
return GL_FRAMEBUFFER_COMPLETE_EXT;
}
- test_framebuffer_completeness(ctx, ctx->CurrentFramebuffer);
- return ctx->CurrentFramebuffer->Status;
+ _mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer);
+ return ctx->DrawBuffer->_Status;
}
@@ -948,13 +903,14 @@ error_check_framebuffer_texture(GLcontext *ctx, GLuint dims,
return GL_TRUE;
}
- if (ctx->CurrentFramebuffer == NULL) {
+ /* check framebuffer binding */
+ if (ctx->DrawBuffer->Name == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glFramebufferTexture%dDEXT", dims);
return GL_TRUE;
}
- /* only check textarget, level if texture ID is non-zero*/
+ /* only check textarget, level if texture ID is non-zero */
if (texture) {
if ((dims == 1 && textarget != GL_TEXTURE_1D) ||
(dims == 3 && textarget != GL_TEXTURE_3D) ||
@@ -982,9 +938,11 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
struct gl_renderbuffer_attachment *att;
+ struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* XXX check */
if (error_check_framebuffer_texture(ctx, 1, target, attachment,
textarget, texture, level))
@@ -992,7 +950,7 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
ASSERT(textarget == GL_TEXTURE_1D);
- att = get_attachment(ctx, ctx->CurrentFramebuffer, attachment);
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture1DEXT(attachment)");
@@ -1000,7 +958,7 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
}
if (texture) {
- struct gl_texture_object *texObj = (struct gl_texture_object *)
+ texObj = (struct gl_texture_object *)
_mesa_HashLookup(ctx->Shared->TexObjects, texture);
if (!texObj) {
_mesa_error(ctx, GL_INVALID_VALUE,
@@ -1012,13 +970,12 @@ _mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
"glFramebufferTexture1DEXT(texture target)");
return;
}
- set_texture_attachment(ctx, att, texObj, textarget, level, 0);
}
else {
- remove_attachment(ctx, att);
+ /* remove texture attachment */
+ texObj = NULL;
}
-
- /* XXX call a driver function to signal new attachment? */
+ ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget, level, 0);
}
@@ -1027,9 +984,11 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
struct gl_renderbuffer_attachment *att;
+ struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* XXX check */
if (error_check_framebuffer_texture(ctx, 2, target, attachment,
textarget, texture, level))
@@ -1039,7 +998,7 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
textarget == GL_TEXTURE_RECTANGLE_ARB ||
IS_CUBE_FACE(textarget));
- att = get_attachment(ctx, ctx->CurrentFramebuffer, attachment);
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture2DEXT(attachment)");
@@ -1047,7 +1006,7 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
}
if (texture) {
- struct gl_texture_object *texObj = (struct gl_texture_object *)
+ texObj = (struct gl_texture_object *)
_mesa_HashLookup(ctx->Shared->TexObjects, texture);
if (!texObj) {
_mesa_error(ctx, GL_INVALID_VALUE,
@@ -1063,12 +1022,12 @@ _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
"glFramebufferTexture2DEXT(texture target)");
return;
}
- set_texture_attachment(ctx, att, texObj, textarget, level, 0);
}
else {
- remove_attachment(ctx, att);
+ /* remove texture attachment */
+ texObj = NULL;
}
-
+ ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget, level, 0);
}
@@ -1078,9 +1037,11 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
GLint level, GLint zoffset)
{
struct gl_renderbuffer_attachment *att;
+ struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS); /* XXX check */
if (error_check_framebuffer_texture(ctx, 3, target, attachment,
textarget, texture, level))
@@ -1088,7 +1049,7 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
ASSERT(textarget == GL_TEXTURE_3D);
- att = get_attachment(ctx, ctx->CurrentFramebuffer, attachment);
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferTexture1DEXT(attachment)");
@@ -1097,7 +1058,7 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
if (texture) {
const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
- struct gl_texture_object *texObj = (struct gl_texture_object *)
+ texObj = (struct gl_texture_object *)
_mesa_HashLookup(ctx->Shared->TexObjects, texture);
if (!texObj) {
_mesa_error(ctx, GL_INVALID_VALUE,
@@ -1114,11 +1075,13 @@ _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
"glFramebufferTexture3DEXT(zoffset)");
return;
}
- set_texture_attachment(ctx, att, texObj, textarget, level, zoffset);
}
else {
- remove_attachment(ctx, att);
+ /* remove texture attachment */
+ texObj = NULL;
}
+ ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget,
+ level, zoffset);
}
@@ -1128,9 +1091,11 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
GLuint renderbuffer)
{
struct gl_renderbuffer_attachment *att;
+ struct gl_renderbuffer *rb;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
if (target != GL_FRAMEBUFFER_EXT) {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -1139,17 +1104,17 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
}
if (renderbufferTarget != GL_RENDERBUFFER_EXT) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferRenderbufferEXT(renderbufferTarget)");
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferRenderbufferEXT(renderbufferTarget)");
return;
}
- if (ctx->CurrentFramebuffer == NULL) {
+ if (ctx->DrawBuffer->Name == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT");
return;
}
- att = get_attachment(ctx, ctx->CurrentFramebuffer, attachment);
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glFramebufferRenderbufferEXT(attachment)");
@@ -1157,18 +1122,22 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
}
if (renderbuffer) {
- struct gl_renderbuffer *rb;
rb = lookup_renderbuffer(ctx, renderbuffer);
if (!rb) {
- _mesa_error(ctx, GL_INVALID_VALUE,
+ _mesa_error(ctx, GL_INVALID_OPERATION,
"glFramebufferRenderbufferEXT(renderbuffer)");
return;
}
- set_renderbuffer_attachment(ctx, att, rb);
}
else {
- remove_attachment(ctx, att);
+ /* remove renderbuffer attachment */
+ rb = NULL;
}
+
+ assert(ctx->Driver.FramebufferRenderbuffer);
+ ctx->Driver.FramebufferRenderbuffer(ctx, att, rb);
+
+ _mesa_update_framebuffer_visual(ctx->DrawBuffer);
}
@@ -1187,13 +1156,13 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
return;
}
- if (ctx->CurrentFramebuffer == NULL) {
+ if (ctx->DrawBuffer->Name == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetFramebufferAttachmentParameterivEXT");
return;
}
- att = get_attachment(ctx, ctx->CurrentFramebuffer, attachment);
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetFramebufferAttachmentParameterivEXT(attachment)");
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 0241da2efc..2c86ef9372 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -27,137 +27,28 @@
#define FBOBJECT_H
-/**
- * A renderbuffer stores colors or depth values or stencil values.
- * A framebuffer object will have a collection of these.
- * Data are read/written to the buffer with a handful of Get/Put functions.
- *
- * Instances of this object are allocated with the Driver's NewRenderbuffer
- * hook. Drivers will likely wrap this class inside a driver-specific
- * class to simulate inheritance.
- */
-struct gl_renderbuffer
-{
- GLuint Name;
- GLint RefCount;
- GLuint Width, Height;
- GLenum InternalFormat;
- GLenum _BaseFormat; /* Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or */
- /* GL_STENCIL_INDEX. */
-
- GLenum DataType; /* GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, etc */
- GLvoid *Data;
-
- /* Delete this renderbuffer */
- void (*Delete)(GLcontext *ctx, struct gl_renderbuffer *rb);
-
- /* Allocate new storage for this renderbuffer */
- GLboolean (*AllocStorage)(GLcontext *ctx, struct gl_renderbuffer *rb,
- GLenum internalFormat,
- GLuint width, GLuint height);
-
- /* Return a pointer to the element/pixel at (x,y).
- * Should return NULL if the buffer memory can't be directly addressed.
- */
- void *(*GetPointer)(struct gl_renderbuffer *rb, GLint x, GLint y);
-
- /* Get/Read a row of values.
- * The values will be of format _BaseFormat and type DataType.
- */
- void (*GetRow)(struct gl_renderbuffer *rb,
- GLint x, GLint y, GLuint count, void *values);
-
- /* Get/Read values at arbitrary locations
- * The values will be of format _BaseFormat and type DataType.
- */
- void (*GetValues)(struct gl_renderbuffer *rb,
- const GLint x[], const GLint y[],
- GLuint count, void *values);
-
- /* Put/Write a row of values
- * The values will be of format _BaseFormat and type DataType.
- */
- void (*PutRow)(struct gl_renderbuffer *rb,
- GLint x, GLint y, GLuint count,
- const void *values, const GLubyte *maek);
-
- /* Put/Write values at arbitrary locations
- * The values will be of format _BaseFormat and type DataType.
- */
- void (*PutValues)(struct gl_renderbuffer *rb,
- const GLint x[], const GLint y[], GLuint count,
- const void *values, const GLubyte *mask);
-};
-
-
-/**
- * A renderbuffer attachment point points to either a texture object
- * (and specifies a mipmap level, cube face or 3D texture slice) or
- * points to a renderbuffer.
- */
-struct gl_renderbuffer_attachment
-{
- GLenum Type; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
- GLboolean Complete;
-
- /* IF Type == GL_RENDERBUFFER_EXT: */
- struct gl_renderbuffer *Renderbuffer;
-
- /* IF Type == GL_TEXTURE: */
- struct gl_texture_object *Texture;
- GLuint TextureLevel;
- GLuint CubeMapFace; /* 0 .. 5, for cube map textures */
- GLuint Zoffset; /* for 3D textures */
-};
-
-
-/**
- * A framebuffer object is basically a collection of rendering buffers.
- * (Though, a rendering buffer might actually be a texture image.)
- * All the renderbuffers/textures which we reference must have the same
- * width and height (and meet a few other requirements) in order for the
- * framebufffer object to be "complete".
- *
- * Instances of this object are allocated with the Driver's Newframebuffer
- * hook. Drivers will likely wrap this class inside a driver-specific
- * class to simulate inheritance.
- */
-struct gl_framebuffer
-{
- GLuint Name;
- GLint RefCount;
-
- GLenum Status; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
-
- struct gl_renderbuffer_attachment ColorAttachment[MAX_COLOR_ATTACHMENTS];
- struct gl_renderbuffer_attachment DepthAttachment;
- struct gl_renderbuffer_attachment StencilAttachment;
-
- /* In unextended OpenGL, these vars are part of the GL_COLOR_BUFFER
- * attribute group and GL_PIXEL attribute group, respectively.
- */
- GLenum DrawBuffer[MAX_DRAW_BUFFERS];
- GLenum ReadBuffer;
-
- GLuint _Width, _Height;
-
- /** Delete this framebuffer */
- void (*Delete)(GLcontext *ctx, struct gl_framebuffer *fb);
-};
-
-
-extern struct gl_framebuffer *
-_mesa_new_framebuffer(GLcontext *ctx, GLuint name);
+extern void
+_mesa_remove_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att);
extern void
-_mesa_delete_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb);
+_mesa_set_texture_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset);
-extern struct gl_renderbuffer *
-_mesa_new_renderbuffer(GLcontext *ctx, GLuint name);
+extern void
+_mesa_set_renderbuffer_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb);
extern void
-_mesa_delete_renderbuffer(GLcontext *ctx, struct gl_renderbuffer *rb);
+_mesa_framebuffer_renderbuffer(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb);
+extern void
+_mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb);
extern GLboolean GLAPIENTRY
_mesa_IsRenderbufferEXT(GLuint renderbuffer);
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
new file mode 100644
index 0000000000..c23c60948c
--- /dev/null
+++ b/src/mesa/main/framebuffer.c
@@ -0,0 +1,513 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * Functions for allocating/managing framebuffers and renderbuffers.
+ * Also, routines for reading/writing renderbuffer data as ubytes,
+ * ushorts, uints, etc.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "mtypes.h"
+#include "fbobject.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+
+
+/**
+ * Compute/set the _DepthMax field for the given framebuffer.
+ * This value depends on the Z buffer resolution.
+ */
+static void
+compute_depth_max(struct gl_framebuffer *fb)
+{
+ if (fb->Visual.depthBits == 0) {
+ /* Special case. Even if we don't have a depth buffer we need
+ * good values for DepthMax for Z vertex transformation purposes
+ * and for per-fragment fog computation.
+ */
+ fb->_DepthMax = (1 << 16) - 1;
+ }
+ else if (fb->Visual.depthBits < 32) {
+ fb->_DepthMax = (1 << fb->Visual.depthBits) - 1;
+ }
+ else {
+ /* Special case since shift values greater than or equal to the
+ * number of bits in the left hand expression's type are undefined.
+ */
+ fb->_DepthMax = 0xffffffff;
+ }
+ fb->_DepthMaxF = (GLfloat) fb->_DepthMax;
+ fb->_MRD = 1.0; /* Minimum resolvable depth value, for polygon offset */
+}
+
+
+/**
+ * Create and initialize a gl_framebuffer object.
+ * This is intended for creating _window_system_ framebuffers, not generic
+ * framebuffer objects ala GL_EXT_framebuffer_object.
+ *
+ * \sa _mesa_new_framebuffer
+ */
+struct gl_framebuffer *
+_mesa_create_framebuffer(const GLvisual *visual)
+{
+ struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer);
+ assert(visual);
+ if (fb) {
+ _mesa_initialize_framebuffer(fb, visual);
+ }
+ return fb;
+}
+
+
+/**
+ * Allocate a new gl_framebuffer object.
+ * This is the default function for ctx->Driver.NewFramebuffer().
+ * This is for allocating user-created framebuffers, not window-system
+ * framebuffers!
+ * \sa _mesa_create_framebuffer
+ */
+struct gl_framebuffer *
+_mesa_new_framebuffer(GLcontext *ctx, GLuint name)
+{
+ struct gl_framebuffer *fb;
+ assert(name != 0);
+ fb = CALLOC_STRUCT(gl_framebuffer);
+ if (fb) {
+ fb->Name = name;
+ fb->RefCount = 1;
+ fb->Delete = _mesa_destroy_framebuffer;
+ fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT;
+ fb->_ColorDrawBufferMask[0] = BUFFER_BIT_COLOR0;
+ fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT;
+ fb->_ColorReadBufferMask = BUFFER_BIT_COLOR0;
+ fb->Delete = _mesa_destroy_framebuffer;
+ }
+ return fb;
+}
+
+
+/**
+ * Initialize a gl_framebuffer object.
+ * \sa _mesa_create_framebuffer
+ */
+void
+_mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual)
+{
+ assert(fb);
+ assert(visual);
+
+ _mesa_bzero(fb, sizeof(struct gl_framebuffer));
+
+ /* save the visual */
+ fb->Visual = *visual;
+
+ /* Init glRead/DrawBuffer state */
+ if (visual->doubleBufferMode) {
+ fb->ColorDrawBuffer[0] = GL_BACK;
+ fb->_ColorDrawBufferMask[0] = BUFFER_BIT_BACK_LEFT;
+ fb->ColorReadBuffer = GL_BACK;
+ fb->_ColorReadBufferMask = BUFFER_BIT_BACK_LEFT;
+ }
+ else {
+ fb->ColorDrawBuffer[0] = GL_FRONT;
+ fb->_ColorDrawBufferMask[0] = BUFFER_BIT_FRONT_LEFT;
+ fb->ColorReadBuffer = GL_FRONT;
+ fb->_ColorReadBufferMask = BUFFER_BIT_FRONT_LEFT;
+ }
+
+ fb->Delete = _mesa_destroy_framebuffer;
+
+ compute_depth_max(fb);
+}
+
+
+/**
+ * Create/attach software-based renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers. Drivers can just as well
+ * call the individual _mesa_add_*_renderbuffer() routines directly.
+ */
+void
+_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
+ GLboolean color,
+ GLboolean depth,
+ GLboolean stencil,
+ GLboolean accum,
+ GLboolean alpha,
+ GLboolean aux)
+{
+ GLboolean frontLeft = GL_TRUE;
+ GLboolean backLeft = fb->Visual.doubleBufferMode;
+ GLboolean frontRight = fb->Visual.stereoMode;
+ GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode;
+
+ if (color) {
+ if (fb->Visual.rgbMode) {
+ assert(fb->Visual.redBits == fb->Visual.greenBits);
+ assert(fb->Visual.redBits == fb->Visual.blueBits);
+ _mesa_add_color_renderbuffers(NULL, fb,
+ fb->Visual.redBits,
+ fb->Visual.alphaBits,
+ frontLeft, backLeft,
+ frontRight, backRight);
+ }
+ else {
+ _mesa_add_color_index_renderbuffers(NULL, fb,
+ fb->Visual.indexBits,
+ frontLeft, backLeft,
+ frontRight, backRight);
+ }
+ }
+
+ if (depth) {
+ assert(fb->Visual.depthBits > 0);
+ _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits);
+ }
+
+ if (stencil) {
+ assert(fb->Visual.stencilBits > 0);
+ _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits);
+ }
+
+ if (accum) {
+ assert(fb->Visual.rgbMode);
+ assert(fb->Visual.accumRedBits > 0);
+ assert(fb->Visual.accumGreenBits > 0);
+ assert(fb->Visual.accumBlueBits > 0);
+ _mesa_add_accum_renderbuffer(NULL, fb,
+ fb->Visual.accumRedBits,
+ fb->Visual.accumGreenBits,
+ fb->Visual.accumBlueBits,
+ fb->Visual.accumAlphaBits);
+ }
+
+ if (aux) {
+ assert(fb->Visual.rgbMode);
+ assert(fb->Visual.numAuxBuffers > 0);
+ _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits,
+ fb->Visual.numAuxBuffers);
+ }
+
+#if 1
+ if (alpha) {
+ assert(fb->Visual.rgbMode);
+ assert(fb->Visual.alphaBits > 0);
+ _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits,
+ frontLeft, backLeft,
+ frontRight, backRight);
+ }
+#endif
+
+#if 0
+ if (multisample) {
+ /* maybe someday */
+ }
+#endif
+}
+
+
+/**
+ * Deallocate buffer and everything attached to it.
+ */
+void
+_mesa_destroy_framebuffer(struct gl_framebuffer *buffer)
+{
+ if (buffer) {
+ _mesa_free_framebuffer_data(buffer);
+ FREE(buffer);
+ }
+}
+
+
+/**
+ * Free all the data hanging off the given gl_framebuffer, but don't free
+ * the gl_framebuffer object itself.
+ */
+void
+_mesa_free_framebuffer_data(struct gl_framebuffer *fb)
+{
+ GLuint i;
+
+ assert(fb);
+
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+ if (att->Type == GL_RENDERBUFFER_EXT && att->Renderbuffer) {
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ rb->RefCount--;
+ if (rb->RefCount == 0) {
+ rb->Delete(rb);
+ }
+ }
+ att->Type = GL_NONE;
+ att->Renderbuffer = NULL;
+ }
+}
+
+
+/**
+ * Resize the given framebuffer's renderbuffers to the new width and height.
+ * This should only be used for window-system framebuffers, not
+ * user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object).
+ * This will typically be called via ctx->Driver.ResizeBuffers()
+ */
+void
+_mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint width, GLuint height)
+{
+ GLuint i;
+
+ /* For window system framebuffers, Name is zero */
+ assert(fb->Name == 0);
+
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+ if (att->Type == GL_RENDERBUFFER_EXT && att->Renderbuffer) {
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ /* only resize if size is changing */
+ if (rb->Width != width || rb->Height != height) {
+ if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) {
+ rb->Width = width;
+ rb->Height = height;
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer");
+ }
+ }
+ }
+ }
+
+ fb->Width = width;
+ fb->Height = height;
+}
+
+
+/**
+ * Examine all the framebuffer's renderbuffers to update the Width/Height
+ * fields of the framebuffer. If we have renderbuffers with different
+ * sizes, set the framebuffer's width and height to zero.
+ * Note: this is only intended for user-created framebuffers, not
+ * window-system framebuffes.
+ */
+static void
+update_framebuffer_size(struct gl_framebuffer *fb)
+{
+ GLboolean haveSize = GL_FALSE;
+ GLuint i;
+
+ /* user-created framebuffers only */
+ assert(fb->Name);
+
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+ const struct gl_renderbuffer *rb = att->Renderbuffer;
+ if (rb) {
+ if (haveSize) {
+ if (rb->Width != fb->Width && rb->Height != fb->Height) {
+ /* size mismatch! */
+ fb->Width = 0;
+ fb->Height = 0;
+ return;
+ }
+ }
+ else {
+ fb->Width = rb->Width;
+ fb->Height = rb->Height;
+ haveSize = GL_TRUE;
+ }
+ }
+ }
+}
+
+
+/**
+ * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields.
+ * These values are computed from the buffer's width and height and
+ * the scissor box, if it's enabled.
+ * \param ctx the GL context.
+ */
+void
+_mesa_update_draw_buffer_bounds(GLcontext *ctx)
+{
+ struct gl_framebuffer *buffer = ctx->DrawBuffer;
+
+ if (buffer->Name) {
+ /* user-created framebuffer size depends on the renderbuffers */
+ update_framebuffer_size(buffer);
+ }
+
+ buffer->_Xmin = 0;
+ buffer->_Ymin = 0;
+ buffer->_Xmax = buffer->Width;
+ buffer->_Ymax = buffer->Height;
+
+ if (ctx->Scissor.Enabled) {
+ if (ctx->Scissor.X > buffer->_Xmin) {
+ buffer->_Xmin = ctx->Scissor.X;
+ }
+ if (ctx->Scissor.Y > buffer->_Ymin) {
+ buffer->_Ymin = ctx->Scissor.Y;
+ }
+ if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) {
+ buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width;
+ }
+ if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) {
+ buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height;
+ }
+ /* finally, check for empty region */
+ if (buffer->_Xmin > buffer->_Xmax) {
+ buffer->_Xmin = buffer->_Xmax;
+ }
+ if (buffer->_Ymin > buffer->_Ymax) {
+ buffer->_Ymin = buffer->_Ymax;
+ }
+ }
+
+ ASSERT(buffer->_Xmin <= buffer->_Xmax);
+ ASSERT(buffer->_Ymin <= buffer->_Ymax);
+}
+
+
+/**
+ * The glGet queries of the framebuffer red/green/blue size, stencil size,
+ * etc. are satisfied by the fields of ctx->DrawBuffer->Visual. These can
+ * change depending on the renderbuffer bindings. This function update's
+ * the given framebuffer's Visual from the current renderbuffer bindings.
+ * This is only intended for user-created framebuffers.
+ */
+void
+_mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
+{
+ assert(fb->Name != 0);
+
+ _mesa_bzero(&fb->Visual, sizeof(fb->Visual));
+ fb->Visual.rgbMode = GL_TRUE;
+
+ if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) {
+ fb->Visual.redBits
+ = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->ComponentSizes[0];
+ fb->Visual.greenBits
+ = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->ComponentSizes[1];
+ fb->Visual.blueBits
+ = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->ComponentSizes[2];
+ fb->Visual.alphaBits
+ = fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer->ComponentSizes[3];
+ fb->Visual.rgbBits
+ = fb->Visual.redBits + fb->Visual.greenBits + fb->Visual.blueBits;
+ fb->Visual.floatMode = GL_FALSE;
+ }
+
+ if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
+ fb->Visual.haveDepthBuffer = GL_TRUE;
+ fb->Visual.depthBits
+ = fb->Attachment[BUFFER_DEPTH].Renderbuffer->ComponentSizes[0];
+ }
+
+ if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) {
+ fb->Visual.haveStencilBuffer = GL_TRUE;
+ fb->Visual.stencilBits
+ = fb->Attachment[BUFFER_STENCIL].Renderbuffer->ComponentSizes[0];
+ }
+
+ compute_depth_max(fb);
+}
+
+
+/**
+ * Given a framebuffer and a buffer bit (like BUFFER_BIT_FRONT_LEFT), return
+ * the corresponding renderbuffer.
+ */
+static struct gl_renderbuffer *
+get_renderbuffer(struct gl_framebuffer *fb, GLuint bufferBit)
+{
+ GLuint index;
+ for (index = 0; index < BUFFER_COUNT; index++) {
+ if ((1 << index) == bufferBit) {
+ return fb->Attachment[index].Renderbuffer;
+ }
+ }
+ _mesa_problem(NULL, "Bad bufferBit in get_renderbuffer");
+ return NULL;
+}
+
+
+/**
+ * Update state related to the current draw/read framebuffers.
+ * If the current framebuffer is user-created, make sure it's complete.
+ */
+void
+_mesa_update_framebuffer(GLcontext *ctx)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ GLuint output;
+
+ /* Completeness only matters for user-created framebuffers */
+ if (fb->Name != 0)
+ _mesa_test_framebuffer_completeness(ctx, fb);
+
+ /*
+ * Update the list of drawing renderbuffer pointers.
+ * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers
+ * writing colors. We have a loop because glDrawBuffer(GL_FRONT_AND_BACK)
+ * can specify writing to two or four color buffers.
+ */
+ for (output = 0; output < ctx->Const.MaxDrawBuffers; output++) {
+ GLuint bufferMask = fb->_ColorDrawBufferMask[output];
+ GLuint count = 0;
+ GLuint bufferBit;
+ /* for each bit that's set in the bufferMask... */
+ for (bufferBit = 1; bufferMask; bufferBit <<= 1) {
+ if (bufferBit & bufferMask) {
+ struct gl_renderbuffer *rb = get_renderbuffer(fb, bufferBit);
+ if (rb) {
+ fb->_ColorDrawBuffers[output][count] = rb;
+ fb->_ColorDrawBit[output][count] = bufferBit;
+ count++;
+ }
+ else {
+ _mesa_warning(ctx, "DrawBuffer names a missing buffer!");
+ }
+ bufferMask &= ~bufferBit;
+ }
+ }
+ fb->_NumColorDrawBuffers[output] = count;
+ }
+
+ /*
+ * Update the read renderbuffer pointer.
+ * Unlike the DrawBuffer, we can only read from one (or zero) color buffers.
+ */
+ if (fb->_ColorReadBufferMask == 0x0)
+ fb->_ColorReadBuffer = NULL; /* legal! */
+ else
+ fb->_ColorReadBuffer = get_renderbuffer(fb, fb->_ColorReadBufferMask);
+
+ compute_depth_max(fb);
+}
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
new file mode 100644
index 0000000000..11b002877c
--- /dev/null
+++ b/src/mesa/main/framebuffer.h
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+
+#ifndef FRAMEBUFFER_H
+#define FRAMEBUFFER_H
+
+
+extern struct gl_framebuffer *
+_mesa_create_framebuffer(const GLvisual *visual);
+
+extern struct gl_framebuffer *
+_mesa_new_framebuffer(GLcontext *ctx, GLuint name);
+
+extern void
+_mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual);
+
+extern void
+_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
+ GLboolean color,
+ GLboolean depth,
+ GLboolean stencil,
+ GLboolean accum,
+ GLboolean alpha,
+ GLboolean aux);
+
+extern void
+_mesa_destroy_framebuffer(struct gl_framebuffer *buffer);
+
+extern void
+_mesa_free_framebuffer_data(struct gl_framebuffer *buffer);
+
+extern void
+_mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *b,
+ GLuint width, GLuint height);
+
+extern void
+_mesa_update_draw_buffer_bounds(GLcontext *ctx);
+
+extern void
+_mesa_update_framebuffer_visual(struct gl_framebuffer *fb);
+
+extern void
+_mesa_update_framebuffer(GLcontext *ctx);
+
+#endif /* FRAMEBUFFER_H */
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 9b2981059c..b6f08efc34 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -91,16 +91,16 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
switch (pname) {
case GL_ACCUM_RED_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.accumRedBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumRedBits);
break;
case GL_ACCUM_GREEN_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.accumGreenBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumGreenBits);
break;
case GL_ACCUM_BLUE_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.accumBlueBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumBlueBits);
break;
case GL_ACCUM_ALPHA_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.accumAlphaBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumAlphaBits);
break;
case GL_ACCUM_CLEAR_VALUE:
params[0] = FLOAT_TO_BOOLEAN(ctx->Accum.ClearColor[0]);
@@ -112,7 +112,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.AlphaBias);
break;
case GL_ALPHA_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.alphaBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.alphaBits);
break;
case GL_ALPHA_SCALE:
params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.AlphaScale);
@@ -133,7 +133,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = ctx->Eval.AutoNormal;
break;
case GL_AUX_BUFFERS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.numAuxBuffers);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.numAuxBuffers);
break;
case GL_BLEND:
params[0] = ctx->Color.BlendEnabled;
@@ -172,7 +172,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.BlueBias);
break;
case GL_BLUE_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.blueBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.blueBits);
break;
case GL_BLUE_SCALE:
params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.BlueScale);
@@ -291,7 +291,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.DepthBias);
break;
case GL_DEPTH_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.depthBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.depthBits);
break;
case GL_DEPTH_CLEAR_VALUE:
params[0] = FLOAT_TO_BOOLEAN(ctx->Depth.Clear);
@@ -316,7 +316,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = ctx->Color.DitherFlag;
break;
case GL_DOUBLEBUFFER:
- params[0] = ctx->Visual.doubleBufferMode;
+ params[0] = ctx->DrawBuffer->Visual.doubleBufferMode;
break;
case GL_DRAW_BUFFER:
params[0] = ENUM_TO_BOOLEAN(ctx->Color.DrawBuffer[0]);
@@ -367,19 +367,19 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenBias);
break;
case GL_GREEN_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.greenBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.greenBits);
break;
case GL_GREEN_SCALE:
params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenScale);
break;
case GL_INDEX_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.indexBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.indexBits);
break;
case GL_INDEX_CLEAR_VALUE:
params[0] = INT_TO_BOOLEAN(ctx->Color.ClearIndex);
break;
case GL_INDEX_MODE:
- params[0] = !ctx->Visual.rgbMode;
+ params[0] = !ctx->DrawBuffer->Visual.rgbMode;
break;
case GL_INDEX_OFFSET:
params[0] = INT_TO_BOOLEAN(ctx->Pixel.IndexOffset);
@@ -794,7 +794,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.RedBias);
break;
case GL_RED_BITS:
- params[0] = INT_TO_BOOLEAN( ctx->Visual.redBits );
+ params[0] = INT_TO_BOOLEAN( ctx->DrawBuffer->Visual.redBits );
break;
case GL_RED_SCALE:
params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.RedScale);
@@ -806,7 +806,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = ctx->Transform.RescaleNormals;
break;
case GL_RGBA_MODE:
- params[0] = ctx->Visual.rgbMode;
+ params[0] = ctx->DrawBuffer->Visual.rgbMode;
break;
case GL_SCISSOR_BOX:
params[0] = INT_TO_BOOLEAN(ctx->Scissor.X);
@@ -827,7 +827,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = ctx->Texture.SharedPalette;
break;
case GL_STENCIL_BITS:
- params[0] = INT_TO_BOOLEAN(ctx->Visual.stencilBits);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.stencilBits);
break;
case GL_STENCIL_CLEAR_VALUE:
params[0] = INT_TO_BOOLEAN(ctx->Stencil.Clear);
@@ -857,7 +857,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
params[0] = INT_TO_BOOLEAN(ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]);
break;
case GL_STEREO:
- params[0] = ctx->Visual.stereoMode;
+ params[0] = ctx->DrawBuffer->Visual.stereoMode;
break;
case GL_SUBPIXEL_BITS:
params[0] = INT_TO_BOOLEAN(ctx->Const.SubPixelBits);
@@ -1414,11 +1414,11 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
break;
case GL_SAMPLE_BUFFERS_ARB:
CHECK_EXTENSION_B(ARB_multisample, pname);
- params[0] = INT_TO_BOOLEAN(0);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.sampleBuffers);
break;
case GL_SAMPLES_ARB:
CHECK_EXTENSION_B(ARB_multisample, pname);
- params[0] = INT_TO_BOOLEAN(0);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.samples);
break;
case GL_RASTER_POSITION_UNCLIPPED_IBM:
CHECK_EXTENSION_B(IBM_rasterpos_clip, pname);
@@ -1877,7 +1877,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
break;
case GL_FRAMEBUFFER_BINDING_EXT:
CHECK_EXTENSION_B(EXT_framebuffer_object, pname);
- params[0] = INT_TO_BOOLEAN(ctx->CurrentFramebuffer ? ctx->CurrentFramebuffer->Name : 0);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Name);
break;
case GL_RENDERBUFFER_BINDING_EXT:
CHECK_EXTENSION_B(EXT_framebuffer_object, pname);
@@ -1935,16 +1935,16 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
switch (pname) {
case GL_ACCUM_RED_BITS:
- params[0] = (GLfloat)(ctx->Visual.accumRedBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumRedBits);
break;
case GL_ACCUM_GREEN_BITS:
- params[0] = (GLfloat)(ctx->Visual.accumGreenBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumGreenBits);
break;
case GL_ACCUM_BLUE_BITS:
- params[0] = (GLfloat)(ctx->Visual.accumBlueBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumBlueBits);
break;
case GL_ACCUM_ALPHA_BITS:
- params[0] = (GLfloat)(ctx->Visual.accumAlphaBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumAlphaBits);
break;
case GL_ACCUM_CLEAR_VALUE:
params[0] = ctx->Accum.ClearColor[0];
@@ -1956,7 +1956,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = ctx->Pixel.AlphaBias;
break;
case GL_ALPHA_BITS:
- params[0] = (GLfloat)(ctx->Visual.alphaBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.alphaBits);
break;
case GL_ALPHA_SCALE:
params[0] = ctx->Pixel.AlphaScale;
@@ -1977,7 +1977,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.AutoNormal);
break;
case GL_AUX_BUFFERS:
- params[0] = (GLfloat)(ctx->Visual.numAuxBuffers);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.numAuxBuffers);
break;
case GL_BLEND:
params[0] = BOOLEAN_TO_FLOAT(ctx->Color.BlendEnabled);
@@ -2016,7 +2016,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = ctx->Pixel.BlueBias;
break;
case GL_BLUE_BITS:
- params[0] = (GLfloat)(ctx->Visual.blueBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.blueBits);
break;
case GL_BLUE_SCALE:
params[0] = ctx->Pixel.BlueScale;
@@ -2135,7 +2135,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = ctx->Pixel.DepthBias;
break;
case GL_DEPTH_BITS:
- params[0] = (GLfloat)(ctx->Visual.depthBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.depthBits);
break;
case GL_DEPTH_CLEAR_VALUE:
params[0] = ctx->Depth.Clear;
@@ -2160,7 +2160,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = BOOLEAN_TO_FLOAT(ctx->Color.DitherFlag);
break;
case GL_DOUBLEBUFFER:
- params[0] = BOOLEAN_TO_FLOAT(ctx->Visual.doubleBufferMode);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->DrawBuffer->Visual.doubleBufferMode);
break;
case GL_DRAW_BUFFER:
params[0] = ENUM_TO_FLOAT(ctx->Color.DrawBuffer[0]);
@@ -2211,19 +2211,19 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = ctx->Pixel.GreenBias;
break;
case GL_GREEN_BITS:
- params[0] = (GLfloat)(ctx->Visual.greenBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.greenBits);
break;
case GL_GREEN_SCALE:
params[0] = ctx->Pixel.GreenScale;
break;
case GL_INDEX_BITS:
- params[0] = (GLfloat)(ctx->Visual.indexBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.indexBits);
break;
case GL_INDEX_CLEAR_VALUE:
params[0] = (GLfloat)(ctx->Color.ClearIndex);
break;
case GL_INDEX_MODE:
- params[0] = BOOLEAN_TO_FLOAT(!ctx->Visual.rgbMode);
+ params[0] = BOOLEAN_TO_FLOAT(!ctx->DrawBuffer->Visual.rgbMode);
break;
case GL_INDEX_OFFSET:
params[0] = (GLfloat)(ctx->Pixel.IndexOffset);
@@ -2638,7 +2638,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = ctx->Pixel.RedBias;
break;
case GL_RED_BITS:
- params[0] = (GLfloat)( ctx->Visual.redBits );
+ params[0] = (GLfloat)( ctx->DrawBuffer->Visual.redBits );
break;
case GL_RED_SCALE:
params[0] = ctx->Pixel.RedScale;
@@ -2650,7 +2650,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = BOOLEAN_TO_FLOAT(ctx->Transform.RescaleNormals);
break;
case GL_RGBA_MODE:
- params[0] = BOOLEAN_TO_FLOAT(ctx->Visual.rgbMode);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->DrawBuffer->Visual.rgbMode);
break;
case GL_SCISSOR_BOX:
params[0] = (GLfloat)(ctx->Scissor.X);
@@ -2671,7 +2671,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = BOOLEAN_TO_FLOAT(ctx->Texture.SharedPalette);
break;
case GL_STENCIL_BITS:
- params[0] = (GLfloat)(ctx->Visual.stencilBits);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.stencilBits);
break;
case GL_STENCIL_CLEAR_VALUE:
params[0] = (GLfloat)(ctx->Stencil.Clear);
@@ -2701,7 +2701,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
params[0] = (GLfloat)(ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]);
break;
case GL_STEREO:
- params[0] = BOOLEAN_TO_FLOAT(ctx->Visual.stereoMode);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->DrawBuffer->Visual.stereoMode);
break;
case GL_SUBPIXEL_BITS:
params[0] = (GLfloat)(ctx->Const.SubPixelBits);
@@ -3258,11 +3258,11 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
break;
case GL_SAMPLE_BUFFERS_ARB:
CHECK_EXTENSION_F(ARB_multisample, pname);
- params[0] = (GLfloat)(0);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.sampleBuffers);
break;
case GL_SAMPLES_ARB:
CHECK_EXTENSION_F(ARB_multisample, pname);
- params[0] = (GLfloat)(0);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.samples);
break;
case GL_RASTER_POSITION_UNCLIPPED_IBM:
CHECK_EXTENSION_F(IBM_rasterpos_clip, pname);
@@ -3721,7 +3721,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
break;
case GL_FRAMEBUFFER_BINDING_EXT:
CHECK_EXTENSION_F(EXT_framebuffer_object, pname);
- params[0] = (GLfloat)(ctx->CurrentFramebuffer ? ctx->CurrentFramebuffer->Name : 0);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Name);
break;
case GL_RENDERBUFFER_BINDING_EXT:
CHECK_EXTENSION_F(EXT_framebuffer_object, pname);
@@ -3779,16 +3779,16 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
switch (pname) {
case GL_ACCUM_RED_BITS:
- params[0] = ctx->Visual.accumRedBits;
+ params[0] = ctx->DrawBuffer->Visual.accumRedBits;
break;
case GL_ACCUM_GREEN_BITS:
- params[0] = ctx->Visual.accumGreenBits;
+ params[0] = ctx->DrawBuffer->Visual.accumGreenBits;
break;
case GL_ACCUM_BLUE_BITS:
- params[0] = ctx->Visual.accumBlueBits;
+ params[0] = ctx->DrawBuffer->Visual.accumBlueBits;
break;
case GL_ACCUM_ALPHA_BITS:
- params[0] = ctx->Visual.accumAlphaBits;
+ params[0] = ctx->DrawBuffer->Visual.accumAlphaBits;
break;
case GL_ACCUM_CLEAR_VALUE:
params[0] = FLOAT_TO_INT(ctx->Accum.ClearColor[0]);
@@ -3800,7 +3800,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = IROUND(ctx->Pixel.AlphaBias);
break;
case GL_ALPHA_BITS:
- params[0] = ctx->Visual.alphaBits;
+ params[0] = ctx->DrawBuffer->Visual.alphaBits;
break;
case GL_ALPHA_SCALE:
params[0] = IROUND(ctx->Pixel.AlphaScale);
@@ -3821,7 +3821,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = BOOLEAN_TO_INT(ctx->Eval.AutoNormal);
break;
case GL_AUX_BUFFERS:
- params[0] = ctx->Visual.numAuxBuffers;
+ params[0] = ctx->DrawBuffer->Visual.numAuxBuffers;
break;
case GL_BLEND:
params[0] = BOOLEAN_TO_INT(ctx->Color.BlendEnabled);
@@ -3860,7 +3860,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = IROUND(ctx->Pixel.BlueBias);
break;
case GL_BLUE_BITS:
- params[0] = ctx->Visual.blueBits;
+ params[0] = ctx->DrawBuffer->Visual.blueBits;
break;
case GL_BLUE_SCALE:
params[0] = IROUND(ctx->Pixel.BlueScale);
@@ -3979,7 +3979,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = IROUND(ctx->Pixel.DepthBias);
break;
case GL_DEPTH_BITS:
- params[0] = ctx->Visual.depthBits;
+ params[0] = ctx->DrawBuffer->Visual.depthBits;
break;
case GL_DEPTH_CLEAR_VALUE:
params[0] = IROUND(ctx->Depth.Clear);
@@ -4004,7 +4004,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = BOOLEAN_TO_INT(ctx->Color.DitherFlag);
break;
case GL_DOUBLEBUFFER:
- params[0] = BOOLEAN_TO_INT(ctx->Visual.doubleBufferMode);
+ params[0] = BOOLEAN_TO_INT(ctx->DrawBuffer->Visual.doubleBufferMode);
break;
case GL_DRAW_BUFFER:
params[0] = ENUM_TO_INT(ctx->Color.DrawBuffer[0]);
@@ -4055,19 +4055,19 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = IROUND(ctx->Pixel.GreenBias);
break;
case GL_GREEN_BITS:
- params[0] = ctx->Visual.greenBits;
+ params[0] = ctx->DrawBuffer->Visual.greenBits;
break;
case GL_GREEN_SCALE:
params[0] = IROUND(ctx->Pixel.GreenScale);
break;
case GL_INDEX_BITS:
- params[0] = ctx->Visual.indexBits;
+ params[0] = ctx->DrawBuffer->Visual.indexBits;
break;
case GL_INDEX_CLEAR_VALUE:
params[0] = ctx->Color.ClearIndex;
break;
case GL_INDEX_MODE:
- params[0] = BOOLEAN_TO_INT(!ctx->Visual.rgbMode);
+ params[0] = BOOLEAN_TO_INT(!ctx->DrawBuffer->Visual.rgbMode);
break;
case GL_INDEX_OFFSET:
params[0] = ctx->Pixel.IndexOffset;
@@ -4482,7 +4482,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = IROUND(ctx->Pixel.RedBias);
break;
case GL_RED_BITS:
- params[0] = ctx->Visual.redBits ;
+ params[0] = ctx->DrawBuffer->Visual.redBits ;
break;
case GL_RED_SCALE:
params[0] = IROUND(ctx->Pixel.RedScale);
@@ -4494,7 +4494,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = BOOLEAN_TO_INT(ctx->Transform.RescaleNormals);
break;
case GL_RGBA_MODE:
- params[0] = BOOLEAN_TO_INT(ctx->Visual.rgbMode);
+ params[0] = BOOLEAN_TO_INT(ctx->DrawBuffer->Visual.rgbMode);
break;
case GL_SCISSOR_BOX:
params[0] = ctx->Scissor.X;
@@ -4515,7 +4515,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = BOOLEAN_TO_INT(ctx->Texture.SharedPalette);
break;
case GL_STENCIL_BITS:
- params[0] = ctx->Visual.stencilBits;
+ params[0] = ctx->DrawBuffer->Visual.stencilBits;
break;
case GL_STENCIL_CLEAR_VALUE:
params[0] = ctx->Stencil.Clear;
@@ -4545,7 +4545,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
params[0] = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace];
break;
case GL_STEREO:
- params[0] = BOOLEAN_TO_INT(ctx->Visual.stereoMode);
+ params[0] = BOOLEAN_TO_INT(ctx->DrawBuffer->Visual.stereoMode);
break;
case GL_SUBPIXEL_BITS:
params[0] = ctx->Const.SubPixelBits;
@@ -5102,11 +5102,11 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
break;
case GL_SAMPLE_BUFFERS_ARB:
CHECK_EXTENSION_I(ARB_multisample, pname);
- params[0] = 0;
+ params[0] = ctx->DrawBuffer->Visual.sampleBuffers;
break;
case GL_SAMPLES_ARB:
CHECK_EXTENSION_I(ARB_multisample, pname);
- params[0] = 0;
+ params[0] = ctx->DrawBuffer->Visual.samples;
break;
case GL_RASTER_POSITION_UNCLIPPED_IBM:
CHECK_EXTENSION_I(IBM_rasterpos_clip, pname);
@@ -5565,7 +5565,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
break;
case GL_FRAMEBUFFER_BINDING_EXT:
CHECK_EXTENSION_I(EXT_framebuffer_object, pname);
- params[0] = ctx->CurrentFramebuffer ? ctx->CurrentFramebuffer->Name : 0;
+ params[0] = ctx->DrawBuffer->Name;
break;
case GL_RENDERBUFFER_BINDING_EXT:
CHECK_EXTENSION_I(EXT_framebuffer_object, pname);
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index b3e6bc5855..8259972daa 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -54,10 +54,14 @@ TypeStrings = {
# - optional extension to check, or None (XXX this should be a list!)
#
StateVars = [
- ( "GL_ACCUM_RED_BITS", GLint, ["ctx->Visual.accumRedBits"], "", None ),
- ( "GL_ACCUM_GREEN_BITS", GLint, ["ctx->Visual.accumGreenBits"], "", None ),
- ( "GL_ACCUM_BLUE_BITS", GLint, ["ctx->Visual.accumBlueBits"], "", None ),
- ( "GL_ACCUM_ALPHA_BITS", GLint, ["ctx->Visual.accumAlphaBits"], "", None ),
+ ( "GL_ACCUM_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.accumRedBits"],
+ "", None ),
+ ( "GL_ACCUM_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.accumGreenBits"],
+ "", None ),
+ ( "GL_ACCUM_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.accumBlueBits"],
+ "", None ),
+ ( "GL_ACCUM_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.accumAlphaBits"],
+ "", None ),
( "GL_ACCUM_CLEAR_VALUE", GLfloatN,
[ "ctx->Accum.ClearColor[0]",
"ctx->Accum.ClearColor[1]",
@@ -65,14 +69,16 @@ StateVars = [
"ctx->Accum.ClearColor[3]" ],
"", None ),
( "GL_ALPHA_BIAS", GLfloat, ["ctx->Pixel.AlphaBias"], "", None ),
- ( "GL_ALPHA_BITS", GLint, ["ctx->Visual.alphaBits"], "", None ),
+ ( "GL_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.alphaBits"],
+ "", None ),
( "GL_ALPHA_SCALE", GLfloat, ["ctx->Pixel.AlphaScale"], "", None ),
( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", None ),
( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", None ),
( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", None ),
( "GL_ATTRIB_STACK_DEPTH", GLint, ["ctx->AttribStackDepth"], "", None ),
( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", None ),
- ( "GL_AUX_BUFFERS", GLint, ["ctx->Visual.numAuxBuffers"], "", None ),
+ ( "GL_AUX_BUFFERS", GLint, ["ctx->DrawBuffer->Visual.numAuxBuffers"],
+ "", None ),
( "GL_BLEND", GLboolean, ["ctx->Color.BlendEnabled"], "", None ),
( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
@@ -89,7 +95,7 @@ StateVars = [
"ctx->Color.BlendColor[2]",
"ctx->Color.BlendColor[3]"], "", None ),
( "GL_BLUE_BIAS", GLfloat, ["ctx->Pixel.BlueBias"], "", None ),
- ( "GL_BLUE_BITS", GLint, ["ctx->Visual.blueBits"], "", None ),
+ ( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", None ),
( "GL_BLUE_SCALE", GLfloat, ["ctx->Pixel.BlueScale"], "", None ),
( "GL_CLIENT_ATTRIB_STACK_DEPTH", GLint,
["ctx->ClientAttribStackDepth"], "", None ),
@@ -165,7 +171,8 @@ StateVars = [
"ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][3]"],
"const GLuint texUnit = ctx->Texture.CurrentUnit;", None ),
( "GL_DEPTH_BIAS", GLfloat, ["ctx->Pixel.DepthBias"], "", None ),
- ( "GL_DEPTH_BITS", GLint, ["ctx->Visual.depthBits"], "", None ),
+ ( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"],
+ "", None ),
( "GL_DEPTH_CLEAR_VALUE", GLfloat, ["ctx->Depth.Clear"], "", None ),
( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", None ),
( "GL_DEPTH_RANGE", GLfloatN,
@@ -174,7 +181,8 @@ StateVars = [
( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", None ),
( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", None ),
( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", None ),
- ( "GL_DOUBLEBUFFER", GLboolean, ["ctx->Visual.doubleBufferMode"], "", None ),
+ ( "GL_DOUBLEBUFFER", GLboolean,
+ ["ctx->DrawBuffer->Visual.doubleBufferMode"], "", None ),
( "GL_DRAW_BUFFER", GLenum, ["ctx->Color.DrawBuffer[0]"], "", None ),
( "GL_EDGE_FLAG", GLboolean, ["ctx->Current.EdgeFlag"],
"FLUSH_CURRENT(ctx, 0);", None ),
@@ -194,11 +202,14 @@ StateVars = [
( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", None ),
( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", None ),
( "GL_GREEN_BIAS", GLfloat, ["ctx->Pixel.GreenBias"], "", None ),
- ( "GL_GREEN_BITS", GLint, ["ctx->Visual.greenBits"], "", None ),
+ ( "GL_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.greenBits"],
+ "", None ),
( "GL_GREEN_SCALE", GLfloat, ["ctx->Pixel.GreenScale"], "", None ),
- ( "GL_INDEX_BITS", GLint, ["ctx->Visual.indexBits"], "", None ),
+ ( "GL_INDEX_BITS", GLint, ["ctx->DrawBuffer->Visual.indexBits"],
+ "", None ),
( "GL_INDEX_CLEAR_VALUE", GLint, ["ctx->Color.ClearIndex"], "", None ),
- ( "GL_INDEX_MODE", GLboolean, ["!ctx->Visual.rgbMode"], "", None ),
+ ( "GL_INDEX_MODE", GLboolean, ["!ctx->DrawBuffer->Visual.rgbMode"],
+ "", None ),
( "GL_INDEX_OFFSET", GLint, ["ctx->Pixel.IndexOffset"], "", None ),
( "GL_INDEX_SHIFT", GLint, ["ctx->Pixel.IndexShift"], "", None ),
( "GL_INDEX_WRITEMASK", GLint, ["ctx->Color.IndexMask"], "", None ),
@@ -368,12 +379,13 @@ StateVars = [
["ctx->ProjectionMatrixStack.Depth + 1"], "", None ),
( "GL_READ_BUFFER", GLenum, ["ctx->Pixel.ReadBuffer"], "", None ),
( "GL_RED_BIAS", GLfloat, ["ctx->Pixel.RedBias"], "", None ),
- ( "GL_RED_BITS", GLint, [" ctx->Visual.redBits "], "", None ),
+ ( "GL_RED_BITS", GLint, [" ctx->DrawBuffer->Visual.redBits "], "", None ),
( "GL_RED_SCALE", GLfloat, ["ctx->Pixel.RedScale"], "", None ),
( "GL_RENDER_MODE", GLenum, ["ctx->RenderMode"], "", None ),
( "GL_RESCALE_NORMAL", GLboolean,
["ctx->Transform.RescaleNormals"], "", None ),
- ( "GL_RGBA_MODE", GLboolean, ["ctx->Visual.rgbMode"], "", None ),
+ ( "GL_RGBA_MODE", GLboolean, ["ctx->DrawBuffer->Visual.rgbMode"],
+ "", None ),
( "GL_SCISSOR_BOX", GLint,
["ctx->Scissor.X",
"ctx->Scissor.Y",
@@ -384,7 +396,7 @@ StateVars = [
( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", None ),
( "GL_SHARED_TEXTURE_PALETTE_EXT", GLboolean,
["ctx->Texture.SharedPalette"], "", None ),
- ( "GL_STENCIL_BITS", GLint, ["ctx->Visual.stencilBits"], "", None ),
+ ( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", None ),
( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", None ),
( "GL_STENCIL_FAIL", GLenum,
["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", None ),
@@ -401,7 +413,8 @@ StateVars = [
["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", None ),
( "GL_STENCIL_WRITEMASK", GLint,
["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", None ),
- ( "GL_STEREO", GLboolean, ["ctx->Visual.stereoMode"], "", None ),
+ ( "GL_STEREO", GLboolean, ["ctx->DrawBuffer->Visual.stereoMode"],
+ "", None ),
( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", None ),
( "GL_TEXTURE_1D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D)"], "", None ),
( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", None ),
@@ -692,8 +705,10 @@ StateVars = [
["ctx->Multisample.SampleCoverageValue"], "", "ARB_multisample" ),
( "GL_SAMPLE_COVERAGE_INVERT_ARB", GLboolean,
["ctx->Multisample.SampleCoverageInvert"], "", "ARB_multisample" ),
- ( "GL_SAMPLE_BUFFERS_ARB", GLint, ["0"], "", "ARB_multisample" ),
- ( "GL_SAMPLES_ARB", GLint, ["0"], "", "ARB_multisample" ),
+ ( "GL_SAMPLE_BUFFERS_ARB", GLint,
+ ["ctx->DrawBuffer->Visual.sampleBuffers"], "", "ARB_multisample" ),
+ ( "GL_SAMPLES_ARB", GLint,
+ ["ctx->DrawBuffer->Visual.samples"], "", "ARB_multisample" ),
# GL_IBM_rasterpos_clip
( "GL_RASTER_POSITION_UNCLIPPED_IBM", GLboolean,
@@ -953,8 +968,7 @@ StateVars = [
( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"], "", None ),
# GL_EXT_framebuffer_object
- ( "GL_FRAMEBUFFER_BINDING_EXT", GLint,
- ["ctx->CurrentFramebuffer ? ctx->CurrentFramebuffer->Name : 0"], "",
+ ( "GL_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->DrawBuffer->Name"], "",
"EXT_framebuffer_object" ),
( "GL_RENDERBUFFER_BINDING_EXT", GLint,
["ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0"], "",
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 70cbee5f3d..2f0a1fa8c6 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -569,9 +569,12 @@ void
_mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
const GLfloat n = ctx->Viewport.Near;
const GLfloat f = ctx->Viewport.Far;
+ ASSERT(depthMax > 0);
+
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height);
@@ -606,8 +609,8 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
ctx->Viewport._WindowMap.m[MAT_TX] = ctx->Viewport._WindowMap.m[MAT_SX] + x;
ctx->Viewport._WindowMap.m[MAT_SY] = (GLfloat) height / 2.0F;
ctx->Viewport._WindowMap.m[MAT_TY] = ctx->Viewport._WindowMap.m[MAT_SY] + y;
- ctx->Viewport._WindowMap.m[MAT_SZ] = ctx->DepthMaxF * ((f - n) / 2.0F);
- ctx->Viewport._WindowMap.m[MAT_TZ] = ctx->DepthMaxF * ((f - n) / 2.0F + n);
+ ctx->Viewport._WindowMap.m[MAT_SZ] = depthMax * ((f - n) / 2.0F);
+ ctx->Viewport._WindowMap.m[MAT_TZ] = depthMax * ((f - n) / 2.0F + n);
ctx->Viewport._WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION;
ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT;
ctx->NewState |= _NEW_VIEWPORT;
@@ -636,10 +639,13 @@ _mesa_DepthRange( GLclampd nearval, GLclampd farval )
* specifies a linear mapping of the normalized z coords in
* this range to window z coords.
*/
+ GLfloat depthMax;
GLfloat n, f;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ depthMax = ctx->DrawBuffer->_DepthMaxF;
+
if (MESA_VERBOSE&VERBOSE_API)
_mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval);
@@ -648,8 +654,8 @@ _mesa_DepthRange( GLclampd nearval, GLclampd farval )
ctx->Viewport.Near = n;
ctx->Viewport.Far = f;
- ctx->Viewport._WindowMap.m[MAT_SZ] = ctx->DepthMaxF * ((f - n) / 2.0F);
- ctx->Viewport._WindowMap.m[MAT_TZ] = ctx->DepthMaxF * ((f - n) / 2.0F + n);
+ ctx->Viewport._WindowMap.m[MAT_SZ] = depthMax * ((f - n) / 2.0F);
+ ctx->Viewport._WindowMap.m[MAT_TZ] = depthMax * ((f - n) / 2.0F + n);
ctx->NewState |= _NEW_VIEWPORT;
if (ctx->Driver.DepthRange) {
@@ -919,12 +925,14 @@ void _mesa_init_viewport( GLcontext *ctx )
ctx->Viewport.Far = 1.0;
_math_matrix_ctr(&ctx->Viewport._WindowMap);
+#if 0000
#define Sz 10
#define Tz 14
ctx->Viewport._WindowMap.m[Sz] = 0.5F * ctx->DepthMaxF;
ctx->Viewport._WindowMap.m[Tz] = 0.5F * ctx->DepthMaxF;
#undef Sz
#undef Tz
+#endif
ctx->Viewport._WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION;
ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b50bf0e4f1..832166d2c0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -65,16 +65,8 @@
#endif
-/**
- * Accumulation buffer data type.
- */
-#if ACCUM_BITS==8
- typedef GLbyte GLaccum;
-#elif ACCUM_BITS==16
- typedef GLshort GLaccum;
-#elif ACCUM_BITS==32
- typedef GLfloat GLaccum;
-#else
+#if ACCUM_BITS != 16
+/* Software accum done with GLshort at this time */
# error "illegal number of accumulation bits"
#endif
@@ -139,13 +131,13 @@ typedef int GLfixed;
*/
/*@{*/
struct _mesa_HashTable;
+struct gl_pixelstore_attrib;
+struct gl_texture_format;
struct gl_texture_image;
struct gl_texture_object;
typedef struct __GLcontextRec GLcontext;
typedef struct __GLcontextModesRec GLvisual;
-typedef struct gl_frame_buffer GLframebuffer;
-struct gl_pixelstore_attrib;
-struct gl_texture_format;
+typedef struct gl_framebuffer GLframebuffer;
/*@}*/
@@ -282,25 +274,53 @@ enum
/**
- * Bits for each basic buffer in a complete framebuffer.
- * When glDrawBuffer(GL_FRONT_AND_BACK) is called (non-stereo),
- * _DrawDestMask will be set to (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT),
- * for example. Also passed to ctx->Driver.Clear() to indicate which
- * buffers to clear.
- */
-/*@{*/
-#define DD_FRONT_LEFT_BIT 0x1
-#define DD_FRONT_RIGHT_BIT 0x2
-#define DD_BACK_LEFT_BIT 0x4
-#define DD_BACK_RIGHT_BIT 0x8
-#define DD_AUX0_BIT 0x10
-#define DD_AUX1_BIT 0x20
-#define DD_AUX2_BIT 0x40
-#define DD_AUX3_BIT 0x80
-#define DD_DEPTH_BIT GL_DEPTH_BUFFER_BIT /* 0x00000100 */
-#define DD_ACCUM_BIT GL_ACCUM_BUFFER_BIT /* 0x00000200 */
-#define DD_STENCIL_BIT GL_STENCIL_BUFFER_BIT /* 0x00000400 */
-/*@}*/
+ * Indexes for all renderbuffers
+ */
+enum {
+ BUFFER_FRONT_LEFT = 0, /* the four standard color buffers */
+ BUFFER_BACK_LEFT = 1,
+ BUFFER_FRONT_RIGHT = 2,
+ BUFFER_BACK_RIGHT = 3,
+ BUFFER_AUX0 = 4, /* optional aux buffer */
+ BUFFER_AUX1 = 5,
+ BUFFER_AUX2 = 6,
+ BUFFER_AUX3 = 7,
+ BUFFER_DEPTH = 8,
+ BUFFER_STENCIL = 9,
+ BUFFER_ACCUM = 10,
+ BUFFER_COLOR0 = 11, /* generic renderbuffers */
+ BUFFER_COLOR1 = 12,
+ BUFFER_COLOR2 = 13,
+ BUFFER_COLOR3 = 14,
+ BUFFER_COLOR4 = 15,
+ BUFFER_COLOR5 = 16,
+ BUFFER_COLOR6 = 17,
+ BUFFER_COLOR7 = 18,
+ BUFFER_COUNT = 19
+};
+
+/**
+ * Bit flags for all renderbuffers
+ */
+#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
+#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
+#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
+#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
+#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
+#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
+#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
+#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
+#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
+#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
+#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
+#define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
+#define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
+#define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
+#define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
+#define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
+#define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
+#define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
+#define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
/**
@@ -484,7 +504,6 @@ struct gl_colorbuffer_attrib
GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */
GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
- GLbitfield _DrawDestMask[MAX_DRAW_BUFFERS];/**< bitmask of DD_*_BIT bits */
/**
* \name alpha testing
@@ -885,11 +904,7 @@ struct gl_multisample_attrib
*/
struct gl_pixel_attrib
{
- GLenum ReadBuffer; /**< source buffer for glReadPixels()/glCopyPixels() */
- GLubyte _ReadSrcMask; /**< Not really a mask, but like _DrawDestMask
- *
- * May be: FRONT_LEFT_BIT, BACK_LEFT_BIT,
- * FRONT_RIGHT_BIT or BACK_RIGHT_BIT. */
+ GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */
GLfloat RedBias, RedScale;
GLfloat GreenBias, GreenScale;
GLfloat BlueBias, BlueScale;
@@ -973,7 +988,7 @@ struct gl_point_attrib
GLfloat Threshold; /**< GL_EXT_point_parameters */
GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
GLboolean PointSprite; /**< GL_NV_point_sprite / GL_NV_point_sprite */
- GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
+ GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV/ARB_point_sprite */
GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
};
@@ -1136,6 +1151,10 @@ typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
GLfloat *texelOut );
+typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ const void *texel);
+
/**
* TexImage store function. This is called by the glTex[Sub]Image
* functions and is responsible for converting the user-specified texture
@@ -1191,6 +1210,8 @@ struct gl_texture_format
FetchTexelFuncF FetchTexel2Df;
FetchTexelFuncF FetchTexel3Df;
/*@}*/
+
+ StoreTexelFunc StoreTexel;
};
@@ -2001,64 +2022,174 @@ struct gl_shared_state
};
+
+
/**
- * Frame buffer.
+ * A renderbuffer stores colors or depth values or stencil values.
+ * A framebuffer object will have a collection of these.
+ * Data are read/written to the buffer with a handful of Get/Put functions.
*
- * A "frame buffer" is a color buffer and its optional ancillary buffers:
- * depth, accum, stencil, and software-simulated alpha buffers.
+ * Instances of this object are allocated with the Driver's NewRenderbuffer
+ * hook. Drivers will likely wrap this class inside a driver-specific
+ * class to simulate inheritance.
+ */
+struct gl_renderbuffer
+{
+ GLuint Name;
+ GLint RefCount;
+ GLuint Width, Height;
+ GLenum InternalFormat; /* The user-specified value */
+ GLenum _BaseFormat; /* Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or */
+ /* GL_STENCIL_INDEX. */
+ GLenum DataType; /* Type of values passed to the Get/Put functions */
+ GLubyte ComponentSizes[4]; /* bits per component or channel */
+ GLvoid *Data;
+
+ /* Delete this renderbuffer */
+ void (*Delete)(struct gl_renderbuffer *rb);
+
+ /* Allocate new storage for this renderbuffer */
+ GLboolean (*AllocStorage)(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat,
+ GLuint width, GLuint height);
+
+ /* Lock/Unlock are called before/after calling the Get/Put functions.
+ * Not sure this is the right place for these yet.
+ void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
+ void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
+ */
+
+ /* Return a pointer to the element/pixel at (x,y).
+ * Should return NULL if the buffer memory can't be directly addressed.
+ */
+ void *(*GetPointer)(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y);
+
+ /* Get/Read a row of values.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*GetRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values);
+
+ /* Get/Read values at arbitrary locations.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*GetValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values);
+
+ /* Put/Write a row of values.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*PutRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask);
+
+ /* Put/Write a row of RGB values. This is a special-case routine that's
+ * only used for RGBA renderbuffers when the source data is GL_RGB. That's
+ * a common case for glDrawPixels and some triangle routines.
+ * The values will be of format GL_RGB and type DataType.
+ */
+ void (*PutRowRGB)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask);
+
+
+ /* Put/Write a row of identical values.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*PutMonoRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask);
+
+ /* Put/Write values at arbitrary locations.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*PutValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask);
+ /* Put/Write identical values at arbitrary locations.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*PutMonoValues)(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask);
+};
+
+
+/**
+ * A renderbuffer attachment point points to either a texture object
+ * (and specifies a mipmap level, cube face or 3D texture slice) or
+ * points to a renderbuffer.
+ */
+struct gl_renderbuffer_attachment
+{
+ GLenum Type; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
+ GLboolean Complete;
+
+ /* IF Type == GL_RENDERBUFFER_EXT: */
+ struct gl_renderbuffer *Renderbuffer;
+
+ /* IF Type == GL_TEXTURE: */
+ struct gl_texture_object *Texture;
+ GLuint TextureLevel;
+ GLuint CubeMapFace; /* 0 .. 5, for cube map textures */
+ GLuint Zoffset; /* for 3D textures */
+};
+
+
+/**
+ * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
* In C++ terms, think of this as a base class from which device drivers
* will make derived classes.
*/
-struct gl_frame_buffer
+struct gl_framebuffer
{
- GLvisual Visual; /**< The corresponding visual */
+ GLuint Name; /* if zero, this is a window system framebuffer */
+ GLint RefCount;
- GLuint Width, Height; /**< size of frame buffer in pixels */
+ GLvisual Visual; /**< The corresponding visual */
GLboolean Initialized;
- GLboolean UseSoftwareDepthBuffer;
- GLboolean UseSoftwareAccumBuffer;
- GLboolean UseSoftwareStencilBuffer;
- GLboolean UseSoftwareAlphaBuffers;
- GLboolean UseSoftwareAuxBuffers;
-
- /** \name Software depth (aka Z) buffer */
- /*@{*/
- GLvoid *DepthBuffer; /**< array [Width*Height] of GLushort or GLuint*/
- /*@}*/
+ GLuint Width, Height; /**< size of frame buffer in pixels */
- /** \name Software stencil buffer */
+ /** \name Drawing bounds (Intersection of buffer size and scissor box) */
/*@{*/
- GLstencil *Stencil; /**< array [Width*Height] of GLstencil values */
+ GLint _Xmin, _Xmax; /**< inclusive */
+ GLint _Ymin, _Ymax; /**< exclusive */
/*@}*/
- /** \name Software accumulation buffer */
+ /** \name Derived Z buffer stuff */
/*@{*/
- GLaccum *Accum; /**< array [4*Width*Height] of GLaccum values */
+ GLuint _DepthMax; /**< Max depth buffer value */
+ GLfloat _DepthMaxF; /**< Float max depth buffer value */
+ GLfloat _MRD; /**< minimum resolvable difference in Z values */
/*@}*/
- /** \name Software alpha planes */
- /*@{*/
- GLchan *FrontLeftAlpha; /**< array [Width*Height] of GLchan */
- GLchan *BackLeftAlpha; /**< array [Width*Height] of GLchan */
- GLchan *FrontRightAlpha; /**< array [Width*Height] of GLchan */
- GLchan *BackRightAlpha; /**< array [Width*Height] of GLchan */
- /*@}*/
+ GLenum _Status; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
- GLchan *AuxBuffers[MAX_AUX_BUFFERS];
+ /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
+ struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
- /**
- * \name Drawing bounds
- *
- * Intersection of window size and scissor box
+ /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
+ * attribute group and GL_PIXEL attribute group, respectively.
*/
- /*@{*/
- GLint _Xmin; /**< inclusive */
- GLint _Ymin; /**< inclusive */
- GLint _Xmax; /**< exclusive */
- GLint _Ymax; /**< exclusive */
- /*@}*/
+ GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
+ GLenum ColorReadBuffer;
+
+ /* These are computed from ColorDrawBuffer and ColorReadBuffer */
+ GLuint _ColorDrawBufferMask[MAX_DRAW_BUFFERS]; /* Mask of BUFFER_BIT_* flags */
+ GLuint _ColorReadBufferMask; /* Zero or one of BUFFER_BIT_ flags */
+
+ /* These are computed from _Draw/ReadBufferMask, above. */
+ GLuint _NumColorDrawBuffers[MAX_DRAW_BUFFERS];
+ struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS][4];
+ struct gl_renderbuffer *_ColorReadBuffer;
+
+#if OLD_RENDERBUFFER
+ /* XXX THIS IS TEMPORARY */
+ GLuint _ColorDrawBit[MAX_DRAW_BUFFERS][4];
+#endif
+
+ /** Delete this framebuffer */
+ void (*Delete)(struct gl_framebuffer *fb);
};
@@ -2545,6 +2676,8 @@ struct __GLcontextRec
GLvisual Visual;
GLframebuffer *DrawBuffer; /**< buffer for writing */
GLframebuffer *ReadBuffer; /**< buffer for reading */
+ GLframebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
+ GLframebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
/**
* Device driver function pointer table
@@ -2663,7 +2796,7 @@ struct __GLcontextRec
/*@}*/
#if FEATURE_EXT_framebuffer_object
- struct gl_framebuffer *CurrentFramebuffer;
+ /*struct gl_framebuffer *CurrentFramebuffer;*/
struct gl_renderbuffer *CurrentRenderbuffer;
#endif
@@ -2696,14 +2829,6 @@ struct __GLcontextRec
* We don't have a better way to communicate this value from
* swrast_setup to swrast. */
-
- /** \name Z buffer stuff */
- /*@{*/
- GLuint DepthMax; /**< Max depth buffer value */
- GLfloat DepthMaxF; /**< Float max depth buffer value */
- GLfloat MRD; /**< minimum resolvable difference in Z values */
- /*@}*/
-
/** \name Color clamping (tentative part of GL_ARB_color_clamp_control) */
/*@{*/
GLboolean ClampFragmentColors;
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 2b1434b62a..6497813a82 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -2108,11 +2108,9 @@ _mesa_init_pixel( GLcontext *ctx )
if (ctx->Visual.doubleBufferMode) {
ctx->Pixel.ReadBuffer = GL_BACK;
- ctx->Pixel._ReadSrcMask = DD_BACK_LEFT_BIT;
}
else {
ctx->Pixel.ReadBuffer = GL_FRONT;
- ctx->Pixel._ReadSrcMask = DD_FRONT_LEFT_BIT;
}
/* Miscellaneous */
diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
index 6dbf81c37d..b771408cf3 100644
--- a/src/mesa/main/polygon.c
+++ b/src/mesa/main/polygon.c
@@ -313,7 +313,8 @@ void GLAPIENTRY
_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_PolygonOffset(factor, bias * ctx->DepthMaxF );
+ /* XXX mult by DepthMaxF here??? */
+ _mesa_PolygonOffset(factor, bias * ctx->DrawBuffer->_DepthMaxF );
}
#endif
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 23285d0275..507eb9f984 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -466,7 +466,7 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+ ctx->Viewport._WindowMap.m[MAT_TY]);
ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ]
+ ctx->Viewport._WindowMap.m[MAT_TZ])
- / ctx->DepthMaxF;
+ / ctx->DrawBuffer->_DepthMaxF;
ctx->Current.RasterPos[3] = clip[3];
/* compute raster distance */
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
new file mode 100644
index 0000000000..7d21a8e358
--- /dev/null
+++ b/src/mesa/main/renderbuffer.c
@@ -0,0 +1,1863 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * Functions for allocating/managing renderbuffers.
+ * Also, routines for reading/writing software-based renderbuffer data as
+ * ubytes, ushorts, uints, etc.
+ *
+ * The 'alpha8' renderbuffer is interesting. It's used to add a software-based
+ * alpha channel to RGB renderbuffers. This is done by wrapping the RGB
+ * renderbuffer with the alpha renderbuffer. We can do this because of the
+ * OO-nature of renderbuffers.
+ *
+ * Down the road we'll use this for run-time support of 8, 16 and 32-bit
+ * color channels. For example, Mesa may use 32-bit/float color channels
+ * internally (swrast) and use wrapper renderbuffers to convert 32-bit
+ * values down to 16 or 8-bit values for whatever kind of framebuffer we have.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "mtypes.h"
+#include "fbobject.h"
+#include "renderbuffer.h"
+
+
+#define COLOR_INDEX32 0x424243
+
+
+/*
+ * Routines for get/put values in common buffer formats follow.
+ * Someday add support for arbitrary row stride to make them more
+ * flexible.
+ */
+
+/**********************************************************************
+ * Functions for buffers of 1 X GLushort values.
+ * Typically stencil.
+ */
+
+static void *
+get_pointer_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ return (GLubyte *) rb->Data + y * rb->Width + x;
+}
+
+
+static void
+get_row_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLubyte *src = (const GLubyte *) rb->Data + y * rb->Width + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ _mesa_memcpy(values, src, count * sizeof(GLubyte));
+}
+
+
+static void
+get_values_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, values, count * sizeof(GLubyte));
+ }
+}
+
+
+static void
+put_mono_row_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLubyte val = *((const GLubyte *) value);
+ GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+}
+
+
+static void
+put_values_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ const GLubyte *src = (const GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLubyte val = *((const GLubyte *) value);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 1 X GLushort values.
+ * Typically depth/Z.
+ */
+
+static void *
+get_pointer_ushort(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ ASSERT(rb->Width > 0);
+ return (GLushort *) rb->Data + y * rb->Width + x;
+}
+
+
+static void
+get_row_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const void *src = rb->GetPointer(ctx, rb, x, y);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ _mesa_memcpy(values, src, count * sizeof(GLushort));
+}
+
+
+static void
+get_values_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLushort *dst = (GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ for (i = 0; i < count; i++) {
+ const GLushort *src = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, count * sizeof(GLushort));
+ }
+}
+
+
+static void
+put_mono_row_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLushort val = *((const GLushort *) value);
+ GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+}
+
+
+static void
+put_values_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ushort(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLushort val = *((const GLushort *) value);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 1 X GLuint values.
+ * Typically depth/Z or color index.
+ */
+
+static void *
+get_pointer_uint(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ return (GLuint *) rb->Data + y * rb->Width + x;
+}
+
+
+static void
+get_row_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const void *src = rb->GetPointer(ctx, rb, x, y);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ _mesa_memcpy(values, src, count * sizeof(GLuint));
+}
+
+
+static void
+get_values_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLuint *dst = (GLuint *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < count; i++) {
+ const GLuint *src = (GLuint *) rb->Data + y[i] * rb->Width + x[i];
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLuint *src = (const GLuint *) values;
+ GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, count * sizeof(GLuint));
+ }
+}
+
+
+static void
+put_mono_row_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLuint val = *((const GLuint *) value);
+ GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = val;
+ }
+ }
+}
+
+
+static void
+put_values_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const GLuint *src = (const GLuint *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *value,
+ const GLubyte *mask)
+{
+ const GLuint val = *((const GLuint *) value);
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 3 X GLubyte (or GLbyte) values.
+ * Typically color buffers.
+ * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming
+ * alpha values and return 255 for outgoing alpha values.
+ */
+
+static void *
+get_pointer_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ /* No direct access since this buffer is RGB but caller will be
+ * treating it as if it were RGBA.
+ */
+ return NULL;
+}
+
+
+static void
+get_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLubyte *src = (const GLubyte *) rb->Data + 3 * (y * rb->Width + x);
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + 0] = src[i * 3 + 0];
+ dst[i * 4 + 1] = src[i * 3 + 1];
+ dst[i * 4 + 2] = src[i * 3 + 2];
+ dst[i * 4 + 3] = 255;
+ }
+}
+
+
+static void
+get_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ const GLubyte *src
+ = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]);
+ dst[i * 4 + 0] = src[0];
+ dst[i * 4 + 1] = src[1];
+ dst[i * 4 + 2] = src[2];
+ dst[i * 4 + 3] = 255;
+ }
+}
+
+
+static void
+put_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* note: incoming values are RGB+A! */
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 3 + 0] = src[i * 4 + 0];
+ dst[i * 3 + 1] = src[i * 4 + 1];
+ dst[i * 3 + 2] = src[i * 4 + 2];
+ }
+ }
+}
+
+
+static void
+put_row_rgb_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* note: incoming values are RGB+A! */
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 3 + 0] = src[i * 3 + 0];
+ dst[i * 3 + 1] = src[i * 3 + 1];
+ dst[i * 3 + 2] = src[i * 3 + 2];
+ }
+ }
+}
+
+
+static void
+put_mono_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ /* note: incoming value is RGB+A! */
+ const GLubyte val0 = ((const GLubyte *) value)[0];
+ const GLubyte val1 = ((const GLubyte *) value)[1];
+ const GLubyte val2 = ((const GLubyte *) value)[2];
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (!mask && val0 == val1 && val1 == val2) {
+ /* optimized case */
+ _mesa_memset(dst, val0, 3 * count);
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 3 + 0] = val0;
+ dst[i * 3 + 1] = val1;
+ dst[i * 3 + 2] = val2;
+ }
+ }
+ }
+}
+
+
+static void
+put_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ /* note: incoming values are RGB+A! */
+ const GLubyte *src = (const GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]);
+ dst[0] = src[i * 4 + 0];
+ dst[1] = src[i * 4 + 1];
+ dst[2] = src[i * 4 + 2];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ /* note: incoming value is RGB+A! */
+ const GLubyte val0 = ((const GLubyte *) value)[0];
+ const GLubyte val1 = ((const GLubyte *) value)[1];
+ const GLubyte val2 = ((const GLubyte *) value)[2];
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]);
+ dst[0] = val0;
+ dst[1] = val1;
+ dst[2] = val2;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 4 X GLubyte (or GLbyte) values.
+ * Typically color buffers.
+ */
+
+static void *
+get_pointer_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ return (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
+}
+
+
+static void
+get_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLbyte *src = (const GLbyte *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ _mesa_memcpy(values, src, 4 * count * sizeof(GLbyte));
+}
+
+
+static void
+get_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ GLuint *dst = (GLuint *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint *src = (const GLuint *) values;
+ GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, 4 * count * sizeof(GLubyte));
+ }
+}
+
+
+static void
+put_row_rgb_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* Store RGB values in RGBA buffer */
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 4 + 0] = src[i * 3 + 0];
+ dst[i * 4 + 1] = src[i * 3 + 1];
+ dst[i * 4 + 2] = src[i * 3 + 2];
+ dst[i * 4 + 3] = 0xff;
+ }
+ }
+}
+
+
+static void
+put_mono_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint val = *((const GLuint *) value);
+ GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (!mask && val == 0) {
+ /* common case */
+ _mesa_bzero(dst, count * 4 * sizeof(GLubyte));
+ }
+ else {
+ /* general case */
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+ }
+}
+
+
+static void
+put_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint *src = (const GLuint *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint val = *((const GLuint *) value);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 4 X GLushort (or GLshort) values.
+ * Typically accum buffer.
+ */
+
+static void *
+get_pointer_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ return (GLushort *) rb->Data + 4 * (y * rb->Width + x);
+}
+
+
+static void
+get_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLshort *src = (const GLshort *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ _mesa_memcpy(values, src, 4 * count * sizeof(GLshort));
+}
+
+
+static void
+get_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLushort *dst = (GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ for (i = 0; i < count; i++) {
+ const GLushort *src
+ = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]);
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i * 4 + 0] = src[i * 4 + 0];
+ dst[i * 4 + 1] = src[i * 4 + 1];
+ dst[i * 4 + 2] = src[i * 4 + 2];
+ dst[i * 4 + 3] = src[i * 4 + 3];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, 4 * count * sizeof(GLushort));
+ }
+}
+
+
+static void
+put_row_rgb_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* Put RGB values in RGBA buffer */
+ const GLushort *src = (const GLushort *) values;
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i * 4 + 0] = src[i * 3 + 0];
+ dst[i * 4 + 1] = src[i * 3 + 1];
+ dst[i * 4 + 2] = src[i * 3 + 2];
+ dst[i * 4 + 3] = 0xffff;
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, 4 * count * sizeof(GLushort));
+ }
+}
+
+
+static void
+put_mono_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLushort val0 = ((const GLushort *) value)[0];
+ const GLushort val1 = ((const GLushort *) value)[1];
+ const GLushort val2 = ((const GLushort *) value)[2];
+ const GLushort val3 = ((const GLushort *) value)[3];
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) {
+ /* common case for clearing accum buffer */
+ _mesa_bzero(dst, count * 4 * sizeof(GLushort));
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 4 + 0] = val0;
+ dst[i * 4 + 1] = val1;
+ dst[i * 4 + 2] = val2;
+ dst[i * 4 + 3] = val3;
+ }
+ }
+ }
+}
+
+
+static void
+put_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]);
+ dst[0] = src[i * 4 + 0];
+ dst[1] = src[i * 4 + 1];
+ dst[2] = src[i * 4 + 2];
+ dst[3] = src[i * 4 + 3];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLushort val0 = ((const GLushort *) value)[0];
+ const GLushort val1 = ((const GLushort *) value)[1];
+ const GLushort val2 = ((const GLushort *) value)[2];
+ const GLushort val3 = ((const GLushort *) value)[3];
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]);
+ dst[0] = val0;
+ dst[1] = val1;
+ dst[2] = val2;
+ dst[3] = val3;
+ }
+ }
+}
+
+
+
+/**
+ * This is a software fallback for the gl_renderbuffer->AllocStorage
+ * function.
+ * Device drivers will typically override this function for the buffers
+ * which it manages (typically color buffers, Z and stencil).
+ * Other buffers (like software accumulation and aux buffers) which the driver
+ * doesn't manage can be handled with this function.
+ *
+ * This one multi-purpose function can allocate stencil, depth, accum, color
+ * or color-index buffers!
+ *
+ * This function also plugs in the appropriate GetPointer, Get/PutRow and
+ * Get/PutValues functions.
+ */
+static GLboolean
+soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ GLuint pixelSize;
+
+ switch (internalFormat) {
+ case GL_RGB:
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ rb->_BaseFormat = GL_RGB;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_ubyte3;
+ rb->GetRow = get_row_ubyte3;
+ rb->GetValues = get_values_ubyte3;
+ rb->PutRow = put_row_ubyte3;
+ rb->PutRowRGB = put_row_rgb_ubyte3;
+ rb->PutMonoRow = put_mono_row_ubyte3;
+ rb->PutValues = put_values_ubyte3;
+ rb->PutMonoValues = put_mono_values_ubyte3;
+ rb->ComponentSizes[0] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[1] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[2] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[3] = 0;
+ pixelSize = 3 * sizeof(GLchan);
+ break;
+ case GL_RGBA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ rb->_BaseFormat = GL_RGBA;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_ubyte4;
+ rb->GetRow = get_row_ubyte4;
+ rb->GetValues = get_values_ubyte4;
+ rb->PutRow = put_row_ubyte4;
+ rb->PutRowRGB = put_row_rgb_ubyte4;
+ rb->PutMonoRow = put_mono_row_ubyte4;
+ rb->PutValues = put_values_ubyte4;
+ rb->PutMonoValues = put_mono_values_ubyte4;
+ rb->ComponentSizes[0] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[1] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[2] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[3] = 8 * sizeof(GLubyte);
+ pixelSize = 4 * sizeof(GLubyte);
+ break;
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ rb->_BaseFormat = GL_RGBA;
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetPointer = get_pointer_ushort4;
+ rb->GetRow = get_row_ushort4;
+ rb->GetValues = get_values_ushort4;
+ rb->PutRow = put_row_ushort4;
+ rb->PutRowRGB = put_row_rgb_ushort4;
+ rb->PutMonoRow = put_mono_row_ushort4;
+ rb->PutValues = put_values_ushort4;
+ rb->PutMonoValues = put_mono_values_ushort4;
+ rb->ComponentSizes[0] = 8 * sizeof(GLushort);
+ rb->ComponentSizes[1] = 8 * sizeof(GLushort);
+ rb->ComponentSizes[2] = 8 * sizeof(GLushort);
+ rb->ComponentSizes[3] = 8 * sizeof(GLushort);
+ pixelSize = 4 * sizeof(GLushort);
+ break;
+#if 00
+ case ALPHA8:
+ rb->_BaseFormat = GL_RGBA; /* Yes, not GL_ALPHA! */
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_alpha8;
+ rb->GetRow = get_row_alpha8;
+ rb->GetValues = get_values_alpha8;
+ rb->PutRow = put_row_alpha8;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_alpha8;
+ rb->PutValues = put_values_alpha8;
+ rb->PutMonoValues = put_mono_values_alpha8;
+ rb->ComponentSizes[0] = 0; /*red*/
+ rb->ComponentSizes[1] = 0; /*green*/
+ rb->ComponentSizes[2] = 0; /*blue*/
+ rb->ComponentSizes[3] = 8 * sizeof(GLubyte);
+ pixelSize = sizeof(GLubyte);
+ break;
+#endif
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ rb->_BaseFormat = GL_STENCIL_INDEX;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_ubyte;
+ rb->GetRow = get_row_ubyte;
+ rb->GetValues = get_values_ubyte;
+ rb->PutRow = put_row_ubyte;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ubyte;
+ rb->PutValues = put_values_ubyte;
+ rb->PutMonoValues = put_mono_values_ubyte;
+ rb->ComponentSizes[0] = 8 * sizeof(GLubyte);
+ pixelSize = sizeof(GLubyte);
+ break;
+ case GL_STENCIL_INDEX16_EXT:
+ rb->_BaseFormat = GL_STENCIL_INDEX;
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetPointer = get_pointer_ushort;
+ rb->GetRow = get_row_ushort;
+ rb->GetValues = get_values_ushort;
+ rb->PutRow = put_row_ushort;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ushort;
+ rb->PutValues = put_values_ushort;
+ rb->PutMonoValues = put_mono_values_ushort;
+ rb->ComponentSizes[0] = 8 * sizeof(GLushort);
+ pixelSize = sizeof(GLushort);
+ break;
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ rb->_BaseFormat = GL_DEPTH_COMPONENT;
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetPointer = get_pointer_ushort;
+ rb->GetRow = get_row_ushort;
+ rb->GetValues = get_values_ushort;
+ rb->PutRow = put_row_ushort;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ushort;
+ rb->PutValues = put_values_ushort;
+ rb->PutMonoValues = put_mono_values_ushort;
+ rb->ComponentSizes[0] = 8 * sizeof(GLushort);
+ pixelSize = sizeof(GLushort);
+ break;
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ rb->_BaseFormat = GL_DEPTH_COMPONENT;
+ rb->DataType = GL_UNSIGNED_INT;
+ rb->GetPointer = get_pointer_uint;
+ rb->GetRow = get_row_uint;
+ rb->GetValues = get_values_uint;
+ rb->PutRow = put_row_uint;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_uint;
+ rb->PutValues = put_values_uint;
+ rb->PutMonoValues = put_mono_values_uint;
+ rb->ComponentSizes[0] = 8 * sizeof(GLuint);
+ pixelSize = sizeof(GLuint);
+ break;
+ case GL_COLOR_INDEX8_EXT:
+ rb->_BaseFormat = GL_COLOR_INDEX;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_ubyte;
+ rb->GetRow = get_row_ubyte;
+ rb->GetValues = get_values_ubyte;
+ rb->PutRow = put_row_ubyte;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ubyte;
+ rb->PutValues = put_values_ubyte;
+ rb->PutMonoValues = put_mono_values_ubyte;
+ rb->ComponentSizes[0] = 8 * sizeof(GLubyte);
+ pixelSize = sizeof(GLubyte);
+ break;
+ case GL_COLOR_INDEX16_EXT:
+ rb->_BaseFormat = GL_COLOR_INDEX;
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetPointer = get_pointer_ushort;
+ rb->GetRow = get_row_ushort;
+ rb->GetValues = get_values_ushort;
+ rb->PutRow = put_row_ushort;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ushort;
+ rb->PutValues = put_values_ushort;
+ rb->PutMonoValues = put_mono_values_ushort;
+ rb->ComponentSizes[0] = 8 * sizeof(GLushort);
+ pixelSize = sizeof(GLushort);
+ break;
+ case COLOR_INDEX32:
+ rb->_BaseFormat = GL_COLOR_INDEX;
+ rb->DataType = GL_UNSIGNED_INT;
+ rb->GetPointer = get_pointer_uint;
+ rb->GetRow = get_row_uint;
+ rb->GetValues = get_values_uint;
+ rb->PutRow = put_row_uint;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_uint;
+ rb->PutValues = put_values_uint;
+ rb->PutMonoValues = put_mono_values_uint;
+ rb->ComponentSizes[0] = 8 * sizeof(GLuint);
+ pixelSize = sizeof(GLuint);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad internalFormat in soft_renderbuffer_storage");
+ return GL_FALSE;
+ }
+
+ ASSERT(rb->DataType);
+ ASSERT(rb->GetPointer);
+ ASSERT(rb->GetRow);
+ ASSERT(rb->GetValues);
+ ASSERT(rb->PutRow);
+ ASSERT(rb->PutMonoRow);
+ ASSERT(rb->PutValues);
+ ASSERT(rb->PutMonoValues);
+ ASSERT(rb->ComponentSizes[0] > 0);
+
+ /* free old buffer storage */
+ if (rb->Data)
+ _mesa_free(rb->Data);
+
+ /* allocate new buffer storage */
+ rb->Data = _mesa_malloc(width * height * pixelSize);
+ if (rb->Data == NULL) {
+ rb->Width = 0;
+ rb->Height = 0;
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "software renderbuffer allocation");
+ return GL_FALSE;
+ }
+
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+
+ return GL_TRUE;
+}
+
+
+/**********************************************************************/
+/**********************************************************************/
+/**********************************************************************/
+
+
+/**
+ * The alpha_renderbuffer class is used to augment an RGB renderbuffer with
+ * an alpha channel. The RGB buffer can be hardware-based.
+ * We basically wrap the RGB buffer. When PutRow is called (for example),
+ * we store the alpha values in this buffer, then pass on the PutRow call
+ * to the wrapped RGB buffer.
+ */
+struct alpha_renderbuffer
+{
+ struct gl_renderbuffer Base; /* the alpha buffer */
+ struct gl_renderbuffer *RGBbuffer; /* the wrapped RGB buffer */
+};
+
+
+static GLboolean
+alloc_storage_alpha8(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ struct alpha_renderbuffer *arb = (struct alpha_renderbuffer *) rb;
+
+ /* first, pass the call to the wrapped RGB buffer */
+ if (!arb->RGBbuffer->AllocStorage(ctx, arb->RGBbuffer, internalFormat,
+ width, height)) {
+ return GL_FALSE;
+ }
+
+ /* next, resize my alpha buffer */
+ if (arb->Base.Data) {
+ _mesa_free(arb->Base.Data);
+ }
+
+ arb->Base.Data = _mesa_malloc(width * height * sizeof(GLubyte));
+ if (arb->Base.Data == NULL) {
+ arb->Base.Width = 0;
+ arb->Base.Height = 0;
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "software alpha buffer allocation");
+ return GL_FALSE;
+ }
+
+ arb->Base.Width = width;
+ arb->Base.Height = height;
+ arb->Base.InternalFormat = internalFormat;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Delete an alpha_renderbuffer object, as well as the wrapped RGB buffer.
+ */
+static void
+delete_renderbuffer_alpha8(struct gl_renderbuffer *rb)
+{
+ struct alpha_renderbuffer *arb = (struct alpha_renderbuffer *) rb;
+ if (arb->Base.Data) {
+ _mesa_free(arb->Base.Data);
+ }
+ assert(arb->RGBbuffer);
+ arb->RGBbuffer->Delete(arb->RGBbuffer);
+ arb->RGBbuffer = NULL;
+ _mesa_free(arb);
+}
+
+
+static void *
+get_pointer_alpha8(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ return NULL; /* don't allow direct access! */
+}
+
+
+static void
+get_row_alpha8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ /* NOTE: 'values' is RGBA format! */
+ struct alpha_renderbuffer *arb = (struct alpha_renderbuffer *) rb;
+ const GLubyte *src = (const GLubyte *) rb->Data + y * rb->Width + x;
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->RGBbuffer->GetRow(ctx, arb->RGBbuffer, count, x, y, values);
+ /* second, fill in alpha values from this buffer! */
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + 3] = src[i];
+ }
+}
+
+
+static void
+get_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ struct alpha_renderbuffer *arb = (struct alpha_renderbuffer *) rb;
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->RGBbuffer->GetValues(ctx, arb->RGBbuffer, count, x, y, values);
+ /* second, fill in alpha values from this buffer! */
+ for (i = 0; i < count; i++) {
+ const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
+ dst[i * 4 + 3] = *src;
+ }
+}
+
+
+static void
+put_row_alpha8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ struct alpha_renderbuffer *arb = (struct alpha_renderbuffer *) rb;
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->RGBbuffer->PutRow(ctx, arb->RGBbuffer, count, x, y, values, mask);
+ /* second, store alpha in our buffer */
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = src[i * 4 + 3];
+ }
+ }
+}
+
+
+static void
+put_row_rgb_alpha8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ struct alpha_renderbuffer *arb = (struct alpha_renderbuffer *) rb;
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->RGBbuffer->PutRowRGB(ctx, arb->RGBbuffer, count, x, y, values, mask);
+ /* second, store alpha in our buffer */
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = src[i * 4 + 3];
+ }
+ }
+}
+
+
+static void
+put_mono_row_alpha8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ struct alpha_renderbuffer *arb = (struct alpha_renderbuffer *) rb;
+ const GLubyte val = ((const GLubyte *) value)[3];
+ GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->RGBbuffer->PutMonoRow(ctx, arb->RGBbuffer, count, x, y, value, mask);
+ /* second, store alpha in our buffer */
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ _mesa_memset(dst, val, count);
+ }
+}
+
+
+static void
+put_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ struct alpha_renderbuffer *arb = (struct alpha_renderbuffer *) rb;
+ const GLubyte *src = (const GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->RGBbuffer->PutValues(ctx, arb->RGBbuffer, count, x, y, values, mask);
+ /* second, store alpha in our buffer */
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = src[i * 4 + 3];
+ }
+ }
+}
+
+
+static void
+put_mono_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ struct alpha_renderbuffer *arb = (struct alpha_renderbuffer *) rb;
+ const GLubyte val = ((const GLubyte *) value)[3];
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->RGBbuffer->PutValues(ctx, arb->RGBbuffer, count, x, y, value, mask);
+ /* second, store alpha in our buffer */
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+
+/**********************************************************************/
+/**********************************************************************/
+/**********************************************************************/
+
+
+/**
+ * Default GetPointer routine. Always return NULL to indicate that
+ * direct buffer access is not supported.
+ */
+static void *
+nop_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb, GLint x, GLint y)
+{
+ return NULL;
+}
+
+
+/**
+ * Initialize the fields of a gl_renderbuffer to default values.
+ */
+void
+_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
+{
+ rb->Name = name;
+ rb->RefCount = 1;
+ rb->Delete = _mesa_delete_renderbuffer;
+
+ /* The rest of these should be set later by the caller of this function or
+ * the AllocStorage method:
+ */
+ rb->AllocStorage = NULL;
+
+ rb->Width = 0;
+ rb->Height = 0;
+ rb->InternalFormat = GL_NONE;
+ rb->_BaseFormat = GL_NONE;
+ rb->DataType = GL_NONE;
+ rb->ComponentSizes[0] = 0;
+ rb->ComponentSizes[1] = 0;
+ rb->ComponentSizes[2] = 0;
+ rb->ComponentSizes[3] = 0;
+ rb->Data = NULL;
+
+ rb->GetPointer = nop_get_pointer;
+ rb->GetRow = NULL;
+ rb->GetValues = NULL;
+ rb->PutRow = NULL;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = NULL;
+ rb->PutValues = NULL;
+ rb->PutMonoValues = NULL;
+}
+
+
+/**
+ * Allocate a new gl_renderbuffer object. This can be used for user-created
+ * renderbuffers or window-system renderbuffers.
+ */
+struct gl_renderbuffer *
+_mesa_new_renderbuffer(GLcontext *ctx, GLuint name)
+{
+ struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer);
+ if (rb) {
+ _mesa_init_renderbuffer(rb, name);
+ }
+ return rb;
+}
+
+
+/**
+ * Delete a gl_framebuffer.
+ * This is the default function for framebuffer->Delete().
+ */
+void
+_mesa_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+ if (rb->Data) {
+ _mesa_free(rb->Data);
+ }
+ _mesa_free(rb);
+}
+
+
+/**
+ * Allocate a software-based renderbuffer. This is called via the
+ * ctx->Driver.NewRenderbuffer() function when the user creates a new
+ * renderbuffer.
+ */
+struct gl_renderbuffer *
+_mesa_new_soft_renderbuffer(GLcontext *ctx, GLuint name)
+{
+ struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
+ if (rb) {
+ rb->AllocStorage = soft_renderbuffer_storage;
+ /* Normally, one would setup the PutRow, GetRow, etc functions here.
+ * But we're doing that in the soft_renderbuffer_storage() function
+ * instead.
+ */
+ }
+ return rb;
+}
+
+
+/**
+ * Add software-based color renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_color_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint rgbBits, GLuint alphaBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight)
+{
+ GLuint b;
+
+ if (rgbBits > 16 || alphaBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported bit depth in _mesa_add_color_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(MAX_COLOR_ATTACHMENTS >= 4);
+
+ for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
+ struct gl_renderbuffer *rb;
+
+ if (b == BUFFER_FRONT_LEFT && !frontLeft)
+ continue;
+ else if (b == BUFFER_BACK_LEFT && !backLeft)
+ continue;
+ else if (b == BUFFER_FRONT_RIGHT && !frontRight)
+ continue;
+ else if (b == BUFFER_BACK_RIGHT && !backRight)
+ continue;
+
+ assert(fb->Attachment[b].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer");
+ return GL_FALSE;
+ }
+
+ if (rgbBits <= 8) {
+ if (alphaBits)
+ rb->InternalFormat = GL_RGBA8;
+ else
+ rb->InternalFormat = GL_RGB8;
+ }
+ else {
+ assert(rgbBits <= 16);
+ if (alphaBits)
+ rb->InternalFormat = GL_RGBA16;
+ else
+ rb->InternalFormat = GL_RGBA16; /* don't really have RGB16 yet */
+ }
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, b, rb);
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add software-based color index renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_color_index_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint indexBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight)
+{
+ GLuint b;
+
+ if (indexBits > 8) {
+ _mesa_problem(ctx,
+ "Unsupported bit depth in _mesa_add_color_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(MAX_COLOR_ATTACHMENTS >= 4);
+
+ for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
+ struct gl_renderbuffer *rb;
+
+ if (b == BUFFER_FRONT_LEFT && !frontLeft)
+ continue;
+ else if (b == BUFFER_BACK_LEFT && !backLeft)
+ continue;
+ else if (b == BUFFER_FRONT_RIGHT && !frontRight)
+ continue;
+ else if (b == BUFFER_BACK_RIGHT && !backRight)
+ continue;
+
+ assert(fb->Attachment[b].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer");
+ return GL_FALSE;
+ }
+
+ if (indexBits <= 8) {
+ /* only support GLuint for now */
+ /*rb->InternalFormat = GL_COLOR_INDEX8_EXT;*/
+ rb->InternalFormat = COLOR_INDEX32;
+ }
+ else {
+ rb->InternalFormat = COLOR_INDEX32;
+ }
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, b, rb);
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add software-based alpha renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint alphaBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight)
+{
+ GLuint b;
+
+ /* for window system framebuffers only! */
+ assert(fb->Name == 0);
+
+ if (alphaBits > 8) {
+ _mesa_problem(ctx,
+ "Unsupported bit depth in _mesa_add_alpha_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(MAX_COLOR_ATTACHMENTS >= 4);
+
+ for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
+ struct alpha_renderbuffer *arb;
+
+ if (b == BUFFER_FRONT_LEFT && !frontLeft)
+ continue;
+ else if (b == BUFFER_BACK_LEFT && !backLeft)
+ continue;
+ else if (b == BUFFER_FRONT_RIGHT && !frontRight)
+ continue;
+ else if (b == BUFFER_BACK_RIGHT && !backRight)
+ continue;
+
+ /* the RGB buffer to wrap must already exist!! */
+ assert(fb->Attachment[b].Renderbuffer);
+
+ /* only GLubyte supported for now */
+ assert(fb->Attachment[b].Renderbuffer->DataType == GL_UNSIGNED_BYTE);
+
+ arb = CALLOC_STRUCT(alpha_renderbuffer);
+ if (!arb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating alpha buffer");
+ return GL_FALSE;
+ }
+
+ _mesa_init_renderbuffer(&arb->Base, 0);
+
+ /* wrap the RGB buffer */
+ arb->RGBbuffer = fb->Attachment[b].Renderbuffer;
+
+ /* plug in my functions */
+ arb->Base.InternalFormat = arb->RGBbuffer->InternalFormat;
+ arb->Base._BaseFormat = arb->RGBbuffer->_BaseFormat;
+ arb->Base.DataType = arb->RGBbuffer->DataType;
+ arb->Base.AllocStorage = alloc_storage_alpha8;
+ arb->Base.Delete = delete_renderbuffer_alpha8;
+ arb->Base.GetPointer = get_pointer_alpha8;
+ arb->Base.GetRow = get_row_alpha8;
+ arb->Base.GetValues = get_values_alpha8;
+ arb->Base.PutRow = put_row_alpha8;
+ arb->Base.PutRowRGB = put_row_rgb_alpha8;
+ arb->Base.PutMonoRow = put_mono_row_alpha8;
+ arb->Base.PutValues = put_values_alpha8;
+ arb->Base.PutMonoValues = put_mono_values_alpha8;
+
+ /* clear the pointer to avoid assertion/sanity check failure later */
+ fb->Attachment[b].Renderbuffer = NULL;
+
+ /* plug the alpha renderbuffer into the colorbuffer attachment */
+ _mesa_add_renderbuffer(fb, b, &arb->Base);
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add a software-based depth renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint depthBits)
+{
+ struct gl_renderbuffer *rb;
+
+ if (depthBits > 32) {
+ _mesa_problem(ctx,
+ "Unsupported depthBits in _mesa_add_depth_renderbuffer");
+ return GL_FALSE;
+ }
+
+ assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer");
+ return GL_FALSE;
+ }
+
+ if (depthBits <= 16) {
+ rb->InternalFormat = GL_DEPTH_COMPONENT16;
+ }
+ else {
+ rb->InternalFormat = GL_DEPTH_COMPONENT32;
+ }
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add a software-based stencil renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_stencil_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint stencilBits)
+{
+ struct gl_renderbuffer *rb;
+
+ if (stencilBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported stencilBits in _mesa_add_stencil_renderbuffer");
+ return GL_FALSE;
+ }
+
+ assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer");
+ return GL_FALSE;
+ }
+
+ if (stencilBits <= 8) {
+ rb->InternalFormat = GL_STENCIL_INDEX8_EXT;
+ }
+ else {
+ /* not really supported (see s_stencil.c code) */
+ rb->InternalFormat = GL_STENCIL_INDEX16_EXT;
+ }
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add a software-based accumulation renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_accum_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint redBits, GLuint greenBits,
+ GLuint blueBits, GLuint alphaBits)
+{
+ struct gl_renderbuffer *rb;
+
+ if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported accumBits in _mesa_add_accum_renderbuffer");
+ return GL_FALSE;
+ }
+
+ assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer");
+ return GL_FALSE;
+ }
+
+ rb->InternalFormat = GL_RGBA16;
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb);
+
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Add a software-based accumulation renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ *
+ * NOTE: color-index aux buffers not supported.
+ */
+GLboolean
+_mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint colorBits, GLuint numBuffers)
+{
+ GLuint i;
+
+ if (colorBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported accumBits in _mesa_add_aux_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(numBuffers < MAX_AUX_BUFFERS);
+
+ for (i = 0; i < numBuffers; i++) {
+ struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0);
+
+ assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL);
+
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer");
+ return GL_FALSE;
+ }
+
+ if (colorBits <= 8) {
+ rb->InternalFormat = GL_RGBA8;
+ }
+ else {
+ rb->InternalFormat = GL_RGBA16;
+ }
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb);
+ }
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Attach a renderbuffer to a framebuffer.
+ */
+void
+_mesa_add_renderbuffer(struct gl_framebuffer *fb,
+ GLuint bufferName, struct gl_renderbuffer *rb)
+{
+ assert(fb);
+ assert(rb);
+ /* there should be no previous renderbuffer on this attachment point! */
+ assert(fb->Attachment[bufferName].Renderbuffer == NULL);
+ assert(bufferName < BUFFER_COUNT);
+
+ /* winsys vs. user-created buffer cross check */
+ if (fb->Name) {
+ assert(rb->Name);
+ }
+ else {
+ assert(!rb->Name);
+ }
+
+ fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT;
+ fb->Attachment[bufferName].Complete = GL_TRUE;
+ fb->Attachment[bufferName].Renderbuffer = rb;
+}
diff --git a/src/mesa/main/renderbuffer.h b/src/mesa/main/renderbuffer.h
new file mode 100644
index 0000000000..5c11de7c8a
--- /dev/null
+++ b/src/mesa/main/renderbuffer.h
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+
+#ifndef RENDERBUFFER_H
+#define RENDERBUFFER_H
+
+
+extern void
+_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name);
+
+extern struct gl_renderbuffer *
+_mesa_new_renderbuffer(GLcontext *ctx, GLuint name);
+
+extern void
+_mesa_delete_renderbuffer(struct gl_renderbuffer *rb);
+
+
+extern struct gl_renderbuffer *
+_mesa_new_soft_renderbuffer(GLcontext *ctx, GLuint name);
+
+
+extern GLboolean
+_mesa_add_color_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint rgbBits, GLuint alphaBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight);
+
+extern GLboolean
+_mesa_add_color_index_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint indexBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight);
+
+extern GLboolean
+_mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint alphaBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight);
+
+extern GLboolean
+_mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint depthBits);
+
+extern GLboolean
+_mesa_add_stencil_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint stencilBits);
+
+
+extern GLboolean
+_mesa_add_accum_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint redBits, GLuint greenBits,
+ GLuint blueBits, GLuint alphaBits);
+
+extern GLboolean
+_mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint bits, GLuint numBuffers);
+
+extern void
+_mesa_add_renderbuffer(struct gl_framebuffer *fb,
+ GLuint bufferName, struct gl_renderbuffer *rb);
+
+#endif /* RENDERBUFFER_H */
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 540d3ce993..561f5763a2 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -61,6 +61,7 @@
#if FEATURE_EXT_framebuffer_object
#include "fbobject.h"
#endif
+#include "framebuffer.h"
#include "hint.h"
#include "histogram.h"
#include "imports.h"
@@ -974,6 +975,9 @@ _mesa_update_state( GLcontext *ctx )
if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))
_mesa_update_texture( ctx, new_state );
+ if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL))
+ _mesa_update_framebuffer(ctx);
+
if (new_state & (_NEW_SCISSOR|_NEW_BUFFERS))
_mesa_update_draw_buffer_bounds( ctx );
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index a496cf8cbf..3cbc7c88f8 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -82,6 +82,13 @@ static void fetch_null_texelf( const struct gl_texture_image *texImage,
_mesa_warning(NULL, "fetch_null_texelf() called!");
}
+static void store_null_texel(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ /* no-op */
+}
+
+
/***************************************************************/
/** \name Default GLchan-based formats */
@@ -107,6 +114,7 @@ const struct gl_texture_format _mesa_texformat_rgba = {
fetch_texel_1d_f_rgba, /* FetchTexel1Df */
fetch_texel_2d_f_rgba, /* FetchTexel2Df */
fetch_texel_3d_f_rgba, /* FetchTexel3Df */
+ store_texel_rgba /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgb = {
@@ -129,6 +137,7 @@ const struct gl_texture_format _mesa_texformat_rgb = {
fetch_texel_1d_f_rgb, /* FetchTexel1Df */
fetch_texel_2d_f_rgb, /* FetchTexel2Df */
fetch_texel_3d_f_rgb, /* FetchTexel3Df */
+ store_texel_rgb /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_alpha = {
@@ -151,6 +160,7 @@ const struct gl_texture_format _mesa_texformat_alpha = {
fetch_texel_1d_f_alpha, /* FetchTexel1Df */
fetch_texel_2d_f_alpha, /* FetchTexel2Df */
fetch_texel_3d_f_alpha, /* FetchTexel3Df */
+ store_texel_alpha /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_luminance = {
@@ -173,6 +183,7 @@ const struct gl_texture_format _mesa_texformat_luminance = {
fetch_texel_1d_f_luminance, /* FetchTexel1Df */
fetch_texel_2d_f_luminance, /* FetchTexel2Df */
fetch_texel_3d_f_luminance, /* FetchTexel3Df */
+ store_texel_luminance /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_luminance_alpha = {
@@ -195,6 +206,7 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha = {
fetch_texel_1d_f_luminance_alpha, /* FetchTexel1Df */
fetch_texel_2d_f_luminance_alpha, /* FetchTexel2Df */
fetch_texel_3d_f_luminance_alpha, /* FetchTexel3Df */
+ store_texel_luminance_alpha /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_intensity = {
@@ -217,6 +229,7 @@ const struct gl_texture_format _mesa_texformat_intensity = {
fetch_texel_1d_f_intensity, /* FetchTexel1Df */
fetch_texel_2d_f_intensity, /* FetchTexel2Df */
fetch_texel_3d_f_intensity, /* FetchTexel3Df */
+ store_texel_intensity /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
@@ -239,6 +252,7 @@ const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */
fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */
fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */
+ store_texel_depth_component_f32 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_depth_component16 = {
@@ -261,6 +275,7 @@ const struct gl_texture_format _mesa_texformat_depth_component16 = {
fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */
fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */
fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */
+ store_texel_depth_component16 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgba_float32 = {
@@ -283,6 +298,7 @@ const struct gl_texture_format _mesa_texformat_rgba_float32 = {
fetch_texel_1d_f_rgba_f32, /* FetchTexel1Df */
fetch_texel_2d_f_rgba_f32, /* FetchTexel2Df */
fetch_texel_3d_f_rgba_f32, /* FetchTexel3Df */
+ store_texel_rgba_f32 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgba_float16 = {
@@ -305,6 +321,7 @@ const struct gl_texture_format _mesa_texformat_rgba_float16 = {
fetch_texel_1d_f_rgba_f16, /* FetchTexel1Df */
fetch_texel_2d_f_rgba_f16, /* FetchTexel2Df */
fetch_texel_3d_f_rgba_f16, /* FetchTexel3Df */
+ store_texel_rgba_f16 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgb_float32 = {
@@ -327,6 +344,7 @@ const struct gl_texture_format _mesa_texformat_rgb_float32 = {
fetch_texel_1d_f_rgb_f32, /* FetchTexel1Df */
fetch_texel_2d_f_rgb_f32, /* FetchTexel2Df */
fetch_texel_3d_f_rgb_f32, /* FetchTexel3Df */
+ store_texel_rgb_f32 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgb_float16 = {
@@ -348,7 +366,8 @@ const struct gl_texture_format _mesa_texformat_rgb_float16 = {
fetch_texel_3d_rgb_f16, /* FetchTexel1D */
fetch_texel_1d_f_rgb_f16, /* FetchTexel1Df */
fetch_texel_2d_f_rgb_f16, /* FetchTexel2Df */
- fetch_texel_3d_f_rgb_f16 /* FetchTexel3Df */
+ fetch_texel_3d_f_rgb_f16, /* FetchTexel3Df */
+ store_texel_rgb_f16 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_alpha_float32 = {
@@ -370,7 +389,8 @@ const struct gl_texture_format _mesa_texformat_alpha_float32 = {
fetch_texel_3d_alpha_f32, /* FetchTexel1D */
fetch_texel_1d_f_alpha_f32, /* FetchTexel1Df */
fetch_texel_2d_f_alpha_f32, /* FetchTexel2Df */
- fetch_texel_3d_f_alpha_f32 /* FetchTexel3Df */
+ fetch_texel_3d_f_alpha_f32, /* FetchTexel3Df */
+ store_texel_alpha_f32 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_alpha_float16 = {
@@ -392,7 +412,8 @@ const struct gl_texture_format _mesa_texformat_alpha_float16 = {
fetch_texel_3d_alpha_f16, /* FetchTexel1D */
fetch_texel_1d_f_alpha_f16, /* FetchTexel1Df */
fetch_texel_2d_f_alpha_f16, /* FetchTexel2Df */
- fetch_texel_3d_f_alpha_f16 /* FetchTexel3Df */
+ fetch_texel_3d_f_alpha_f16, /* FetchTexel3Df */
+ store_texel_alpha_f16 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_luminance_float32 = {
@@ -414,7 +435,8 @@ const struct gl_texture_format _mesa_texformat_luminance_float32 = {
fetch_texel_3d_luminance_f32, /* FetchTexel3D */
fetch_texel_1d_f_luminance_f32, /* FetchTexel1Df */
fetch_texel_2d_f_luminance_f32, /* FetchTexel2Df */
- fetch_texel_3d_f_luminance_f32 /* FetchTexel3Df */
+ fetch_texel_3d_f_luminance_f32, /* FetchTexel3Df */
+ store_texel_luminance_f32 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_luminance_float16 = {
@@ -436,7 +458,8 @@ const struct gl_texture_format _mesa_texformat_luminance_float16 = {
fetch_texel_3d_luminance_f16, /* FetchTexel3D */
fetch_texel_1d_f_luminance_f16, /* FetchTexel1Df */
fetch_texel_2d_f_luminance_f16, /* FetchTexel2Df */
- fetch_texel_3d_f_luminance_f16 /* FetchTexel3Df */
+ fetch_texel_3d_f_luminance_f16, /* FetchTexel3Df */
+ store_texel_luminance_f16 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
@@ -458,7 +481,8 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
fetch_texel_3d_luminance_alpha_f32, /* FetchTexel3D */
fetch_texel_1d_f_luminance_alpha_f32,/* FetchTexel1Df */
fetch_texel_2d_f_luminance_alpha_f32,/* FetchTexel2Df */
- fetch_texel_3d_f_luminance_alpha_f32 /* FetchTexel3Df */
+ fetch_texel_3d_f_luminance_alpha_f32,/* FetchTexel3Df */
+ store_texel_luminance_alpha_f32 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
@@ -480,7 +504,8 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
fetch_texel_3d_luminance_alpha_f16, /* FetchTexel3D */
fetch_texel_1d_f_luminance_alpha_f16,/* FetchTexel1Df */
fetch_texel_2d_f_luminance_alpha_f16,/* FetchTexel2Df */
- fetch_texel_3d_f_luminance_alpha_f16 /* FetchTexel3Df */
+ fetch_texel_3d_f_luminance_alpha_f16,/* FetchTexel3Df */
+ store_texel_luminance_alpha_f16 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_intensity_float32 = {
@@ -502,7 +527,8 @@ const struct gl_texture_format _mesa_texformat_intensity_float32 = {
fetch_texel_3d_intensity_f32, /* FetchTexel3D */
fetch_texel_1d_f_intensity_f32, /* FetchTexel1Df */
fetch_texel_2d_f_intensity_f32, /* FetchTexel2Df */
- fetch_texel_3d_f_intensity_f32 /* FetchTexel3Df */
+ fetch_texel_3d_f_intensity_f32, /* FetchTexel3Df */
+ store_texel_intensity_f32 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_intensity_float16 = {
@@ -524,7 +550,8 @@ const struct gl_texture_format _mesa_texformat_intensity_float16 = {
fetch_texel_3d_intensity_f16, /* FetchTexel3D */
fetch_texel_1d_f_intensity_f16, /* FetchTexel1Df */
fetch_texel_2d_f_intensity_f16, /* FetchTexel2Df */
- fetch_texel_3d_f_intensity_f16 /* FetchTexel3Df */
+ fetch_texel_3d_f_intensity_f16, /* FetchTexel3Df */
+ store_texel_intensity_f16 /* StoreTexel */
};
@@ -555,6 +582,7 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = {
fetch_texel_1d_f_rgba8888, /* FetchTexel1Df */
fetch_texel_2d_f_rgba8888, /* FetchTexel2Df */
fetch_texel_3d_f_rgba8888, /* FetchTexel3Df */
+ store_texel_rgba8888 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
@@ -577,6 +605,7 @@ const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
fetch_texel_1d_f_rgba8888_rev, /* FetchTexel1Df */
fetch_texel_2d_f_rgba8888_rev, /* FetchTexel2Df */
fetch_texel_3d_f_rgba8888_rev, /* FetchTexel3Df */
+ store_texel_rgba8888_rev /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_argb8888 = {
@@ -599,6 +628,7 @@ const struct gl_texture_format _mesa_texformat_argb8888 = {
fetch_texel_1d_f_argb8888, /* FetchTexel1Df */
fetch_texel_2d_f_argb8888, /* FetchTexel2Df */
fetch_texel_3d_f_argb8888, /* FetchTexel3Df */
+ store_texel_argb8888 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_argb8888_rev = {
@@ -621,6 +651,7 @@ const struct gl_texture_format _mesa_texformat_argb8888_rev = {
fetch_texel_1d_f_argb8888_rev, /* FetchTexel1Df */
fetch_texel_2d_f_argb8888_rev, /* FetchTexel2Df */
fetch_texel_3d_f_argb8888_rev, /* FetchTexel3Df */
+ store_texel_argb8888_rev /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgb888 = {
@@ -643,6 +674,7 @@ const struct gl_texture_format _mesa_texformat_rgb888 = {
fetch_texel_1d_f_rgb888, /* FetchTexel1Df */
fetch_texel_2d_f_rgb888, /* FetchTexel2Df */
fetch_texel_3d_f_rgb888, /* FetchTexel3Df */
+ store_texel_rgb888 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_bgr888 = {
@@ -665,6 +697,7 @@ const struct gl_texture_format _mesa_texformat_bgr888 = {
fetch_texel_1d_f_bgr888, /* FetchTexel1Df */
fetch_texel_2d_f_bgr888, /* FetchTexel2Df */
fetch_texel_3d_f_bgr888, /* FetchTexel3Df */
+ store_texel_bgr888 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgb565 = {
@@ -687,6 +720,7 @@ const struct gl_texture_format _mesa_texformat_rgb565 = {
fetch_texel_1d_f_rgb565, /* FetchTexel1Df */
fetch_texel_2d_f_rgb565, /* FetchTexel2Df */
fetch_texel_3d_f_rgb565, /* FetchTexel3Df */
+ store_texel_rgb565 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgb565_rev = {
@@ -709,6 +743,7 @@ const struct gl_texture_format _mesa_texformat_rgb565_rev = {
fetch_texel_1d_f_rgb565_rev, /* FetchTexel1Df */
fetch_texel_2d_f_rgb565_rev, /* FetchTexel2Df */
fetch_texel_3d_f_rgb565_rev, /* FetchTexel3Df */
+ store_texel_rgb565_rev /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_argb4444 = {
@@ -731,6 +766,7 @@ const struct gl_texture_format _mesa_texformat_argb4444 = {
fetch_texel_1d_f_argb4444, /* FetchTexel1Df */
fetch_texel_2d_f_argb4444, /* FetchTexel2Df */
fetch_texel_3d_f_argb4444, /* FetchTexel3Df */
+ store_texel_argb4444 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_argb4444_rev = {
@@ -753,6 +789,7 @@ const struct gl_texture_format _mesa_texformat_argb4444_rev = {
fetch_texel_1d_f_argb4444_rev, /* FetchTexel1Df */
fetch_texel_2d_f_argb4444_rev, /* FetchTexel2Df */
fetch_texel_3d_f_argb4444_rev, /* FetchTexel3Df */
+ store_texel_argb4444_rev /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_argb1555 = {
@@ -775,6 +812,7 @@ const struct gl_texture_format _mesa_texformat_argb1555 = {
fetch_texel_1d_f_argb1555, /* FetchTexel1Df */
fetch_texel_2d_f_argb1555, /* FetchTexel2Df */
fetch_texel_3d_f_argb1555, /* FetchTexel3Df */
+ store_texel_argb1555 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_argb1555_rev = {
@@ -797,6 +835,7 @@ const struct gl_texture_format _mesa_texformat_argb1555_rev = {
fetch_texel_1d_f_argb1555_rev, /* FetchTexel1Df */
fetch_texel_2d_f_argb1555_rev, /* FetchTexel2Df */
fetch_texel_3d_f_argb1555_rev, /* FetchTexel3Df */
+ store_texel_argb1555_rev /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_al88 = {
@@ -819,6 +858,7 @@ const struct gl_texture_format _mesa_texformat_al88 = {
fetch_texel_1d_f_al88, /* FetchTexel1Df */
fetch_texel_2d_f_al88, /* FetchTexel2Df */
fetch_texel_3d_f_al88, /* FetchTexel3Df */
+ store_texel_al88 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_al88_rev = {
@@ -841,6 +881,7 @@ const struct gl_texture_format _mesa_texformat_al88_rev = {
fetch_texel_1d_f_al88_rev, /* FetchTexel1Df */
fetch_texel_2d_f_al88_rev, /* FetchTexel2Df */
fetch_texel_3d_f_al88_rev, /* FetchTexel3Df */
+ store_texel_al88_rev /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_rgb332 = {
@@ -863,6 +904,7 @@ const struct gl_texture_format _mesa_texformat_rgb332 = {
fetch_texel_1d_f_rgb332, /* FetchTexel1Df */
fetch_texel_2d_f_rgb332, /* FetchTexel2Df */
fetch_texel_3d_f_rgb332, /* FetchTexel3Df */
+ store_texel_rgb332 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_a8 = {
@@ -885,6 +927,7 @@ const struct gl_texture_format _mesa_texformat_a8 = {
fetch_texel_1d_f_a8, /* FetchTexel1Df */
fetch_texel_2d_f_a8, /* FetchTexel2Df */
fetch_texel_3d_f_a8, /* FetchTexel3Df */
+ store_texel_a8 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_l8 = {
@@ -907,6 +950,7 @@ const struct gl_texture_format _mesa_texformat_l8 = {
fetch_texel_1d_f_l8, /* FetchTexel1Df */
fetch_texel_2d_f_l8, /* FetchTexel2Df */
fetch_texel_3d_f_l8, /* FetchTexel3Df */
+ store_texel_l8 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_i8 = {
@@ -929,6 +973,7 @@ const struct gl_texture_format _mesa_texformat_i8 = {
fetch_texel_1d_f_i8, /* FetchTexel1Df */
fetch_texel_2d_f_i8, /* FetchTexel2Df */
fetch_texel_3d_f_i8, /* FetchTexel3Df */
+ store_texel_i8 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_ci8 = {
@@ -951,6 +996,7 @@ const struct gl_texture_format _mesa_texformat_ci8 = {
fetch_texel_1d_f_ci8, /* FetchTexel1Df */
fetch_texel_2d_f_ci8, /* FetchTexel2Df */
fetch_texel_3d_f_ci8, /* FetchTexel3Df */
+ store_texel_ci8 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_ycbcr = {
@@ -973,6 +1019,7 @@ const struct gl_texture_format _mesa_texformat_ycbcr = {
fetch_texel_1d_f_ycbcr, /* FetchTexel1Df */
fetch_texel_2d_f_ycbcr, /* FetchTexel2Df */
fetch_texel_3d_f_ycbcr, /* FetchTexel3Df */
+ store_texel_ycbcr /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
@@ -995,6 +1042,7 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
fetch_texel_1d_f_ycbcr_rev, /* FetchTexel1Df */
fetch_texel_2d_f_ycbcr_rev, /* FetchTexel2Df */
fetch_texel_3d_f_ycbcr_rev, /* FetchTexel3Df */
+ store_texel_ycbcr_rev /* StoreTexel */
};
/*@}*/
@@ -1024,6 +1072,7 @@ const struct gl_texture_format _mesa_null_texformat = {
fetch_null_texelf, /* FetchTexel1Df */
fetch_null_texelf, /* FetchTexel2Df */
fetch_null_texelf, /* FetchTexel3Df */
+ store_null_texel /* StoreTexel */
};
/*@}*/
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index 3df72291a1..7351929826 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -43,22 +43,22 @@
#if DIM == 1
-#define CHAN_SRC( t, i, j, k, sz ) \
+#define CHAN_ADDR( t, i, j, k, sz ) \
((void) (j), (void) (k), \
((GLchan *)(t)->Data + (i) * (sz)))
-#define UBYTE_SRC( t, i, j, k, sz ) \
+#define UBYTE_ADDR( t, i, j, k, sz ) \
((void) (j), (void) (k), \
((GLubyte *)(t)->Data + (i) * (sz)))
-#define USHORT_SRC( t, i, j, k ) \
+#define USHORT_ADDR( t, i, j, k ) \
((void) (j), (void) (k), \
((GLushort *)(t)->Data + (i)))
-#define UINT_SRC( t, i, j, k ) \
+#define UINT_ADDR( t, i, j, k ) \
((void) (j), (void) (k), \
((GLuint *)(t)->Data + (i)))
-#define FLOAT_SRC( t, i, j, k, sz ) \
+#define FLOAT_ADDR( t, i, j, k, sz ) \
((void) (j), (void) (k), \
((GLfloat *)(t)->Data + (i) * (sz)))
-#define HALF_SRC( t, i, j, k, sz ) \
+#define HALF_ADDR( t, i, j, k, sz ) \
((void) (j), (void) (k), \
((GLhalfARB *)(t)->Data + (i) * (sz)))
@@ -66,22 +66,22 @@
#elif DIM == 2
-#define CHAN_SRC( t, i, j, k, sz ) \
+#define CHAN_ADDR( t, i, j, k, sz ) \
((void) (k), \
((GLchan *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)))
-#define UBYTE_SRC( t, i, j, k, sz ) \
+#define UBYTE_ADDR( t, i, j, k, sz ) \
((void) (k), \
((GLubyte *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)))
-#define USHORT_SRC( t, i, j, k ) \
+#define USHORT_ADDR( t, i, j, k ) \
((void) (k), \
((GLushort *)(t)->Data + ((t)->RowStride * (j) + (i))))
-#define UINT_SRC( t, i, j, k ) \
+#define UINT_ADDR( t, i, j, k ) \
((void) (k), \
((GLuint *)(t)->Data + ((t)->RowStride * (j) + (i))))
-#define FLOAT_SRC( t, i, j, k, sz ) \
+#define FLOAT_ADDR( t, i, j, k, sz ) \
((void) (k), \
((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)))
-#define HALF_SRC( t, i, j, k, sz ) \
+#define HALF_ADDR( t, i, j, k, sz ) \
((void) (k), \
((GLhalfARB *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)))
@@ -89,22 +89,22 @@
#elif DIM == 3
-#define CHAN_SRC( t, i, j, k, sz ) \
+#define CHAN_ADDR( t, i, j, k, sz ) \
(GLchan *)(t)->Data + (((t)->Height * (k) + (j)) * \
(t)->RowStride + (i)) * (sz)
-#define UBYTE_SRC( t, i, j, k, sz ) \
+#define UBYTE_ADDR( t, i, j, k, sz ) \
((GLubyte *)(t)->Data + (((t)->Height * (k) + (j)) * \
(t)->RowStride + (i)) * (sz))
-#define USHORT_SRC( t, i, j, k ) \
+#define USHORT_ADDR( t, i, j, k ) \
((GLushort *)(t)->Data + (((t)->Height * (k) + (j)) * \
(t)->RowStride + (i)))
-#define UINT_SRC( t, i, j, k ) \
+#define UINT_ADDR( t, i, j, k ) \
((GLuint *)(t)->Data + (((t)->Height * (k) + (j)) * \
(t)->RowStride + (i)))
-#define FLOAT_SRC( t, i, j, k, sz ) \
+#define FLOAT_ADDR( t, i, j, k, sz ) \
((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \
(t)->RowStride + (i)) * (sz))
-#define HALF_SRC( t, i, j, k, sz ) \
+#define HALF_ADDR( t, i, j, k, sz ) \
((GLhalfARB *)(t)->Data + (((t)->Height * (k) + (j)) * \
(t)->RowStride + (i)) * (sz))
@@ -115,11 +115,13 @@
#endif
+/* MESA_FORMAT_RGBA **********************************************************/
+
/* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLchans */
static void FETCH(rgba)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 4 );
COPY_CHAN4( texel, src );
}
@@ -127,19 +129,34 @@ static void FETCH(rgba)( const struct gl_texture_image *texImage,
static void FETCH(f_rgba)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 4 );
texel[RCOMP] = CHAN_TO_FLOAT(src[0]);
texel[GCOMP] = CHAN_TO_FLOAT(src[1]);
texel[BCOMP] = CHAN_TO_FLOAT(src[2]);
texel[ACOMP] = CHAN_TO_FLOAT(src[3]);
}
+#if DIM == 3
+/* Store a GLchan RGBA texel */
+static void store_texel_rgba(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+/* MESA_FORMAT_RGB ***********************************************************/
/* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLchans */
static void FETCH(rgb)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = src[0];
texel[GCOMP] = src[1];
texel[BCOMP] = src[2];
@@ -150,18 +167,32 @@ static void FETCH(rgb)( const struct gl_texture_image *texImage,
static void FETCH(f_rgb)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = CHAN_TO_FLOAT(src[0]);
texel[GCOMP] = CHAN_TO_FLOAT(src[1]);
texel[BCOMP] = CHAN_TO_FLOAT(src[2]);
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_rgb(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 3);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+}
+#endif
+
+/* MESA_FORMAT_ALPHA *********************************************************/
+
/* Fetch texel from 1D, 2D or 3D ALPHA texture, returning 4 GLchans */
static void FETCH(alpha)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = 0;
@@ -172,18 +203,30 @@ static void FETCH(alpha)( const struct gl_texture_image *texImage,
static void FETCH(f_alpha)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = 0.0;
texel[ACOMP] = CHAN_TO_FLOAT(src[0]);
}
+#if DIM == 3
+static void store_texel_alpha(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[ACOMP];
+}
+#endif
+
+/* MESA_FORMAT_LUMINANCE *****************************************************/
+
/* Fetch texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */
static void FETCH(luminance)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = src[0];
@@ -194,18 +237,30 @@ static void FETCH(luminance)( const struct gl_texture_image *texImage,
static void FETCH(f_luminance)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = CHAN_TO_FLOAT(src[0]);
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_luminance(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+/* MESA_FORMAT_LUMINANCE_ALPHA ***********************************************/
+
/* Fetch texel from 1D, 2D or 3D L_A texture, returning 4 GLchans */
static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 2 );
texel[RCOMP] = src[0];
texel[GCOMP] = src[0];
texel[BCOMP] = src[0];
@@ -216,19 +271,31 @@ static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage,
static void FETCH(f_luminance_alpha)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 2 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = CHAN_TO_FLOAT(src[0]);
texel[ACOMP] = CHAN_TO_FLOAT(src[1]);
}
+#if DIM == 3
+static void store_texel_luminance_alpha(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[ACOMP];
+}
+#endif
+
+/* MESA_FORMAT_INTENSITY *****************************************************/
/* Fetch texel from 1D, 2D or 3D INT. texture, returning 4 GLchans */
static void FETCH(intensity)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] = src[0];
texel[GCOMP] = src[0];
texel[BCOMP] = src[0];
@@ -239,13 +306,25 @@ static void FETCH(intensity)( const struct gl_texture_image *texImage,
static void FETCH(f_intensity)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] =
texel[ACOMP] = CHAN_TO_FLOAT(src[0]);
}
+#if DIM == 3
+static void store_texel_intensity(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_DEPTH_COMPONENT_F32 *******************************************/
/* Fetch depth texel from 1D, 2D or 3D float32 DEPTH texture,
* returning 1 GLfloat.
@@ -254,56 +333,94 @@ static void FETCH(f_intensity)( const struct gl_texture_image *texImage,
static void FETCH(f_depth_component_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
texel[0] = src[0];
}
+#if DIM == 3
+static void store_texel_depth_component_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORMAT_DEPTH_COMPONENT16 *********************************************/
/* Fetch depth texel from 1D, 2D or 3D float32 DEPTH texture,
* returning 1 GLfloat.
* Note: no GLchan version of this function.
*/
-static void FETCH(f_depth_component16)( const struct gl_texture_image *texImage,
+static void FETCH(f_depth_component16)(const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
texel[0] = src[0] * (1.0F / 65535.0F);
}
+#if DIM == 3
+static void store_texel_depth_component16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLushort *depth = (const GLushort *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ dst[0] = *depth;
+}
+#endif
+
-/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture,
- * returning 4 GLchans.
+/* MESA_FORMAT_RGBA_F32 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLchans.
*/
static void FETCH(rgba_f32)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLchan *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 4 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 4 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], src[1]);
UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], src[2]);
UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[3]);
}
-/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture,
- * returning 4 GLfloats.
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats.
*/
static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 4 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 4 );
texel[RCOMP] = src[0];
texel[GCOMP] = src[1];
texel[BCOMP] = src[2];
texel[ACOMP] = src[3];
}
+#if DIM == 3
+static void store_texel_rgba_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = depth[RCOMP];
+ dst[1] = depth[GCOMP];
+ dst[2] = depth[BCOMP];
+ dst[3] = depth[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_F16 ******************************************************/
+
/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
* returning 4 GLchans.
*/
static void FETCH(rgba_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 4 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 4 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], _mesa_half_to_float(src[1]));
UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], _mesa_half_to_float(src[2]));
@@ -316,20 +433,32 @@ static void FETCH(rgba_f16)( const struct gl_texture_image *texImage,
static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 4 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 4 );
texel[RCOMP] = _mesa_half_to_float(src[0]);
texel[GCOMP] = _mesa_half_to_float(src[1]);
texel[BCOMP] = _mesa_half_to_float(src[2]);
texel[ACOMP] = _mesa_half_to_float(src[3]);
}
+#if DIM == 3
+static void store_texel_rgba_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(*depth);
+}
+#endif
+
+/* MESA_FORMAT_RGB_F32 *******************************************************/
+
/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
* returning 4 GLchans.
*/
static void FETCH(rgb_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 3 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 3 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], src[1]);
UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], src[2]);
@@ -342,20 +471,33 @@ static void FETCH(rgb_f32)( const struct gl_texture_image *texImage,
static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 3 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = src[0];
texel[GCOMP] = src[1];
texel[BCOMP] = src[2];
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_rgb_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORAMT_RGB_F16 *******************************************************/
+
/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
* returning 4 GLchans.
*/
static void FETCH(rgb_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 3 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 3 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], _mesa_half_to_float(src[1]));
UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], _mesa_half_to_float(src[2]));
@@ -368,20 +510,33 @@ static void FETCH(rgb_f16)( const struct gl_texture_image *texImage,
static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 3 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = _mesa_half_to_float(src[0]);
texel[GCOMP] = _mesa_half_to_float(src[1]);
texel[BCOMP] = _mesa_half_to_float(src[2]);
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_rgb_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(*depth);
+}
+#endif
+
+
+/* MESA_FORMAT_ALPHA_F32 *****************************************************/
+
/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
* returning 4 GLchans.
*/
static void FETCH(alpha_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = 0;
@@ -394,20 +549,33 @@ static void FETCH(alpha_f32)( const struct gl_texture_image *texImage,
static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = 0.0F;
texel[ACOMP] = src[0];
}
+#if DIM == 3
+static void store_texel_alpha_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_ALPHA_F32 *****************************************************/
+
/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
* returning 4 GLchans.
*/
static void FETCH(alpha_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = 0;
@@ -420,20 +588,33 @@ static void FETCH(alpha_f16)( const struct gl_texture_image *texImage,
static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = 0.0F;
texel[ACOMP] = _mesa_half_to_float(src[0]);
}
+#if DIM == 3
+static void store_texel_alpha_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_F32 *************************************************/
+
/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
* returning 4 GLchans.
*/
static void FETCH(luminance_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
texel[GCOMP] =
texel[BCOMP] = texel[RCOMP];
@@ -446,20 +627,33 @@ static void FETCH(luminance_f32)( const struct gl_texture_image *texImage,
static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = src[0];
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_luminance_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_F16 *************************************************/
+
/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
* returning 4 GLchans.
*/
static void FETCH(luminance_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
texel[GCOMP] =
texel[BCOMP] = texel[RCOMP];
@@ -472,20 +666,33 @@ static void FETCH(luminance_f16)( const struct gl_texture_image *texImage,
static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = _mesa_half_to_float(src[0]);
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_luminance_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/
+
/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
* returning 4 GLchans.
*/
static void FETCH(luminance_alpha_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 2 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 2 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
texel[GCOMP] =
texel[BCOMP] = texel[RCOMP];
@@ -498,20 +705,34 @@ static void FETCH(luminance_alpha_f32)( const struct gl_texture_image *texImage,
static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 2 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 2 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = src[0];
texel[ACOMP] = src[1];
}
+#if DIM == 3
+static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
+
/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
* returning 4 GLfloats.
*/
static void FETCH(luminance_alpha_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 2 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 2 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
texel[GCOMP] =
texel[BCOMP] = texel[RCOMP];
@@ -524,20 +745,34 @@ static void FETCH(luminance_alpha_f16)( const struct gl_texture_image *texImage,
static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 2 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 2 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = _mesa_half_to_float(src[0]);
texel[ACOMP] = _mesa_half_to_float(src[1]);
}
+#if DIM == 3
+static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 2);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+ dst[1] = _mesa_float_to_half(rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_INTENSITY_F32 *************************************************/
+
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
* returning 4 GLchans.
*/
static void FETCH(intensity_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
texel[GCOMP] =
texel[BCOMP] =
@@ -550,20 +785,33 @@ static void FETCH(intensity_f32)( const struct gl_texture_image *texImage,
static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLfloat *src = FLOAT_SRC( texImage, i, j, k, 1 );
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] =
texel[ACOMP] = src[0];
}
+#if DIM == 3
+static void store_texel_intensity_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_INTENSITY_F16 *************************************************/
+
/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
* returning 4 GLchans.
*/
static void FETCH(intensity_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
texel[GCOMP] =
texel[BCOMP] =
@@ -576,24 +824,37 @@ static void FETCH(intensity_f16)( const struct gl_texture_image *texImage,
static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLhalfARB *src = HALF_SRC( texImage, i, j, k, 1 );
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] =
texel[ACOMP] = _mesa_half_to_float(src[0]);
}
+#if DIM == 3
+static void store_texel_intensity_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
/*
* Begin Hardware formats
*/
+/* MESA_FORMAT_RGBA8888 ******************************************************/
+
/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLchans */
static void FETCH(rgba8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLuint s = *UINT_SRC( texImage, i, j, k );
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_CHAN( (s >> 24) );
texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
texel[BCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
@@ -604,19 +865,31 @@ static void FETCH(rgba8888)( const struct gl_texture_image *texImage,
static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLuint s = *UINT_SRC( texImage, i, j, k );
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
}
+#if DIM == 3
+static void store_texel_rgba8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = UINT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA888_REV ***************************************************/
/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
static void FETCH(rgba8888_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLuint s = *UINT_SRC( texImage, i, j, k );
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
texel[BCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
@@ -627,19 +900,31 @@ static void FETCH(rgba8888_rev)( const struct gl_texture_image *texImage,
static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLuint s = *UINT_SRC( texImage, i, j, k );
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
}
+#if DIM == 3
+static void store_texel_rgba8888_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = UINT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB8888 ******************************************************/
/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
static void FETCH(argb8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLuint s = *UINT_SRC( texImage, i, j, k );
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
texel[BCOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
@@ -650,43 +935,66 @@ static void FETCH(argb8888)( const struct gl_texture_image *texImage,
static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLuint s = *UINT_SRC( texImage, i, j, k );
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
}
+#if DIM == 3
+static void store_texel_argb8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = UINT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB8888_REV **************************************************/
/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLchans */
static void FETCH(argb8888_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLuint s = *UINT_SRC( texImage, i, j, k );
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
texel[BCOMP] = UBYTE_TO_CHAN( (s >> 24) );
texel[ACOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
}
-
/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLuint s = *UINT_SRC( texImage, i, j, k );
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
}
+#if DIM == 3
+static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = UINT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB888 ********************************************************/
/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
static void FETCH(rgb888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = UBYTE_TO_CHAN( src[2] );
texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
@@ -697,19 +1005,33 @@ static void FETCH(rgb888)( const struct gl_texture_image *texImage,
static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_rgb888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 3);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_BGR888 ********************************************************/
/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
static void FETCH(bgr888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
texel[BCOMP] = UBYTE_TO_CHAN( src[2] );
@@ -720,19 +1042,33 @@ static void FETCH(bgr888)( const struct gl_texture_image *texImage,
static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_bgr888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 3);
+ dst[0] = rgba[BCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGB565 ********************************************************/
/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
static void FETCH(rgb565)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = *src;
texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
@@ -744,7 +1080,7 @@ static void FETCH(rgb565)( const struct gl_texture_image *texImage,
static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = *src;
texel[RCOMP] = ((s >> 8) & 0xf8) * (1.0F / 248.0F);
texel[GCOMP] = ((s >> 3) & 0xfc) * (1.0F / 252.0F);
@@ -752,12 +1088,24 @@ static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_rgb565(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB565_REV ****************************************************/
/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */
static void FETCH(rgb565_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
@@ -769,7 +1117,7 @@ static void FETCH(rgb565_rev)( const struct gl_texture_image *texImage,
static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
texel[RCOMP] = ((s >> 8) & 0xf8) * (1.0F / 248.0F);
texel[GCOMP] = ((s >> 3) & 0xfc) * (1.0F / 252.0F);
@@ -777,12 +1125,24 @@ static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB4444 ******************************************************/
/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
static void FETCH(argb4444)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = *src;
texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf );
texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf );
@@ -794,7 +1154,7 @@ static void FETCH(argb4444)( const struct gl_texture_image *texImage,
static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = *src;
texel[RCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
texel[GCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
@@ -802,12 +1162,24 @@ static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
}
+#if DIM == 3
+static void store_texel_argb4444(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_4444(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB4444_REV **************************************************/
/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */
static void FETCH(argb4444_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort s = *USHORT_SRC( texImage, i, j, k );
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
texel[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf );
texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf );
@@ -818,19 +1190,31 @@ static void FETCH(argb4444_rev)( const struct gl_texture_image *texImage,
static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort s = *USHORT_SRC( texImage, i, j, k );
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
texel[RCOMP] = ((s ) & 0xf) * (1.0F / 15.0F);
texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
texel[BCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
}
+#if DIM == 3
+static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB1555 ******************************************************/
/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
static void FETCH(argb1555)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = *src;
texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f );
@@ -842,7 +1226,7 @@ static void FETCH(argb1555)( const struct gl_texture_image *texImage,
static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = *src;
texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F);
@@ -850,12 +1234,24 @@ static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
texel[ACOMP] = ((s >> 15) & 0x01);
}
+#if DIM == 3
+static void store_texel_argb1555(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB1555_REV **************************************************/
/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */
static void FETCH(argb1555_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f );
@@ -867,7 +1263,7 @@ static void FETCH(argb1555_rev)( const struct gl_texture_image *texImage,
static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F);
@@ -875,12 +1271,24 @@ static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage,
texel[ACOMP] = ((s >> 15) & 0x01);
}
+#if DIM == 3
+static void store_texel_argb1555_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL88 **********************************************************/
/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
static void FETCH(al88)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort s = *USHORT_SRC( texImage, i, j, k );
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = UBYTE_TO_CHAN( s & 0xff );
@@ -891,19 +1299,31 @@ static void FETCH(al88)( const struct gl_texture_image *texImage,
static void FETCH(f_al88)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort s = *USHORT_SRC( texImage, i, j, k );
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 );
}
+#if DIM == 3
+static void store_texel_al88(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL88_REV ******************************************************/
/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */
static void FETCH(al88_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort s = *USHORT_SRC( texImage, i, j, k );
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = UBYTE_TO_CHAN( s >> 8 );
@@ -914,19 +1334,31 @@ static void FETCH(al88_rev)( const struct gl_texture_image *texImage,
static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort s = *USHORT_SRC( texImage, i, j, k );
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 );
texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff );
}
+#if DIM == 3
+static void store_texel_al88_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB332 ********************************************************/
/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
static void FETCH(rgb332)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
const GLubyte s = *src;
texel[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 );
texel[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
@@ -938,7 +1370,7 @@ static void FETCH(rgb332)( const struct gl_texture_image *texImage,
static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
const GLubyte s = *src;
texel[RCOMP] = ((s ) & 0xe0) * (1.0F / 224.0F);
texel[GCOMP] = ((s << 3) & 0xe0) * (1.0F / 224.0F);
@@ -946,12 +1378,24 @@ static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_rgb332(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_A8 ************************************************************/
/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
static void FETCH(a8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = 0;
@@ -962,19 +1406,31 @@ static void FETCH(a8)( const struct gl_texture_image *texImage,
static void FETCH(f_a8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = 0.0;
texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
}
+#if DIM == 3
+static void store_texel_a8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_L8 ************************************************************/
/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
static void FETCH(l8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
@@ -985,19 +1441,31 @@ static void FETCH(l8)( const struct gl_texture_image *texImage,
static void FETCH(f_l8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_l8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_I8 ************************************************************/
/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
static void FETCH(i8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] =
@@ -1008,13 +1476,25 @@ static void FETCH(i8)( const struct gl_texture_image *texImage,
static void FETCH(f_i8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] =
texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
}
+#if DIM == 3
+static void store_texel_i8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_CI8 ***********************************************************/
/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
* color table, and return 4 GLchans.
@@ -1022,7 +1502,7 @@ static void FETCH(f_i8)( const struct gl_texture_image *texImage,
static void FETCH(ci8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
const struct gl_color_table *palette;
const GLchan *table;
GLuint index;
@@ -1101,6 +1581,18 @@ static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
}
+#if DIM == 3
+static void store_texel_ci8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *index = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = *index;
+}
+#endif
+
+
+/* MESA_FORMAT_YCBCR *********************************************************/
/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLchans */
/* We convert YCbCr to RGB here */
@@ -1108,7 +1600,7 @@ static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
static void FETCH(ycbcr)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
+ const GLushort *src0 = USHORT_ADDR( texImage, (i & ~1), j, k ); /* even */
const GLushort *src1 = src0 + 1; /* odd */
const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
const GLubyte cb = *src0 & 0xff; /* chroma U */
@@ -1138,7 +1630,7 @@ static void FETCH(ycbcr)( const struct gl_texture_image *texImage,
static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
+ const GLushort *src0 = USHORT_ADDR( texImage, (i & ~1), j, k ); /* even */
const GLushort *src1 = src0 + 1; /* odd */
const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
const GLubyte cb = *src0 & 0xff; /* chroma U */
@@ -1168,6 +1660,16 @@ static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_ycbcr(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ /* XXX to do */
+}
+#endif
+
+
+/* MESA_FORMAT_YCBCR_REV *****************************************************/
/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLchans */
/* We convert YCbCr to RGB here */
@@ -1175,7 +1677,7 @@ static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
+ const GLushort *src0 = USHORT_ADDR( texImage, (i & ~1), j, k ); /* even */
const GLushort *src1 = src0 + 1; /* odd */
const GLubyte y0 = *src0 & 0xff; /* luminance */
const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
@@ -1205,7 +1707,7 @@ static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage,
static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
- const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
+ const GLushort *src0 = USHORT_ADDR( texImage, (i & ~1), j, k ); /* even */
const GLushort *src1 = src0 + 1; /* odd */
const GLubyte y0 = *src0 & 0xff; /* luminance */
const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
@@ -1235,13 +1737,21 @@ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
texel[ACOMP] = 1.0F;
}
+#if DIM == 3
+static void store_texel_ycbcr_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ /* XXX to do */
+}
+#endif
+
-#undef CHAN_SRC
-#undef UBYTE_SRC
-#undef USHORT_SRC
-#undef UINT_SRC
-#undef FLOAT_SRC
-#undef HALF_SRC
+#undef CHAN_ADDR
+#undef UBYTE_ADDR
+#undef USHORT_ADDR
+#undef UINT_ADDR
+#undef FLOAT_ADDR
+#undef HALF_ADDR
#undef FETCH
#undef DIM
diff --git a/src/mesa/main/texrender.c b/src/mesa/main/texrender.c
new file mode 100644
index 0000000000..12afa93d01
--- /dev/null
+++ b/src/mesa/main/texrender.c
@@ -0,0 +1,197 @@
+
+#include "context.h"
+#include "fbobject.h"
+#include "texrender.h"
+#include "renderbuffer.h"
+
+
+/*
+ * Render-to-texture code for GL_EXT_framebuffer_object
+ */
+
+
+/**
+ * Derived from gl_renderbuffer class
+ */
+struct texture_renderbuffer
+{
+ struct gl_renderbuffer Base; /* Base class object */
+ struct gl_texture_image *TexImage;
+ StoreTexelFunc Store;
+ GLint Zoffset;
+};
+
+
+
+static void
+texture_get_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ /* XXX unfinished */
+}
+
+static void
+texture_get_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ /* XXX unfinished */
+}
+
+static void
+texture_put_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ const GLchan *rgba = (const GLchan *) values;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x + i, y, z, rgba);
+ }
+ rgba += 4;
+ }
+}
+
+static void
+texture_put_mono_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ const GLchan *rgba = (const GLchan *) value;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x + i, y, z, rgba);
+ }
+ }
+}
+
+static void
+texture_put_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ const GLchan *rgba = (const GLchan *) values;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x[i], y[i], z, rgba);
+ }
+ rgba += 4;
+ }
+}
+
+static void
+texture_put_mono_values(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ const GLchan *rgba = (const GLchan *) value;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x[i], y[i], z, rgba);
+ }
+ }
+}
+
+
+static void
+delete_texture_wrapper(struct gl_renderbuffer *rb)
+{
+ _mesa_free(rb);
+}
+
+
+/**
+ * If a render buffer attachment specifies a texture image, we'll use
+ * this function to make a gl_renderbuffer wrapper around the texture image.
+ * This allows other parts of Mesa to access the texture image as if it
+ * was a renderbuffer.
+ */
+static void
+wrap_texture(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
+{
+ struct texture_renderbuffer *trb;
+ const GLuint name = 0;
+
+ ASSERT(att->Type == GL_TEXTURE);
+ ASSERT(att->Renderbuffer == NULL);
+ /*
+ ASSERT(att->Complete);
+ */
+
+ trb = CALLOC_STRUCT(texture_renderbuffer);
+ if (!trb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "wrap_texture");
+ return;
+ }
+
+ _mesa_init_renderbuffer(&trb->Base, name);
+
+ trb->TexImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+ assert(trb->TexImage);
+
+ trb->Store = trb->TexImage->TexFormat->StoreTexel;
+ assert(trb->Store);
+
+ trb->Zoffset = att->Zoffset;
+
+ trb->Base.Width = trb->TexImage->Width;
+ trb->Base.Height = trb->TexImage->Height;
+ trb->Base.InternalFormat = trb->TexImage->IntFormat; /* XXX fix? */
+ trb->Base._BaseFormat = trb->TexImage->TexFormat->BaseFormat;
+ assert(trb->Base._BaseFormat == GL_RGB ||
+ trb->Base._BaseFormat == GL_RGBA ||
+ trb->Base._BaseFormat == GL_DEPTH_COMPONENT);
+ trb->Base.DataType = GL_UNSIGNED_BYTE; /* XXX fix! */
+ trb->Base.Data = trb->TexImage->Data;
+
+ trb->Base.GetRow = texture_get_row;
+ trb->Base.GetValues = texture_get_values;
+ trb->Base.PutRow = texture_put_row;
+ trb->Base.PutMonoRow = texture_put_mono_row;
+ trb->Base.PutValues = texture_put_values;
+ trb->Base.PutMonoValues = texture_put_mono_values;
+
+ trb->Base.Delete = delete_texture_wrapper;
+ trb->Base.AllocStorage = NULL; /* illegal! */
+
+ att->Renderbuffer = &(trb->Base);
+}
+
+
+
+/**
+ * Software fallback for ctx->Driver.RenderbufferTexture.
+ * This is called via the glRenderbufferTexture1D/2D/3D() functions.
+ * If we're unbinding a texture, texObj will be NULL.
+ * The framebuffer of interest is ctx->DrawBuffer.
+ * \sa _mesa_framebuffer_renderbuffer
+ */
+void
+_mesa_renderbuffer_texture(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset)
+{
+ if (texObj) {
+ _mesa_set_texture_attachment(ctx, att, texObj,
+ texTarget, level, zoffset);
+
+ wrap_texture(ctx, att);
+ }
+ else {
+ _mesa_remove_attachment(ctx, att);
+ }
+}
diff --git a/src/mesa/main/texrender.h b/src/mesa/main/texrender.h
new file mode 100644
index 0000000000..6d8bc96414
--- /dev/null
+++ b/src/mesa/main/texrender.h
@@ -0,0 +1,12 @@
+#ifndef TEXRENDER_H
+#define TEXRENDER_H
+
+
+extern void
+_mesa_renderbuffer_texture(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset);
+
+
+#endif /* TEXRENDER_H */
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 3a8ccb3984..02f2dbe69f 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2200,8 +2200,8 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
return;
}
- pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, pixels,
- packing, "glTexImage1D");
+ pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type,
+ pixels, packing, "glTexImage1D");
if (!pixels) {
/* Note: we check for a NULL image pointer here, _after_ we allocated
* memory for the texture. That's what the GL spec calls for.
@@ -2289,7 +2289,7 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
}
pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
- pixels, packing, "glTexImage2D");
+ pixels, packing, "glTexImage2D");
if (!pixels) {
/* Note: we check for a NULL image pointer here, _after_ we allocated
* memory for the texture. That's what the GL spec calls for.
@@ -2368,8 +2368,8 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
return;
}
- pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, type,
- pixels, packing, "glTexImage3D");
+ pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format,
+ type, pixels, packing, "glTexImage3D");
if (!pixels) {
/* Note: we check for a NULL image pointer here, _after_ we allocated
* memory for the texture. That's what the GL spec calls for.
@@ -2425,8 +2425,8 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, pixels,
- packing, "glTexSubImage1D");
+ pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type,
+ pixels, packing, "glTexSubImage1D");
if (!pixels)
return;
@@ -2472,7 +2472,7 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage)
{
pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
- pixels, packing, "glTexSubImage2D");
+ pixels, packing, "glTexSubImage2D");
if (!pixels)
return;
@@ -2523,8 +2523,9 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, type,
- pixels, packing, "glTexSubImage3D");
+ pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format,
+ type, pixels, packing,
+ "glTexSubImage3D");
if (!pixels)
return;
@@ -2625,8 +2626,9 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
return;
}
- data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, &ctx->Unpack,
- "glCompressedTexImage2D");
+ data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
+ &ctx->Unpack,
+ "glCompressedTexImage2D");
if (!data)
return;
@@ -2719,8 +2721,9 @@ _mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target,
ASSERT((xoffset & 3) == 0);
ASSERT((yoffset & 3) == 0);
- data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, &ctx->Unpack,
- "glCompressedTexSubImage2D");
+ data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
+ &ctx->Unpack,
+ "glCompressedTexSubImage2D");
if (!data)
return;
diff --git a/src/mesa/sources b/src/mesa/sources
index 54cd290524..8a649d7d47 100644
--- a/src/mesa/sources
+++ b/src/mesa/sources
@@ -26,6 +26,7 @@ MAIN_SOURCES = \
main/fbobject.c \
main/feedback.c \
main/fog.c \
+ main/framebuffer.c \
main/get.c \
main/getstring.c \
main/hash.c \
@@ -41,6 +42,7 @@ MAIN_SOURCES = \
main/points.c \
main/polygon.c \
main/rastpos.c \
+ main/renderbuffer.c \
main/state.c \
main/stencil.c \
main/texcompress.c \
@@ -49,6 +51,7 @@ MAIN_SOURCES = \
main/texenvprogram.c \
main/texformat.c \
main/teximage.c \
+ main/texrender.c \
main/texobj.c \
main/texstate.c \
main/texstore.c \
@@ -79,9 +82,7 @@ SWRAST_SOURCES = \
swrast/s_aatriangle.c \
swrast/s_accum.c \
swrast/s_alpha.c \
- swrast/s_alphabuf.c \
swrast/s_atifragshader.c \
- swrast/s_auxbuffer.c \
swrast/s_bitmap.c \
swrast/s_blend.c \
swrast/s_buffers.c \
@@ -229,7 +230,7 @@ SPARC_SOURCES = \
SPARC_API = \
sparc/glapi_sparc.S
-COMMON_DRIVER_SOURCES = \
+COMMON_DRIVER_SOURCES = \
drivers/common/driverfuncs.c
X11_DRIVER_SOURCES = \
@@ -237,9 +238,10 @@ X11_DRIVER_SOURCES = \
drivers/x11/fakeglx.c \
drivers/x11/xfonts.c \
drivers/x11/xm_api.c \
+ drivers/x11/xm_buffer.c \
drivers/x11/xm_dd.c \
drivers/x11/xm_line.c \
- drivers/x11/xm_span.c \
+ drivers/x11/xm_span2.c \
drivers/x11/xm_tri.c
OSMESA_DRIVER_SOURCES = \
diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c
index 55ba831059..b0af0f95d4 100644
--- a/src/mesa/swrast/s_accum.c
+++ b/src/mesa/swrast/s_accum.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.0.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"),
@@ -27,20 +27,23 @@
#include "context.h"
#include "macros.h"
#include "imports.h"
+#include "fbobject.h"
#include "s_accum.h"
-#include "s_alphabuf.h"
#include "s_context.h"
#include "s_masking.h"
#include "s_span.h"
+#define ACCUM_SCALE16 32767.0
+
+
/*
* Accumulation buffer notes
*
* Normally, accumulation buffer values are GLshorts with values in
* [-32767, 32767] which represent floating point colors in [-1, 1],
- * as suggested by the OpenGL specification.
+ * as defined by the OpenGL specification.
*
* We optimize for the common case used for full-scene antialiasing:
* // start with accum buffer cleared to zero
@@ -54,68 +57,61 @@
* In this scenario, we can simply store unscaled integer values in
* the accum buffer instead of scaled integers. We'll also keep track
* of the w value so when we do GL_RETURN we simply divide the accumulated
- * values by n (=1/w).
+ * values by n (n=1/w).
* This lets us avoid _many_ int->float->int conversions.
*/
-#if CHAN_BITS == 8 && ACCUM_BITS < 32
-#define USE_OPTIMIZED_ACCUM /* enable the optimization */
-#endif
-
-
-void
-_swrast_alloc_accum_buffer( GLframebuffer *buffer )
-{
- GET_CURRENT_CONTEXT(ctx);
- GLint n;
-
- ASSERT(buffer->UseSoftwareAccumBuffer);
-
- if (buffer->Accum) {
- MESA_PBUFFER_FREE( buffer->Accum );
- buffer->Accum = NULL;
- }
-
- /* allocate accumulation buffer if not already present */
- n = buffer->Width * buffer->Height * 4 * sizeof(GLaccum);
- buffer->Accum = (GLaccum *) MESA_PBUFFER_ALLOC( n );
- if (!buffer->Accum) {
- /* unable to setup accumulation buffer */
- _mesa_error( NULL, GL_OUT_OF_MEMORY, "glAccum" );
- }
-
- if (ctx) {
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- /* XXX these fields should probably be in the GLframebuffer */
-#ifdef USE_OPTIMIZED_ACCUM
- swrast->_IntegerAccumMode = GL_TRUE;
+#if CHAN_BITS == 8 && ACCUM_BITS <= 32
+/* enable the optimization */
+#define USE_OPTIMIZED_ACCUM 1
#else
- swrast->_IntegerAccumMode = GL_FALSE;
+#define USE_OPTIMIZED_ACCUM 0
#endif
- swrast->_IntegerAccumScaler = 0.0;
- }
-}
-/*
+/**
* This is called when we fall out of optimized/unscaled accum buffer mode.
* That is, we convert each unscaled accum buffer value into a scaled value
* representing the range[-1, 1].
*/
-static void rescale_accum( GLcontext *ctx )
+static void
+rescale_accum( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLuint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4;
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
const GLfloat s = swrast->_IntegerAccumScaler * (32767.0F / CHAN_MAXF);
- GLaccum *accum = ctx->DrawBuffer->Accum;
- GLuint i;
+ assert(rb);
+ assert(rb->_BaseFormat == GL_RGBA);
+ /* add other types in future? */
+ assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT);
assert(swrast->_IntegerAccumMode);
- assert(accum);
- for (i = 0; i < n; i++) {
- accum[i] = (GLaccum) (accum[i] * s);
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* directly-addressable memory */
+ GLuint y;
+ for (y = 0; y < rb->Height; y++) {
+ GLuint i;
+ GLshort *acc = (GLshort *) rb->GetPointer(ctx, rb, 0, y);
+ for (i = 0; i < 4 * rb->Width; i++) {
+ acc[i] = (GLshort) (acc[i] * s);
+ }
+ }
+ }
+ else {
+ /* use get/put row funcs */
+ GLuint y;
+ for (y = 0; y < rb->Height; y++) {
+ GLshort accRow[MAX_WIDTH * 4];
+ GLuint i;
+ rb->GetRow(ctx, rb, rb->Width, 0, y, accRow);
+ for (i = 0; i < 4 * rb->Width; i++) {
+ accRow[i] = (GLshort) (accRow[i] * s);
+ }
+ rb->PutRow(ctx, rb, rb->Width, 0, y, accRow, NULL);
+ }
}
swrast->_IntegerAccumMode = GL_FALSE;
@@ -123,406 +119,472 @@ static void rescale_accum( GLcontext *ctx )
-
-
-
-/*
+/**
* Clear the accumulation Buffer.
*/
void
-_swrast_clear_accum_buffer( GLcontext *ctx )
+_swrast_clear_accum_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLuint buffersize;
- GLfloat acc_scale;
+ GLuint x, y, width, height;
- if (ctx->Visual.accumRedBits==0) {
- /* No accumulation buffer! */
+ if (ctx->Visual.accumRedBits == 0) {
+ /* No accumulation buffer! Not an error. */
return;
}
- if (sizeof(GLaccum)==1) {
- acc_scale = 127.0;
- }
- else if (sizeof(GLaccum)==2) {
- acc_scale = 32767.0;
+ assert(rb);
+ assert(rb->_BaseFormat == GL_RGBA);
+ /* add other types in future? */
+ assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT);
+
+ /* bounds, with scissor */
+ x = ctx->DrawBuffer->_Xmin;
+ y = ctx->DrawBuffer->_Ymin;
+ width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ const GLfloat accScale = 32767.0;
+ GLshort clearVal[4];
+ GLuint i;
+
+ clearVal[0] = (GLshort) (ctx->Accum.ClearColor[0] * accScale);
+ clearVal[1] = (GLshort) (ctx->Accum.ClearColor[1] * accScale);
+ clearVal[2] = (GLshort) (ctx->Accum.ClearColor[2] * accScale);
+ clearVal[3] = (GLshort) (ctx->Accum.ClearColor[3] * accScale);
+
+ for (i = 0; i < height; i++) {
+ rb->PutMonoRow(ctx, rb, width, x, y + i, clearVal, NULL);
+ }
}
else {
- acc_scale = 1.0F;
+ /* someday support other sizes */
}
- /* number of pixels */
- buffersize = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
-
- if (!ctx->DrawBuffer->Accum) {
- /* try to alloc accumulation buffer */
- ctx->DrawBuffer->Accum = (GLaccum *)
- MALLOC( buffersize * 4 * sizeof(GLaccum) );
+ /* update optimized accum state vars */
+ if (ctx->Accum.ClearColor[0] == 0.0 && ctx->Accum.ClearColor[1] == 0.0 &&
+ ctx->Accum.ClearColor[2] == 0.0 && ctx->Accum.ClearColor[3] == 0.0) {
+#if USE_OPTIMIZED_ACCUM
+ swrast->_IntegerAccumMode = GL_TRUE;
+#else
+ swrast->_IntegerAccumMode = GL_FALSE;
+#endif
+ swrast->_IntegerAccumScaler = 0.0; /* denotes empty accum buffer */
}
+ else {
+ swrast->_IntegerAccumMode = GL_FALSE;
+ }
+}
- if (ctx->DrawBuffer->Accum) {
- if (ctx->Scissor.Enabled) {
- /* Limit clear to scissor box */
- const GLaccum r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
- const GLaccum g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
- const GLaccum b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
- const GLaccum a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
- GLint i, j;
- GLint width, height;
- GLaccum *row;
- /* size of region to clear */
- width = 4 * (ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin);
- height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
- /* ptr to first element to clear */
- row = ctx->DrawBuffer->Accum
- + 4 * (ctx->DrawBuffer->_Ymin * ctx->DrawBuffer->Width
- + ctx->DrawBuffer->_Xmin);
- for (j=0;j<height;j++) {
- for (i=0;i<width;i+=4) {
- row[i+0] = r;
- row[i+1] = g;
- row[i+2] = b;
- row[i+3] = a;
- }
- row += 4 * ctx->DrawBuffer->Width;
- }
+
+static void
+accum_add(GLcontext *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+
+ assert(rb);
+
+ /* Leave optimized accum buffer mode */
+ if (swrast->_IntegerAccumMode)
+ rescale_accum(ctx);
+
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ const GLshort incr = (GLshort) (value * ACCUM_SCALE16);
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLshort *acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
+ for (j = 0; j < 4 * width; j++) {
+ acc[j] += incr;
+ }
+ }
}
else {
- /* clear whole buffer */
- if (ctx->Accum.ClearColor[0]==0.0 &&
- ctx->Accum.ClearColor[1]==0.0 &&
- ctx->Accum.ClearColor[2]==0.0 &&
- ctx->Accum.ClearColor[3]==0.0) {
- /* Black */
- _mesa_bzero( ctx->DrawBuffer->Accum,
- buffersize * 4 * sizeof(GLaccum) );
- }
- else {
- /* Not black */
- const GLaccum r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
- const GLaccum g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
- const GLaccum b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
- const GLaccum a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
- GLaccum *acc = ctx->DrawBuffer->Accum;
- GLuint i;
- for (i=0;i<buffersize;i++) {
- *acc++ = r;
- *acc++ = g;
- *acc++ = b;
- *acc++ = a;
- }
- }
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLshort accRow[4 * MAX_WIDTH];
+ rb->GetRow(ctx, rb, width, xpos, ypos + i, accRow);
+ for (j = 0; j < 4 * width; j++) {
+ accRow[j] += incr;
+ }
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, accRow, NULL);
+ }
}
+ }
+ else {
+ /* other types someday */
+ }
+}
- /* update optimized accum state vars */
- if (ctx->Accum.ClearColor[0] == 0.0 && ctx->Accum.ClearColor[1] == 0.0 &&
- ctx->Accum.ClearColor[2] == 0.0 && ctx->Accum.ClearColor[3] == 0.0) {
-#ifdef USE_OPTIMIZED_ACCUM
- swrast->_IntegerAccumMode = GL_TRUE;
-#else
- swrast->_IntegerAccumMode = GL_FALSE;
-#endif
- swrast->_IntegerAccumScaler = 0.0; /* denotes empty accum buffer */
+
+static void
+accum_mult(GLcontext *ctx, GLfloat mult,
+ GLint xpos, GLint ypos, GLint width, GLint height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+
+ assert(rb);
+
+ /* Leave optimized accum buffer mode */
+ if (swrast->_IntegerAccumMode)
+ rescale_accum(ctx);
+
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLshort *acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
+ for (j = 0; j < 4 * width; j++) {
+ acc[j] = (GLshort) (acc[j] * mult);
+ }
+ }
}
else {
- swrast->_IntegerAccumMode = GL_FALSE;
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLshort accRow[4 * MAX_WIDTH];
+ rb->GetRow(ctx, rb, width, xpos, ypos + i, accRow);
+ for (j = 0; j < 4 * width; j++) {
+ accRow[j] = (GLshort) (accRow[j] * mult);
+ }
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, accRow, NULL);
+ }
}
}
+ else {
+ /* other types someday */
+ }
}
-void
-_swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
- GLint xpos, GLint ypos,
- GLint width, GLint height )
+static void
+accum_accum(GLcontext *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLuint width4;
- GLfloat acc_scale;
- GLchan rgba[MAX_WIDTH][4];
- const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ const GLboolean directAccess = (rb->GetPointer(ctx, rb, 0, 0) != NULL);
+ assert(rb);
- if (SWRAST_CONTEXT(ctx)->NewState)
- _swrast_validate_derived( ctx );
-
- if (!ctx->DrawBuffer->Accum) {
- _mesa_warning(ctx,
- "Calling glAccum() without an accumulation "
- "buffer (low memory?)");
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no read buffer - OK */
return;
}
- if (sizeof(GLaccum)==1) {
- acc_scale = 127.0;
- }
- else if (sizeof(GLaccum)==2) {
- acc_scale = 32767.0;
- }
- else {
- acc_scale = 1.0F;
- }
-
- width4 = 4 * width;
+ /* May have to leave optimized accum buffer mode */
+ if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
+ swrast->_IntegerAccumScaler = value;
+ if (swrast->_IntegerAccumMode && value != swrast->_IntegerAccumScaler)
+ rescale_accum(ctx);
- switch (op) {
- case GL_ADD:
- if (value != 0.0F) {
- const GLaccum val = (GLaccum) (value * acc_scale);
- GLint j;
- /* Leave optimized accum buffer mode */
- if (swrast->_IntegerAccumMode)
- rescale_accum(ctx);
- for (j = 0; j < height; j++) {
- GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + 4*xpos;
- GLuint i;
- for (i = 0; i < width4; i++) {
- acc[i] += val;
- }
- ypos++;
- }
- }
- break;
+ _swrast_use_read_buffer(ctx);
- case GL_MULT:
- if (value != 1.0F) {
- GLint j;
- /* Leave optimized accum buffer mode */
- if (swrast->_IntegerAccumMode)
- rescale_accum(ctx);
- for (j = 0; j < height; j++) {
- GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + 4 * xpos;
- GLuint i;
- for (i = 0; i < width4; i++) {
- acc[i] = (GLaccum) ( (GLfloat) acc[i] * value );
- }
- ypos++;
- }
- }
- break;
-
- case GL_ACCUM:
- if (value == 0.0F)
- return;
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ const GLfloat scale = value * ACCUM_SCALE16 / CHAN_MAXF;
+ GLshort accumRow[4 * MAX_WIDTH];
+ GLchan rgba[MAX_WIDTH][4];
+ GLint i;
- _swrast_use_read_buffer(ctx);
-
- /* May have to leave optimized accum buffer mode */
- if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
- swrast->_IntegerAccumScaler = value;
- if (swrast->_IntegerAccumMode && value != swrast->_IntegerAccumScaler)
- rescale_accum(ctx);
+ for (i = 0; i < height; i++) {
+ GLshort *acc;
+ if (directAccess) {
+ acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
+ }
+ else {
+ rb->GetRow(ctx, rb, width, xpos, ypos + i, accumRow);
+ acc = accumRow;
+ }
- RENDER_START(swrast,ctx);
+ /* read colors from color buffer */
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, width,
+ xpos, ypos + i, rgba);
+ /* do accumulation */
if (swrast->_IntegerAccumMode) {
/* simply add integer color values into accum buffer */
GLint j;
- GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
- assert(swrast->_IntegerAccumScaler > 0.0);
- assert(swrast->_IntegerAccumScaler <= 1.0);
- for (j = 0; j < height; j++) {
-
- GLint i, i4;
- _swrast_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
- for (i = i4 = 0; i < width; i++, i4+=4) {
- acc[i4+0] += rgba[i][RCOMP];
- acc[i4+1] += rgba[i][GCOMP];
- acc[i4+2] += rgba[i][BCOMP];
- acc[i4+3] += rgba[i][ACOMP];
- }
- acc += width4;
- ypos++;
+ for (j = 0; j < width; j++) {
+ acc[j * 4 + 0] += rgba[j][RCOMP];
+ acc[j * 4 + 1] += rgba[j][GCOMP];
+ acc[j * 4 + 2] += rgba[j][BCOMP];
+ acc[j * 4 + 3] += rgba[j][ACOMP];
}
}
else {
/* scaled integer (or float) accum buffer */
- const GLfloat rscale = value * acc_scale / CHAN_MAXF;
- const GLfloat gscale = value * acc_scale / CHAN_MAXF;
- const GLfloat bscale = value * acc_scale / CHAN_MAXF;
- const GLfloat ascale = value * acc_scale / CHAN_MAXF;
GLint j;
- for (j=0;j<height;j++) {
- GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
- GLint i;
- _swrast_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
- for (i=0;i<width;i++) {
- acc[0] += (GLaccum) ( (GLfloat) rgba[i][RCOMP] * rscale );
- acc[1] += (GLaccum) ( (GLfloat) rgba[i][GCOMP] * gscale );
- acc[2] += (GLaccum) ( (GLfloat) rgba[i][BCOMP] * bscale );
- acc[3] += (GLaccum) ( (GLfloat) rgba[i][ACOMP] * ascale );
- acc += 4;
- }
- ypos++;
+ for (j = 0; j < width; j++) {
+ acc[j * 4 + 0] += (GLshort) ((GLfloat) rgba[j][RCOMP] * scale);
+ acc[j * 4 + 1] += (GLshort) ((GLfloat) rgba[j][GCOMP] * scale);
+ acc[j * 4 + 2] += (GLshort) ((GLfloat) rgba[j][BCOMP] * scale);
+ acc[j * 4 + 3] += (GLshort) ((GLfloat) rgba[j][ACOMP] * scale);
}
}
- /* restore read buffer = draw buffer (the default) */
- _swrast_use_draw_buffer(ctx);
- RENDER_FINISH(swrast,ctx);
- break;
+ if (!directAccess) {
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, accumRow, NULL);
+ }
+ }
+ }
+ else {
+ /* other types someday */
+ }
- case GL_LOAD:
- _swrast_use_read_buffer(ctx);
+ _swrast_use_draw_buffer(ctx);
+}
+
+
+
+static void
+accum_load(GLcontext *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ const GLboolean directAccess = (rb->GetPointer(ctx, rb, 0, 0) != NULL);
- /* This is a change to go into optimized accum buffer mode */
- if (value > 0.0 && value <= 1.0) {
-#ifdef USE_OPTIMIZED_ACCUM
- swrast->_IntegerAccumMode = GL_TRUE;
+ assert(rb);
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no read buffer - OK */
+ return;
+ }
+
+ /* This is a change to go into optimized accum buffer mode */
+ if (value > 0.0 && value <= 1.0) {
+#if USE_OPTIMIZED_ACCUM
+ swrast->_IntegerAccumMode = GL_TRUE;
#else
- swrast->_IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumMode = GL_FALSE;
#endif
- swrast->_IntegerAccumScaler = value;
+ swrast->_IntegerAccumScaler = value;
+ }
+ else {
+ swrast->_IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumScaler = 0.0;
+ }
+
+ _swrast_use_read_buffer(ctx);
+
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ const GLfloat scale = value * ACCUM_SCALE16 / CHAN_MAXF;
+ GLshort accumRow[4 * MAX_WIDTH];
+ GLchan rgba[MAX_WIDTH][4];
+ GLint i;
+
+ for (i = 0; i < height; i++) {
+ GLshort *acc;
+ if (directAccess) {
+ acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
}
else {
- swrast->_IntegerAccumMode = GL_FALSE;
- swrast->_IntegerAccumScaler = 0.0;
+ rb->GetRow(ctx, rb, width, xpos, ypos + i, accumRow);
+ acc = accumRow;
}
- RENDER_START(swrast,ctx);
+ /* read colors from color buffer */
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, width,
+ xpos, ypos + i, rgba);
+
+ /* do load */
if (swrast->_IntegerAccumMode) {
- /* just copy values into accum buffer */
+ /* just copy values in */
GLint j;
- GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
assert(swrast->_IntegerAccumScaler > 0.0);
assert(swrast->_IntegerAccumScaler <= 1.0);
- for (j = 0; j < height; j++) {
- GLint i, i4;
- _swrast_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
- for (i = i4 = 0; i < width; i++, i4 += 4) {
- acc[i4+0] = rgba[i][RCOMP];
- acc[i4+1] = rgba[i][GCOMP];
- acc[i4+2] = rgba[i][BCOMP];
- acc[i4+3] = rgba[i][ACOMP];
- }
- acc += width4;
- ypos++;
+ for (j = 0; j < width; j++) {
+ acc[j * 4 + 0] = rgba[j][RCOMP];
+ acc[j * 4 + 1] = rgba[j][GCOMP];
+ acc[j * 4 + 2] = rgba[j][BCOMP];
+ acc[j * 4 + 3] = rgba[j][ACOMP];
}
}
else {
/* scaled integer (or float) accum buffer */
- const GLfloat rscale = value * acc_scale / CHAN_MAXF;
- const GLfloat gscale = value * acc_scale / CHAN_MAXF;
- const GLfloat bscale = value * acc_scale / CHAN_MAXF;
- const GLfloat ascale = value * acc_scale / CHAN_MAXF;
-#if 0
- const GLfloat d = 3.0 / acc_scale; /* XXX what's this? */
-#endif
- GLint i, j;
- for (j = 0; j < height; j++) {
- GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
- _swrast_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
- for (i=0;i<width;i++) {
-#if 0
- *acc++ = (GLaccum) ((GLfloat) rgba[i][RCOMP] * rscale + d);
- *acc++ = (GLaccum) ((GLfloat) rgba[i][GCOMP] * gscale + d);
- *acc++ = (GLaccum) ((GLfloat) rgba[i][BCOMP] * bscale + d);
- *acc++ = (GLaccum) ((GLfloat) rgba[i][ACOMP] * ascale + d);
-#else
- *acc++ = (GLaccum) ((GLfloat) rgba[i][RCOMP] * rscale);
- *acc++ = (GLaccum) ((GLfloat) rgba[i][GCOMP] * gscale);
- *acc++ = (GLaccum) ((GLfloat) rgba[i][BCOMP] * bscale);
- *acc++ = (GLaccum) ((GLfloat) rgba[i][ACOMP] * ascale);
-#endif
- }
- ypos++;
+ GLint j;
+ for (j = 0; j < width; j++) {
+ acc[j * 4 + 0] = (GLshort) ((GLfloat) rgba[j][RCOMP] * scale);
+ acc[j * 4 + 1] = (GLshort) ((GLfloat) rgba[j][GCOMP] * scale);
+ acc[j * 4 + 2] = (GLshort) ((GLfloat) rgba[j][BCOMP] * scale);
+ acc[j * 4 + 3] = (GLshort) ((GLfloat) rgba[j][ACOMP] * scale);
}
}
- /* restore read buffer = draw buffer (the default) */
- _swrast_use_draw_buffer(ctx);
+ if (!directAccess) {
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, accumRow, NULL);
+ }
+ }
+ }
+ else {
+ /* other types someday */
+ }
- RENDER_FINISH(swrast,ctx);
- break;
+ _swrast_use_draw_buffer(ctx);
+}
- case GL_RETURN:
- /* May have to leave optimized accum buffer mode */
- if (swrast->_IntegerAccumMode && value != 1.0)
- rescale_accum(ctx);
-
- RENDER_START(swrast,ctx);
-#ifdef USE_OPTIMIZED_ACCUM
- if (swrast->_IntegerAccumMode && swrast->_IntegerAccumScaler > 0) {
- /* build lookup table to avoid many floating point multiplies */
- static GLchan multTable[32768];
- static GLfloat prevMult = 0.0;
- const GLfloat mult = swrast->_IntegerAccumScaler;
- const GLint max = MIN2((GLint) (256 / mult), 32767);
- GLint j;
- if (mult != prevMult) {
- for (j = 0; j < max; j++)
- multTable[j] = IROUND((GLfloat) j * mult);
- prevMult = mult;
- }
- assert(swrast->_IntegerAccumScaler > 0.0);
- assert(swrast->_IntegerAccumScaler <= 1.0);
- for (j = 0; j < height; j++) {
- const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
- GLint i, i4;
- for (i = i4 = 0; i < width; i++, i4 += 4) {
- ASSERT(acc[i4+0] < max);
- ASSERT(acc[i4+1] < max);
- ASSERT(acc[i4+2] < max);
- ASSERT(acc[i4+3] < max);
- rgba[i][RCOMP] = multTable[acc[i4+0]];
- rgba[i][GCOMP] = multTable[acc[i4+1]];
- rgba[i][BCOMP] = multTable[acc[i4+2]];
- rgba[i][ACOMP] = multTable[acc[i4+3]];
- }
- if (colorMask != 0xffffffff) {
- _swrast_mask_rgba_array( ctx, width, xpos, ypos, rgba );
- }
- (*swrast->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
- (const GLchan (*)[4])rgba, NULL );
- if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
- && ctx->Color.ColorMask[ACOMP]) {
- _swrast_write_alpha_span(ctx, width, xpos, ypos,
- (CONST GLchan (*)[4]) rgba, NULL);
- }
- ypos++;
+static void
+accum_return(GLcontext *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *accumRb = fb->Attachment[BUFFER_ACCUM].Renderbuffer;
+ const GLboolean directAccess
+ = (accumRb->GetPointer(ctx, accumRb, 0, 0) != NULL);
+ const GLboolean masking = (!ctx->Color.ColorMask[RCOMP] ||
+ !ctx->Color.ColorMask[GCOMP] ||
+ !ctx->Color.ColorMask[BCOMP] ||
+ !ctx->Color.ColorMask[ACOMP]);
+
+ static GLchan multTable[32768];
+ static GLfloat prevMult = 0.0;
+ const GLfloat mult = swrast->_IntegerAccumScaler;
+ const GLint max = MIN2((GLint) (256 / mult), 32767);
+
+ /* May have to leave optimized accum buffer mode */
+ if (swrast->_IntegerAccumMode && value != 1.0)
+ rescale_accum(ctx);
+
+ if (swrast->_IntegerAccumMode && swrast->_IntegerAccumScaler > 0) {
+ /* build lookup table to avoid many floating point multiplies */
+ GLint j;
+ assert(swrast->_IntegerAccumScaler <= 1.0);
+ if (mult != prevMult) {
+ for (j = 0; j < max; j++)
+ multTable[j] = IROUND((GLfloat) j * mult);
+ prevMult = mult;
+ }
+ }
+
+ if (accumRb->DataType == GL_SHORT ||
+ accumRb->DataType == GL_UNSIGNED_SHORT) {
+ const GLfloat scale = value * CHAN_MAXF / ACCUM_SCALE16;
+ GLuint buffer, i;
+
+ /* XXX maybe transpose the 'i' and 'buffer' loops??? */
+ for (i = 0; i < height; i++) {
+ GLchan rgba[MAX_WIDTH][4];
+ GLshort accumRow[4 * MAX_WIDTH];
+ GLshort *acc;
+
+ if (directAccess) {
+ acc = (GLshort *) accumRb->GetPointer(ctx, accumRb, xpos, ypos +i);
+ }
+ else {
+ accumRb->GetRow(ctx, accumRb, width, xpos, ypos + i, accumRow);
+ acc = accumRow;
+ }
+
+ /* get the colors to return */
+ if (swrast->_IntegerAccumMode) {
+ GLint j;
+ for (j = 0; j < width; j++) {
+ ASSERT(acc[j * 4 + 0] < max);
+ ASSERT(acc[j * 4 + 1] < max);
+ ASSERT(acc[j * 4 + 2] < max);
+ ASSERT(acc[j * 4 + 3] < max);
+ rgba[j][RCOMP] = multTable[acc[j * 4 + 0]];
+ rgba[j][GCOMP] = multTable[acc[j * 4 + 1]];
+ rgba[j][BCOMP] = multTable[acc[j * 4 + 2]];
+ rgba[j][ACOMP] = multTable[acc[j * 4 + 3]];
}
}
- else
-#endif /* USE_OPTIMIZED_ACCUM */
- {
+ else {
/* scaled integer (or float) accum buffer */
- const GLfloat rscale = value / acc_scale * CHAN_MAXF;
- const GLfloat gscale = value / acc_scale * CHAN_MAXF;
- const GLfloat bscale = value / acc_scale * CHAN_MAXF;
- const GLfloat ascale = value / acc_scale * CHAN_MAXF;
- GLint i, j;
- for (j=0;j<height;j++) {
- const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
- for (i=0;i<width;i++) {
- GLint r = IROUND( (GLfloat) (acc[0]) * rscale );
- GLint g = IROUND( (GLfloat) (acc[1]) * gscale );
- GLint b = IROUND( (GLfloat) (acc[2]) * bscale );
- GLint a = IROUND( (GLfloat) (acc[3]) * ascale );
- acc += 4;
- rgba[i][RCOMP] = CLAMP( r, 0, CHAN_MAX );
- rgba[i][GCOMP] = CLAMP( g, 0, CHAN_MAX );
- rgba[i][BCOMP] = CLAMP( b, 0, CHAN_MAX );
- rgba[i][ACOMP] = CLAMP( a, 0, CHAN_MAX );
- }
- if (colorMask != 0xffffffff) {
- _swrast_mask_rgba_array( ctx, width, xpos, ypos, rgba );
- }
- (*swrast->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
- (const GLchan (*)[4])rgba, NULL );
- if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
- && ctx->Color.ColorMask[ACOMP]) {
- _swrast_write_alpha_span(ctx, width, xpos, ypos,
- (CONST GLchan (*)[4]) rgba, NULL);
- }
- ypos++;
+ GLint j;
+ for (j = 0; j < width; j++) {
+ GLint r = IROUND( (GLfloat) (acc[j * 4 + 0]) * scale );
+ GLint g = IROUND( (GLfloat) (acc[j * 4 + 1]) * scale );
+ GLint b = IROUND( (GLfloat) (acc[j * 4 + 2]) * scale );
+ GLint a = IROUND( (GLfloat) (acc[j * 4 + 3]) * scale );
+ rgba[j][RCOMP] = CLAMP( r, 0, CHAN_MAX );
+ rgba[j][GCOMP] = CLAMP( g, 0, CHAN_MAX );
+ rgba[j][BCOMP] = CLAMP( b, 0, CHAN_MAX );
+ rgba[j][ACOMP] = CLAMP( a, 0, CHAN_MAX );
}
+ }
+
+ /* store colors */
+ for (buffer = 0; buffer < fb->_NumColorDrawBuffers[0]; buffer++) {
+ struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[0][buffer];
+ if (masking) {
+ _swrast_mask_rgba_array(ctx, rb, width, xpos, ypos + i, rgba);
+ }
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, rb, width, xpos, ypos + i,
+ (const GLchan (*)[4]) rgba, NULL);
+ else
+#endif
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, rgba, NULL);
+ }
+ }
+ }
+ else {
+ /* other types someday */
+ }
+}
+
+
+
+/**
+ * Software fallback for glAccum.
+ */
+void
+_swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
+ GLint xpos, GLint ypos,
+ GLint width, GLint height )
+
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (SWRAST_CONTEXT(ctx)->NewState)
+ _swrast_validate_derived( ctx );
+
+ if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) {
+ _mesa_warning(ctx, "Calling glAccum() without an accumulation buffer");
+ return;
+ }
+
+ RENDER_START(swrast, ctx);
+
+ switch (op) {
+ case GL_ADD:
+ if (value != 0.0F) {
+ accum_add(ctx, value, xpos, ypos, width, height);
}
- RENDER_FINISH(swrast,ctx);
break;
-
+ case GL_MULT:
+ if (value != 1.0F) {
+ accum_mult(ctx, value, xpos, ypos, width, height);
+ }
+ break;
+ case GL_ACCUM:
+ if (value != 0.0F) {
+ accum_accum(ctx, value, xpos, ypos, width, height);
+ }
+ break;
+ case GL_LOAD:
+ accum_load(ctx, value, xpos, ypos, width, height);
+ break;
+ case GL_RETURN:
+ accum_return(ctx, value, xpos, ypos, width, height);
+ break;
default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glAccum" );
+ _mesa_problem(ctx, "invalid mode in _swrast_Accum()");
+ break;
}
+
+ RENDER_FINISH(swrast, ctx);
}
diff --git a/src/mesa/swrast/s_accum.h b/src/mesa/swrast/s_accum.h
index ac84fdec95..97d2bef4c3 100644
--- a/src/mesa/swrast/s_accum.h
+++ b/src/mesa/swrast/s_accum.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.0.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"),
@@ -28,15 +28,10 @@
#include "mtypes.h"
-#include "swrast.h"
extern void
-_swrast_alloc_accum_buffer( GLframebuffer *buffer );
-
-
-extern void
-_swrast_clear_accum_buffer( GLcontext *ctx );
+_swrast_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb);
#endif
diff --git a/src/mesa/swrast/s_alphabuf.c b/src/mesa/swrast/s_alphabuf.c
deleted file mode 100644
index 5d8107c2d6..0000000000
--- a/src/mesa/swrast/s_alphabuf.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 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.
- */
-
-
-/*
- * Software alpha planes. Many frame buffers don't have alpha bits so
- * we simulate them in software.
- */
-
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "imports.h"
-
-#include "s_context.h"
-#include "s_alphabuf.h"
-
-
-/*
- * Allocate a new front and back alpha buffer.
- */
-void
-_swrast_alloc_alpha_buffers( GLframebuffer *buffer )
-{
- const GLint bytes = buffer->Width * buffer->Height * sizeof(GLchan);
-
- ASSERT(buffer->UseSoftwareAlphaBuffers);
-
- if (buffer->FrontLeftAlpha) {
- MESA_PBUFFER_FREE( buffer->FrontLeftAlpha );
- }
- buffer->FrontLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
- if (!buffer->FrontLeftAlpha) {
- /* out of memory */
- _mesa_error( NULL, GL_OUT_OF_MEMORY,
- "Couldn't allocate front-left alpha buffer" );
- }
-
- if (buffer->Visual.doubleBufferMode) {
- if (buffer->BackLeftAlpha) {
- MESA_PBUFFER_FREE( buffer->BackLeftAlpha );
- }
- buffer->BackLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
- if (!buffer->BackLeftAlpha) {
- /* out of memory */
- _mesa_error( NULL, GL_OUT_OF_MEMORY,
- "Couldn't allocate back-left alpha buffer" );
- }
- }
-
- if (buffer->Visual.stereoMode) {
- if (buffer->FrontRightAlpha) {
- MESA_PBUFFER_FREE( buffer->FrontRightAlpha );
- }
- buffer->FrontRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
- if (!buffer->FrontRightAlpha) {
- /* out of memory */
- _mesa_error( NULL, GL_OUT_OF_MEMORY,
- "Couldn't allocate front-right alpha buffer" );
- }
-
- if (buffer->Visual.doubleBufferMode) {
- if (buffer->BackRightAlpha) {
- MESA_PBUFFER_FREE( buffer->BackRightAlpha );
- }
- buffer->BackRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
- if (!buffer->BackRightAlpha) {
- /* out of memory */
- _mesa_error( NULL, GL_OUT_OF_MEMORY,
- "Couldn't allocate back-right alpha buffer" );
- }
- }
- }
-}
-
-
-/*
- * Clear all the alpha buffers
- */
-void
-_swrast_clear_alpha_buffers( GLcontext *ctx )
-{
- GLchan aclear;
- GLuint bufferBit;
-
- CLAMPED_FLOAT_TO_CHAN(aclear, ctx->Color.ClearColor[3]);
-
- ASSERT(ctx->DrawBuffer->UseSoftwareAlphaBuffers);
- ASSERT(ctx->Color.ColorMask[ACOMP]);
-
- /* loop over four possible alpha buffers */
- for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) {
- if (bufferBit & ctx->Color._DrawDestMask[0]) {
- GLchan *buffer;
- if (bufferBit == DD_FRONT_LEFT_BIT) {
- buffer = ctx->DrawBuffer->FrontLeftAlpha;
- }
- else if (bufferBit == DD_FRONT_RIGHT_BIT) {
- buffer = ctx->DrawBuffer->FrontRightAlpha;
- }
- else if (bufferBit == DD_BACK_LEFT_BIT) {
- buffer = ctx->DrawBuffer->BackLeftAlpha;
- }
- else {
- buffer = ctx->DrawBuffer->BackRightAlpha;
- }
-
- if (ctx->Scissor.Enabled) {
- /* clear scissor region */
- GLint j;
- GLint rowLen = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
- GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
- GLint width = ctx->DrawBuffer->Width;
- GLchan *aptr = buffer
- + ctx->DrawBuffer->_Ymin * ctx->DrawBuffer->Width
- + ctx->DrawBuffer->_Xmin;
- for (j = 0; j < rows; j++) {
-#if CHAN_BITS == 8
- MEMSET( aptr, aclear, rowLen );
-#elif CHAN_BITS == 16
- MEMSET16( aptr, aclear, rowLen );
-#else
- GLint i;
- for (i = 0; i < rowLen; i++) {
- aptr[i] = aclear;
- }
-#endif
- aptr += width;
- }
- }
- else {
- /* clear whole buffer */
- GLuint pixels = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
-#if CHAN_BITS == 8
- MEMSET(buffer, aclear, pixels);
-#elif CHAN_BITS == 16
- MEMSET16(buffer, aclear, pixels);
-#else
- GLuint i;
- for (i = 0; i < pixels; i++) {
- buffer[i] = aclear;
- }
-#endif
- }
- }
- }
-}
-
-
-
-static INLINE
-GLchan *get_alpha_buffer( GLcontext *ctx )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- switch (swrast->CurrentBufferBit) {
- case DD_FRONT_LEFT_BIT:
- return ctx->DrawBuffer->FrontLeftAlpha;
- case DD_BACK_LEFT_BIT:
- return ctx->DrawBuffer->BackLeftAlpha;
- case DD_FRONT_RIGHT_BIT:
- return ctx->DrawBuffer->FrontRightAlpha;
- case DD_BACK_RIGHT_BIT:
- return ctx->DrawBuffer->BackRightAlpha;
- default:
- _mesa_problem(ctx, "Bad CurrentBuffer in get_alpha_buffer()");
- return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
- }
-}
-
-
-void
-_swrast_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
- CONST GLchan rgba[][4], const GLubyte mask[] )
-{
- GLchan *buffer, *aptr;
- GLuint i;
-
- buffer = get_alpha_buffer(ctx);
- aptr = buffer + y * ctx->DrawBuffer->Width + x;
-
- if (mask) {
- for (i=0;i<n;i++) {
- if (mask[i]) {
- *aptr = rgba[i][ACOMP];
- }
- aptr++;
- }
- }
- else {
- for (i=0;i<n;i++) {
- *aptr++ = rgba[i][ACOMP];
- }
- }
-}
-
-
-void
-_swrast_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLchan alpha, const GLubyte mask[] )
-{
- GLchan *buffer, *aptr;
- GLuint i;
-
- buffer = get_alpha_buffer(ctx);
- aptr = buffer + y * ctx->DrawBuffer->Width + x;
-
- if (mask) {
- for (i=0;i<n;i++) {
- if (mask[i]) {
- *aptr = alpha;
- }
- aptr++;
- }
- }
- else {
- for (i=0;i<n;i++) {
- *aptr++ = alpha;
- }
- }
-}
-
-
-void
-_swrast_write_alpha_pixels( GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLchan rgba[][4], const GLubyte mask[] )
-{
- GLchan *buffer;
- GLuint i;
-
- buffer = get_alpha_buffer(ctx);
-
- if (mask) {
- for (i=0;i<n;i++) {
- if (mask[i]) {
- GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
- *aptr = rgba[i][ACOMP];
- }
- }
- }
- else {
- for (i=0;i<n;i++) {
- GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
- *aptr = rgba[i][ACOMP];
- }
- }
-}
-
-
-void
-_swrast_write_mono_alpha_pixels( GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLchan alpha, const GLubyte mask[] )
-{
- GLchan *buffer;
- GLuint i;
-
- buffer = get_alpha_buffer(ctx);
-
- if (mask) {
- for (i=0;i<n;i++) {
- if (mask[i]) {
- GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
- *aptr = alpha;
- }
- }
- }
- else {
- for (i=0;i<n;i++) {
- GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
- *aptr = alpha;
- }
- }
-}
-
-
-
-void
-_swrast_read_alpha_span( GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLchan rgba[][4] )
-{
- const GLchan *buffer, *aptr;
- GLuint i;
-
- buffer = get_alpha_buffer(ctx);
- aptr = buffer + y * ctx->DrawBuffer->Width + x;
-
- for (i = 0; i < n; i++)
- rgba[i][ACOMP] = *aptr++;
-}
-
-
-void
-_swrast_read_alpha_pixels( GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLchan rgba[][4], const GLubyte mask[] )
-{
- const GLchan *buffer;
- GLuint i;
-
- buffer = get_alpha_buffer(ctx);
-
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- const GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
- rgba[i][ACOMP] = *aptr;
- }
- }
-}
diff --git a/src/mesa/swrast/s_alphabuf.h b/src/mesa/swrast/s_alphabuf.h
deleted file mode 100644
index f09bb91adb..0000000000
--- a/src/mesa/swrast/s_alphabuf.h
+++ /dev/null
@@ -1,80 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 4.0.2
- *
- * Copyright (C) 1999-2002 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.
- */
-
-
-#ifndef S_ALPHABUF_H
-#define S_ALPHABUF_H
-
-
-#include "mtypes.h"
-#include "swrast.h"
-
-
-extern void
-_swrast_alloc_alpha_buffers( GLframebuffer *buffer );
-
-
-extern void
-_swrast_clear_alpha_buffers( GLcontext *ctx );
-
-
-extern void
-_swrast_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
- CONST GLchan rgba[][4], const GLubyte mask[] );
-
-
-extern void
-_swrast_write_mono_alpha_span( GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- GLchan alpha, const GLubyte mask[] );
-
-
-
-extern void
-_swrast_write_alpha_pixels( GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- CONST GLchan rgba[][4],
- const GLubyte mask[] );
-
-
-extern void
-_swrast_write_mono_alpha_pixels( GLcontext* ctx,
- GLuint n, const GLint x[],
- const GLint y[], GLchan alpha,
- const GLubyte mask[] );
-
-
-extern void
-_swrast_read_alpha_span( GLcontext* ctx,
- GLuint n, GLint x, GLint y, GLchan rgba[][4] );
-
-
-extern void
-_swrast_read_alpha_pixels( GLcontext* ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLchan rgba[][4], const GLubyte mask[] );
-
-
-#endif
diff --git a/src/mesa/swrast/s_auxbuffer.c b/src/mesa/swrast/s_auxbuffer.c
deleted file mode 100644
index b2224c8884..0000000000
--- a/src/mesa/swrast/s_auxbuffer.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 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 "glheader.h"
-#include "imports.h"
-
-#include "s_auxbuffer.h"
-#include "s_context.h"
-
-
-
-/**
- * Allocate memory for the software auxillary buffers associated with
- * the given GLframebuffer. Free any currently allocated aux buffers
- * first.
- */
-void
-_swrast_alloc_aux_buffers( GLframebuffer *buffer )
-{
- GLint i;
-
- ASSERT(buffer->UseSoftwareAuxBuffers);
-
- for (i = 0; i < buffer->Visual.numAuxBuffers; i++) {
- if (buffer->AuxBuffers[i]) {
- _mesa_free(buffer->AuxBuffers[i]);
- buffer->AuxBuffers[i] = NULL;
- }
-
- buffer->AuxBuffers[i] = (GLchan *) _mesa_malloc(buffer->Width
- * buffer->Height * 4 * sizeof(GLchan));
- }
-}
-
-
-
-/* RGBA */
-#define NAME(PREFIX) PREFIX##_aux
-#define SPAN_VARS \
- const SWcontext *swrast = SWRAST_CONTEXT(ctx);
-#define INIT_PIXEL_PTR(P, X, Y) \
- GLchan *P = swrast->CurAuxBuffer + ((Y) * ctx->DrawBuffer->Width + (X)) * 4; \
- assert(swrast->CurAuxBuffer);
-
-#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)
-#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
-#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"
-
-
-
-/**
- * Called from driver's SetBuffer() function to choose an aux buffer.
- */
-void
-_swrast_use_aux_buffer(GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit)
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- (void) buffer;
-
- switch (bufferBit) {
- case DD_AUX0_BIT:
- ASSERT(buffer->Visual.numAuxBuffers >= 1);
- swrast->CurAuxBuffer = ctx->DrawBuffer->AuxBuffers[0];
- break;
- case DD_AUX1_BIT:
- ASSERT(buffer->Visual.numAuxBuffers >= 2);
- swrast->CurAuxBuffer = ctx->DrawBuffer->AuxBuffers[1];
- break;
- case DD_AUX2_BIT:
- ASSERT(buffer->Visual.numAuxBuffers >= 3);
- swrast->CurAuxBuffer = ctx->DrawBuffer->AuxBuffers[2];
- break;
- case DD_AUX3_BIT:
- ASSERT(buffer->Visual.numAuxBuffers >= 4);
- swrast->CurAuxBuffer = ctx->DrawBuffer->AuxBuffers[3];
- break;
- default:
- swrast->CurAuxBuffer = NULL;
- }
-
- swrast->Driver.WriteRGBASpan = write_rgba_span_aux;
- swrast->Driver.WriteRGBSpan = write_rgb_span_aux;
- swrast->Driver.WriteMonoRGBASpan = write_monorgba_span_aux;
- swrast->Driver.WriteRGBAPixels = write_rgba_pixels_aux;
- swrast->Driver.WriteMonoRGBAPixels = write_monorgba_pixels_aux;
- swrast->Driver.ReadRGBASpan = read_rgba_span_aux;
- swrast->Driver.ReadRGBAPixels = read_rgba_pixels_aux;
-}
-
diff --git a/src/mesa/swrast/s_auxbuffer.h b/src/mesa/swrast/s_auxbuffer.h
deleted file mode 100644
index 48fb6951a1..0000000000
--- a/src/mesa/swrast/s_auxbuffer.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 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.
- */
-
-
-#ifndef S_AUXBUFFER_H
-#define S_AUXBUFFER_H
-
-
-#include "context.h"
-
-
-extern void
-_swrast_alloc_aux_buffers( GLframebuffer *buffer );
-
-
-extern void
-_swrast_use_aux_buffer(GLcontext *ctx, GLframebuffer *buffr, GLuint bufferBit);
-
-
-#endif /* S_AUXBUFFER_H */
diff --git a/src/mesa/swrast/s_blend.c b/src/mesa/swrast/s_blend.c
index 1001d6f212..f15c95710d 100644
--- a/src/mesa/swrast/s_blend.c
+++ b/src/mesa/swrast/s_blend.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.0
+ * 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"),
@@ -37,7 +37,6 @@
#include "colormac.h"
#include "macros.h"
-#include "s_alphabuf.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_span.h"
@@ -847,8 +846,8 @@ void _swrast_choose_blend_func( GLcontext *ctx )
* pixel coordinates.
*/
void
-_swrast_blend_span( GLcontext *ctx, const struct sw_span *span,
- GLchan rgba[][4] )
+_swrast_blend_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4])
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan framebuffer[MAX_WIDTH][4];
@@ -860,19 +859,20 @@ _swrast_blend_span( GLcontext *ctx, const struct sw_span *span,
/* Read span of current frame buffer pixels */
if (span->arrayMask & SPAN_XY) {
/* array of x/y pixel coords */
- (*swrast->Driver.ReadRGBAPixels)( ctx, span->end,
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.ReadRGBAPixels)
+ (*swrast->Driver.ReadRGBAPixels)( ctx, rb, span->end,
span->array->x, span->array->y,
framebuffer, span->array->mask );
- if (swrast->_RasterMask & ALPHABUF_BIT) {
- _swrast_read_alpha_pixels( ctx, span->end,
- span->array->x, span->array->y,
- framebuffer, span->array->mask );
- }
+ else
+#endif
+ rb->GetValues(ctx, rb, span->end, span->array->x, span->array->y,
+ framebuffer);
}
else {
/* horizontal run of pixels */
- _swrast_read_rgba_span( ctx, ctx->DrawBuffer, span->end,
- span->x, span->y, framebuffer );
+ _swrast_read_rgba_span(ctx, rb, span->end, span->x, span->y,
+ framebuffer);
}
SWRAST_CONTEXT(ctx)->BlendFunc( ctx, span->end, span->array->mask, rgba,
diff --git a/src/mesa/swrast/s_blend.h b/src/mesa/swrast/s_blend.h
index 11bf378e31..c951932152 100644
--- a/src/mesa/swrast/s_blend.h
+++ b/src/mesa/swrast/s_blend.h
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2002 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"),
@@ -32,14 +31,13 @@
#include "s_context.h"
-
extern void
-_swrast_blend_span( GLcontext *ctx, const struct sw_span *span,
- GLchan rgba[][4] );
+_swrast_blend_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4]);
extern void
-_swrast_choose_blend_func( GLcontext *ctx );
+_swrast_choose_blend_func(GLcontext *ctx);
#endif
diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c
index d05c8dfbf9..cf469f8c62 100644
--- a/src/mesa/swrast/s_buffers.c
+++ b/src/mesa/swrast/s_buffers.c
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* 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"),
@@ -27,10 +27,10 @@
#include "colormac.h"
#include "macros.h"
#include "imports.h"
+#include "mtypes.h"
+#include "fbobject.h"
#include "s_accum.h"
-#include "s_alphabuf.h"
-#include "s_auxbuffer.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_masking.h"
@@ -38,98 +38,190 @@
/**
- * Clear the color buffer when glColorMask or glIndexMask is in effect.
- * We'll have specified which color buffer to clear by previously
- * calling Driver.SetBuffer().
+ * Clear the color buffer when glColorMask is in effect.
*/
static void
-clear_color_buffer_with_masking( GLcontext *ctx )
+clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLint x = ctx->DrawBuffer->_Xmin;
const GLint y = ctx->DrawBuffer->_Ymin;
const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ GLchan clearColor[4];
+ GLint i;
- if (ctx->Visual.rgbMode) {
- /* RGBA mode */
- GLchan clearColor[4];
- GLint i;
- CLAMPED_FLOAT_TO_CHAN(clearColor[RCOMP], ctx->Color.ClearColor[0]);
- CLAMPED_FLOAT_TO_CHAN(clearColor[GCOMP], ctx->Color.ClearColor[1]);
- CLAMPED_FLOAT_TO_CHAN(clearColor[BCOMP], ctx->Color.ClearColor[2]);
- CLAMPED_FLOAT_TO_CHAN(clearColor[ACOMP], ctx->Color.ClearColor[3]);
- for (i = 0; i < height; i++) {
- GLchan rgba[MAX_WIDTH][4];
- GLint j;
- for (j = 0; j < width; j++) {
- COPY_CHAN4(rgba[j], clearColor);
- }
- _swrast_mask_rgba_array( ctx, width, x, y + i, rgba );
- (*swrast->Driver.WriteRGBASpan)( ctx, width, x, y + i,
- (CONST GLchan (*)[4]) rgba, NULL );
+ ASSERT(ctx->Visual.rgbMode);
+
+ CLAMPED_FLOAT_TO_CHAN(clearColor[RCOMP], ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[GCOMP], ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[BCOMP], ctx->Color.ClearColor[2]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[ACOMP], ctx->Color.ClearColor[3]);
+
+ for (i = 0; i < height; i++) {
+ GLchan rgba[MAX_WIDTH][4];
+ GLint j;
+ for (j = 0; j < width; j++) {
+ COPY_CHAN4(rgba[j], clearColor);
}
+ _swrast_mask_rgba_array( ctx, rb, width, x, y + i, rgba );
+#if NEW_RENDERBUFFER
+ if (rb->PutRow) {
+ rb->PutRow(ctx, rb, width, x, y + i, rgba, NULL);
+ }
+#endif
+#if OLD_RENDERBUFFER
+ else {
+ swrast->Driver.WriteRGBASpan(ctx, rb, width, x, y + i,
+ (CONST GLchan (*)[4]) rgba, NULL);
+ }
+#endif
}
- else {
- /* Color index mode */
- GLuint span[MAX_WIDTH];
- GLubyte mask[MAX_WIDTH];
- GLint i, j;
- MEMSET( mask, 1, width );
- for (i=0;i<height;i++) {
- for (j=0;j<width;j++) {
- span[j] = ctx->Color.ClearIndex;
- }
- _swrast_mask_index_array( ctx, width, x, y + i, span );
- (*swrast->Driver.WriteCI32Span)( ctx, width, x, y + i, span, mask );
+}
+
+
+/**
+ * Clear color index buffer with masking.
+ */
+static void
+clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
+{
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ GLuint span[MAX_WIDTH];
+ GLubyte mask[MAX_WIDTH];
+ GLint i, j;
+
+ ASSERT(!ctx->Visual.rgbMode);
+
+ MEMSET( mask, 1, width );
+ for (i = 0; i < height;i++) {
+ for (j = 0; j < width;j++) {
+ span[j] = ctx->Color.ClearIndex;
}
+ _swrast_mask_ci_array(ctx, rb, width, x, y + i, span);
+ ASSERT(rb->PutRow);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->PutRow(ctx, rb, width, x, y + i, span, mask);
}
}
/**
- * Clear a color buffer without index/channel masking.
- * We'll have specified which color buffer to clear by previously
- * calling Driver.SetBuffer().
+ * Clear an rgba color buffer without channel masking.
*/
static void
-clear_color_buffer(GLcontext *ctx)
+clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLint x = ctx->DrawBuffer->_Xmin;
const GLint y = ctx->DrawBuffer->_Ymin;
const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
-
- if (ctx->Visual.rgbMode) {
- /* RGBA mode */
+ GLint i;
+
+ ASSERT(ctx->Visual.rgbMode);
+
+ ASSERT(ctx->Color.ColorMask[0] &&
+ ctx->Color.ColorMask[1] &&
+ ctx->Color.ColorMask[2] &&
+ ctx->Color.ColorMask[3]);
+
+#if NEW_RENDERBUFFER
+ if (rb->PutMonoRow) { /* XXX assert this */
+ GLubyte clear8[4];
+ GLushort clear16[4];
+ GLvoid *clearVal;
+ switch (rb->DataType) {
+ case GL_UNSIGNED_BYTE:
+ clear8[0] = FLOAT_TO_UBYTE(ctx->Color.ClearColor[0]);
+ clear8[1] = FLOAT_TO_UBYTE(ctx->Color.ClearColor[1]);
+ clear8[2] = FLOAT_TO_UBYTE(ctx->Color.ClearColor[2]);
+ clear8[3] = FLOAT_TO_UBYTE(ctx->Color.ClearColor[3]);
+ clearVal = clear8;
+ break;
+ case GL_UNSIGNED_SHORT:
+ clear16[0] = FLOAT_TO_USHORT(ctx->Color.ClearColor[0]);
+ clear16[1] = FLOAT_TO_USHORT(ctx->Color.ClearColor[1]);
+ clear16[2] = FLOAT_TO_USHORT(ctx->Color.ClearColor[2]);
+ clear16[3] = FLOAT_TO_USHORT(ctx->Color.ClearColor[3]);
+ clearVal = clear16;
+ break;
+ case GL_FLOAT:
+ clearVal = ctx->Color.ClearColor;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad rb DataType in clear_color_buffer");
+ return;
+ }
+ for (i = 0; i < height; i++) {
+ rb->PutMonoRow(ctx, rb, width, x, y + i, clearVal, NULL);
+ }
+ }
+#endif
+#if OLD_RENDERBUFFER
+ else {
GLchan clearColor[4];
- GLint i;
-
CLAMPED_FLOAT_TO_CHAN(clearColor[RCOMP], ctx->Color.ClearColor[0]);
CLAMPED_FLOAT_TO_CHAN(clearColor[GCOMP], ctx->Color.ClearColor[1]);
CLAMPED_FLOAT_TO_CHAN(clearColor[BCOMP], ctx->Color.ClearColor[2]);
CLAMPED_FLOAT_TO_CHAN(clearColor[ACOMP], ctx->Color.ClearColor[3]);
-
- ASSERT(*((GLuint *) &ctx->Color.ColorMask) == 0xffffffff);
ASSERT(swrast->Driver.WriteRGBASpan);
-
for (i = 0; i < height; i++) {
- (*swrast->Driver.WriteMonoRGBASpan)( ctx, width, x, y + i,
- clearColor, NULL );
+ swrast->Driver.WriteMonoRGBASpan(ctx, rb, width, x, y + i,
+ clearColor, NULL );
}
}
- else {
- /* Color index mode */
+#endif
+}
+
+
+/**
+ * Clear color index buffer without masking.
+ */
+static void
+clear_ci_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
+{
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+
+ ASSERT(!ctx->Visual.rgbMode);
+
+ ASSERT((ctx->Color.IndexMask & ((1 << ctx->Visual.indexBits) - 1))
+ == (GLuint) ((1 << ctx->Visual.indexBits) - 1));
+
+#if NEW_RENDERBUFFER
+ if (rb->PutMonoRow) { /* XXX assert this */
+ GLubyte clear8;
+ GLushort clear16;
+ GLuint clear32;
+ GLvoid *clearVal;
GLint i;
- ASSERT((ctx->Color.IndexMask & ((1 << ctx->Visual.indexBits) - 1))
- == (GLuint) ((1 << ctx->Visual.indexBits) - 1));
- ASSERT(swrast->Driver.WriteMonoCISpan);
- for (i = 0; i < height; i++) {
- (*swrast->Driver.WriteMonoCISpan)( ctx, width, x, y + i,
- ctx->Color.ClearIndex, NULL);
+ switch (rb->DataType) {
+ case GL_UNSIGNED_BYTE:
+ clear8 = (GLubyte) ctx->Color.ClearIndex;
+ clearVal = &clear8;
+ break;
+ case GL_UNSIGNED_SHORT:
+ clear16 = (GLushort) ctx->Color.ClearIndex;
+ clearVal = &clear16;
+ break;
+ case GL_UNSIGNED_INT:
+ clear32 = ctx->Color.ClearIndex;
+ clearVal = &clear32;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad rb DataType in clear_color_buffer");
+ return;
}
+ for (i = 0; i < height; i++)
+ rb->PutMonoRow(ctx, rb, width, x, y + i, clearVal, NULL);
}
+#endif
}
@@ -141,20 +233,46 @@ clear_color_buffer(GLcontext *ctx)
static void
clear_color_buffers(GLcontext *ctx)
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
- GLuint bufferBit;
+ GLboolean masking;
+ GLuint i;
- /* loop over four possible dest color buffers */
- for (bufferBit = 1; bufferBit <= DD_AUX3_BIT; bufferBit <<= 1) {
- if (bufferBit & ctx->Color._DrawDestMask[0]) {
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, bufferBit);
+ if (ctx->Visual.rgbMode) {
+ if (ctx->Color.ColorMask[0] &&
+ ctx->Color.ColorMask[1] &&
+ ctx->Color.ColorMask[2] &&
+ ctx->Color.ColorMask[3]) {
+ masking = GL_FALSE;
+ }
+ else {
+ masking = GL_TRUE;
+ }
+ }
+ else {
+ const GLuint indexBits = (1 << ctx->Visual.indexBits) - 1;
+ if ((ctx->Color.IndexMask & indexBits) == indexBits) {
+ masking = GL_FALSE;
+ }
+ else {
+ masking = GL_TRUE;
+ }
+ }
- if (colorMask != 0xffffffff) {
- clear_color_buffer_with_masking(ctx);
+ for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers[0]; i++) {
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][i];
+ if (ctx->Visual.rgbMode) {
+ if (masking) {
+ clear_rgba_buffer_with_masking(ctx, rb);
}
else {
- clear_color_buffer(ctx);
+ clear_rgba_buffer(ctx, rb);
+ }
+ }
+ else {
+ if (masking) {
+ clear_ci_buffer_with_masking(ctx, rb);
+ }
+ else {
+ clear_ci_buffer(ctx, rb);
}
}
}
@@ -171,26 +289,27 @@ clear_color_buffers(GLcontext *ctx)
* \param all if GL_TRUE, clear whole buffer, else clear specified region.
*/
void
-_swrast_Clear( GLcontext *ctx, GLbitfield mask,
- GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+_swrast_Clear(GLcontext *ctx, GLbitfield mask,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
(void) all; (void) x; (void) y; (void) width; (void) height;
-#ifdef DEBUG
+
+#ifdef DEBUG_FOO
{
const GLbitfield legalBits =
- DD_FRONT_LEFT_BIT |
- DD_FRONT_RIGHT_BIT |
- DD_BACK_LEFT_BIT |
- DD_BACK_RIGHT_BIT |
- DD_DEPTH_BIT |
- DD_STENCIL_BIT |
- DD_ACCUM_BIT |
- DD_AUX0_BIT |
- DD_AUX1_BIT |
- DD_AUX2_BIT |
- DD_AUX3_BIT;
+ BUFFER_BIT_FRONT_LEFT |
+ BUFFER_BIT_FRONT_RIGHT |
+ BUFFER_BIT_BACK_LEFT |
+ BUFFER_BIT_BACK_RIGHT |
+ BUFFER_BIT_DEPTH |
+ BUFFER_BIT_STENCIL |
+ BUFFER_BIT_ACCUM |
+ BUFFER_BIT_AUX0 |
+ BUFFER_BIT_AUX1 |
+ BUFFER_BIT_AUX2 |
+ BUFFER_BIT_AUX3;
assert((mask & (~legalBits)) == 0);
}
#endif
@@ -199,22 +318,30 @@ _swrast_Clear( GLcontext *ctx, GLbitfield mask,
/* do software clearing here */
if (mask) {
- if (mask & ctx->Color._DrawDestMask[0]) {
+ if (mask & ctx->DrawBuffer->_ColorDrawBufferMask[0]) {
clear_color_buffers(ctx);
/* clear software-based alpha buffer(s) */
+#if OLD_RENDERBUFFER && 0
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
&& ctx->Color.ColorMask[ACOMP]) {
_swrast_clear_alpha_buffers( ctx );
}
+#endif
}
- if (mask & DD_DEPTH_BIT) {
- _swrast_clear_depth_buffer(ctx);
+ if (mask & BUFFER_BIT_DEPTH) {
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ _swrast_clear_depth_buffer(ctx, rb);
}
- if (mask & DD_ACCUM_BIT) {
- _swrast_clear_accum_buffer(ctx);
+ if (mask & BUFFER_BIT_ACCUM) {
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ _swrast_clear_accum_buffer(ctx, rb);
}
- if (mask & DD_STENCIL_BIT) {
- _swrast_clear_stencil_buffer(ctx);
+ if (mask & BUFFER_BIT_STENCIL) {
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ _swrast_clear_stencil_buffer(ctx, rb);
}
}
@@ -222,33 +349,6 @@ _swrast_Clear( GLcontext *ctx, GLbitfield mask,
}
-/**
- * Typically called via ctx->Driver.ResizeBuffers().
- * Reallocate all software-based depth/stencil/accum/etc buffers
- * to match current window dimensions.
- */
-void
-_swrast_alloc_buffers( GLframebuffer *buffer )
-{
- /* Reallocate other buffers if needed. */
- if (buffer->UseSoftwareDepthBuffer) {
- _swrast_alloc_depth_buffer( buffer );
- }
- if (buffer->UseSoftwareStencilBuffer) {
- _swrast_alloc_stencil_buffer( buffer );
- }
- if (buffer->UseSoftwareAccumBuffer) {
- _swrast_alloc_accum_buffer( buffer );
- }
- if (buffer->UseSoftwareAlphaBuffers) {
- _swrast_alloc_alpha_buffers( buffer );
- }
- if (buffer->UseSoftwareAuxBuffers) {
- _swrast_alloc_aux_buffers( buffer );
- }
-}
-
-
/*
* Fallback for ctx->Driver.DrawBuffer()
*/
@@ -281,7 +381,7 @@ _swrast_use_read_buffer( GLcontext *ctx )
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* Do this so the software-emulated alpha plane span functions work! */
- swrast->CurrentBufferBit = ctx->Pixel._ReadSrcMask;
+ swrast->CurrentBufferBit = ctx->ReadBuffer->_ColorReadBufferMask;
/* Tell the device driver where to read/write spans */
swrast->Driver.SetBuffer(ctx, ctx->ReadBuffer, swrast->CurrentBufferBit);
}
@@ -307,25 +407,25 @@ _swrast_use_draw_buffer( GLcontext *ctx )
* we loop over multiple color buffers when needed.
*/
- if (ctx->Color._DrawDestMask[0] & DD_FRONT_LEFT_BIT)
- swrast->CurrentBufferBit = DD_FRONT_LEFT_BIT;
- else if (ctx->Color._DrawDestMask[0] & DD_BACK_LEFT_BIT)
- swrast->CurrentBufferBit = DD_BACK_LEFT_BIT;
- else if (ctx->Color._DrawDestMask[0] & DD_FRONT_RIGHT_BIT)
- swrast->CurrentBufferBit = DD_FRONT_RIGHT_BIT;
- else if (ctx->Color._DrawDestMask[0] & DD_BACK_RIGHT_BIT)
- swrast->CurrentBufferBit = DD_BACK_RIGHT_BIT;
- else if (ctx->Color._DrawDestMask[0] & DD_AUX0_BIT)
- swrast->CurrentBufferBit = DD_AUX0_BIT;
- else if (ctx->Color._DrawDestMask[0] & DD_AUX1_BIT)
- swrast->CurrentBufferBit = DD_AUX1_BIT;
- else if (ctx->Color._DrawDestMask[0] & DD_AUX2_BIT)
- swrast->CurrentBufferBit = DD_AUX2_BIT;
- else if (ctx->Color._DrawDestMask[0] & DD_AUX3_BIT)
- swrast->CurrentBufferBit = DD_AUX3_BIT;
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT)
+ swrast->CurrentBufferBit = BUFFER_BIT_FRONT_LEFT;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_BACK_LEFT)
+ swrast->CurrentBufferBit = BUFFER_BIT_BACK_LEFT;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_RIGHT)
+ swrast->CurrentBufferBit = BUFFER_BIT_FRONT_RIGHT;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_BACK_RIGHT)
+ swrast->CurrentBufferBit = BUFFER_BIT_BACK_RIGHT;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_AUX0)
+ swrast->CurrentBufferBit = BUFFER_BIT_AUX0;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_AUX1)
+ swrast->CurrentBufferBit = BUFFER_BIT_AUX1;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_AUX2)
+ swrast->CurrentBufferBit = BUFFER_BIT_AUX2;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_AUX3)
+ swrast->CurrentBufferBit = BUFFER_BIT_AUX3;
else
/* glDrawBuffer(GL_NONE) */
- swrast->CurrentBufferBit = DD_FRONT_LEFT_BIT; /* we always have this buffer */
+ swrast->CurrentBufferBit = BUFFER_BIT_FRONT_LEFT; /* we always have this buffer */
swrast->Driver.SetBuffer(ctx, ctx->DrawBuffer, swrast->CurrentBufferBit);
}
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index f6dcdbb964..00c4ae4bc9 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -73,11 +73,6 @@ _swrast_update_rasterflags( GLcontext *ctx )
if (ctx->Color.IndexLogicOpEnabled) rasterMask |= LOGIC_OP_BIT;
}
- if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
- && ctx->Color.ColorMask[ACOMP]
- && ctx->Color.DrawBuffer != GL_NONE)
- rasterMask |= ALPHABUF_BIT;
-
if ( ctx->Viewport.X < 0
|| ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width
|| ctx->Viewport.Y < 0
@@ -93,7 +88,9 @@ _swrast_update_rasterflags( GLcontext *ctx )
* MULTI_DRAW_BIT flag. Also set it if we're drawing to no
* buffers or the RGBA or CI mask disables all writes.
*/
- if (_mesa_bitcount(ctx->Color._DrawDestMask[0]) != 1) {
+#if NEW_RENDERBUFFER
+ if (ctx->DrawBuffer->_NumColorDrawBuffers[0] != 1) {
+#endif
/* more than one color buffer designated for writing (or zero buffers) */
rasterMask |= MULTI_DRAW_BIT;
}
@@ -446,26 +443,6 @@ _swrast_invalidate_state( GLcontext *ctx, GLuint new_state )
if (new_state & _SWRAST_NEW_TEXTURE_SAMPLE_FUNC)
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
swrast->TextureSample[i] = _swrast_validate_texture_sample;
-
- /* Debug checks */
- if (ctx->Visual.rgbMode) {
- ASSERT(swrast->Driver.WriteRGBASpan);
- ASSERT(swrast->Driver.WriteRGBSpan);
- ASSERT(swrast->Driver.WriteMonoRGBASpan);
- ASSERT(swrast->Driver.WriteRGBAPixels);
- ASSERT(swrast->Driver.WriteMonoRGBAPixels);
- ASSERT(swrast->Driver.ReadRGBASpan);
- ASSERT(swrast->Driver.ReadRGBAPixels);
- }
- else {
- ASSERT(swrast->Driver.WriteCI32Span);
- ASSERT(swrast->Driver.WriteCI8Span);
- ASSERT(swrast->Driver.WriteMonoCISpan);
- ASSERT(swrast->Driver.WriteCI32Pixels);
- ASSERT(swrast->Driver.WriteMonoCIPixels);
- ASSERT(swrast->Driver.ReadCI32Span);
- ASSERT(swrast->Driver.ReadCI32Pixels);
- }
}
@@ -625,12 +602,12 @@ _swrast_CreateContext( GLcontext *ctx )
swrast->AllowPixelFog = GL_TRUE;
if (ctx->Visual.doubleBufferMode)
- swrast->CurrentBufferBit = DD_BACK_LEFT_BIT;
+ swrast->CurrentBufferBit = BUFFER_BIT_BACK_LEFT;
else
- swrast->CurrentBufferBit = DD_FRONT_LEFT_BIT;
+ swrast->CurrentBufferBit = BUFFER_FRONT_LEFT;
/* Optimized Accum buffer */
- swrast->_IntegerAccumMode = GL_TRUE;
+ swrast->_IntegerAccumMode = GL_FALSE;
swrast->_IntegerAccumScaler = 0.0;
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 6eac3232b0..5f5efdc22a 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -240,7 +240,6 @@ typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *,
#define CLIP_BIT 0x020 /**< Scissor or window clip pixels */
#define STENCIL_BIT 0x040 /**< Stencil pixels */
#define MASKING_BIT 0x080 /**< Do glColorMask or glIndexMask */
-#define ALPHABUF_BIT 0x100 /**< Using software alpha buffer */
#define MULTI_DRAW_BIT 0x400 /**< Write to more than one color- */
/**< buffer or no buffers. */
#define OCCLUSION_BIT 0x800 /**< GL_HP_occlusion_test enabled */
@@ -294,8 +293,6 @@ typedef struct
GLboolean _IntegerAccumMode; /**< Storing unscaled integers? */
GLfloat _IntegerAccumScaler; /**< Implicit scale factor */
- GLchan *CurAuxBuffer;
-
/* Working values:
*/
GLuint StippleCounter; /**< Line stipple counter */
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index 7454cfd2d2..3d6d91de51 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -131,6 +131,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *drawRb = NULL;
GLboolean quick_draw;
GLint row;
GLboolean changeBuffer;
@@ -152,6 +153,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
&& destx >= 0
&& destx + width <= (GLint) ctx->DrawBuffer->Width) {
quick_draw = GL_TRUE;
+ drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
}
else {
quick_draw = GL_FALSE;
@@ -185,8 +187,8 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
for (row = 0; row < height; row++) {
GLchan rgba[MAX_WIDTH][4];
/* Read GLchan and convert to GLfloat */
- _swrast_read_rgba_span(ctx, ctx->ReadBuffer, width, srcx,
- srcy + row, rgba);
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, srcy + row, rgba);
chan_span_to_float(width, (CONST GLchan (*)[4]) rgba,
(GLfloat (*)[4]) dest);
dest += 4 * width;
@@ -240,8 +242,14 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
dy = desty + row;
if (quick_draw && dy >= 0 && dy < (GLint) ctx->DrawBuffer->Height) {
- (*swrast->Driver.WriteRGBASpan)( ctx, width, destx, dy,
- (const GLchan (*)[4])span.array->rgba, NULL );
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, drawRb, width, destx, dy,
+ (const GLchan (*)[4]) span.array->rgba, NULL);
+ else
+#endif
+ drawRb->PutRow(ctx, drawRb, width, destx, dy,
+ span.array->rgba, NULL);
}
else if (zoom) {
span.x = destx;
@@ -271,6 +279,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *drawRb;
GLchan *tmpImage,*p;
GLboolean quick_draw;
GLint sy, dy, stepy, j;
@@ -280,6 +289,11 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
const GLuint transferOps = ctx->_ImageTransferState;
struct sw_span span;
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
@@ -319,9 +333,11 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
&& destx >= 0
&& destx + width <= (GLint) ctx->DrawBuffer->Width) {
quick_draw = GL_TRUE;
+ drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
}
else {
quick_draw = GL_FALSE;
+ drawRb = NULL;
}
/* If read and draw buffer are different we must do buffer switching */
@@ -341,8 +357,8 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* read the source image */
p = tmpImage;
for (j = 0; j < height; j++, ssy += stepy) {
- _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, ssy,
- (GLchan (*)[4]) p );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, ssy, (GLchan (*)[4]) p );
p += width * 4;
}
p = tmpImage;
@@ -370,8 +386,8 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (changeBuffer)
_swrast_use_read_buffer(ctx);
ASSERT(width < MAX_WIDTH);
- _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, sy,
- span.array->rgba );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, sy, span.array->rgba );
if (changeBuffer)
_swrast_use_draw_buffer(ctx);
}
@@ -397,8 +413,14 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* Write color span */
if (quick_draw && dy >= 0 && dy < (GLint) ctx->DrawBuffer->Height) {
- (*swrast->Driver.WriteRGBASpan)( ctx, width, destx, dy,
- (const GLchan (*)[4])span.array->rgba, NULL );
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, drawRb, width, destx, dy,
+ (const GLchan (*)[4])span.array->rgba, NULL);
+ else
+#endif
+ drawRb->PutRow(ctx, drawRb, width, destx, dy, span.array->rgba, NULL);
+
}
else if (zoom) {
span.x = destx;
@@ -435,6 +457,11 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLint overlapping;
struct sw_span span;
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX);
/* Determine if copy should be bottom-to-top or top-to-bottom */
@@ -481,7 +508,8 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
/* read the image */
p = tmpImage;
for (j = 0; j < height; j++, ssy += stepy) {
- _swrast_read_index_span( ctx, ctx->ReadBuffer, width, srcx, ssy, p );
+ _swrast_read_index_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, ssy, p );
p += width;
}
p = tmpImage;
@@ -505,8 +533,8 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
else {
if (changeBuffer)
_swrast_use_read_buffer(ctx);
- _swrast_read_index_span( ctx, ctx->ReadBuffer, width, srcx, sy,
- span.array->index );
+ _swrast_read_index_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, sy, span.array->index );
if (changeBuffer)
_swrast_use_draw_buffer(ctx);
}
@@ -543,6 +571,9 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height,
GLint destx, GLint desty )
{
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
+ struct gl_renderbuffer *readRb
+ = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
GLfloat *p, *tmpImage;
GLint sy, dy, stepy;
GLint i, j;
@@ -550,6 +581,11 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLint overlapping;
struct sw_span span;
+ if (!readRb) {
+ /* no readbuffer - OK */
+ return;
+ }
+
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z);
if (!ctx->Visual.depthBits) {
@@ -592,7 +628,7 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
}
p = tmpImage;
for (j = 0; j < height; j++, ssy += stepy) {
- _swrast_read_depth_span_float(ctx, width, srcx, ssy, p);
+ _swrast_read_depth_span_float(ctx, readRb, width, srcx, ssy, p);
p += width;
}
p = tmpImage;
@@ -604,20 +640,21 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
for (j = 0; j < height; j++, sy += stepy, dy += stepy) {
GLfloat depth[MAX_WIDTH];
-
+ float sum = 0;
/* get depth values */
if (overlapping) {
MEMCPY(depth, p, width * sizeof(GLfloat));
p += width;
}
else {
- _swrast_read_depth_span_float(ctx, width, srcx, sy, depth);
+ _swrast_read_depth_span_float(ctx, readRb, width, srcx, sy, depth);
}
/* apply scale and bias */
for (i = 0; i < width; i++) {
GLfloat d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
- span.array->z[i] = (GLdepth) (CLAMP(d, 0.0F, 1.0F) * ctx->DepthMax);
+ sum += d;
+ span.array->z[i] = (GLdepth) (CLAMP(d, 0.0F, 1.0F) * depthMax);
}
/* write depth values */
@@ -650,6 +687,8 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height,
GLint destx, GLint desty )
{
+ struct gl_renderbuffer *rb
+ = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
GLint sy, dy, stepy;
GLint j;
GLstencil *p, *tmpImage;
@@ -662,6 +701,11 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
return;
}
+ if (!rb) {
+ /* no readbuffer - OK */
+ return;
+ }
+
/* Determine if copy should be bottom-to-top or top-to-bottom */
if (srcy < desty) {
/* top-down max-to-min */
@@ -693,7 +737,7 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
}
p = tmpImage;
for (j = 0; j < height; j++, ssy += stepy) {
- _swrast_read_stencil_span( ctx, width, srcx, ssy, p );
+ _swrast_read_stencil_span( ctx, rb, width, srcx, ssy, p );
p += width;
}
p = tmpImage;
@@ -712,7 +756,7 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
p += width;
}
else {
- _swrast_read_stencil_span( ctx, width, srcx, sy, stencil );
+ _swrast_read_stencil_span( ctx, rb, width, srcx, sy, stencil );
}
/* Apply shift, offset, look-up table */
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 0142fe1552..e36878e6fc 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2003 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"),
@@ -27,51 +27,21 @@
#include "context.h"
#include "macros.h"
#include "imports.h"
+#include "fbobject.h"
#include "s_depth.h"
#include "s_context.h"
/**
- * Return address of depth buffer value for given window coord.
- */
-GLvoid *
-_swrast_zbuffer_address(GLcontext *ctx, GLint x, GLint y)
-{
- if (ctx->Visual.depthBits <= 16)
- return (GLushort *) ctx->DrawBuffer->DepthBuffer
- + ctx->DrawBuffer->Width * y + x;
- else
- return (GLuint *) ctx->DrawBuffer->DepthBuffer
- + ctx->DrawBuffer->Width * y + x;
-}
-
-
-#define Z_ADDRESS16( CTX, X, Y ) \
- ( ((GLushort *) (CTX)->DrawBuffer->DepthBuffer) \
- + (CTX)->DrawBuffer->Width * (Y) + (X) )
-
-#define Z_ADDRESS32( CTX, X, Y ) \
- ( ((GLuint *) (CTX)->DrawBuffer->DepthBuffer) \
- + (CTX)->DrawBuffer->Width * (Y) + (X) )
-
-
-
-/**********************************************************************/
-/***** Depth Testing Functions *****/
-/**********************************************************************/
-
-
-/*
- * Do depth test for an array of fragments. This is used both for
- * software and hardware Z buffers.
+ * Do depth test for a horizontal span of fragments.
* Input: zbuffer - array of z values in the zbuffer
* z - array of fragment z values
* Return: number of fragments which pass the test.
*/
static GLuint
depth_test_span16( GLcontext *ctx, GLuint n,
- GLushort zbuffer[], const GLdepth z[], GLubyte mask[] )
+ GLushort zbuffer[], const GLuint z[], GLubyte mask[] )
{
GLuint passed = 0;
@@ -300,7 +270,7 @@ depth_test_span16( GLcontext *ctx, GLuint n,
static GLuint
depth_test_span32( GLcontext *ctx, GLuint n,
- GLuint zbuffer[], const GLdepth z[], GLubyte mask[] )
+ GLuint zbuffer[], const GLuint z[], GLubyte mask[] )
{
GLuint passed = 0;
@@ -529,74 +499,69 @@ depth_test_span32( GLcontext *ctx, GLuint n,
/*
- * Apply depth test to span of fragments. Hardware or software z buffer.
+ * Apply depth test to span of fragments.
*/
static GLuint
depth_test_span( GLcontext *ctx, struct sw_span *span)
{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
const GLint x = span->x;
const GLint y = span->y;
- const GLuint n = span->end;
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLuint count = span->end;
+ const GLuint *zValues = span->array->z;
+ GLubyte *mask = span->array->mask;
+ GLuint passed;
ASSERT((span->arrayMask & SPAN_XY) == 0);
ASSERT(span->arrayMask & SPAN_Z);
- if (swrast->Driver.ReadDepthSpan) {
- /* hardware-based depth buffer */
- GLdepth zbuffer[MAX_WIDTH];
- GLuint passed;
- (*swrast->Driver.ReadDepthSpan)(ctx, n, x, y, zbuffer);
- passed = depth_test_span32(ctx, n, zbuffer, span->array->z,
- span->array->mask);
- ASSERT(swrast->Driver.WriteDepthSpan);
- (*swrast->Driver.WriteDepthSpan)(ctx, n, x, y, zbuffer,
- span->array->mask);
- if (passed < n)
- span->writeAll = GL_FALSE;
- return passed;
- }
- else {
- GLuint passed;
- /* software depth buffer */
- if (ctx->Visual.depthBits <= 16) {
- GLushort *zptr = (GLushort *) Z_ADDRESS16(ctx, x, y);
- passed = depth_test_span16(ctx, n, zptr, span->array->z, span->array->mask);
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* Directly access buffer */
+ if (ctx->DrawBuffer->Visual.depthBits <= 16) {
+ GLushort *zbuffer = (GLushort *) rb->GetPointer(ctx, rb, x, y);
+ passed = depth_test_span16(ctx, count, zbuffer, zValues, mask);
}
else {
- GLuint *zptr = (GLuint *) Z_ADDRESS32(ctx, x, y);
- passed = depth_test_span32(ctx, n, zptr, span->array->z, span->array->mask);
+ GLuint *zbuffer = (GLuint *) rb->GetPointer(ctx, rb, x, y);
+ passed = depth_test_span32(ctx, count, zbuffer, zValues, mask);
}
-#if 1
- if (passed < span->end) {
- span->writeAll = GL_FALSE;
+ }
+ else {
+ /* read depth values from buffer, test, write back */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort zbuffer[MAX_WIDTH];
+ rb->GetRow(ctx, rb, count, x, y, zbuffer);
+ passed = depth_test_span16(ctx, count, zbuffer, zValues, mask );
+ rb->PutRow(ctx, rb, count, x, y, zbuffer, NULL);
}
-#else
- /* this causes a glDrawPixels(GL_DEPTH_COMPONENT) conformance failure */
- if (passed < span->end) {
- span->writeAll = GL_FALSE;
- if (passed == 0) {
- span->end = 0;
- return 0;
- }
- while (span->end > 0 && span->mask[span->end - 1] == 0)
- span->end --;
+ else {
+ GLuint zbuffer[MAX_WIDTH];
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetRow(ctx, rb, count, x, y, zbuffer);
+ passed = depth_test_span32(ctx, count, zbuffer, zValues, mask );
+ rb->PutRow(ctx, rb, count, x, y, zbuffer, NULL);
}
-#endif
- return passed;
}
+
+ if (passed < count) {
+ span->writeAll = GL_FALSE;
+ }
+ return passed;
}
+#define Z_ADDRESS(X, Y) (zStart + (Y) * stride + (X))
+
/*
- * Do depth testing for an array of fragments using software Z buffer.
+ * Do depth testing for an array of fragments at assorted locations.
*/
static void
-software_depth_test_pixels16( GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[] )
+direct_depth_test_pixels16(GLcontext *ctx, GLushort *zStart, GLuint stride,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLuint z[], GLubyte mask[] )
{
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Depth.Func) {
@@ -606,7 +571,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] < *zptr) {
/* pass */
*zptr = z[i];
@@ -623,7 +588,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] < *zptr) {
/* pass */
}
@@ -641,7 +606,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] <= *zptr) {
/* pass */
*zptr = z[i];
@@ -658,7 +623,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] <= *zptr) {
/* pass */
}
@@ -676,7 +641,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] >= *zptr) {
/* pass */
*zptr = z[i];
@@ -693,7 +658,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] >= *zptr) {
/* pass */
}
@@ -711,7 +676,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] > *zptr) {
/* pass */
*zptr = z[i];
@@ -728,7 +693,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] > *zptr) {
/* pass */
}
@@ -746,7 +711,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] != *zptr) {
/* pass */
*zptr = z[i];
@@ -763,7 +728,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] != *zptr) {
/* pass */
}
@@ -781,7 +746,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] == *zptr) {
/* pass */
*zptr = z[i];
@@ -798,7 +763,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] == *zptr) {
/* pass */
}
@@ -816,7 +781,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
*zptr = z[i];
}
}
@@ -830,19 +795,19 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n,
_mesa_bzero(mask, n * sizeof(GLubyte));
break;
default:
- _mesa_problem(ctx, "Bad depth func in software_depth_test_pixels");
+ _mesa_problem(ctx, "Bad depth func in direct_depth_test_pixels");
}
}
/*
- * Do depth testing for an array of fragments using software Z buffer.
+ * Do depth testing for an array of fragments with direct access to zbuffer.
*/
static void
-software_depth_test_pixels32( GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[] )
+direct_depth_test_pixels32(GLcontext *ctx, GLuint *zStart, GLuint stride,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLuint z[], GLubyte mask[] )
{
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Depth.Func) {
@@ -852,7 +817,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] < *zptr) {
/* pass */
*zptr = z[i];
@@ -869,7 +834,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] < *zptr) {
/* pass */
}
@@ -887,7 +852,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] <= *zptr) {
/* pass */
*zptr = z[i];
@@ -904,7 +869,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] <= *zptr) {
/* pass */
}
@@ -922,7 +887,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] >= *zptr) {
/* pass */
*zptr = z[i];
@@ -939,7 +904,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] >= *zptr) {
/* pass */
}
@@ -957,7 +922,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] > *zptr) {
/* pass */
*zptr = z[i];
@@ -974,7 +939,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] > *zptr) {
/* pass */
}
@@ -992,7 +957,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] != *zptr) {
/* pass */
*zptr = z[i];
@@ -1009,7 +974,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] != *zptr) {
/* pass */
}
@@ -1027,7 +992,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] == *zptr) {
/* pass */
*zptr = z[i];
@@ -1044,7 +1009,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
if (z[i] == *zptr) {
/* pass */
}
@@ -1062,7 +1027,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
*zptr = z[i];
}
}
@@ -1076,275 +1041,55 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n,
_mesa_bzero(mask, n * sizeof(GLubyte));
break;
default:
- _mesa_problem(ctx, "Bad depth func in software_depth_test_pixels");
+ _mesa_problem(ctx, "Bad depth func in direct_depth_test_pixels");
}
}
-/*
- * Do depth testing for an array of pixels using hardware Z buffer.
- * Input/output: zbuffer - array of depth values from Z buffer
- * Input: z - array of fragment z values.
- */
-static void
-hardware_depth_test_pixels( GLcontext *ctx, GLuint n, GLdepth zbuffer[],
- const GLdepth z[], GLubyte mask[] )
-{
- /* switch cases ordered from most frequent to less frequent */
- switch (ctx->Depth.Func) {
- case GL_LESS:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] < zbuffer[i]) {
- /* pass */
- zbuffer[i] = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] < zbuffer[i]) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_LEQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] <= zbuffer[i]) {
- /* pass */
- zbuffer[i] = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] <= zbuffer[i]) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_GEQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] >= zbuffer[i]) {
- /* pass */
- zbuffer[i] = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] >= zbuffer[i]) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_GREATER:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] > zbuffer[i]) {
- /* pass */
- zbuffer[i] = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] > zbuffer[i]) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_NOTEQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] != zbuffer[i]) {
- /* pass */
- zbuffer[i] = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] != zbuffer[i]) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_EQUAL:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] == zbuffer[i]) {
- /* pass */
- zbuffer[i] = z[i];
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- else {
- /* Don't update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- if (z[i] == zbuffer[i]) {
- /* pass */
- }
- else {
- /* fail */
- mask[i] = 0;
- }
- }
- }
- }
- break;
- case GL_ALWAYS:
- if (ctx->Depth.Mask) {
- /* Update Z buffer */
- GLuint i;
- for (i=0; i<n; i++) {
- if (mask[i]) {
- zbuffer[i] = z[i];
- }
- }
- }
- else {
- /* Don't update Z buffer or mask */
- }
- break;
- case GL_NEVER:
- /* depth test never passes */
- _mesa_bzero(mask, n * sizeof(GLubyte));
- break;
- default:
- _mesa_problem(ctx, "Bad depth func in hardware_depth_test_pixels");
- }
-}
-
-
static GLuint
depth_test_pixels( GLcontext *ctx, struct sw_span *span )
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLuint n = span->end;
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ const GLuint count = span->end;
const GLint *x = span->array->x;
const GLint *y = span->array->y;
- const GLdepth *z = span->array->z;
+ const GLuint *z = span->array->z;
GLubyte *mask = span->array->mask;
- if (swrast->Driver.ReadDepthPixels) {
- /* read depth values from hardware Z buffer */
- GLdepth zbuffer[MAX_WIDTH];
- (*swrast->Driver.ReadDepthPixels)(ctx, n, x, y, zbuffer);
-
- hardware_depth_test_pixels( ctx, n, zbuffer, z, mask );
-
- /* update hardware Z buffer with new values */
- assert(swrast->Driver.WriteDepthPixels);
- (*swrast->Driver.WriteDepthPixels)(ctx, n, x, y, zbuffer, mask );
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* Directly access values */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort *zStart = (GLushort *) rb->Data;
+ GLuint stride = rb->Width;
+ direct_depth_test_pixels16(ctx, zStart, stride, count, x, y, z, mask);
+ }
+ else {
+ GLuint *zStart = (GLuint *) rb->Data;
+ GLuint stride = rb->Width;
+ direct_depth_test_pixels32(ctx, zStart, stride, count, x, y, z, mask);
+ }
}
else {
- /* software depth testing */
- if (ctx->Visual.depthBits <= 16)
- software_depth_test_pixels16(ctx, n, x, y, z, mask);
- else
- software_depth_test_pixels32(ctx, n, x, y, z, mask);
+ /* read depth values from buffer, test, write back */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort zbuffer[MAX_WIDTH];
+ rb->GetValues(ctx, rb, count, x, y, zbuffer);
+ depth_test_span16(ctx, count, zbuffer, z, mask );
+ rb->PutValues(ctx, rb, count, x, y, zbuffer, NULL);
+ }
+ else {
+ GLuint zbuffer[MAX_WIDTH];
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetValues(ctx, rb, count, x, y, zbuffer);
+ depth_test_span32(ctx, count, zbuffer, z, mask );
+ rb->PutValues(ctx, rb, count, x, y, zbuffer, NULL);
+ }
}
- return n; /* not really correct, but OK */
+
+ return count; /* not really correct, but OK */
}
@@ -1372,24 +1117,33 @@ _swrast_depth_test_span( GLcontext *ctx, struct sw_span *span)
GLboolean
_swrast_depth_bounds_test( GLcontext *ctx, struct sw_span *span )
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLdepth zMin = (GLdepth) (ctx->Depth.BoundsMin * ctx->DepthMaxF + 0.5F);
- GLdepth zMax = (GLdepth) (ctx->Depth.BoundsMax * ctx->DepthMaxF + 0.5F);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ GLuint zMin = (GLuint) (ctx->Depth.BoundsMin * fb->_DepthMaxF + 0.5F);
+ GLuint zMax = (GLuint) (ctx->Depth.BoundsMax * fb->_DepthMaxF + 0.5F);
GLubyte *mask = span->array->mask;
+ const GLuint count = span->end;
GLuint i;
GLboolean anyPass = GL_FALSE;
- if (swrast->Driver.ReadDepthPixels) {
- /* read depth values from hardware Z buffer */
- GLdepth zbuffer[MAX_WIDTH];
- ASSERT(span->end <= MAX_WIDTH);
- if (span->arrayMask & SPAN_XY)
- (*swrast->Driver.ReadDepthPixels)(ctx, span->end, span->array->x,
- span->array->y, zbuffer);
- else
- (*swrast->Driver.ReadDepthSpan)(ctx, span->end, span->x, span->y,
- zbuffer);
- for (i = 0; i < span->end; i++) {
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ /* get 16-bit values */
+ GLushort zbuffer16[MAX_WIDTH], *zbuffer;
+ if (span->arrayMask & SPAN_XY) {
+ rb->GetValues(ctx, rb, count, span->array->x, span->array->y, zbuffer16);
+ zbuffer = zbuffer16;
+ }
+ else {
+ zbuffer = rb->GetPointer(ctx, rb, span->x, span->y);
+ if (!zbuffer) {
+ rb->GetRow(ctx, rb, count, span->x, span->y, zbuffer16);
+ zbuffer = zbuffer16;
+ }
+ }
+ assert(zbuffer);
+
+ /* Now do the tests */
+ for (i = 0; i < count; i++) {
if (mask[i]) {
if (zbuffer[i] < zMin || zbuffer[i] > zMax)
mask[i] = GL_FALSE;
@@ -1399,62 +1153,32 @@ _swrast_depth_bounds_test( GLcontext *ctx, struct sw_span *span )
}
}
else {
- /* software Z buffer */
+ /* get 32-bit values */
+ GLuint zbuffer32[MAX_WIDTH], *zbuffer;
if (span->arrayMask & SPAN_XY) {
- if (ctx->Visual.depthBits <= 16) {
- /* 16 bits / Z */
- for (i = 0; i < span->end; i++) {
- if (mask[i]) {
- const GLushort *zPtr = Z_ADDRESS16(ctx, span->array->x[i],
- span->array->y[i]);
- if (*zPtr < zMin || *zPtr > zMax)
- mask[i] = GL_FALSE;
- else
- anyPass = GL_TRUE;
- }
- }
- }
- else {
- /* 32 bits / Z */
- for (i = 0; i < span->end; i++) {
- if (mask[i]) {
- const GLuint *zPtr = Z_ADDRESS32(ctx, span->array->x[i],
- span->array->y[i]);
- if (*zPtr < zMin || *zPtr > zMax)
- mask[i] = GL_FALSE;
- else
- anyPass = GL_TRUE;
- }
- }
- }
+ rb->GetValues(ctx, rb, count, span->array->x, span->array->y, zbuffer32);
+ zbuffer = zbuffer32;
}
else {
- if (ctx->Visual.depthBits <= 16) {
- /* 16 bits / Z */
- const GLushort *zPtr = Z_ADDRESS16(ctx, span->x, span->y);
- for (i = 0; i < span->end; i++) {
- if (mask[i]) {
- if (zPtr[i] < zMin || zPtr[i] > zMax)
- mask[i] = GL_FALSE;
- else
- anyPass = GL_TRUE;
- }
- }
+ zbuffer = rb->GetPointer(ctx, rb, span->x, span->y);
+ if (!zbuffer) {
+ rb->GetRow(ctx, rb, count, span->x, span->y, zbuffer32);
+ zbuffer = zbuffer32;
}
- else {
- /* 32 bits / Z */
- const GLuint *zPtr = Z_ADDRESS32(ctx, span->x, span->y);
- for (i = 0; i < span->end; i++) {
- if (mask[i]) {
- if (zPtr[i] < zMin || zPtr[i] > zMax)
- mask[i] = GL_FALSE;
- else
- anyPass = GL_TRUE;
- }
- }
+ }
+ assert(zbuffer);
+
+ /* Now do the tests */
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ if (zbuffer[i] < zMin || zbuffer[i] > zMax)
+ mask[i] = GL_FALSE;
+ else
+ anyPass = GL_TRUE;
}
}
}
+
return anyPass;
}
@@ -1468,15 +1192,16 @@ _swrast_depth_bounds_test( GLcontext *ctx, struct sw_span *span )
/**
* Read a span of depth values from the depth buffer.
* This function does clipping before calling the device driver function.
+ *
+ * XXXX this is no longer a swrast function!!!
+ *
*/
void
-_swrast_read_depth_span( GLcontext *ctx,
- GLint n, GLint x, GLint y, GLdepth depth[] )
+_swrast_read_depth_span( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLuint depth[] )
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- if (y < 0 || y >= (GLint) ctx->DrawBuffer->Height ||
- x + (GLint) n <= 0 || x >= (GLint) ctx->DrawBuffer->Width) {
+ if (y < 0 || y >= (GLint) rb->Height ||
+ x + (GLint) n <= 0 || x >= (GLint) rb->Width) {
/* span is completely outside framebuffer */
GLint i;
for (i = 0; i < n; i++)
@@ -1493,8 +1218,8 @@ _swrast_read_depth_span( GLcontext *ctx,
n -= dx;
depth += dx;
}
- if (x + n > (GLint) ctx->DrawBuffer->Width) {
- GLint dx = x + n - (GLint) ctx->DrawBuffer->Width;
+ if (x + n > (GLint) rb->Width) {
+ GLint dx = x + n - (GLint) rb->Width;
GLint i;
for (i = 0; i < dx; i++)
depth[n - i - 1] = 0;
@@ -1504,292 +1229,127 @@ _swrast_read_depth_span( GLcontext *ctx,
return;
}
- if (ctx->DrawBuffer->DepthBuffer) {
- /* read from software depth buffer */
- if (ctx->Visual.depthBits <= 16) {
- const GLushort *zptr = Z_ADDRESS16( ctx, x, y );
- GLint i;
- for (i = 0; i < n; i++) {
- depth[i] = zptr[i];
- }
- }
- else {
- const GLuint *zptr = Z_ADDRESS32( ctx, x, y );
- GLint i;
- for (i = 0; i < n; i++) {
- depth[i] = zptr[i];
- }
- }
+ /* we'll always return 32-bit values to our caller */
+ if (!rb) {
+ _mesa_bzero(depth, n * sizeof(GLuint));
}
- else if (swrast->Driver.ReadDepthSpan) {
- /* read from hardware depth buffer */
- (*swrast->Driver.ReadDepthSpan)( ctx, n, x, y, depth );
+ else if (rb->DataType == GL_UNSIGNED_INT) {
+ rb->GetRow(ctx, rb, x, y, n, depth);
}
else {
- /* no depth buffer */
- _mesa_bzero(depth, n * sizeof(GLfloat));
+ GLushort temp[MAX_WIDTH];
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ rb->GetRow(ctx, rb, n, x, y, temp);
+ for (i = 0; i < n; i++) {
+ depth[i] = temp[i];
+ }
}
-
}
-
-
/**
* Return a span of depth values from the depth buffer as floats in [0,1].
- * This is used for both hardware and software depth buffers.
* Input: n - how many pixels
* x,y - location of first pixel
* Output: depth - the array of depth values
*/
void
-_swrast_read_depth_span_float( GLcontext *ctx,
- GLint n, GLint x, GLint y, GLfloat depth[] )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLfloat scale = 1.0F / ctx->DepthMaxF;
-
- if (y < 0 || y >= (GLint) ctx->DrawBuffer->Height ||
- x + (GLint) n <= 0 || x >= (GLint) ctx->DrawBuffer->Width) {
- /* span is completely outside framebuffer */
- GLint i;
- for (i = 0; i < n; i++)
- depth[i] = 0.0F;
- return;
- }
-
- if (x < 0) {
- GLint dx = -x;
- GLint i;
- for (i = 0; i < dx; i++)
- depth[i] = 0.0F;
- n -= dx;
- x = 0;
- }
- if (x + n > (GLint) ctx->DrawBuffer->Width) {
- GLint dx = x + n - (GLint) ctx->DrawBuffer->Width;
- GLint i;
- for (i = 0; i < dx; i++)
- depth[n - i - 1] = 0.0F;
- n -= dx;
- }
- if (n <= 0) {
- return;
- }
-
- if (ctx->DrawBuffer->DepthBuffer) {
- /* read from software depth buffer */
- if (ctx->Visual.depthBits <= 16) {
- const GLushort *zptr = Z_ADDRESS16( ctx, x, y );
- GLint i;
- for (i = 0; i < n; i++) {
- depth[i] = (GLfloat) zptr[i] * scale;
- }
- }
- else {
- const GLuint *zptr = Z_ADDRESS32( ctx, x, y );
- GLint i;
- for (i = 0; i < n; i++) {
- depth[i] = (GLfloat) zptr[i] * scale;
- }
- }
- }
- else if (swrast->Driver.ReadDepthSpan) {
- /* read from hardware depth buffer */
- GLdepth d[MAX_WIDTH];
- GLint i;
- assert(n <= MAX_WIDTH);
- (*swrast->Driver.ReadDepthSpan)( ctx, n, x, y, d );
- for (i = 0; i < n; i++) {
- depth[i] = d[i] * scale;
- }
- }
- else {
- /* no depth buffer */
- _mesa_bzero(depth, n * sizeof(GLfloat));
- }
-}
-
-
-
-/**********************************************************************/
-/***** Allocate and Clear Depth Buffer *****/
-/**********************************************************************/
-
-
-
-/**
- * Allocate a new depth buffer. If there's already a depth buffer allocated
- * it will be free()'d. The new depth buffer will be uninitialized.
- */
-void
-_swrast_alloc_depth_buffer( GLframebuffer *buffer )
+_swrast_read_depth_span_float( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLfloat depth[] )
{
- GLint bytesPerValue;
-
- ASSERT(buffer->UseSoftwareDepthBuffer);
+ const GLfloat scale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+ GLuint temp[MAX_WIDTH];
+ GLint i;
- /* deallocate current depth buffer if present */
- if (buffer->DepthBuffer) {
- MESA_PBUFFER_FREE(buffer->DepthBuffer);
- buffer->DepthBuffer = NULL;
- }
-
- /* allocate new depth buffer, but don't initialize it */
- if (buffer->Visual.depthBits <= 16)
- bytesPerValue = sizeof(GLushort);
- else
- bytesPerValue = sizeof(GLuint);
+ assert(n <= MAX_WIDTH);
- buffer->DepthBuffer = MESA_PBUFFER_ALLOC(buffer->Width * buffer->Height
- * bytesPerValue);
-
- if (!buffer->DepthBuffer) {
- /* out of memory */
- GET_CURRENT_CONTEXT(ctx);
- if (ctx) {
- ctx->Depth.Test = GL_FALSE;
- ctx->NewState |= _NEW_DEPTH;
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Couldn't allocate depth buffer");
- }
+ _swrast_read_depth_span(ctx, rb, n, x, y, temp);
+ for (i = 0; i < n; i++) {
+ depth[i] = temp[i] * scale;
}
}
/**
- * Clear the depth buffer. If the depth buffer doesn't exist yet we'll
- * allocate it now.
- * This function is only called through Driver.clear_depth_buffer.
+ * Clear the depth buffer.
+ * XXX this is no longer a swrast function!!!
*/
void
-_swrast_clear_depth_buffer( GLcontext *ctx )
+_swrast_clear_depth_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLuint clearValue
+ = (GLuint) (ctx->Depth.Clear * ctx->DrawBuffer->_DepthMaxF);
+ GLint x, y, width, height;
- if (ctx->Visual.depthBits == 0
- || !ctx->Depth.Mask) {
+ if (!rb || !ctx->Depth.Mask) {
/* no depth buffer, or writing to it is disabled */
return;
}
- if (swrast->Driver.WriteMonoDepthSpan) {
- const GLdepth clearValue = (GLdepth)(ctx->Depth.Clear * ctx->DepthMax);
- const GLint x = ctx->DrawBuffer->_Xmin;
- const GLint y = ctx->DrawBuffer->_Ymin;
- const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
- const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
- GLint i;
-
- for (i = 0; i < height; i++) {
- (*swrast->Driver.WriteMonoDepthSpan)( ctx, width, x, y + i,
- clearValue, NULL );
- }
-
- return;
- }
-
- if (!ctx->DrawBuffer->DepthBuffer)
- return;
-
- /* The loops in this function have been written so the IRIX 5.3
- * C compiler can unroll them. Hopefully other compilers can too!
- */
-
- if (ctx->Scissor.Enabled) {
- /* only clear scissor region */
- if (ctx->Visual.depthBits <= 16) {
- const GLushort clearValue = (GLushort) (ctx->Depth.Clear * ctx->DepthMax);
- const GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
- const GLint cols = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
- const GLint rowStride = ctx->DrawBuffer->Width;
- GLushort *dRow = (GLushort *) ctx->DrawBuffer->DepthBuffer
- + ctx->DrawBuffer->_Ymin * rowStride + ctx->DrawBuffer->_Xmin;
- GLint i, j;
- for (i = 0; i < rows; i++) {
- for (j = 0; j < cols; j++) {
- dRow[j] = clearValue;
+ assert(rb->_BaseFormat == GL_DEPTH_COMPONENT);
+
+ /* compute region to clear */
+ x = ctx->DrawBuffer->_Xmin;
+ y = ctx->DrawBuffer->_Ymin;
+ width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* Direct buffer access is possible. Either this is just malloc'd
+ * memory, or perhaps the driver mmap'd the zbuffer memory.
+ */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ if (width == rb->Width &&
+ (clearValue & 0xff) == ((clearValue >> 8) & 0xff)) {
+ /* optimized case */
+ GLushort *dst = (GLushort *) rb->GetPointer(ctx, rb, x, y);
+ GLuint len = width * height * sizeof(GLushort);
+ _mesa_memset(dst, (clearValue & 0xff), len);
+ }
+ else {
+ /* general case */
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLushort *dst = (GLushort *) rb->GetPointer(ctx, rb, x, y + i);
+ for (j = 0; j < width; j++) {
+ dst[j] = clearValue;
+ }
}
- dRow += rowStride;
}
}
else {
- const GLuint clearValue = (GLuint) (ctx->Depth.Clear * ctx->DepthMax);
- const GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
- const GLint cols = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
- const GLint rowStride = ctx->DrawBuffer->Width;
- GLuint *dRow = (GLuint *) ctx->DrawBuffer->DepthBuffer
- + ctx->DrawBuffer->_Ymin * rowStride + ctx->DrawBuffer->_Xmin;
GLint i, j;
- for (i = 0; i < rows; i++) {
- for (j = 0; j < cols; j++) {
- dRow[j] = clearValue;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < height; i++) {
+ GLuint *dst = (GLuint *) rb->GetPointer(ctx, rb, x, y + i);
+ for (j = 0; j < width; j++) {
+ dst[j] = clearValue;
}
- dRow += rowStride;
}
}
}
else {
- /* clear whole buffer */
- if (ctx->Visual.depthBits <= 16) {
- const GLushort clearValue = (GLushort) (ctx->Depth.Clear * ctx->DepthMax);
- if ((clearValue & 0xff) == (clearValue >> 8)) {
- if (clearValue == 0) {
- _mesa_bzero(ctx->DrawBuffer->DepthBuffer,
- 2*ctx->DrawBuffer->Width*ctx->DrawBuffer->Height);
- }
- else {
- /* lower and upper bytes of clear_value are same, use MEMSET */
- MEMSET( ctx->DrawBuffer->DepthBuffer, clearValue & 0xff,
- 2 * ctx->DrawBuffer->Width * ctx->DrawBuffer->Height);
- }
+ /* Direct access not possible. Use PutRow to write new values. */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort clearRow[MAX_WIDTH];
+ GLint i, j;
+ for (j = 0; j < width; j++) {
+ clearRow[j] = clearValue;
}
- else {
- GLushort *d = (GLushort *) ctx->DrawBuffer->DepthBuffer;
- GLint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
- while (n >= 16) {
- d[0] = clearValue; d[1] = clearValue;
- d[2] = clearValue; d[3] = clearValue;
- d[4] = clearValue; d[5] = clearValue;
- d[6] = clearValue; d[7] = clearValue;
- d[8] = clearValue; d[9] = clearValue;
- d[10] = clearValue; d[11] = clearValue;
- d[12] = clearValue; d[13] = clearValue;
- d[14] = clearValue; d[15] = clearValue;
- d += 16;
- n -= 16;
- }
- while (n > 0) {
- *d++ = clearValue;
- n--;
- }
+ for (i = 0; i < height; i++) {
+ rb->PutRow(ctx, rb, width, x, y + i, clearRow, NULL);
}
}
else {
- /* >16 bit depth buffer */
- const GLuint clearValue = (GLuint) (ctx->Depth.Clear * ctx->DepthMax);
- if (clearValue == 0) {
- _mesa_bzero(ctx->DrawBuffer->DepthBuffer,
- ctx->DrawBuffer->Width*ctx->DrawBuffer->Height*sizeof(GLuint));
+ GLuint clearRow[MAX_WIDTH];
+ GLint i, j;
+ assert(rb->DataType == GL_UNSIGNED_INT);
+ for (j = 0; j < width; j++) {
+ clearRow[j] = clearValue;
}
- else {
- GLint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
- GLuint *d = (GLuint *) ctx->DrawBuffer->DepthBuffer;
- while (n >= 16) {
- d[0] = clearValue; d[1] = clearValue;
- d[2] = clearValue; d[3] = clearValue;
- d[4] = clearValue; d[5] = clearValue;
- d[6] = clearValue; d[7] = clearValue;
- d[8] = clearValue; d[9] = clearValue;
- d[10] = clearValue; d[11] = clearValue;
- d[12] = clearValue; d[13] = clearValue;
- d[14] = clearValue; d[15] = clearValue;
- d += 16;
- n -= 16;
- }
- while (n > 0) {
- *d++ = clearValue;
- n--;
- }
+ for (i = 0; i < height; i++) {
+ rb->PutRow(ctx, rb, width, x, y + i, clearRow, NULL);
}
}
}
diff --git a/src/mesa/swrast/s_depth.h b/src/mesa/swrast/s_depth.h
index b972a84c56..2229e8a22d 100644
--- a/src/mesa/swrast/s_depth.h
+++ b/src/mesa/swrast/s_depth.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2003 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"),
@@ -31,10 +31,6 @@
#include "s_context.h"
-extern GLvoid *
-_swrast_zbuffer_address(GLcontext *ctx, GLint x, GLint y);
-
-
extern GLuint
_swrast_depth_test_span( GLcontext *ctx, struct sw_span *span);
@@ -44,21 +40,17 @@ _swrast_depth_bounds_test( GLcontext *ctx, struct sw_span *span );
extern void
-_swrast_read_depth_span( GLcontext *ctx,
- GLint n, GLint x, GLint y, GLdepth depth[] );
-
-
-extern void
-_swrast_read_depth_span_float( GLcontext *ctx, GLint n, GLint x, GLint y,
- GLfloat depth[] );
+_swrast_read_depth_span( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLuint depth[] );
extern void
-_swrast_alloc_depth_buffer( GLframebuffer *buffer );
+_swrast_read_depth_span_float( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLfloat depth[] );
extern void
-_swrast_clear_depth_buffer( GLcontext *ctx );
+_swrast_clear_depth_buffer( GLcontext *ctx, struct gl_renderbuffer *rb );
#endif
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 5b0a24bfb2..bd9a14b119 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -51,6 +51,9 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels)
{
+#if NEW_RENDERBUFFER
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+#endif
SWcontext *swrast = SWRAST_CONTEXT(ctx);
struct sw_span span;
@@ -59,6 +62,9 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
if (!ctx->Current.RasterPosValid) {
return GL_TRUE; /* no-op */
}
+
+ if (swrast->_RasterMask & MULTI_DRAW_BIT)
+ return GL_FALSE;
if (ctx->Depth.Test)
_swrast_span_default_z(ctx, &span);
@@ -164,8 +170,15 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
/* no zooming */
GLint row;
for (row=0; row<drawHeight; row++) {
- (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (CONST GLchan (*)[4]) src, NULL);
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, rb, drawWidth,
+ destX, destY,
+ (CONST GLchan (*)[4]) src,
+ NULL);
+ else
+#endif
+ rb->PutRow(ctx, rb, drawWidth, destX, destY, src, NULL);
src += rowLength * 4;
destY++;
}
@@ -175,8 +188,15 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row=0; row<drawHeight; row++) {
destY--;
- (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
- (CONST GLchan (*)[4]) src, NULL);
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, rb, drawWidth,
+ destX, destY,
+ (CONST GLchan (*)[4]) src,
+ NULL);
+ else
+#endif
+ rb->PutRow(ctx, rb, drawWidth, destX, destY, src, NULL);
src += rowLength * 4;
}
}
@@ -204,8 +224,15 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
GLint row;
for (row=0; row<drawHeight; row++) {
- (*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
- (CONST GLchan (*)[3]) src, NULL);
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBSpan)
+ (*swrast->Driver.WriteRGBSpan)(ctx, rb, drawWidth,
+ destX, destY,
+ (CONST GLchan (*)[3]) src,
+ NULL);
+ else
+#endif
+ rb->PutRowRGB(ctx, rb, drawWidth, destX, destY, src, NULL);
src += rowLength * 3;
destY++;
}
@@ -215,8 +242,15 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row=0; row<drawHeight; row++) {
destY--;
- (*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
- (CONST GLchan (*)[3]) src, NULL);
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ (*swrast->Driver.WriteRGBSpan)(ctx, rb, drawWidth,
+ destX, destY,
+ (CONST GLchan (*)[3]) src,
+ NULL);
+ else
+#endif
+ rb->PutRowRGB(ctx, rb, drawWidth, destX, destY, src, NULL);
src += rowLength * 3;
}
}
@@ -252,8 +286,15 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
span.array->rgb[i][1] = src[i];
span.array->rgb[i][2] = src[i];
}
- (*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBSpan)
+ (*swrast->Driver.WriteRGBSpan)(ctx, rb, drawWidth,
+ destX, destY,
(CONST GLchan (*)[3]) span.array->rgb, NULL);
+ else
+#endif
+ rb->PutRowRGB(ctx, rb, drawWidth, destX, destY,
+ span.array->rgb, NULL);
src += rowLength;
destY++;
}
@@ -270,8 +311,15 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
span.array->rgb[i][2] = src[i];
}
destY--;
- (*swrast->Driver.WriteRGBSpan)(ctx, drawWidth, destX, destY,
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBSpan)
+ (*swrast->Driver.WriteRGBSpan)(ctx, rb, drawWidth,
+ destX, destY,
(CONST GLchan (*)[3]) span.array->rgb, NULL);
+ else
+#endif
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgb, NULL);
src += rowLength;
}
}
@@ -316,8 +364,14 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
span.array->rgba[i][2] = *ptr++;
span.array->rgba[i][3] = *ptr++;
}
- (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, rb, drawWidth, destX,destY,
(CONST GLchan (*)[4]) span.array->rgba, NULL);
+ else
+#endif
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgba, NULL);
src += rowLength*2;
destY++;
}
@@ -336,8 +390,14 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
span.array->rgba[i][3] = *ptr++;
}
destY--;
- (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, rb, drawWidth, destX,destY,
(CONST GLchan (*)[4]) span.array->rgba, NULL);
+ else
+#endif
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgba, NULL);
src += rowLength*2;
}
}
@@ -376,8 +436,15 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
for (row=0; row<drawHeight; row++) {
ASSERT(drawWidth <= MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba);
- (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, rb, drawWidth, destX,destY,
(const GLchan (*)[4]) span.array->rgba, NULL);
+ else
+#endif
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgba, NULL);
+
src += rowLength;
destY++;
}
@@ -390,8 +457,14 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
ASSERT(drawWidth <= MAX_WIDTH);
_mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba);
destY--;
- (*swrast->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, rb, drawWidth, destX,destY,
(CONST GLchan (*)[4]) span.array->rgba, NULL);
+ else
+#endif
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgba, NULL);
src += rowLength;
}
return GL_TRUE;
@@ -419,8 +492,11 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* no zooming */
for (row=0; row<drawHeight; row++) {
- (*swrast->Driver.WriteCI8Span)(ctx, drawWidth, destX, destY,
- src, NULL);
+ GLuint index32[MAX_WIDTH];
+ GLint col;
+ for (col = 0; col < drawWidth; col++)
+ index32[col] = src[col];
+ rb->PutRow(ctx, rb, drawWidth, destX, destY, index32, NULL);
src += rowLength;
destY++;
}
@@ -656,6 +732,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
}
else {
/* General case */
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
GLint row, skipPixels = 0;
/* in case width > MAX_WIDTH do the copy in chunks */
@@ -683,10 +760,9 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
zSrc, unpack);
/* clamp depth values to [0,1] and convert from floats to ints */
{
- const GLfloat zScale = ctx->DepthMaxF;
GLuint i;
for (i = 0; i < span.end; i++) {
- span.array->z[i] = (GLdepth) (floatSpan[i] * zScale);
+ span.array->z[i] = (GLdepth) (floatSpan[i] * depthMax);
}
}
if (zoom) {
@@ -717,6 +793,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
const GLvoid *pixels )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb = NULL; /* only used for quickDraw path */
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
const GLint desty = y;
GLboolean quickDraw;
@@ -744,11 +821,14 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
if (SWRAST_CONTEXT(ctx)->_RasterMask == 0 && !zoom && x >= 0 && y >= 0
&& x + width <= (GLint) ctx->DrawBuffer->Width
- && y + height <= (GLint) ctx->DrawBuffer->Height) {
+ && y + height <= (GLint) ctx->DrawBuffer->Height
+ && ctx->DrawBuffer->_NumColorDrawBuffers[0] == 1) {
quickDraw = GL_TRUE;
+ rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
}
else {
quickDraw = GL_FALSE;
+ rb = NULL;
}
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
@@ -846,8 +926,14 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
/* draw the span */
if (quickDraw) {
- (*swrast->Driver.WriteRGBASpan)(ctx, span.end, span.x, span.y,
- (CONST GLchan (*)[4]) span.array->rgba, NULL);
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.WriteRGBASpan)
+ swrast->Driver.WriteRGBASpan(ctx, rb, span.end, span.x, span.y,
+ (CONST GLchan (*)[4]) span.array->rgba, NULL);
+ else
+#endif
+ rb->PutRow(ctx, rb, span.end, span.x, span.y,
+ span.array->rgba, NULL);
}
else if (zoom) {
_swrast_write_zoomed_rgba_span(ctx, &span,
diff --git a/src/mesa/swrast/s_feedback.c b/src/mesa/swrast/s_feedback.c
index 892c40db6a..26cb05cd56 100644
--- a/src/mesa/swrast/s_feedback.c
+++ b/src/mesa/swrast/s_feedback.c
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2003 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"),
@@ -54,7 +53,7 @@ static void feedback_vertex( GLcontext *ctx,
win[0] = v->win[0];
win[1] = v->win[1];
- win[2] = v->win[2] / ctx->DepthMaxF;
+ win[2] = v->win[2] / ctx->DrawBuffer->_DepthMaxF;
win[3] = 1.0F / v->win[3];
color[0] = CHAN_TO_FLOAT(pv->color[0]);
@@ -138,7 +137,7 @@ void _swrast_select_triangle( GLcontext *ctx,
const SWvertex *v2)
{
if (_swrast_culltriangle( ctx, v0, v1, v2 )) {
- const GLfloat zs = 1.0F / ctx->DepthMaxF;
+ const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
_mesa_update_hitflag( ctx, v0->win[2] * zs );
_mesa_update_hitflag( ctx, v1->win[2] * zs );
@@ -149,7 +148,7 @@ void _swrast_select_triangle( GLcontext *ctx,
void _swrast_select_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
{
- const GLfloat zs = 1.0F / ctx->DepthMaxF;
+ const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
_mesa_update_hitflag( ctx, v0->win[2] * zs );
_mesa_update_hitflag( ctx, v1->win[2] * zs );
}
@@ -157,6 +156,6 @@ void _swrast_select_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1
void _swrast_select_point( GLcontext *ctx, const SWvertex *v )
{
- const GLfloat zs = 1.0F / ctx->DepthMaxF;
+ const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
_mesa_update_hitflag( ctx, v->win[2] * zs );
}
diff --git a/src/mesa/swrast/s_imaging.c b/src/mesa/swrast/s_imaging.c
index 088215d535..5c79a7ba95 100644
--- a/src/mesa/swrast/s_imaging.c
+++ b/src/mesa/swrast/s_imaging.c
@@ -41,6 +41,11 @@ _swrast_CopyColorTable( GLcontext *ctx,
GLchan data[MAX_WIDTH][4];
struct gl_buffer_object *bufferSave;
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
/* Select buffer to read from */
_swrast_use_read_buffer(ctx);
@@ -48,7 +53,8 @@ _swrast_CopyColorTable( GLcontext *ctx,
width = MAX_WIDTH;
/* read the data from framebuffer */
- _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y, data );
/* Restore reading from draw buffer (the default) */
_swrast_use_draw_buffer(ctx);
@@ -71,6 +77,11 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
GLchan data[MAX_WIDTH][4];
struct gl_buffer_object *bufferSave;
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
/* Select buffer to read from */
_swrast_use_read_buffer(ctx);
@@ -78,7 +89,8 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
width = MAX_WIDTH;
/* read the data from framebuffer */
- _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y, data );
/* Restore reading from draw buffer (the default) */
_swrast_use_draw_buffer(ctx);
@@ -103,14 +115,19 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,
GLchan rgba[MAX_CONVOLUTION_WIDTH][4];
struct gl_buffer_object *bufferSave;
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
/* Select buffer to read from */
_swrast_use_read_buffer(ctx);
RENDER_START( swrast, ctx );
/* read the data from framebuffer */
- _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y,
- (GLchan (*)[4]) rgba );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y, (GLchan (*)[4]) rgba );
RENDER_FINISH( swrast, ctx );
@@ -141,6 +158,11 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
GLint i;
struct gl_buffer_object *bufferSave;
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
/* Select buffer to read from */
_swrast_use_read_buffer(ctx);
@@ -148,8 +170,8 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
/* read pixels from framebuffer */
for (i = 0; i < height; i++) {
- _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y + i,
- (GLchan (*)[4]) rgba[i] );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y + i, (GLchan (*)[4]) rgba[i] );
}
RENDER_FINISH(swrast,ctx);
diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h
index efdf149069..af7aeabf62 100644
--- a/src/mesa/swrast/s_linetemp.h
+++ b/src/mesa/swrast/s_linetemp.h
@@ -82,6 +82,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
#if defined(DEPTH_TYPE)
const GLint depthBits = ctx->Visual.depthBits;
const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
+ struct gl_renderbuffer *zrb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
#define FixedToDepth(F) ((F) >> fixedToDepthShift)
GLint zPtrXstep, zPtrYstep;
DEPTH_TYPE *zPtr;
@@ -151,7 +152,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
return;
#ifdef DEPTH_TYPE
- zPtr = (DEPTH_TYPE *) _swrast_zbuffer_address(ctx, x0, y0);
+ zPtr = (DEPTH_TYPE *) zrb->GetPointer(ctx, zrb, x0, y0);
#endif
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE *) PIXEL_ADDRESS(x0,y0);
diff --git a/src/mesa/swrast/s_logic.c b/src/mesa/swrast/s_logic.c
index ad27cb7b62..aabe18d9c9 100644
--- a/src/mesa/swrast/s_logic.c
+++ b/src/mesa/swrast/s_logic.c
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2002 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"),
@@ -29,133 +28,151 @@
#include "imports.h"
#include "macros.h"
-#include "s_alphabuf.h"
#include "s_context.h"
#include "s_logic.h"
#include "s_span.h"
+#define LOGIC_OP_LOOP(MODE) \
+do { \
+ GLuint i; \
+ switch (MODE) { \
+ case GL_CLEAR: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = 0; \
+ } \
+ } \
+ break; \
+ case GL_SET: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~0; \
+ } \
+ } \
+ break; \
+ case GL_COPY: \
+ /* do nothing */ \
+ break; \
+ case GL_COPY_INVERTED: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~src[i]; \
+ } \
+ } \
+ break; \
+ case GL_NOOP: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_INVERT: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_AND: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] &= dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_NAND: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~(src[i] & dest[i]); \
+ } \
+ } \
+ break; \
+ case GL_OR: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] |= dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_NOR: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~(src[i] | dest[i]); \
+ } \
+ } \
+ break; \
+ case GL_XOR: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] ^= dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_EQUIV: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~(src[i] ^ dest[i]); \
+ } \
+ } \
+ break; \
+ case GL_AND_REVERSE: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = src[i] & ~dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_AND_INVERTED: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~src[i] & dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_OR_REVERSE: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = src[i] | ~dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_OR_INVERTED: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~src[i] | dest[i]; \
+ } \
+ } \
+ break; \
+ default: \
+ _mesa_problem(ctx, "bad logicop mode");\
+ } \
+} while (0)
+
+
-/*
- * Apply logic op to array of CI pixels.
- */
static void
-index_logicop( GLcontext *ctx, GLuint n, GLuint index[], const GLuint dest[],
- const GLubyte mask[] )
+logicop_ubyte(GLcontext *ctx, GLuint n, GLubyte src[], const GLubyte dest[],
+ const GLubyte mask[])
{
- GLuint i;
- switch (ctx->Color.LogicOp) {
- case GL_CLEAR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = 0;
- }
- }
- break;
- case GL_SET:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = ~0;
- }
- }
- break;
- case GL_COPY:
- /* do nothing */
- break;
- case GL_COPY_INVERTED:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = ~index[i];
- }
- }
- break;
- case GL_NOOP:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = dest[i];
- }
- }
- break;
- case GL_INVERT:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = ~dest[i];
- }
- }
- break;
- case GL_AND:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] &= dest[i];
- }
- }
- break;
- case GL_NAND:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = ~(index[i] & dest[i]);
- }
- }
- break;
- case GL_OR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] |= dest[i];
- }
- }
- break;
- case GL_NOR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = ~(index[i] | dest[i]);
- }
- }
- break;
- case GL_XOR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] ^= dest[i];
- }
- }
- break;
- case GL_EQUIV:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = ~(index[i] ^ dest[i]);
- }
- }
- break;
- case GL_AND_REVERSE:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = index[i] & ~dest[i];
- }
- }
- break;
- case GL_AND_INVERTED:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = ~index[i] & dest[i];
- }
- }
- break;
- case GL_OR_REVERSE:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = index[i] | ~dest[i];
- }
- }
- break;
- case GL_OR_INVERTED:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- index[i] = ~index[i] | dest[i];
- }
- }
- break;
- default:
- _mesa_problem(ctx, "bad mode in index_logic()");
- }
+ LOGIC_OP_LOOP(ctx->Color.LogicOp);
+}
+
+
+static void
+logicop_ushort(GLcontext *ctx, GLuint n, GLushort src[], const GLushort dest[],
+ const GLubyte mask[])
+{
+ LOGIC_OP_LOOP(ctx->Color.LogicOp);
+}
+
+
+static void
+logicop_uint(GLcontext *ctx, GLuint n, GLuint src[], const GLuint dest[],
+ const GLubyte mask[])
+{
+ LOGIC_OP_LOOP(ctx->Color.LogicOp);
}
@@ -165,305 +182,35 @@ index_logicop( GLcontext *ctx, GLuint n, GLuint index[], const GLuint dest[],
* used if the device driver can't do logic ops.
*/
void
-_swrast_logicop_ci_span( GLcontext *ctx, const struct sw_span *span,
- GLuint index[] )
+_swrast_logicop_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLuint index[])
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint dest[MAX_WIDTH];
ASSERT(span->end < MAX_WIDTH);
/* Read dest values from frame buffer */
if (span->arrayMask & SPAN_XY) {
- (*swrast->Driver.ReadCI32Pixels)( ctx, span->end,
- span->array->x, span->array->y,
- dest, span->array->mask );
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetValues(ctx, rb, span->end, span->array->x, span->array->y, dest);
}
else {
- (*swrast->Driver.ReadCI32Span)( ctx, span->end, span->x, span->y, dest );
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetRow(ctx, rb, span->end, span->x, span->y, dest);
}
- index_logicop( ctx, span->end, index, dest, span->array->mask );
+ logicop_uint(ctx, span->end, index, dest, span->array->mask);
}
-
-/*
- * Apply logic operator to rgba pixels.
- * Input: ctx - the context
- * n - number of pixels
- * mask - pixel mask array
- * In/Out: src - incoming pixels which will be modified
- * Input: dest - frame buffer values
- *
- * Note: Since the R, G, B, and A channels are all treated the same we
- * process them as 4-byte GLuints instead of four GLubytes.
- */
-static void
-rgba_logicop_ui( const GLcontext *ctx, GLuint n, const GLubyte mask[],
- GLuint src[], const GLuint dest[] )
-{
- GLuint i;
- switch (ctx->Color.LogicOp) {
- case GL_CLEAR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = 0;
- }
- }
- break;
- case GL_SET:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~0;
- }
- }
- break;
- case GL_COPY:
- /* do nothing */
- break;
- case GL_COPY_INVERTED:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~src[i];
- }
- }
- break;
- case GL_NOOP:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = dest[i];
- }
- }
- break;
- case GL_INVERT:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~dest[i];
- }
- }
- break;
- case GL_AND:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] &= dest[i];
- }
- }
- break;
- case GL_NAND:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~(src[i] & dest[i]);
- }
- }
- break;
- case GL_OR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i]|= dest[i];
- }
- }
- break;
- case GL_NOR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~(src[i] | dest[i]);
- }
- }
- break;
- case GL_XOR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] ^= dest[i];
- }
- }
- break;
- case GL_EQUIV:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~(src[i] ^ dest[i]);
- }
- }
- break;
- case GL_AND_REVERSE:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = src[i] & ~dest[i];
- }
- }
- break;
- case GL_AND_INVERTED:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~src[i] & dest[i];
- }
- }
- break;
- case GL_OR_REVERSE:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = src[i] | ~dest[i];
- }
- }
- break;
- case GL_OR_INVERTED:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~src[i] | dest[i];
- }
- }
- break;
- default:
- /* should never happen */
- _mesa_problem(ctx, "Bad function in rgba_logicop");
- }
-}
-
-
-/*
- * As above, but operate on GLchan values
- * Note: need to pass n = numPixels * 4.
- */
-static void
-rgba_logicop_chan( const GLcontext *ctx, GLuint n, const GLubyte mask[],
- GLchan srcPtr[], const GLchan destPtr[] )
-{
-#if CHAN_TYPE == GL_FLOAT
- GLuint *src = (GLuint *) srcPtr;
- const GLuint *dest = (const GLuint *) destPtr;
- GLuint i;
- ASSERT(sizeof(GLfloat) == sizeof(GLuint));
-#else
- GLchan *src = srcPtr;
- const GLchan *dest = destPtr;
- GLuint i;
-#endif
-
- switch (ctx->Color.LogicOp) {
- case GL_CLEAR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = 0;
- }
- }
- break;
- case GL_SET:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~0;
- }
- }
- break;
- case GL_COPY:
- /* do nothing */
- break;
- case GL_COPY_INVERTED:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~src[i];
- }
- }
- break;
- case GL_NOOP:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = dest[i];
- }
- }
- break;
- case GL_INVERT:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~dest[i];
- }
- }
- break;
- case GL_AND:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] &= dest[i];
- }
- }
- break;
- case GL_NAND:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~(src[i] & dest[i]);
- }
- }
- break;
- case GL_OR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i]|= dest[i];
- }
- }
- break;
- case GL_NOR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~(src[i] | dest[i]);
- }
- }
- break;
- case GL_XOR:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] ^= dest[i];
- }
- }
- break;
- case GL_EQUIV:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~(src[i] ^ dest[i]);
- }
- }
- break;
- case GL_AND_REVERSE:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = src[i] & ~dest[i];
- }
- }
- break;
- case GL_AND_INVERTED:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~src[i] & dest[i];
- }
- }
- break;
- case GL_OR_REVERSE:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = src[i] | ~dest[i];
- }
- }
- break;
- case GL_OR_INVERTED:
- for (i=0;i<n;i++) {
- if (mask[i]) {
- src[i] = ~src[i] | dest[i];
- }
- }
- break;
- default:
- /* should never happen */
- _mesa_problem(ctx, "Bad function in rgba_logicop");
- }
-}
-
-
-
-/*
+/**
* Apply the current logic operator to a span of RGBA pixels.
* We can handle horizontal runs of pixels (spans) or arrays of x/y
* pixel coordinates.
*/
void
-_swrast_logicop_rgba_span( GLcontext *ctx, const struct sw_span *span,
- GLchan rgba[][4] )
+_swrast_logicop_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4])
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan dest[MAX_WIDTH][4];
@@ -472,26 +219,27 @@ _swrast_logicop_rgba_span( GLcontext *ctx, const struct sw_span *span,
ASSERT(span->arrayMask & SPAN_RGBA);
if (span->arrayMask & SPAN_XY) {
- (*swrast->Driver.ReadRGBAPixels)(ctx, span->end,
- span->array->x, span->array->y,
- dest, span->array->mask);
- if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
- _swrast_read_alpha_pixels(ctx, span->end,
- span->array->x, span->array->y,
- dest, span->array->mask);
- }
+ swrast->Driver.ReadRGBAPixels(ctx, rb, span->end,
+ span->array->x, span->array->y,
+ dest, span->array->mask);
}
else {
- _swrast_read_rgba_span(ctx, ctx->DrawBuffer, span->end,
- span->x, span->y, dest);
+ _swrast_read_rgba_span(ctx, rb, span->end, span->x, span->y, dest);
}
- if (sizeof(GLchan) * 4 == sizeof(GLuint)) {
- rgba_logicop_ui(ctx, span->end, span->array->mask,
- (GLuint *) rgba, (const GLuint *) dest);
- }
- else {
- rgba_logicop_chan(ctx, 4 * span->end, span->array->mask,
- (GLchan *) rgba, (const GLchan *) dest);
- }
+ /* NEW_RENDERBUFFER: XXX make this a runtime test */
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ /* treat 4*GLubyte as GLuint */
+ logicop_uint(ctx, span->end, (GLuint *) rgba,
+ (const GLuint *) dest, span->array->mask);
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ logicop_ushort(ctx, 4 * span->end, (GLushort *) rgba,
+ (const GLushort *) dest, span->array->mask);
+#elif CHAN_TYPE == GL_FLOAT
+ logicop_uint(ctx, 4 * span->end, (GLuint *) rgba,
+ (const GLuint *) dest, span->array->mask);
+#endif
+ (void) logicop_ubyte;
+ (void) logicop_ushort;
+ (void) logicop_uint;
}
diff --git a/src/mesa/swrast/s_logic.h b/src/mesa/swrast/s_logic.h
index 19ec9c3246..ce5f183ff6 100644
--- a/src/mesa/swrast/s_logic.h
+++ b/src/mesa/swrast/s_logic.h
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2002 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"),
@@ -33,13 +32,13 @@
extern void
-_swrast_logicop_ci_span( GLcontext *ctx, const struct sw_span *span,
- GLuint index[] );
+_swrast_logicop_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLuint index[]);
extern void
-_swrast_logicop_rgba_span( GLcontext *ctx, const struct sw_span *span,
- GLchan rgba[][4] );
+_swrast_logicop_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4]);
#endif
diff --git a/src/mesa/swrast/s_masking.c b/src/mesa/swrast/s_masking.c
index 3badb86007..d5f60a6958 100644
--- a/src/mesa/swrast/s_masking.c
+++ b/src/mesa/swrast/s_masking.c
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2002 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"),
@@ -33,7 +32,6 @@
#include "enums.h"
#include "macros.h"
-#include "s_alphabuf.h"
#include "s_context.h"
#include "s_masking.h"
#include "s_span.h"
@@ -41,8 +39,8 @@
void
-_swrast_mask_rgba_span( GLcontext *ctx, const struct sw_span *span,
- GLchan rgba[][4] )
+_swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4])
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan dest[MAX_WIDTH][4];
@@ -64,15 +62,16 @@ _swrast_mask_rgba_span( GLcontext *ctx, const struct sw_span *span,
ASSERT(span->arrayMask & SPAN_RGBA);
if (span->arrayMask & SPAN_XY) {
- (*swrast->Driver.ReadRGBAPixels)(ctx, n, span->array->x, span->array->y,
+#if OLD_RENDERBUFFER
+ if (swrast->Driver.ReadRGBAPixels)
+ swrast->Driver.ReadRGBAPixels(ctx, rb, n, span->array->x, span->array->y,
dest, span->array->mask);
- if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
- _swrast_read_alpha_pixels(ctx, n, span->array->x, span->array->y,
- dest, span->array->mask);
- }
+ else
+#endif
+ rb->GetValues(ctx, rb, n, span->array->x, span->array->y, dest);
}
else {
- _swrast_read_rgba_span(ctx, ctx->DrawBuffer, n, span->x, span->y, dest);
+ _swrast_read_rgba_span(ctx, rb, n, span->x, span->y, dest);
}
#if CHAN_BITS == 8
@@ -90,14 +89,12 @@ _swrast_mask_rgba_span( GLcontext *ctx, const struct sw_span *span,
}
-
-
/*
* Apply glColorMask to a span of RGBA pixels.
*/
void
-_swrast_mask_rgba_array( GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLchan rgba[][4] )
+_swrast_mask_rgba_array(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLchan rgba[][4])
{
GLchan dest[MAX_WIDTH][4];
GLuint i;
@@ -109,7 +106,7 @@ _swrast_mask_rgba_array( GLcontext *ctx,
GLuint *rgba32 = (GLuint *) rgba;
GLuint *dest32 = (GLuint *) dest;
- _swrast_read_rgba_span( ctx, ctx->DrawBuffer, n, x, y, dest );
+ _swrast_read_rgba_span( ctx, rb, n, x, y, dest );
for (i = 0; i < n; i++) {
rgba32[i] = (rgba32[i] & srcMask) | (dest32[i] & dstMask);
}
@@ -135,57 +132,46 @@ _swrast_mask_rgba_array( GLcontext *ctx,
void
-_swrast_mask_index_span( GLcontext *ctx, const struct sw_span *span,
- GLuint index[] )
+_swrast_mask_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLuint index[])
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLuint msrc = ctx->Color.IndexMask;
- const GLuint mdest = ~msrc;
- GLuint fbindexes[MAX_WIDTH];
+ const GLuint srcMask = ctx->Color.IndexMask;
+ const GLuint dstMask = ~srcMask;
+ GLuint dest[MAX_WIDTH];
GLuint i;
ASSERT(span->arrayMask & SPAN_INDEX);
ASSERT(span->end < MAX_WIDTH);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
if (span->arrayMask & SPAN_XY) {
-
- (*swrast->Driver.ReadCI32Pixels)(ctx, span->end, span->array->x,
- span->array->y, fbindexes,
- span->array->mask);
-
- for (i = 0; i < span->end; i++) {
- index[i] = (index[i] & msrc) | (fbindexes[i] & mdest);
- }
+ rb->GetValues(ctx, rb, span->end, span->array->x, span->array->y, dest);
}
else {
- _swrast_read_index_span(ctx, ctx->DrawBuffer, span->end, span->x, span->y,
- fbindexes );
+ _swrast_read_index_span(ctx, rb, span->end, span->x, span->y, dest);
+ }
- for (i = 0; i < span->end; i++) {
- index[i] = (index[i] & msrc) | (fbindexes[i] & mdest);
- }
+ for (i = 0; i < span->end; i++) {
+ index[i] = (index[i] & srcMask) | (dest[i] & dstMask);
}
}
-
/*
- * Apply glIndexMask to a span of CI pixels.
+ * Apply glIndexMask to an array of CI pixels.
*/
void
-_swrast_mask_index_array( GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLuint index[] )
+_swrast_mask_ci_array(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint index[])
{
+ const GLuint srcMask = ctx->Color.IndexMask;
+ const GLuint dstMask = ~srcMask;
+ GLuint dest[MAX_WIDTH];
GLuint i;
- GLuint fbindexes[MAX_WIDTH];
- GLuint msrc, mdest;
-
- _swrast_read_index_span( ctx, ctx->DrawBuffer, n, x, y, fbindexes );
- msrc = ctx->Color.IndexMask;
- mdest = ~msrc;
+ _swrast_read_index_span(ctx, rb, n, x, y, dest);
for (i=0;i<n;i++) {
- index[i] = (index[i] & msrc) | (fbindexes[i] & mdest);
+ index[i] = (index[i] & srcMask) | (dest[i] & dstMask);
}
}
diff --git a/src/mesa/swrast/s_masking.h b/src/mesa/swrast/s_masking.h
index 965e9f2180..e2265448f8 100644
--- a/src/mesa/swrast/s_masking.h
+++ b/src/mesa/swrast/s_masking.h
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2002 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"),
@@ -36,26 +35,24 @@
* Implement glColorMask for a span of RGBA pixels.
*/
extern void
-_swrast_mask_rgba_span( GLcontext *ctx, const struct sw_span *span,
- GLchan rgba[][4] );
+_swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4]);
extern void
-_swrast_mask_rgba_array( GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLchan rgba[][4] );
+_swrast_mask_rgba_array(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLchan rgba[][4]);
/*
* Implement glIndexMask for a span of CI pixels.
*/
extern void
-_swrast_mask_index_span( GLcontext *ctx, const struct sw_span *span,
- GLuint index[] );
-
+_swrast_mask_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLuint index[]);
extern void
-_swrast_mask_index_array( GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLuint index[] );
-
+_swrast_mask_ci_array(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint index[]);
#endif
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index 51d36c0a2b..1cd1bdaf49 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -207,13 +207,13 @@ fetch_vector4_deriv( GLcontext *ctx,
if (xOrY == 'X') {
src[0] = 1.0;
src[1] = 0.0;
- src[2] = span->dzdx / ctx->DepthMaxF;
+ src[2] = span->dzdx / ctx->DrawBuffer->_DepthMaxF;
src[3] = span->dwdx;
}
else {
src[0] = 0.0;
src[1] = 1.0;
- src[2] = span->dzdy / ctx->DepthMaxF;
+ src[2] = span->dzdy / ctx->DrawBuffer->_DepthMaxF;
src[3] = span->dwdy;
}
break;
@@ -1180,6 +1180,8 @@ execute_program( GLcontext *ctx,
* while the NV extension says it's implementation dependant.
*/
fetch_texel( ctx, texcoord, 0.0F, inst->TexSrcUnit, color );
+ if (color[3])
+ printf("color[3] = %f\n", color[3]);
store_vector4( inst, machine, color );
}
break;
@@ -1362,7 +1364,7 @@ init_machine( GLcontext *ctx, struct fp_machine *machine,
GLfloat *wpos = machine->Inputs[FRAG_ATTRIB_WPOS];
wpos[0] = (GLfloat) span->x + col;
wpos[1] = (GLfloat) span->y;
- wpos[2] = (GLfloat) span->array->z[col] / ctx->DepthMaxF;
+ wpos[2] = (GLfloat) span->array->z[col] / ctx->DrawBuffer->_DepthMaxF;
wpos[3] = span->w + col * span->dwdx;
}
if (inputsRead & (1 << FRAG_ATTRIB_COL0)) {
@@ -1444,7 +1446,7 @@ _swrast_exec_fragment_program( GLcontext *ctx, struct sw_span *span )
}
/* depth value */
if (program->OutputsWritten & (1 << FRAG_OUTPUT_DEPR))
- span->array->z[i] = IROUND(ctx->FragmentProgram.Machine.Outputs[FRAG_OUTPUT_DEPR][0] * ctx->DepthMaxF);
+ span->array->z[i] = IROUND(ctx->FragmentProgram.Machine.Outputs[FRAG_OUTPUT_DEPR][0] * ctx->DrawBuffer->_DepthMaxF);
}
}
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 7d8112fb9b..559fed5da6 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -34,7 +34,6 @@
#include "imports.h"
#include "pixel.h"
-#include "s_alphabuf.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_span.h"
@@ -52,7 +51,10 @@ read_index_pixels( GLcontext *ctx,
GLenum type, GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
+ struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ /*
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ */
GLint i, readWidth;
/* error checking */
@@ -81,8 +83,8 @@ read_index_pixels( GLcontext *ctx,
for (i = 0; i < height; i++) {
GLuint index[MAX_WIDTH];
GLvoid *dest;
-
- (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y + i, index);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetRow(ctx, rb, readWidth, x, y + i, index);
dest = _mesa_image_address2d(packing, pixels, width, height,
GL_COLOR_INDEX, type, i, 0);
@@ -106,9 +108,16 @@ read_depth_pixels( GLcontext *ctx,
GLenum type, GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
+ struct gl_renderbuffer *rb
+ = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
GLint readWidth;
GLboolean bias_or_scale;
+ if (!rb) {
+ /* no readbuffer - OK */
+ return;
+ }
+
/* Error checking */
if (ctx->Visual.depthBits <= 0) {
/* No depth buffer */
@@ -116,9 +125,6 @@ read_depth_pixels( GLcontext *ctx,
return;
}
- /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
- readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
-
if (type != GL_BYTE &&
type != GL_UNSIGNED_BYTE &&
type != GL_SHORT &&
@@ -130,6 +136,9 @@ read_depth_pixels( GLcontext *ctx,
return;
}
+ /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
+ readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+
bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0;
if (type==GL_UNSIGNED_SHORT && ctx->Visual.depthBits == 16
@@ -141,7 +150,7 @@ read_depth_pixels( GLcontext *ctx,
GLushort *dst = (GLushort*) _mesa_image_address2d(packing, pixels,
width, height, GL_DEPTH_COMPONENT, type, j, 0);
GLint i;
- _swrast_read_depth_span(ctx, width, x, y, depth);
+ _swrast_read_depth_span(ctx, rb, width, x, y, depth);
for (i = 0; i < width; i++)
dst[i] = depth[i];
}
@@ -153,7 +162,7 @@ read_depth_pixels( GLcontext *ctx,
for (j=0;j<height;j++,y++) {
GLdepth *dst = (GLdepth *) _mesa_image_address2d(packing, pixels,
width, height, GL_DEPTH_COMPONENT, type, j, 0);
- _swrast_read_depth_span(ctx, width, x, y, dst);
+ _swrast_read_depth_span(ctx, rb, width, x, y, dst);
}
}
else {
@@ -163,7 +172,7 @@ read_depth_pixels( GLcontext *ctx,
GLfloat depth[MAX_WIDTH];
GLvoid *dest;
- _swrast_read_depth_span_float(ctx, readWidth, x, y, depth);
+ _swrast_read_depth_span_float(ctx, rb, readWidth, x, y, depth);
dest = _mesa_image_address2d(packing, pixels, width, height,
GL_DEPTH_COMPONENT, type, j, 0);
@@ -185,8 +194,15 @@ read_stencil_pixels( GLcontext *ctx,
GLenum type, GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
+ struct gl_renderbuffer *rb
+ = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
GLint j, readWidth;
+ if (!rb) {
+ /* no readbuffer - OK */
+ return;
+ }
+
if (type != GL_BYTE &&
type != GL_UNSIGNED_BYTE &&
type != GL_SHORT &&
@@ -199,21 +215,21 @@ read_stencil_pixels( GLcontext *ctx,
return;
}
- /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
- readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
-
if (ctx->Visual.stencilBits <= 0) {
/* No stencil buffer */
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels" );
return;
}
+ /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
+ readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+
/* process image row by row */
for (j=0;j<height;j++,y++) {
GLvoid *dest;
GLstencil stencil[MAX_WIDTH];
- _swrast_read_stencil_span(ctx, readWidth, x, y, stencil);
+ _swrast_read_stencil_span(ctx, rb, readWidth, x, y, stencil);
dest = _mesa_image_address2d(packing, pixels, width, height,
GL_STENCIL_INDEX, type, j, 0);
@@ -237,7 +253,7 @@ read_fast_rgba_pixels( GLcontext *ctx,
GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
/* can't do scale, bias, mapping, etc */
if (ctx->_ImageTransferState)
return GL_FALSE;
@@ -285,12 +301,16 @@ read_fast_rgba_pixels( GLcontext *ctx,
}
for (row=0; row<readHeight; row++) {
- (*swrast->Driver.ReadRGBASpan)(ctx, readWidth, srcX, srcY,
+#if OLD_RENDERBUFFER && 0
+ (*swrast->Driver.ReadRGBASpan)(ctx, rb, readWidth, srcX, srcY,
(GLchan (*)[4]) dest);
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) {
_swrast_read_alpha_span(ctx, readWidth, srcX, srcY,
(GLchan (*)[4]) dest);
}
+#else
+ rb->GetRow(ctx, rb, readWidth, srcX, srcY, dest);
+#endif
dest += rowLength * 4;
srcY++;
}
@@ -315,22 +335,17 @@ read_rgba_pixels( GLcontext *ctx,
GLenum format, GLenum type, GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
+ struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ /*
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ */
GLint readWidth;
- _swrast_use_read_buffer(ctx);
-
- /* Try optimized path first */
- if (read_fast_rgba_pixels( ctx, x, y, width, height,
- format, type, pixels, packing )) {
-
- _swrast_use_draw_buffer(ctx);
- return; /* done! */
+ if (!rb) {
+ /* No readbuffer is OK with GL_EXT_framebuffer_object */
+ return;
}
- /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
- readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
-
/* do error checking on pixel type, format was already checked by caller */
switch (type) {
case GL_UNSIGNED_BYTE:
@@ -371,6 +386,20 @@ read_rgba_pixels( GLcontext *ctx,
return;
}
+ _swrast_use_read_buffer(ctx);
+
+ /* Try optimized path first */
+ if (read_fast_rgba_pixels( ctx, x, y, width, height,
+ format, type, pixels, packing )) {
+
+ _swrast_use_draw_buffer(ctx);
+ return; /* done! */
+ }
+
+ /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
+ readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+
+
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
const GLuint transferOps = ctx->_ImageTransferState;
GLfloat *dest, *src, *tmpImage, *convImage;
@@ -393,11 +422,12 @@ read_rgba_pixels( GLcontext *ctx,
for (row = 0; row < height; row++, y++) {
GLchan rgba[MAX_WIDTH][4];
if (ctx->Visual.rgbMode) {
- _swrast_read_rgba_span(ctx, ctx->ReadBuffer, readWidth, x, y, rgba);
+ _swrast_read_rgba_span(ctx, rb, readWidth, x, y, rgba);
}
else {
GLuint index[MAX_WIDTH];
- (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetRow(ctx, rb, readWidth, x, y, index);
if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset !=0 ) {
_mesa_map_ci(ctx, readWidth, index);
}
@@ -439,11 +469,12 @@ read_rgba_pixels( GLcontext *ctx,
GLchan rgba[MAX_WIDTH][4];
GLvoid *dst;
if (ctx->Visual.rgbMode) {
- _swrast_read_rgba_span(ctx, ctx->ReadBuffer, readWidth, x, y, rgba);
+ _swrast_read_rgba_span(ctx, rb, readWidth, x, y, rgba);
}
else {
GLuint index[MAX_WIDTH];
- (*swrast->Driver.ReadCI32Span)(ctx, readWidth, x, y, index);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetRow(ctx, rb, readWidth, x, y, index);
if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset != 0) {
_mesa_map_ci(ctx, readWidth, index);
}
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index e6afee1eaa..6019eff990 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* 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"),
@@ -38,7 +38,6 @@
#include "s_atifragshader.h"
#include "s_alpha.h"
-#include "s_alphabuf.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_depth.h"
@@ -58,10 +57,11 @@
void
_swrast_span_default_z( GLcontext *ctx, struct sw_span *span )
{
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
if (ctx->Visual.depthBits <= 16)
- span->z = FloatToFixed(ctx->Current.RasterPos[2] * ctx->DepthMax + 0.5F);
+ span->z = FloatToFixed(ctx->Current.RasterPos[2] * depthMax + 0.5F);
else
- span->z = (GLint) (ctx->Current.RasterPos[2] * ctx->DepthMax + 0.5F);
+ span->z = (GLint) (ctx->Current.RasterPos[2] * depthMax + 0.5F);
span->zStep = 0;
span->interpMask |= SPAN_Z;
}
@@ -235,6 +235,7 @@ interpolate_indexes(GLcontext *ctx, struct sw_span *span)
}
}
span->arrayMask |= SPAN_INDEX;
+ span->interpMask &= ~SPAN_INDEX;
}
@@ -761,141 +762,22 @@ clip_span( GLcontext *ctx, struct sw_span *span )
}
-
/**
- * Draw to more than one color buffer (or none).
- */
-static void
-multi_write_index_span( GLcontext *ctx, struct sw_span *span )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLuint bufferBit;
-
- /* loop over four possible dest color buffers */
- for (bufferBit = 1; bufferBit <= 8; bufferBit <<= 1) {
- if (bufferBit & ctx->Color._DrawDestMask[0]) {
- GLuint indexTmp[MAX_WIDTH];
- ASSERT(span->end < MAX_WIDTH);
-
- /* Set the current read/draw buffer */
- swrast->CurrentBufferBit = bufferBit;
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, bufferBit);
-
- /* make copy of incoming indexes */
- MEMCPY( indexTmp, span->array->index, span->end * sizeof(GLuint) );
-
- if (ctx->Color.IndexLogicOpEnabled) {
- _swrast_logicop_ci_span(ctx, span, indexTmp);
- }
-
- if (ctx->Color.IndexMask != 0xffffffff) {
- _swrast_mask_index_span(ctx, span, indexTmp);
- }
-
- if (span->arrayMask & SPAN_XY) {
- /* array of pixel coords */
- (*swrast->Driver.WriteCI32Pixels)(ctx, span->end,
- span->array->x, span->array->y,
- indexTmp, span->array->mask);
- }
- else {
- /* horizontal run of pixels */
- (*swrast->Driver.WriteCI32Span)(ctx, span->end, span->x, span->y,
- indexTmp, span->array->mask);
- }
- }
- }
-
- /* restore default dest buffer */
- _swrast_use_draw_buffer(ctx);
-}
-
-
-/**
- * Draw to more than one RGBA color buffer (or none).
- * All fragment operations, up to (but not) blending/logicop should
- * have been done first.
- */
-static void
-multi_write_rgba_span( GLcontext *ctx, struct sw_span *span )
-{
- const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
- GLuint bufferBit;
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- ASSERT(colorMask != 0x0);
-
- if (ctx->Color.DrawBuffer == GL_NONE)
- return;
-
- /* loop over four possible dest color buffers */
- for (bufferBit = 1; bufferBit <= 8; bufferBit <<= 1) {
- if (bufferBit & ctx->Color._DrawDestMask[0]) {
- GLchan rgbaTmp[MAX_WIDTH][4];
- ASSERT(span->end < MAX_WIDTH);
-
- /* Set the current read/draw buffer */
- swrast->CurrentBufferBit = bufferBit;
- (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, bufferBit);
-
- /* make copy of incoming colors */
- MEMCPY( rgbaTmp, span->array->rgba, 4 * span->end * sizeof(GLchan) );
-
- if (ctx->Color._LogicOpEnabled) {
- _swrast_logicop_rgba_span(ctx, span, rgbaTmp);
- }
- else if (ctx->Color.BlendEnabled) {
- _swrast_blend_span(ctx, span, rgbaTmp);
- }
-
- if (colorMask != 0xffffffff) {
- _swrast_mask_rgba_span(ctx, span, rgbaTmp);
- }
-
- if (span->arrayMask & SPAN_XY) {
- /* array of pixel coords */
- (*swrast->Driver.WriteRGBAPixels)(ctx, span->end,
- span->array->x, span->array->y,
- (const GLchan (*)[4]) rgbaTmp,
- span->array->mask);
- if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
- _swrast_write_alpha_pixels(ctx, span->end,
- span->array->x, span->array->y,
- (const GLchan (*)[4]) rgbaTmp,
- span->array->mask);
- }
- }
- else {
- /* horizontal run of pixels */
- (*swrast->Driver.WriteRGBASpan)(ctx, span->end, span->x, span->y,
- (const GLchan (*)[4]) rgbaTmp,
- span->array->mask);
- if (swrast->_RasterMask & ALPHABUF_BIT) {
- _swrast_write_alpha_span(ctx, span->end, span->x, span->y,
- (const GLchan (*)[4]) rgbaTmp,
- span->array->mask);
- }
- }
- }
- }
-
- /* restore default dest buffer */
- _swrast_use_draw_buffer(ctx);
-}
-
-
-
-/**
- * This function may modify any of the array values in the span.
+ * Apply all the per-fragment opertions to a span of color index fragments
+ * and write them to the enabled color drawbuffers.
+ * The 'span' parameter can be considered to be const. Note that
* span->interpMask and span->arrayMask may be changed but will be restored
* to their original values before returning.
*/
void
_swrast_write_index_span( GLcontext *ctx, struct sw_span *span)
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const struct gl_framebuffer *fb = ctx->DrawBuffer;
+ const GLuint output = 0;
const GLuint origInterpMask = span->interpMask;
const GLuint origArrayMask = span->arrayMask;
+ GLuint buf;
ASSERT(span->end <= MAX_WIDTH);
ASSERT(span->primitive == GL_POINT || span->primitive == GL_LINE ||
@@ -946,7 +828,7 @@ _swrast_write_index_span( GLcontext *ctx, struct sw_span *span)
stipple_polygon_span(ctx, span);
}
- /* Depth test and stencil */
+ /* Stencil and Z testing */
if (ctx->Depth.Test || ctx->Stencil.Enabled) {
if (span->interpMask & SPAN_Z)
_swrast_span_interpolate_z(ctx, span);
@@ -960,6 +842,7 @@ _swrast_write_index_span( GLcontext *ctx, struct sw_span *span)
else {
ASSERT(ctx->Depth.Test);
if (!_swrast_depth_test_span(ctx, span)) {
+ span->interpMask = origInterpMask;
span->arrayMask = origArrayMask;
return;
}
@@ -988,10 +871,13 @@ _swrast_write_index_span( GLcontext *ctx, struct sw_span *span)
}
/* Interpolate the color indexes if needed */
- if (span->interpMask & SPAN_INDEX) {
- interpolate_indexes(ctx, span);
- /* clear the bit - this allows the WriteMonoCISpan optimization below */
- span->interpMask &= ~SPAN_INDEX;
+ if (ctx->Fog.Enabled ||
+ ctx->Color.IndexLogicOpEnabled ||
+ ctx->Color.IndexMask != 0xffffffff ||
+ (span->arrayMask & SPAN_COVERAGE)) {
+ if (span->interpMask & SPAN_INDEX) {
+ interpolate_indexes(ctx, span);
+ }
}
/* Fog */
@@ -1001,61 +887,111 @@ _swrast_write_index_span( GLcontext *ctx, struct sw_span *span)
/* Antialias coverage application */
if (span->arrayMask & SPAN_COVERAGE) {
- GLuint i;
+ const GLfloat *coverage = span->array->coverage;
GLuint *index = span->array->index;
- GLfloat *coverage = span->array->coverage;
+ GLuint i;
for (i = 0; i < span->end; i++) {
ASSERT(coverage[i] < 16);
index[i] = (index[i] & ~0xf) | ((GLuint) coverage[i]);
}
}
- if (swrast->_RasterMask & MULTI_DRAW_BIT) {
- /* draw to zero or two or more buffers */
- multi_write_index_span(ctx, span);
- }
- else {
- /* normal situation: draw to exactly one buffer */
- if (ctx->Color.IndexLogicOpEnabled) {
- _swrast_logicop_ci_span(ctx, span, span->array->index);
- }
+ /* Loop over drawing buffers */
+ for (buf = 0; buf < fb->_NumColorDrawBuffers[output]; buf++) {
+ struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[output][buf];
+ GLuint indexTemp[MAX_WIDTH], *index32;
+
+ ASSERT(rb->_BaseFormat == GL_COLOR_INDEX);
+
+ if (ctx->Color.IndexLogicOpEnabled ||
+ ctx->Color.IndexMask != 0xffffffff) {
+ /* make copy of incoming indexes */
+ MEMCPY(indexTemp, span->array->index, span->end * sizeof(GLuint));
- if (ctx->Color.IndexMask != 0xffffffff) {
- _swrast_mask_index_span(ctx, span, span->array->index);
+ if (ctx->Color.IndexLogicOpEnabled) {
+ _swrast_logicop_ci_span(ctx, rb, span, indexTemp);
+ }
+
+ if (ctx->Color.IndexMask != 0xffffffff) {
+ _swrast_mask_ci_span(ctx, rb, span, indexTemp);
+ }
+ index32 = indexTemp;
+ }
+ else {
+ index32 = span->array->index;
}
- /* write pixels */
- if (span->arrayMask & SPAN_XY) {
- /* array of pixel coords */
- if ((span->interpMask & SPAN_INDEX) && span->indexStep == 0) {
- /* all pixels have same color index */
- (*swrast->Driver.WriteMonoCIPixels)(ctx, span->end,
- span->array->x, span->array->y,
- FixedToInt(span->index),
- span->array->mask);
+ if ((span->interpMask & SPAN_INDEX) && span->indexStep == 0) {
+ /* all fragments have same color index */
+ GLubyte index8;
+ GLushort index16;
+ GLuint index32;
+ void *value;
+
+ if (rb->DataType == GL_UNSIGNED_BYTE) {
+ index8 = FixedToInt(span->index);
+ value = &index8;
+ }
+ else if (rb->DataType == GL_UNSIGNED_SHORT) {
+ index16 = FixedToInt(span->index);
+ value = &index16;
}
else {
- (*swrast->Driver.WriteCI32Pixels)(ctx, span->end, span->array->x,
- span->array->y, span->array->index,
- span->array->mask );
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ index32 = FixedToInt(span->index);
+ value = &index32;
+ }
+
+ if (span->arrayMask & SPAN_XY) {
+ rb->PutMonoValues(ctx, rb, span->end, span->array->x,
+ span->array->y, value, span->array->mask);
+ }
+ else {
+ rb->PutMonoRow(ctx, rb, span->end, span->x, span->y,
+ value, span->array->mask);
}
}
else {
- /* horizontal run of pixels */
- if ((span->interpMask & SPAN_INDEX) && span->indexStep == 0) {
- /* all pixels have same color index */
- (*swrast->Driver.WriteMonoCISpan)(ctx, span->end, span->x, span->y,
- FixedToInt(span->index),
- span->array->mask);
+ /* each fragment is a different color */
+ GLubyte index8[MAX_WIDTH];
+ GLushort index16[MAX_WIDTH];
+ void *values;
+
+ if (rb->DataType == GL_UNSIGNED_BYTE) {
+ GLuint k;
+ for (k = 0; k < span->end; k++) {
+ index8[k] = (GLubyte) index32[k];
+ }
+ values = index8;
+ }
+ else if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLuint k;
+ for (k = 0; k < span->end; k++) {
+ index16[k] = (GLushort) index32[k];
+ }
+ values = index16;
}
else {
- (*swrast->Driver.WriteCI32Span)(ctx, span->end, span->x, span->y,
- span->array->index,
- span->array->mask);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ values = index32;
+ }
+
+ if (span->arrayMask & SPAN_XY) {
+ rb->PutValues(ctx, rb, span->end, span->array->x, span->array->y,
+ values, span->array->mask);
+ }
+ else {
+ rb->PutRow(ctx, rb, span->end, span->x, span->y,
+ values, span->array->mask);
}
}
}
+#if OLD_RENDERBUFFER
+ /* restore default dest buffer */
+ _swrast_use_draw_buffer(ctx);
+#endif
+
span->interpMask = origInterpMask;
span->arrayMask = origArrayMask;
}
@@ -1088,6 +1024,88 @@ add_colors(GLuint n, GLchan rgba[][4], GLchan specular[][4] )
/**
+ * XXX merge this code into the _swrast_write_rgba_span() routine!
+ *
+ * Draw to more than one RGBA color buffer (or none).
+ * All fragment operations, up to (but not) blending/logicop should
+ * have been done first.
+ */
+static void
+multi_write_rgba_span( GLcontext *ctx, struct sw_span *span )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ const GLuint output = 0;
+ GLuint i;
+
+ ASSERT(span->end < MAX_WIDTH);
+ ASSERT(colorMask != 0x0);
+
+ for (i = 0; i < fb->_NumColorDrawBuffers[output]; i++) {
+ struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[output][i];
+ GLchan rgbaTmp[MAX_WIDTH][4];
+
+#if OLD_RENDERBUFFER /* obsolete code */
+ GLuint bufferBit = fb->_ColorDrawBit[output][i];
+ /* Set the current read/draw buffer */
+ swrast->CurrentBufferBit = bufferBit;
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, bufferBit);
+#endif
+
+ /* make copy of incoming colors */
+ MEMCPY( rgbaTmp, span->array->rgba, 4 * span->end * sizeof(GLchan) );
+
+ if (ctx->Color._LogicOpEnabled) {
+ _swrast_logicop_rgba_span(ctx, rb, span, rgbaTmp);
+ }
+ else if (ctx->Color.BlendEnabled) {
+ _swrast_blend_span(ctx, rb, span, rgbaTmp);
+ }
+
+ if (colorMask != 0xffffffff) {
+ _swrast_mask_rgba_span(ctx, rb, span, rgbaTmp);
+ }
+
+ if (span->arrayMask & SPAN_XY) {
+ /* array of pixel coords */
+ if (rb->PutValues) {
+ rb->PutValues(ctx, rb, span->end, span->array->x,
+ span->array->y, rgbaTmp, span->array->mask);
+ }
+#if OLD_RENDERBUFFER
+ else {
+ swrast->Driver.WriteRGBAPixels(ctx, rb, span->end,
+ span->array->x, span->array->y,
+ (const GLchan (*)[4]) rgbaTmp,
+ span->array->mask);
+ }
+#endif
+ }
+ else {
+ /* horizontal run of pixels */
+ if (rb->PutRow) {
+ rb->PutRow(ctx, rb, span->end, span->x, span->y, rgbaTmp,
+ span->array->mask);
+ }
+#if OLD_RENDERBUFFER
+ else {
+ swrast->Driver.WriteRGBASpan(ctx, rb, span->end, span->x, span->y,
+ (const GLchan (*)[4]) rgbaTmp,
+ span->array->mask);
+ }
+#endif
+ }
+ }
+
+#if OLD_RENDERBUFFER
+ /* restore default dest buffer */
+ _swrast_use_draw_buffer(ctx);
+#endif
+}
+
+
+/**
* Apply all the per-fragment operations to a span.
* This now includes texturing (_swrast_write_texture_span() is history).
* This function may modify any of the array values in the span.
@@ -1194,7 +1212,7 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
if (span->interpMask & SPAN_Z)
_swrast_span_interpolate_z(ctx, span);
- if (ctx->Stencil.Enabled) {
+ if (ctx->Stencil.Enabled && ctx->DrawBuffer->Visual.stencilBits > 0) {
/* Combined Z/stencil tests */
if (!_swrast_stencil_and_ztest_span(ctx, span)) {
span->interpMask = origInterpMask;
@@ -1202,7 +1220,7 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
return;
}
}
- else {
+ else if (ctx->DrawBuffer->Visual.depthBits > 0) {
/* Just regular depth testing */
ASSERT(ctx->Depth.Test);
ASSERT(span->arrayMask & SPAN_Z);
@@ -1302,41 +1320,54 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
}
else {
/* normal: write to exactly one buffer */
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+
if (ctx->Color._LogicOpEnabled) {
- _swrast_logicop_rgba_span(ctx, span, span->array->rgba);
+ _swrast_logicop_rgba_span(ctx, rb, span, span->array->rgba);
}
else if (ctx->Color.BlendEnabled) {
- _swrast_blend_span(ctx, span, span->array->rgba);
+ _swrast_blend_span(ctx, rb, span, span->array->rgba);
}
/* Color component masking */
if (colorMask != 0xffffffff) {
- _swrast_mask_rgba_span(ctx, span, span->array->rgba);
+ _swrast_mask_rgba_span(ctx, rb, span, span->array->rgba);
}
/* Finally, write the pixels to a color buffer */
if (span->arrayMask & SPAN_XY) {
/* array of pixel coords */
- swrast->Driver.WriteRGBAPixels(ctx, span->end, span->array->x,
+ if (rb->PutValues) {
+ ASSERT(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA);
+ /* XXX check datatype */
+ rb->PutValues(ctx, rb, span->end, span->array->x, span->array->y,
+ span->array->rgba, span->array->mask);
+ }
+#ifdef OLD_RENDERBUFFER
+ else
+ {
+ swrast->Driver.WriteRGBAPixels(ctx, rb, span->end, span->array->x,
span->array->y, (const GLchan (*)[4]) span->array->rgba,
span->array->mask);
- if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
- _swrast_write_alpha_pixels(ctx, span->end,
- span->array->x, span->array->y,
- (const GLchan (*)[4]) span->array->rgba,
- span->array->mask);
}
+#endif
}
else {
/* horizontal run of pixels */
- swrast->Driver.WriteRGBASpan(ctx, span->end, span->x, span->y,
+ if (rb->PutRow) {
+ ASSERT(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA);
+ /* XXX check datatype */
+ rb->PutRow(ctx, rb, span->end, span->x, span->y, span->array->rgba,
+ span->writeAll ? NULL : span->array->mask);
+ }
+#ifdef OLD_RENDERBUFFER
+ else
+ {
+ swrast->Driver.WriteRGBASpan(ctx, rb, span->end, span->x, span->y,
(const GLchan (*)[4]) span->array->rgba,
span->writeAll ? NULL : span->array->mask);
- if (swrast->_RasterMask & ALPHABUF_BIT) {
- _swrast_write_alpha_span(ctx, span->end, span->x, span->y,
- (const GLchan (*)[4]) span->array->rgba,
- span->writeAll ? NULL : span->array->mask);
}
+#endif
}
}
@@ -1351,16 +1382,16 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
* reading ouside the buffer's boundaries.
*/
void
-_swrast_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
+_swrast_read_rgba_span( GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y, GLchan rgba[][4] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLint bufWidth = (GLint) buffer->Width;
- const GLint bufHeight = (GLint) buffer->Height;
+ const GLint bufWidth = (GLint) rb->Width;
+ const GLint bufHeight = (GLint) rb->Height;
if (y < 0 || y >= bufHeight || x + (GLint) n < 0 || x >= bufWidth) {
/* completely above, below, or right */
- /* XXX maybe leave undefined? */
+ /* XXX maybe leave rgba values undefined? */
_mesa_bzero(rgba, 4 * n * sizeof(GLchan));
}
else {
@@ -1392,10 +1423,22 @@ _swrast_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
length = (GLint) n;
}
- (*swrast->Driver.ReadRGBASpan)( ctx, length, x + skip, y, rgba + skip );
- if (buffer->UseSoftwareAlphaBuffers) {
- _swrast_read_alpha_span(ctx, length, x + skip, y, rgba + skip);
+ if (rb && rb->GetRow) {
+ assert(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA);
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ rb->GetRow(ctx, rb, length, x + skip, y, rgba + skip);
+ }
+#if OLD_RENDERBUFFER
+ else {
+ swrast->Driver.ReadRGBASpan(ctx, rb, length, x + skip, y,
+ rgba + skip);
+ /*
+ if (buffer->UseSoftwareAlphaBuffers) {
+ _swrast_read_alpha_span(ctx, length, x + skip, y, rgba + skip);
+ }
+ */
}
+#endif
}
}
@@ -1405,16 +1448,15 @@ _swrast_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
* reading ouside the buffer's boundaries.
*/
void
-_swrast_read_index_span( GLcontext *ctx, GLframebuffer *buffer,
- GLuint n, GLint x, GLint y, GLuint indx[] )
+_swrast_read_index_span( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint index[] )
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLint bufWidth = (GLint) buffer->Width;
- const GLint bufHeight = (GLint) buffer->Height;
+ const GLint bufWidth = (GLint) rb->Width;
+ const GLint bufHeight = (GLint) rb->Height;
if (y < 0 || y >= bufHeight || x + (GLint) n < 0 || x >= bufWidth) {
/* completely above, below, or right */
- _mesa_bzero(indx, n * sizeof(GLuint));
+ _mesa_bzero(index, n * sizeof(GLuint));
}
else {
GLint skip, length;
@@ -1445,6 +1487,25 @@ _swrast_read_index_span( GLcontext *ctx, GLframebuffer *buffer,
length = (GLint) n;
}
- (*swrast->Driver.ReadCI32Span)( ctx, length, skip + x, y, indx + skip );
+ ASSERT(rb->GetRow);
+ ASSERT(rb->_BaseFormat == GL_COLOR_INDEX);
+
+ if (rb->DataType == GL_UNSIGNED_BYTE) {
+ GLubyte index8[MAX_WIDTH];
+ GLint i;
+ rb->GetRow(ctx, rb, length, x + skip, y, index8);
+ for (i = 0; i < length; i++)
+ index[skip + i] = index8[i];
+ }
+ else if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort index16[MAX_WIDTH];
+ GLint i;
+ rb->GetRow(ctx, rb, length, x + skip, y, index16);
+ for (i = 0; i < length; i++)
+ index[skip + i] = index16[i];
+ }
+ else if (rb->DataType == GL_UNSIGNED_INT) {
+ rb->GetRow(ctx, rb, length, x + skip, y, index + skip);
+ }
}
}
diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h
index 29c485c4d0..789010bd7f 100644
--- a/src/mesa/swrast/s_span.h
+++ b/src/mesa/swrast/s_span.h
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* 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"),
@@ -60,11 +60,11 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span);
extern void
-_swrast_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer,
+_swrast_read_rgba_span( GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y, GLchan rgba[][4] );
extern void
-_swrast_read_index_span( GLcontext *ctx, GLframebuffer *buffer,
+_swrast_read_index_span( GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y, GLuint indx[] );
#endif
diff --git a/src/mesa/swrast/s_spantemp.h b/src/mesa/swrast/s_spantemp.h
index 1ce0b00bef..5c67758035 100644
--- a/src/mesa/swrast/s_spantemp.h
+++ b/src/mesa/swrast/s_spantemp.h
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2002 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,12 +51,14 @@
#ifdef STORE_RGBA_PIXEL
static void
-NAME(write_rgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
- CONST GLchan rgba[][4], const GLubyte mask[] )
+NAME(write_rgba_span)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
GLuint i;
INIT_PIXEL_PTR(pixel, x, y);
if (mask) {
@@ -79,12 +80,14 @@ NAME(write_rgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
}
static void
-NAME(write_rgb_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
- CONST GLchan rgb[][3], const GLubyte mask[] )
+NAME(write_rgb_span)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
GLuint i;
INIT_PIXEL_PTR(pixel, x, y);
if (mask) {
@@ -106,12 +109,14 @@ NAME(write_rgb_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
}
static void
-NAME(write_monorgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLchan color[4], const GLubyte mask[] )
+NAME(write_monorgba_span)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value, const GLubyte mask[] )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ const GLubyte *color = (const GLubyte *) value;
GLuint i;
INIT_PIXEL_PTR(pixel, x, y);
if (mask) {
@@ -133,13 +138,14 @@ NAME(write_monorgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
}
static void
-NAME(write_rgba_pixels)( const GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- CONST GLchan rgba[][4], const GLubyte mask[] )
+NAME(write_rgba_pixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[] )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
GLuint i;
ASSERT(mask);
for (i = 0; i < n; i++) {
@@ -152,13 +158,14 @@ NAME(write_rgba_pixels)( const GLcontext *ctx, GLuint n,
}
static void
-NAME(write_monorgba_pixels)( const GLcontext *ctx,
+NAME(write_monorgba_pixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
- const GLchan color[4], const GLubyte mask[] )
+ const void *value, const GLubyte mask[] )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ const GLubyte *color = (const GLubyte *) value;
GLuint i;
ASSERT(mask);
for (i = 0; i < n; i++) {
@@ -171,12 +178,13 @@ NAME(write_monorgba_pixels)( const GLcontext *ctx,
}
static void
-NAME(read_rgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLchan rgba[][4] )
+NAME(read_rgba_span)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, void *values )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
GLuint i;
INIT_PIXEL_PTR(pixel, x, y);
for (i = 0; i < n; i++) {
@@ -187,21 +195,20 @@ NAME(read_rgba_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
}
static void
-NAME(read_rgba_pixels)( const GLcontext *ctx,
+NAME(read_rgba_pixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
- GLchan rgba[][4], const GLubyte mask[] )
+ void *values)
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
GLuint i;
ASSERT(mask);
for (i = 0; i < n; i++) {
- if (mask[i]) {
- INIT_PIXEL_PTR(pixel, x[i], y[i]);
- FETCH_RGBA_PIXEL(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP],
- rgba[i][ACOMP], pixel);
- }
+ INIT_PIXEL_PTR(pixel, x[i], y[i]);
+ FETCH_RGBA_PIXEL(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP],
+ rgba[i][ACOMP], pixel);
}
}
@@ -213,38 +220,14 @@ NAME(read_rgba_pixels)( const GLcontext *ctx,
#ifdef STORE_CI_PIXEL
static void
-NAME(write_index32_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLuint index[], const GLubyte mask[] )
-{
-#ifdef SPAN_VARS
- SPAN_VARS
-#endif
- GLuint i;
- INIT_PIXEL_PTR(pixel, x, y);
- if (mask) {
- for (i = 0; i < n; i++) {
- if (mask[i]) {
- STORE_CI_PIXEL(pixel, index[i]);
- }
- INC_PIXEL_PTR(pixel);
- }
- }
- else {
- for (i = 0; i < n; i++) {
- STORE_CI_PIXEL(pixel, index[i]);
- INC_PIXEL_PTR(pixel);
- }
- }
-}
-
-
-static void
-NAME(write_index8_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
- const GLubyte index[], const GLubyte mask[] )
+NAME(write_index_span)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ const GLuint *index = (const GLuint *) values;
GLuint i;
INIT_PIXEL_PTR(pixel, x, y);
if (mask) {
@@ -265,12 +248,14 @@ NAME(write_index8_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
static void
-NAME(write_monoindex_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLuint colorIndex, const GLubyte mask[] )
+NAME(write_monoindex_span)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value, const GLubyte mask[] )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ GLuint colorIndex = *((GLuint *) value);
GLuint i;
INIT_PIXEL_PTR(pixel, x, y);
if (mask) {
@@ -291,13 +276,14 @@ NAME(write_monoindex_span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
static void
-NAME(write_index_pixels)( const GLcontext *ctx,
+NAME(write_index_pixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
- const GLuint index[], const GLubyte mask[] )
+ const void *values, const GLubyte mask[] )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ const GLuint *index = (const GLuint *) values;
GLuint i;
ASSERT(mask);
for (i = 0; i < n; i++) {
@@ -310,13 +296,14 @@ NAME(write_index_pixels)( const GLcontext *ctx,
static void
-NAME(write_monoindex_pixels)( const GLcontext *ctx,
+NAME(write_monoindex_pixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
- GLuint colorIndex, const GLubyte mask[] )
+ const void *value, const GLubyte mask[] )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ GLuint colorIndex = *((GLuint *) value);
GLuint i;
ASSERT(mask);
for (i = 0; i < n; i++) {
@@ -329,12 +316,13 @@ NAME(write_monoindex_pixels)( const GLcontext *ctx,
static void
-NAME(read_index_span)( const GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLuint index[] )
+NAME(read_index_span)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, void *values )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ GLuint *index = (GLuint *) values;
GLuint i;
INIT_PIXEL_PTR(pixel, x, y);
for (i = 0; i < n; i++) {
@@ -345,20 +333,19 @@ NAME(read_index_span)( const GLcontext *ctx,
static void
-NAME(read_index_pixels)( const GLcontext *ctx,
+NAME(read_index_pixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
- GLuint index[], const GLubyte mask[] )
+ void *values )
{
#ifdef SPAN_VARS
SPAN_VARS
#endif
+ GLuint *index = (GLuint *) values;
GLuint i;
ASSERT(mask);
for (i = 0; i < n; i++) {
- if (mask[i] ) {
- INIT_PIXEL_PTR(pixel, x[i], y[i]);
- FETCH_CI_PIXEL(index[i], pixel);
- }
+ INIT_PIXEL_PTR(pixel, x[i], y[i]);
+ FETCH_CI_PIXEL(index[i], pixel);
}
}
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index 38182ad613..8481877171 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -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"),
@@ -27,6 +27,7 @@
#include "context.h"
#include "macros.h"
#include "imports.h"
+#include "fbobject.h"
#include "s_context.h"
#include "s_depth.h"
@@ -50,14 +51,6 @@ ENDIF
*/
-/*
- * Return the address of a stencil buffer value given the window coords:
- */
-#define STENCIL_ADDRESS(X,Y) \
- (ctx->DrawBuffer->Stencil + ctx->DrawBuffer->Width * (Y) + (X))
-
-
-
/**
* Apply the given stencil operator to the array of stencil values.
* Don't touch stencil[i] if mask[i] is zero.
@@ -415,7 +408,8 @@ do_stencil_test( GLcontext *ctx, GLuint face, GLuint n, GLstencil stencil[],
static GLboolean
stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face)
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
GLstencil stencilRow[MAX_WIDTH];
GLstencil *stencil;
const GLuint n = span->end;
@@ -431,19 +425,13 @@ stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face)
ASSERT(span->arrayMask & SPAN_Z);
}
#endif
-
- /* Get initial stencil values */
- if (swrast->Driver.WriteStencilSpan) {
- /* Get stencil values from the hardware stencil buffer */
- ASSERT(swrast->Driver.ReadStencilSpan);
- (*swrast->Driver.ReadStencilSpan)(ctx, n, x, y, stencilRow);
+
+ stencil = rb->GetPointer(ctx, rb, x, y);
+ if (!stencil) {
+ rb->GetRow(ctx, rb, n, x, y, stencilRow);
stencil = stencilRow;
}
- else {
- /* Get pointer into software stencil buffer */
- stencil = STENCIL_ADDRESS(x, y);
- }
-
+
/*
* Apply the stencil test to the fragments.
* failMask[i] is 1 if the stencil test failed.
@@ -507,9 +495,8 @@ stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face)
/*
* Write updated stencil values back into hardware stencil buffer.
*/
- if (swrast->Driver.WriteStencilSpan) {
- ASSERT(stencil == stencilRow);
- (swrast->Driver.WriteStencilSpan)(ctx, n, x, y, stencil, mask );
+ if (!rb->GetPointer(ctx, rb, 0, 0)) {
+ rb->PutRow(ctx, rb, n, x, y, stencil, mask);
}
span->writeAll = GL_FALSE;
@@ -519,6 +506,12 @@ stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face)
+/*
+ * Return the address of a stencil buffer value given the window coords:
+ */
+#define STENCIL_ADDRESS(X, Y) (stencilStart + (Y) * stride + (X))
+
+
/**
* Apply the given stencil operator for each pixel in the array whose
@@ -530,16 +523,21 @@ stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face)
* mask - array [n] of flag: 1=apply operator, 0=don't apply operator
*/
static void
-apply_stencil_op_to_pixels( const GLcontext *ctx,
+apply_stencil_op_to_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLenum oper, GLuint face, const GLubyte mask[] )
{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
const GLstencil ref = ctx->Stencil.Ref[face];
const GLstencil wrtmask = ctx->Stencil.WriteMask[face];
const GLstencil invmask = (GLstencil) (~wrtmask);
GLuint i;
+ GLstencil *stencilStart = (GLubyte *) rb->Data;
+ const GLuint stride = rb->Width;
- ASSERT(!SWRAST_CONTEXT(ctx)->Driver.WriteStencilSpan); /* software stencil buffer only! */
+ ASSERT(rb->GetPointer(ctx, rb, 0, 0));
+ ASSERT(sizeof(GLstencil) == 1);
switch (oper) {
case GL_KEEP:
@@ -701,16 +699,18 @@ static GLboolean
stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
const GLint x[], const GLint y[], GLubyte mask[] )
{
+ const struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
GLubyte fail[MAX_WIDTH];
GLstencil r, s;
GLuint i;
GLboolean allfail = GL_FALSE;
const GLuint valueMask = ctx->Stencil.ValueMask[face];
+ const GLstencil *stencilStart = (GLstencil *) rb->Data;
+ const GLuint stride = rb->Width;
- /* software stencil buffer only! */
- ASSERT(ctx->DrawBuffer->UseSoftwareStencilBuffer);
- ASSERT(!SWRAST_CONTEXT(ctx)->Driver.ReadStencilSpan);
- ASSERT(!SWRAST_CONTEXT(ctx)->Driver.WriteStencilSpan);
+ ASSERT(rb->GetPointer(ctx, rb, 0, 0));
+ ASSERT(sizeof(GLstencil) == 1);
/*
* Perform stencil test. The results of this operation are stored
@@ -740,7 +740,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
s = (GLstencil) (*sptr & valueMask);
if (r < s) {
/* passed */
@@ -760,7 +760,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
s = (GLstencil) (*sptr & valueMask);
if (r <= s) {
/* pass */
@@ -780,7 +780,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
s = (GLstencil) (*sptr & valueMask);
if (r > s) {
/* passed */
@@ -800,7 +800,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
s = (GLstencil) (*sptr & valueMask);
if (r >= s) {
/* passed */
@@ -820,7 +820,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
s = (GLstencil) (*sptr & valueMask);
if (r == s) {
/* passed */
@@ -840,7 +840,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
s = (GLstencil) (*sptr & valueMask);
if (r != s) {
/* passed */
@@ -897,24 +897,23 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
static GLboolean
stencil_and_ztest_pixels( GLcontext *ctx, struct sw_span *span, GLuint face )
{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
const GLuint n = span->end;
const GLint *x = span->array->x;
const GLint *y = span->array->y;
GLubyte *mask = span->array->mask;
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
ASSERT(span->arrayMask & SPAN_XY);
ASSERT(ctx->Stencil.Enabled);
ASSERT(n <= MAX_WIDTH);
- if (swrast->Driver.WriteStencilPixels) {
- /*** Hardware stencil buffer ***/
+ if (!rb->GetPointer(ctx, rb, 0, 0)) {
+ /* No direct access */
GLstencil stencil[MAX_WIDTH];
GLubyte origMask[MAX_WIDTH];
- ASSERT(!ctx->DrawBuffer->UseSoftwareStencilBuffer);
- ASSERT(swrast->Driver.ReadStencilPixels);
- (*swrast->Driver.ReadStencilPixels)(ctx, n, x, y, stencil);
+ rb->GetValues(ctx, rb, n, x, y, stencil);
MEMCPY(origMask, mask, n * sizeof(GLubyte));
@@ -950,14 +949,12 @@ stencil_and_ztest_pixels( GLcontext *ctx, struct sw_span *span, GLuint face )
}
/* Write updated stencil values into hardware stencil buffer */
- (swrast->Driver.WriteStencilPixels)(ctx, n, x, y, stencil, origMask);
+ rb->PutValues(ctx, rb, n, x, y, stencil, origMask);
return GL_TRUE;
}
else {
- /*** Software stencil buffer ***/
-
- ASSERT(ctx->DrawBuffer->UseSoftwareStencilBuffer);
+ /* Direct access to stencil buffer */
if (stencil_test_pixels(ctx, face, n, x, y, mask) == GL_FALSE) {
/* all fragments failed the stencil test, we're done. */
@@ -1015,6 +1012,39 @@ _swrast_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span)
}
+#if 0
+GLuint
+clip_span(GLuint bufferWidth, GLuint bufferHeight,
+ GLint x, GLint y, GLuint *count)
+{
+ GLuint n = *count;
+ GLuint skipPixels = 0;
+
+ if (y < 0 || y >= bufferHeight || x + n <= 0 || x >= bufferWidth) {
+ /* totally out of bounds */
+ n = 0;
+ }
+ else {
+ /* left clip */
+ if (x < 0) {
+ skipPixels = -x;
+ x = 0;
+ n -= skipPixels;
+ }
+ /* right clip */
+ if (x + n > bufferWidth) {
+ GLint dx = x + n - bufferWidth;
+ n -= dx;
+ }
+ }
+
+ *count = n;
+
+ return skipPixels;
+}
+#endif
+
+
/**
* Return a span of stencil values from the stencil buffer.
* Used for glRead/CopyPixels
@@ -1023,14 +1053,10 @@ _swrast_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span)
* Output: stencil - the array of stencil values
*/
void
-_swrast_read_stencil_span( GLcontext *ctx,
- GLint n, GLint x, GLint y, GLstencil stencil[] )
+_swrast_read_stencil_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLstencil stencil[])
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLint bufWidth = (GLint) ctx->DrawBuffer->Width;
- const GLint bufHeight = (GLint) ctx->DrawBuffer->Height;
-
- if (y < 0 || y >= bufHeight || x + n <= 0 || x >= bufWidth) {
+ if (y < 0 || y >= rb->Height || x + n <= 0 || x >= rb->Width) {
/* span is completely outside framebuffer */
return; /* undefined values OK */
}
@@ -1041,29 +1067,15 @@ _swrast_read_stencil_span( GLcontext *ctx,
n -= dx;
stencil += dx;
}
- if (x + n > bufWidth) {
- GLint dx = x + n - bufWidth;
+ if (x + n > rb->Width) {
+ GLint dx = x + n - rb->Width;
n -= dx;
}
if (n <= 0) {
return;
}
-
- ASSERT(n >= 0);
- if (swrast->Driver.ReadStencilSpan) {
- (*swrast->Driver.ReadStencilSpan)( ctx, (GLuint) n, x, y, stencil );
- }
- else if (ctx->DrawBuffer->Stencil) {
- const GLstencil *s = STENCIL_ADDRESS( x, y );
-#if STENCIL_BITS == 8
- MEMCPY( stencil, s, n * sizeof(GLstencil) );
-#else
- GLuint i;
- for (i=0;i<n;i++)
- stencil[i] = s[i];
-#endif
- }
+ rb->GetRow(ctx, rb, n, x, y, stencil);
}
@@ -1076,252 +1088,113 @@ _swrast_read_stencil_span( GLcontext *ctx,
* stencil - the array of stencil values
*/
void
-_swrast_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
- const GLstencil stencil[] )
+_swrast_write_stencil_span(GLcontext *ctx, GLint n, GLint x, GLint y,
+ const GLstencil stencil[] )
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLstencil *ssrc = stencil;
- const GLint bufWidth = (GLint) ctx->DrawBuffer->Width;
- const GLint bufHeight = (GLint) ctx->DrawBuffer->Height;
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
- if (y < 0 || y >= bufHeight || x + n <= 0 || x >= bufWidth) {
+ if (y < 0 || y >= rb->Height || x + n <= 0 || x >= rb->Width) {
/* span is completely outside framebuffer */
return; /* undefined values OK */
}
-
if (x < 0) {
GLint dx = -x;
x = 0;
n -= dx;
- ssrc += dx;
+ stencil += dx;
}
- if (x + n > bufWidth) {
- GLint dx = x + n - bufWidth;
+ if (x + n > rb->Width) {
+ GLint dx = x + n - rb->Width;
n -= dx;
}
if (n <= 0) {
return;
}
- if (swrast->Driver.WriteStencilSpan) {
- (*swrast->Driver.WriteStencilSpan)( ctx, n, x, y, ssrc, NULL );
- }
- else if (ctx->DrawBuffer->Stencil) {
- GLstencil *s = STENCIL_ADDRESS( x, y );
-#if STENCIL_BITS == 8
- MEMCPY( s, ssrc, n * sizeof(GLstencil) );
-#else
- GLuint i;
- for (i=0;i<n;i++)
- s[i] = ssrc[i];
-#endif
- }
+ rb->PutRow(ctx, rb, n, x, y, stencil, NULL);
}
/**
- * Allocate a new stencil buffer. If there's an old one it will be
- * deallocated first. The new stencil buffer will be uninitialized.
+ * Clear the stencil buffer.
*/
void
-_swrast_alloc_stencil_buffer( GLframebuffer *buffer )
+_swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
{
- ASSERT(buffer->UseSoftwareStencilBuffer);
-
- /* deallocate current stencil buffer if present */
- if (buffer->Stencil) {
- MESA_PBUFFER_FREE(buffer->Stencil);
- buffer->Stencil = NULL;
- }
-
- /* allocate new stencil buffer */
- buffer->Stencil = (GLstencil *)
- MESA_PBUFFER_ALLOC(buffer->Width * buffer->Height * sizeof(GLstencil));
- if (!buffer->Stencil) {
- /* out of memory */
- _mesa_error( NULL, GL_OUT_OF_MEMORY, "_swrast_alloc_stencil_buffer" );
- }
-}
+ const GLstencil mask = ctx->Stencil.WriteMask[0];
+ const GLstencil invMask = ~mask;
+ const GLstencil clearVal = (ctx->Stencil.Clear & mask);
+ GLint x, y, width, height;
-
-
-/**
- * Clear the software (malloc'd) stencil buffer.
- */
-static void
-clear_software_stencil_buffer( GLcontext *ctx )
-{
- if (ctx->Visual.stencilBits==0 || !ctx->DrawBuffer->Stencil) {
- /* no stencil buffer */
+ if (!rb || mask == 0)
return;
- }
-
- if (ctx->Scissor.Enabled) {
- /* clear scissor region only */
- const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
- if (ctx->Stencil.WriteMask[0] != STENCIL_MAX) {
- /* must apply mask to the clear */
- GLint y;
- for (y = ctx->DrawBuffer->_Ymin; y < ctx->DrawBuffer->_Ymax; y++) {
- const GLstencil mask = ctx->Stencil.WriteMask[0];
- const GLstencil invMask = ~mask;
- const GLstencil clearVal = (ctx->Stencil.Clear & mask);
- GLstencil *stencil = STENCIL_ADDRESS( ctx->DrawBuffer->_Xmin, y );
- GLint i;
- for (i = 0; i < width; i++) {
- stencil[i] = (stencil[i] & invMask) | clearVal;
- }
- }
- }
- else {
- /* no masking */
- GLint y;
- for (y = ctx->DrawBuffer->_Ymin; y < ctx->DrawBuffer->_Ymax; y++) {
- GLstencil *stencil = STENCIL_ADDRESS( ctx->DrawBuffer->_Xmin, y );
-#if STENCIL_BITS==8
- MEMSET( stencil, ctx->Stencil.Clear, width * sizeof(GLstencil) );
-#else
- GLint i;
- for (i = 0; i < width; i++)
- stencil[i] = ctx->Stencil.Clear;
-#endif
- }
- }
- }
- else {
- /* clear whole stencil buffer */
- if (ctx->Stencil.WriteMask[0] != STENCIL_MAX) {
- /* must apply mask to the clear */
- const GLuint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
- GLstencil *stencil = ctx->DrawBuffer->Stencil;
- const GLstencil mask = ctx->Stencil.WriteMask[0];
- const GLstencil invMask = ~mask;
- const GLstencil clearVal = (ctx->Stencil.Clear & mask);
- GLuint i;
- for (i = 0; i < n; i++) {
- stencil[i] = (stencil[i] & invMask) | clearVal;
- }
- }
- else {
- /* clear whole buffer without masking */
- const GLuint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
- GLstencil *stencil = ctx->DrawBuffer->Stencil;
-
-#if STENCIL_BITS==8
- MEMSET(stencil, ctx->Stencil.Clear, n * sizeof(GLstencil) );
-#else
- GLuint i;
- for (i = 0; i < n; i++) {
- stencil[i] = ctx->Stencil.Clear;
- }
-#endif
- }
- }
-}
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ ASSERT(rb->_BaseFormat == GL_STENCIL_INDEX);
+ /* compute region to clear */
+ x = ctx->DrawBuffer->_Xmin;
+ y = ctx->DrawBuffer->_Ymin;
+ width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
-/**
- * Clear the hardware (in graphics card) stencil buffer.
- * This is done with the Driver.WriteStencilSpan() and Driver.ReadStencilSpan()
- * functions.
- * Actually, if there is a hardware stencil buffer it really should have
- * been cleared in Driver.Clear()! However, if the hardware does not
- * support scissored clears or masked clears (i.e. glStencilMask) then
- * we have to use the span-based functions.
- */
-static void
-clear_hardware_stencil_buffer( GLcontext *ctx )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- ASSERT(swrast->Driver.WriteStencilSpan);
- ASSERT(swrast->Driver.ReadStencilSpan);
-
- if (ctx->Scissor.Enabled) {
- /* clear scissor region only */
- const GLint x = ctx->DrawBuffer->_Xmin;
- const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* Direct buffer access */
if (ctx->Stencil.WriteMask[0] != STENCIL_MAX) {
- /* must apply mask to the clear */
- GLint y;
- for (y = ctx->DrawBuffer->_Ymin; y < ctx->DrawBuffer->_Ymax; y++) {
- const GLstencil mask = ctx->Stencil.WriteMask[0];
- const GLstencil invMask = ~mask;
- const GLstencil clearVal = (ctx->Stencil.Clear & mask);
- GLstencil stencil[MAX_WIDTH];
- GLint i;
- (*swrast->Driver.ReadStencilSpan)(ctx, width, x, y, stencil);
- for (i = 0; i < width; i++) {
- stencil[i] = (stencil[i] & invMask) | clearVal;
+ /* need to mask the clear */
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLubyte *stencil = rb->GetPointer(ctx, rb, x, y + i);
+ for (j = 0; j < width; j++) {
+ stencil[j] = (stencil[j] & invMask) | clearVal;
}
- (*swrast->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
}
}
else {
- /* no masking */
- GLstencil stencil[MAX_WIDTH];
- GLint y, i;
- for (i = 0; i < width; i++) {
- stencil[i] = ctx->Stencil.Clear;
+ /* no bit masking */
+ if (width == rb->Width &&
+ rb->InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ /* optimized case */
+ GLubyte *stencil = rb->GetPointer(ctx, rb, x, y);
+ GLuint len = width * height * sizeof(GLubyte);
+ _mesa_memset(stencil, clearVal, len);
}
- for (y = ctx->DrawBuffer->_Ymin; y < ctx->DrawBuffer->_Ymax; y++) {
- (*swrast->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
+ else {
+ /* general case */
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLubyte *stencil = rb->GetPointer(ctx, rb, x, y + i);
+ for (j = 0; j < width; j++) {
+ stencil[j] = clearVal;
+ }
+ }
}
}
}
else {
- /* clear whole stencil buffer */
+ /* no direct access */
if (ctx->Stencil.WriteMask[0] != STENCIL_MAX) {
- /* must apply mask to the clear */
- const GLstencil mask = ctx->Stencil.WriteMask[0];
- const GLstencil invMask = ~mask;
- const GLstencil clearVal = (ctx->Stencil.Clear & mask);
- const GLint width = ctx->DrawBuffer->Width;
- const GLint height = ctx->DrawBuffer->Height;
- const GLint x = ctx->DrawBuffer->_Xmin;
- GLint y;
- for (y = 0; y < height; y++) {
- GLstencil stencil[MAX_WIDTH];
- GLint i;
- (*swrast->Driver.ReadStencilSpan)(ctx, width, x, y, stencil);
- for (i = 0; i < width; i++) {
- stencil[i] = (stencil[i] & invMask) | clearVal;
+ /* need to mask the clear */
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLubyte stencil[MAX_WIDTH];
+ rb->GetRow(ctx, rb, width, x, y + i, stencil);
+ for (j = 0; j < width; j++) {
+ stencil[j] = (stencil[j] & invMask) | clearVal;
}
- (*swrast->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
+ rb->PutRow(ctx, rb, width, x, y + i, stencil, NULL);
}
}
else {
- /* clear whole buffer without masking */
- const GLint width = ctx->DrawBuffer->Width;
- const GLint height = ctx->DrawBuffer->Height;
- const GLint x = ctx->DrawBuffer->_Xmin;
- GLstencil stencil[MAX_WIDTH];
- GLint y, i;
- for (i = 0; i < width; i++) {
- stencil[i] = ctx->Stencil.Clear;
- }
- for (y = 0; y < height; y++) {
- (*swrast->Driver.WriteStencilSpan)(ctx, width, x, y, stencil, NULL);
- }
+ /* no bit masking */
+ const GLubyte clear8 = clearVal;
+ GLint i;
+ for (i = 0; i < height; i++) {
+ rb->PutMonoRow(ctx, rb, width, x, y + i, &clear8, NULL);
+ }
}
}
}
-
-
-/**
- * Clear the stencil buffer (hardware or software).
- */
-void
-_swrast_clear_stencil_buffer( GLcontext *ctx )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- if (swrast->Driver.WriteStencilSpan) {
- ASSERT(swrast->Driver.ReadStencilSpan);
- clear_hardware_stencil_buffer(ctx);
- }
- else {
- clear_software_stencil_buffer(ctx);
- }
-}
diff --git a/src/mesa/swrast/s_stencil.h b/src/mesa/swrast/s_stencil.h
index 655f1dc3cf..fabc25250d 100644
--- a/src/mesa/swrast/s_stencil.h
+++ b/src/mesa/swrast/s_stencil.h
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2002 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"),
@@ -37,10 +36,9 @@ extern GLboolean
_swrast_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span);
-
extern void
-_swrast_read_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
- GLstencil stencil[] );
+_swrast_read_stencil_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLstencil stencil[]);
extern void
@@ -49,11 +47,7 @@ _swrast_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
extern void
-_swrast_alloc_stencil_buffer( GLframebuffer *buffer );
-
-
-extern void
-_swrast_clear_stencil_buffer( GLcontext *ctx );
+_swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb );
#endif
diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c
index fa6b74b745..24470a7358 100644
--- a/src/mesa/swrast/s_texstore.c
+++ b/src/mesa/swrast/s_texstore.c
@@ -79,8 +79,8 @@ read_color_image( GLcontext *ctx, GLint x, GLint y,
dst = image;
stride = width * 4;
for (i = 0; i < height; i++) {
- _swrast_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y + i,
- (GLchan (*)[4]) dst );
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y + i, (GLchan (*)[4]) dst);
dst += stride;
}
@@ -100,6 +100,8 @@ static GLfloat *
read_depth_image( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ struct gl_renderbuffer *rb
+ = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLfloat *image, *dst;
GLint i;
@@ -112,7 +114,7 @@ read_depth_image( GLcontext *ctx, GLint x, GLint y,
dst = image;
for (i = 0; i < height; i++) {
- _swrast_read_depth_span_float(ctx, width, x, y + i, dst);
+ _swrast_read_depth_span_float(ctx, rb, width, x, y + i, dst);
dst += width;
}
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 4533980455..48ec2836e8 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* 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"),
@@ -35,8 +35,6 @@
#include "imports.h"
#include "macros.h"
#include "texformat.h"
-#include "teximage.h"
-#include "texstate.h"
#include "s_aatriangle.h"
#include "s_context.h"
@@ -151,6 +149,7 @@ _swrast_culltriangle( GLcontext *ctx,
#define SETUP_CODE \
SWcontext *swrast = SWRAST_CONTEXT(ctx); \
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];\
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
const GLint b = obj->BaseLevel; \
const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \
@@ -179,9 +178,13 @@ _swrast_culltriangle( GLcontext *ctx,
span.intTex[0] += span.intTexStep[0]; \
span.intTex[1] += span.intTexStep[1]; \
} \
- (*swrast->Driver.WriteRGBSpan)(ctx, span.end, span.x, span.y, \
+ if (swrast->Driver.WriteRGBSpan) \
+ swrast->Driver.WriteRGBSpan(ctx, rb, span.end, span.x, span.y, \
(CONST GLchan (*)[3]) span.array->rgb,\
- NULL );
+ NULL ); \
+ else \
+ rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, span.array->rgb, NULL);
+
#include "s_tritemp.h"
@@ -203,6 +206,7 @@ _swrast_culltriangle( GLcontext *ctx,
#define SETUP_CODE \
SWcontext *swrast = SWRAST_CONTEXT(ctx); \
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];\
struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
const GLint b = obj->BaseLevel; \
const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \
@@ -240,9 +244,13 @@ _swrast_culltriangle( GLcontext *ctx,
span.intTex[1] += span.intTexStep[1]; \
span.z += span.zStep; \
} \
- (*swrast->Driver.WriteRGBSpan)(ctx, span.end, span.x, span.y, \
+ if (swrast->Driver.WriteRGBSpan) \
+ swrast->Driver.WriteRGBSpan(ctx, rb, span.end, span.x, span.y, \
(CONST GLchan (*)[3]) span.array->rgb,\
- span.array->mask );
+ span.array->mask ); \
+ else \
+ rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, span.array->rgb, NULL);
+
#include "s_tritemp.h"
@@ -908,6 +916,8 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
#define NAME occlusion_zless_triangle
#define INTERP_Z 1
#define SETUP_CODE \
+ struct gl_renderbuffer *rb \
+ = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; \
ASSERT(ctx->Depth.Test); \
ASSERT(!ctx->Depth.Mask); \
ASSERT(ctx->Depth.Func == GL_LESS); \
@@ -918,7 +928,7 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
if (ctx->Visual.depthBits <= 16) { \
GLuint i; \
const GLushort *zRow = (const GLushort *) \
- _swrast_zbuffer_address(ctx, span.x, span.y); \
+ rb->GetPointer(ctx, rb, span.x, span.y); \
for (i = 0; i < span.end; i++) { \
GLdepth z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -931,7 +941,7 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
else { \
GLuint i; \
const GLuint *zRow = (const GLuint *) \
- _swrast_zbuffer_address(ctx, span.x, span.y); \
+ rb->GetPointer(ctx, rb, span.x, span.y); \
for (i = 0; i < span.end; i++) { \
if ((GLuint)span.z < zRow[i]) { \
ctx->OcclusionResult = GL_TRUE; \
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index 0be17ed0b3..fe19a3363f 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -169,9 +169,9 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
} EdgeT;
#ifdef INTERP_Z
- const GLint depthBits = ctx->Visual.depthBits;
+ const GLint depthBits = ctx->DrawBuffer->Visual.depthBits;
const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
- const GLfloat maxDepth = ctx->DepthMaxF;
+ const GLfloat maxDepth = ctx->DrawBuffer->_DepthMaxF;
#define FixedToDepth(F) ((F) >> fixedToDepthShift)
#endif
EdgeT eMaj, eTop, eBot;
@@ -688,6 +688,8 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
#endif
#ifdef INTERP_Z
# ifdef DEPTH_TYPE
+ struct gl_renderbuffer *zrb
+ = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
DEPTH_TYPE *zRow = NULL;
GLint dZRowOuter = 0, dZRowInner; /* offset in bytes */
# endif
@@ -853,7 +855,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
}
# ifdef DEPTH_TYPE
zRow = (DEPTH_TYPE *)
- _swrast_zbuffer_address(ctx, InterpToInt(fxLeftEdge), span.y);
+ zrb->GetPointer(ctx, zrb, InterpToInt(fxLeftEdge), span.y);
dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(DEPTH_TYPE);
# endif
}
@@ -1065,7 +1067,6 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
/* ff = fixed-pt fragment */
const GLint right = InterpToInt(fxRightEdge);
span.x = InterpToInt(fxLeftEdge);
-
if (right <= span.x)
span.end = 0;
else
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index 8f249d9428..e1dbe0f512 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* 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"),
@@ -79,9 +79,6 @@ struct swrast_device_driver;
/* These are the public-access functions exported from swrast.
*/
extern void
-_swrast_alloc_buffers( GLframebuffer *buffer );
-
-extern void
_swrast_use_read_buffer( GLcontext *ctx );
extern void
@@ -260,7 +257,7 @@ _swrast_copy_texsubimage3d(GLcontext *ctx,
* Unless otherwise noted, all functions are mandatory.
*/
struct swrast_device_driver {
-
+#if OLD_RENDERBUFFER
void (*SetBuffer)(GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit);
/*
* Specifies the current color buffer for span/pixel writing/reading.
@@ -274,7 +271,7 @@ struct swrast_device_driver {
* DD_BACK_RIGHT_BIT - when using stereo and double buffering
* DD_AUXn_BIT - if aux buffers are implemented
*/
-
+#endif
/***
*** Functions for synchronizing access to the framebuffer:
@@ -297,10 +294,10 @@ struct swrast_device_driver {
*** Functions for writing pixels to the frame buffer:
***/
- void (*WriteRGBASpan)( const GLcontext *ctx,
+ void (*WriteRGBASpan)( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
CONST GLchan rgba[][4], const GLubyte mask[] );
- void (*WriteRGBSpan)( const GLcontext *ctx,
+ void (*WriteRGBSpan)( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
CONST GLchan rgb[][3], const GLubyte mask[] );
/* Write a horizontal run of RGBA or RGB pixels.
@@ -308,28 +305,33 @@ struct swrast_device_driver {
* If mask is not null, only draw pixel [i] when mask [i] is true.
*/
- void (*WriteMonoRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ void (*WriteMonoRGBASpan)( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLchan color[4], const GLubyte mask[] );
/* Write a horizontal run of RGBA pixels all with the same color.
* If mask is NULL, draw all pixels.
* If mask is not null, only draw pixel [i] when mask [i] is true.
*/
- void (*WriteRGBAPixels)( const GLcontext *ctx,
+ void (*WriteRGBAPixels)( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
CONST GLchan rgba[][4], const GLubyte mask[] );
/* Write array of RGBA pixels at random locations.
*/
void (*WriteMonoRGBAPixels)( const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
const GLchan color[4], const GLubyte mask[] );
/* Write an array of mono-RGBA pixels at random locations.
*/
- void (*WriteCI32Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+#if OLD_RENDERBUFFER /* these are obsolete */
+ void (*WriteCI32Span)( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLuint index[], const GLubyte mask[] );
- void (*WriteCI8Span)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ void (*WriteCI8Span)( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLubyte index[], const GLubyte mask[] );
/* Write a horizontal run of CI pixels. One function is for 32bpp
* indexes and the other for 8bpp pixels (the common case). You mus
@@ -337,8 +339,8 @@ struct swrast_device_driver {
* If mask is NULL, draw all pixels.
* If mask is not null, only draw pixel [i] when mask [i] is true.
*/
-
- void (*WriteMonoCISpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
+ void (*WriteMonoCISpan)( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
GLuint colorIndex, const GLubyte mask[] );
/* Write a horizontal run of color index pixels using the color index
* last specified by the Index() function.
@@ -346,42 +348,40 @@ struct swrast_device_driver {
* If mask is not null, only draw pixel [i] when mask [i] is true.
*/
- void (*WriteCI32Pixels)( const GLcontext *ctx,
+ void (*WriteCI32Pixels)( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
const GLuint index[], const GLubyte mask[] );
/*
* Write a random array of CI pixels.
*/
-
- void (*WriteMonoCIPixels)( const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
+ void (*WriteMonoCIPixels)( const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, const GLint x[], const GLint y[],
GLuint colorIndex, const GLubyte mask[] );
/* Write a random array of color index pixels using the color index
* last specified by the Index() function.
*/
-
/***
*** Functions to read pixels from frame buffer:
***/
- void (*ReadCI32Span)( const GLcontext *ctx,
+ void (*ReadCI32Span)( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y, GLuint index[] );
/* Read a horizontal run of color index pixels.
*/
- void (*ReadRGBASpan)( const GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLchan rgba[][4] );
- /* Read a horizontal run of RGBA pixels.
- */
-
- void (*ReadCI32Pixels)( const GLcontext *ctx,
+ void (*ReadCI32Pixels)( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
GLuint indx[], const GLubyte mask[] );
/* Read a random array of CI pixels.
*/
+#endif
+
+ void (*ReadRGBASpan)( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLchan rgba[][4] );
+ /* Read a horizontal run of RGBA pixels.
+ */
- void (*ReadRGBAPixels)( const GLcontext *ctx,
+ void (*ReadRGBAPixels)( const GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] );
/* Read a random array of RGBA pixels.
@@ -396,34 +396,36 @@ struct swrast_device_driver {
*** buffer is less than 32 bits deep then the extra upperbits are zero.
***/
- void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ void (*WriteDepthSpan)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLdepth depth[], const GLubyte mask[] );
/* Write a horizontal span of values into the depth buffer. Only write
* depth[i] value if mask[i] is nonzero.
*/
- void (*WriteMonoDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ void (*WriteMonoDepthSpan)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLdepth depth, const GLubyte mask[] );
/* Write a horizontal run of depth values.
* If mask is NULL, draw all pixels.
* If mask is not null, only draw pixel [i] when mask [i] is true.
*/
- void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLdepth depth[] );
+ void (*ReadDepthSpan)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLdepth depth[] );
/* Read a horizontal span of values from the depth buffer.
*/
- void (*WriteDepthPixels)( GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
+ void (*WriteDepthPixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
const GLdepth depth[], const GLubyte mask[] );
/* Write an array of randomly positioned depth values into the
* depth buffer. Only write depth[i] value if mask[i] is nonzero.
*/
- void (*ReadDepthPixels)( GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
+ void (*ReadDepthPixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
GLdepth depth[] );
/* Read an array of randomly positioned depth values from the depth buffer.
*/
@@ -435,20 +437,21 @@ struct swrast_device_driver {
*** Either ALL or NONE of these functions must be implemented!
***/
- void (*WriteStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ void (*WriteStencilSpan)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
const GLstencil stencil[], const GLubyte mask[] );
/* Write a horizontal span of stencil values into the stencil buffer.
* If mask is NULL, write all stencil values.
* Else, only write stencil[i] if mask[i] is non-zero.
*/
- void (*ReadStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLstencil stencil[] );
+ void (*ReadStencilSpan)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLstencil stencil[] );
/* Read a horizontal span of stencil values from the stencil buffer.
*/
- void (*WriteStencilPixels)( GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
+ void (*WriteStencilPixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
const GLstencil stencil[],
const GLubyte mask[] );
/* Write an array of stencil values into the stencil buffer.
@@ -456,8 +459,8 @@ struct swrast_device_driver {
* Else, only write stencil[i] if mask[i] is non-zero.
*/
- void (*ReadStencilPixels)( GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
+ void (*ReadStencilPixels)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
GLstencil stencil[] );
/* Read an array of stencil values from the stencil buffer.
*/
diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h
index 3465ad3912..34ea1e1e9d 100644
--- a/src/mesa/swrast_setup/ss_tritmp.h
+++ b/src/mesa/swrast_setup/ss_tritmp.h
@@ -101,7 +101,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
if (IND & SS_OFFSET_BIT)
{
- offset = ctx->Polygon.OffsetUnits * ctx->MRD;
+ offset = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD;
z[0] = v[0]->win[2];
z[1] = v[1]->win[2];
z[2] = v[2]->win[2];
diff --git a/src/mesa/tnl_dd/t_dd_tritmp.h b/src/mesa/tnl_dd/t_dd_tritmp.h
index 6ba15cea02..a822c38255 100644
--- a/src/mesa/tnl_dd/t_dd_tritmp.h
+++ b/src/mesa/tnl_dd/t_dd_tritmp.h
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 6.3
*
- * Copyright (C) 1999-2001 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"),
@@ -274,7 +273,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
if ( bc < 0.0f ) bc = -bc;
offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
}
- offset *= REVERSE_DEPTH ? -ctx->MRD : ctx->MRD;
+ offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
}
}
@@ -550,7 +549,7 @@ static void TAG(quad)( GLcontext *ctx,
if ( bc < 0.0f ) bc = -bc;
offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
}
- offset *= REVERSE_DEPTH ? -ctx->MRD : ctx->MRD;
+ offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
}
}