amdgpu/addrlib: Change to compute TC compatible stencil info
authorCarlos Xiong <clever.xiong@amd.com>
Tue, 10 Jun 2014 07:43:44 +0000 (03:43 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 30 Mar 2017 12:44:33 +0000 (14:44 +0200)
Change the logic to compute tc compatible stencil info via depth's
tileIndex instead of using depth's tileInfo. So the clients can get
the stencil's tileInfo computed from macroModeTable. If the stencil
tileInfo is same as depth tileInfo, then stencil is tc compatible;
otherwise, stencil is not tc compatible. The current suggestion is to
create another stencil buffer with the tc compatible tileInfo, use
depth-to-color copy to decompress and tile convert the rendered
stencil to tc compoatible stencil (And use the new stencil buffer to
program TC).

src/amd/addrlib/core/addrlib.cpp
src/amd/addrlib/r800/ciaddrlib.cpp

index 1df693e..b829eec 100644 (file)
@@ -542,6 +542,8 @@ ADDR_E_RETURNCODE AddrLib::ComputeSurfaceInfo(
                 {
                     ADDR_ASSERT(!IsMacroTiled(localIn.tileMode));
                 }
+
+                pOut->macroModeIndex = macroModeIndex;
             }
         }
 
index ae91e44..26c4e05 100644 (file)
@@ -1455,96 +1455,88 @@ INT_32 CiAddrLib::HwlComputeMacroModeIndex(
 {
     INT_32 macroModeIndex = TileIndexInvalid;
 
-    if (flags.tcCompatible && flags.stencil)
+    AddrTileMode tileMode = m_tileTable[tileIndex].mode;
+    AddrTileType tileType = m_tileTable[tileIndex].type;
+    UINT_32 thickness = ComputeSurfaceThickness(tileMode);
+
+    if (!IsMacroTiled(tileMode))
     {
-        // Don't compute macroModeIndex for tc compatible stencil surface
+        *pTileInfo = m_tileTable[tileIndex].info;
         macroModeIndex = TileIndexNoMacroIndex;
     }
     else
     {
-        AddrTileMode tileMode = m_tileTable[tileIndex].mode;
-        AddrTileType tileType = m_tileTable[tileIndex].type;
-        UINT_32 thickness = ComputeSurfaceThickness(tileMode);
+        UINT_32 tileBytes1x = BITS_TO_BYTES(bpp * MicroTilePixels * thickness);
+        UINT_32 tileSplit;
 
-        if (!IsMacroTiled(tileMode))
+        if (m_tileTable[tileIndex].type == ADDR_DEPTH_SAMPLE_ORDER)
         {
-            *pTileInfo = m_tileTable[tileIndex].info;
-            macroModeIndex = TileIndexNoMacroIndex;
+            // Depth entries store real tileSplitBytes
+            tileSplit = m_tileTable[tileIndex].info.tileSplitBytes;
         }
         else
         {
-            UINT_32 tileBytes1x = BITS_TO_BYTES(bpp * MicroTilePixels * thickness);
-            UINT_32 tileSplit;
+            // Non-depth entries store a split factor
+            UINT_32 sampleSplit = m_tileTable[tileIndex].info.tileSplitBytes;
+            UINT_32 colorTileSplit = Max(256u, sampleSplit * tileBytes1x);
 
-            if (m_tileTable[tileIndex].type == ADDR_DEPTH_SAMPLE_ORDER)
-            {
-                // Depth entries store real tileSplitBytes
-                tileSplit = m_tileTable[tileIndex].info.tileSplitBytes;
-            }
-            else
-            {
-                // Non-depth entries store a split factor
-                UINT_32 sampleSplit = m_tileTable[tileIndex].info.tileSplitBytes;
-                UINT_32 colorTileSplit = Max(256u, sampleSplit * tileBytes1x);
-
-                tileSplit = colorTileSplit;
-            }
-
-            UINT_32 tileSplitC = Min(m_rowSize, tileSplit);
-            UINT_32 tileBytes;
-
-            if (flags.fmask)
-            {
-                tileBytes = Min(tileSplitC, tileBytes1x);
-            }
-            else
-            {
-                tileBytes = Min(tileSplitC, numSamples * tileBytes1x);
-            }
+            tileSplit = colorTileSplit;
+        }
 
-            if (tileBytes < 64)
-            {
-                tileBytes = 64;
-            }
+        UINT_32 tileSplitC = Min(m_rowSize, tileSplit);
+        UINT_32 tileBytes;
 
-            macroModeIndex = Log2(tileBytes / 64);
+        if (flags.fmask)
+        {
+            tileBytes = Min(tileSplitC, tileBytes1x);
+        }
+        else
+        {
+            tileBytes = Min(tileSplitC, numSamples * tileBytes1x);
+        }
 
-            if (flags.prt || IsPrtTileMode(tileMode))
-            {
-                // Unknown - assume it is 1/2 of table size
-                const UINT_32 PrtMacroModeOffset = MacroTileTableSize / 2;
+        if (tileBytes < 64)
+        {
+            tileBytes = 64;
+        }
 
-                macroModeIndex += PrtMacroModeOffset;
-                *pTileInfo = m_macroTileTable[macroModeIndex];
-            }
-            else
-            {
-                *pTileInfo = m_macroTileTable[macroModeIndex];
-            }
+        macroModeIndex = Log2(tileBytes / 64);
 
-            pTileInfo->pipeConfig = m_tileTable[tileIndex].info.pipeConfig;
+        if (flags.prt || IsPrtTileMode(tileMode))
+        {
+            // Unknown - assume it is 1/2 of table size
+            const UINT_32 PrtMacroModeOffset = MacroTileTableSize / 2;
 
-            if (m_tileTable[tileIndex].type != ADDR_DEPTH_SAMPLE_ORDER)
-            {
-                pTileInfo->tileSplitBytes = tileSplitC;
-            }
-            else
-            {
-                pTileInfo->tileSplitBytes = m_tileTable[tileIndex].info.tileSplitBytes;
-            }
+            macroModeIndex += PrtMacroModeOffset;
+            *pTileInfo = m_macroTileTable[macroModeIndex];
         }
-
-        if (NULL != pTileMode)
+        else
         {
-            *pTileMode = tileMode;
+            *pTileInfo = m_macroTileTable[macroModeIndex];
         }
 
-        if (NULL != pTileType)
+        pTileInfo->pipeConfig = m_tileTable[tileIndex].info.pipeConfig;
+
+        if (m_tileTable[tileIndex].type != ADDR_DEPTH_SAMPLE_ORDER)
+        {
+            pTileInfo->tileSplitBytes = tileSplitC;
+        }
+        else
         {
-            *pTileType = tileType;
+            pTileInfo->tileSplitBytes = m_tileTable[tileIndex].info.tileSplitBytes;
         }
     }
 
+    if (NULL != pTileMode)
+    {
+        *pTileMode = tileMode;
+    }
+
+    if (NULL != pTileType)
+    {
+        *pTileType = tileType;
+    }
+
     return macroModeIndex;
 }