Mesa (master): Revert "mesa: Simplify _mesa_base_fbo_format by making it exceptions to teximages."

Brian Paul brianp at kemper.freedesktop.org
Tue Jan 25 02:39:58 UTC 2011


Module: Mesa
Branch: master
Commit: f41bbc7c44565c7f3949340a4e2fdf78a8cebf3f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f41bbc7c44565c7f3949340a4e2fdf78a8cebf3f

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Jan 24 19:38:52 2011 -0700

Revert "mesa: Simplify _mesa_base_fbo_format by making it exceptions to teximages."

This reverts commit 65c41d55a06137115f0b4c67f9a3fd2708f0b625.

There really are quite a few differences in the set of internal
formats allowed by glTexImage and glRenderbufferStorage.

---

 src/mesa/main/fbobject.c |   67 +++++++++++++++++++++++++++++----------------
 1 files changed, 43 insertions(+), 24 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 17c6295..ce27a6a 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -960,42 +960,69 @@ _mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers)
 
 
 /**
- * Given an internal format token for a renderbuffer, return the
+ * Given an internal format token for a render buffer, return the
  * corresponding base format.
+ * This is very similar to _mesa_base_tex_format() but the set of valid
+ * internal formats is somewhat different.
+ *
+ * \return one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT
+ *  GL_DEPTH_STENCIL_EXT or zero if error.
+ *
+ * XXX in the future when we support red-only and red-green formats
+ * we'll also return GL_RED and GL_RG.
  */
 GLenum
 _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
 {
-   GLenum baseFormat;
-
    switch (internalFormat) {
+   case GL_ALPHA:
+   case GL_ALPHA4:
+   case GL_ALPHA8:
+   case GL_ALPHA12:
+   case GL_ALPHA16:
+      return GL_ALPHA;
+   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:
+   case GL_SRGB8_EXT:
+      return GL_RGB;
+   case GL_RGBA:
+   case GL_RGBA2:
+   case GL_RGBA4:
+   case GL_RGB5_A1:
+   case GL_RGBA8:
+   case GL_RGB10_A2:
+   case GL_RGBA12:
+   case GL_RGBA16:
    case GL_RGBA16_SNORM:
-      /* This is used internally by Mesa for accum buffers. */
+   case GL_SRGB8_ALPHA8_EXT:
       return GL_RGBA;
    case GL_STENCIL_INDEX:
    case GL_STENCIL_INDEX1_EXT:
    case GL_STENCIL_INDEX4_EXT:
    case GL_STENCIL_INDEX8_EXT:
    case GL_STENCIL_INDEX16_EXT:
-      /* This is not a valid texture internalFormat, but valid for
-       * renderbuffers.
-       */
       return GL_STENCIL_INDEX;
    case GL_DEPTH_COMPONENT:
    case GL_DEPTH_COMPONENT16:
    case GL_DEPTH_COMPONENT24:
    case GL_DEPTH_COMPONENT32:
-      /* This is an override of _mesa_base_tex_format's check that
-       * ARB_depth_texture is present.  We allow depth RBs without it.
-       */
       return GL_DEPTH_COMPONENT;
-   }
-
-   baseFormat = _mesa_base_tex_format(ctx, internalFormat);
-   if (baseFormat < 0)
+   case GL_DEPTH_STENCIL_EXT:
+   case GL_DEPTH24_STENCIL8_EXT:
+      if (ctx->Extensions.EXT_packed_depth_stencil)
+         return GL_DEPTH_STENCIL_EXT;
+      else
+         return 0;
+   /* XXX add floating point formats eventually */
+   default:
       return 0;
-
-   return baseFormat;
+   }
 }
 
 
@@ -1031,14 +1058,6 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,
       return;
    }
 
-   if (baseFormat != GL_DEPTH_COMPONENT &&
-       baseFormat != GL_STENCIL_INDEX &&
-       baseFormat != GL_DEPTH_STENCIL &&
-       !_mesa_is_legal_color_format(ctx, baseFormat)) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat)", func);
-      return;
-   }
-
    if (width < 1 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) {
       _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func);
       return;




More information about the mesa-commit mailing list