diff options
author | Samuel Pitoiset <[email protected]> | 2017-07-20 11:53:03 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2017-07-20 16:14:34 +0200 |
commit | 1ebe4305fd0e4b4f023eb50ca0b8229bdd7c1a5e (patch) | |
tree | 6e7bd8087d8ca000d7a19837b329cd20226543c9 /src/mesa/main | |
parent | 0752428a32998c700ef13c8b3291915d748665a0 (diff) |
mesa: remove duplicated code around framebuffer_renderbuffer()
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/fbobject.c | 70 |
1 files changed, 23 insertions, 47 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 7c92df56080..46bc129effc 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -3645,15 +3645,29 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx, } static void -framebuffer_renderbuffer(struct gl_context *ctx, - struct gl_framebuffer *fb, - GLenum attachment, - struct gl_renderbuffer *rb, - const char *func) +framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer, const char *func) { struct gl_renderbuffer_attachment *att; + struct gl_renderbuffer *rb; bool is_color_attachment; + if (renderbuffertarget != GL_RENDERBUFFER) { + _mesa_error(ctx, GL_INVALID_ENUM, + "%s(renderbuffertarget is not GL_RENDERBUFFER)", func); + return; + } + + if (renderbuffer) { + rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer, func); + if (!rb) + return; + } else { + /* remove renderbuffer attachment */ + rb = NULL; + } + if (_mesa_is_winsys_fbo(fb)) { /* Can't attach new renderbuffers to a window system framebuffer */ _mesa_error(ctx, GL_INVALID_OPERATION, @@ -3707,7 +3721,6 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment, GLuint renderbuffer) { struct gl_framebuffer *fb; - struct gl_renderbuffer *rb; GET_CURRENT_CONTEXT(ctx); fb = get_framebuffer_target(ctx, target); @@ -3718,26 +3731,8 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment, return; } - if (renderbuffertarget != GL_RENDERBUFFER) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferRenderbuffer(renderbuffertarget is not " - "GL_RENDERBUFFER)"); - return; - } - - if (renderbuffer) { - rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer, - "glFramebufferRenderbuffer"); - if (!rb) - return; - } - else { - /* remove renderbuffer attachment */ - rb = NULL; - } - - framebuffer_renderbuffer(ctx, fb, attachment, rb, - "glFramebufferRenderbuffer"); + framebuffer_renderbuffer(ctx, fb, attachment, renderbuffertarget, + renderbuffer, "glFramebufferRenderbuffer"); } @@ -3747,7 +3742,6 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment, GLuint renderbuffer) { struct gl_framebuffer *fb; - struct gl_renderbuffer *rb; GET_CURRENT_CONTEXT(ctx); fb = _mesa_lookup_framebuffer_err(ctx, framebuffer, @@ -3755,26 +3749,8 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment, if (!fb) return; - if (renderbuffertarget != GL_RENDERBUFFER) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glNamedFramebufferRenderbuffer(renderbuffertarget is not " - "GL_RENDERBUFFER)"); - return; - } - - if (renderbuffer) { - rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer, - "glNamedFramebufferRenderbuffer"); - if (!rb) - return; - } - else { - /* remove renderbuffer attachment */ - rb = NULL; - } - - framebuffer_renderbuffer(ctx, fb, attachment, rb, - "glNamedFramebufferRenderbuffer"); + framebuffer_renderbuffer(ctx, fb, attachment, renderbuffertarget, + renderbuffer, "glNamedFramebufferRenderbuffer"); } |