Mesa (master): nouveau: Recursively swizzle an NPOT sized copy

Patrice Mandin pmandin at kemper.freedesktop.org
Sun Jul 26 10:31:08 UTC 2009


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

Author: Patrice Mandin <patmandin at gmail.com>
Date:   Sun Jul 26 12:30:12 2009 +0200

nouveau: Recursively swizzle an NPOT sized copy

---

 src/gallium/drivers/nv04/nv04_surface_2d.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/nv04/nv04_surface_2d.c b/src/gallium/drivers/nv04/nv04_surface_2d.c
index c0adf7c..143b858 100644
--- a/src/gallium/drivers/nv04/nv04_surface_2d.c
+++ b/src/gallium/drivers/nv04/nv04_surface_2d.c
@@ -111,8 +111,6 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
 	unsigned cy;
 
 #if 0
-	/* POT or GTFO */
-	assert(!(w & (w - 1)) && !(h & (h - 1)));
 	/* That's the way she likes it */
 	assert(src_pitch == ((struct nv04_surface *)dst)->pitch);
 #endif
@@ -260,9 +258,27 @@ nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
 	assert(src->format == dst->format);
 
 	/* Setup transfer to swizzle the texture to vram if needed */
-	if (src_linear && !dst_linear && w > 1 && h > 1 &&
-	    !(w & (w - 1)) && !(h & (h - 1))) { /* POT only */
-		nv04_surface_copy_swizzle(ctx, dst, dx, dy, src, sx, sy, w, h);
+	if (src_linear && !dst_linear && w > 1 && h > 1) {
+		int potWidth = 1<<log2i(w);
+		int potHeight = 1<<log2i(h);
+		int remainWidth = w-potWidth;
+		int remainHeight = h-potHeight;
+
+		nv04_surface_copy_swizzle(ctx, dst, dx, dy, src, sx, sy,
+		                          potWidth, potHeight);
+
+		if (remainWidth>0) {
+			nv04_surface_copy(ctx, dst, dx+potWidth, dy,
+			                  src, sx+potWidth, sy,
+			                  remainWidth, potHeight);
+		}
+
+		if (remainHeight>0) {
+			nv04_surface_copy(ctx, dst, dx, dy+potHeight,
+			                  src, sx, sy+potHeight,
+			                  w, remainHeight);
+		}
+
 		return;
 	}
 




More information about the mesa-commit mailing list