aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/glformats.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-12-03 09:16:19 +0100
committermarha <marha@users.sourceforge.net>2012-12-03 09:16:19 +0100
commit17464545a9abdd19312065a578d1f69a6b0b015f (patch)
treed39fde94a445ddde95399d4850ffbbbd357a3a19 /mesalib/src/mesa/main/glformats.c
parenteba14241fe23d0561687a1e530a57fa0bfc6ab69 (diff)
parentb8da71ffb17d3d16706db04115e9ba1dd8bc49b9 (diff)
downloadvcxsrv-17464545a9abdd19312065a578d1f69a6b0b015f.tar.gz
vcxsrv-17464545a9abdd19312065a578d1f69a6b0b015f.tar.bz2
vcxsrv-17464545a9abdd19312065a578d1f69a6b0b015f.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig mesa xserver pixman xkeyboard-config git update 3 dec 2012
Diffstat (limited to 'mesalib/src/mesa/main/glformats.c')
-rw-r--r--mesalib/src/mesa/main/glformats.c117
1 files changed, 115 insertions, 2 deletions
diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c
index ba79f193b..69caef70b 100644
--- a/mesalib/src/mesa/main/glformats.c
+++ b/mesalib/src/mesa/main/glformats.c
@@ -821,10 +821,10 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
- return ctx->API == API_OPENGL
+ return ctx->API == API_OPENGL_COMPAT
&& ctx->Extensions.EXT_texture_compression_latc;
case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
- return ctx->API == API_OPENGL
+ return ctx->API == API_OPENGL_COMPAT
&& ctx->Extensions.ATI_texture_compression_3dc;
case GL_ETC1_RGB8_OES:
return _mesa_is_gles(ctx)
@@ -1008,6 +1008,119 @@ _mesa_generic_compressed_format_to_uncompressed_format(GLenum format)
/**
+ * Return the equivalent non-generic internal format.
+ * This is useful for comparing whether two internal formats are equivalent.
+ */
+GLenum
+_mesa_get_nongeneric_internalformat(GLenum format)
+{
+ switch (format) {
+ /* GL 1.1 formats. */
+ case 4:
+ case GL_RGBA:
+ return GL_RGBA8;
+
+ case 3:
+ case GL_RGB:
+ return GL_RGB8;
+
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ return GL_LUMINANCE8_ALPHA8;
+
+ case 1:
+ case GL_LUMINANCE:
+ return GL_LUMINANCE8;
+
+ case GL_ALPHA:
+ return GL_ALPHA8;
+
+ case GL_INTENSITY:
+ return GL_INTENSITY8;
+
+ /* GL_ARB_texture_rg */
+ case GL_RED:
+ return GL_R8;
+
+ case GL_RG:
+ return GL_RG8;
+
+ /* GL_EXT_texture_sRGB */
+ case GL_SRGB:
+ return GL_SRGB8;
+
+ case GL_SRGB_ALPHA:
+ return GL_SRGB8_ALPHA8;
+
+ case GL_SLUMINANCE:
+ return GL_SLUMINANCE8;
+
+ case GL_SLUMINANCE_ALPHA:
+ return GL_SLUMINANCE8_ALPHA8;
+
+ /* GL_EXT_texture_snorm */
+ case GL_RGBA_SNORM:
+ return GL_RGBA8_SNORM;
+
+ case GL_RGB_SNORM:
+ return GL_RGB8_SNORM;
+
+ case GL_RG_SNORM:
+ return GL_RG8_SNORM;
+
+ case GL_RED_SNORM:
+ return GL_R8_SNORM;
+
+ case GL_LUMINANCE_ALPHA_SNORM:
+ return GL_LUMINANCE8_ALPHA8_SNORM;
+
+ case GL_LUMINANCE_SNORM:
+ return GL_LUMINANCE8_SNORM;
+
+ case GL_ALPHA_SNORM:
+ return GL_ALPHA8_SNORM;
+
+ case GL_INTENSITY_SNORM:
+ return GL_INTENSITY8_SNORM;
+
+ default:
+ return format;
+ }
+}
+
+
+/**
+ * Convert an sRGB internal format to linear.
+ */
+GLenum
+_mesa_get_linear_internalformat(GLenum format)
+{
+ switch (format) {
+ case GL_SRGB:
+ return GL_RGB;
+
+ case GL_SRGB_ALPHA:
+ return GL_RGBA;
+
+ case GL_SRGB8:
+ return GL_RGB8;
+
+ case GL_SRGB8_ALPHA8:
+ return GL_RGBA8;
+
+ case GL_SLUMINANCE:
+ return GL_LUMINANCE8;
+
+ case GL_SLUMINANCE_ALPHA:
+ return GL_LUMINANCE8_ALPHA8;
+
+ default:
+ return format;
+ }
+}
+
+
+/**
* Do error checking of format/type combinations for glReadPixels,
* glDrawPixels and glTex[Sub]Image. Note that depending on the format
* and type values, we may either generate GL_INVALID_OPERATION or