[Mesa-dev] [PATCH 12/23] copytexture: update error checking for GLES3
Ian Romanick
idr at freedesktop.org
Mon Jan 7 10:53:18 PST 2013
On 01/04/2013 06:41 PM, Jordan Justen wrote:
> Changes based on GTF/gles3 conformance test suite.
>
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
> src/mesa/main/teximage.c | 62 +++++++++++++++++++++++++++++++++-------------
> 1 file changed, 45 insertions(+), 17 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 169e768..cb0084a 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -2370,6 +2370,9 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
> GLint width, GLint height, GLint border )
> {
> GLint baseFormat;
> + GLint rb_base_format;
> + struct gl_renderbuffer *rb;
> + GLenum rb_internal_format;
>
> /* check target */
> if (!legal_texsubimage_target(ctx, dimensions, target)) {
> @@ -2414,31 +2417,56 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
> return GL_TRUE;
> }
>
> - /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the
> - * internalFormat.
> - */
> - if (_mesa_is_gles(ctx) && !_mesa_is_gles3(ctx)) {
> - switch (internalFormat) {
> - case GL_ALPHA:
> - case GL_RGB:
> - case GL_RGBA:
> - case GL_LUMINANCE:
> - case GL_LUMINANCE_ALPHA:
> - break;
> - default:
> - _mesa_error(ctx, GL_INVALID_VALUE,
> - "glCopyTexImage%dD(internalFormat)", dimensions);
> - return GL_TRUE;
> - }
> + rb = _mesa_get_read_renderbuffer(ctx, internalFormat);
> + if (rb == NULL) {
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "glCopyTexImage%dD(read buffer)", dimensions);
> + return GL_TRUE;
> }
>
> + rb_internal_format = rb->InternalFormat;
> baseFormat = _mesa_base_tex_format(ctx, internalFormat);
> + rb_base_format = _mesa_base_tex_format(ctx, rb->InternalFormat);
It seems weird that these assignments are here... so far from where
they're actually used. Also, the declaration (and assignment) of
rb_internal_format needs to be in the previous patch. :)
> if (baseFormat < 0) {
> - _mesa_error(ctx, GL_INVALID_VALUE,
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> "glCopyTexImage%dD(internalFormat)", dimensions);
> return GL_TRUE;
> }
>
> + if (_mesa_is_color_format(internalFormat)) {
> + if (rb_base_format < 0) {
> + _mesa_error(ctx, GL_INVALID_VALUE,
> + "glCopyTexImage%dD(internalFormat)", dimensions);
> + return GL_TRUE;
> + }
> + }
> +
> + if (_mesa_is_gles(ctx)) {
> + bool valid = true;
> + if (_mesa_base_format_component_count(baseFormat) >
> + _mesa_base_format_component_count(rb_base_format)) {
> + valid = false;
> + }
> + if (baseFormat == GL_DEPTH_COMPONENT ||
> + baseFormat == GL_DEPTH_STENCIL ||
> + rb_base_format == GL_DEPTH_COMPONENT ||
> + rb_base_format == GL_DEPTH_STENCIL ||
> + ((baseFormat == GL_LUMINANCE_ALPHA ||
> + baseFormat == GL_ALPHA) &&
> + rb_base_format != GL_RGBA) ||
> + internalFormat == GL_RGB9_E5) {
> + valid = false;
> + }
> + if (internalFormat == GL_RGB9_E5) {
> + valid = false;
> + }
> + if (!valid) {
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "glCopyTexImage%dD(internalFormat)", dimensions);
> + return GL_TRUE;
> + }
> + }
> +
> if (is_srgb_format(internalFormat) != is_srgb_format(rb_internal_format)) {
> _mesa_error(ctx, GL_INVALID_OPERATION,
> "glCopyTexImage%dD(srgb usage mismatch)", dimensions);
>
More information about the mesa-dev
mailing list