ac/surface/gfx9: let addrlib choose the preferred swizzle kind
[mesa.git] / src / amd / addrlib / r800 / siaddrlib.cpp
index 4822d77a4c2e19a1208ccc099268c0d94a0ae0ce..bc009f5aff066d9410a68a722bf859e46009a938 100644 (file)
  */
 
 /**
-***************************************************************************************************
+****************************************************************************************************
 * @file  siaddrlib.cpp
-* @brief Contains the implementation for the SiAddrLib class.
-***************************************************************************************************
+* @brief Contains the implementation for the SiLib class.
+****************************************************************************************************
 */
 
 #include "siaddrlib.h"
-
 #include "si_gb_reg.h"
 
-#include "si_ci_vi_merged_enum.h"
-
-#if BRAHMA_BUILD
-#include "amdgpu_id.h"
-#else
-#include "si_id.h"
-#endif
+#include "amdgpu_asic_addr.h"
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+namespace Addr
+{
 
 /**
-***************************************************************************************************
-*   AddrSIHwlInit
+****************************************************************************************************
+*   SiHwlInit
 *
 *   @brief
-*       Creates an SiAddrLib object.
+*       Creates an SiLib object.
 *
 *   @return
-*       Returns an SiAddrLib object pointer.
-***************************************************************************************************
+*       Returns an SiLib object pointer.
+****************************************************************************************************
 */
-AddrLib* AddrSIHwlInit(const AddrClient* pClient)
+Lib* SiHwlInit(const Client* pClient)
 {
-    return SiAddrLib::CreateObj(pClient);
+    return V1::SiLib::CreateObj(pClient);
 }
 
+namespace V1
+{
+
+// We don't support MSAA for equation
+const BOOL_32 SiLib::m_EquationSupport[SiLib::TileTableSize][SiLib::MaxNumElementBytes] =
+{
+    {TRUE,  TRUE,  TRUE,  FALSE, FALSE},    //  0, non-AA compressed depth or any stencil
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    //  1, 2xAA/4xAA compressed depth with or without stencil
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    //  2, 8xAA compressed depth with or without stencil
+    {FALSE, TRUE,  FALSE, FALSE, FALSE},    //  3, 16 bpp depth PRT (non-MSAA), don't support uncompressed depth
+    {TRUE,  TRUE,  TRUE,  FALSE, FALSE},    //  4, 1D depth
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    //  5, 16 bpp depth PRT (4xMSAA)
+    {FALSE, FALSE, TRUE,  FALSE, FALSE},    //  6, 32 bpp depth PRT (non-MSAA)
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    //  7, 32 bpp depth PRT (4xMSAA)
+    {TRUE,  TRUE,  TRUE,  TRUE,  TRUE },    //  8, Linear
+    {TRUE,  TRUE,  TRUE,  TRUE,  TRUE },    //  9, 1D display
+    {TRUE,  FALSE, FALSE, FALSE, FALSE},    // 10, 8 bpp color (displayable)
+    {FALSE, TRUE,  FALSE, FALSE, FALSE},    // 11, 16 bpp color (displayable)
+    {FALSE, FALSE, TRUE,  TRUE,  FALSE},    // 12, 32/64 bpp color (displayable)
+    {TRUE,  TRUE,  TRUE,  TRUE,  TRUE },    // 13, 1D thin
+    {TRUE,  FALSE, FALSE, FALSE, FALSE},    // 14, 8 bpp color non-displayable
+    {FALSE, TRUE,  FALSE, FALSE, FALSE},    // 15, 16 bpp color non-displayable
+    {FALSE, FALSE, TRUE,  FALSE, FALSE},    // 16, 32 bpp color non-displayable
+    {FALSE, FALSE, FALSE, TRUE,  TRUE },    // 17, 64/128 bpp color non-displayable
+    {TRUE,  TRUE,  TRUE,  TRUE,  TRUE },    // 18, 1D THICK
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    // 19, 2D XTHICK
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    // 20, 2D THICK
+    {TRUE,  FALSE, FALSE, FALSE, FALSE},    // 21, 8 bpp 2D PRTs (non-MSAA)
+    {FALSE, TRUE,  FALSE, FALSE, FALSE},    // 22, 16 bpp 2D PRTs (non-MSAA)
+    {FALSE, FALSE, TRUE,  FALSE, FALSE},    // 23, 32 bpp 2D PRTs (non-MSAA)
+    {FALSE, FALSE, FALSE, TRUE,  FALSE},    // 24, 64 bpp 2D PRTs (non-MSAA)
+    {FALSE, FALSE, FALSE, FALSE, TRUE },    // 25, 128bpp 2D PRTs (non-MSAA)
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    // 26, none
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    // 27, none
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    // 28, none
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    // 29, none
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    // 30, 64bpp 2D PRTs (4xMSAA)
+    {FALSE, FALSE, FALSE, FALSE, FALSE},    // 31, none
+};
+
 /**
-***************************************************************************************************
-*   SiAddrLib::SiAddrLib
+****************************************************************************************************
+*   SiLib::SiLib
 *
 *   @brief
 *       Constructor
 *
-***************************************************************************************************
+****************************************************************************************************
 */
-SiAddrLib::SiAddrLib(const AddrClient* pClient) :
-    EgBasedAddrLib(pClient),
+SiLib::SiLib(const Client* pClient)
+    :
+    EgBasedLib(pClient),
     m_noOfEntries(0),
     m_numEquations(0)
 {
@@ -81,28 +117,28 @@ SiAddrLib::SiAddrLib(const AddrClient* pClient) :
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::~SiAddrLib
+****************************************************************************************************
+*   SiLib::~SiLib
 *
 *   @brief
 *       Destructor
-***************************************************************************************************
+****************************************************************************************************
 */
-SiAddrLib::~SiAddrLib()
+SiLib::~SiLib()
 {
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlGetPipes
+****************************************************************************************************
+*   SiLib::HwlGetPipes
 *
 *   @brief
 *       Get number pipes
 *   @return
 *       num pipes
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::HwlGetPipes(
+UINT_32 SiLib::HwlGetPipes(
     const ADDR_TILEINFO* pTileInfo    ///< [in] Tile info
     ) const
 {
@@ -122,15 +158,15 @@ UINT_32 SiAddrLib::HwlGetPipes(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::GetPipePerSurf
+****************************************************************************************************
+*   SiLib::GetPipePerSurf
 *   @brief
 *       get pipe num base on inputing tileinfo->pipeconfig
 *   @return
 *       pipe number
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::GetPipePerSurf(
+UINT_32 SiLib::GetPipePerSurf(
     AddrPipeCfg pipeConfig   ///< [in] pipe config
     ) const
 {
@@ -168,17 +204,17 @@ UINT_32 SiAddrLib::GetPipePerSurf(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::ComputeBankEquation
+****************************************************************************************************
+*   SiLib::ComputeBankEquation
 *
 *   @brief
 *       Compute bank equation
 *
 *   @return
 *       If equation can be computed
-***************************************************************************************************
+****************************************************************************************************
 */
-ADDR_E_RETURNCODE SiAddrLib::ComputeBankEquation(
+ADDR_E_RETURNCODE SiLib::ComputeBankEquation(
     UINT_32         log2BytesPP,    ///< [in] log2 of bytes per pixel
     UINT_32         threshX,        ///< [in] threshold for x channel
     UINT_32         threshY,        ///< [in] threshold for y channel
@@ -213,37 +249,132 @@ ADDR_E_RETURNCODE SiAddrLib::ComputeBankEquation(
     switch (pTileInfo->banks)
     {
         case 16:
-            pEquation->addr[0] = y6;
-            pEquation->xor1[0] = x3;
-            pEquation->addr[1] = y5;
-            pEquation->xor1[1] = y6;
-            pEquation->xor2[1] = x4;
-            pEquation->addr[2] = y4;
-            pEquation->xor1[2] = x5;
-            pEquation->addr[3] = y3;
-            pEquation->xor1[3] = x6;
+            if (pTileInfo->macroAspectRatio == 1)
+            {
+                pEquation->addr[0] = y6;
+                pEquation->xor1[0] = x3;
+                pEquation->addr[1] = y5;
+                pEquation->xor1[1] = y6;
+                pEquation->xor2[1] = x4;
+                pEquation->addr[2] = y4;
+                pEquation->xor1[2] = x5;
+                pEquation->addr[3] = y3;
+                pEquation->xor1[3] = x6;
+            }
+            else if (pTileInfo->macroAspectRatio == 2)
+            {
+                pEquation->addr[0] = x3;
+                pEquation->xor1[0] = y6;
+                pEquation->addr[1] = y5;
+                pEquation->xor1[1] = y6;
+                pEquation->xor2[1] = x4;
+                pEquation->addr[2] = y4;
+                pEquation->xor1[2] = x5;
+                pEquation->addr[3] = y3;
+                pEquation->xor1[3] = x6;
+            }
+            else if (pTileInfo->macroAspectRatio == 4)
+            {
+                pEquation->addr[0] = x3;
+                pEquation->xor1[0] = y6;
+                pEquation->addr[1] = x4;
+                pEquation->xor1[1] = y5;
+                pEquation->xor2[1] = y6;
+                pEquation->addr[2] = y4;
+                pEquation->xor1[2] = x5;
+                pEquation->addr[3] = y3;
+                pEquation->xor1[3] = x6;
+            }
+            else if (pTileInfo->macroAspectRatio == 8)
+            {
+                pEquation->addr[0] = x3;
+                pEquation->xor1[0] = y6;
+                pEquation->addr[1] = x4;
+                pEquation->xor1[1] = y5;
+                pEquation->xor2[1] = y6;
+                pEquation->addr[2] = x5;
+                pEquation->xor1[2] = y4;
+                pEquation->addr[3] = y3;
+                pEquation->xor1[3] = x6;
+            }
+            else
+            {
+                ADDR_ASSERT_ALWAYS();
+            }
             pEquation->numBits = 4;
             break;
         case 8:
-            pEquation->addr[0] = y5;
-            pEquation->xor1[0] = x3;
-            pEquation->addr[1] = y4;
-            pEquation->xor1[1] = y5;
-            pEquation->xor2[1] = x4;
-            pEquation->addr[2] = y3;
-            pEquation->xor1[2] = x5;
+            if (pTileInfo->macroAspectRatio == 1)
+            {
+                pEquation->addr[0] = y5;
+                pEquation->xor1[0] = x3;
+                pEquation->addr[1] = y4;
+                pEquation->xor1[1] = y5;
+                pEquation->xor2[1] = x4;
+                pEquation->addr[2] = y3;
+                pEquation->xor1[2] = x5;
+            }
+            else if (pTileInfo->macroAspectRatio == 2)
+            {
+                pEquation->addr[0] = x3;
+                pEquation->xor1[0] = y5;
+                pEquation->addr[1] = y4;
+                pEquation->xor1[1] = y5;
+                pEquation->xor2[1] = x4;
+                pEquation->addr[2] = y3;
+                pEquation->xor1[2] = x5;
+            }
+            else if (pTileInfo->macroAspectRatio == 4)
+            {
+                pEquation->addr[0] = x3;
+                pEquation->xor1[0] = y5;
+                pEquation->addr[1] = x4;
+                pEquation->xor1[1] = y4;
+                pEquation->xor2[1] = y5;
+                pEquation->addr[2] = y3;
+                pEquation->xor1[2] = x5;
+            }
+            else
+            {
+                ADDR_ASSERT_ALWAYS();
+            }
             pEquation->numBits = 3;
             break;
         case 4:
-            pEquation->addr[0] = y4;
-            pEquation->xor1[0] = x3;
-            pEquation->addr[1] = y3;
-            pEquation->xor1[1] = x4;
+            if (pTileInfo->macroAspectRatio == 1)
+            {
+                pEquation->addr[0] = y4;
+                pEquation->xor1[0] = x3;
+                pEquation->addr[1] = y3;
+                pEquation->xor1[1] = x4;
+            }
+            else if (pTileInfo->macroAspectRatio == 2)
+            {
+                pEquation->addr[0] = x3;
+                pEquation->xor1[0] = y4;
+                pEquation->addr[1] = y3;
+                pEquation->xor1[1] = x4;
+            }
+            else
+            {
+                pEquation->addr[0] = x3;
+                pEquation->xor1[0] = y4;
+                pEquation->addr[1] = x4;
+                pEquation->xor1[1] = y3;
+            }
             pEquation->numBits = 2;
             break;
         case 2:
-            pEquation->addr[0] = y3;
-            pEquation->xor1[0] = x3;
+            if (pTileInfo->macroAspectRatio == 1)
+            {
+                pEquation->addr[0] = y3;
+                pEquation->xor1[0] = x3;
+            }
+            else
+            {
+                pEquation->addr[0] = x3;
+                pEquation->xor1[0] = y3;
+            }
             pEquation->numBits = 1;
             break;
         default:
@@ -302,17 +433,17 @@ ADDR_E_RETURNCODE SiAddrLib::ComputeBankEquation(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::ComputePipeEquation
+****************************************************************************************************
+*   SiLib::ComputePipeEquation
 *
 *   @brief
 *       Compute pipe equation
 *
 *   @return
 *       If equation can be computed
-***************************************************************************************************
+****************************************************************************************************
 */
-ADDR_E_RETURNCODE SiAddrLib::ComputePipeEquation(
+ADDR_E_RETURNCODE SiLib::ComputePipeEquation(
     UINT_32        log2BytesPP, ///< [in] Log2 of bytes per pixel
     UINT_32        threshX,     ///< [in] Threshold for X channel
     UINT_32        threshY,     ///< [in] Threshold for Y channel
@@ -480,6 +611,29 @@ ADDR_E_RETURNCODE SiAddrLib::ComputePipeEquation(
             break;
     }
 
+    if (m_settings.isVegaM && (pEquation->numBits == 4))
+    {
+        ADDR_CHANNEL_SETTING addeMsb = pAddr[0];
+        ADDR_CHANNEL_SETTING xor1Msb = pXor1[0];
+        ADDR_CHANNEL_SETTING xor2Msb = pXor2[0];
+
+        pAddr[0] = pAddr[1];
+        pXor1[0] = pXor1[1];
+        pXor2[0] = pXor2[1];
+
+        pAddr[1] = pAddr[2];
+        pXor1[1] = pXor1[2];
+        pXor2[1] = pXor2[2];
+
+        pAddr[2] = pAddr[3];
+        pXor1[2] = pXor1[3];
+        pXor2[2] = pXor2[3];
+
+        pAddr[3] = addeMsb;
+        pXor1[3] = xor1Msb;
+        pXor2[3] = xor2Msb;
+    }
+
     for (UINT_32 i = 0; i < pEquation->numBits; i++)
     {
         if (pAddr[i].value == 0)
@@ -500,16 +654,16 @@ ADDR_E_RETURNCODE SiAddrLib::ComputePipeEquation(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::ComputePipeFromCoord
+****************************************************************************************************
+*   SiLib::ComputePipeFromCoord
 *
 *   @brief
 *       Compute pipe number from coordinates
 *   @return
 *       Pipe number
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::ComputePipeFromCoord(
+UINT_32 SiLib::ComputePipeFromCoord(
     UINT_32         x,              ///< [in] x coordinate
     UINT_32         y,              ///< [in] y coordinate
     UINT_32         slice,          ///< [in] slice index
@@ -623,6 +777,16 @@ UINT_32 SiAddrLib::ComputePipeFromCoord(
             ADDR_UNHANDLED_CASE();
             break;
     }
+
+    if (m_settings.isVegaM && (numPipes == 16))
+    {
+        UINT_32 pipeMsb = pipeBit0;
+        pipeBit0 = pipeBit1;
+        pipeBit1 = pipeBit2;
+        pipeBit2 = pipeBit3;
+        pipeBit3 = pipeMsb;
+    }
+
     pipe = pipeBit0 | (pipeBit1 << 1) | (pipeBit2 << 2) | (pipeBit3 << 3);
 
     UINT_32 microTileThickness = Thickness(tileMode);
@@ -651,16 +815,16 @@ UINT_32 SiAddrLib::ComputePipeFromCoord(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::ComputeTileCoordFromPipeAndElemIdx
+****************************************************************************************************
+*   SiLib::ComputeTileCoordFromPipeAndElemIdx
 *
 *   @brief
 *       Compute (x,y) of a tile within a macro tile from address
 *   @return
 *       Pipe number
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::ComputeTileCoordFromPipeAndElemIdx(
+VOID SiLib::ComputeTileCoordFromPipeAndElemIdx(
     UINT_32         elemIdx,          ///< [in] per pipe element index within a macro tile
     UINT_32         pipe,             ///< [in] pipe index
     AddrPipeCfg     pipeCfg,          ///< [in] pipe config
@@ -908,16 +1072,16 @@ VOID SiAddrLib::ComputeTileCoordFromPipeAndElemIdx(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::TileCoordToMaskElementIndex
+****************************************************************************************************
+*   SiLib::TileCoordToMaskElementIndex
 *
 *   @brief
 *       Compute element index from coordinates in tiles
 *   @return
 *       Element index
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::TileCoordToMaskElementIndex(
+UINT_32 SiLib::TileCoordToMaskElementIndex(
     UINT_32         tx,                 ///< [in] x coord, in Tiles
     UINT_32         ty,                 ///< [in] y coord, in Tiles
     AddrPipeCfg     pipeConfig,         ///< [in] pipe config
@@ -1044,8 +1208,8 @@ UINT_32 SiAddrLib::TileCoordToMaskElementIndex(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlComputeTileDataWidthAndHeightLinear
+****************************************************************************************************
+*   SiLib::HwlComputeTileDataWidthAndHeightLinear
 *
 *   @brief
 *       Compute the squared cache shape for per-tile data (CMASK and HTILE) for linear layout
@@ -1055,9 +1219,9 @@ UINT_32 SiAddrLib::TileCoordToMaskElementIndex(
 *
 *   @note
 *       MacroWidth and macroHeight are measured in pixels
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::HwlComputeTileDataWidthAndHeightLinear(
+VOID SiLib::HwlComputeTileDataWidthAndHeightLinear(
     UINT_32*        pMacroWidth,     ///< [out] macro tile width
     UINT_32*        pMacroHeight,    ///< [out] macro tile height
     UINT_32         bpp,             ///< [in] bits per pixel
@@ -1090,17 +1254,17 @@ VOID SiAddrLib::HwlComputeTileDataWidthAndHeightLinear(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlComputeHtileBytes
+****************************************************************************************************
+*   SiLib::HwlComputeHtileBytes
 *
 *   @brief
 *       Compute htile size in bytes
 *
 *   @return
 *       Htile size in bytes
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_64 SiAddrLib::HwlComputeHtileBytes(
+UINT_64 SiLib::HwlComputeHtileBytes(
     UINT_32     pitch,          ///< [in] pitch
     UINT_32     height,         ///< [in] height
     UINT_32     bpp,            ///< [in] bits per pixel
@@ -1114,16 +1278,16 @@ UINT_64 SiAddrLib::HwlComputeHtileBytes(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlComputeXmaskAddrFromCoord
+****************************************************************************************************
+*   SiLib::HwlComputeXmaskAddrFromCoord
 *
 *   @brief
 *       Compute address from coordinates for htile/cmask
 *   @return
 *       Byte address
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_64 SiAddrLib::HwlComputeXmaskAddrFromCoord(
+UINT_64 SiLib::HwlComputeXmaskAddrFromCoord(
     UINT_32        pitch,          ///< [in] pitch
     UINT_32        height,         ///< [in] height
     UINT_32        x,              ///< [in] x coord
@@ -1269,8 +1433,8 @@ UINT_64 SiAddrLib::HwlComputeXmaskAddrFromCoord(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlComputeXmaskCoordFromAddr
+****************************************************************************************************
+*   SiLib::HwlComputeXmaskCoordFromAddr
 *
 *   @brief
 *       Compute the coord from an address of a cmask/htile
@@ -1280,9 +1444,9 @@ UINT_64 SiAddrLib::HwlComputeXmaskAddrFromCoord(
 *
 *   @note
 *       This method is reused by htile, so rename to Xmask
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::HwlComputeXmaskCoordFromAddr(
+VOID SiLib::HwlComputeXmaskCoordFromAddr(
     UINT_64         addr,           ///< [in] address
     UINT_32         bitPosition,    ///< [in] bitPosition in a byte
     UINT_32         pitch,          ///< [in] pitch
@@ -1475,15 +1639,15 @@ VOID SiAddrLib::HwlComputeXmaskCoordFromAddr(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlGetPitchAlignmentLinear
+****************************************************************************************************
+*   SiLib::HwlGetPitchAlignmentLinear
 *   @brief
 *       Get pitch alignment
 *   @return
 *       pitch alignment
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::HwlGetPitchAlignmentLinear(
+UINT_32 SiLib::HwlGetPitchAlignmentLinear(
     UINT_32             bpp,    ///< [in] bits per pixel
     ADDR_SURFACE_FLAGS  flags   ///< [in] surface flags
     ) const
@@ -1505,25 +1669,25 @@ UINT_32 SiAddrLib::HwlGetPitchAlignmentLinear(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlGetSizeAdjustmentLinear
+****************************************************************************************************
+*   SiLib::HwlGetSizeAdjustmentLinear
 *
 *   @brief
 *       Adjust linear surface pitch and slice size
 *
 *   @return
 *       Logical slice size in bytes
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_64 SiAddrLib::HwlGetSizeAdjustmentLinear(
+UINT_64 SiLib::HwlGetSizeAdjustmentLinear(
     AddrTileMode        tileMode,       ///< [in] tile mode
     UINT_32             bpp,            ///< [in] bits per pixel
     UINT_32             numSamples,     ///< [in] number of samples
     UINT_32             baseAlign,      ///< [in] base alignment
     UINT_32             pitchAlign,     ///< [in] pitch alignment
-    UINT_32*            pPitch,         ///< [in/out] pointer to pitch
-    UINT_32*            pHeight,        ///< [in/out] pointer to height
-    UINT_32*            pHeightAlign    ///< [in/out] pointer to height align
+    UINT_32*            pPitch,         ///< [in,out] pointer to pitch
+    UINT_32*            pHeight,        ///< [in,out] pointer to height
+    UINT_32*            pHeightAlign    ///< [in,out] pointer to height align
     ) const
 {
     UINT_64 sliceSize;
@@ -1566,17 +1730,17 @@ UINT_64 SiAddrLib::HwlGetSizeAdjustmentLinear(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlPreHandleBaseLvl3xPitch
+****************************************************************************************************
+*   SiLib::HwlPreHandleBaseLvl3xPitch
 *
 *   @brief
 *       Pre-handler of 3x pitch (96 bit) adjustment
 *
 *   @return
 *       Expected pitch
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::HwlPreHandleBaseLvl3xPitch(
+UINT_32 SiLib::HwlPreHandleBaseLvl3xPitch(
     const ADDR_COMPUTE_SURFACE_INFO_INPUT*  pIn,        ///< [in] input
     UINT_32                                 expPitch    ///< [in] pitch
     ) const
@@ -1587,7 +1751,7 @@ UINT_32 SiAddrLib::HwlPreHandleBaseLvl3xPitch(
     // do here
     if (pIn->flags.pow2Pad == FALSE)
     {
-        AddrLib1::HwlPreHandleBaseLvl3xPitch(pIn, expPitch);
+        Addr::V1::Lib::HwlPreHandleBaseLvl3xPitch(pIn, expPitch);
     }
     else
     {
@@ -1598,17 +1762,17 @@ UINT_32 SiAddrLib::HwlPreHandleBaseLvl3xPitch(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlPostHandleBaseLvl3xPitch
+****************************************************************************************************
+*   SiLib::HwlPostHandleBaseLvl3xPitch
 *
 *   @brief
 *       Post-handler of 3x pitch adjustment
 *
 *   @return
 *       Expected pitch
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::HwlPostHandleBaseLvl3xPitch(
+UINT_32 SiLib::HwlPostHandleBaseLvl3xPitch(
     const ADDR_COMPUTE_SURFACE_INFO_INPUT*  pIn,        ///< [in] input
     UINT_32                                 expPitch    ///< [in] pitch
     ) const
@@ -1620,24 +1784,24 @@ UINT_32 SiAddrLib::HwlPostHandleBaseLvl3xPitch(
     // From SI, the pitch is expanded 3x first, then padded to pow2, so no special handler here
     if (pIn->flags.pow2Pad == FALSE)
     {
-        AddrLib1::HwlPostHandleBaseLvl3xPitch(pIn, expPitch);
+        Addr::V1::Lib::HwlPostHandleBaseLvl3xPitch(pIn, expPitch);
     }
 
     return expPitch;
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlGetPitchAlignmentMicroTiled
+****************************************************************************************************
+*   SiLib::HwlGetPitchAlignmentMicroTiled
 *
 *   @brief
 *       Compute 1D tiled surface pitch alignment
 *
 *   @return
 *       pitch alignment
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::HwlGetPitchAlignmentMicroTiled(
+UINT_32 SiLib::HwlGetPitchAlignmentMicroTiled(
     AddrTileMode        tileMode,          ///< [in] tile mode
     UINT_32             bpp,               ///< [in] bits per pixel
     ADDR_SURFACE_FLAGS  flags,             ///< [in] surface flags
@@ -1648,7 +1812,7 @@ UINT_32 SiAddrLib::HwlGetPitchAlignmentMicroTiled(
 
     if (flags.qbStereo)
     {
-        pitchAlign = EgBasedAddrLib::HwlGetPitchAlignmentMicroTiled(tileMode,bpp,flags,numSamples);
+        pitchAlign = EgBasedLib::HwlGetPitchAlignmentMicroTiled(tileMode,bpp,flags,numSamples);
     }
     else
     {
@@ -1659,25 +1823,25 @@ UINT_32 SiAddrLib::HwlGetPitchAlignmentMicroTiled(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlGetSizeAdjustmentMicroTiled
+****************************************************************************************************
+*   SiLib::HwlGetSizeAdjustmentMicroTiled
 *
 *   @brief
 *       Adjust 1D tiled surface pitch and slice size
 *
 *   @return
 *       Logical slice size in bytes
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_64 SiAddrLib::HwlGetSizeAdjustmentMicroTiled(
+UINT_64 SiLib::HwlGetSizeAdjustmentMicroTiled(
     UINT_32             thickness,      ///< [in] thickness
     UINT_32             bpp,            ///< [in] bits per pixel
     ADDR_SURFACE_FLAGS  flags,          ///< [in] surface flags
     UINT_32             numSamples,     ///< [in] number of samples
     UINT_32             baseAlign,      ///< [in] base alignment
     UINT_32             pitchAlign,     ///< [in] pitch alignment
-    UINT_32*            pPitch,         ///< [in/out] pointer to pitch
-    UINT_32*            pHeight         ///< [in/out] pointer to height
+    UINT_32*            pPitch,         ///< [in,out] pointer to pitch
+    UINT_32*            pHeight         ///< [in,out] pointer to height
     ) const
 {
     UINT_64 logicalSliceSize;
@@ -1739,20 +1903,20 @@ UINT_64 SiAddrLib::HwlGetSizeAdjustmentMicroTiled(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlConvertChipFamily
+****************************************************************************************************
+*   SiLib::HwlConvertChipFamily
 *
 *   @brief
-*       Convert familyID defined in atiid.h to AddrChipFamily and set m_chipFamily/m_chipRevision
+*       Convert familyID defined in atiid.h to ChipFamily and set m_chipFamily/m_chipRevision
 *   @return
-*       AddrChipFamily
-***************************************************************************************************
+*       ChipFamily
+****************************************************************************************************
 */
-AddrChipFamily SiAddrLib::HwlConvertChipFamily(
+ChipFamily SiLib::HwlConvertChipFamily(
     UINT_32 uChipFamily,        ///< [in] chip family defined in atiih.h
     UINT_32 uChipRevision)      ///< [in] chip revision defined in "asic_family"_id.h
 {
-    AddrChipFamily family = ADDR_CHIP_FAMILY_SI;
+    ChipFamily family = ADDR_CHIP_FAMILY_SI;
 
     switch (uChipFamily)
     {
@@ -1773,14 +1937,14 @@ AddrChipFamily SiAddrLib::HwlConvertChipFamily(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlSetupTileInfo
+****************************************************************************************************
+*   SiLib::HwlSetupTileInfo
 *
 *   @brief
 *       Setup default value of tile info for SI
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::HwlSetupTileInfo(
+VOID SiLib::HwlSetupTileInfo(
     AddrTileMode                        tileMode,       ///< [in] Tile mode
     ADDR_SURFACE_FLAGS                  flags,          ///< [in] Surface type flags
     UINT_32                             bpp,            ///< [in] Bits per pixel
@@ -2093,11 +2257,12 @@ VOID SiAddrLib::HwlSetupTileInfo(
     }
 
     pOut->tileIndex = index;
+    pOut->prtTileIndex = flags.prt;
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::DecodeGbRegs
+****************************************************************************************************
+*   SiLib::DecodeGbRegs
 *
 *   @brief
 *       Decodes GB_ADDR_CONFIG and noOfBanks/noOfRanks
@@ -2105,9 +2270,9 @@ VOID SiAddrLib::HwlSetupTileInfo(
 *   @return
 *       TRUE if all settings are valid
 *
-***************************************************************************************************
+****************************************************************************************************
 */
-BOOL_32 SiAddrLib::DecodeGbRegs(
+BOOL_32 SiLib::DecodeGbRegs(
     const ADDR_REGISTER_VALUE* pRegValue) ///< [in] create input
 {
     GB_ADDR_CONFIG  reg;
@@ -2185,8 +2350,8 @@ BOOL_32 SiAddrLib::DecodeGbRegs(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlInitGlobalParams
+****************************************************************************************************
+*   SiLib::HwlInitGlobalParams
 *
 *   @brief
 *       Initializes global parameters
@@ -2194,9 +2359,9 @@ BOOL_32 SiAddrLib::DecodeGbRegs(
 *   @return
 *       TRUE if all settings are valid
 *
-***************************************************************************************************
+****************************************************************************************************
 */
-BOOL_32 SiAddrLib::HwlInitGlobalParams(
+BOOL_32 SiLib::HwlInitGlobalParams(
     const ADDR_CREATE_INPUT* pCreateIn) ///< [in] create input
 {
     BOOL_32 valid = TRUE;
@@ -2234,22 +2399,22 @@ BOOL_32 SiAddrLib::HwlInitGlobalParams(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlConvertTileInfoToHW
+****************************************************************************************************
+*   SiLib::HwlConvertTileInfoToHW
 *   @brief
 *       Entry of si's ConvertTileInfoToHW
 *   @return
 *       ADDR_E_RETURNCODE
-***************************************************************************************************
+****************************************************************************************************
 */
-ADDR_E_RETURNCODE SiAddrLib::HwlConvertTileInfoToHW(
+ADDR_E_RETURNCODE SiLib::HwlConvertTileInfoToHW(
     const ADDR_CONVERT_TILEINFOTOHW_INPUT* pIn, ///< [in] input structure
     ADDR_CONVERT_TILEINFOTOHW_OUTPUT* pOut      ///< [out] output structure
     ) const
 {
     ADDR_E_RETURNCODE retCode   = ADDR_OK;
 
-    retCode = EgBasedAddrLib::HwlConvertTileInfoToHW(pIn, pOut);
+    retCode = EgBasedLib::HwlConvertTileInfoToHW(pIn, pOut);
 
     if (retCode == ADDR_OK)
     {
@@ -2276,17 +2441,17 @@ ADDR_E_RETURNCODE SiAddrLib::HwlConvertTileInfoToHW(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlComputeXmaskCoordYFrom8Pipe
+****************************************************************************************************
+*   SiLib::HwlComputeXmaskCoordYFrom8Pipe
 *
 *   @brief
 *       Compute the Y coord which will be added to Xmask Y
 *       coord.
 *   @return
 *       Y coord
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::HwlComputeXmaskCoordYFrom8Pipe(
+UINT_32 SiLib::HwlComputeXmaskCoordYFrom8Pipe(
     UINT_32         pipe,       ///< [in] pipe id
     UINT_32         x           ///< [in] tile coord x, which is original x coord / 8
     ) const
@@ -2299,19 +2464,19 @@ UINT_32 SiAddrLib::HwlComputeXmaskCoordYFrom8Pipe(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlComputeSurfaceCoord2DFromBankPipe
+****************************************************************************************************
+*   SiLib::HwlComputeSurfaceCoord2DFromBankPipe
 *
 *   @brief
 *       Compute surface x,y coordinates from bank/pipe info
 *   @return
 *       N/A
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::HwlComputeSurfaceCoord2DFromBankPipe(
+VOID SiLib::HwlComputeSurfaceCoord2DFromBankPipe(
     AddrTileMode        tileMode,   ///< [in] tile mode
-    UINT_32*            pX,         ///< [in/out] x coordinate
-    UINT_32*            pY,         ///< [in/out] y coordinate
+    UINT_32*            pX,         ///< [in,out] x coordinate
+    UINT_32*            pY,         ///< [in,out] y coordinate
     UINT_32             slice,      ///< [in] slice index
     UINT_32             bank,       ///< [in] bank number
     UINT_32             pipe,       ///< [in] pipe number
@@ -2464,16 +2629,16 @@ VOID SiAddrLib::HwlComputeSurfaceCoord2DFromBankPipe(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlPreAdjustBank
+****************************************************************************************************
+*   SiLib::HwlPreAdjustBank
 *
 *   @brief
 *       Adjust bank before calculating address acoording to bank/pipe
 *   @return
 *       Adjusted bank
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::HwlPreAdjustBank(
+UINT_32 SiLib::HwlPreAdjustBank(
     UINT_32         tileX,      ///< [in] x coordinate in unit of tile
     UINT_32         bank,       ///< [in] bank
     ADDR_TILEINFO*  pTileInfo   ///< [in] tile info
@@ -2496,31 +2661,51 @@ UINT_32 SiAddrLib::HwlPreAdjustBank(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlComputeSurfaceInfo
+****************************************************************************************************
+*   SiLib::HwlComputeSurfaceInfo
 *
 *   @brief
 *       Entry of si's ComputeSurfaceInfo
 *   @return
 *       ADDR_E_RETURNCODE
-***************************************************************************************************
+****************************************************************************************************
 */
-ADDR_E_RETURNCODE SiAddrLib::HwlComputeSurfaceInfo(
+ADDR_E_RETURNCODE SiLib::HwlComputeSurfaceInfo(
     const ADDR_COMPUTE_SURFACE_INFO_INPUT*  pIn,    ///< [in] input structure
     ADDR_COMPUTE_SURFACE_INFO_OUTPUT*       pOut    ///< [out] output structure
     ) const
 {
     pOut->tileIndex = pIn->tileIndex;
 
-    ADDR_E_RETURNCODE retCode = EgBasedAddrLib::HwlComputeSurfaceInfo(pIn, pOut);
+    ADDR_E_RETURNCODE retCode = EgBasedLib::HwlComputeSurfaceInfo(pIn, pOut);
 
     UINT_32 tileIndex = static_cast<UINT_32>(pOut->tileIndex);
 
-    if ((pIn->flags.needEquation == TRUE) &&
+    if (((pIn->flags.needEquation   == TRUE) ||
+         (pIn->flags.preferEquation == TRUE)) &&
         (pIn->numSamples <= 1) &&
         (tileIndex < TileTableSize))
     {
-        pOut->equationIndex = m_equationLookupTable[Log2(pIn->bpp >> 3)][tileIndex];
+        static const UINT_32 SiUncompressDepthTileIndex = 3;
+
+        if ((pIn->numSlices > 1) &&
+            (IsMacroTiled(pOut->tileMode) == TRUE) &&
+            ((m_chipFamily == ADDR_CHIP_FAMILY_SI) ||
+             (IsPrtTileMode(pOut->tileMode) == FALSE)))
+        {
+            pOut->equationIndex = ADDR_INVALID_EQUATION_INDEX;
+        }
+        else if ((pIn->flags.prt == FALSE) &&
+                 (m_uncompressDepthEqIndex != 0) &&
+                 (tileIndex == SiUncompressDepthTileIndex))
+        {
+            pOut->equationIndex = m_uncompressDepthEqIndex + Log2(pIn->bpp >> 3);
+        }
+        else
+        {
+
+            pOut->equationIndex = m_equationLookupTable[Log2(pIn->bpp >> 3)][tileIndex];
+        }
 
         if (pOut->equationIndex != ADDR_INVALID_EQUATION_INDEX)
         {
@@ -2540,16 +2725,16 @@ ADDR_E_RETURNCODE SiAddrLib::HwlComputeSurfaceInfo(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlComputeMipLevel
+****************************************************************************************************
+*   SiLib::HwlComputeMipLevel
 *   @brief
 *       Compute MipLevel info (including level 0)
 *   @return
 *       TRUE if HWL's handled
-***************************************************************************************************
+****************************************************************************************************
 */
-BOOL_32 SiAddrLib::HwlComputeMipLevel(
-    ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn ///< [in/out] Input structure
+BOOL_32 SiLib::HwlComputeMipLevel(
+    ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn ///< [in,out] Input structure
     ) const
 {
     // basePitch is calculated from level 0 so we only check this for mipLevel > 0
@@ -2558,7 +2743,7 @@ BOOL_32 SiAddrLib::HwlComputeMipLevel(
         // Note: Don't check expand 3x formats(96 bit) as the basePitch is not pow2 even if
         // we explicity set pow2Pad flag. The 3x base pitch is padded to pow2 but after being
         // divided by expandX factor (3) - to program texture pitch, the basePitch is never pow2.
-        if (AddrElemLib::IsExpand3x(pIn->format) == FALSE)
+        if (ElemLib::IsExpand3x(pIn->format) == FALSE)
         {
             // Sublevel pitches are generated from base level pitch instead of width on SI
             // If pow2Pad is 0, we don't assert - as this is not really used for a mip chain
@@ -2578,18 +2763,18 @@ BOOL_32 SiAddrLib::HwlComputeMipLevel(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlCheckLastMacroTiledLvl
+****************************************************************************************************
+*   SiLib::HwlCheckLastMacroTiledLvl
 *
 *   @brief
 *       Sets pOut->last2DLevel to TRUE if it is
 *   @note
 *
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::HwlCheckLastMacroTiledLvl(
+VOID SiLib::HwlCheckLastMacroTiledLvl(
     const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn, ///< [in] Input structure
-    ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut      ///< [in/out] Output structure (used as input, too)
+    ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut      ///< [in,out] Output structure (used as input, too)
     ) const
 {
     // pow2Pad covers all mipmap cases
@@ -2622,7 +2807,7 @@ VOID SiAddrLib::HwlCheckLastMacroTiledLvl(
         nextHeight = pOut->height >> 1;
         // Special format such as FMT_1 and FMT_32_32_32 can be linear only so we consider block
         // compressed foramts
-        if (AddrElemLib::IsBlockCompressed(pIn->format))
+        if (ElemLib::IsBlockCompressed(pIn->format))
         {
             nextHeight = (nextHeight + 3) / 4;
         }
@@ -2653,36 +2838,36 @@ VOID SiAddrLib::HwlCheckLastMacroTiledLvl(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlDegradeThickTileMode
+****************************************************************************************************
+*   SiLib::HwlDegradeThickTileMode
 *
 *   @brief
 *       Degrades valid tile mode for thick modes if needed
 *
 *   @return
 *       Suitable tile mode
-***************************************************************************************************
+****************************************************************************************************
 */
-AddrTileMode SiAddrLib::HwlDegradeThickTileMode(
-    AddrTileMode        baseTileMode,   ///< [in] base tile mode
-    UINT_32             numSlices,      ///< [in] current number of slices
-    UINT_32*            pBytesPerTile   ///< [in/out] pointer to bytes per slice
+AddrTileMode SiLib::HwlDegradeThickTileMode(
+    AddrTileMode        baseTileMode,   ///< base tile mode
+    UINT_32             numSlices,      ///< current number of slices
+    UINT_32*            pBytesPerTile   ///< [in,out] pointer to bytes per slice
     ) const
 {
-    return EgBasedAddrLib::HwlDegradeThickTileMode(baseTileMode, numSlices, pBytesPerTile);
+    return EgBasedLib::HwlDegradeThickTileMode(baseTileMode, numSlices, pBytesPerTile);
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlTileInfoEqual
+****************************************************************************************************
+*   SiLib::HwlTileInfoEqual
 *
 *   @brief
 *       Return TRUE if all field are equal
 *   @note
 *       Only takes care of current HWL's data
-***************************************************************************************************
+****************************************************************************************************
 */
-BOOL_32 SiAddrLib::HwlTileInfoEqual(
+BOOL_32 SiLib::HwlTileInfoEqual(
     const ADDR_TILEINFO* pLeft, ///<[in] Left compare operand
     const ADDR_TILEINFO* pRight ///<[in] Right compare operand
     ) const
@@ -2691,23 +2876,23 @@ BOOL_32 SiAddrLib::HwlTileInfoEqual(
 
     if (pLeft->pipeConfig == pRight->pipeConfig)
     {
-        equal =  EgBasedAddrLib::HwlTileInfoEqual(pLeft, pRight);
+        equal =  EgBasedLib::HwlTileInfoEqual(pLeft, pRight);
     }
 
     return equal;
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::GetTileSettings
+****************************************************************************************************
+*   SiLib::GetTileSettings
 *
 *   @brief
 *       Get tile setting infos by index.
 *   @return
 *       Tile setting info.
-***************************************************************************************************
+****************************************************************************************************
 */
-const AddrTileConfig* SiAddrLib::GetTileSetting(
+const TileConfig* SiLib::GetTileSetting(
     UINT_32 index          ///< [in] Tile index
     ) const
 {
@@ -2716,17 +2901,17 @@ const AddrTileConfig* SiAddrLib::GetTileSetting(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlPostCheckTileIndex
+****************************************************************************************************
+*   SiLib::HwlPostCheckTileIndex
 *
 *   @brief
 *       Map a tile setting to index if curIndex is invalid, otherwise check if curIndex matches
 *       tile mode/type/info and change the index if needed
 *   @return
 *       Tile index.
-***************************************************************************************************
+****************************************************************************************************
 */
-INT_32 SiAddrLib::HwlPostCheckTileIndex(
+INT_32 SiLib::HwlPostCheckTileIndex(
     const ADDR_TILEINFO* pInfo,     ///< [in] Tile Info
     AddrTileMode         mode,      ///< [in] Tile mode
     AddrTileType         type,      ///< [in] Tile type
@@ -2795,19 +2980,19 @@ INT_32 SiAddrLib::HwlPostCheckTileIndex(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlSetupTileCfg
+****************************************************************************************************
+*   SiLib::HwlSetupTileCfg
 *
 *   @brief
 *       Map tile index to tile setting.
 *   @return
 *       ADDR_E_RETURNCODE
-***************************************************************************************************
+****************************************************************************************************
 */
-ADDR_E_RETURNCODE SiAddrLib::HwlSetupTileCfg(
-    UINT_32         bpp,            ///< [in] Bits per pixel
-    INT_32          index,          ///< [in] Tile index
-    INT_32          macroModeIndex, ///< [in] Index in macro tile mode table(CI)
+ADDR_E_RETURNCODE SiLib::HwlSetupTileCfg(
+    UINT_32         bpp,            ///< Bits per pixel
+    INT_32          index,          ///< Tile index
+    INT_32          macroModeIndex, ///< Index in macro tile mode table(CI)
     ADDR_TILEINFO*  pInfo,          ///< [out] Tile Info
     AddrTileMode*   pMode,          ///< [out] Tile mode
     AddrTileType*   pType           ///< [out] Tile type
@@ -2846,7 +3031,7 @@ ADDR_E_RETURNCODE SiAddrLib::HwlSetupTileCfg(
         }
         else
         {
-            const AddrTileConfig* pCfgTable = GetTileSetting(index);
+            const TileConfig* pCfgTable = GetTileSetting(index);
 
             if (pInfo)
             {
@@ -2876,18 +3061,18 @@ ADDR_E_RETURNCODE SiAddrLib::HwlSetupTileCfg(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::ReadGbTileMode
+****************************************************************************************************
+*   SiLib::ReadGbTileMode
 *
 *   @brief
-*       Convert GB_TILE_MODE HW value to ADDR_TILE_CONFIG.
+*       Convert GB_TILE_MODE HW value to TileConfig.
 *   @return
 *       NA.
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::ReadGbTileMode(
-    UINT_32             regValue,   ///< [in] GB_TILE_MODE register
-    AddrTileConfig*     pCfg        ///< [out] output structure
+VOID SiLib::ReadGbTileMode(
+    UINT_32     regValue,   ///< [in] GB_TILE_MODE register
+    TileConfig* pCfg        ///< [out] output structure
     ) const
 {
     GB_TILE_MODE gbTileMode;
@@ -2916,16 +3101,16 @@ VOID SiAddrLib::ReadGbTileMode(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::InitTileSettingTable
+****************************************************************************************************
+*   SiLib::InitTileSettingTable
 *
 *   @brief
 *       Initialize the ADDR_TILE_CONFIG table.
 *   @return
 *       TRUE if tile table is correctly initialized
-***************************************************************************************************
+****************************************************************************************************
 */
-BOOL_32 SiAddrLib::InitTileSettingTable(
+BOOL_32 SiLib::InitTileSettingTable(
     const UINT_32*  pCfg,           ///< [in] Pointer to table of tile configs
     UINT_32         noOfEntries     ///< [in] Numbe of entries in the table above
     )
@@ -2967,16 +3152,16 @@ BOOL_32 SiAddrLib::InitTileSettingTable(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlGetTileIndex
+****************************************************************************************************
+*   SiLib::HwlGetTileIndex
 *
 *   @brief
 *       Return the virtual/real index for given mode/type/info
 *   @return
 *       ADDR_OK if successful.
-***************************************************************************************************
+****************************************************************************************************
 */
-ADDR_E_RETURNCODE SiAddrLib::HwlGetTileIndex(
+ADDR_E_RETURNCODE SiLib::HwlGetTileIndex(
     const ADDR_GET_TILEINDEX_INPUT* pIn,
     ADDR_GET_TILEINDEX_OUTPUT*      pOut) const
 {
@@ -2988,16 +3173,16 @@ ADDR_E_RETURNCODE SiAddrLib::HwlGetTileIndex(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlFmaskPreThunkSurfInfo
+****************************************************************************************************
+*   SiLib::HwlFmaskPreThunkSurfInfo
 *
 *   @brief
 *       Some preparation before thunking a ComputeSurfaceInfo call for Fmask
 *   @return
 *       ADDR_E_RETURNCODE
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::HwlFmaskPreThunkSurfInfo(
+VOID SiLib::HwlFmaskPreThunkSurfInfo(
     const ADDR_COMPUTE_FMASK_INFO_INPUT*    pFmaskIn,   ///< [in] Input of fmask info
     const ADDR_COMPUTE_FMASK_INFO_OUTPUT*   pFmaskOut,  ///< [in] Output of fmask info
     ADDR_COMPUTE_SURFACE_INFO_INPUT*        pSurfIn,    ///< [out] Input of thunked surface info
@@ -3008,16 +3193,16 @@ VOID SiAddrLib::HwlFmaskPreThunkSurfInfo(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlFmaskPostThunkSurfInfo
+****************************************************************************************************
+*   SiLib::HwlFmaskPostThunkSurfInfo
 *
 *   @brief
 *       Copy hwl extra field after calling thunked ComputeSurfaceInfo
 *   @return
 *       ADDR_E_RETURNCODE
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::HwlFmaskPostThunkSurfInfo(
+VOID SiLib::HwlFmaskPostThunkSurfInfo(
     const ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pSurfOut,   ///< [in] Output of surface info
     ADDR_COMPUTE_FMASK_INFO_OUTPUT* pFmaskOut           ///< [out] Output of fmask info
     ) const
@@ -3027,15 +3212,15 @@ VOID SiAddrLib::HwlFmaskPostThunkSurfInfo(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlComputeFmaskBits
+****************************************************************************************************
+*   SiLib::HwlComputeFmaskBits
 *   @brief
 *       Computes fmask bits
 *   @return
 *       Fmask bits
-***************************************************************************************************
+****************************************************************************************************
 */
-UINT_32 SiAddrLib::HwlComputeFmaskBits(
+UINT_32 SiLib::HwlComputeFmaskBits(
     const ADDR_COMPUTE_FMASK_INFO_INPUT* pIn,
     UINT_32* pNumSamples
     ) const
@@ -3128,8 +3313,52 @@ UINT_32 SiAddrLib::HwlComputeFmaskBits(
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlOverrideTileMode
+****************************************************************************************************
+*   SiLib::HwlOptimizeTileMode
+*
+*   @brief
+*       Optimize tile mode on SI
+*
+*   @return
+*       N/A
+*
+****************************************************************************************************
+*/
+VOID SiLib::HwlOptimizeTileMode(
+    ADDR_COMPUTE_SURFACE_INFO_INPUT*    pInOut      ///< [in,out] input output structure
+    ) const
+{
+    AddrTileMode tileMode = pInOut->tileMode;
+
+    if ((pInOut->flags.needEquation == TRUE) &&
+        (IsMacroTiled(tileMode) == TRUE) &&
+        (pInOut->numSamples <= 1))
+    {
+        UINT_32 thickness = Thickness(tileMode);
+
+        if (thickness > 1)
+        {
+            tileMode = ADDR_TM_1D_TILED_THICK;
+        }
+        else if (pInOut->numSlices > 1)
+        {
+            tileMode = ADDR_TM_1D_TILED_THIN1;
+        }
+        else
+        {
+            tileMode = ADDR_TM_2D_TILED_THIN1;
+        }
+    }
+
+    if (tileMode != pInOut->tileMode)
+    {
+        pInOut->tileMode = tileMode;
+    }
+}
+
+/**
+****************************************************************************************************
+*   SiLib::HwlOverrideTileMode
 *
 *   @brief
 *       Override tile modes (for PRT only, avoid client passes in an invalid PRT mode for SI.
@@ -3137,10 +3366,10 @@ UINT_32 SiAddrLib::HwlComputeFmaskBits(
 *   @return
 *       N/A
 *
-***************************************************************************************************
+****************************************************************************************************
 */
-void SiAddrLib::HwlOverrideTileMode(
-    ADDR_COMPUTE_SURFACE_INFO_INPUT*    pInOut          ///< [in/out] input output structure
+VOID SiLib::HwlOverrideTileMode(
+    ADDR_COMPUTE_SURFACE_INFO_INPUT*    pInOut          ///< [in,out] input output structure
     ) const
 {
     AddrTileMode tileMode = pInOut->tileMode;
@@ -3148,73 +3377,144 @@ void SiAddrLib::HwlOverrideTileMode(
     switch (tileMode)
     {
         case ADDR_TM_PRT_TILED_THIN1:
-            tileMode    = ADDR_TM_2D_TILED_THIN1;
+            tileMode = ADDR_TM_2D_TILED_THIN1;
             break;
 
         case ADDR_TM_PRT_TILED_THICK:
-            tileMode    = ADDR_TM_2D_TILED_THICK;
+            tileMode = ADDR_TM_2D_TILED_THICK;
             break;
 
         case ADDR_TM_PRT_2D_TILED_THICK:
-            tileMode    = ADDR_TM_2D_TILED_THICK;
+            tileMode = ADDR_TM_2D_TILED_THICK;
             break;
 
         case ADDR_TM_PRT_3D_TILED_THICK:
-            tileMode    = ADDR_TM_3D_TILED_THICK;
+            tileMode = ADDR_TM_3D_TILED_THICK;
             break;
 
         default:
             break;
     }
 
-    if ((pInOut->flags.needEquation == TRUE) &&
-        (IsMacroTiled(tileMode) == TRUE) &&
-        (pInOut->numSamples <= 1))
+    if (tileMode != pInOut->tileMode)
     {
-        UINT_32 thickness = Thickness(tileMode);
-
+        pInOut->tileMode  = tileMode;
+        // Only PRT tile modes are overridden for now. Revisit this once new modes are added above.
         pInOut->flags.prt = TRUE;
+    }
+}
 
-        if (thickness > 1)
+/**
+****************************************************************************************************
+*   SiLib::HwlSetPrtTileMode
+*
+*   @brief
+*       Set prt tile modes.
+*
+*   @return
+*       N/A
+*
+****************************************************************************************************
+*/
+VOID SiLib::HwlSetPrtTileMode(
+    ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut     ///< [in,out] input output structure
+    ) const
+{
+    pInOut->tileMode = ADDR_TM_2D_TILED_THIN1;
+    pInOut->tileType = (pInOut->tileType == ADDR_DEPTH_SAMPLE_ORDER) ?
+                       ADDR_DEPTH_SAMPLE_ORDER : ADDR_NON_DISPLAYABLE;
+    pInOut->flags.prt = TRUE;
+}
+
+/**
+****************************************************************************************************
+*   SiLib::HwlSelectTileMode
+*
+*   @brief
+*       Select tile modes.
+*
+*   @return
+*       N/A
+*
+****************************************************************************************************
+*/
+VOID SiLib::HwlSelectTileMode(
+    ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut     ///< [in,out] input output structure
+    ) const
+{
+    AddrTileMode tileMode;
+    AddrTileType tileType;
+
+    if (pInOut->flags.volume)
+    {
+        if (pInOut->numSlices >= 8)
         {
-            tileMode = ADDR_TM_1D_TILED_THICK;
+            tileMode = ADDR_TM_2D_TILED_XTHICK;
         }
-        else if (pInOut->numSlices > 1)
+        else if (pInOut->numSlices >= 4)
         {
-            tileMode = ADDR_TM_1D_TILED_THIN1;
+            tileMode = ADDR_TM_2D_TILED_THICK;
         }
         else
         {
             tileMode = ADDR_TM_2D_TILED_THIN1;
         }
+        tileType = ADDR_NON_DISPLAYABLE;
     }
-
-    if (tileMode != pInOut->tileMode)
+    else
     {
-        pInOut->tileMode = tileMode;
+        tileMode = ADDR_TM_2D_TILED_THIN1;
+
+        if (pInOut->flags.depth || pInOut->flags.stencil)
+        {
+            tileType = ADDR_DEPTH_SAMPLE_ORDER;
+        }
+        else if ((pInOut->bpp <= 32) ||
+                 (pInOut->flags.display == TRUE) ||
+                 (pInOut->flags.overlay == TRUE))
+        {
+            tileType = ADDR_DISPLAYABLE;
+        }
+        else
+        {
+            tileType = ADDR_NON_DISPLAYABLE;
+        }
+    }
 
-        ADDR_ASSERT(pInOut->flags.prt == TRUE);
+    if (pInOut->flags.prt)
+    {
+        tileMode = ADDR_TM_2D_TILED_THIN1;
+        tileType = (tileType == ADDR_DISPLAYABLE) ? ADDR_NON_DISPLAYABLE : tileType;
     }
+
+    pInOut->tileMode = tileMode;
+    pInOut->tileType = tileType;
+
+    // Optimize tile mode if possible
+    pInOut->flags.opt4Space = TRUE;
+
+    // Optimize tile mode if possible
+    OptimizeTileMode(pInOut);
+
+    HwlOverrideTileMode(pInOut);
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::HwlGetMaxAlignments
+****************************************************************************************************
+*   SiLib::HwlComputeMaxBaseAlignments
 *
 *   @brief
 *       Gets maximum alignments
 *   @return
-*       ADDR_E_RETURNCODE
-***************************************************************************************************
+*       maximum alignments
+****************************************************************************************************
 */
-ADDR_E_RETURNCODE SiAddrLib::HwlGetMaxAlignments(
-    ADDR_GET_MAX_ALINGMENTS_OUTPUT* pOut    ///< [out] output structure
-    ) const
+UINT_32 SiLib::HwlComputeMaxBaseAlignments() const
 {
     const UINT_32 pipes = HwlGetPipes(&m_tileTable[0].info);
 
     // Initial size is 64 KiB for PRT.
-    UINT_64 maxBaseAlign = 64 * 1024;
+    UINT_32 maxBaseAlign = 64 * 1024;
 
     for (UINT_32 i = 0; i < m_noOfEntries; i++)
     {
@@ -3225,7 +3525,7 @@ ADDR_E_RETURNCODE SiAddrLib::HwlGetMaxAlignments(
             UINT_32 tileSize = Min(m_tileTable[i].info.tileSplitBytes,
                                    MicroTilePixels * 8 * 16);
 
-            UINT_64 baseAlign = tileSize * pipes * m_tileTable[i].info.banks *
+            UINT_32 baseAlign = tileSize * pipes * m_tileTable[i].info.banks *
                                 m_tileTable[i].info.bankWidth * m_tileTable[i].info.bankHeight;
 
             if (baseAlign > maxBaseAlign)
@@ -3235,26 +3535,80 @@ ADDR_E_RETURNCODE SiAddrLib::HwlGetMaxAlignments(
         }
     }
 
-    if (pOut != NULL)
+    return maxBaseAlign;
+}
+
+/**
+****************************************************************************************************
+*   SiLib::HwlComputeMaxMetaBaseAlignments
+*
+*   @brief
+*       Gets maximum alignments for metadata
+*   @return
+*       maximum alignments for metadata
+****************************************************************************************************
+*/
+UINT_32 SiLib::HwlComputeMaxMetaBaseAlignments() const
+{
+    UINT_32 maxPipe = 1;
+
+    for (UINT_32 i = 0; i < m_noOfEntries; i++)
     {
-        pOut->baseAlign = maxBaseAlign;
+        maxPipe = Max(maxPipe, HwlGetPipes(&m_tileTable[i].info));
     }
 
-    return ADDR_OK;
+    return m_pipeInterleaveBytes * maxPipe;
+}
+
+/**
+****************************************************************************************************
+*   SiLib::HwlComputeSurfaceAlignmentsMacroTiled
+*
+*   @brief
+*       Hardware layer function to compute alignment request for macro tile mode
+*
+*   @return
+*       N/A
+*
+****************************************************************************************************
+*/
+VOID SiLib::HwlComputeSurfaceAlignmentsMacroTiled(
+    AddrTileMode                      tileMode,           ///< [in] tile mode
+    UINT_32                           bpp,                ///< [in] bits per pixel
+    ADDR_SURFACE_FLAGS                flags,              ///< [in] surface flags
+    UINT_32                           mipLevel,           ///< [in] mip level
+    UINT_32                           numSamples,         ///< [in] number of samples
+    ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut                ///< [in,out] Surface output
+    ) const
+{
+    if ((mipLevel == 0) && (flags.prt))
+    {
+        UINT_32 macroTileSize = pOut->blockWidth * pOut->blockHeight * numSamples * bpp / 8;
+
+        if (macroTileSize < PrtTileSize)
+        {
+            UINT_32 numMacroTiles = PrtTileSize / macroTileSize;
+
+            ADDR_ASSERT((PrtTileSize % macroTileSize) == 0);
+
+            pOut->pitchAlign *= numMacroTiles;
+            pOut->baseAlign  *= numMacroTiles;
+        }
+    }
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::InitEquationTable
+****************************************************************************************************
+*   SiLib::InitEquationTable
 *
 *   @brief
 *       Initialize Equation table.
 *
 *   @return
 *       N/A
-***************************************************************************************************
+****************************************************************************************************
 */
-VOID SiAddrLib::InitEquationTable()
+VOID SiLib::InitEquationTable()
 {
     ADDR_EQUATION_KEY equationKeyTable[EquationTableSize];
     memset(equationKeyTable, 0, sizeof(equationKeyTable));
@@ -3278,7 +3632,7 @@ VOID SiAddrLib::InitEquationTable()
         {
             UINT_32 equationIndex = ADDR_INVALID_EQUATION_INDEX;
 
-            AddrTileConfig tileConfig = m_tileTable[tileIndex];
+            TileConfig tileConfig = m_tileTable[tileIndex];
 
             ADDR_SURFACE_FLAGS flags = {{0}};
 
@@ -3287,7 +3641,7 @@ VOID SiAddrLib::InitEquationTable()
             HwlComputeMacroModeIndex(tileIndex, flags, bpp, 1, &tileConfig.info, NULL, NULL);
 
             // Check if the input is supported
-            if (IsEquationSupported(bpp, tileConfig, tileIndex) == TRUE)
+            if (IsEquationSupported(bpp, tileConfig, tileIndex, log2ElementBytes) == TRUE)
             {
                 ADDR_EQUATION_KEY  key   = {{0}};
 
@@ -3299,10 +3653,12 @@ VOID SiAddrLib::InitEquationTable()
                 key.fields.microTileType    = (tileConfig.type == ADDR_DEPTH_SAMPLE_ORDER) ?
                                               ADDR_NON_DISPLAYABLE : tileConfig.type;
                 key.fields.pipeConfig       = tileConfig.info.pipeConfig;
-                key.fields.numBanks         = tileConfig.info.banks;
+                key.fields.numBanksLog2     = Log2(tileConfig.info.banks);
                 key.fields.bankWidth        = tileConfig.info.bankWidth;
                 key.fields.bankHeight       = tileConfig.info.bankHeight;
                 key.fields.macroAspectRatio = tileConfig.info.macroAspectRatio;
+                key.fields.prt              = ((m_chipFamily == ADDR_CHIP_FAMILY_SI) &&
+                                               ((1 << tileIndex) & SiPrtTileIndexMask)) ? 1 : 0;
 
                 // Find in the table if the equation has been built based on the key
                 for (UINT_32 i = 0; i < m_numEquations; i++)
@@ -3366,10 +3722,8 @@ VOID SiAddrLib::InitEquationTable()
                                 MicroTileHeight * pTileInfo->bankHeight * pTileInfo->banks /
                                 pTileInfo->macroAspectRatio;
 
-                            if (m_chipFamily == ADDR_CHIP_FAMILY_SI)
+                            if (key.fields.prt)
                             {
-                                static const UINT_32 PrtTileSize = 0x10000;
-
                                 UINT_32 macroTileSize =
                                     m_blockWidth[equationIndex] * m_blockHeight[equationIndex] *
                                     bpp / 8;
@@ -3411,24 +3765,67 @@ VOID SiAddrLib::InitEquationTable()
             // fill the invalid equation index
             m_equationLookupTable[log2ElementBytes][tileIndex] = equationIndex;
         }
+
+        if (m_chipFamily == ADDR_CHIP_FAMILY_SI)
+        {
+            // For tile index 3 which is shared between PRT depth and uncompressed depth
+            m_uncompressDepthEqIndex = m_numEquations;
+
+            for (UINT_32 log2ElemBytes = 0; log2ElemBytes < MaxNumElementBytes; log2ElemBytes++)
+            {
+                TileConfig        tileConfig = m_tileTable[3];
+                ADDR_EQUATION     equation;
+                ADDR_E_RETURNCODE retCode;
+
+                memset(&equation, 0, sizeof(ADDR_EQUATION));
+
+                retCode = ComputeMacroTileEquation(log2ElemBytes,
+                                                   tileConfig.mode,
+                                                   tileConfig.type,
+                                                   &tileConfig.info,
+                                                   &equation);
+
+                if (retCode == ADDR_OK)
+                {
+                    UINT_32 equationIndex = m_numEquations;
+                    ADDR_ASSERT(equationIndex < EquationTableSize);
+
+                    m_blockSlices[equationIndex] = 1;
+
+                    const ADDR_TILEINFO* pTileInfo = &tileConfig.info;
+
+                    m_blockWidth[equationIndex]  =
+                        HwlGetPipes(pTileInfo) * MicroTileWidth * pTileInfo->bankWidth *
+                        pTileInfo->macroAspectRatio;
+                    m_blockHeight[equationIndex] =
+                        MicroTileHeight * pTileInfo->bankHeight * pTileInfo->banks /
+                        pTileInfo->macroAspectRatio;
+
+                    m_equationTable[equationIndex] = equation;
+
+                    m_numEquations++;
+                }
+            }
+        }
     }
 }
 
 /**
-***************************************************************************************************
-*   SiAddrLib::IsEquationSupported
+****************************************************************************************************
+*   SiLib::IsEquationSupported
 *
 *   @brief
 *       Check if it is supported for given bpp and tile config to generate a equation.
 *
 *   @return
 *       TRUE if supported
-***************************************************************************************************
+****************************************************************************************************
 */
-BOOL_32 SiAddrLib::IsEquationSupported(
-    UINT_32        bpp,         ///< Bits per pixel
-    AddrTileConfig tileConfig,  ///< Tile config
-    INT_32         tileIndex    ///< Tile index
+BOOL_32 SiLib::IsEquationSupported(
+    UINT_32    bpp,             ///< Bits per pixel
+    TileConfig tileConfig,      ///< Tile config
+    INT_32     tileIndex,       ///< Tile index
+    UINT_32    elementBytesLog2 ///< Log2 of element bytes
     ) const
 {
     BOOL_32 supported = TRUE;
@@ -3464,28 +3861,12 @@ BOOL_32 SiAddrLib::IsEquationSupported(
 
         if ((supported == TRUE) && (m_chipFamily == ADDR_CHIP_FAMILY_SI))
         {
-            // Please refer to SiAddrLib::HwlSetupTileInfo for PRT tile index selecting
-            // Tile index 3, 6, 21-25 are for PRT single sample
-            if (tileIndex == 3)
-            {
-                supported = (bpp == 16);
-            }
-            else if (tileIndex == 6)
-            {
-                supported = (bpp == 32);
-            }
-            else if ((tileIndex >= 21) && (tileIndex <= 25))
-            {
-                supported = (bpp == 8u * (1u << (static_cast<UINT_32>(tileIndex) - 21u)));
-            }
-            else
-            {
-                supported = FALSE;
-            }
+            supported = m_EquationSupport[tileIndex][elementBytesLog2];
         }
     }
 
     return supported;
 }
 
-
+} // V1
+} // Addr