Mesa (+gles3): mesa: Return INVALID_ENUM for glReadPixels(..., GL_DEPTH_*, ...) on ES 3

Ian Romanick idr at kemper.freedesktop.org
Thu Dec 6 20:14:53 UTC 2012


Module: Mesa
Branch: +gles3
Commit: 412a815f427c791561fa561d13bef6b6648b5f75
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=412a815f427c791561fa561d13bef6b6648b5f75

Author: Matt Turner <mattst88 at gmail.com>
Date:   Fri Nov 30 15:07:54 2012 -0800

mesa: Return INVALID_ENUM for glReadPixels(..., GL_DEPTH_*, ...) on ES 3

I'm not sure if this is the correct fix. The
_mesa_es_error_check_format_and_type function (used above in the ES 1
and 2 cases) was originally added for glTexImage checking and allows
GL_DEPTH_STENCIL/GL_UNSIGNED_INT_24_8 combinations. Using it in ES 3
causes other tests to regress.

Fixes es3conform's packed_depth_stencil_error test.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org> (v1)
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>

---

 src/mesa/main/readpix.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index d6d105b..5b80e9a 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -679,7 +679,7 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
 		      GLenum format, GLenum type, GLsizei bufSize,
                       GLvoid *pixels )
 {
-   GLenum err;
+   GLenum err = GL_NO_ERROR;
 
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -707,17 +707,21 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height,
     * preferred combination.  This code doesn't know what that preferred
     * combination is, and Mesa can handle anything valid.  Just work instead.
     */
-   if (_mesa_is_gles(ctx) && ctx->Version < 30) {
-      err = _mesa_es_error_check_format_and_type(format, type, 2);
-      if (err == GL_NO_ERROR) {
-         if (type == GL_FLOAT || type == GL_HALF_FLOAT_OES) {
-            err = GL_INVALID_OPERATION;
-         } else if (format == GL_DEPTH_COMPONENT
-                    || format == GL_DEPTH_STENCIL) {
-            err = GL_INVALID_ENUM;
+   if (_mesa_is_gles(ctx)) {
+      if (ctx->Version < 30) {
+         err = _mesa_es_error_check_format_and_type(format, type, 2);
+         if (err == GL_NO_ERROR) {
+            if (type == GL_FLOAT || type == GL_HALF_FLOAT_OES) {
+               err = GL_INVALID_OPERATION;
+            }
          }
       }
 
+      if (err == GL_NO_ERROR && (format == GL_DEPTH_COMPONENT
+          || format == GL_DEPTH_STENCIL)) {
+         err = GL_INVALID_ENUM;
+      }
+
       if (err != GL_NO_ERROR) {
          _mesa_error(ctx, err, "glReadPixels(invalid format %s and/or type %s)",
                      _mesa_lookup_enum_by_nr(format),




More information about the mesa-commit mailing list