summaryrefslogtreecommitdiffstats
path: root/src/amd/addrlib/r800
diff options
context:
space:
mode:
authorFrans Gu <[email protected]>2015-08-17 23:56:23 -0400
committerMarek Olšák <[email protected]>2017-03-30 14:44:33 +0200
commitfe216415c69091ac27a10daafa3cd4ba0e205c6d (patch)
tree954e8b355bd45ad2d56f2fdb0cd8075070eed4cc /src/amd/addrlib/r800
parent4dd4700612adf7cb089eb667f265b7c55fd6fd7c (diff)
amdgpu/addrlib: Add new flags minimizePadding and maxBaseAlign
1) minimizePadding - Use 1D tile mode if padded size of 2D is bigger than 1D 2) maxBaseAlign - Force PRT tile mode if macro block size is bigger than requested alignment. Also, related changes to tile mode optimization for needEquation.
Diffstat (limited to 'src/amd/addrlib/r800')
-rw-r--r--src/amd/addrlib/r800/ciaddrlib.cpp152
-rw-r--r--src/amd/addrlib/r800/ciaddrlib.h5
-rw-r--r--src/amd/addrlib/r800/egbaddrlib.cpp58
-rw-r--r--src/amd/addrlib/r800/egbaddrlib.h5
-rw-r--r--src/amd/addrlib/r800/siaddrlib.cpp97
-rw-r--r--src/amd/addrlib/r800/siaddrlib.h5
6 files changed, 216 insertions, 106 deletions
diff --git a/src/amd/addrlib/r800/ciaddrlib.cpp b/src/amd/addrlib/r800/ciaddrlib.cpp
index ed7958d3223..7272c49affe 100644
--- a/src/amd/addrlib/r800/ciaddrlib.cpp
+++ b/src/amd/addrlib/r800/ciaddrlib.cpp
@@ -871,6 +871,76 @@ AddrTileMode CiLib::HwlDegradeThickTileMode(
/**
****************************************************************************************************
+* CiLib::HwlOptimizeTileMode
+*
+* @brief
+* Optimize tile mode on CI
+*
+* @return
+* N/A
+*
+****************************************************************************************************
+*/
+VOID CiLib::HwlOptimizeTileMode(
+ ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut ///< [in,out] input output structure
+ ) const
+{
+ AddrTileMode tileMode = pInOut->tileMode;
+
+ // Override 2D/3D macro tile mode to PRT_* tile mode if
+ // client driver requests this surface is equation compatible
+ if ((pInOut->flags.needEquation == TRUE) &&
+ (pInOut->numSamples <= 1) &&
+ (IsMacroTiled(tileMode) == TRUE) &&
+ (IsPrtTileMode(tileMode) == FALSE))
+ {
+ UINT_32 thickness = Thickness(tileMode);
+
+ if (pInOut->maxBaseAlign < Block64K)
+ {
+ tileMode = (thickness == 1) ? ADDR_TM_1D_TILED_THIN1 : ADDR_TM_1D_TILED_THICK;
+ }
+ else if (thickness == 1)
+ {
+ tileMode = ADDR_TM_PRT_TILED_THIN1;
+ }
+ else
+ {
+ static const UINT_32 PrtTileBytes = 0x10000;
+ // First prt thick tile index in the tile mode table
+ static const UINT_32 PrtThickTileIndex = 22;
+ ADDR_TILEINFO tileInfo = {0};
+
+ HwlComputeMacroModeIndex(PrtThickTileIndex,
+ pInOut->flags,
+ pInOut->bpp,
+ pInOut->numSamples,
+ &tileInfo);
+
+ UINT_32 macroTileBytes = ((pInOut->bpp) >> 3) * 64 * pInOut->numSamples *
+ thickness * HwlGetPipes(&tileInfo) *
+ tileInfo.banks * tileInfo.bankWidth *
+ tileInfo.bankHeight;
+
+ if (macroTileBytes <= PrtTileBytes)
+ {
+ tileMode = ADDR_TM_PRT_TILED_THICK;
+ }
+ else
+ {
+ tileMode = ADDR_TM_PRT_TILED_THIN1;
+ }
+ }
+ }
+
+ if (tileMode != pInOut->tileMode)
+ {
+ pInOut->tileMode = tileMode;
+ }
+}
+
+/**
+****************************************************************************************************
* CiLib::HwlOverrideTileMode
*
* @brief
@@ -981,48 +1051,6 @@ VOID CiLib::HwlOverrideTileMode(
}
}
- // Override 2D/3D macro tile mode to PRT_* tile mode if
- // client driver requests this surface is equation compatible
- if ((pInOut->flags.needEquation == TRUE) &&
- (pInOut->numSamples <= 1) &&
- (IsMacroTiled(tileMode) == TRUE) &&
- (IsPrtTileMode(tileMode) == FALSE))
- {
- UINT_32 thickness = Thickness(tileMode);
-
- if (thickness == 1)
- {
- tileMode = ADDR_TM_PRT_TILED_THIN1;
- }
- else
- {
- static const UINT_32 PrtTileBytes = 0x10000;
- // First prt thick tile index in the tile mode table
- static const UINT_32 PrtThickTileIndex = 22;
- ADDR_TILEINFO tileInfo = {0};
-
- HwlComputeMacroModeIndex(PrtThickTileIndex,
- pInOut->flags,
- pInOut->bpp,
- pInOut->numSamples,
- &tileInfo);
-
- UINT_32 macroTileBytes = ((pInOut->bpp) >> 3) * 64 * pInOut->numSamples *
- thickness * HwlGetPipes(&tileInfo) *
- tileInfo.banks * tileInfo.bankWidth *
- tileInfo.bankHeight;
-
- if (macroTileBytes <= PrtTileBytes)
- {
- tileMode = ADDR_TM_PRT_TILED_THICK;
- }
- else
- {
- tileMode = ADDR_TM_PRT_TILED_THIN1;
- }
- }
- }
-
if (tileMode != pInOut->tileMode)
{
pInOut->tileMode = tileMode;
@@ -1115,12 +1143,10 @@ VOID CiLib::HwlSelectTileMode(
(pInOut->flags.tcCompatible == FALSE))
{
pInOut->flags.opt4Space = TRUE;
+ pInOut->maxBaseAlign = Block64K;
// Optimize tile mode if possible
- if (OptimizeTileMode(pInOut, &tileMode))
- {
- pInOut->tileMode = tileMode;
- }
+ OptimizeTileMode(pInOut);
}
HwlOverrideTileMode(pInOut);
@@ -1128,6 +1154,40 @@ VOID CiLib::HwlSelectTileMode(
/**
****************************************************************************************************
+* CiLib::HwlSetPrtTileMode
+*
+* @brief
+* Set PRT tile mode.
+*
+* @return
+* N/A
+*
+****************************************************************************************************
+*/
+VOID CiLib::HwlSetPrtTileMode(
+ ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut ///< [in,out] input output structure
+ ) const
+{
+ AddrTileMode tileMode = pInOut->tileMode;
+ AddrTileType tileType = pInOut->tileType;
+
+ if (Thickness(tileMode) > 1)
+ {
+ tileMode = ADDR_TM_PRT_TILED_THICK;
+ tileType = (m_settings.isBonaire == TRUE) ? ADDR_NON_DISPLAYABLE : ADDR_THICK;
+ }
+ else
+ {
+ tileMode = ADDR_TM_PRT_TILED_THIN1;
+ tileType = (tileType == ADDR_THICK) ? ADDR_NON_DISPLAYABLE : tileType;
+ }
+
+ pInOut->tileMode = tileMode;
+ pInOut->tileType = tileType;
+}
+
+/**
+****************************************************************************************************
* CiLib::HwlSetupTileInfo
*
* @brief
diff --git a/src/amd/addrlib/r800/ciaddrlib.h b/src/amd/addrlib/r800/ciaddrlib.h
index f6c865536ce..7fa6b75e864 100644
--- a/src/amd/addrlib/r800/ciaddrlib.h
+++ b/src/amd/addrlib/r800/ciaddrlib.h
@@ -149,8 +149,13 @@ protected:
virtual VOID HwlOverrideTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
+ virtual VOID HwlOptimizeTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
+
virtual VOID HwlSelectTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
+ /// Overwrite tile setting to PRT
+ virtual VOID HwlSetPrtTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
+
virtual ADDR_E_RETURNCODE HwlComputeDccInfo(
const ADDR_COMPUTE_DCCINFO_INPUT* pIn,
ADDR_COMPUTE_DCCINFO_OUTPUT* pOut) const;
diff --git a/src/amd/addrlib/r800/egbaddrlib.cpp b/src/amd/addrlib/r800/egbaddrlib.cpp
index f413cfffda9..2d1123a3ccd 100644
--- a/src/amd/addrlib/r800/egbaddrlib.cpp
+++ b/src/amd/addrlib/r800/egbaddrlib.cpp
@@ -240,6 +240,18 @@ BOOL_32 EgBasedLib::ComputeSurfaceInfoLinear(
&pOut->pitchAlign,
&pOut->heightAlign);
+ if (pIn->pitchAlign != 0)
+ {
+ ADDR_ASSERT((pIn->pitchAlign % pOut->pitchAlign) == 0);
+ pOut->pitchAlign = pIn->pitchAlign;
+ }
+
+ if (pIn->heightAlign != 0)
+ {
+ ADDR_ASSERT((pIn->heightAlign % pOut->heightAlign) == 0);
+ pOut->heightAlign = pIn->heightAlign;
+ }
+
if ((pIn->tileMode == ADDR_TM_LINEAR_GENERAL) && pIn->flags.color && (pIn->height > 1))
{
#if !ALT_TEST
@@ -1139,17 +1151,20 @@ AddrTileMode EgBasedLib::ComputeSurfaceMipLevelTileMode(
/**
****************************************************************************************************
-* EgBasedLib::HwlDegradeBaseLevel
+* EgBasedLib::HwlGetAlignmentInfoMacroTiled
* @brief
-* Check if degrade is needed for base level
+* Get alignment info for giving tile mode
* @return
-* TRUE if degrade is suggested
+* TRUE if getting alignment is OK
****************************************************************************************************
*/
-BOOL_32 EgBasedLib::HwlDegradeBaseLevel(
- const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn) const
+BOOL_32 EgBasedLib::HwlGetAlignmentInfoMacroTiled(
+ const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn, ///< [in] create surface info
+ UINT_32* pPitchAlign, ///< [out] pitch alignment
+ UINT_32* pHeightAlign, ///< [out] height alignment
+ UINT_32* pSizeAlign ///< [out] size alignment
+ ) const
{
- BOOL_32 degrade = FALSE;
BOOL_32 valid = TRUE;
ADDR_ASSERT(IsMacroTiled(pIn->tileMode));
@@ -1159,6 +1174,7 @@ BOOL_32 EgBasedLib::HwlDegradeBaseLevel(
UINT_32 heightAlign;
UINT_32 macroTileWidth;
UINT_32 macroTileHeight;
+ UINT_32 numSamples = (pIn->numFrags == 0) ? pIn->numSamples : pIn->numFrags;
ADDR_ASSERT(pIn->pTileInfo);
ADDR_TILEINFO tileInfo = *pIn->pTileInfo;
@@ -1175,7 +1191,7 @@ BOOL_32 EgBasedLib::HwlDegradeBaseLevel(
pIn->bpp,
pIn->width,
pIn->height,
- pIn->numSamples,
+ numSamples,
&tileInfo,
&tileInfo,
pIn->tileType,
@@ -1185,7 +1201,7 @@ BOOL_32 EgBasedLib::HwlDegradeBaseLevel(
pIn->bpp,
pIn->flags,
pIn->mipLevel,
- pIn->numSamples,
+ numSamples,
&tileInfo,
&baseAlign,
&pitchAlign,
@@ -1195,30 +1211,12 @@ BOOL_32 EgBasedLib::HwlDegradeBaseLevel(
if (valid)
{
- degrade = ((pIn->width < macroTileWidth) || (pIn->height < macroTileHeight));
- // Check whether 2D tiling still has too much footprint
- if (degrade == FALSE)
- {
- // Only check width and height as slices are aligned to thickness
- UINT_64 unalignedSize = pIn->width * pIn->height;
-
- UINT_32 alignedPitch = PowTwoAlign(pIn->width, pitchAlign);
- UINT_32 alignedHeight = PowTwoAlign(pIn->height, heightAlign);
- UINT_64 alignedSize = alignedPitch * alignedHeight;
-
- // alignedSize > 1.5 * unalignedSize
- if (2 * alignedSize > 3 * unalignedSize)
- {
- degrade = TRUE;
- }
- }
- }
- else
- {
- degrade = TRUE;
+ *pPitchAlign = pitchAlign;
+ *pHeightAlign = heightAlign;
+ *pSizeAlign = baseAlign;
}
- return degrade;
+ return valid;
}
/**
diff --git a/src/amd/addrlib/r800/egbaddrlib.h b/src/amd/addrlib/r800/egbaddrlib.h
index 1a560033681..50fd3d927ad 100644
--- a/src/amd/addrlib/r800/egbaddrlib.h
+++ b/src/amd/addrlib/r800/egbaddrlib.h
@@ -137,8 +137,9 @@ protected:
const ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT* pIn,
ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT* pOut) const;
- virtual BOOL_32 HwlDegradeBaseLevel(
- const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn) const;
+ virtual BOOL_32 HwlGetAlignmentInfoMacroTiled(
+ const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn,
+ UINT_32* pPitchAlign, UINT_32* pHeightAlign, UINT_32* pSizeAlign) const;
virtual UINT_32 HwlComputeQbStereoRightSwizzle(
ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pInfo) const;
diff --git a/src/amd/addrlib/r800/siaddrlib.cpp b/src/amd/addrlib/r800/siaddrlib.cpp
index f8f937950ed..299951edc01 100644
--- a/src/amd/addrlib/r800/siaddrlib.cpp
+++ b/src/amd/addrlib/r800/siaddrlib.cpp
@@ -3135,6 +3135,52 @@ UINT_32 SiLib::HwlComputeFmaskBits(
/**
****************************************************************************************************
+* 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);
+
+ pInOut->flags.prt = TRUE;
+
+ 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
@@ -3173,28 +3219,6 @@ VOID SiLib::HwlOverrideTileMode(
break;
}
- if ((pInOut->flags.needEquation == TRUE) &&
- (IsMacroTiled(tileMode) == TRUE) &&
- (pInOut->numSamples <= 1))
- {
- UINT_32 thickness = Thickness(tileMode);
-
- pInOut->flags.prt = TRUE;
-
- 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;
@@ -3205,6 +3229,28 @@ VOID SiLib::HwlOverrideTileMode(
/**
****************************************************************************************************
+* 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
@@ -3271,10 +3317,7 @@ VOID SiLib::HwlSelectTileMode(
pInOut->flags.opt4Space = TRUE;
// Optimize tile mode if possible
- if (OptimizeTileMode(pInOut, &tileMode))
- {
- pInOut->tileMode = tileMode;
- }
+ OptimizeTileMode(pInOut);
HwlOverrideTileMode(pInOut);
}
@@ -3492,8 +3535,6 @@ VOID SiLib::InitEquationTable()
if (m_chipFamily == ADDR_CHIP_FAMILY_SI)
{
- static const UINT_32 PrtTileSize = 0x10000;
-
UINT_32 macroTileSize =
m_blockWidth[equationIndex] * m_blockHeight[equationIndex] *
bpp / 8;
diff --git a/src/amd/addrlib/r800/siaddrlib.h b/src/amd/addrlib/r800/siaddrlib.h
index 86d21167da7..53ec68ba06a 100644
--- a/src/amd/addrlib/r800/siaddrlib.h
+++ b/src/amd/addrlib/r800/siaddrlib.h
@@ -189,8 +189,13 @@ protected:
virtual VOID HwlOverrideTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
+ virtual VOID HwlOptimizeTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
+
virtual VOID HwlSelectTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
+ /// Overwrite tile setting to PRT
+ virtual VOID HwlSetPrtTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
+
virtual BOOL_32 HwlSanityCheckMacroTiled(
ADDR_TILEINFO* pTileInfo) const
{