From 6d8eff4af7816d675f8ee91f99106fa118cda424 Mon Sep 17 00:00:00 2001 From: Laura Ekstrand Date: Thu, 22 Jan 2015 10:23:35 -0800 Subject: [PATCH] main: Add utility function _mesa_lookup_framebuffer_err. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit [Fredrik: Generate an error for non-existent framebuffers] Reviewed-by: Fredrik Höglund Reviewed-by: Anuj Phogat Signed-off-by: Fredrik Höglund --- src/mesa/main/fbobject.c | 21 +++++++++++++++++++++ src/mesa/main/fbobject.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 27cf97f1778..3f5c0d7ef19 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -137,6 +137,27 @@ _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id) } +/** + * A convenience function for direct state access that throws + * GL_INVALID_OPERATION if the framebuffer doesn't exist. + */ +struct gl_framebuffer * +_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id, + const char *func) +{ + struct gl_framebuffer *fb; + + fb = _mesa_lookup_framebuffer(ctx, id); + if (!fb || fb == &DummyFramebuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(non-existent framebuffer %u)", func, id); + return NULL; + } + + return fb; +} + + /** * Mark the given framebuffer as invalid. This will force the * test for framebuffer completeness to be done before the framebuffer diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h index 61aa1f50308..1f0eb0b5b78 100644 --- a/src/mesa/main/fbobject.h +++ b/src/mesa/main/fbobject.h @@ -67,6 +67,10 @@ _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id); extern struct gl_framebuffer * _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id); +extern struct gl_framebuffer * +_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id, + const char *func); + void _mesa_update_texture_renderbuffer(struct gl_context *ctx, -- 2.30.2