amd/addrlib: fix typo in api name.
[mesa.git] / src / amd / addrlib / r800 / siaddrlib.h
1 /*
2 * Copyright © 2014 Advanced Micro Devices, Inc.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
17 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 */
26
27 /**
28 ****************************************************************************************************
29 * @file siaddrlib.h
30 * @brief Contains the R800Lib class definition.
31 ****************************************************************************************************
32 */
33
34 #ifndef __SI_ADDR_LIB_H__
35 #define __SI_ADDR_LIB_H__
36
37 #include "addrlib1.h"
38 #include "egbaddrlib.h"
39
40 namespace Addr
41 {
42 namespace V1
43 {
44
45 /**
46 ****************************************************************************************************
47 * @brief Describes the information in tile mode table
48 ****************************************************************************************************
49 */
50 struct TileConfig
51 {
52 AddrTileMode mode;
53 AddrTileType type;
54 ADDR_TILEINFO info;
55 };
56
57 /**
58 ****************************************************************************************************
59 * @brief SI specific settings structure.
60 ****************************************************************************************************
61 */
62 struct SIChipSettings
63 {
64 struct
65 {
66 UINT_32 isSouthernIsland : 1;
67 UINT_32 isTahiti : 1;
68 UINT_32 isPitCairn : 1;
69 UINT_32 isCapeVerde : 1;
70 /// Oland/Hainan are of GFXIP 6.0, similar with SI
71 UINT_32 isOland : 1;
72 UINT_32 isHainan : 1;
73 };
74 };
75
76 /**
77 ****************************************************************************************************
78 * @brief This class is the SI specific address library
79 * function set.
80 ****************************************************************************************************
81 */
82 class SiLib : public EgBasedLib
83 {
84 public:
85 /// Creates SiLib object
86 static Addr::Lib* CreateObj(const Client* pClient)
87 {
88 VOID* pMem = Object::ClientAlloc(sizeof(SiLib), pClient);
89 return (pMem != NULL) ? new (pMem) SiLib(pClient) : NULL;
90 }
91
92 protected:
93 SiLib(const Client* pClient);
94 virtual ~SiLib();
95
96 // Hwl interface - defined in AddrLib1
97 virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfo(
98 const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn,
99 ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
100
101 virtual ADDR_E_RETURNCODE HwlConvertTileInfoToHW(
102 const ADDR_CONVERT_TILEINFOTOHW_INPUT* pIn,
103 ADDR_CONVERT_TILEINFOTOHW_OUTPUT* pOut) const;
104
105 virtual UINT_64 HwlComputeXmaskAddrFromCoord(
106 UINT_32 pitch, UINT_32 height, UINT_32 x, UINT_32 y, UINT_32 slice, UINT_32 numSlices,
107 UINT_32 factor, BOOL_32 isLinear, BOOL_32 isWidth8, BOOL_32 isHeight8,
108 ADDR_TILEINFO* pTileInfo, UINT_32* pBitPosition) const;
109
110 virtual VOID HwlComputeXmaskCoordFromAddr(
111 UINT_64 addr, UINT_32 bitPosition, UINT_32 pitch, UINT_32 height, UINT_32 numSlices,
112 UINT_32 factor, BOOL_32 isLinear, BOOL_32 isWidth8, BOOL_32 isHeight8,
113 ADDR_TILEINFO* pTileInfo, UINT_32* pX, UINT_32* pY, UINT_32* pSlice) const;
114
115 virtual ADDR_E_RETURNCODE HwlGetTileIndex(
116 const ADDR_GET_TILEINDEX_INPUT* pIn,
117 ADDR_GET_TILEINDEX_OUTPUT* pOut) const;
118
119 virtual BOOL_32 HwlComputeMipLevel(
120 ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn) const;
121
122 virtual ChipFamily HwlConvertChipFamily(
123 UINT_32 uChipFamily, UINT_32 uChipRevision);
124
125 virtual BOOL_32 HwlInitGlobalParams(
126 const ADDR_CREATE_INPUT* pCreateIn);
127
128 virtual ADDR_E_RETURNCODE HwlSetupTileCfg(
129 UINT_32 bpp, INT_32 index, INT_32 macroModeIndex,
130 ADDR_TILEINFO* pInfo, AddrTileMode* pMode = 0, AddrTileType* pType = 0) const;
131
132 virtual VOID HwlComputeTileDataWidthAndHeightLinear(
133 UINT_32* pMacroWidth, UINT_32* pMacroHeight,
134 UINT_32 bpp, ADDR_TILEINFO* pTileInfo) const;
135
136 virtual UINT_64 HwlComputeHtileBytes(
137 UINT_32 pitch, UINT_32 height, UINT_32 bpp,
138 BOOL_32 isLinear, UINT_32 numSlices, UINT_64* pSliceBytes, UINT_32 baseAlign) const;
139
140 virtual ADDR_E_RETURNCODE ComputeBankEquation(
141 UINT_32 log2BytesPP, UINT_32 threshX, UINT_32 threshY,
142 ADDR_TILEINFO* pTileInfo, ADDR_EQUATION* pEquation) const;
143
144 virtual ADDR_E_RETURNCODE ComputePipeEquation(
145 UINT_32 log2BytesPP, UINT_32 threshX, UINT_32 threshY,
146 ADDR_TILEINFO* pTileInfo, ADDR_EQUATION* pEquation) const;
147
148 virtual UINT_32 ComputePipeFromCoord(
149 UINT_32 x, UINT_32 y, UINT_32 slice,
150 AddrTileMode tileMode, UINT_32 pipeSwizzle, BOOL_32 ignoreSE,
151 ADDR_TILEINFO* pTileInfo) const;
152
153 virtual UINT_32 HwlGetPipes(const ADDR_TILEINFO* pTileInfo) const;
154
155 /// Pre-handler of 3x pitch (96 bit) adjustment
156 virtual UINT_32 HwlPreHandleBaseLvl3xPitch(
157 const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn, UINT_32 expPitch) const;
158 /// Post-handler of 3x pitch adjustment
159 virtual UINT_32 HwlPostHandleBaseLvl3xPitch(
160 const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn, UINT_32 expPitch) const;
161
162 /// Dummy function to finalize the inheritance
163 virtual UINT_32 HwlComputeXmaskCoordYFrom8Pipe(
164 UINT_32 pipe, UINT_32 x) const;
165
166 // Sub-hwl interface - defined in EgBasedLib
167 virtual VOID HwlSetupTileInfo(
168 AddrTileMode tileMode, ADDR_SURFACE_FLAGS flags,
169 UINT_32 bpp, UINT_32 pitch, UINT_32 height, UINT_32 numSamples,
170 ADDR_TILEINFO* inputTileInfo, ADDR_TILEINFO* outputTileInfo,
171 AddrTileType inTileType, ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
172
173 virtual UINT_32 HwlGetPitchAlignmentMicroTiled(
174 AddrTileMode tileMode, UINT_32 bpp, ADDR_SURFACE_FLAGS flags, UINT_32 numSamples) const;
175
176 virtual UINT_64 HwlGetSizeAdjustmentMicroTiled(
177 UINT_32 thickness, UINT_32 bpp, ADDR_SURFACE_FLAGS flags, UINT_32 numSamples,
178 UINT_32 baseAlign, UINT_32 pitchAlign,
179 UINT_32 *pPitch, UINT_32 *pHeight) const;
180
181 virtual VOID HwlCheckLastMacroTiledLvl(
182 const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn, ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
183
184 virtual BOOL_32 HwlTileInfoEqual(
185 const ADDR_TILEINFO* pLeft, const ADDR_TILEINFO* pRight) const;
186
187 virtual AddrTileMode HwlDegradeThickTileMode(
188 AddrTileMode baseTileMode, UINT_32 numSlices, UINT_32* pBytesPerTile) const;
189
190 virtual VOID HwlOverrideTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
191
192 virtual VOID HwlOptimizeTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
193
194 virtual VOID HwlSelectTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
195
196 /// Overwrite tile setting to PRT
197 virtual VOID HwlSetPrtTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
198
199 virtual BOOL_32 HwlSanityCheckMacroTiled(
200 ADDR_TILEINFO* pTileInfo) const
201 {
202 return TRUE;
203 }
204
205 virtual UINT_32 HwlGetPitchAlignmentLinear(UINT_32 bpp, ADDR_SURFACE_FLAGS flags) const;
206
207 virtual UINT_64 HwlGetSizeAdjustmentLinear(
208 AddrTileMode tileMode,
209 UINT_32 bpp, UINT_32 numSamples, UINT_32 baseAlign, UINT_32 pitchAlign,
210 UINT_32 *pPitch, UINT_32 *pHeight, UINT_32 *pHeightAlign) const;
211
212 virtual VOID HwlComputeSurfaceCoord2DFromBankPipe(
213 AddrTileMode tileMode, UINT_32* pX, UINT_32* pY, UINT_32 slice,
214 UINT_32 bank, UINT_32 pipe,
215 UINT_32 bankSwizzle, UINT_32 pipeSwizzle, UINT_32 tileSlices,
216 BOOL_32 ignoreSE,
217 ADDR_TILEINFO* pTileInfo) const;
218
219 virtual UINT_32 HwlPreAdjustBank(
220 UINT_32 tileX, UINT_32 bank, ADDR_TILEINFO* pTileInfo) const;
221
222 virtual INT_32 HwlPostCheckTileIndex(
223 const ADDR_TILEINFO* pInfo, AddrTileMode mode, AddrTileType type,
224 INT curIndex = TileIndexInvalid) const;
225
226 virtual VOID HwlFmaskPreThunkSurfInfo(
227 const ADDR_COMPUTE_FMASK_INFO_INPUT* pFmaskIn,
228 const ADDR_COMPUTE_FMASK_INFO_OUTPUT* pFmaskOut,
229 ADDR_COMPUTE_SURFACE_INFO_INPUT* pSurfIn,
230 ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pSurfOut) const;
231
232 virtual VOID HwlFmaskPostThunkSurfInfo(
233 const ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pSurfOut,
234 ADDR_COMPUTE_FMASK_INFO_OUTPUT* pFmaskOut) const;
235
236 virtual UINT_32 HwlComputeFmaskBits(
237 const ADDR_COMPUTE_FMASK_INFO_INPUT* pIn,
238 UINT_32* pNumSamples) const;
239
240 virtual BOOL_32 HwlReduceBankWidthHeight(
241 UINT_32 tileSize, UINT_32 bpp, ADDR_SURFACE_FLAGS flags, UINT_32 numSamples,
242 UINT_32 bankHeightAlign, UINT_32 pipes,
243 ADDR_TILEINFO* pTileInfo) const
244 {
245 return TRUE;
246 }
247
248 virtual ADDR_E_RETURNCODE HwlGetMaxAlignments(ADDR_GET_MAX_ALIGNMENTS_OUTPUT* pOut) const;
249
250 virtual VOID HwlComputeSurfaceAlignmentsMacroTiled(
251 AddrTileMode tileMode, UINT_32 bpp, ADDR_SURFACE_FLAGS flags,
252 UINT_32 mipLevel, UINT_32 numSamples, ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
253
254 // Get equation table pointer and number of equations
255 virtual UINT_32 HwlGetEquationTableInfo(const ADDR_EQUATION** ppEquationTable) const
256 {
257 *ppEquationTable = m_equationTable;
258
259 return m_numEquations;
260 }
261
262 // Check if it is supported for given bpp and tile config to generate an equation
263 BOOL_32 IsEquationSupported(
264 UINT_32 bpp, TileConfig tileConfig, INT_32 tileIndex, UINT_32 elementBytesLog2) const;
265
266 // Protected non-virtual functions
267 VOID ComputeTileCoordFromPipeAndElemIdx(
268 UINT_32 elemIdx, UINT_32 pipe, AddrPipeCfg pipeCfg, UINT_32 pitchInMacroTile,
269 UINT_32 x, UINT_32 y, UINT_32* pX, UINT_32* pY) const;
270
271 UINT_32 TileCoordToMaskElementIndex(
272 UINT_32 tx, UINT_32 ty, AddrPipeCfg pipeConfig,
273 UINT_32 *macroShift, UINT_32 *elemIdxBits) const;
274
275 BOOL_32 DecodeGbRegs(
276 const ADDR_REGISTER_VALUE* pRegValue);
277
278 const TileConfig* GetTileSetting(
279 UINT_32 index) const;
280
281 // Initialize equation table
282 VOID InitEquationTable();
283
284 UINT_32 GetPipePerSurf(AddrPipeCfg pipeConfig) const;
285
286 static const UINT_32 TileTableSize = 32;
287 TileConfig m_tileTable[TileTableSize];
288 UINT_32 m_noOfEntries;
289
290 // Max number of bpp (8bpp/16bpp/32bpp/64bpp/128bpp)
291 static const UINT_32 MaxNumElementBytes = 5;
292
293 static const BOOL_32 m_EquationSupport[TileTableSize][MaxNumElementBytes];
294
295 // Prt tile mode index mask
296 static const UINT_32 SiPrtTileIndexMask = ((1 << 3) | (1 << 5) | (1 << 6) | (1 << 7) |
297 (1 << 21) | (1 << 22) | (1 << 23) | (1 << 24) |
298 (1 << 25) | (1 << 30));
299
300 // More than half slots in tile mode table can't support equation
301 static const UINT_32 EquationTableSize = (MaxNumElementBytes * TileTableSize) / 2;
302 // Equation table
303 ADDR_EQUATION m_equationTable[EquationTableSize];
304 UINT_32 m_numMacroBits[EquationTableSize];
305 UINT_32 m_blockWidth[EquationTableSize];
306 UINT_32 m_blockHeight[EquationTableSize];
307 UINT_32 m_blockSlices[EquationTableSize];
308 // Number of equation entries in the table
309 UINT_32 m_numEquations;
310 // Equation lookup table according to bpp and tile index
311 UINT_32 m_equationLookupTable[MaxNumElementBytes][TileTableSize];
312
313 UINT_32 m_uncompressDepthEqIndex;
314
315 private:
316
317 VOID ReadGbTileMode(UINT_32 regValue, TileConfig* pCfg) const;
318 BOOL_32 InitTileSettingTable(const UINT_32 *pSetting, UINT_32 noOfEntries);
319
320 SIChipSettings m_settings;
321 };
322
323 } // V1
324 } // Addr
325
326 #endif
327