dri/drivers: update driNewRenderbuffer() to take a gl_format
authorBrian Paul <brianp@vmware.com>
Fri, 23 Oct 2009 01:49:21 +0000 (19:49 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 23 Oct 2009 01:57:32 +0000 (19:57 -0600)
Now pass a specific MESA_FORMAT_x token to indicate the renderbuffer's
format.  This is better than passing a GLenum and having to guess the
specific format.

I'm unable to test all the drivers, but any issues should be easy to fix.

20 files changed:
src/mesa/drivers/dri/common/drirenderbuffer.c
src/mesa/drivers/dri/common/drirenderbuffer.h
src/mesa/drivers/dri/fb/fb_dri.c
src/mesa/drivers/dri/fb/fb_egl.c
src/mesa/drivers/dri/ffb/ffb_xmesa.c
src/mesa/drivers/dri/i810/i810screen.c
src/mesa/drivers/dri/mach64/mach64_screen.c
src/mesa/drivers/dri/mach64/mach64_span.c
src/mesa/drivers/dri/mga/mga_xmesa.c
src/mesa/drivers/dri/mga/mgaspan.c
src/mesa/drivers/dri/r128/r128_screen.c
src/mesa/drivers/dri/r128/r128_span.c
src/mesa/drivers/dri/s3v/s3v_xmesa.c
src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/savage/savagespan.c
src/mesa/drivers/dri/sis/sis_span.c
src/mesa/drivers/dri/tdfx/tdfx_screen.c
src/mesa/drivers/dri/trident/trident_context.c
src/mesa/drivers/dri/unichrome/via_screen.c
src/mesa/drivers/dri/unichrome/via_span.c

index 6fa1c6caa0134b513e3b7b4f5009c8134424ae1f..4e7e92c82bc89debaf96c6163021abd696f20bc2 100644 (file)
@@ -54,7 +54,7 @@ driDeleteRenderbuffer(struct gl_renderbuffer *rb)
  * \param pitch   pixels per row
  */
 driRenderbuffer *
-driNewRenderbuffer(GLenum format, GLvoid *addr,
+driNewRenderbuffer(gl_format format, GLvoid *addr,
                    GLint cpp, GLint offset, GLint pitch,
                    __DRIdrawablePrivate *dPriv)
 {
@@ -80,46 +80,47 @@ driNewRenderbuffer(GLenum format, GLvoid *addr,
       /* 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 || format == GL_RGB5 || format == GL_RGBA8) {
-         /* Color */
-         drb->Base.DataType = GL_UNSIGNED_BYTE;
-         if (format == GL_RGB5) {
-            drb->Base.Format = MESA_FORMAT_RGB565;
+      switch (format) {
+      case MESA_FORMAT_ARGB8888:
+         if (cpp == 2) {
+            /* override format */
+            format = MESA_FORMAT_RGB565;
          }
-         else {
-            drb->Base.Format = MESA_FORMAT_ARGB8888;
-         }
-      }
-      else if (format == GL_DEPTH_COMPONENT16) {
-         /* Depth */
-         /* we always Get/Put 32-bit Z values */
-         drb->Base.DataType = GL_UNSIGNED_INT;
-         drb->Base.Format = MESA_FORMAT_Z16;
-      }
-      else if (format == GL_DEPTH_COMPONENT24) {
+         drb->Base.DataType = GL_UNSIGNED_BYTE;
+         break;
+      case MESA_FORMAT_Z16:
          /* Depth */
          /* we always Get/Put 32-bit Z values */
          drb->Base.DataType = GL_UNSIGNED_INT;
-         drb->Base.Format = MESA_FORMAT_Z32;
-      }
-      else if (format == GL_DEPTH_COMPONENT32) {
+         assert(cpp == 2);
+         break;
+      case MESA_FORMAT_Z32:
          /* Depth */
          /* we always Get/Put 32-bit Z values */
          drb->Base.DataType = GL_UNSIGNED_INT;
-         drb->Base.Format = MESA_FORMAT_Z32;
-      }
-      else {
+         assert(cpp == 4);
+         break;
+      case MESA_FORMAT_Z24_S8:
+         drb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+         assert(cpp == 4);
+         break;
+      case MESA_FORMAT_S8_Z24:
+         drb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+         assert(cpp == 4);
+         break;
+      case MESA_FORMAT_S8:
          /* Stencil */
-         ASSERT(format == GL_STENCIL_INDEX8_EXT);
          drb->Base.DataType = GL_UNSIGNED_BYTE;
-         drb->Base.Format = MESA_FORMAT_S8;
+         break;
+      default:
+         _mesa_problem(NULL, "Bad format 0x%x in driNewRenderbuffer", format);
+         return NULL;
       }
 
-      /* XXX if we were allocating a user-created renderbuffer, we'd have
-       * to fill in the Red/Green/Blue/.../Bits values too.
-       */
+      drb->Base.Format = format;
+
+      drb->Base.InternalFormat =
+      drb->Base._BaseFormat = _mesa_get_format_base_format(format);
 
       drb->Base.AllocStorage = driRenderbufferStorage;
       drb->Base.Delete = driDeleteRenderbuffer;
index cf55286b30fd066e1302be52517db8b5d1e92cd3..9712c0017bad1d5a913ab039831645981d0876f3 100644 (file)
@@ -11,6 +11,7 @@
 #define DRIRENDERBUFFER_H
 
 #include "main/mtypes.h"
+#include "main/formats.h"
 #include "dri_util.h"
 
 
@@ -63,7 +64,7 @@ typedef struct {
 
 
 extern driRenderbuffer *
-driNewRenderbuffer(GLenum format, GLvoid *addr,
+driNewRenderbuffer(gl_format format, GLvoid *addr,
                    GLint cpp, GLint offset, GLint pitch,
                    __DRIdrawablePrivate *dPriv);
 
index 571b8922d5d6cc7e819cb264fed0c1818b402b59..fd869b2fe7dace1737762ee0ad9c159287f15e90 100644 (file)
@@ -437,7 +437,7 @@ fbCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       /* XXX double-check these parameters (bpp vs cpp, etc) */
       {
-         driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA,
+         driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                                    driScrnPriv->pFB,
                                                    driScrnPriv->fbBPP / 8,
                                                    driScrnPriv->fbOrigin,
@@ -451,7 +451,7 @@ fbCreateBuffer( __DRIscreenPrivate *driScrnPriv,
          /* XXX what are the correct origin/stride values? */
          GLvoid *backBuf = _mesa_malloc(driScrnPriv->fbStride
                                         * driScrnPriv->fbHeight);
-         driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA,
+         driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                                    backBuf,
                                                    driScrnPriv->fbBPP /8,
                                                    driScrnPriv->fbOrigin,
index 4e41860d8c8fe70000fbb9337e8a9918daffbf13..eb7adf8224b01fa90c3195b84c2732bcd9851f82 100644 (file)
@@ -692,7 +692,7 @@ fbCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg,
 
    /* front color renderbuffer */
    {
-      driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, display->pFB,
+      driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, display->pFB,
                                                 bytesPerPixel,
                                                 origin, stride, NULL);
       fbSetSpanFunctions(drb, &vis);
@@ -703,7 +703,7 @@ fbCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg,
    /* back color renderbuffer */
    if (vis.doubleBufferMode) {
       GLubyte *backBuf = _mesa_malloc(stride * height);
-      driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, backBuf,
+      driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, backBuf,
                                                 bytesPerPixel,
                                                 origin, stride, NULL);
       fbSetSpanFunctions(drb, &vis);
index 3b9f5c675919c8858c80df1efb38404b4e1d5923..09cc26d09eb59217b485dfc22b4dfd85b2cde95f 100644 (file)
@@ -347,7 +347,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL, bpp, offset, bogusPitch,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, bpp, offset, bogusPitch,
                                  driDrawPriv);
          ffbSetSpanFunctions(frontRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
@@ -355,7 +355,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL, bpp, offset, bogusPitch,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, bpp, offset, bogusPitch,
                                  driDrawPriv);
          ffbSetSpanFunctions(backRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
@@ -363,7 +363,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, bpp, offset,
+            = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, bpp, offset,
                                  bogusPitch, driDrawPriv);
          ffbSetDepthFunctions(depthRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
@@ -371,7 +371,7 @@ ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL, bpp, offset,
+            = driNewRenderbuffer(MESA_FORMAT_S8, NULL, bpp, offset,
                                  bogusPitch, driDrawPriv);
          ffbSetStencilFunctions(stencilRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
index 6e49f3466c3ccea78b6aa50c9f81621fdcef6a48..b0256abbfb3c358798cf1709f228c45efa2fea33 100644 (file)
@@ -293,7 +293,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  driScrnPriv->pFB,
                                  screen->cpp,
                                  /*screen->frontOffset*/0, screen->backPitch,
@@ -304,7 +304,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  screen->back.map,
                                  screen->cpp,
                                  screen->backOffset, screen->backPitch,
@@ -315,7 +315,7 @@ i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  screen->depth.map,
                                  screen->cpp,
                                  screen->depthOffset, screen->backPitch,
index 6440027ca4a6f0976c3c0c1c83ca295859e81e59..a7222ec96003905a19a121c1d1b7b77a6381955f 100644 (file)
@@ -316,7 +316,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->frontOffset, screen->frontPitch,
@@ -327,7 +327,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->backOffset, screen->backPitch,
@@ -338,7 +338,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  NULL, screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
                                  driDrawPriv);
@@ -348,7 +348,7 @@ mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
       else if (mesaVis->depthBits == 24) {
          /* XXX I don't think 24-bit Z is supported - so this isn't used */
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+            = driNewRenderbuffer(MESA_FORMAT_Z24_S8,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
index 91d46ce32eb4f76c54170e54b27b4bdd56b8f91c..500319e0e31f4a9ff9e3adce80ee55237e1ac7f3 100644 (file)
@@ -157,15 +157,13 @@ void mach64DDInitSpanFuncs( GLcontext *ctx )
 void
 mach64SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
 {
-   if (drb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         mach64InitPointers_RGB565(&drb->Base);
-      }
-      else {
-         mach64InitPointers_ARGB8888(&drb->Base);
-      }
+   if (drb->Base.Format == MESA_FORMAT_RGB565) {
+      mach64InitPointers_RGB565(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+      mach64InitPointers_ARGB8888(&drb->Base);
+   }
+   else if (drb->Base.Format == MESA_FORMAT_Z16) {
       mach64InitDepthPointers_z16(&drb->Base);
    }
 }
index 0dc76fea50a490ad6a850c17f09940250b3c591d..4ca71ca505af5257bc9c6e56bfa06628079d7ddf 100644 (file)
@@ -723,7 +723,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->frontOffset, screen->frontPitch,
@@ -734,7 +734,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->backOffset, screen->backPitch,
@@ -745,7 +745,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -757,7 +757,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
          /* XXX is this right? */
          if (mesaVis->stencilBits) {
             driRenderbuffer *depthRb
-               = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+               = driNewRenderbuffer(MESA_FORMAT_Z24_S8,
                                     NULL,
                                     screen->cpp,
                                     screen->depthOffset, screen->depthPitch,
@@ -767,7 +767,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
          }
          else {
             driRenderbuffer *depthRb
-               = driNewRenderbuffer(GL_DEPTH_COMPONENT32,
+               = driNewRenderbuffer(MESA_FORMAT_Z32,
                                     NULL,
                                     screen->cpp,
                                     screen->depthOffset, screen->depthPitch,
@@ -778,7 +778,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 32) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT32,
+            = driNewRenderbuffer(MESA_FORMAT_Z32,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -789,7 +789,7 @@ mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,
+            = driNewRenderbuffer(MESA_FORMAT_S8,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
index 5b6d323ca98de16325a321ac9cace926fe570564..2ff1cac8e24c41dd532e66f3569e297cbcd655c1 100644 (file)
@@ -206,24 +206,22 @@ void mgaDDInitSpanFuncs( GLcontext *ctx )
 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);
-      }
+   if (drb->Base.Format == MESA_FORMAT_RGB565) {
+      mgaInitPointers_565(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+      mgaInitPointers_8888(&drb->Base);
+   }
+   else if (drb->Base.Format == MESA_FORMAT_Z16) {
       mgaInitDepthPointers_z16(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (drb->Base.Format == MESA_FORMAT_Z24_S8) {
       mgaInitDepthPointers_z24_s8(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+   else if (drb->Base.Format == MESA_FORMAT_Z32) {
       mgaInitDepthPointers_z32(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (drb->Base.Format == MESA_FORMAT_S8) {
       mgaInitStencilPointers_z24_s8(&drb->Base);
    }
 }
index f5bcc2f2906bd414486c3d0319c8d858e5a68c14..652dad51f2abd48d7243e9c75d85b8eb42c58fd3 100644 (file)
@@ -284,7 +284,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->frontOffset, screen->frontPitch,
@@ -295,7 +295,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  NULL,
                                  screen->cpp,
                                  screen->backOffset, screen->backPitch,
@@ -306,7 +306,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -316,7 +316,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+            = driNewRenderbuffer(MESA_FORMAT_S8_Z24,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
@@ -327,7 +327,7 @@ r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,
+            = driNewRenderbuffer(MESA_FORMAT_S8,
                                  NULL,
                                  screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
index dd177e0def5cceef049858cb7d5f454a02079393..d238cc3c9419bf26ca4698bfa88319e41c6d85c3 100644 (file)
@@ -433,21 +433,19 @@ void r128DDInitSpanFuncs( GLcontext *ctx )
 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);
-      }
+   if (drb->Base.Format == MESA_FORMAT_RGB565) {
+      r128InitPointers_RGB565(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+      r128InitPointers_ARGB8888(&drb->Base);
+   }
+   else if (drb->Base.Format == MESA_FORMAT_Z16) {
       r128InitDepthPointers_z16(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (drb->Base.Format == MESA_FORMAT_S8_Z24) {
       r128InitDepthPointers_z24_s8(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (drb->Base.Format == MESA_FORMAT_S8) {
       radeonInitStencilPointers_z24_s8(&drb->Base);
    }
 }
index 85f148176965912d87993bfed1b45a5d249bf3fd..f1e123d67697b758f2bbbee89051edaeda7dd193 100644 (file)
@@ -70,7 +70,7 @@ s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
                                  screen->frontOffset, screen->frontPitch,
                                  driDrawPriv);
          s3vSetSpanFunctions(frontRb, mesaVis);
@@ -79,7 +79,7 @@ s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
                                  screen->backOffset, screen->backPitch,
                                  driDrawPriv);
          s3vSetSpanFunctions(backRb, mesaVis);
@@ -89,7 +89,7 @@ s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
                                  driDrawPriv);
          s3vSetSpanFunctions(depthRb, mesaVis);
@@ -97,7 +97,7 @@ s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_Z24_S8, NULL, screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
                                  driDrawPriv);
          s3vSetSpanFunctions(depthRb, mesaVis);
@@ -107,7 +107,7 @@ s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       /* no h/w stencil yet?
       if (mesaVis->stencilBits > 0) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_S8, NULL,
                                  screen->cpp, screen->depthOffset,
                                  screen->depthPitch, driDrawPriv);
          s3vSetSpanFunctions(stencilRb, mesaVis);
index 048fbe452c2cd9a419adb3fcaa2119c9bfa15182..9eea7283196aaf7314387a879cdc2bcee0c8daa0 100644 (file)
@@ -602,7 +602,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_FRONT,
                                  screen->cpp,
@@ -615,7 +615,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_BACK,
                                  screen->cpp,
@@ -628,7 +628,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
+            = driNewRenderbuffer(MESA_FORMAT_Z16,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_DEPTH,
                                  screen->zpp,
@@ -639,7 +639,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
+            = driNewRenderbuffer(MESA_FORMAT_S8_Z24,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_DEPTH,
                                  screen->zpp,
@@ -651,7 +651,7 @@ savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,
+            = driNewRenderbuffer(MESA_FORMAT_S8,
                                  (GLubyte *) screen->aperture.map
                                  + 0x01000000 * TARGET_DEPTH,
                                  screen->zpp,
index 9615e34013ce8ac6553832ffd7dd09efead26f11..3bb6fbcc63c0839c99a98f8fb42b9a59abee3a3b 100644 (file)
@@ -255,15 +255,13 @@ 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);
-      }
+   if (drb->Base.Format == MESA_FORMAT_RGB565) {
+      savageInitPointers_565(&drb->Base);
+   }
+   else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
+      savageInitPointers_8888(&drb->Base);
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (drb->Base.Format == MESA_FORMAT_Z16) {
       if (float_depth) {
          savageInitDepthPointers_z16f(&drb->Base);
       }
@@ -271,7 +269,7 @@ savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
          savageInitDepthPointers_z16(&drb->Base);
       }
    }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (drb->Base.Format == MESA_FORMAT_S8_Z24) {
       if (float_depth) {
          savageInitDepthPointers_s8_z24f(&drb->Base);
       }
@@ -279,7 +277,7 @@ savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
          savageInitDepthPointers_s8_z24(&drb->Base);
       }
    }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (drb->Base.Format == MESA_FORMAT_S8) {
       savageInitStencilPointers_s8_z24(&drb->Base);
    }
 }
index 9e9a509755d8090577877ad26338fdeaa802fe5f..cfbb51007d10668b5351446087ad904b446f94bd 100644 (file)
@@ -176,24 +176,22 @@ sisDDInitSpanFuncs( GLcontext *ctx )
 void
 sisSetSpanFunctions(struct sis_renderbuffer *srb, const GLvisual *vis)
 {
-   if (srb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         sisInitPointers_RGB565( &srb->Base );
-      }
-      else {
-         sisInitPointers_ARGB8888( &srb->Base );
-      }
+   if (srb->Base.Format == MESA_FORMAT_RGB565) {
+      sisInitPointers_RGB565( &srb->Base );
    }
-   else if (srb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (srb->Base.Format == MESA_FORMAT_ARGB8888) {
+      sisInitPointers_ARGB8888( &srb->Base );
+   }
+   else if (srb->Base.Format == MESA_FORMAT_Z16) {
       sisInitDepthPointers_z16(&srb->Base);
    }
-   else if (srb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (srb->Base.Format == MESA_FORMAT_S8_Z24) {
       sisInitDepthPointers_z24_s8(&srb->Base);
    }
-   else if (srb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+   else if (srb->Base.Format == MESA_FORMAT_Z32) {
       sisInitDepthPointers_z32(&srb->Base);
    }
-   else if (srb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (srb->Base.Format == MESA_FORMAT_S8) {
       sisInitStencilPointers_z24_s8(&srb->Base);
    }
 }
index 58bd48b294ce63e15cf776d4f7ef094be8114290..c29694679de6f82efa819bbe61a49192bb72e74b 100644 (file)
@@ -173,7 +173,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
                                  screen->fbOffset, screen->width, driDrawPriv);
          tdfxSetSpanFunctions(frontRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
@@ -181,7 +181,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
                                  screen->backOffset, screen->width,
                                  driDrawPriv);
          tdfxSetSpanFunctions(backRb, mesaVis);
@@ -191,7 +191,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, screen->cpp,
                                  screen->depthOffset, screen->width,
                                  driDrawPriv);
          tdfxSetSpanFunctions(depthRb, mesaVis);
@@ -199,7 +199,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_Z24_S8, NULL, screen->cpp,
                                  screen->depthOffset, screen->width,
                                  driDrawPriv);
          tdfxSetSpanFunctions(depthRb, mesaVis);
@@ -208,7 +208,7 @@ tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_S8, NULL, screen->cpp,
                                  screen->depthOffset, screen->width,
                                  driDrawPriv);
          tdfxSetSpanFunctions(stencilRb, mesaVis);
index b5126b07ea641595dd602111a4606cea99ccac7b..b693a95ece0e746c038f83aea2c8f75b55e5cd03 100644 (file)
@@ -215,7 +215,7 @@ tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
                                  screen->frontOffset, screen->frontPitch,
                                  driDrawPriv);
          /*
@@ -226,7 +226,7 @@ tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL, screen->cpp,
                                  screen->backOffset, screen->backPitch,
                                  driDrawPriv);
          /*
@@ -237,7 +237,7 @@ tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_Z16, NULL, screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
                                  driDrawPriv);
          /*
@@ -247,7 +247,7 @@ tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp,
+            = driNewRenderbuffer(MESA_FORMAT_Z24_S8, NULL, screen->cpp,
                                  screen->depthOffset, screen->depthPitch,
                                  driDrawPriv);
          /*
@@ -259,7 +259,7 @@ tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
       /* no h/w stencil?
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
+            = driNewRenderbuffer(MESA_FORMAT_S8);
          tridentSetSpanFunctions(stencilRb, mesaVis);
          _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
       }
index 3dbb5705710382e7e723df17c506e2744b663117..5b5477d8e01075701a0bf51ab272b7a616e17e1a 100644 (file)
@@ -248,7 +248,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
       /* XXX check/fix the offset/pitch parameters! */
       {
          driRenderbuffer *frontRb
-            = driNewRenderbuffer(GL_RGBA, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(frontRb, mesaVis);
@@ -257,7 +257,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->doubleBufferMode) {
          driRenderbuffer *backRb
-            = driNewRenderbuffer(GL_RGBA, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_ARGB8888, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(backRb, mesaVis);
@@ -266,7 +266,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->depthBits == 16) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_Z16, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(depthRb, mesaVis);
@@ -274,7 +274,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 24) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_Z24_S8, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(depthRb, mesaVis);
@@ -282,7 +282,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
       }
       else if (mesaVis->depthBits == 32) {
          driRenderbuffer *depthRb
-            = driNewRenderbuffer(GL_DEPTH_COMPONENT32, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_Z32, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(depthRb, mesaVis);
@@ -291,7 +291,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
 
       if (mesaVis->stencilBits > 0 && !swStencil) {
          driRenderbuffer *stencilRb
-            = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL,
+            = driNewRenderbuffer(MESA_FORMAT_S8, NULL,
                                  screen->bytesPerPixel,
                                  0, screen->width, driDrawPriv);
          viaSetSpanFunctions(stencilRb, mesaVis);
index b908f0fb23a93a774c8d491d4be74471cb6750c2..e847164cd026562517cd6f0d2b53e8bc47b57cb6 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include "main/glheader.h"
+#include "main/formats.h"
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/colormac.h"
@@ -177,24 +178,22 @@ void viaInitSpanFuncs(GLcontext *ctx)
 void
 viaSetSpanFunctions(struct via_renderbuffer *vrb, const GLvisual *vis)
 {
-   if (vrb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         viaInitPointers_565(&vrb->Base);
-      }
-      else {
-         viaInitPointers_8888(&vrb->Base);
-      }
+   if (vrb->Base.Format == MESA_FORMAT_RGB565) {
+      viaInitPointers_565(&vrb->Base);
    }
-   else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+   else if (vrb->Base.Format == MESA_FORMAT_ARGB8888) {
+      viaInitPointers_8888(&vrb->Base);
+   }
+   else if (vrb->Base.Format == MESA_FORMAT_Z16) {
       viaInitDepthPointers_z16(&vrb->Base);
    }
-   else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+   else if (vrb->Base.Format == MESA_FORMAT_Z24_S8) {
       viaInitDepthPointers_z24_s8(&vrb->Base);
    }
-   else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+   else if (vrb->Base.Format == MESA_FORMAT_Z32) {
       viaInitDepthPointers_z32(&vrb->Base);
    }
-   else if (vrb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+   else if (vrb->Base.Format == MESA_FORMAT_S8) {
       viaInitStencilPointers_z24_s8(&vrb->Base);
    }
 }