[Mesa-dev] [PATCH 1/1] main: validate the type correctly against the OpenGL ES spec.

Oliver McFadden oliver.mcfadden at linux.intel.com
Tue Sep 11 05:09:21 PDT 2012


Previously Mesa would validate UNSIGNED_INT successfully in violation of
the OpenGL(R) ES 1.0 and 2.0 Specification.

http://www.khronos.org/registry/gles/specs/1.1/es_full_spec_1.1.12.pdf
http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf
http://www.khronos.org/registry/gles/specs/3.0/es_spec_3.0.0.pdf

Signed-off-by: Oliver McFadden <oliver.mcfadden at linux.intel.com>
---
 src/mesa/main/api_validate.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index d0d2ca4..698394c 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -296,10 +296,32 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
 static bool
 valid_elements_type(struct gl_context *ctx, GLenum type, const char *name)
 {
+  /*
+   * Page 22 of the OpenGL(R) ES Version 1.0 Specification (PDF)
+   * and
+   * Page 21 of the OpenGL(R) ES Version 2.0 Specification (PDF) says:
+   *
+   * `type' must be one of UNSIGNED_BYTE or UNSIGNED_SHORT, indicating that the
+   * values in indices are indices of GL type ubyte or ushort, respectively.
+   *
+   * Page 29 of the OpenGL(R) ES Version 3.0 Specification (PDF) says:
+   *
+   * `type' must be one of UNSIGNED_BYTE, UNSIGNED_SHORT, or UNSIGNED_INT,
+   * indicating that the index values are of GL type ubyte, ushort, or uint
+   * respectively.
+   *
+   */
    switch (type) {
    case GL_UNSIGNED_BYTE:
    case GL_UNSIGNED_SHORT:
+      return true;
    case GL_UNSIGNED_INT:
+      if (ctx->API == API_OPENGLES ||
+          (ctx->API == API_OPENGLES2 && ctx->Version < 30)) {
+         _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", name,
+                     _mesa_lookup_enum_by_nr(type));
+         return false;
+      }
       return true;
 
    default:
-- 
1.7.8.6



More information about the mesa-dev mailing list