Mesa (gallium-0.2): nouveau: Calc pitch for swizzled textures appropriately .

Younes Manton ymanton at kemper.freedesktop.org
Tue Dec 2 21:16:22 UTC 2008


Module: Mesa
Branch: gallium-0.2
Commit: 4371a24c320f3d26f07effa0c3e862078762c942
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4371a24c320f3d26f07effa0c3e862078762c942

Author: Younes Manton <younes.m at gmail.com>
Date:   Tue Dec  2 16:12:49 2008 -0500

nouveau: Calc pitch for swizzled textures appropriately.

---

 src/gallium/drivers/nv40/nv40_miptree.c       |    7 +++----
 src/gallium/winsys/drm/nouveau/nv04_surface.c |    5 ++++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c
index 6516bff..b68967c 100644
--- a/src/gallium/drivers/nv40/nv40_miptree.c
+++ b/src/gallium/drivers/nv40/nv40_miptree.c
@@ -8,7 +8,6 @@ static void
 nv40_miptree_layout(struct nv40_miptree *mt)
 {
 	struct pipe_texture *pt = &mt->base;
-	boolean swizzled = FALSE;
 	uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
 	uint offset = 0;
 	int nr_faces, l, f, pitch;
@@ -30,7 +29,7 @@ nv40_miptree_layout(struct nv40_miptree *mt)
 		pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
 		pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
 
-		if (swizzled)
+		if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
 			pitch = pt->nblocksx[l];
 		pitch = align(pitch, 64);
 
@@ -68,8 +67,6 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
 	mt->shadow_tex = NULL;
 	mt->shadow_surface = NULL;
 
-	nv40_miptree_layout(mt);
-
 	/* Swizzled textures must be POT */
 	if (pt->width[0] & (pt->width[0] - 1) ||
 	    pt->height[0] & (pt->height[0] - 1))
@@ -91,6 +88,8 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
 		}
 	}
 
+	nv40_miptree_layout(mt);
+
 	mt->buffer = ws->buffer_create(ws, 256,
 				       PIPE_BUFFER_USAGE_PIXEL |
 				       NOUVEAU_BUFFER_USAGE_TEXTURE,
diff --git a/src/gallium/winsys/drm/nouveau/nv04_surface.c b/src/gallium/winsys/drm/nouveau/nv04_surface.c
index 1178620..68338eb 100644
--- a/src/gallium/winsys/drm/nouveau/nv04_surface.c
+++ b/src/gallium/winsys/drm/nouveau/nv04_surface.c
@@ -84,12 +84,15 @@ nv04_scaled_image_format(enum pipe_format format)
 
 static void
 nv04_surface_copy_swizzle(struct nouveau_context *nv, unsigned dx, unsigned dy,
-		       unsigned sx, unsigned sy, unsigned w, unsigned h)
+                          unsigned sx, unsigned sy, unsigned w, unsigned h)
 {
 	struct nouveau_channel *chan = nv->nvc->channel;
 	struct pipe_surface *dst = nv->surf_dst;
 	struct pipe_surface *src = nv->surf_src;
 
+	/* POT or GTFO */
+	assert(!(w & (w - 1)) && !(h & (h - 1)));
+
 	BEGIN_RING(chan, nv->nvc->NvSwzSurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1);
 	OUT_RELOCo(chan, nouveau_buffer(dst->buffer)->bo,
 	                 NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);




More information about the mesa-commit mailing list