2 * Copyright © 2017 Advanced Micro Devices, Inc.
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:
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.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
28 ****************************************************************************************************
30 * @brief Contgfx9ns the Gfx9Lib class definition.
31 ****************************************************************************************************
34 #ifndef __GFX9_ADDR_LIB_H__
35 #define __GFX9_ADDR_LIB_H__
46 ****************************************************************************************************
47 * @brief GFX9 specific settings structure.
48 ****************************************************************************************************
50 struct Gfx9ChipSettings
54 // Asic/Generation name
55 UINT_32 isArcticIsland
: 1;
57 UINT_32 reserved0
: 30;
59 // Display engine IP version name
61 UINT_32 reserved1
: 31;
63 // Misc configuration bits
64 UINT_32 metaBaseAlignFix
: 1;
65 UINT_32 reserved2
: 31;
70 ****************************************************************************************************
71 * @brief GFX9 data surface type.
72 ****************************************************************************************************
82 ****************************************************************************************************
83 * @brief This class is the GFX9 specific address library
85 ****************************************************************************************************
87 class Gfx9Lib
: public Lib
90 /// Creates Gfx9Lib object
91 static Addr::Lib
* CreateObj(const Client
* pClient
)
93 VOID
* pMem
= Object::ClientAlloc(sizeof(Gfx9Lib
), pClient
);
94 return (pMem
!= NULL
) ? new (pMem
) Gfx9Lib(pClient
) : NULL
;
98 Gfx9Lib(const Client
* pClient
);
101 virtual ADDR_E_RETURNCODE
HwlComputeHtileInfo(
102 const ADDR2_COMPUTE_HTILE_INFO_INPUT
* pIn
,
103 ADDR2_COMPUTE_HTILE_INFO_OUTPUT
* pOut
) const;
105 virtual ADDR_E_RETURNCODE
HwlComputeCmaskInfo(
106 const ADDR2_COMPUTE_CMASK_INFO_INPUT
* pIn
,
107 ADDR2_COMPUTE_CMASK_INFO_OUTPUT
* pOut
) const;
109 virtual ADDR_E_RETURNCODE
HwlComputeDccInfo(
110 const ADDR2_COMPUTE_DCCINFO_INPUT
* pIn
,
111 ADDR2_COMPUTE_DCCINFO_OUTPUT
* pOut
) const;
113 virtual ADDR_E_RETURNCODE
HwlComputeCmaskAddrFromCoord(
114 const ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_INPUT
* pIn
,
115 ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT
* pOut
) const;
117 virtual ADDR_E_RETURNCODE
HwlComputeHtileAddrFromCoord(
118 const ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_INPUT
* pIn
,
119 ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT
* pOut
) const;
121 virtual ADDR_E_RETURNCODE
HwlComputeHtileCoordFromAddr(
122 const ADDR2_COMPUTE_HTILE_COORDFROMADDR_INPUT
* pIn
,
123 ADDR2_COMPUTE_HTILE_COORDFROMADDR_OUTPUT
* pOut
) const;
125 virtual UINT_32
HwlGetEquationIndex(
126 const ADDR2_COMPUTE_SURFACE_INFO_INPUT
* pIn
,
127 ADDR2_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
) const;
129 virtual ADDR_E_RETURNCODE
HwlComputeBlock256Equation(
130 AddrResourceType rsrcType
,
131 AddrSwizzleMode swMode
,
132 UINT_32 elementBytesLog2
,
133 ADDR_EQUATION
* pEquation
) const;
135 virtual ADDR_E_RETURNCODE
HwlComputeThinEquation(
136 AddrResourceType rsrcType
,
137 AddrSwizzleMode swMode
,
138 UINT_32 elementBytesLog2
,
139 ADDR_EQUATION
* pEquation
) const;
141 virtual ADDR_E_RETURNCODE
HwlComputeThickEquation(
142 AddrResourceType rsrcType
,
143 AddrSwizzleMode swMode
,
144 UINT_32 elementBytesLog2
,
145 ADDR_EQUATION
* pEquation
) const;
147 // Get equation table pointer and number of equations
148 virtual UINT_32
HwlGetEquationTableInfo(const ADDR_EQUATION
** ppEquationTable
) const
150 *ppEquationTable
= m_equationTable
;
152 return m_numEquations
;
155 virtual BOOL_32
IsEquationSupported(
156 AddrResourceType rsrcType
,
157 AddrSwizzleMode swMode
,
158 UINT_32 elementBytesLog2
) const;
160 virtual UINT_32
HwlComputeSurfaceBaseAlign(AddrSwizzleMode swizzleMode
) const
164 if (IsXor(swizzleMode
))
166 if (m_settings
.isVega10
)
168 baseAlign
= GetBlockSize(swizzleMode
);
172 UINT_32 blockSizeLog2
= GetBlockSizeLog2(swizzleMode
);
173 UINT_32 pipeBits
= GetPipeXorBits(blockSizeLog2
);
174 UINT_32 bankBits
= GetBankXorBits(blockSizeLog2
);
175 baseAlign
= 1 << (Min(blockSizeLog2
, m_pipeInterleaveLog2
+ pipeBits
+ bankBits
));
186 virtual BOOL_32
HwlIsValidDisplaySwizzleMode(const ADDR2_COMPUTE_SURFACE_INFO_INPUT
* pIn
) const;
188 virtual BOOL_32
HwlIsDce12() const { return m_settings
.isDce12
; }
190 // Initialize equation table
191 VOID
InitEquationTable();
193 // Max number of swizzle mode supported for equation
194 static const UINT_32 MaxSwMode
= 32;
195 // Max number of resource type (2D/3D) supported for equation
196 static const UINT_32 MaxRsrcType
= 2;
197 // Max number of bpp (8bpp/16bpp/32bpp/64bpp/128bpp)
198 static const UINT_32 MaxElementBytesLog2
= 5;
199 // Almost all swizzle mode + resource type support equation
200 static const UINT_32 EquationTableSize
= MaxElementBytesLog2
* MaxSwMode
* MaxRsrcType
;
202 ADDR_EQUATION m_equationTable
[EquationTableSize
];
204 // Number of equation entries in the table
205 UINT_32 m_numEquations
;
206 // Equation lookup table according to bpp and tile index
207 UINT_32 m_equationLookupTable
[MaxRsrcType
][MaxSwMode
][MaxElementBytesLog2
];
210 virtual ADDR_E_RETURNCODE
HwlGetMaxAlignments(
211 ADDR_GET_MAX_ALINGMENTS_OUTPUT
* pOut
) const;
213 virtual BOOL_32
HwlInitGlobalParams(
214 const ADDR_CREATE_INPUT
* pCreateIn
);
216 static VOID
GetRbEquation(CoordEq
* pRbEq
, UINT_32 rbPerSeLog2
, UINT_32 seLog2
);
218 VOID
GetDataEquation(CoordEq
* pDataEq
, Gfx9DataType dataSurfaceType
,
219 AddrSwizzleMode swizzleMode
, AddrResourceType resourceType
,
220 UINT_32 elementBytesLog2
, UINT_32 numSamplesLog2
) const;
222 VOID
GetPipeEquation(CoordEq
* pPipeEq
, CoordEq
* pDataEq
,
223 UINT_32 pipeInterleaveLog2
, UINT_32 numPipesLog2
,
224 UINT_32 numSamplesLog2
, Gfx9DataType dataSurfaceType
,
225 AddrSwizzleMode swizzleMode
, AddrResourceType resourceType
) const;
227 VOID
GetMetaEquation(CoordEq
* pMetaEq
, UINT_32 maxMip
,
228 UINT_32 elementBytesLog2
, UINT_32 numSamplesLog2
,
229 ADDR2_META_FLAGS metaFlag
, Gfx9DataType dataSurfaceType
,
230 AddrSwizzleMode swizzleMode
, AddrResourceType resourceType
,
231 UINT_32 metaBlkWidthLog2
, UINT_32 metaBlkHeightLog2
,
232 UINT_32 metaBlkDepthLog2
, UINT_32 compBlkWidthLog2
,
233 UINT_32 compBlkHeightLog2
, UINT_32 compBlkDepthLog2
) const;
235 virtual ChipFamily
HwlConvertChipFamily(UINT_32 uChipFamily
, UINT_32 uChipRevision
);
237 VOID
GetMetaMipInfo(UINT_32 numMipLevels
, Dim3d
* pMetaBlkDim
,
238 BOOL_32 dataThick
, ADDR2_META_MIP_INFO
* pInfo
,
239 UINT_32 mip0Width
, UINT_32 mip0Height
, UINT_32 mip0Depth
,
240 UINT_32
* pNumMetaBlkX
, UINT_32
* pNumMetaBlkY
, UINT_32
* pNumMetaBlkZ
) const;
242 Gfx9ChipSettings m_settings
;