radeon: simplify radeon_create_renderbuffer()
authorBrian Paul <brianp@vmware.com>
Fri, 23 Oct 2009 01:20:38 +0000 (19:20 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 23 Oct 2009 01:57:06 +0000 (19:57 -0600)
src/mesa/drivers/dri/radeon/radeon_common.h
src/mesa/drivers/dri/radeon/radeon_fbo.c
src/mesa/drivers/dri/radeon/radeon_screen.c

index f3201911ac67bba93e0a094f7cddf4d3ed6fb7a9..def0cc17a915e09bc3aa7c12dd823a672048e07d 100644 (file)
@@ -43,7 +43,7 @@ void
 radeon_renderbuffer_set_bo(struct radeon_renderbuffer *rb,
                           struct radeon_bo *bo);
 struct radeon_renderbuffer *
-radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv);
+radeon_create_renderbuffer(gl_format format, __DRIdrawablePrivate *driDrawPriv);
 static inline struct radeon_renderbuffer *radeon_renderbuffer(struct gl_renderbuffer *rb)
 {
        struct radeon_renderbuffer *rrb = (struct radeon_renderbuffer *)rb;
index 096ded23fb35a5d5a83f2fdfde77416c7878d5b8..40846828c5382951f6ddfcfc94f00804d4f62814 100644 (file)
@@ -240,8 +240,13 @@ radeon_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    return GL_FALSE;
 }
 
+
+/**
+ * Create a renderbuffer for a window's color, depth and/or stencil buffer.
+ * Not used for user-created renderbuffers.
+ */
 struct radeon_renderbuffer *
-radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv)
+radeon_create_renderbuffer(gl_format format, __DRIdrawablePrivate *driDrawPriv)
 {
     struct radeon_renderbuffer *rrb;
 
@@ -252,40 +257,30 @@ radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv)
     _mesa_init_renderbuffer(&rrb->base, 0);
     rrb->base.ClassID = RADEON_RB_CLASS;
 
-    /* XXX format junk */
+    rrb->base.Format = format;
+
     switch (format) {
-       case GL_RGB5:
-           rrb->base.Format = MESA_FORMAT_RGB565;
+        case MESA_FORMAT_RGB565:
            rrb->base.DataType = GL_UNSIGNED_BYTE;
             rrb->base._BaseFormat = GL_RGB;
            break;
-       case GL_RGB8:
-           rrb->base.Format = MESA_FORMAT_ARGB8888;
+        case MESA_FORMAT_XRGB8888:
            rrb->base.DataType = GL_UNSIGNED_BYTE;
             rrb->base._BaseFormat = GL_RGB;
            break;
-       case GL_RGBA8:
-           rrb->base.Format = MESA_FORMAT_ARGB8888;
+       case MESA_FORMAT_ARGB8888:
            rrb->base.DataType = GL_UNSIGNED_BYTE;
             rrb->base._BaseFormat = GL_RGBA;
            break;
-       case GL_STENCIL_INDEX8_EXT:
-           rrb->base.Format = MESA_FORMAT_S8;
+       case MESA_FORMAT_S8:
            rrb->base.DataType = GL_UNSIGNED_BYTE;
             rrb->base._BaseFormat = GL_STENCIL_INDEX;
            break;
-       case GL_DEPTH_COMPONENT16:
-           rrb->base.Format = MESA_FORMAT_Z16;
+       case MESA_FORMAT_Z16:
            rrb->base.DataType = GL_UNSIGNED_SHORT;
             rrb->base._BaseFormat = GL_DEPTH_COMPONENT;
            break;
-       case GL_DEPTH_COMPONENT24:
-           rrb->base.Format = MESA_FORMAT_S8_Z24;
-           rrb->base.DataType = GL_UNSIGNED_INT_24_8_EXT;
-            rrb->base._BaseFormat = GL_DEPTH_STENCIL;
-           break;
-       case GL_DEPTH24_STENCIL8_EXT:
-           rrb->base.Format = MESA_FORMAT_S8_Z24;
+       case MESA_FORMAT_S8_Z24:
            rrb->base.DataType = GL_UNSIGNED_INT_24_8_EXT;
             rrb->base._BaseFormat = GL_DEPTH_STENCIL;
            break;
@@ -296,7 +291,7 @@ radeon_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv)
     }
 
     rrb->dPriv = driDrawPriv;
-    rrb->base.InternalFormat = format;
+    rrb->base.InternalFormat = _mesa_get_format_base_format(format);
 
     rrb->base.Delete = radeon_delete_renderbuffer;
     rrb->base.AllocStorage = radeon_alloc_window_storage;
index 573eb6c9c1870562b580f3c248e0b6c414dc7e5a..4a2313f99e15ac7db71c099d8561c045f23c314e 100644 (file)
@@ -1480,7 +1480,7 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
     const GLboolean swAccum = mesaVis->accumRedBits > 0;
     const GLboolean swStencil = mesaVis->stencilBits > 0 &&
        mesaVis->depthBits != 24;
-    GLenum rgbFormat;
+    gl_format rgbFormat;
     struct radeon_framebuffer *rfb;
 
     if (isPixmap)
@@ -1493,11 +1493,11 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
     _mesa_initialize_framebuffer(&rfb->base, mesaVis);
 
     if (mesaVis->redBits == 5)
-        rgbFormat = GL_RGB5;
+        rgbFormat = MESA_FORMAT_RGB565;
     else if (mesaVis->alphaBits == 0)
-        rgbFormat = GL_RGB8;
+        rgbFormat = MESA_FORMAT_XRGB8888;
     else
-        rgbFormat = GL_RGBA8;
+        rgbFormat = MESA_FORMAT_ARGB8888;
 
     /* front color renderbuffer */
     rfb->color_rb[0] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
@@ -1513,19 +1513,22 @@ radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
 
     if (mesaVis->depthBits == 24) {
       if (mesaVis->stencilBits == 8) {
-       struct radeon_renderbuffer *depthStencilRb = radeon_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT, driDrawPriv);
+       struct radeon_renderbuffer *depthStencilRb =
+           radeon_create_renderbuffer(MESA_FORMAT_S8_Z24, driDrawPriv);
        _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depthStencilRb->base);
        _mesa_add_renderbuffer(&rfb->base, BUFFER_STENCIL, &depthStencilRb->base);
        depthStencilRb->has_surface = screen->depthHasSurface;
       } else {
        /* depth renderbuffer */
-       struct radeon_renderbuffer *depth = radeon_create_renderbuffer(GL_DEPTH_COMPONENT24, driDrawPriv);
+       struct radeon_renderbuffer *depth =
+           radeon_create_renderbuffer(MESA_FORMAT_X8_Z24, driDrawPriv);
        _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depth->base);
        depth->has_surface = screen->depthHasSurface;
       }
     } else if (mesaVis->depthBits == 16) {
-      /* just 16-bit depth buffer, no hw stencil */
-       struct radeon_renderbuffer *depth = radeon_create_renderbuffer(GL_DEPTH_COMPONENT16, driDrawPriv);
+        /* just 16-bit depth buffer, no hw stencil */
+       struct radeon_renderbuffer *depth =
+           radeon_create_renderbuffer(MESA_FORMAT_Z16, driDrawPriv);
        _mesa_add_renderbuffer(&rfb->base, BUFFER_DEPTH, &depth->base);
        depth->has_surface = screen->depthHasSurface;
     }