meta: Fold the texture setup into setup_copypix_texture().

There was this funny argument passed to setup for "did alloc decide we
need to allocate new texture storage?", which goes away if we don't have
the caller do alloc as a separate step.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Eric Anholt 2014-02-03 15:58:03 -08:00
parent 397b2c3966
commit cd084aa297

View file

@ -1539,17 +1539,20 @@ alloc_texture(struct temp_texture *tex,
static void static void
setup_copypix_texture(struct gl_context *ctx, setup_copypix_texture(struct gl_context *ctx,
struct temp_texture *tex, struct temp_texture *tex,
GLboolean newTex,
GLint srcX, GLint srcY, GLint srcX, GLint srcY,
GLsizei width, GLsizei height, GLenum intFormat, GLsizei width, GLsizei height, GLenum intFormat,
GLenum filter) GLenum filter)
{ {
bool newTex;
_mesa_BindTexture(tex->Target, tex->TexObj); _mesa_BindTexture(tex->Target, tex->TexObj);
_mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, filter); _mesa_TexParameteri(tex->Target, GL_TEXTURE_MIN_FILTER, filter);
_mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, filter); _mesa_TexParameteri(tex->Target, GL_TEXTURE_MAG_FILTER, filter);
if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES)
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
newTex = alloc_texture(tex, width, height, intFormat);
/* copy framebuffer image to texture */ /* copy framebuffer image to texture */
if (newTex) { if (newTex) {
/* create new tex image */ /* create new tex image */
@ -1942,8 +1945,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
* linear filtering along the edges. So, allocate the texture extended along * linear filtering along the edges. So, allocate the texture extended along
* edges by one pixel in x, y directions. * edges by one pixel in x, y directions.
*/ */
newTex = alloc_texture(tex, srcW + 2, srcH + 2, rb_base_format); setup_copypix_texture(ctx, tex,
setup_copypix_texture(ctx, tex, newTex,
srcX - 1, srcY - 1, srcW + 2, srcH + 2, srcX - 1, srcY - 1, srcW + 2, srcH + 2,
rb_base_format, filter); rb_base_format, filter);
/* texcoords (after texture allocation!) */ /* texcoords (after texture allocation!) */
@ -2439,8 +2441,6 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
struct copypix_state *copypix = &ctx->Meta->CopyPix; struct copypix_state *copypix = &ctx->Meta->CopyPix;
struct temp_texture *tex = get_temp_texture(ctx); struct temp_texture *tex = get_temp_texture(ctx);
struct vertex verts[4]; struct vertex verts[4];
GLboolean newTex;
GLenum intFormat = GL_RGBA;
if (type != GL_COLOR || if (type != GL_COLOR ||
ctx->_ImageTransferState || ctx->_ImageTransferState ||
@ -2465,11 +2465,13 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
setup_vertex_objects(&copypix->VAO, &copypix->VBO, false, 3, 2, 0); setup_vertex_objects(&copypix->VAO, &copypix->VBO, false, 3, 2, 0);
newTex = alloc_texture(tex, width, height, intFormat);
/* Silence valgrind warnings about reading uninitialized stack. */ /* Silence valgrind warnings about reading uninitialized stack. */
memset(verts, 0, sizeof(verts)); memset(verts, 0, sizeof(verts));
/* Alloc/setup texture */
setup_copypix_texture(ctx, tex, srcX, srcY, width, height,
GL_RGBA, GL_NEAREST);
/* vertex positions, texcoords (after texture allocation!) */ /* vertex positions, texcoords (after texture allocation!) */
{ {
const GLfloat dstX0 = (GLfloat) dstX; const GLfloat dstX0 = (GLfloat) dstX;
@ -2503,10 +2505,6 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY,
_mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
} }
/* Alloc/setup texture */
setup_copypix_texture(ctx, tex, newTex, srcX, srcY, width, height,
GL_RGBA, GL_NEAREST);
_mesa_set_enable(ctx, tex->Target, GL_TRUE); _mesa_set_enable(ctx, tex->Target, GL_TRUE);
/* draw textured quad */ /* draw textured quad */