Hi list,

the first of these two patches fixes _mesa_meta_GenerateMipmap to update
the viewport and projection matrix after changing the destination mipmap
level. Before, pixels would get clipped to the boundaries of the
original DrawBuffer, which may be smaller than the second mipmap level.
The second patch just pulls projection matrix and vertex array setup out
of the main loop.

The other way to fix this i can think of is to disable clipping to
viewport. I could not figure out if that is even possible.

Tested with swrast and i965.

Regards,
  Pierre
>From 493e1fe00e902723c0b20cc75d83fbbca107b90e Mon Sep 17 00:00:00 2001
From: Pierre Willenbrock <pie...@pirsoft.de>
Date: Wed, 6 Jan 2010 22:37:18 +0100
Subject: [PATCH 1/2] Setup viewport and Projection Matrix in _mesa_meta_GenerateMipmap

This fixes mipmap levels being clipped to the last viewport.

Signed-off-by: Pierre Willenbrock <pie...@pirsoft.de>
---
 src/mesa/drivers/common/meta.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index c4dbfa6..51dd5e0 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2430,7 +2430,7 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
                                        texObj->Name,
                                        dstLevel);
       }
-
+      
       _mesa_DrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
 
       /* sanity check */
@@ -2440,6 +2440,15 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
          break;
       }
 
+      /* setup viewport and matching projection matrix */
+      _mesa_set_viewport(ctx, 0, 0,
+			 ctx->DrawBuffer->Width, ctx->DrawBuffer->Height);
+      _mesa_MatrixMode(GL_PROJECTION);
+      _mesa_LoadIdentity();
+      _mesa_Ortho(0.0F, ctx->DrawBuffer->Width,
+		  0.0F, ctx->DrawBuffer->Height,
+		  -1.0F, 1.0F);
+
       _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
    }
 
-- 
1.6.6.rc4

>From 258f82377d39888040d297fe11b0c17d1a0a55c4 Mon Sep 17 00:00:00 2001
From: Pierre Willenbrock <pie...@pirsoft.de>
Date: Wed, 6 Jan 2010 22:37:32 +0100
Subject: [PATCH 2/2] Move destination vertex/projection setup out of _mesa_meta_GenerateMipmap

Signed-off-by: Pierre Willenbrock <pie...@pirsoft.de>
---
 src/mesa/drivers/common/meta.c |   44 ++++++++++++++++++++-------------------
 1 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 51dd5e0..25234d9 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2321,6 +2321,28 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
 
    _mesa_set_enable(ctx, target, GL_TRUE);
 
+   /* setup vertex positions */
+   {
+      verts[0].x = 0.0F;
+      verts[0].y = 0.0F;
+      verts[1].x = 1.0F;
+      verts[1].y = 0.0F;
+      verts[2].x = 1.0F;
+      verts[2].y = 1.0F;
+      verts[3].x = 0.0F;
+      verts[3].y = 1.0F;
+      
+      /* upload new vertex data */
+      _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
+   }
+
+   /* setup projection matrix */
+   _mesa_MatrixMode(GL_PROJECTION);
+   _mesa_LoadIdentity();
+   _mesa_Ortho(0.0F, 1.0F,
+	       0.0F, 1.0F,
+	       -1.0F, 1.0F);
+
    /* texture is already locked, unlock now */
    _mesa_unlock_texture(ctx, texObj);
 
@@ -2387,21 +2409,6 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
          }
       }
 
-      /* setup vertex positions */
-      {
-         verts[0].x = 0.0F;
-         verts[0].y = 0.0F;
-         verts[1].x = (GLfloat) dstWidth;
-         verts[1].y = 0.0F;
-         verts[2].x = (GLfloat) dstWidth;
-         verts[2].y = (GLfloat) dstHeight;
-         verts[3].x = 0.0F;
-         verts[3].y = (GLfloat) dstHeight;
-
-         /* upload new vertex data */
-         _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
-      }
-
       /* limit sampling to src level */
       _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
       _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
@@ -2440,14 +2447,9 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
          break;
       }
 
-      /* setup viewport and matching projection matrix */
+      /* setup viewport */
       _mesa_set_viewport(ctx, 0, 0,
 			 ctx->DrawBuffer->Width, ctx->DrawBuffer->Height);
-      _mesa_MatrixMode(GL_PROJECTION);
-      _mesa_LoadIdentity();
-      _mesa_Ortho(0.0F, ctx->DrawBuffer->Width,
-		  0.0F, ctx->DrawBuffer->Height,
-		  -1.0F, 1.0F);
 
       _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
    }
-- 
1.6.6.rc4

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to