amd/addrlib: update to latest version
[mesa.git] / src / amd / addrlib / core / addrlib1.cpp
index 809bca23914bc331f887dc5a41c1f740d8b1f193..c796a63436c71969ddcdb58e6086ffe288b1d466 100644 (file)
@@ -259,10 +259,9 @@ ADDR_E_RETURNCODE Lib::ComputeSurfaceInfo(
             // Also Mip 1+ needs an element pitch of 32 bits so we do not need this workaround
             // but we use this flag to skip RestoreSurfaceInfo below
 
-            if ((elemMode == ADDR_EXPANDED) &&
-                (expandX > 1))
+            if ((elemMode == ADDR_EXPANDED) && (expandX > 1))
             {
-                ADDR_ASSERT(localIn.tileMode == ADDR_TM_LINEAR_ALIGNED || localIn.height == 1);
+                ADDR_ASSERT(IsLinear(localIn.tileMode));
             }
 
             GetElemLib()->AdjustSurfaceInfo(elemMode,
@@ -336,6 +335,8 @@ ADDR_E_RETURNCODE Lib::ComputeSurfaceInfo(
 
         if (returnCode == ADDR_OK)
         {
+            localIn.flags.dccPipeWorkaround = localIn.flags.dccCompatible;
+
             if (localIn.tileMode == ADDR_TM_UNKNOWN)
             {
                 // HWL layer may override tile mode if necessary
@@ -1280,36 +1281,54 @@ ADDR_E_RETURNCODE Lib::ComputeHtileInfo(
 
         if (returnCode == ADDR_OK)
         {
-            pOut->bpp = ComputeHtileInfo(pIn->flags,
-                                         pIn->pitch,
-                                         pIn->height,
-                                         pIn->numSlices,
-                                         pIn->isLinear,
-                                         isWidth8,
-                                         isHeight8,
-                                         pIn->pTileInfo,
-                                         &pOut->pitch,
-                                         &pOut->height,
-                                         &pOut->htileBytes,
-                                         &pOut->macroWidth,
-                                         &pOut->macroHeight,
-                                         &pOut->sliceSize,
-                                         &pOut->baseAlign);
-
-            if (pIn->flags.tcCompatible && (pIn->numSlices > 1))
+            if (pIn->flags.tcCompatible)
             {
-                pOut->sliceSize = pIn->pitch * pIn->height * 4 / (8 * 8);
+                const UINT_32 sliceSize = pIn->pitch * pIn->height * 4 / (8 * 8);
+                const UINT_32 align     = HwlGetPipes(pIn->pTileInfo) * pIn->pTileInfo->banks * m_pipeInterleaveBytes;
 
-                const UINT_32 align = HwlGetPipes(pIn->pTileInfo) * pIn->pTileInfo->banks * m_pipeInterleaveBytes;
-
-                if ((pOut->sliceSize % align) == 0)
+                if (pIn->numSlices > 1)
                 {
-                    pOut->sliceInterleaved = FALSE;
+                    const UINT_32 surfBytes = (sliceSize * pIn->numSlices);
+
+                    pOut->sliceSize        = sliceSize;
+                    pOut->htileBytes       = pIn->flags.skipTcCompatSizeAlign ?
+                                             surfBytes : PowTwoAlign(surfBytes, align);
+                    pOut->sliceInterleaved = ((sliceSize % align) != 0) ? TRUE : FALSE;
                 }
                 else
                 {
-                    pOut->sliceInterleaved = TRUE;
+                    pOut->sliceSize        = pIn->flags.skipTcCompatSizeAlign ?
+                                             sliceSize : PowTwoAlign(sliceSize, align);
+                    pOut->htileBytes       = pOut->sliceSize;
+                    pOut->sliceInterleaved = FALSE;
                 }
+
+                pOut->nextMipLevelCompressible = ((sliceSize % align) == 0) ? TRUE : FALSE;
+
+                pOut->pitch       = pIn->pitch;
+                pOut->height      = pIn->height;
+                pOut->baseAlign   = align;
+                pOut->macroWidth  = 0;
+                pOut->macroHeight = 0;
+                pOut->bpp         = 32;
+            }
+            else
+            {
+                pOut->bpp = ComputeHtileInfo(pIn->flags,
+                                             pIn->pitch,
+                                             pIn->height,
+                                             pIn->numSlices,
+                                             pIn->isLinear,
+                                             isWidth8,
+                                             isHeight8,
+                                             pIn->pTileInfo,
+                                             &pOut->pitch,
+                                             &pOut->height,
+                                             &pOut->htileBytes,
+                                             &pOut->macroWidth,
+                                             &pOut->macroHeight,
+                                             &pOut->sliceSize,
+                                             &pOut->baseAlign);
             }
         }
     }
@@ -2161,6 +2180,8 @@ VOID Lib::HwlComputeXmaskCoordFromAddr(
 {
     UINT_32 pipe;
     UINT_32 numPipes;
+    UINT_32 numGroupBits;
+    (void)numGroupBits;
     UINT_32 numPipeBits;
     UINT_32 macroTilePitch;
     UINT_32 macroTileHeight;
@@ -2203,6 +2224,7 @@ VOID Lib::HwlComputeXmaskCoordFromAddr(
     //
     // Compute the number of group and pipe bits.
     //
+    numGroupBits = Log2(m_pipeInterleaveBytes);
     numPipeBits  = Log2(numPipes);
 
     UINT_32 groupBits = 8 * m_pipeInterleaveBytes;
@@ -3503,6 +3525,10 @@ VOID Lib::ComputeMipLevel(
     ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn ///< [in,out] Input structure
     ) const
 {
+    // Check if HWL has handled
+    BOOL_32 hwlHandled = FALSE;
+    (void)hwlHandled;
+
     if (ElemLib::IsBlockCompressed(pIn->format))
     {
         if (pIn->mipLevel == 0)
@@ -3516,7 +3542,7 @@ VOID Lib::ComputeMipLevel(
         }
     }
 
-    HwlComputeMipLevel(pIn);
+    hwlHandled = HwlComputeMipLevel(pIn);
 }
 
 /**
@@ -3619,7 +3645,7 @@ VOID Lib::OptimizeTileMode(
                 {
                     tileMode = ADDR_TM_LINEAR_ALIGNED;
                 }
-                else if (IsMacroTiled(tileMode))
+                else if (IsMacroTiled(tileMode) && (pInOut->flags.tcCompatible == FALSE))
                 {
                     if (DegradeTo1D(width, height, macroWidthAlign, macroHeightAlign))
                     {
@@ -3876,41 +3902,33 @@ UINT_32 Lib::HwlGetPipes(
 *   @brief
 *       Get quad buffer stereo information
 *   @return
-*       TRUE if no error
+*       N/A
 ****************************************************************************************************
 */
-BOOL_32 Lib::ComputeQbStereoInfo(
+VOID Lib::ComputeQbStereoInfo(
     ADDR_COMPUTE_SURFACE_INFO_OUTPUT*       pOut    ///< [in,out] updated pOut+pStereoInfo
     ) const
 {
-    BOOL_32 success = FALSE;
-
-    if (pOut->pStereoInfo)
-    {
-        ADDR_ASSERT(pOut->bpp >= 8);
-        ADDR_ASSERT((pOut->surfSize % pOut->baseAlign) == 0);
-
-        // Save original height
-        pOut->pStereoInfo->eyeHeight = pOut->height;
+    ADDR_ASSERT(pOut->bpp >= 8);
+    ADDR_ASSERT((pOut->surfSize % pOut->baseAlign) == 0);
 
-        // Right offset
-        pOut->pStereoInfo->rightOffset = static_cast<UINT_32>(pOut->surfSize);
+    // Save original height
+    pOut->pStereoInfo->eyeHeight = pOut->height;
 
-        pOut->pStereoInfo->rightSwizzle = HwlComputeQbStereoRightSwizzle(pOut);
-        // Double height
-        pOut->height <<= 1;
-        pOut->pixelHeight <<= 1;
+    // Right offset
+    pOut->pStereoInfo->rightOffset = static_cast<UINT_32>(pOut->surfSize);
 
-        // Double size
-        pOut->surfSize <<= 1;
+    pOut->pStereoInfo->rightSwizzle = HwlComputeQbStereoRightSwizzle(pOut);
+    // Double height
+    pOut->height <<= 1;
+    pOut->pixelHeight <<= 1;
 
-        // Right start address meets the base align since it is guaranteed by AddrLib1
+    // Double size
+    pOut->surfSize <<= 1;
 
-        // 1D surface on SI may break this rule, but we can force it to meet by checking .qbStereo.
-        success = TRUE;
-    }
+    // Right start address meets the base align since it is guaranteed by AddrLib1
 
-    return success;
+    // 1D surface on SI may break this rule, but we can force it to meet by checking .qbStereo.
 }