• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 ************************************************************************************************************************
3 *
4 *  Copyright (C) 2007-2022 Advanced Micro Devices, Inc.  All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE
23 *
24 ***********************************************************************************************************************/
25 
26 /**
27 ****************************************************************************************************
28 * @file  ciaddrlib.h
29 * @brief Contains the CiLib class definition.
30 ****************************************************************************************************
31 */
32 
33 #ifndef __CI_ADDR_LIB_H__
34 #define __CI_ADDR_LIB_H__
35 
36 #include "addrlib1.h"
37 #include "siaddrlib.h"
38 
39 namespace Addr
40 {
41 namespace V1
42 {
43 
44 /**
45 ****************************************************************************************************
46 * @brief This class is the CI specific address library
47 *        function set.
48 ****************************************************************************************************
49 */
50 class CiLib : public SiLib
51 {
52 public:
53     /// Creates CiLib object
CreateObj(const Client * pClient)54     static Addr::Lib* CreateObj(const Client* pClient)
55     {
56         VOID* pMem = Object::ClientAlloc(sizeof(CiLib), pClient);
57         return (pMem != NULL) ? new (pMem) CiLib(pClient) : NULL;
58     }
59 
60 private:
61     CiLib(const Client* pClient);
62     virtual ~CiLib();
63 
64 protected:
65 
66     // Hwl interface - defined in AddrLib1
67     virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfo(
68         const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn,
69         ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
70 
71     virtual ADDR_E_RETURNCODE HwlComputeFmaskInfo(
72         const ADDR_COMPUTE_FMASK_INFO_INPUT* pIn,
73         ADDR_COMPUTE_FMASK_INFO_OUTPUT* pOut);
74 
75     virtual ChipFamily HwlConvertChipFamily(
76         UINT_32 uChipFamily, UINT_32 uChipRevision);
77 
78     virtual BOOL_32 HwlInitGlobalParams(
79         const ADDR_CREATE_INPUT* pCreateIn);
80 
81     virtual ADDR_E_RETURNCODE HwlSetupTileCfg(
82         UINT_32 bpp, INT_32 index, INT_32 macroModeIndex, ADDR_TILEINFO* pInfo,
83         AddrTileMode* pMode = 0, AddrTileType* pType = 0) const;
84 
85     virtual VOID HwlComputeTileDataWidthAndHeightLinear(
86         UINT_32* pMacroWidth, UINT_32* pMacroHeight,
87         UINT_32 bpp, ADDR_TILEINFO* pTileInfo) const;
88 
89     virtual INT_32 HwlComputeMacroModeIndex(
90         INT_32 tileIndex, ADDR_SURFACE_FLAGS flags, UINT_32 bpp, UINT_32 numSamples,
91         ADDR_TILEINFO* pTileInfo, AddrTileMode* pTileMode = NULL, AddrTileType* pTileType = NULL
92         ) const;
93 
94     // Sub-hwl interface - defined in EgBasedLib
95     virtual VOID HwlSetupTileInfo(
96         AddrTileMode tileMode, ADDR_SURFACE_FLAGS flags,
97         UINT_32 bpp, UINT_32 pitch, UINT_32 height, UINT_32 numSamples,
98         ADDR_TILEINFO* inputTileInfo, ADDR_TILEINFO* outputTileInfo,
99         AddrTileType inTileType, ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
100 
101     virtual INT_32 HwlPostCheckTileIndex(
102         const ADDR_TILEINFO* pInfo, AddrTileMode mode, AddrTileType type,
103         INT curIndex = TileIndexInvalid) const;
104 
105     virtual VOID HwlFmaskPreThunkSurfInfo(
106         const ADDR_COMPUTE_FMASK_INFO_INPUT* pFmaskIn,
107         const ADDR_COMPUTE_FMASK_INFO_OUTPUT* pFmaskOut,
108         ADDR_COMPUTE_SURFACE_INFO_INPUT* pSurfIn,
109         ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pSurfOut) const;
110 
111     virtual VOID HwlFmaskPostThunkSurfInfo(
112         const ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pSurfOut,
113         ADDR_COMPUTE_FMASK_INFO_OUTPUT* pFmaskOut) const;
114 
115     virtual AddrTileMode HwlDegradeThickTileMode(
116         AddrTileMode baseTileMode, UINT_32 numSlices, UINT_32* pBytesPerTile) const;
117 
118     virtual VOID HwlOverrideTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
119 
120     virtual VOID HwlOptimizeTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
121 
122     virtual VOID HwlSelectTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
123 
124     /// Overwrite tile setting to PRT
125     virtual VOID HwlSetPrtTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
126 
127     virtual ADDR_E_RETURNCODE HwlComputeDccInfo(
128         const ADDR_COMPUTE_DCCINFO_INPUT* pIn,
129         ADDR_COMPUTE_DCCINFO_OUTPUT* pOut) const;
130 
131     virtual ADDR_E_RETURNCODE HwlComputeCmaskAddrFromCoord(
132         const ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT* pIn,
133         ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT* pOut) const;
134 
135     virtual ADDR_E_RETURNCODE HwlComputeHtileAddrFromCoord(
136         const ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT*  pIn,
137         ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT*       pOut) const;
138 
139     virtual UINT_32 HwlComputeMaxBaseAlignments() const;
140 
141     virtual UINT_32 HwlComputeMaxMetaBaseAlignments() const;
142 
143     virtual VOID HwlPadDimensions(
144         AddrTileMode tileMode, UINT_32 bpp, ADDR_SURFACE_FLAGS flags,
145         UINT_32 numSamples, ADDR_TILEINFO* pTileInfo, UINT_32 mipLevel,
146         UINT_32* pPitch, UINT_32 *PitchAlign, UINT_32 height, UINT_32 heightAlign) const;
147 
148     virtual VOID HwlComputeSurfaceAlignmentsMacroTiled(
149         AddrTileMode tileMode, UINT_32 bpp, ADDR_SURFACE_FLAGS flags,
150         UINT_32 mipLevel, UINT_32 numSamples, ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
151 
152 private:
153     VOID ReadGbTileMode(
154         UINT_32 regValue, TileConfig* pCfg) const;
155 
156     VOID ReadGbMacroTileCfg(
157         UINT_32 regValue, ADDR_TILEINFO* pCfg) const;
158 
159 private:
160     BOOL_32 InitTileSettingTable(
161         const UINT_32 *pSetting, UINT_32 noOfEntries);
162 
163     BOOL_32 InitMacroTileCfgTable(
164         const UINT_32 *pSetting, UINT_32 noOfEntries);
165 
166     UINT_64 HwlComputeMetadataNibbleAddress(
167         UINT_64 uncompressedDataByteAddress,
168         UINT_64 dataBaseByteAddress,
169         UINT_64 metadataBaseByteAddress,
170         UINT_32 metadataBitSize,
171         UINT_32 elementBitSize,
172         UINT_32 blockByteSize,
173         UINT_32 pipeInterleaveBytes,
174         UINT_32 numOfPipes,
175         UINT_32 numOfBanks,
176         UINT_32 numOfSamplesPerSplit) const;
177 
178     BOOL_32 DepthStencilTileCfgMatch(
179         const ADDR_COMPUTE_SURFACE_INFO_INPUT*  pIn,
180         ADDR_COMPUTE_SURFACE_INFO_OUTPUT*       pOut) const;
181 
182     BOOL_32 CheckTcCompatibility(const ADDR_TILEINFO* pTileInfo, UINT_32 bpp, AddrTileMode tileMode,
183                                  AddrTileType tileType, const ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
184 
SupportDccAndTcCompatibility()185     BOOL_32 SupportDccAndTcCompatibility() const
186     {
187         return ((m_settings.isVolcanicIslands == TRUE) || (m_configFlags.forceDccAndTcCompat == TRUE));
188     }
189 
AltTilingEnabled()190     BOOL_32 AltTilingEnabled() const
191     {
192         return (m_configFlags.enableAltTiling == TRUE);
193     }
194 
195     static const UINT_32    MacroTileTableSize = 16;
196     static const UINT_32    PrtMacroModeOffset = MacroTileTableSize / 2;
197     static const INT_32     MinDepth2DThinIndex = 0;
198     static const INT_32     MaxDepth2DThinIndex = 4;
199     static const INT_32     Depth1DThinIndex = 5;
200 
201     ADDR_TILEINFO           m_macroTileTable[MacroTileTableSize];
202     UINT_32                 m_noOfMacroEntries;
203     BOOL_32                 m_allowNonDispThickModes;
204 };
205 
206 } // V1
207 } // Addr
208 
209 #endif
210 
211 
212