[Mesa-dev] [PATCH V2 04/10] mesa: get_texbuffer_format(): differentiate between core and compat context

Pi Tabred servuswiegehtz at yahoo.de
Wed Dec 11 13:55:28 PST 2013


alpha, lumincance and intensity formats are illegal in a core context.
Add a check to return MESA_FORMAT_NONE if one of those is requested within
a core context.
---
 src/mesa/main/teximage.c | 167 ++++++++++++++++++++++++-----------------------
 1 file changed, 87 insertions(+), 80 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index cbe572c..cf8c52e 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3879,87 +3879,94 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
 static gl_format
 get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
 {
+   if (ctx->API != API_OPENGL_CORE) {
+      switch (internalFormat) {
+      case GL_ALPHA8:
+         return MESA_FORMAT_A8;
+      case  GL_ALPHA16:
+         return MESA_FORMAT_A16;
+      case  GL_ALPHA16F_ARB:
+         return MESA_FORMAT_ALPHA_FLOAT16;
+      case  GL_ALPHA32F_ARB:
+         return MESA_FORMAT_ALPHA_FLOAT32;
+      case  GL_ALPHA8I_EXT:
+         return MESA_FORMAT_ALPHA_INT8;
+      case  GL_ALPHA16I_EXT:
+         return MESA_FORMAT_ALPHA_INT16;
+      case  GL_ALPHA32I_EXT:
+         return MESA_FORMAT_ALPHA_INT32;
+      case  GL_ALPHA8UI_EXT:
+         return MESA_FORMAT_ALPHA_UINT8;
+      case  GL_ALPHA16UI_EXT:
+         return MESA_FORMAT_ALPHA_UINT16;
+      case  GL_ALPHA32UI_EXT:
+         return MESA_FORMAT_ALPHA_UINT32;
+      case  GL_LUMINANCE8:
+         return MESA_FORMAT_L8;
+      case  GL_LUMINANCE16:
+         return MESA_FORMAT_L16;
+      case  GL_LUMINANCE16F_ARB:
+         return MESA_FORMAT_LUMINANCE_FLOAT16;
+      case  GL_LUMINANCE32F_ARB:
+         return MESA_FORMAT_LUMINANCE_FLOAT32;
+      case  GL_LUMINANCE8I_EXT:
+         return MESA_FORMAT_LUMINANCE_INT8;
+      case  GL_LUMINANCE16I_EXT:
+         return MESA_FORMAT_LUMINANCE_INT16;
+      case  GL_LUMINANCE32I_EXT:
+         return MESA_FORMAT_LUMINANCE_INT32;
+      case  GL_LUMINANCE8UI_EXT:
+         return MESA_FORMAT_LUMINANCE_UINT8;
+      case  GL_LUMINANCE16UI_EXT:
+         return MESA_FORMAT_LUMINANCE_UINT16;
+      case  GL_LUMINANCE32UI_EXT:
+         return MESA_FORMAT_LUMINANCE_UINT32;
+      case  GL_LUMINANCE8_ALPHA8:
+         return MESA_FORMAT_AL88;
+      case  GL_LUMINANCE16_ALPHA16:
+         return MESA_FORMAT_AL1616;
+      case  GL_LUMINANCE_ALPHA16F_ARB:
+         return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16;
+      case  GL_LUMINANCE_ALPHA32F_ARB:
+         return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32;
+      case  GL_LUMINANCE_ALPHA8I_EXT:
+         return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
+      case  GL_LUMINANCE_ALPHA16I_EXT:
+         return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
+      case  GL_LUMINANCE_ALPHA32I_EXT:
+         return MESA_FORMAT_LUMINANCE_ALPHA_INT16;
+      case  GL_LUMINANCE_ALPHA8UI_EXT:
+         return MESA_FORMAT_LUMINANCE_ALPHA_UINT8;
+      case  GL_LUMINANCE_ALPHA16UI_EXT:
+         return MESA_FORMAT_LUMINANCE_ALPHA_UINT16;
+      case  GL_LUMINANCE_ALPHA32UI_EXT:
+         return MESA_FORMAT_LUMINANCE_ALPHA_UINT32;
+      case  GL_INTENSITY8:
+         return MESA_FORMAT_I8;
+      case  GL_INTENSITY16:
+         return MESA_FORMAT_I16;
+      case  GL_INTENSITY16F_ARB:
+         return MESA_FORMAT_INTENSITY_FLOAT16;
+      case  GL_INTENSITY32F_ARB:
+         return MESA_FORMAT_INTENSITY_FLOAT32;
+      case  GL_INTENSITY8I_EXT:
+         return MESA_FORMAT_INTENSITY_INT8;
+      case  GL_INTENSITY16I_EXT:
+         return MESA_FORMAT_INTENSITY_INT16;
+      case  GL_INTENSITY32I_EXT:
+         return MESA_FORMAT_INTENSITY_INT32;
+      case  GL_INTENSITY8UI_EXT:
+         return MESA_FORMAT_INTENSITY_UINT8;
+      case  GL_INTENSITY16UI_EXT:
+         return MESA_FORMAT_INTENSITY_UINT16;
+      case  GL_INTENSITY32UI_EXT:
+         return MESA_FORMAT_INTENSITY_UINT32;
+      default:
+         break;
+      }
+   }
+
    switch (internalFormat) {
-   case GL_ALPHA8:
-      return MESA_FORMAT_A8;
-   case GL_ALPHA16:
-      return MESA_FORMAT_A16;
-   case GL_ALPHA16F_ARB:
-      return MESA_FORMAT_ALPHA_FLOAT16;
-   case GL_ALPHA32F_ARB:
-      return MESA_FORMAT_ALPHA_FLOAT32;
-   case GL_ALPHA8I_EXT:
-      return MESA_FORMAT_ALPHA_INT8;
-   case GL_ALPHA16I_EXT:
-      return MESA_FORMAT_ALPHA_INT16;
-   case GL_ALPHA32I_EXT:
-      return MESA_FORMAT_ALPHA_INT32;
-   case GL_ALPHA8UI_EXT:
-      return MESA_FORMAT_ALPHA_UINT8;
-   case GL_ALPHA16UI_EXT:
-      return MESA_FORMAT_ALPHA_UINT16;
-   case GL_ALPHA32UI_EXT:
-      return MESA_FORMAT_ALPHA_UINT32;
-   case GL_LUMINANCE8:
-      return MESA_FORMAT_L8;
-   case GL_LUMINANCE16:
-      return MESA_FORMAT_L16;
-   case GL_LUMINANCE16F_ARB:
-      return MESA_FORMAT_LUMINANCE_FLOAT16;
-   case GL_LUMINANCE32F_ARB:
-      return MESA_FORMAT_LUMINANCE_FLOAT32;
-   case GL_LUMINANCE8I_EXT:
-      return MESA_FORMAT_LUMINANCE_INT8;
-   case GL_LUMINANCE16I_EXT:
-      return MESA_FORMAT_LUMINANCE_INT16;
-   case GL_LUMINANCE32I_EXT:
-      return MESA_FORMAT_LUMINANCE_INT32;
-   case GL_LUMINANCE8UI_EXT:
-      return MESA_FORMAT_LUMINANCE_UINT8;
-   case GL_LUMINANCE16UI_EXT:
-      return MESA_FORMAT_LUMINANCE_UINT16;
-   case GL_LUMINANCE32UI_EXT:
-      return MESA_FORMAT_LUMINANCE_UINT32;
-   case GL_LUMINANCE8_ALPHA8:
-      return MESA_FORMAT_AL88;
-   case GL_LUMINANCE16_ALPHA16:
-      return MESA_FORMAT_AL1616;
-   case GL_LUMINANCE_ALPHA16F_ARB:
-      return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16;
-   case GL_LUMINANCE_ALPHA32F_ARB:
-      return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32;
-   case GL_LUMINANCE_ALPHA8I_EXT:
-      return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
-   case GL_LUMINANCE_ALPHA16I_EXT:
-      return MESA_FORMAT_LUMINANCE_ALPHA_INT8;
-   case GL_LUMINANCE_ALPHA32I_EXT:
-      return MESA_FORMAT_LUMINANCE_ALPHA_INT16;
-   case GL_LUMINANCE_ALPHA8UI_EXT:
-      return MESA_FORMAT_LUMINANCE_ALPHA_UINT8;
-   case GL_LUMINANCE_ALPHA16UI_EXT:
-      return MESA_FORMAT_LUMINANCE_ALPHA_UINT16;
-   case GL_LUMINANCE_ALPHA32UI_EXT:
-      return MESA_FORMAT_LUMINANCE_ALPHA_UINT32;
-   case GL_INTENSITY8:
-      return MESA_FORMAT_I8;
-   case GL_INTENSITY16:
-      return MESA_FORMAT_I16;
-   case GL_INTENSITY16F_ARB:
-      return MESA_FORMAT_INTENSITY_FLOAT16;
-   case GL_INTENSITY32F_ARB:
-      return MESA_FORMAT_INTENSITY_FLOAT32;
-   case GL_INTENSITY8I_EXT:
-      return MESA_FORMAT_INTENSITY_INT8;
-   case GL_INTENSITY16I_EXT:
-      return MESA_FORMAT_INTENSITY_INT16;
-   case GL_INTENSITY32I_EXT:
-      return MESA_FORMAT_INTENSITY_INT32;
-   case GL_INTENSITY8UI_EXT:
-      return MESA_FORMAT_INTENSITY_UINT8;
-   case GL_INTENSITY16UI_EXT:
-      return MESA_FORMAT_INTENSITY_UINT16;
-   case GL_INTENSITY32UI_EXT:
-      return MESA_FORMAT_INTENSITY_UINT32;
    case GL_RGBA8:
       return MESA_FORMAT_RGBA8888_REV;
    case GL_RGBA16:
-- 
1.8.3.1



More information about the mesa-dev mailing list