From 064d3c36f871cb74e3ade65e7d27b792ec8e085a Mon Sep 17 00:00:00 2001
From: Alex Deucher <alexdeucher@gmail.com>
Date: Wed, 22 Jun 2011 10:43:54 -0400
Subject: [PATCH 5/5] r600g: make sure we allocate htile for fbo case

Based on a similar patch from Pierre-Eric Pelloux-Prayer.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
---
 src/gallium/drivers/r600/r600_texture.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index 927eb5d..9f6574a 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -265,9 +265,13 @@ static void r600_setup_miptree(struct pipe_screen *screen,
 		else
 			size = layer_size * ptex->array_size;
 
-		/* evergreen stores depth and stencil separately */
-		if ((chipc >= EVERGREEN) && util_format_is_depth_or_stencil(ptex->format))
-			extra_size = align(extra_size + (nblocksx * nblocksy * 1), base_align);
+		if (util_format_is_depth_or_stencil(ptex->format)) {
+			/* evergreen stores depth and stencil separately */
+			if (chipc >= EVERGREEN)
+				extra_size = align(extra_size + (nblocksx * nblocksy * 1), base_align);
+			/* add space for htile */
+			extra_size = align(extra_size + (((nblocksx * nblocksy) / (4 * 4)) * 4), base_align);
+		}
 
 		/* align base image and start of miptree */
 		if ((i == 0) || (i == 1))
-- 
1.7.1.1

