summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorLaura Ekstrand <[email protected]>2015-03-02 13:41:13 -0800
committerFredrik Höglund <[email protected]>2015-05-14 15:48:13 +0200
commita9f73f7f42081594d0ba9ff6cb7a0a743c3cad93 (patch)
treeb1ba7b8487e3a81bfc729176aff89a8d01b3a2d9 /src/mesa
parenta245e3bdeb1cf38b56df4f208a7e20d0f0de6045 (diff)
main: Refactor get_texture_for_framebuffer.
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 function as well. [Fredrik: Fix the texObj NULL check] Reviewed-by: Fredrik Höglund <[email protected]> Signed-off-by: Fredrik Höglund <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/fbobject.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 553a32b2a4d..f1c0780318c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2585,17 +2585,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 == NULL || (*texObj)->Target == 0) {
+ /* Can't render to a non-existent 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).
+ */
+ const GLenum error = *layered ? GL_INVALID_VALUE :
+ GL_INVALID_OPERATION;
+ _mesa_error(ctx, error,
+ "%s(non-existent texture %u)", caller, texture);
+ return false;
+ }
- *texObj = _mesa_lookup_texture(ctx, texture);
- if (*texObj != NULL && (*texObj)->Target != 0) {
if (textarget == 0) {
if (*layered) {
/* We're being called by gl*FramebufferTexture() and textarget
@@ -2644,23 +2661,6 @@ get_texture_for_framebuffer(struct gl_context *ctx,
? !_mesa_is_cube_face(textarget)
: ((*texObj)->Target != textarget);
}
- }
- else {
- /* Can't render to a non-existent 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).
- */
- const GLenum error = *layered ? GL_INVALID_VALUE :
- GL_INVALID_OPERATION;
- _mesa_error(ctx, error,
- "%s(non-existent texture %u)", caller, texture);
- return false;
- }
if (err) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -2707,7 +2707,6 @@ get_texture_for_framebuffer(struct gl_context *ctx,
"%s(invalid level %d)", caller, level);
return false;
}
- }
return true;
}