Mesa (master): mesa: for meta blit, check max texture size, use glCopyTexSubImage2D() when possible

Brian Paul brianp at kemper.freedesktop.org
Mon Aug 10 21:48:59 UTC 2009


Module: Mesa
Branch: master
Commit: 2ad10c966c87b2efc956bcc58aaedc60f0a5c6a4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ad10c966c87b2efc956bcc58aaedc60f0a5c6a4

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Aug 10 15:05:53 2009 -0600

mesa: for meta blit, check max texture size, use glCopyTexSubImage2D() when possible

---

 src/mesa/drivers/common/meta.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 7a3969d..a7eba2e 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -137,6 +137,8 @@ struct save_state
 struct blit_state
 {
    GLuint TexObj;
+   GLsizei TexWidth, TexHeight;
+   GLenum TexType;
    GLuint ArrayObj;
    GLuint VBO;
    GLfloat verts[4][4]; /** four verts of X,Y,S,T */
@@ -630,6 +632,15 @@ _mesa_meta_blit_framebuffer(GLcontext *ctx,
 
    ASSERT(ctx->Extensions.NV_texture_rectangle);
 
+   if (srcW > ctx->Const.MaxTextureRectSize ||
+       srcH > ctx->Const.MaxTextureRectSize) {
+      /* XXX avoid this fallback */
+      _swrast_BlitFramebuffer(ctx, srcX0, srcY0, srcX1, srcY1,
+                              dstX0, dstY0, dstX1, dstY1, mask, filter);
+      return;
+   }
+
+
    if (srcFlipX) {
       GLint tmp = dstX0;
       dstX0 = dstX1;
@@ -712,8 +723,22 @@ _mesa_meta_blit_framebuffer(GLcontext *ctx,
 
    /* copy framebuffer image to texture */
    if (mask & GL_COLOR_BUFFER_BIT) {
-      _mesa_CopyTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA,
-                           srcX, srcY, srcW, srcH, 0);
+      if (blit->TexWidth == srcW &&
+          blit->TexHeight == srcH &&
+          blit->TexType == GL_RGBA) {
+         /* replace existing tex image */
+         _mesa_CopyTexSubImage2D(GL_TEXTURE_RECTANGLE, 0,
+                                 0, 0, srcX, srcY, srcW, srcH);
+      }
+      else {
+         /* create new tex image */
+         _mesa_CopyTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA,
+                              srcX, srcY, srcW, srcH, 0);
+         blit->TexWidth = srcW;
+         blit->TexHeight = srcH;
+         blit->TexType = GL_RGBA;
+      }
+
       mask &= ~GL_COLOR_BUFFER_BIT;
    }
 




More information about the mesa-commit mailing list