From c809e858326852f095cbfcb32db6f440548aedd5 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 6 Mar 2024 18:00:19 -0600 Subject: [PATCH] nil: Add a concept of width to tile sizes Part-of: --- src/nouveau/nil/nil_image.c | 10 +++++++++- src/nouveau/nil/nil_image.h | 4 +++- src/nouveau/nil/nil_image_tic.c | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/nouveau/nil/nil_image.c b/src/nouveau/nil/nil_image.c index ebc6b2081e0..46a621661c6 100644 --- a/src/nouveau/nil/nil_image.c +++ b/src/nouveau/nil/nil_image.c @@ -194,7 +194,7 @@ nil_tiling_extent_B(struct nil_tiling tiling) { if (tiling.is_tiled) { return (struct nil_extent4d) { - .w = NIL_GOB_WIDTH_B, /* Tiles are always 1 GOB wide */ + .w = NIL_GOB_WIDTH_B << tiling.x_log2, .h = NIL_GOB_HEIGHT(tiling.gob_height_8) << tiling.y_log2, .d = NIL_GOB_DEPTH << tiling.z_log2, .a = 1, @@ -215,6 +215,14 @@ nil_tiling_clamp(struct nil_tiling tiling, struct nil_extent4d extent_B) if (!tiling.is_tiled) return tiling; + const struct nil_extent4d tiling_extent_B = nil_tiling_extent_B(tiling); + + /* The moment the LOD is smaller than a tile, tiling.x_log2 goes to 0 */ + if (extent_B.w < tiling_extent_B.w || + extent_B.h < tiling_extent_B.h || + extent_B.d < tiling_extent_B.d) + tiling.x_log2 = 0; + const struct nil_extent4d extent_GOB = nil_extent4d_B_to_GOB(extent_B, tiling.gob_height_8); diff --git a/src/nouveau/nil/nil_image.h b/src/nouveau/nil/nil_image.h index ff627497225..0b72f3be577 100644 --- a/src/nouveau/nil/nil_image.h +++ b/src/nouveau/nil/nil_image.h @@ -106,10 +106,12 @@ nil_offset4d_px_to_el(struct nil_offset4d offset_px, struct nil_tiling { bool is_tiled:1; bool gob_height_8:1; /**< GOB height is 4 or 8 */ + uint8_t x_log2:3; /**< log2 of the Y tile dimension in GOBs */ uint8_t y_log2:3; /**< log2 of the Y tile dimension in GOBs */ uint8_t z_log2:3; /**< log2 of the Z tile dimension in GOBs */ + uint8_t pad:5; }; -static_assert(sizeof(struct nil_tiling) == 1, "This struct has no holes"); +static_assert(sizeof(struct nil_tiling) == 2, "This struct has no holes"); struct nil_image_init_info { enum nil_image_dim dim; diff --git a/src/nouveau/nil/nil_image_tic.c b/src/nouveau/nil/nil_image_tic.c index 302de1823d3..6a1b356c910 100644 --- a/src/nouveau/nil/nil_image_tic.c +++ b/src/nouveau/nil/nil_image_tic.c @@ -330,6 +330,7 @@ nv9097_nil_image_fill_tic(const struct nil_image *image, TH_NV9097_SET_E(th, 2, MEMORY_LAYOUT, BLOCKLINEAR); assert(tiling->gob_height_8); + assert(tiling->x_log2 == 0); TH_NV9097_SET_E(th, 2, GOBS_PER_BLOCK_WIDTH, ONE_GOB); TH_NV9097_SET_U(th, 2, GOBS_PER_BLOCK_HEIGHT, tiling->y_log2); TH_NV9097_SET_U(th, 2, GOBS_PER_BLOCK_DEPTH, tiling->z_log2); @@ -421,6 +422,7 @@ nvb097_nil_image_fill_tic(const struct nil_image *image, TH_NVB097_SET_E(th, BL, GOBS_PER_BLOCK_WIDTH, ONE_GOB); TH_NVB097_SET_U(th, BL, GOBS_PER_BLOCK_HEIGHT, tiling->y_log2); TH_NVB097_SET_U(th, BL, GOBS_PER_BLOCK_DEPTH, tiling->z_log2); + TH_NVB097_SET_U(th, BL, TILE_WIDTH_IN_GOBS, tiling->x_log2); TH_NVB097_SET_U(th, BL, TEXTURE_TYPE, pipe_to_nv_texture_type(view->type)); } else {