amd/addrlib: update to the latest version
[mesa.git] / src / amd / addrlib / src / core / addrlib2.h
index fd433403d8260bb5b09542bb243061e87ef48fe8..75fe6442db8486857895333f22d68ffa8a466085 100644 (file)
@@ -68,6 +68,8 @@ struct SwizzleModeFlags
     UINT_32 isT             : 1;    // T mode
 
     UINT_32 isRtOpt         : 1;    // mode opt for render target
+
+    UINT_32 reserved        : 20;   // Reserved bits
 };
 
 struct Dim2d
@@ -87,25 +89,14 @@ struct Dim3d
 enum AddrBlockType
 {
     AddrBlockMicro     = 0, // Resource uses 256B block
-    AddrBlock4KB       = 1, // Resource uses 4KB block
-    AddrBlock64KB      = 2, // Resource uses 64KB block
-    AddrBlockVar       = 3, // Resource uses var block, only valid for GFX9
-    AddrBlockLinear    = 4, // Resource uses linear swizzle mode
-
-    AddrBlockMaxTiledType = AddrBlock64KB + 1,
-};
-
-enum AddrBlockSet
-{
-    AddrBlockSetMicro     = 1 << AddrBlockMicro,
-    AddrBlockSetMacro4KB  = 1 << AddrBlock4KB,
-    AddrBlockSetMacro64KB = 1 << AddrBlock64KB,
-    AddrBlockSetVar       = 1 << AddrBlockVar,
-    AddrBlockSetLinear    = 1 << AddrBlockLinear,
-
-    AddrBlockSetMacro   = AddrBlockSetMacro4KB | AddrBlockSetMacro64KB,
-    AddrBlockSet2dGfx10 = AddrBlockSetMicro    | AddrBlockSetMacro,
-    AddrBlockSet3dGfx10 = AddrBlockSetMacro,
+    AddrBlockThin4KB   = 1, // Resource uses thin 4KB block
+    AddrBlockThick4KB  = 2, // Resource uses thick 4KB block
+    AddrBlockThin64KB  = 3, // Resource uses thin 64KB block
+    AddrBlockThick64KB = 4, // Resource uses thick 64KB block
+    AddrBlockVar       = 5, // Resource uses var block, only valid for GFX9
+    AddrBlockLinear    = 6, // Resource uses linear swizzle mode
+
+    AddrBlockMaxTiledType = AddrBlockVar + 1,
 };
 
 enum AddrSwSet
@@ -115,11 +106,17 @@ enum AddrSwSet
     AddrSwSetD = 1 << ADDR_SW_D,
     AddrSwSetR = 1 << ADDR_SW_R,
 
-    AddrSwSetAll         = AddrSwSetZ | AddrSwSetS | AddrSwSetD | AddrSwSetR,
-    AddrSwSet3dThinGfx10 = AddrSwSetZ | AddrSwSetR,
-    AddrSwSetColorGfx10  = AddrSwSetS | AddrSwSetD | AddrSwSetR,
+    AddrSwSetAll = AddrSwSetZ | AddrSwSetS | AddrSwSetD | AddrSwSetR,
 };
 
+const UINT_32 Size256 = 256u;
+const UINT_32 Size4K  = 4096u;
+const UINT_32 Size64K = 65536u;
+
+const UINT_32 Log2Size256 = 8u;
+const UINT_32 Log2Size4K  = 12u;
+const UINT_32 Log2Size64K = 16u;
+
 /**
 ************************************************************************************************************************
 * @brief This class contains asic independent address lib functionalities
@@ -237,6 +234,15 @@ protected:
 
     static const UINT_32 MaxMipLevels = 16;
 
+    BOOL_32 IsValidSwMode(AddrSwizzleMode swizzleMode) const
+    {
+        // Don't dereference a reinterpret_cast pointer so as not to break
+        // strict-aliasing rules.
+        UINT_32 mode;
+        memcpy(&mode, &m_swizzleModeTable[swizzleMode], sizeof(UINT_32));
+        return mode != 0;
+    }
+
     // Checking block size
     BOOL_32 IsBlock256b(AddrSwizzleMode swizzleMode) const
     {
@@ -356,7 +362,7 @@ protected:
         {
             blockSizeLog2 = 16;
         }
-        else if (IsBlockVariable(swizzleMode))
+        else if (IsBlockVariable(swizzleMode) && (m_blockVarSizeLog2 != 0))
         {
             blockSizeLog2 = m_blockVarSizeLog2;
         }
@@ -653,12 +659,29 @@ protected:
         AddrSwizzleMode  swizzleMode) const;
 
     ADDR_E_RETURNCODE ComputeBlockDimension(
-        UINT_32*          pWidth,
-        UINT_32*          pHeight,
-        UINT_32*          pDepth,
-        UINT_32           bpp,
-        AddrResourceType  resourceType,
-        AddrSwizzleMode   swizzleMode) const;
+        UINT_32*         pWidth,
+        UINT_32*         pHeight,
+        UINT_32*         pDepth,
+        UINT_32          bpp,
+        AddrResourceType resourceType,
+        AddrSwizzleMode  swizzleMode) const;
+
+    virtual VOID ComputeThinBlockDimension(
+        UINT_32*         pWidth,
+        UINT_32*         pHeight,
+        UINT_32*         pDepth,
+        UINT_32          bpp,
+        UINT_32          numSamples,
+        AddrResourceType resourceType,
+        AddrSwizzleMode  swizzleMode) const;
+
+    VOID ComputeThickBlockDimension(
+        UINT_32*         pWidth,
+        UINT_32*         pHeight,
+        UINT_32*         pDepth,
+        UINT_32          bpp,
+        AddrResourceType resourceType,
+        AddrSwizzleMode  swizzleMode) const;
 
     static UINT_64 ComputePadSize(
         const Dim3d*      pBlkDim,
@@ -793,6 +816,11 @@ protected:
 
     VOID ComputeQbStereoInfo(ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
 
+    VOID FilterInvalidEqSwizzleMode(
+        ADDR2_SWMODE_SET& allowedSwModeSet,
+        AddrResourceType  resourceType,
+        UINT_32           elemLog2) const;
+
     UINT_32 m_se;                       ///< Number of shader engine
     UINT_32 m_rbPerSe;                  ///< Number of render backend per shader engine
     UINT_32 m_maxCompFrag;              ///< Number of max compressed fragment
@@ -809,6 +837,22 @@ protected:
 
     SwizzleModeFlags m_swizzleModeTable[ADDR_SW_MAX_TYPE];  ///< Swizzle mode table
 
+    // Max number of swizzle mode supported for equation
+    static const UINT_32    MaxSwModeType = 32;
+    // Max number of resource type (2D/3D) supported for equation
+    static const UINT_32    MaxRsrcType = 2;
+    // Max number of bpp (8bpp/16bpp/32bpp/64bpp/128bpp)
+    static const UINT_32    MaxElementBytesLog2  = 5;
+    // Almost all swizzle mode + resource type support equation
+    static const UINT_32    EquationTableSize = MaxElementBytesLog2 * MaxSwModeType * MaxRsrcType;
+    // Equation table
+    ADDR_EQUATION           m_equationTable[EquationTableSize];
+
+    // Number of equation entries in the table
+    UINT_32                 m_numEquations;
+    // Equation lookup table according to bpp and tile index
+    UINT_32                 m_equationLookupTable[MaxRsrcType][MaxSwModeType][MaxElementBytesLog2];
+
 private:
     // Disallow the copy constructor
     Lib(const Lib& a);