meta: Do a massive unindent (and rename) of blitframebuffer_texture().

This function is only handling the color case.  We can just unindent as
long as we're willing to do the check for the bit outside of the
function.

v2: Rebase on idr's changes, drop readAtt check that's always non-null
    anyway (it's a pointer into to the statically-allocated attachments
    array in the renderbuffer).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
This commit is contained in:
Eric Anholt 2014-02-04 14:52:27 -08:00
parent 3e4ccf499e
commit 431decf16f
1 changed files with 151 additions and 149 deletions

View File

@ -96,33 +96,27 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx,
/**
* Try to do a glBlitFramebuffer using no-copy texturing.
* We can do this when the src renderbuffer is actually a texture.
*
* \return new buffer mask indicating the buffers left to blit using the
* normal path.
*/
static GLbitfield
static bool
blitframebuffer_texture(struct gl_context *ctx,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter, GLint flipX,
GLint flipY, GLboolean glsl_version)
GLenum filter, GLint flipX, GLint flipY,
GLboolean glsl_version)
{
if (mask & GL_COLOR_BUFFER_BIT) {
const struct gl_framebuffer *readFb = ctx->ReadBuffer;
const struct gl_renderbuffer_attachment *readAtt =
&readFb->Attachment[readFb->_ColorReadBufferIndex];
if (readAtt && readAtt->Texture) {
struct blit_state *blit = &ctx->Meta->Blit;
const GLint dstX = MIN2(dstX0, dstX1);
const GLint dstY = MIN2(dstY0, dstY1);
const GLint dstW = abs(dstX1 - dstX0);
const GLint dstH = abs(dstY1 - dstY0);
const struct gl_texture_object *texObj = readAtt->Texture;
const GLuint srcLevel = readAtt->TextureLevel;
const GLint baseLevelSave = texObj->BaseLevel;
const GLint maxLevelSave = texObj->MaxLevel;
const GLenum target = texObj->Target;
GLuint srcLevel;
GLint baseLevelSave;
GLint maxLevelSave;
GLenum target;
GLuint sampler, samplerSave =
ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;
@ -132,9 +126,17 @@ blitframebuffer_texture(struct gl_context *ctx,
return mask;
}
/* Choose between glsl version and fixed function version of
* BlitFramebuffer function.
*/
if (readAtt->Texture) {
srcLevel = readAtt->TextureLevel;
texObj = readAtt->Texture;
} else {
return false;
}
baseLevelSave = texObj->BaseLevel;
maxLevelSave = texObj->MaxLevel;
target = texObj->Target;
if (glsl_version) {
setup_glsl_blit_framebuffer(ctx, blit, target);
}
@ -241,12 +243,7 @@ blitframebuffer_texture(struct gl_context *ctx,
_mesa_BindSampler(ctx->Texture.CurrentUnit, samplerSave);
_mesa_DeleteSamplers(1, &sampler);
/* Done with color buffer */
mask &= ~GL_COLOR_BUFFER_BIT;
}
}
return mask;
return true;
}
/**
@ -300,13 +297,18 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
_mesa_meta_begin(ctx, ~MESA_META_SCISSOR);
/* Try faster, direct texture approach first */
mask = blitframebuffer_texture(ctx, srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1, mask, filter,
dstFlipX, dstFlipY, use_glsl_version);
if (mask & GL_COLOR_BUFFER_BIT) {
if (blitframebuffer_texture(ctx, srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
filter, dstFlipX, dstFlipY,
use_glsl_version)) {
mask &= ~GL_COLOR_BUFFER_BIT;
if (mask == 0x0) {
_mesa_meta_end(ctx);
return;
}
}
}
/* Choose between glsl version and fixed function version of
* BlitFramebuffer function.