[Mesa-dev] [PATCH 6/6] radeonsi: simplify si_num_banks function

Marek Olšák maraeo at gmail.com
Mon Aug 18 14:52:58 PDT 2014


From: Marek Olšák <marek.olsak at amd.com>

This makes it easier to use.
---
 src/gallium/drivers/radeonsi/si_dma.c   |  6 ++----
 src/gallium/drivers/radeonsi/si_state.c | 19 ++++++++++---------
 src/gallium/drivers/radeonsi/si_state.h |  3 +--
 3 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_dma.c b/src/gallium/drivers/radeonsi/si_dma.c
index e908746..a69f533 100644
--- a/src/gallium/drivers/radeonsi/si_dma.c
+++ b/src/gallium/drivers/radeonsi/si_dma.c
@@ -173,8 +173,7 @@ static void si_dma_copy_tile(struct si_context *ctx,
 		tile_split = cik_tile_split(rsrc->surface.tile_split);
 		tile_mode_index = si_tile_mode_index(rsrc, src_level,
 						     util_format_has_stencil(util_format_description(src->format)));
-		nbanks = si_num_banks(sscreen, rsrc->surface.bpe, rsrc->surface.tile_split,
-				      tile_mode_index);
+		nbanks = si_num_banks(sscreen, rsrc);
 		base += rsrc->resource.gpu_address;
 		addr += rdst->resource.gpu_address;
 	} else {
@@ -202,8 +201,7 @@ static void si_dma_copy_tile(struct si_context *ctx,
 		tile_split = cik_tile_split(rdst->surface.tile_split);
 		tile_mode_index = si_tile_mode_index(rdst, dst_level,
 						     util_format_has_stencil(util_format_description(dst->format)));
-		nbanks = si_num_banks(sscreen, rdst->surface.bpe, rdst->surface.tile_split,
-				      tile_mode_index);
+		nbanks = si_num_banks(sscreen, rdst);
 		base += rdst->resource.gpu_address;
 		addr += rsrc->resource.gpu_address;
 	}
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index fc928f3..4ab2b8b 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -47,15 +47,14 @@ static void si_init_atom(struct r600_atom *atom, struct r600_atom **list_elem,
 	*list_elem = atom;
 }
 
-uint32_t si_num_banks(struct si_screen *sscreen, unsigned bpe, unsigned tile_split,
-		      unsigned tile_mode_index)
+uint32_t si_num_banks(struct si_screen *sscreen, struct r600_texture *tex)
 {
-	if ((sscreen->b.chip_class == CIK) &&
+	if (sscreen->b.chip_class == CIK &&
 	    sscreen->b.info.cik_macrotile_mode_array_valid) {
 		unsigned index, tileb;
 
-		tileb = 8 * 8 * bpe;
-		tileb = MIN2(tile_split, tileb);
+		tileb = 8 * 8 * tex->surface.bpe;
+		tileb = MIN2(tex->surface.tile_split, tileb);
 
 		for (index = 0; tileb > 64; index++) {
 			tileb >>= 1;
@@ -65,11 +64,14 @@ uint32_t si_num_banks(struct si_screen *sscreen, unsigned bpe, unsigned tile_spl
 		return (sscreen->b.info.cik_macrotile_mode_array[index] >> 6) & 0x3;
 	}
 
-	if ((sscreen->b.chip_class == SI) &&
+	if (sscreen->b.chip_class == SI &&
 	    sscreen->b.info.si_tile_mode_array_valid) {
+		/* Don't use stencil_tiling_index, because num_banks is always
+		 * read from the depth mode. */
+		unsigned tile_mode_index = tex->surface.tiling_index[0];
 		assert(tile_mode_index < 32);
 
-		return (sscreen->b.info.si_tile_mode_array[tile_mode_index] >> 20) & 0x3;
+		return G_009910_NUM_BANKS(sscreen->b.info.si_tile_mode_array[tile_mode_index]);
 	}
 
 	/* The old way. */
@@ -1820,8 +1822,7 @@ static void si_init_depth_surface(struct si_context *sctx,
 		macro_aspect = cik_macro_tile_aspect(macro_aspect);
 		bankw = cik_bank_wh(bankw);
 		bankh = cik_bank_wh(bankh);
-		nbanks = si_num_banks(sscreen, rtex->surface.bpe, rtex->surface.tile_split,
-				      ~0);
+		nbanks = si_num_banks(sscreen, rtex);
 		tile_mode_index = si_tile_mode_index(rtex, level, false);
 		pipe_config = cik_db_pipe_config(sscreen, tile_mode_index);
 
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index ce18a27..7362ad1 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -263,8 +263,7 @@ unsigned cik_bank_wh(unsigned bankwh);
 unsigned cik_db_pipe_config(struct si_screen *sscreen, unsigned tile_mode);
 unsigned cik_macro_tile_aspect(unsigned macro_tile_aspect);
 unsigned cik_tile_split(unsigned tile_split);
-uint32_t si_num_banks(struct si_screen *sscreen, unsigned bpe, unsigned tile_split,
-		      unsigned tile_mode_index);
+uint32_t si_num_banks(struct si_screen *sscreen, struct r600_texture *tex);
 unsigned si_tile_mode_index(struct r600_texture *rtex, unsigned level, bool stencil);
 
 /* si_state_draw.c */
-- 
1.9.1



More information about the mesa-dev mailing list