On Mon, Aug 10, 2015 at 5:37 PM, Ilia Mirkin <imir...@alum.mit.edu> wrote: > On Mon, Aug 10, 2015 at 5:28 PM, Rob Clark <robdcl...@gmail.com> wrote: >> From: Rob Clark <robcl...@freedesktop.org> >> >> These extensions allow reading depth/stencil for GLES contexts, which is >> useful for tools like apitrace. >> >> Signed-off-by: Rob Clark <robcl...@freedesktop.org> >> --- >> v2: rework format/type checking >> >> src/mesa/main/extensions.c | 3 +++ >> src/mesa/main/readpix.c | 48 >> +++++++++++++++++++++++++++++++++++++--------- >> 2 files changed, 42 insertions(+), 9 deletions(-) >> >> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c >> index 2dbfabd..d934d19 100644 >> --- a/src/mesa/main/extensions.c >> +++ b/src/mesa/main/extensions.c >> @@ -385,6 +385,9 @@ static const struct extension extension_table[] = { >> { "GL_NV_point_sprite", o(NV_point_sprite), >> GL, 2001 }, >> { "GL_NV_primitive_restart", o(NV_primitive_restart), >> GLL, 2002 }, >> { "GL_NV_read_buffer", o(dummy_true), >> ES2, 2011 }, >> + { "GL_NV_read_depth", o(dummy_true), >> ES2, 2011 }, >> + { "GL_NV_read_depth_stencil", o(dummy_true), >> ES2, 2011 }, >> + { "GL_NV_read_stencil", o(dummy_true), >> ES2, 2011 }, >> { "GL_NV_texgen_reflection", o(dummy_true), >> GLL, 1999 }, >> { "GL_NV_texture_barrier", o(NV_texture_barrier), >> GL, 2009 }, >> { "GL_NV_texture_env_combine4", >> o(NV_texture_env_combine4), GLL, 1999 }, >> diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c >> index 2744232..d826ecf 100644 >> --- a/src/mesa/main/readpix.c >> +++ b/src/mesa/main/readpix.c >> @@ -916,10 +916,8 @@ read_pixels_es3_error_check(GLenum format, GLenum type, > > Does something need to be done differently for ES2?
I don't *think* so.. in the es2 case it uses the same _mesa_es_error_check_format_and_type() which is used for texsubimage, etc (plus the additional is-depth-or-stencil check which I dropped). That said I'm not 100% sure why gles3 has it's own special readpix format check fxn while gles2 doesn't. BR, -R >> const GLenum data_type = _mesa_get_format_datatype(rb->Format); >> GLboolean is_unsigned_int = GL_FALSE; >> GLboolean is_signed_int = GL_FALSE; >> - >> - if (!_mesa_is_color_format(internalFormat)) { >> - return GL_INVALID_OPERATION; >> - } >> + GLboolean is_float_depth = (internalFormat == GL_DEPTH_COMPONENT32F) || >> + (internalFormat == GL_DEPTH32F_STENCIL8); >> >> is_unsigned_int = _mesa_is_enum_format_unsigned_int(internalFormat); >> if (!is_unsigned_int) { >> @@ -950,6 +948,43 @@ read_pixels_es3_error_check(GLenum format, GLenum type, >> (is_unsigned_int && type == GL_UNSIGNED_INT)) >> return GL_NO_ERROR; >> break; >> + case GL_DEPTH_STENCIL: >> + switch (type) { >> + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: >> + if (is_float_depth) >> + return GL_NO_ERROR; >> + break; >> + case GL_UNSIGNED_INT_24_8: >> + if (!is_float_depth) >> + return GL_NO_ERROR; >> + break; >> + default: >> + return GL_INVALID_ENUM; >> + } >> + break; >> + case GL_DEPTH_COMPONENT: >> + switch (type) { >> + case GL_FLOAT: >> + if (is_float_depth) >> + return GL_NO_ERROR; >> + break; >> + case GL_UNSIGNED_SHORT: >> + case GL_UNSIGNED_INT_24_8: >> + if (!is_float_depth) >> + return GL_NO_ERROR; >> + break; >> + default: >> + return GL_INVALID_ENUM; >> + } >> + break; >> + case GL_STENCIL_INDEX: >> + switch (type) { >> + case GL_UNSIGNED_BYTE: >> + return GL_NO_ERROR; >> + default: >> + return GL_INVALID_ENUM; >> + } >> + break; >> } >> >> return GL_INVALID_OPERATION; >> @@ -1023,11 +1058,6 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei >> width, GLsizei height, >> err = read_pixels_es3_error_check(format, type, rb); >> } >> >> - 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_enum_to_string(format), >> -- >> 2.4.3 >> >> _______________________________________________ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev