Mesa (staging/20.1): ac/surface: don't recompute the DCC retile map for imported textures

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 17 21:17:57 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: 21b1f2975fe642f34e9e31340b4674e0c4e39f9b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=21b1f2975fe642f34e9e31340b4674e0c4e39f9b

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Tue Jun  9 02:08:21 2020 -0400

ac/surface: don't recompute the DCC retile map for imported textures

The retile map is not used in this case, and the retile map computation
takes 39% of CPU time when resizing a window.

This brings it down to 23%.

The dcc_retile_use_uint16 setting has to be derived from DCC sizes.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
(cherry picked from commit a1b9eb62f60290e2d5aab403b1954aca7773a1e4)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5422>

---

 .pick_status.json           |   2 +-
 src/amd/common/ac_surface.c | 122 ++++++++++++++++++++++----------------------
 2 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 4176833321d..514cb853957 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2416,7 +2416,7 @@
         "description": "ac/surface: don't recompute the DCC retile map for imported textures",
         "nominated": false,
         "nomination_type": null,
-        "resolution": 4,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c
index 288b8b71771..5ce1f834c52 100644
--- a/src/amd/common/ac_surface.c
+++ b/src/amd/common/ac_surface.c
@@ -1334,22 +1334,9 @@ static int gfx9_compute_miptree(ADDR_HANDLE addrlib,
 				surf->u.gfx9.display_dcc_pitch_max = dout.pitch - 1;
 				assert(surf->u.gfx9.display_dcc_size <= surf->dcc_size);
 
-				/* Compute address mapping from non-displayable to displayable DCC. */
-				ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT addrin = {};
-				addrin.size             = sizeof(addrin);
-				addrin.colorFlags.color = 1;
-				addrin.swizzleMode      = din.swizzleMode;
-				addrin.resourceType     = din.resourceType;
-				addrin.bpp              = din.bpp;
-				addrin.unalignedWidth   = din.unalignedWidth;
-				addrin.unalignedHeight  = din.unalignedHeight;
-				addrin.numSlices        = 1;
-				addrin.numMipLevels     = 1;
-				addrin.numFrags         = 1;
-
-				ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT addrout = {};
-				addrout.size = sizeof(addrout);
-
+				surf->u.gfx9.dcc_retile_use_uint16 =
+					surf->u.gfx9.display_dcc_size <= UINT16_MAX + 1 &&
+					surf->dcc_size <= UINT16_MAX + 1;
 				surf->u.gfx9.dcc_retile_num_elements =
 					DIV_ROUND_UP(in->width, dout.compressBlkWidth) *
 					DIV_ROUND_UP(in->height, dout.compressBlkHeight) * 2;
@@ -1357,53 +1344,66 @@ static int gfx9_compute_miptree(ADDR_HANDLE addrlib,
 				surf->u.gfx9.dcc_retile_num_elements =
 					align(surf->u.gfx9.dcc_retile_num_elements, 4);
 
-				surf->u.gfx9.dcc_retile_map =
-					malloc(surf->u.gfx9.dcc_retile_num_elements * 4);
-				if (!surf->u.gfx9.dcc_retile_map)
-					return ADDR_OUTOFMEMORY;
-
-				unsigned index = 0;
-				surf->u.gfx9.dcc_retile_use_uint16 = true;
-
-				for (unsigned y = 0; y < in->height; y += dout.compressBlkHeight) {
-					addrin.y = y;
-
-					for (unsigned x = 0; x < in->width; x += dout.compressBlkWidth) {
-						addrin.x = x;
-
-						/* Compute src DCC address */
-						addrin.dccKeyFlags.pipeAligned = surf->u.gfx9.dcc.pipe_aligned;
-						addrin.dccKeyFlags.rbAligned = surf->u.gfx9.dcc.rb_aligned;
-						addrout.addr = 0;
-
-						ret = Addr2ComputeDccAddrFromCoord(addrlib, &addrin, &addrout);
-						if (ret != ADDR_OK)
-							return ret;
-
-						surf->u.gfx9.dcc_retile_map[index * 2] = addrout.addr;
-						if (addrout.addr > UINT16_MAX)
-							surf->u.gfx9.dcc_retile_use_uint16 = false;
-
-						/* Compute dst DCC address */
-						addrin.dccKeyFlags.pipeAligned = 0;
-						addrin.dccKeyFlags.rbAligned = 0;
-						addrout.addr = 0;
-
-						ret = Addr2ComputeDccAddrFromCoord(addrlib, &addrin, &addrout);
-						if (ret != ADDR_OK)
-							return ret;
-
-						surf->u.gfx9.dcc_retile_map[index * 2 + 1] = addrout.addr;
-						if (addrout.addr > UINT16_MAX)
-							surf->u.gfx9.dcc_retile_use_uint16 = false;
-
-						assert(index * 2 + 1 < surf->u.gfx9.dcc_retile_num_elements);
-						index++;
+				if (!(surf->flags & RADEON_SURF_IMPORTED)) {
+					/* Compute address mapping from non-displayable to displayable DCC. */
+					ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT addrin = {};
+					addrin.size             = sizeof(addrin);
+					addrin.colorFlags.color = 1;
+					addrin.swizzleMode      = din.swizzleMode;
+					addrin.resourceType     = din.resourceType;
+					addrin.bpp              = din.bpp;
+					addrin.unalignedWidth   = din.unalignedWidth;
+					addrin.unalignedHeight  = din.unalignedHeight;
+					addrin.numSlices        = 1;
+					addrin.numMipLevels     = 1;
+					addrin.numFrags         = 1;
+
+					ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT addrout = {};
+					addrout.size = sizeof(addrout);
+
+					surf->u.gfx9.dcc_retile_map =
+						malloc(surf->u.gfx9.dcc_retile_num_elements * 4);
+					if (!surf->u.gfx9.dcc_retile_map)
+						return ADDR_OUTOFMEMORY;
+
+					unsigned index = 0;
+
+					for (unsigned y = 0; y < in->height; y += dout.compressBlkHeight) {
+						addrin.y = y;
+
+						for (unsigned x = 0; x < in->width; x += dout.compressBlkWidth) {
+							addrin.x = x;
+
+							/* Compute src DCC address */
+							addrin.dccKeyFlags.pipeAligned = surf->u.gfx9.dcc.pipe_aligned;
+							addrin.dccKeyFlags.rbAligned = surf->u.gfx9.dcc.rb_aligned;
+							addrout.addr = 0;
+
+							ret = Addr2ComputeDccAddrFromCoord(addrlib, &addrin, &addrout);
+							if (ret != ADDR_OK)
+								return ret;
+
+							surf->u.gfx9.dcc_retile_map[index * 2] = addrout.addr;
+
+							/* Compute dst DCC address */
+							addrin.dccKeyFlags.pipeAligned = 0;
+							addrin.dccKeyFlags.rbAligned = 0;
+							addrout.addr = 0;
+
+							ret = Addr2ComputeDccAddrFromCoord(addrlib, &addrin, &addrout);
+							if (ret != ADDR_OK)
+								return ret;
+
+							surf->u.gfx9.dcc_retile_map[index * 2 + 1] = addrout.addr;
+
+							assert(index * 2 + 1 < surf->u.gfx9.dcc_retile_num_elements);
+							index++;
+						}
 					}
+					/* Fill the remaining pairs with the last one (for the compute shader). */
+					for (unsigned i = index * 2; i < surf->u.gfx9.dcc_retile_num_elements; i++)
+						surf->u.gfx9.dcc_retile_map[i] = surf->u.gfx9.dcc_retile_map[i - 2];
 				}
-				/* Fill the remaining pairs with the last one (for the compute shader). */
-				for (unsigned i = index * 2; i < surf->u.gfx9.dcc_retile_num_elements; i++)
-					surf->u.gfx9.dcc_retile_map[i] = surf->u.gfx9.dcc_retile_map[i - 2];
 			}
 		}
 



More information about the mesa-commit mailing list