diff options
author | Topi Pohjolainen <[email protected]> | 2014-05-05 17:37:40 +0300 |
---|---|---|
committer | Topi Pohjolainen <[email protected]> | 2014-05-12 17:48:45 +0300 |
commit | a2952315ac2c97311c0a967bf1c337a6c0b82a2f (patch) | |
tree | 982c7486f9c5f067fbc88fb6eb4fae6e1204530e /src/mesa/drivers/common/meta_blit.c | |
parent | ac4db0aa559ac07262d977f35915953f97875333 (diff) |
meta: Refactor binding of renderbuffer as texture image
Cc: "10.2" <[email protected]>
Signed-off-by: Topi Pohjolainen <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers/common/meta_blit.c')
-rw-r--r-- | src/mesa/drivers/common/meta_blit.c | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c index 14ecf8f11ed..9c8231bf02d 100644 --- a/src/mesa/drivers/common/meta_blit.c +++ b/src/mesa/drivers/common/meta_blit.c @@ -392,38 +392,16 @@ blitframebuffer_texture(struct gl_context *ctx, texObj = readAtt->Texture; target = texObj->Target; } else if (!readAtt->Texture && ctx->Driver.BindRenderbufferTexImage) { - /* Otherwise, we need the driver to be able to bind a renderbuffer as - * a texture image. - */ - struct gl_texture_image *texImage; - - if (rb->NumSamples > 1) - target = GL_TEXTURE_2D_MULTISAMPLE; - else - target = GL_TEXTURE_2D; - - _mesa_GenTextures(1, &tempTex); - _mesa_BindTexture(target, tempTex); - srcLevel = 0; - texObj = _mesa_lookup_texture(ctx, tempTex); - texImage = _mesa_get_tex_image(ctx, texObj, target, srcLevel); - - if (!ctx->Driver.BindRenderbufferTexImage(ctx, rb, texImage)) { - _mesa_DeleteTextures(1, &tempTex); + if (!_mesa_meta_bind_rb_as_tex_image(ctx, rb, + &tempTex, &texObj, &target)) return false; - } else { - if (ctx->Driver.FinishRenderTexture && - !rb->NeedsFinishRenderTexture) { - rb->NeedsFinishRenderTexture = true; - ctx->Driver.FinishRenderTexture(ctx, rb); - } - if (_mesa_is_winsys_fbo(readFb)) { - GLint temp = srcY0; - srcY0 = rb->Height - srcY1; - srcY1 = rb->Height - temp; - flipY = -flipY; - } + srcLevel = 0; + if (_mesa_is_winsys_fbo(readFb)) { + GLint temp = srcY0; + srcY0 = rb->Height - srcY1; + srcY1 = rb->Height - temp; + flipY = -flipY; } } else { GLenum tex_base_format; @@ -603,6 +581,38 @@ blitframebuffer_texture(struct gl_context *ctx, return true; } +GLboolean +_mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx, + struct gl_renderbuffer *rb, + GLuint *tex, + struct gl_texture_object **texObj, + GLenum *target) +{ + struct gl_texture_image *texImage; + + if (rb->NumSamples > 1) + *target = GL_TEXTURE_2D_MULTISAMPLE; + else + *target = GL_TEXTURE_2D; + + _mesa_GenTextures(1, tex); + _mesa_BindTexture(*target, *tex); + *texObj = _mesa_lookup_texture(ctx, *tex); + texImage = _mesa_get_tex_image(ctx, *texObj, *target, 0); + + if (!ctx->Driver.BindRenderbufferTexImage(ctx, rb, texImage)) { + _mesa_DeleteTextures(1, tex); + return false; + } + + if (ctx->Driver.FinishRenderTexture && !rb->NeedsFinishRenderTexture) { + rb->NeedsFinishRenderTexture = true; + ctx->Driver.FinishRenderTexture(ctx, rb); + } + + return true; +} + /** * Meta implementation of ctx->Driver.BlitFramebuffer() in terms * of texture mapping and polygon rendering. |