[Mesa-dev] [PATCH 053/140] amd/addrlib: Adjust slie size after pitch and actual height adjustment

Marek Olšák maraeo at gmail.com
Mon Mar 20 22:43:03 UTC 2017


From: Frans Gu <frans.gu at amd.com>

---
 src/amd/addrlib/r800/egbaddrlib.cpp | 57 ++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 26 deletions(-)

diff --git a/src/amd/addrlib/r800/egbaddrlib.cpp b/src/amd/addrlib/r800/egbaddrlib.cpp
index fe98d2f..0cd27ad 100644
--- a/src/amd/addrlib/r800/egbaddrlib.cpp
+++ b/src/amd/addrlib/r800/egbaddrlib.cpp
@@ -278,52 +278,57 @@ BOOL_32 EgBasedLib::ComputeSurfaceInfoLinear(
 
     logicalSliceSize = HwlGetSizeAdjustmentLinear(pIn->tileMode,
                                                   pIn->bpp,
                                                   numSamples,
                                                   pOut->baseAlign,
                                                   pOut->pitchAlign,
                                                   &expPitch,
                                                   &expHeight,
                                                   &pOut->heightAlign);
 
-    if (pIn->pitchAlign != 0)
+    if ((pIn->pitchAlign != 0) || (pIn->heightAlign != 0))
     {
-       ADDR_ASSERT((pIn->pitchAlign % pOut->pitchAlign) == 0);
-       pOut->pitchAlign = pIn->pitchAlign;
-
-        if (IsPow2(pOut->pitchAlign))
-        {
-            expPitch = PowTwoAlign(expPitch, pOut->pitchAlign);
-        }
-        else
+        if (pIn->pitchAlign != 0)
         {
-            expPitch += pOut->pitchAlign - 1;
-            expPitch /= pOut->pitchAlign;
-            expPitch *= pOut->pitchAlign;
-        }
-    }
+           ADDR_ASSERT((pIn->pitchAlign % pOut->pitchAlign) == 0);
+           pOut->pitchAlign = pIn->pitchAlign;
 
-    if (pIn->heightAlign != 0)
-    {
-       ADDR_ASSERT((pIn->heightAlign % pOut->heightAlign) == 0);
-       pOut->heightAlign = pIn->heightAlign;
-
-        if (IsPow2(pOut->heightAlign))
-        {
-            expHeight = PowTwoAlign(expHeight, pOut->heightAlign);
+            if (IsPow2(pOut->pitchAlign))
+            {
+                expPitch = PowTwoAlign(expPitch, pOut->pitchAlign);
+            }
+            else
+            {
+                expPitch += pOut->pitchAlign - 1;
+                expPitch /= pOut->pitchAlign;
+                expPitch *= pOut->pitchAlign;
+            }
         }
-        else
+
+        if (pIn->heightAlign != 0)
         {
-            expHeight += pOut->heightAlign - 1;
-            expHeight /= pOut->heightAlign;
-            expHeight *= pOut->heightAlign;
+           ADDR_ASSERT((pIn->heightAlign % pOut->heightAlign) == 0);
+           pOut->heightAlign = pIn->heightAlign;
+
+            if (IsPow2(pOut->heightAlign))
+            {
+                expHeight = PowTwoAlign(expHeight, pOut->heightAlign);
+            }
+            else
+            {
+                expHeight += pOut->heightAlign - 1;
+                expHeight /= pOut->heightAlign;
+                expHeight *= pOut->heightAlign;
+            }
         }
+
+        logicalSliceSize = BITS_TO_BYTES(expPitch * expHeight * pIn->bpp);
     }
 
     pOut->pitch = expPitch;
     pOut->height = expHeight;
     pOut->depth = expNumSlices;
 
     pOut->surfSize = logicalSliceSize * expNumSlices;
 
     pOut->tileMode = pIn->tileMode;
 
-- 
2.7.4



More information about the mesa-dev mailing list