mesa: Allow querying the system FBO in GetFramebufferAttachmentParameteriv
[mesa.git] / src / mesa / main / texformat.c
index 1a374e7bee51ecffb144c5322c3d6ed6e7e7a411..d235485721a69507e414d55880bdbf706706c24b 100644 (file)
@@ -35,8 +35,6 @@
 
 #include "context.h"
 #include "texcompress.h"
-#include "texcompress_fxt1.h"
-#include "texcompress_s3tc.h"
 #include "texformat.h"
 
 
@@ -63,12 +61,9 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
    (void) type;
 
    switch (internalFormat) {
-      /* RGBA formats */
+      /* shallow RGBA formats */
       case 4:
       case GL_RGBA:
-      case GL_RGB10_A2:
-      case GL_RGBA12:
-      case GL_RGBA16:
       case GL_RGBA8:
          return MESA_FORMAT_RGBA8888;
       case GL_RGB5_A1:
@@ -78,12 +73,15 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       case GL_RGBA4:
          return MESA_FORMAT_ARGB4444;
 
-      /* RGB formats */
+      /* deep RGBA formats */
+      case GL_RGB10_A2:
+      case GL_RGBA12:
+      case GL_RGBA16:
+         return MESA_FORMAT_RGBA_16;
+
+      /* shallow RGB formats */
       case 3:
       case GL_RGB:
-      case GL_RGB10:
-      case GL_RGB12:
-      case GL_RGB16:
       case GL_RGB8:
          return MESA_FORMAT_RGB888;
       case GL_R3_G3_B2:
@@ -93,6 +91,12 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       case GL_RGB5:
          return MESA_FORMAT_RGB565;
 
+      /* deep RGB formats */
+      case GL_RGB10:
+      case GL_RGB12:
+      case GL_RGB16:
+         return MESA_FORMAT_RGBA_16;
+
       /* Alpha formats */
       case GL_ALPHA:
       case GL_ALPHA4:
@@ -296,6 +300,32 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       }
    }
 
+   if (ctx->VersionMajor * 10 + ctx->VersionMinor >= 31) {
+      switch (internalFormat) {
+         case GL_RED_SNORM:
+         case GL_R8_SNORM:
+            return MESA_FORMAT_SIGNED_R8;
+         case GL_RG_SNORM:
+         case GL_RG8_SNORM:
+            return MESA_FORMAT_SIGNED_RG88;
+         case GL_RGB_SNORM:
+         case GL_RGB8_SNORM:
+            return MESA_FORMAT_SIGNED_RGBX8888;
+         case GL_RGBA_SNORM:
+         case GL_RGBA8_SNORM:
+            return MESA_FORMAT_SIGNED_RGBA8888;
+         case GL_R16_SNORM:
+            return MESA_FORMAT_SIGNED_R_16;
+         case GL_RG16_SNORM:
+            return MESA_FORMAT_SIGNED_RG_16;
+         case GL_RGB16_SNORM:
+            return MESA_FORMAT_SIGNED_RGB_16;
+         case GL_RGBA16_SNORM:
+            return MESA_FORMAT_SIGNED_RGBA_16;
+         default:
+            ; /* fall-through */
+      }
+   }
 
 #if FEATURE_EXT_texture_sRGB
    if (ctx->Extensions.EXT_texture_sRGB) {