OSDN Git Service

mesa: support GL_RED/GL_RG in ES2 contexts when driver support exists
authorIlia Mirkin <imirkin@alum.mit.edu>
Thu, 26 Nov 2015 15:32:57 +0000 (10:32 -0500)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 3 Dec 2015 18:43:12 +0000 (18:43 +0000)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93126
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 0396eaaf80c5d7955d7926c4e448f006c7682d2e)

src/mesa/main/glformats.c
src/mesa/main/glformats.h
src/mesa/main/readpix.c
src/mesa/main/teximage.c

index 629a0a4..a6058a5 100644 (file)
@@ -2018,12 +2018,18 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
  * \return error code, or GL_NO_ERROR.
  */
 GLenum
-_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
+_mesa_es_error_check_format_and_type(const struct gl_context *ctx,
+                                     GLenum format, GLenum type,
                                      unsigned dimensions)
 {
    GLboolean type_valid = GL_TRUE;
 
    switch (format) {
+   case GL_RED:
+   case GL_RG:
+      if (ctx->API == API_OPENGLES || !ctx->Extensions.ARB_texture_rg)
+         return GL_INVALID_VALUE;
+      /* fallthrough */
    case GL_ALPHA:
    case GL_LUMINANCE:
    case GL_LUMINANCE_ALPHA:
index 84328f2..046aec3 100644 (file)
@@ -124,7 +124,8 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
                                   GLenum format, GLenum type);
 
 extern GLenum
-_mesa_es_error_check_format_and_type(GLenum format, GLenum type,
+_mesa_es_error_check_format_and_type(const struct gl_context *ctx,
+                                     GLenum format, GLenum type,
                                      unsigned dimensions);
 
 extern GLenum
index 18ab06a..dfbbfac 100644 (file)
@@ -1043,7 +1043,7 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
           _mesa_get_color_read_type(ctx) == type) {
          err = GL_NO_ERROR;
       } else if (ctx->Version < 30) {
-         err = _mesa_es_error_check_format_and_type(format, type, 2);
+         err = _mesa_es_error_check_format_and_type(ctx, format, type, 2);
          if (err == GL_NO_ERROR) {
             if (type == GL_FLOAT || type == GL_HALF_FLOAT_OES) {
                err = GL_INVALID_OPERATION;
index 24a594b..ab60a2f 100644 (file)
@@ -1616,7 +1616,7 @@ texture_format_error_check_gles(struct gl_context *ctx, GLenum format,
       }
    }
    else {
-      err = _mesa_es_error_check_format_and_type(format, type, dimensions);
+      err = _mesa_es_error_check_format_and_type(ctx, format, type, dimensions);
       if (err != GL_NO_ERROR) {
          _mesa_error(ctx, err, "%s(format = %s, type = %s)",
                      callerName, _mesa_enum_to_string(format),