aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/glformats.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-09-27 15:09:52 +0200
committermarha <marha@users.sourceforge.net>2012-09-27 15:09:52 +0200
commit2cf1e3de4759264eac2fa8ac758ea750636542f8 (patch)
tree80298679c1f3134223c592ad3939739aee333eb8 /mesalib/src/mesa/main/glformats.c
parent0ebcd32e91486caccc041c8ca23e39e160b24702 (diff)
downloadvcxsrv-2cf1e3de4759264eac2fa8ac758ea750636542f8.tar.gz
vcxsrv-2cf1e3de4759264eac2fa8ac758ea750636542f8.tar.bz2
vcxsrv-2cf1e3de4759264eac2fa8ac758ea750636542f8.zip
mesa xserver pixman xkeyboard-config git update 27 sep 2012
xserver 0b02150c27e98f996e10d7489f9f67a30e4e3497 pixman aff796d6cee4cb81f0352c2f7d0c994229bd5ca1 xkeyboard-config 33ccc8f4b3f1c6ae95242cf9cb19e8df87f6f37e mesa 6d6aef79742ece3bb570ae44e6c13791aae15e01
Diffstat (limited to 'mesalib/src/mesa/main/glformats.c')
-rw-r--r--mesalib/src/mesa/main/glformats.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c
index 047a613a1..04029c07c 100644
--- a/mesalib/src/mesa/main/glformats.c
+++ b/mesalib/src/mesa/main/glformats.c
@@ -1372,3 +1372,72 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
}
return GL_NO_ERROR;
}
+
+
+/**
+ * Do error checking of format/type combinations for OpenGL ES glReadPixels
+ * and glTex[Sub]Image.
+ * \return error code, or GL_NO_ERROR.
+ */
+GLenum
+_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
+ unsigned dimensions)
+{
+ GLboolean type_valid = GL_TRUE;
+
+ switch (format) {
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ type_valid = (type == GL_UNSIGNED_BYTE
+ || type == GL_FLOAT
+ || type == GL_HALF_FLOAT_OES);
+ break;
+
+ case GL_RGB:
+ type_valid = (type == GL_UNSIGNED_BYTE
+ || type == GL_UNSIGNED_SHORT_5_6_5
+ || type == GL_FLOAT
+ || type == GL_HALF_FLOAT_OES);
+ break;
+
+ case GL_RGBA:
+ type_valid = (type == GL_UNSIGNED_BYTE
+ || type == GL_UNSIGNED_SHORT_4_4_4_4
+ || type == GL_UNSIGNED_SHORT_5_5_5_1
+ || type == GL_FLOAT
+ || type == GL_HALF_FLOAT_OES
+ || type == GL_UNSIGNED_INT_2_10_10_10_REV);
+ break;
+
+ case GL_DEPTH_COMPONENT:
+ /* This format is filtered against invalid dimensionalities elsewhere.
+ */
+ type_valid = (type == GL_UNSIGNED_SHORT
+ || type == GL_UNSIGNED_INT);
+ break;
+
+ case GL_DEPTH_STENCIL:
+ /* This format is filtered against invalid dimensionalities elsewhere.
+ */
+ type_valid = (type == GL_UNSIGNED_INT_24_8);
+ break;
+
+ case GL_BGRA_EXT:
+ type_valid = (type == GL_UNSIGNED_BYTE);
+
+ /* This feels like a bug in the EXT_texture_format_BGRA8888 spec, but
+ * the format does not appear to be allowed for 3D textures in OpenGL
+ * ES.
+ */
+ if (dimensions != 2)
+ return GL_INVALID_VALUE;
+
+ break;
+
+ default:
+ return GL_INVALID_VALUE;
+ }
+
+ return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION;
+}