From 886e7b318dc2add8cd51abb7ba4fdc33af741586 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 3 Sep 2009 22:03:02 -0600 Subject: [PATCH] mesa: use separate temp texture for bitmaps --- src/mesa/drivers/common/meta.c | 63 ++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 8d60f696343..35ce6e408e0 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -137,6 +137,24 @@ struct save_state }; +/** + * Temporary texture used for glBlitFramebuffer, glDrawPixels, etc. + * This is currently shared by all the meta ops. But we could create a + * separate one for each of glDrawPixel, glBlitFramebuffer, glCopyPixels, etc. + */ +struct temp_texture +{ + GLuint TexObj; + GLenum Target; /**< GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE */ + GLsizei MinSize; /**< Min texture size to allocate */ + GLsizei MaxSize; /**< Max possible texture size */ + GLboolean NPOT; /**< Non-power of two size OK? */ + GLsizei Width, Height; /**< Current texture size */ + GLenum IntFormat; + GLfloat Sright, Ttop; /**< right, top texcoords */ +}; + + /** * State for glBlitFramebufer() */ @@ -188,24 +206,7 @@ struct bitmap_state { GLuint ArrayObj; GLuint VBO; -}; - - -/** - * Temporary texture used for glBlitFramebuffer, glDrawPixels, etc. - * This is currently shared by all the meta ops. But we could create a - * separate one for each of glDrawPixel, glBlitFramebuffer, glCopyPixels, etc. - */ -struct temp_texture -{ - GLuint TexObj; - GLenum Target; /**< GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE */ - GLsizei MinSize; /**< Min texture size to allocate */ - GLsizei MaxSize; /**< Max possible texture size */ - GLboolean NPOT; /**< Non-power of two size OK? */ - GLsizei Width, Height; /**< Current texture size */ - GLenum IntFormat; - GLfloat Sright, Ttop; /**< right, top texcoords */ + struct temp_texture Tex; /**< separate texture from other meta ops */ }; @@ -257,6 +258,7 @@ _mesa_meta_free(GLcontext *ctx) * still get freed by _mesa_free_context_data(). */ + /* the temporary texture */ _mesa_DeleteTextures(1, &meta->TempTex.TexObj); /* glBlitFramebuffer */ @@ -281,6 +283,7 @@ _mesa_meta_free(GLcontext *ctx) /* glBitmap */ _mesa_DeleteBuffersARB(1, & meta->Bitmap.VBO); _mesa_DeleteVertexArraysAPPLE(1, &meta->Bitmap.ArrayObj); + _mesa_DeleteTextures(1, &meta->Bitmap.Tex.TexObj); } _mesa_free(ctx->Meta); @@ -747,8 +750,8 @@ init_temp_texture(GLcontext *ctx, struct temp_texture *tex) /** - * Return pointer to temp_texture info. This does some one-time init - * if needed. + * Return pointer to temp_texture info for non-bitmap ops. + * This does some one-time init if needed. */ static struct temp_texture * get_temp_texture(GLcontext *ctx) @@ -763,6 +766,24 @@ get_temp_texture(GLcontext *ctx) } +/** + * Return pointer to temp_texture info for _mesa_meta_bitmap(). + * We use a separate texture for bitmaps to reduce texture + * allocation/deallocation. + */ +static struct temp_texture * +get_bitmap_temp_texture(GLcontext *ctx) +{ + struct temp_texture *tex = &ctx->Meta->Bitmap.Tex; + + if (!tex->TexObj) { + init_temp_texture(ctx, tex); + } + + return tex; +} + + /** * Compute the width/height of texture needed to draw an image of the * given size. Return a flag indicating whether the current texture @@ -1686,7 +1707,7 @@ _mesa_meta_bitmap(GLcontext *ctx, const GLubyte *bitmap1) { struct bitmap_state *bitmap = &ctx->Meta->Bitmap; - struct temp_texture *tex = get_temp_texture(ctx); + struct temp_texture *tex = get_bitmap_temp_texture(ctx); const GLenum texIntFormat = GL_ALPHA; const struct gl_pixelstore_attrib unpackSave = *unpack; GLfloat verts[4][9]; /* four verts of X,Y,Z,S,T,R,G,B,A */ -- 2.30.2