Mesa (master): freedreno/a6xx: fix 3d texture layout

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Dec 22 20:32:09 UTC 2018


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

Author: Rob Clark <robdclark at gmail.com>
Date:   Tue Dec 18 10:34:23 2018 -0500

freedreno/a6xx: fix 3d texture layout

Maybe not 100% perfect, but seems to be a pretty good approximation of
that.

Signed-off-by: Rob Clark <robdclark at gmail.com>

---

 src/gallium/drivers/freedreno/a6xx/fd6_resource.c  | 14 +++++++++++++-
 src/gallium/drivers/freedreno/a6xx/fd6_texture.c   |  2 +-
 src/gallium/drivers/freedreno/freedreno_resource.h |  2 +-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c
index 4f5ab90266..fb24d230c4 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c
@@ -73,7 +73,19 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
 			pitchalign = tile_alignment[rsc->cpp].pitchalign;
 			aligned_height = align(aligned_height, heightalign);
 		} else {
-			pitchalign = 64;
+			if (prsc->target == PIPE_TEXTURE_3D) {
+				unsigned a;
+				if (width >= 64) {
+					a = util_next_power_of_two(MAX2(width, height));
+				} else {
+					a = 16;
+				}
+
+				pitchalign = align(a, 64);
+				aligned_height = align(aligned_height, a);
+			} else {
+				pitchalign = 64;
+			}
 
 			/* The blits used for mem<->gmem work at a granularity of
 			 * 32x32, which can cause faults due to over-fetch on the
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c
index 373a7937e4..b9121523b7 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c
@@ -325,12 +325,12 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 		break;
 	case PIPE_TEXTURE_3D:
 		so->texconst3 =
+			A6XX_TEX_CONST_3_MIN_LAYERSZ(rsc->slices[prsc->last_level].size0) |
 			A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->slices[lvl].size0);
 		so->texconst5 =
 			A6XX_TEX_CONST_5_DEPTH(u_minify(prsc->depth0, lvl));
 		break;
 	default:
-		so->texconst3 = 0x00000000;
 		break;
 	}
 
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h
index 09abb512d7..8370824485 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.h
+++ b/src/gallium/drivers/freedreno/freedreno_resource.h
@@ -41,7 +41,7 @@
  * programmed with the start address of each mipmap level, and hw
  * derives the layer offset within the level.
  *
- * Texture Layout on a4xx:
+ * Texture Layout on a4xx+:
  *
  * For cubemap and 2d array, each layer contains all of it's mipmap
  * levels (layer_first layout).




More information about the mesa-commit mailing list