amd/addrlib: Adjust slie size after pitch and actual height adjustment
authorFrans Gu <frans.gu@amd.com>
Thu, 7 Jul 2016 11:08:16 +0000 (07:08 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 30 Mar 2017 12:44:33 +0000 (14:44 +0200)
src/amd/addrlib/r800/egbaddrlib.cpp

index fe98d2ff25d15e32a5128ace19222fa93b19e04e..0cd27ada070412cc463e94de0b9c3ab8c407b40f 100644 (file)
@@ -285,38 +285,43 @@ BOOL_32 EgBasedLib::ComputeSurfaceInfoLinear(
                                                   &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;