GL_ARB_pixel_buffer_object - buffer objects for pixel read/write functions.
+GL_EXT_framebuffer_object - allows render-to-texture and provides a
+ window-system indepedent Pbuffer facility
+
DirectFB driver, contributed by Claudio Ciccani. See docs/README.directfb
for details.
----------------------------------------------------------------------
-$Id: RELNOTES-6.3,v 3.8 2005/01/20 04:03:37 brianp Exp $
+$Id: RELNOTES-6.3,v 3.9 2005/05/04 20:11:35 brianp Exp $
glFBDevGetString( int str );
-extern const void *
+typedef void (*GLFBDevProc)();
+
+
+extern const GLFBDevProc
glFBDevGetProcAddress( const char *procName );
int main( int argc, char *argv[] )
{
glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL | GLUT_ALPHA);
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( Width, Height );
glutCreateWindow(argv[0]);
cva.c \
dinoshade.c \
floattex.c \
+ fbotest1.c \
+ fbotexture.c \
fogcoord.c \
fptest1.c \
fptexture.c \
--- /dev/null
+/*
+ * Test GL_EXT_framebuffer_object
+ *
+ * Brian Paul
+ * 7 Feb 2005
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+static int Width = 400, Height = 400;
+static GLuint MyFB;
+
+
+static void
+CheckError(int line)
+{
+ GLenum err = glGetError();
+ if (err) {
+ printf("GL Error 0x%x at line %d\n", (int) err, line);
+ }
+}
+
+
+static void
+Display( void )
+{
+ GLubyte *buffer = malloc(Width * Height * 4);
+ GLenum status;
+
+ /* draw to user framebuffer */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+ glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
+ glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
+
+ status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ printf("Framebuffer incomplete!!!\n");
+ }
+
+ glClearColor(0.5, 0.5, 1.0, 0.0);
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glBegin(GL_POLYGON);
+ glColor3f(1, 0, 0);
+ glVertex2f(-1, -1);
+ glColor3f(0, 1, 0);
+ glVertex2f(1, -1);
+ glColor3f(0, 0, 1);
+ glVertex2f(0, 1);
+ glEnd();
+
+ /* read from user framebuffer */
+ glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+ /* draw to window */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glWindowPos2iARB(0, 0);
+ glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+ free(buffer);
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape( int width, int height )
+{
+ float ar = (float) width / (float) height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+#if 0
+ glFrustum( -ar, ar, -1.0, 1.0, 5.0, 25.0 );
+#else
+ glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+#endif
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+ Width = width;
+ Height = height;
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+}
+
+
+static void
+Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init( void )
+{
+ GLuint rb;
+ GLint i;
+
+ if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
+ printf("GL_EXT_framebuffer_object not found!\n");
+ /*exit(0);*/
+ }
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ glGenFramebuffersEXT(1, &MyFB);
+ assert(MyFB);
+ assert(glIsFramebufferEXT(MyFB));
+ glDeleteFramebuffersEXT(1, &MyFB);
+ assert(!glIsFramebufferEXT(MyFB));
+ /* Note, continue to use MyFB below */
+
+ glGenRenderbuffersEXT(1, &rb);
+ assert(rb);
+ assert(glIsRenderbufferEXT(rb));
+ glDeleteRenderbuffersEXT(1, &rb);
+ assert(!glIsRenderbufferEXT(rb));
+ rb = 42; /* an arbitrary ID */
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+ assert(glIsFramebufferEXT(MyFB));
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
+ assert(glIsRenderbufferEXT(rb));
+
+ glGetIntegerv(GL_RENDERBUFFER_BINDING_EXT, &i);
+ assert(i == rb);
+
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &i);
+ assert(i == MyFB);
+
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
+ GL_RENDERBUFFER_EXT, rb);
+
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+
+ CheckError(__LINE__);
+
+ /* restore to default */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+}
+
+
+int
+main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize(Width, Height);
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
--- /dev/null
+/*
+ * Test GL_EXT_framebuffer_object render-to-texture
+ *
+ * Draw a teapot into a texture image with stenciling.
+ * Then draw a textured quad using that texture.
+ *
+ * Brian Paul
+ * 18 Apr 2005
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+static int Width = 400, Height = 400;
+static int TexWidth = 512, TexHeight = 512;
+static GLuint MyFB;
+static GLuint TexObj;
+static GLuint DepthRB, StencilRB;
+static GLboolean Anim = GL_FALSE;
+static GLfloat Rot = 0.0;
+
+
+static void
+CheckError(int line)
+{
+ GLenum err = glGetError();
+ if (err) {
+ printf("GL Error 0x%x at line %d\n", (int) err, line);
+ }
+}
+
+
+static void
+Idle(void)
+{
+ Rot = glutGet(GLUT_ELAPSED_TIME) * 0.05;
+ glutPostRedisplay();
+}
+
+
+static void
+RenderTexture(void)
+{
+ GLint level = 0;
+ GLenum status;
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -15.0);
+
+ /* draw to texture */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, TexObj, level);
+
+ status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ printf("Framebuffer incomplete!!!\n");
+ }
+
+ glViewport(0, 0, TexWidth, TexHeight);
+
+ glClearColor(0.5, 0.5, 1.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_STENCIL_TEST);
+ glStencilFunc(GL_NEVER, 1, ~0);
+ glStencilOp(GL_REPLACE, GL_KEEP, GL_REPLACE);
+
+ /* draw diamond-shaped stencil pattern */
+ glColor3f(0, 1, 0);
+ glBegin(GL_POLYGON);
+ glVertex2f(-0.2, 0.0);
+ glVertex2f( 0.0, -0.2);
+ glVertex2f( 0.2, 0.0);
+ glVertex2f( 0.0, 0.2);
+ glEnd();
+
+ /* draw teapot where stencil != 1 */
+ glStencilFunc(GL_NOTEQUAL, 1, ~0);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+
+#if 0
+ glBegin(GL_POLYGON);
+ glColor3f(1, 0, 0);
+ glVertex2f(-1, -1);
+ glColor3f(0, 1, 0);
+ glVertex2f(1, -1);
+ glColor3f(0, 0, 1);
+ glVertex2f(0, 1);
+ glEnd();
+#else
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glPushMatrix();
+ glRotatef(0.5 * Rot, 1.0, 0.0, 0.0);
+ glutSolidTeapot(0.5);
+ glPopMatrix();
+ glDisable(GL_LIGHTING);
+#endif
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_STENCIL_TEST);
+
+ /* Bind normal framebuffer */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+
+ CheckError(__LINE__);
+}
+
+
+
+static void
+Display(void)
+{
+ float ar = (float) Width / (float) Height;
+
+ RenderTexture();
+
+ /* draw textured quad in the window */
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -7.0);
+
+ glViewport(0, 0, Width, Height);
+
+ glClearColor(0.25, 0.25, 0.25, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glPushMatrix();
+ glRotatef(Rot, 0, 1, 0);
+ glEnable(GL_TEXTURE_2D);
+ glBegin(GL_POLYGON);
+ glColor3f(0.25, 0.25, 0.25);
+ glTexCoord2f(0, 0);
+ glVertex2f(-1, -1);
+ glTexCoord2f(1, 0);
+ glVertex2f(1, -1);
+ glColor3f(1.0, 1.0, 1.0);
+ glTexCoord2f(1, 1);
+ glVertex2f(1, 1);
+ glTexCoord2f(0, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+ glPopMatrix();
+ glDisable(GL_TEXTURE_2D);
+
+ glutSwapBuffers();
+ CheckError(__LINE__);
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ Width = width;
+ Height = height;
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+ GLint i;
+
+ if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
+ printf("GL_EXT_framebuffer_object not found!\n");
+ exit(0);
+ }
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ /* make framebuffer */
+ glGenFramebuffersEXT(1, &MyFB);
+ assert(MyFB);
+ assert(glIsFramebufferEXT(MyFB));
+ glDeleteFramebuffersEXT(1, &MyFB);
+ assert(!glIsFramebufferEXT(MyFB));
+ /* Note, continue to use MyFB below */
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+ assert(glIsFramebufferEXT(MyFB));
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &i);
+ assert(i == MyFB);
+
+ /* make depth renderbuffer */
+ glGenRenderbuffersEXT(1, &DepthRB);
+ assert(DepthRB);
+ assert(glIsRenderbufferEXT(DepthRB));
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
+ TexWidth, TexHeight);
+
+ /* make stencil renderbuffer */
+ glGenRenderbuffersEXT(1, &StencilRB);
+ assert(StencilRB);
+ assert(glIsRenderbufferEXT(StencilRB));
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilRB);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX,
+ TexWidth, TexHeight);
+
+ /* attach DepthRB to MyFB */
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, DepthRB);
+
+ /* attach StencilRB to MyFB */
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, StencilRB);
+
+
+ /* bind regular framebuffer */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+
+ /* Make texture object/image */
+ glGenTextures(1, &TexObj);
+ glBindTexture(GL_TEXTURE_2D, TexObj);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TexWidth, TexHeight, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ CheckError(__LINE__);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(Width, Height);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Display);
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
for (entry = functions; entry->name; entry++) {
if (entry->name[0] == '-') {
+ /* XXX update for OpenGL 2.0 */
if (entry->name[1] == '1') {
/* check GL version X.Y */
const char *version = (const char *) glGetString(GL_VERSION);
#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"
#endif
#if FEATURE_EXT_framebuffer_object
#include "fbobject.h"
+#include "texrender.h"
#endif
#include "driverfuncs.h"
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;
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;
#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 */
* 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;
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;
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[])
{
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;
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[])
{
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[])
{
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;
/* $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
#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;
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;
}
#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;
/* 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;
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;
--- /dev/null
+
+#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;
+}
--- /dev/null
+
+/**
+ * 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 */
#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;
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;
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;
}
-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;
}
-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);
}
-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;
}
-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;
#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;
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;
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;
}
-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;
}
-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);
}
-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;
(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
HW_READ_LOCK()
{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
GLint x1,n1;
LOCAL_VARS;
#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;
#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
HW_READ_LOCK()
{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
GLint x1,n1;
LOCAL_VARS;
#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;
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
(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
((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);
}
}
#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;
}
+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;
/* 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;
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;
#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"
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:
{
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;
#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.
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 */
/* 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 */
if (!fbdrawable)
return 0;
+#if 0
fbdrawable->mesa_framebuffer = (void *)
_mesa_create_framebuffer( mesaVis,
swDepth,
_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;
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;
{
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) "
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;
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
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;
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)
#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
* 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 {
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:
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
}
}
- 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; }
#include "matrix.h"
#include "simple_list.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "imports.h"
#include "swrast/swrast.h"
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?
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:
*/
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;
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:
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) {
#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"
}
+/**
+ * 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);
}
}
(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
swdd->SetBuffer = i810SetBuffer;
+#if 0
swdd->WriteRGBASpan = i810WriteRGBASpan_565;
swdd->WriteRGBSpan = i810WriteRGBSpan_565;
swdd->WriteMonoRGBASpan = i810WriteMonoRGBASpan_565;
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;
+ }
+}
#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
/*
* _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:
#include "matrix.h"
#include "simple_list.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "imports.h"
#include "swrast/swrast.h"
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? */
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:
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;
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 |
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 |
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 |
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 */
#include "context.h"
#include "matrix.h"
#include "simple_list.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "i830_screen.h"
#include "i830_dri.h"
#include "utils.h"
#include "xmlpool.h"
+#include "drirenderbuffer.h"
PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN
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);
}
}
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 {
switch (i830Screen->fbFormat) {
case DV_PF_555:
+#if 0
swdd->WriteRGBASpan = i830WriteRGBASpan_555;
swdd->WriteRGBSpan = i830WriteRGBSpan_555;
swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_555;
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;
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;
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;
}
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;
+ }
+}
#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
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] =
* 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 );
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 );
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);
* 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 );
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 );
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);
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;
}
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);
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++)
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 );
ADVANCE_BATCH();
}
- if ( flags & DD_BACK_LEFT_BIT ) {
+ if ( flags & BUFFER_BIT_BACK_LEFT ) {
BEGIN_BATCH( 6);
OUT_BATCH( CMD );
OUT_BATCH( BR13 );
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 );
#include "matrix.h"
#include "simple_list.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "imports.h"
#include "swrast/swrast.h"
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;
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:
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;
*/
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 );
#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"
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);
}
}
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 {
switch (intelScreen->fbFormat) {
case DV_PF_555:
+#if 0
swdd->WriteRGBASpan = intelWriteRGBASpan_555;
swdd->WriteRGBSpan = intelWriteRGBSpan_555;
swdd->WriteMonoRGBASpan = intelWriteMonoRGBASpan_555;
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;
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;
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;
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;
+ }
+}
#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
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;
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;
#include "context.h"
#include "utils.h"
+#include "framebuffer.h"
#define DRIVER_DATE "20030502"
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;
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 )
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 );
#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"
driScreen->private = NULL;
}
+
/* Create and initialize the Mesa and driver specific pixmap buffer
* data.
*/
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);
}
}
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;
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;
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;
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;
+ }
+}
#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
/*
* _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 */
#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"
#include "mga_xmesa.h"
#include "mga_dri.h"
-
#include "utils.h"
#include "vblank.h"
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ mgaScreenPrivate *screen = (mgaScreenPrivate *) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
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);
}
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;
} 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 );
#include "mtypes.h"
+#include "framebuffer.h"
#include "mm.h"
#include "mgacontext.h"
void mgaInitDriverFuncs( struct dd_function_table *functions )
{
functions->GetBufferSize = mgaBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = mgaGetString;
}
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 ) {
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;
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) {
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;
+ }
+}
#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
/*
* _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;
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;
#include "swrast/swrast.h"
#include "context.h"
+#include "framebuffer.h"
#include "utils.h"
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;
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
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 )
#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"
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);
}
}
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;
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;
switch ( rmesa->r128Screen->cpp ) {
case 2:
+#if 0
r128InitPointers_RGB565( swdd );
+#endif
break;
case 4:
+#if 0
r128InitPointers_ARGB8888( swdd );
+#endif
break;
default:
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:
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;
+ }
+}
#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
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:
#include "imports.h"
#include "matrix.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "state.h"
#include "swrast/swrast.h"
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;
/* 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 );
/* 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 */
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 );
} 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)
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 ) {
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) {
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 );
#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"
}
-
/**
* 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.
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ r200ScreenPtr screen = (r200ScreenPtr) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
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);
}
}
#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; \
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 + \
(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
/* 16-bit depth buffer functions
*/
+
#define WRITE_DEPTH( _x, _y, d ) \
*(GLushort *)(buf + r200_mba_z16( rmesa, _x + xo, _y + yo )) = d;
#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 ); \
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;
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;
switch ( rmesa->r200Screen->cpp ) {
case 2:
+#if 0
r200InitPointers_RGB565( swdd );
+#endif
break;
case 4:
+#if 0
r200InitPointers_ARGB8888( swdd );
+#endif
break;
default:
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:
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;
+ }
+}
#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
/*
* _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;
../common/vblank.c \
../common/xmlconfig.c \
../common/dri_util.c \
+ ../common/drirenderbuffer.c \
../common/glcontextmodes.c
DRIVER_SOURCES = \
#include "imports.h"
#include "matrix.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
static void radeonInitDriverFuncs( struct dd_function_table *functions )
{
functions->GetBufferSize = radeonGetBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
functions->GetString = radeonGetString;
}
/* 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 */
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 );
} 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)
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 ) {
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 )
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 );
#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"
}
-
/**
- * 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.
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
+ radeonScreenPtr screen = (radeonScreenPtr) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
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);
}
}
driOptionCache optionCache;
} radeonScreenRec, *radeonScreenPtr;
-extern radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv );
-extern void radeonDestroyScreen( __DRIscreenPrivate *sPriv );
-
#endif /* __RADEON_SCREEN_H__ */
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;
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;
switch ( rmesa->radeonScreen->cpp ) {
case 2:
+#if 0
swdd->WriteRGBASpan = radeonWriteRGBASpan_RGB565;
swdd->WriteRGBSpan = radeonWriteRGBSpan_RGB565;
swdd->WriteMonoRGBASpan = radeonWriteMonoRGBASpan_RGB565;
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;
swdd->WriteMonoRGBAPixels = radeonWriteMonoRGBAPixels_ARGB8888;
swdd->ReadRGBASpan = radeonReadRGBASpan_ARGB8888;
swdd->ReadRGBAPixels = radeonReadRGBAPixels_ARGB8888;
+#endif
break;
default:
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;
swdd->WriteStencilSpan = radeonWriteStencilSpan_24_8;
swdd->ReadStencilPixels = radeonReadStencilPixels_24_8;
swdd->WriteStencilPixels = radeonWriteStencilPixels_24_8;
+#endif
break;
default:
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;
+ }
+}
#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
/*
* _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;
#include "mtypes.h"
#include "drm.h"
#include "mm.h"
+#include "drirenderbuffer.h"
/* Flags for context */
#define S3V_FRONT_BUFFER 0x00000001
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 );
#endif
#include "context.h"
+#include "framebuffer.h"
#include "swrast/swrast.h"
#define S3V_DATE "20020207"
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:
*/
* Author: Max Lingua <sunmax@libero.it>
*/
+#include "mtypes.h"
+
typedef struct _s3vRegion {
drm_handle_t handle;
drmSize size;
int textureSize;
int logTextureGranularity;
} s3vScreenRec, *s3vScreenPtr;
+
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;
swdd->SetBuffer = s3vSetBuffer;
+#if 0
switch ( vmesa->s3vScreen->cpp ) {
case 2:
swdd->WriteRGBASpan = s3vWriteRGBASpan_RGB555;
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
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;
+ }
+}
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;
DMAFINISH();
DEBUG(("vmesa->ClearDepth = 0x%x\n", vmesa->ClearDepth));
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
if (!vmesa->NotClipped) {
#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"
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? */
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);
}
}
*/
/*
- _mesa_make_current2( newVirgeCtx->glCtx,
+ _mesa_make_current( newVirgeCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
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,
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;
} 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 );
#include "savagecontext.h"
#include "context.h"
#include "matrix.h"
-
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "simple_list.h"
#include "utils.h"
}
}
+
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);
}
}
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:
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;
}
#include "mtypes.h"
+#include "framebuffer.h"
#include <stdio.h>
void savageDDInitDriverFuncs( GLcontext *ctx )
{
ctx->Driver.GetBufferSize = savageBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
ctx->Driver.GetString = savageDDGetString;
}
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);
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];
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;
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;
swdd->WriteStencilSpan = savageWriteStencilSpan_8_24;
swdd->ReadStencilPixels = savageReadStencilPixels_8_24;
swdd->WriteStencilPixels = savageWriteStencilPixels_8_24;
+#endif
break;
}
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;
+ }
+}
#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
}
#undef _1
+
#endif
/*
* _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;
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;
/* 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();
/* 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();
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 );
dirtyflags |= GFLAG_STENCILSETTING;
}
- if (mask & DD_FRONT_LEFT_BIT) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
pExtents = smesa->driDrawable->pClipRects;
count = smesa->driDrawable->numClipRects;
} else {
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
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;
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 */
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;
#include "sis_tris.h"
#include "swrast/swrast.h"
+#include "framebuffer.h"
#include "utils.h"
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;
}
#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"
sPriv->private = NULL;
}
+
/* Create and initialize the Mesa and driver specific pixmap buffer
* data.
*/
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);
}
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;
switch (smesa->zFormat)
{
case SiS_ZFORMAT_Z16:
+#if 0
swdd->ReadDepthSpan = sisReadDepthSpan_16;
swdd->ReadDepthPixels = sisReadDepthPixels_16;
swdd->WriteDepthSpan = sisWriteDepthSpan_16;
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;
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;
swdd->ReadStencilPixels = sisReadStencilPixels_24_8;
swdd->WriteStencilSpan = sisWriteStencilSpan_24_8;
swdd->WriteStencilPixels = sisWriteStencilPixels_24_8;
+#endif
break;
}
+#if 0
switch ( smesa->bytesPerPixel )
{
case 2:
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;
+ }
+}
#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
/*
* _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:
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);
/* 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 */
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;
#include "context.h"
#include "enums.h"
+#include "framebuffer.h"
#include "swrast/swrast.h"
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
functions->GetString = tdfxDDGetString;
functions->GetBufferSize = tdfxDDGetBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
/* Accelerated paths
*/
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,
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,
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;
}
/* 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;
}
}
/* 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);
}
}
* 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,
* 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);
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/
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);
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);
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);
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);
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);
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);
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.
*/
#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;
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);
}
}
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;
}
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;
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;
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;
#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;
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;
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;
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;
(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:
swdd->SetBuffer = tdfxDDSetBuffer;
+#if 0
if ( VISUAL_EQUALS_RGBA(ctx->Visual, 5, 6, 5, 0) )
{
/* 16bpp mode */
{
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;
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;
+ }
+}
#define __TDFX_SPAN_H__
#include "context.h"
+#include "drirenderbuffer.h"
extern void tdfxDDInitSpanFuncs( GLcontext *ctx );
+extern void
+tdfxSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
#endif
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;
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 );
#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"
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? */
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);
}
}
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;
}
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 */
#include "swrast/swrast.h"
#include "context.h"
+#include "framebuffer.h"
#define TRIDENT_DATE "20041223"
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:
*/
#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))
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);
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:
*/
#include "state.h"
#include "simple_list.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
}
-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 );
}
/* 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) {
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;
vmesa->pClipRects = dPriv->pBackClipRects;
}
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
vmesa->numClipRects = dPriv->numClipRects;
vmesa->pClipRects = dPriv->pClipRects;
break;
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,
vmesa->glCtx->Scissor.Height);
}
else {
- _mesa_make_current(0,0);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
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,
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)
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);
}
#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"
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);
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);
}
}
driOptionCache optionCache;
} viaScreenPrivate;
+
extern GLboolean
viaCreateContext(const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
{
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 {
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 );
}
else {
assert(0);
}
-
+#endif
+#if 0
if (vmesa->glCtx->Visual.depthBits == 16) {
swdd->ReadDepthSpan = viaReadDepthSpan_16;
swdd->WriteDepthSpan = viaWriteDepthSpan_16;
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;
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;
+ }
}
#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
#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"
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;
};
/*
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))
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;
}
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. */
}
/* 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 */
}
-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;
return entry->func;
}
}
- return (const void *)_glapi_get_proc_address(procName);
+ return _glapi_get_proc_address(procName);
}
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,
const GLFBDevVisualPtr visual,
void *frontBuffer, void *backBuffer, size_t size )
{
+ struct GLFBDevRenderbufferRec *frontrb, *backrb;
GLFBDevBufferPtr buf;
ASSERT(visual);
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;
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);
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;
_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);
}
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 */
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);
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;
/*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 |
/*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 |
/*CLIP_BIT |*/ /* clipping ok, below */
STENCIL_BIT |
MASKING_BIT |
- ALPHABUF_BIT |
MULTI_DRAW_BIT |
OCCLUSION_BIT | /* nope! at least not yet */
TEXTURE_BIT |
/*CLIP_BIT |*/ /* clipping ok, below */
STENCIL_BIT |
MASKING_BIT |
- ALPHABUF_BIT |
MULTI_DRAW_BIT |
OCCLUSION_BIT | /* nope! at least not yet */
TEXTURE_BIT |
/*CLIP_BIT |*/ /* clipping ok, below */
STENCIL_BIT |
MASKING_BIT |
- ALPHABUF_BIT |
MULTI_DRAW_BIT |
OCCLUSION_BIT | /* nope! at least not yet */
TEXTURE_BIT |
/*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 |
#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"
{
/* 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 )
{
}
-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"
+
+
/**********************************************************************/
_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;
+}
+
/**********************************************************************/
return NULL;
}
-
osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context);
if (osmesa) {
osmesa->gl_visual = _mesa_create_visual( rgbmode,
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,
_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;
/* 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 ) ||
}
_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;
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;
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,
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;
*bytesPerValue = sizeof(GLushort);
else
*bytesPerValue = sizeof(GLuint);
- *buffer = c->gl_buffer->DepthBuffer;
+ *buffer = rb->Data;
return GL_TRUE;
}
}
-/* $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
_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;
}
}
-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;
}
}
-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;
}
}
-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;
}
}
-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[] )
{
}
-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;
}
}
-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[] )
{
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 */
);
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 */
);
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;
if (!b) {
return 0;
}
- return b->frontbuffer;
+ return b->frontxrb->pixmap;
}
if (!b) {
return 0;
}
- return b->frontbuffer;
+ return b->frontxrb->pixmap;
}
/* A GLXPbuffer handle must be an X Drawable because that's what
* glXMakeCurrent takes.
*/
- return (GLXPbuffer) xmbuf->frontbuffer;
+ return (GLXPbuffer) xmbuf->frontxrb->pixmap;
}
{
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 */
}
/* A GLXPbuffer handle must be an X Drawable because that's what
* glXMakeCurrent takes.
*/
- return (GLXPbuffer) xmbuf->frontbuffer;
+ return (GLXPbuffer) xmbuf->frontxrb->pixmap;
}
struct itimerspec;
-
#endif /*GLX_HEADER*/
#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"
/* 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;
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) {
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;
}
_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;
}
-/*
+/**
* 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
/*
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;
/* 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;
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 */
* 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;
}
}
|| 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);
*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
XMesaDrawable window,
XMesaColormap cmap )
{
+#if NEW_RENDERBUFFER
+ struct xmesa_renderbuffer *front_xrb, *back_xrb;
+#endif
#ifndef XFree86Server
XGCValues gcvalues;
#endif
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);
if (b && window) {
/* Do window-specific initializations */
- b->frontbuffer = window;
+ b->frontxrb->pixmap = window;
/* Setup for single/double buffering */
if (v->mesa_visual.doubleBufferMode) {
#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 */
* 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++)
{
* 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;
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;
}
*/
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));
void XMesaDestroyVisual( XMesaVisual v )
{
#ifndef XFree86Server
- FREE(v->visinfo);
+ _mesa_free(v->visinfo);
#endif
- FREE(v);
+ _mesa_free(v);
}
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;
}
/* 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 */
{
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 );
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;
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 );
}
}
if (b->rowimage) {
- FREE( b->rowimage->data );
+ _mesa_free( b->rowimage->data );
b->rowimage->data = NULL;
XMesaDestroyImage( b->rowimage );
}
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;
}
{
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;
{
GET_CURRENT_CONTEXT(ctx);
if (ctx) {
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- return xmesa->xm_read_buffer;
+ return (XMesaBuffer) (ctx->ReadBuffer);
}
else {
return 0;
{
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;
}
GLboolean XMesaLoseCurrent(XMesaContext c)
{
(void) c;
- _mesa_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
return GL_TRUE;
}
* 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 {
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) {
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,
/* 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,
/* 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,
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);*/
#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);*/
}
/* 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 */
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??? */
}
#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 */
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 {
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;
*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;
}
}
{
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;
}
}
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 );
}
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);
*/
void XMesaResizeBuffers( XMesaBuffer b )
{
- xmesa_resize_buffers( &(b->mesa_buffer) );
-
+#if OLD_RENDERBUFFER && 0
+ xmesa_resize_buffers(ctx, &(b->mesa_buffer), 0, 0 );
+#endif
}
--- /dev/null
+/*
+ * 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;
+}
+
+
+
+
#include "depth.h"
#include "drawpix.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "macros.h"
#include "image.h"
#include "imports.h"
#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"
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;
_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
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 */
}
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
}
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);
+ }
}
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);
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 );
}
}
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;
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 );
}
}
/**********************************************************************/
+/**
+ * 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 );
}
}
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) {
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++;
}
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;
}
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;
}
/* 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;
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);
}
}
/* 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;
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;
}
}
}
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);
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
}
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);
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 */
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) {
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);
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 */
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) {
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);
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 */
/* 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 {
}
-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.
_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
+ }
}
/**
* 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
}
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 {
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);
}
}
/**********************************************************************/
+#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"
*/
#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"
*/
#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"
*/
#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"
*/
#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]; \
*/
#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"
*/
#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"
*/
#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"
*/
#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"
*/
#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"
*/
#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
#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"
*/
#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) { \
*/
#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) { \
*/
#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) { \
*/
#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) { \
*/
#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) { \
*/
#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) { \
*/
#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) { \
*/
#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; \
#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) { \
*/
#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) { \
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;
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
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) {
#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[]
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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++) {
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]) {
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++) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
*/
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]) {
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++) {
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++) {
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++) {
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++) {
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]) {
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]) {
*/
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]) {
*/
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]) {
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]) {
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]) {
*/
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++) {
}
-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++) {
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]) {
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]) {
*/
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]) {
*/
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]) {
#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[]
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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 );
}
}
}
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 );
}
}
}
*/
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] );
}
}
*/
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] );
}
}
*/
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] );
}
}
*/
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];
*/
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] );
}
}
*/
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] );
}
}
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] ) );
}
}
*/
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] );
}
}
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] ));
}
}
*/
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] );
}
}
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]) );
}
}
}
*/
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] );
}
}
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] ) );
}
}
*/
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] );
}
}
/**********************************************************************/
#define MONO_SPAN_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, const GLchan color[4], \
const GLubyte mask[]
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;
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.
-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;
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;
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]) {
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 ) );
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 );
}
-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 );
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;
*/
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;
*/
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;
*/
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]) {
*/
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;
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++) {
*/
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++) {
*/
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]);
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 ) );
*/
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]) {
*/
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]) {
*/
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);
/**********************************************************************/
#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[]
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;
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;
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_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;
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]) );
}
}
}
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;
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]) );
}
}
}
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;
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]) );
}
}
}
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 );
}
}
}
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 );
}
}
}
*/
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;
}
}
*/
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;
}
}
*/
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;
}
}
*/
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;
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 ) );
}
}
}
*/
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 );
}
}
*/
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;
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;
}
}
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 ));
}
}
*/
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 );
}
}
*/
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;
}
}
*/
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);
}
}
/*** 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[]
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]) {
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]) {
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]) {
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++) {
*/
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++) {
/**********************************************************************/
#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[]
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;
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]) );
}
}
}
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] );
}
}
}
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 */
/*
* 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
/*
* 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) {
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;
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 );
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;
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++;
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++;
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++;
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;
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++;
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++;
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];
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;
/*
* 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;
if (mask[i]) {
indx[i] = (GLuint) read_pixel( xmesa->display,
source->buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
}
}
}
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]) );
}
}
}
-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;
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];
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);
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);
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);
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);
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);
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];
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);
}
}
else if (source->backimage) {
+ /* Read from XImage back buffer */
switch (xmesa->pixelformat) {
case PF_Truecolor:
case PF_Dither_True:
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];
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);
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);
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);
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;
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;
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];
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);
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:
*/
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;
}
}
}
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;
}
}
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
+
#include "swrast/s_triangle.h"
+#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
+ (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]
+
/**********************************************************************/
/*** Triangle rendering ***/
#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); \
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; \
#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++) { \
#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; \
#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; \
#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++) { \
#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; \
#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++) { \
#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]) { \
#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); \
#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); \
#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; \
#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]) { \
#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]) { \
#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++) { \
#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++) { \
#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++) { \
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"
#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; \
#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]) { \
#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++) { \
#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]) { \
#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]) { \
#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); \
#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]) { \
#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]; \
#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), \
*/
#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++) { \
*/
#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++) { \
*/
#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++) { \
*/
#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; \
#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), \
*/
#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++) { \
*/
#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)); \
*/
#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), \
#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), \
*/
#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; \
*/
#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)); \
#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); \
}
* 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 ) \
* 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 ) \
* 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 ) \
* 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; \
#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], \
* 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 ) \
* 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]); \
* 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); \
}
*/
#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); \
* 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); \
}
* 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]; \
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;
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
/*
* 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"),
} 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 );
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 */
} 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.
*/
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 */
#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 */
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:
/* 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)], \
/* 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 ) \
#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); \
#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)), \
/*
* 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) )
* 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))
* 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 );
/*
* 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"),
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 );
ctx->Driver.Accum( ctx, op, value, xpos, ypos, width, height );
}
+
+
void
_mesa_init_accum( GLcontext *ctx )
{
(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);
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:
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;
}
}
switch (pname) {
case GL_BUFFER_SIZE_ARB:
- *params = bufObj->Size;
+ *params = (GLint) bufObj->Size;
break;
case GL_BUFFER_USAGE_ARB:
*params = bufObj->Usage;
#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
_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)
/* 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 );
}
}
/**
- * 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;
/**
* 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;
}
}
{
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
* 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.
*
*
* \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);
}
* \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 */
}
-/**********************************************************************/
-/** \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 */
/*@{*/
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 );
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);
/*
* 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"),
/** 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 */
/** For GL_EXT_framebuffer_object */
/*@{*/
-#define MAX_COLOR_ATTACHMENTS 4
+#define MAX_COLOR_ATTACHMENTS 8
/*@}*/
#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 */
#include "eval.h"
#include "enums.h"
#include "extensions.h"
+#include "fbobject.h"
#include "feedback.h"
#include "fog.h"
#include "get.h"
/**
* 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,
{
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;
}
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;
vis->numAuxBuffers = 0;
vis->level = 0;
vis->pixmapMode = 0;
+ vis->sampleBuffers = numSamples > 0 ? 1 : 0;
vis->samples = numSamples;
return GL_TRUE;
/*@}*/
-/**********************************************************************/
-/** \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
*
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
{
/* 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 );
}
-/**
- * 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.
* 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.
*/
_glapi_set_context((void *) newCtx);
ASSERT(_mesa_get_current_context() == newCtx);
-
if (!newCtx) {
_glapi_set_dispatch(NULL); /* none current */
}
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
/* 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;
}
/* 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
/*@}*/
-/**********************************************************************/
-/** \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. */
/*@{*/
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);
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.
/*@{*/
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
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) {
ctx->DepthMaxF = (GLfloat) ctx->DepthMax;
}
ctx->MRD = 1.0; /* Minimum resolvable depth value, for polygon offset */
+#endif
}
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);
}
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);
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;
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;
}
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;
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;
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;
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;
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;
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;
/* 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;
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;
#include "context.h"
#include "fbobject.h"
+#include "framebuffer.h"
#include "hash.h"
+#include "renderbuffer.h"
#include "teximage.h"
#include "texstore.h"
}
-/**
- * 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.
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;
}
* 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);
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;
}
* 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;
}
att->Zoffset = zoffset;
att->Complete = GL_FALSE;
+
texObj->RefCount++;
/* XXX when we attach to a texture, we should probably set the
* 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 */
}
+/**
+ * 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,
/* 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) {
}
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;
}
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;
}
}
}
+ 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;
}
}
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;
}
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,
if (oldRb) {
oldRb->RefCount--;
if (oldRb->RefCount == 0) {
- oldRb->Delete(ctx, oldRb);
+ oldRb->Delete(oldRb);
}
}
*/
rb->RefCount--;
if (rb->RefCount == 0) {
- rb->Delete(ctx, rb);
+ rb->Delete(rb);
}
}
}
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)");
rb->_BaseFormat = GL_NONE;
}
+ /*
+ test_framebuffer_completeness(ctx, fb);
+ */
/* XXX if this renderbuffer is attached anywhere, invalidate attachment
* points???
*/
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,
}
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 */
_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;
}
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]);
*/
fb->RefCount--;
if (fb->RefCount == 0) {
- fb->Delete(ctx, fb);
+ fb->Delete(fb);
}
}
}
{
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;
}
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) ||
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))
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)");
}
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,
"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);
}
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))
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)");
}
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,
"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);
}
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))
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)");
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,
"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);
}
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,
}
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)");
}
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);
}
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)");
#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);
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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 */
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]);
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);
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;
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);
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);
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]);
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);
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);
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);
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);
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);
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);
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);
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];
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;
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);
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;
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;
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]);
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);
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;
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);
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);
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);
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);
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);
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]);
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);
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);
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);
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);
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]);
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;
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);
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;
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;
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;
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);
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);
# - 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]",
"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 ),
"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 ),
"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,
( "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 ),
( "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 ),
["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",
( "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 ),
["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 ),
["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,
( "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"], "",
_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);
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;
* 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);
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) {
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;
#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
*/
/*@{*/
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;
/*@}*/
/**
- * 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)
/**
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
*/
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;
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 */
};
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
FetchTexelFuncF FetchTexel2Df;
FetchTexelFuncF FetchTexel3Df;
/*@}*/
+
+ StoreTexelFunc StoreTexel;
};
};
+
+
/**
- * 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);
};
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
/*@}*/
#if FEATURE_EXT_framebuffer_object
- struct gl_framebuffer *CurrentFramebuffer;
+ /*struct gl_framebuffer *CurrentFramebuffer;*/
struct gl_renderbuffer *CurrentRenderbuffer;
#endif
* 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;
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 */
_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
+ 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 */
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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 */
#if FEATURE_EXT_framebuffer_object
#include "fbobject.h"
#endif
+#include "framebuffer.h"
#include "hint.h"
#include "histogram.h"
#include "imports.h"
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 );
_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 */
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 */
};
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 */
};
/*@}*/
fetch_null_texelf, /* FetchTexel1Df */
fetch_null_texelf, /* FetchTexel2Df */
fetch_null_texelf, /* FetchTexel3Df */
+ store_null_texel /* StoreTexel */
};
/*@}*/
#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)))
#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)))
#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))
#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 );
}
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];
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;
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];
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];
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];
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.
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]));
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]);
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]));
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;
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;
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];
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];
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];
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];
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] =
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] =
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 );
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 );
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 );
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] );
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] );
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 );
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);
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 );
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);
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 );
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);
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 );
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 );
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);
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 );
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);
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 );
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 );
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 );
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);
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;
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] );
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] =
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.
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;
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 */
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 */
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 */
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 */
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 */
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 */
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
--- /dev/null
+
+#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);
+ }
+}
--- /dev/null
+#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 */
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.
}
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.
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.
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;
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;
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;
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;
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;
main/fbobject.c \
main/feedback.c \
main/fog.c \
+ main/framebuffer.c \
main/get.c \
main/getstring.c \
main/hash.c \
main/points.c \
main/polygon.c \
main/rastpos.c \
+ main/renderbuffer.c \
main/state.c \
main/stencil.c \
main/texcompress.c \
main/texenvprogram.c \
main/texformat.c \
main/teximage.c \
+ main/texrender.c \
main/texobj.c \
main/texstate.c \
main/texstore.c \
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 \
SPARC_API = \
sparc/glapi_sparc.S
-COMMON_DRIVER_SOURCES = \
+COMMON_DRIVER_SOURCES = \
drivers/common/driverfuncs.c
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 = \
/*
* 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"),
#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
* 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;
-
-
-
-/*
+/**
* 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);
}
/*
* 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"),
#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
+++ /dev/null
-/*
- * 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;
- }
- }
-}
+++ /dev/null
-
-/*
- * 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
+++ /dev/null
-/*
- * 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;
-}
-
+++ /dev/null
-/*
- * 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 */
/*
* 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"),
#include "colormac.h"
#include "macros.h"
-#include "s_alphabuf.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_span.h"
* 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];
/* 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,
-
/*
* 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"),
#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
* 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"),
#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"
/**
- * 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
}
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);
}
}
}
* \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
/* 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);
}
}
}
-/**
- * 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()
*/
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);
}
* 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);
}
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
* 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;
}
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);
- }
}
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++)
#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 */
GLboolean _IntegerAccumMode; /**< Storing unscaled integers? */
GLfloat _IntegerAccumScaler; /**< Implicit scale factor */
- GLchan *CurAuxBuffer;
-
/* Working values:
*/
GLuint StippleCounter; /**< Line stipple counter */
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;
&& destx >= 0
&& destx + width <= (GLint) ctx->DrawBuffer->Width) {
quick_draw = GL_TRUE;
+ drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
}
else {
quick_draw = GL_FALSE;
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;
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;
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;
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) {
&& 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 */
/* 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;
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);
}
/* 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;
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 */
/* 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;
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);
}
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;
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) {
}
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;
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 */
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;
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 */
}
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;
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 */
/*
* 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"),
#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;
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;
/*
- * 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) {
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];
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 */
}
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];
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 */
}
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];
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 */
}
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];
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 */
}
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];
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 */
}
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];
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 */
}
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];
}
}
_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) {
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];
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 */
}
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];
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 */
}
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];
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 */
}
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];
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 */
}
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];
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 */
}
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];
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 */
}
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];
}
}
_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 */
}
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;
}
}
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;
}
/**
* 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++)
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;
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);
}
}
}
/*
* 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"),
#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);
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
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;
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);
/* 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++;
}
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;
}
}
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++;
}
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;
}
}
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++;
}
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;
}
}
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++;
}
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;
}
}
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++;
}
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;
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++;
}
}
else {
/* General case */
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
GLint row, skipPixels = 0;
/* in case width > MAX_WIDTH do the copy in chunks */
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) {
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;
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) {
/* 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,
-
/*
* 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"),
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]);
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 );
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 );
}
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 );
}
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);
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);
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);
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);
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 );
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);
/* 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);
#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;
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);
-
/*
* 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"),
#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);
}
* 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];
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;
}
-
/*
* 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"),
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
-
/*
* 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"),
#include "enums.h"
#include "macros.h"
-#include "s_alphabuf.h"
#include "s_context.h"
#include "s_masking.h"
#include "s_span.h"
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];
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
}
-
-
/*
* 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;
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);
}
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);
}
}
-
/*
* 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"),
* 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
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;
* 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;
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)) {
}
/* 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);
}
}
#include "imports.h"
#include "pixel.h"
-#include "s_alphabuf.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_span.h"
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 */
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);
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 */
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 &&
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
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];
}
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 {
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);
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 &&
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);
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;
}
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++;
}
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:
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;
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);
}
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);
}
* 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"),
#include "s_atifragshader.h"
#include "s_alpha.h"
-#include "s_alphabuf.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_depth.h"
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;
}
}
}
span->arrayMask |= SPAN_INDEX;
+ span->interpMask &= ~SPAN_INDEX;
}
}
-
/**
- * 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 ||
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);
else {
ASSERT(ctx->Depth.Test);
if (!_swrast_depth_test_span(ctx, span)) {
+ span->interpMask = origInterpMask;
span->arrayMask = origArrayMask;
return;
}
}
/* 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 */
/* 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;
}
}
+/**
+ * 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).
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;
return;
}
}
- else {
+ else if (ctx->DrawBuffer->Visual.depthBits > 0) {
/* Just regular depth testing */
ASSERT(ctx->Depth.Test);
ASSERT(span->arrayMask & SPAN_Z);
}
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
}
}
* 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 {
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
}
}
* 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;
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);
+ }
}
}
* 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"),
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
-
/*
* 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"),
#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) {
}
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) {
}
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) {
}
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++) {
}
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++) {
}
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++) {
}
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);
}
}
#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) {
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) {
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++) {
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++) {
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++) {
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);
}
}
/*
* 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"),
#include "context.h"
#include "macros.h"
#include "imports.h"
+#include "fbobject.h"
#include "s_context.h"
#include "s_depth.h"
*/
-/*
- * 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.
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;
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.
/*
* 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;
+/*
+ * 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
* 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:
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
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 */
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 */
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 */
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 */
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 */
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 */
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));
}
/* 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. */
}
+#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
* 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 */
}
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);
}
* 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);
- }
-}
-
/*
* 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"),
_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
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
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;
}
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;
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;
}
* 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"),
#include "imports.h"
#include "macros.h"
#include "texformat.h"
-#include "teximage.h"
-#include "texstate.h"
#include "s_aatriangle.h"
#include "s_context.h"
#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; \
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"
#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; \
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"
#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); \
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]) { \
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; \
} 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;
#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
}
# 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
}
/* ff = fixed-pt fragment */
const GLint right = InterpToInt(fxRightEdge);
span.x = InterpToInt(fxLeftEdge);
-
if (right <= span.x)
span.end = 0;
else
* 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"),
/* These are the public-access functions exported from swrast.
*/
-extern void
-_swrast_alloc_buffers( GLframebuffer *buffer );
-
extern void
_swrast_use_read_buffer( 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.
* 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:
*** 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.
* 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
* 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.
* 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.
*** 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.
*/
*** 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.
* 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.
*/
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];
-
/*
* 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"),
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);
}
}
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);
}
}