On Wednesday 04 March 2015, Laura Ekstrand wrote: > This moves a few blocks around so that the control flow is more obvious. If > the texture is 0, just return true at the beginning of the function. > Likewise, if the texObj is NULL, return true at the beginning of the funciton > as well. > --- > src/mesa/main/fbobject.c | 43 +++++++++++++++++++++---------------------- > 1 file changed, 21 insertions(+), 22 deletions(-) > > diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c > index 143c6b4..f86e1a0 100644 > --- a/src/mesa/main/fbobject.c > +++ b/src/mesa/main/fbobject.c > @@ -2437,17 +2437,34 @@ get_texture_for_framebuffer(struct gl_context *ctx, > struct gl_texture_object **texObj) > { > GLenum maxLevelsTarget; > + GLboolean err = GL_TRUE; > > *texObj = NULL; /* This will get returned if texture = 0. */ > > /* The textarget, level, and zoffset parameters are only validated if > * texture is non-zero. > */ > - if (texture) { > - GLboolean err = GL_TRUE; > + if (!texture) > + return true; > + > + *texObj = _mesa_lookup_texture(ctx, texture); > + if (!texObj) {
One more thing: this line is NULL-checking the wrong pointer. It should be checking *texObj. > + /* Can't render to a non-existant texture object. > + * > + * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and > + * Managing Framebuffer Objects specifies a different error > + * depending upon the calling function (PDF pages 325-328). > + * *FramebufferTexture (where *layered = GL_TRUE) throws invalid > + * value, while the other commands throw invalid operation (where > + * *layered = GL_FALSE). > + */ > + GLenum no_texobj_err = *layered ? GL_INVALID_VALUE : > + GL_INVALID_OPERATION; > + _mesa_error(ctx, no_texobj_err, > + "%s(non-generated texture %u)", caller, texture); > + return false; > + } > > - *texObj = _mesa_lookup_texture(ctx, texture); > - if (*texObj != NULL) { > if (textarget == 0) { > if (*layered) { > /* We're being called by gl*FramebufferTexture() and textarget > @@ -2496,23 +2513,6 @@ get_texture_for_framebuffer(struct gl_context *ctx, > ? !_mesa_is_cube_face(textarget) > : ((*texObj)->Target != textarget); > } > - } > - else { > - /* Can't render to a non-existant texture object. > - * > - * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and > - * Managing Framebuffer Objects specifies a different error > - * depending upon the calling function (PDF pages 325-328). > - * *FramebufferTexture (where *layered = GL_TRUE) throws invalid > - * value, while the other commands throw invalid operation (where > - * *layered = GL_FALSE). > - */ > - GLenum no_texobj_err = *layered ? GL_INVALID_VALUE : > - GL_INVALID_OPERATION; > - _mesa_error(ctx, no_texobj_err, > - "%s(non-generated texture %u)", caller, texture); > - return false; > - } > > if (err) { > _mesa_error(ctx, GL_INVALID_OPERATION, > @@ -2546,7 +2546,6 @@ get_texture_for_framebuffer(struct gl_context *ctx, > "%s(invalid level %d)", caller, level); > return false; > } > - } > > return true; > } > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev