• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  ciaddrlib.h
30 * @brief Contains the CiLib class definition.
31 ****************************************************************************************************
32 */
33 
34 #ifndef __CI_ADDR_LIB_H__
35 #define __CI_ADDR_LIB_H__
36 
37 #include "addrlib1.h"
38 #include "siaddrlib.h"
39 
40 namespace Addr
41 {
42 namespace V1
43 {
44 
45 /**
46 ****************************************************************************************************
47 * @brief This class is the CI specific address library
48 *        function set.
49 ****************************************************************************************************
50 */
51 class CiLib : public SiLib
52 {
53 public:
54     /// Creates CiLib object
CreateObj(const Client * pClient)55     static Addr::Lib* CreateObj(const Client* pClient)
56     {
57         VOID* pMem = Object::ClientAlloc(sizeof(CiLib), pClient);
58         return (pMem != NULL) ? new (pMem) CiLib(pClient) : NULL;
59     }
60 
61 private:
62     CiLib(const Client* pClient);
63     virtual ~CiLib();
64 
65 protected:
66 
67     // Hwl interface - defined in AddrLib1
68     virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfo(
69         const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn,
70         ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
71 
72     virtual ADDR_E_RETURNCODE HwlComputeFmaskInfo(
73         const ADDR_COMPUTE_FMASK_INFO_INPUT* pIn,
74         ADDR_COMPUTE_FMASK_INFO_OUTPUT* pOut);
75 
76     virtual ChipFamily HwlConvertChipFamily(
77         UINT_32 uChipFamily, UINT_32 uChipRevision);
78 
79     virtual BOOL_32 HwlInitGlobalParams(
80         const ADDR_CREATE_INPUT* pCreateIn);
81 
82     virtual ADDR_E_RETURNCODE HwlSetupTileCfg(
83         UINT_32 bpp, INT_32 index, INT_32 macroModeIndex, ADDR_TILEINFO* pInfo,
84         AddrTileMode* pMode = 0, AddrTileType* pType = 0) const;
85 
86     virtual VOID HwlComputeTileDataWidthAndHeightLinear(
87         UINT_32* pMacroWidth, UINT_32* pMacroHeight,
88         UINT_32 bpp, ADDR_TILEINFO* pTileInfo) const;
89 
90     virtual INT_32 HwlComputeMacroModeIndex(
91         INT_32 tileIndex, ADDR_SURFACE_FLAGS flags, UINT_32 bpp, UINT_32 numSamples,
92         ADDR_TILEINFO* pTileInfo, AddrTileMode* pTileMode = NULL, AddrTileType* pTileType = NULL
93         ) const;
94 
95     // Sub-hwl interface - defined in EgBasedLib
96     virtual VOID HwlSetupTileInfo(
97         AddrTileMode tileMode, ADDR_SURFACE_FLAGS flags,
98         UINT_32 bpp, UINT_32 pitch, UINT_32 height, UINT_32 numSamples,
99         ADDR_TILEINFO* inputTileInfo, ADDR_TILEINFO* outputTileInfo,
100         AddrTileType inTileType, ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
101 
102     virtual INT_32 HwlPostCheckTileIndex(
103         const ADDR_TILEINFO* pInfo, AddrTileMode mode, AddrTileType type,
104         INT curIndex = TileIndexInvalid) const;
105 
106     virtual VOID HwlFmaskPreThunkSurfInfo(
107         const ADDR_COMPUTE_FMASK_INFO_INPUT* pFmaskIn,
108         const ADDR_COMPUTE_FMASK_INFO_OUTPUT* pFmaskOut,
109         ADDR_COMPUTE_SURFACE_INFO_INPUT* pSurfIn,
110         ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pSurfOut) const;
111 
112     virtual VOID HwlFmaskPostThunkSurfInfo(
113         const ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pSurfOut,
114         ADDR_COMPUTE_FMASK_INFO_OUTPUT* pFmaskOut) const;
115 
116     virtual AddrTileMode HwlDegradeThickTileMode(
117         AddrTileMode baseTileMode, UINT_32 numSlices, UINT_32* pBytesPerTile) const;
118 
119     virtual VOID HwlOverrideTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
120 
121     virtual VOID HwlOptimizeTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
122 
123     virtual VOID HwlSelectTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
124 
125     /// Overwrite tile setting to PRT
126     virtual VOID HwlSetPrtTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const;
127 
128     virtual ADDR_E_RETURNCODE HwlComputeDccInfo(
129         const ADDR_COMPUTE_DCCINFO_INPUT* pIn,
130         ADDR_COMPUTE_DCCINFO_OUTPUT* pOut) const;
131 
132     virtual ADDR_E_RETURNCODE HwlComputeCmaskAddrFromCoord(
133         const ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT* pIn,
134         ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT* pOut) const;
135 
136     virtual ADDR_E_RETURNCODE HwlComputeHtileAddrFromCoord(
137         const ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT*  pIn,
138         ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT*       pOut) const;
139 
140     virtual ADDR_E_RETURNCODE HwlGetMaxAlignments(ADDR_GET_MAX_ALIGNMENTS_OUTPUT* pOut) const;
141 
142     virtual VOID HwlPadDimensions(
143         AddrTileMode tileMode, UINT_32 bpp, ADDR_SURFACE_FLAGS flags,
144         UINT_32 numSamples, ADDR_TILEINFO* pTileInfo, UINT_32 mipLevel,
145         UINT_32* pPitch, UINT_32 *PitchAlign, UINT_32 height, UINT_32 heightAlign) const;
146 
147     virtual VOID HwlComputeSurfaceAlignmentsMacroTiled(
148         AddrTileMode tileMode, UINT_32 bpp, ADDR_SURFACE_FLAGS flags,
149         UINT_32 mipLevel, UINT_32 numSamples, ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
150 
151 private:
152     VOID ReadGbTileMode(
153         UINT_32 regValue, TileConfig* pCfg) const;
154 
155     VOID ReadGbMacroTileCfg(
156         UINT_32 regValue, ADDR_TILEINFO* pCfg) const;
157 
158     BOOL_32 InitTileSettingTable(
159         const UINT_32 *pSetting, UINT_32 noOfEntries);
160 
161     BOOL_32 InitMacroTileCfgTable(
162         const UINT_32 *pSetting, UINT_32 noOfEntries);
163 
164     UINT_64 HwlComputeMetadataNibbleAddress(
165         UINT_64 uncompressedDataByteAddress,
166         UINT_64 dataBaseByteAddress,
167         UINT_64 metadataBaseByteAddress,
168         UINT_32 metadataBitSize,
169         UINT_32 elementBitSize,
170         UINT_32 blockByteSize,
171         UINT_32 pipeInterleaveBytes,
172         UINT_32 numOfPipes,
173         UINT_32 numOfBanks,
174         UINT_32 numOfSamplesPerSplit) const;
175 
176     BOOL_32 DepthStencilTileCfgMatch(
177         const ADDR_COMPUTE_SURFACE_INFO_INPUT*  pIn,
178         ADDR_COMPUTE_SURFACE_INFO_OUTPUT*       pOut) const;
179 
180     BOOL_32 CheckTcCompatibility(const ADDR_TILEINFO* pTileInfo, UINT_32 bpp, AddrTileMode tileMode,
181                                  AddrTileType tileType, const ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
182 
183     static const UINT_32    MacroTileTableSize = 16;
184     static const UINT_32    PrtMacroModeOffset = MacroTileTableSize / 2;
185     static const INT_32     MinDepth2DThinIndex = 0;
186     static const INT_32     MaxDepth2DThinIndex = 4;
187     static const INT_32     Depth1DThinIndex = 5;
188 
189     ADDR_TILEINFO           m_macroTileTable[MacroTileTableSize];
190     UINT_32                 m_noOfMacroEntries;
191     BOOL_32                 m_allowNonDispThickModes;
192 };
193 
194 } // V1
195 } // Addr
196 
197 #endif
198 
199 
200