summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-09-03 22:03:02 -0600
committerBrian Paul <brianp@vmware.com>2009-09-06 09:37:30 -0600
commit886e7b318dc2add8cd51abb7ba4fdc33af741586 (patch)
tree2ede7ef0b1c69592c347ed8292956b0cfcf85b6b
parentb2951ffe962f56cb88cc2e4eabe4aa4eb7232170 (diff)
mesa: use separate temp texture for bitmaps
-rw-r--r--src/mesa/drivers/common/meta.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 8d60f69634..35ce6e408e 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -138,6 +138,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()
*/
struct blit_state
@@ -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)
@@ -764,6 +767,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
* can be re-used (glTexSubImage2D) or if a new texture needs to be
@@ -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 */