1 /* 2 * Copyright © 2007-2019 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 gfx10addrlib.h 30 * @brief Contains the Gfx10Lib class definition. 31 ************************************************************************************************************************ 32 */ 33 34 #ifndef __GFX10_ADDR_LIB_H__ 35 #define __GFX10_ADDR_LIB_H__ 36 37 #include "addrlib2.h" 38 #include "coord.h" 39 #include "gfx10SwizzlePattern.h" 40 41 namespace Addr 42 { 43 namespace V2 44 { 45 46 /** 47 ************************************************************************************************************************ 48 * @brief GFX10 specific settings structure. 49 ************************************************************************************************************************ 50 */ 51 struct Gfx10ChipSettings 52 { 53 struct 54 { 55 UINT_32 reserved1 : 32; 56 57 // Misc configuration bits 58 UINT_32 isDcn20 : 1; // If using DCN2.0 59 UINT_32 supportRbPlus : 1; 60 UINT_32 dsMipmapHtileFix : 1; 61 UINT_32 dccUnsup3DSwDis : 1; 62 UINT_32 : 2; 63 UINT_32 reserved2 : 26; 64 }; 65 }; 66 67 /** 68 ************************************************************************************************************************ 69 * @brief GFX10 data surface type. 70 ************************************************************************************************************************ 71 */ 72 enum Gfx10DataType 73 { 74 Gfx10DataColor, 75 Gfx10DataDepthStencil, 76 Gfx10DataFmask 77 }; 78 79 const UINT_32 Gfx10LinearSwModeMask = (1u << ADDR_SW_LINEAR); 80 81 const UINT_32 Gfx10Blk256BSwModeMask = (1u << ADDR_SW_256B_S) | 82 (1u << ADDR_SW_256B_D); 83 84 const UINT_32 Gfx10Blk4KBSwModeMask = (1u << ADDR_SW_4KB_S) | 85 (1u << ADDR_SW_4KB_D) | 86 (1u << ADDR_SW_4KB_S_X) | 87 (1u << ADDR_SW_4KB_D_X); 88 89 const UINT_32 Gfx10Blk64KBSwModeMask = (1u << ADDR_SW_64KB_S) | 90 (1u << ADDR_SW_64KB_D) | 91 (1u << ADDR_SW_64KB_S_T) | 92 (1u << ADDR_SW_64KB_D_T) | 93 (1u << ADDR_SW_64KB_Z_X) | 94 (1u << ADDR_SW_64KB_S_X) | 95 (1u << ADDR_SW_64KB_D_X) | 96 (1u << ADDR_SW_64KB_R_X); 97 98 const UINT_32 Gfx10BlkVarSwModeMask = (1u << ADDR_SW_VAR_Z_X) | 99 (1u << ADDR_SW_VAR_R_X); 100 101 const UINT_32 Gfx10ZSwModeMask = (1u << ADDR_SW_64KB_Z_X) | 102 (1u << ADDR_SW_VAR_Z_X); 103 104 const UINT_32 Gfx10StandardSwModeMask = (1u << ADDR_SW_256B_S) | 105 (1u << ADDR_SW_4KB_S) | 106 (1u << ADDR_SW_64KB_S) | 107 (1u << ADDR_SW_64KB_S_T) | 108 (1u << ADDR_SW_4KB_S_X) | 109 (1u << ADDR_SW_64KB_S_X); 110 111 const UINT_32 Gfx10DisplaySwModeMask = (1u << ADDR_SW_256B_D) | 112 (1u << ADDR_SW_4KB_D) | 113 (1u << ADDR_SW_64KB_D) | 114 (1u << ADDR_SW_64KB_D_T) | 115 (1u << ADDR_SW_4KB_D_X) | 116 (1u << ADDR_SW_64KB_D_X); 117 118 const UINT_32 Gfx10RenderSwModeMask = (1u << ADDR_SW_64KB_R_X) | 119 (1u << ADDR_SW_VAR_R_X); 120 121 const UINT_32 Gfx10XSwModeMask = (1u << ADDR_SW_4KB_S_X) | 122 (1u << ADDR_SW_4KB_D_X) | 123 (1u << ADDR_SW_64KB_Z_X) | 124 (1u << ADDR_SW_64KB_S_X) | 125 (1u << ADDR_SW_64KB_D_X) | 126 (1u << ADDR_SW_64KB_R_X) | 127 Gfx10BlkVarSwModeMask; 128 129 const UINT_32 Gfx10TSwModeMask = (1u << ADDR_SW_64KB_S_T) | 130 (1u << ADDR_SW_64KB_D_T); 131 132 const UINT_32 Gfx10XorSwModeMask = Gfx10XSwModeMask | 133 Gfx10TSwModeMask; 134 135 const UINT_32 Gfx10Rsrc1dSwModeMask = Gfx10LinearSwModeMask | 136 Gfx10RenderSwModeMask | 137 Gfx10ZSwModeMask; 138 139 const UINT_32 Gfx10Rsrc2dSwModeMask = Gfx10LinearSwModeMask | 140 Gfx10Blk256BSwModeMask | 141 Gfx10Blk4KBSwModeMask | 142 Gfx10Blk64KBSwModeMask | 143 Gfx10BlkVarSwModeMask; 144 145 const UINT_32 Gfx10Rsrc3dSwModeMask = (1u << ADDR_SW_LINEAR) | 146 (1u << ADDR_SW_4KB_S) | 147 (1u << ADDR_SW_64KB_S) | 148 (1u << ADDR_SW_64KB_S_T) | 149 (1u << ADDR_SW_4KB_S_X) | 150 (1u << ADDR_SW_64KB_Z_X) | 151 (1u << ADDR_SW_64KB_S_X) | 152 (1u << ADDR_SW_64KB_D_X) | 153 (1u << ADDR_SW_64KB_R_X) | 154 Gfx10BlkVarSwModeMask; 155 156 const UINT_32 Gfx10Rsrc2dPrtSwModeMask = (Gfx10Blk4KBSwModeMask | Gfx10Blk64KBSwModeMask) & ~Gfx10XSwModeMask; 157 158 const UINT_32 Gfx10Rsrc3dPrtSwModeMask = Gfx10Rsrc2dPrtSwModeMask & ~Gfx10DisplaySwModeMask; 159 160 const UINT_32 Gfx10Rsrc3dThin64KBSwModeMask = (1u << ADDR_SW_64KB_Z_X) | 161 (1u << ADDR_SW_64KB_R_X); 162 163 const UINT_32 Gfx10Rsrc3dThinSwModeMask = Gfx10Rsrc3dThin64KBSwModeMask | Gfx10BlkVarSwModeMask; 164 165 const UINT_32 Gfx10Rsrc3dThickSwModeMask = Gfx10Rsrc3dSwModeMask & ~(Gfx10Rsrc3dThinSwModeMask | Gfx10LinearSwModeMask); 166 167 const UINT_32 Gfx10Rsrc3dThick4KBSwModeMask = Gfx10Rsrc3dThickSwModeMask & Gfx10Blk4KBSwModeMask; 168 169 const UINT_32 Gfx10Rsrc3dThick64KBSwModeMask = Gfx10Rsrc3dThickSwModeMask & Gfx10Blk64KBSwModeMask; 170 171 const UINT_32 Gfx10MsaaSwModeMask = Gfx10ZSwModeMask | 172 Gfx10RenderSwModeMask; 173 174 const UINT_32 Dcn20NonBpp64SwModeMask = (1u << ADDR_SW_LINEAR) | 175 (1u << ADDR_SW_4KB_S) | 176 (1u << ADDR_SW_64KB_S) | 177 (1u << ADDR_SW_64KB_S_T) | 178 (1u << ADDR_SW_4KB_S_X) | 179 (1u << ADDR_SW_64KB_S_X) | 180 (1u << ADDR_SW_64KB_R_X); 181 182 const UINT_32 Dcn20Bpp64SwModeMask = (1u << ADDR_SW_4KB_D) | 183 (1u << ADDR_SW_64KB_D) | 184 (1u << ADDR_SW_64KB_D_T) | 185 (1u << ADDR_SW_4KB_D_X) | 186 (1u << ADDR_SW_64KB_D_X) | 187 Dcn20NonBpp64SwModeMask; 188 189 const UINT_32 Dcn21NonBpp64SwModeMask = (1u << ADDR_SW_LINEAR) | 190 (1u << ADDR_SW_64KB_S) | 191 (1u << ADDR_SW_64KB_S_T) | 192 (1u << ADDR_SW_64KB_S_X) | 193 (1u << ADDR_SW_64KB_R_X); 194 195 const UINT_32 Dcn21Bpp64SwModeMask = (1u << ADDR_SW_64KB_D) | 196 (1u << ADDR_SW_64KB_D_T) | 197 (1u << ADDR_SW_64KB_D_X) | 198 Dcn21NonBpp64SwModeMask; 199 200 /** 201 ************************************************************************************************************************ 202 * @brief This class is the GFX10 specific address library 203 * function set. 204 ************************************************************************************************************************ 205 */ 206 class Gfx10Lib : public Lib 207 { 208 public: 209 /// Creates Gfx10Lib object CreateObj(const Client * pClient)210 static Addr::Lib* CreateObj(const Client* pClient) 211 { 212 VOID* pMem = Object::ClientAlloc(sizeof(Gfx10Lib), pClient); 213 return (pMem != NULL) ? new (pMem) Gfx10Lib(pClient) : NULL; 214 } 215 216 protected: 217 Gfx10Lib(const Client* pClient); 218 virtual ~Gfx10Lib(); 219 HwlIsStandardSwizzle(AddrResourceType resourceType,AddrSwizzleMode swizzleMode)220 virtual BOOL_32 HwlIsStandardSwizzle( 221 AddrResourceType resourceType, 222 AddrSwizzleMode swizzleMode) const 223 { 224 return m_swizzleModeTable[swizzleMode].isStd; 225 } 226 HwlIsDisplaySwizzle(AddrResourceType resourceType,AddrSwizzleMode swizzleMode)227 virtual BOOL_32 HwlIsDisplaySwizzle( 228 AddrResourceType resourceType, 229 AddrSwizzleMode swizzleMode) const 230 { 231 return m_swizzleModeTable[swizzleMode].isDisp; 232 } 233 HwlIsThin(AddrResourceType resourceType,AddrSwizzleMode swizzleMode)234 virtual BOOL_32 HwlIsThin( 235 AddrResourceType resourceType, 236 AddrSwizzleMode swizzleMode) const 237 { 238 return ((IsTex1d(resourceType) == TRUE) || 239 (IsTex2d(resourceType) == TRUE) || 240 ((IsTex3d(resourceType) == TRUE) && 241 (m_swizzleModeTable[swizzleMode].isStd == FALSE) && 242 (m_swizzleModeTable[swizzleMode].isDisp == FALSE))); 243 } 244 HwlIsThick(AddrResourceType resourceType,AddrSwizzleMode swizzleMode)245 virtual BOOL_32 HwlIsThick( 246 AddrResourceType resourceType, 247 AddrSwizzleMode swizzleMode) const 248 { 249 return ((IsTex3d(resourceType) == TRUE) && 250 (m_swizzleModeTable[swizzleMode].isStd || m_swizzleModeTable[swizzleMode].isDisp)); 251 } 252 253 virtual ADDR_E_RETURNCODE HwlComputeHtileInfo( 254 const ADDR2_COMPUTE_HTILE_INFO_INPUT* pIn, 255 ADDR2_COMPUTE_HTILE_INFO_OUTPUT* pOut) const; 256 257 virtual ADDR_E_RETURNCODE HwlComputeCmaskInfo( 258 const ADDR2_COMPUTE_CMASK_INFO_INPUT* pIn, 259 ADDR2_COMPUTE_CMASK_INFO_OUTPUT* pOut) const; 260 261 virtual ADDR_E_RETURNCODE HwlComputeDccInfo( 262 const ADDR2_COMPUTE_DCCINFO_INPUT* pIn, 263 ADDR2_COMPUTE_DCCINFO_OUTPUT* pOut) const; 264 265 virtual ADDR_E_RETURNCODE HwlComputeCmaskAddrFromCoord( 266 const ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_INPUT* pIn, 267 ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT* pOut); 268 269 virtual ADDR_E_RETURNCODE HwlComputeHtileAddrFromCoord( 270 const ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_INPUT* pIn, 271 ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT* pOut); 272 273 virtual ADDR_E_RETURNCODE HwlComputeHtileCoordFromAddr( 274 const ADDR2_COMPUTE_HTILE_COORDFROMADDR_INPUT* pIn, 275 ADDR2_COMPUTE_HTILE_COORDFROMADDR_OUTPUT* pOut); 276 277 virtual ADDR_E_RETURNCODE HwlSupportComputeDccAddrFromCoord( 278 const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT* pIn); 279 280 virtual VOID HwlComputeDccAddrFromCoord( 281 const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT* pIn, 282 ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT* pOut); 283 284 virtual UINT_32 HwlGetEquationIndex( 285 const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 286 ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const; 287 HwlGetEquationTableInfo(const ADDR_EQUATION ** ppEquationTable)288 virtual UINT_32 HwlGetEquationTableInfo(const ADDR_EQUATION** ppEquationTable) const 289 { 290 *ppEquationTable = m_equationTable; 291 292 return m_numEquations; 293 } 294 295 virtual ADDR_E_RETURNCODE HwlComputePipeBankXor( 296 const ADDR2_COMPUTE_PIPEBANKXOR_INPUT* pIn, 297 ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT* pOut) const; 298 299 virtual ADDR_E_RETURNCODE HwlComputeSlicePipeBankXor( 300 const ADDR2_COMPUTE_SLICE_PIPEBANKXOR_INPUT* pIn, 301 ADDR2_COMPUTE_SLICE_PIPEBANKXOR_OUTPUT* pOut) const; 302 303 virtual ADDR_E_RETURNCODE HwlComputeSubResourceOffsetForSwizzlePattern( 304 const ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_INPUT* pIn, 305 ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_OUTPUT* pOut) const; 306 307 virtual ADDR_E_RETURNCODE HwlComputeNonBlockCompressedView( 308 const ADDR2_COMPUTE_NONBLOCKCOMPRESSEDVIEW_INPUT* pIn, 309 ADDR2_COMPUTE_NONBLOCKCOMPRESSEDVIEW_OUTPUT* pOut) const; 310 311 virtual ADDR_E_RETURNCODE HwlGetPreferredSurfaceSetting( 312 const ADDR2_GET_PREFERRED_SURF_SETTING_INPUT* pIn, 313 ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT* pOut) const; 314 315 virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfoSanityCheck( 316 const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const; 317 318 virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfoTiled( 319 const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 320 ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const; 321 322 virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfoLinear( 323 const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 324 ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const; 325 326 virtual ADDR_E_RETURNCODE HwlComputeSurfaceAddrFromCoordTiled( 327 const ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn, 328 ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT* pOut) const; 329 330 virtual UINT_32 HwlComputeMaxBaseAlignments() const; 331 332 virtual UINT_32 HwlComputeMaxMetaBaseAlignments() const; 333 334 virtual BOOL_32 HwlInitGlobalParams(const ADDR_CREATE_INPUT* pCreateIn); 335 336 virtual ChipFamily HwlConvertChipFamily(UINT_32 uChipFamily, UINT_32 uChipRevision); 337 338 private: 339 // Initialize equation table 340 VOID InitEquationTable(); 341 342 ADDR_E_RETURNCODE ComputeSurfaceInfoMacroTiled( 343 const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 344 ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const; 345 346 ADDR_E_RETURNCODE ComputeSurfaceInfoMicroTiled( 347 const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 348 ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const; 349 350 ADDR_E_RETURNCODE ComputeSurfaceAddrFromCoordMacroTiled( 351 const ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn, 352 ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT* pOut) const; 353 354 ADDR_E_RETURNCODE ComputeSurfaceAddrFromCoordMicroTiled( 355 const ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn, 356 ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT* pOut) const; 357 358 359 UINT_32 ComputeOffsetFromSwizzlePattern( 360 const UINT_64* pPattern, 361 UINT_32 numBits, 362 UINT_32 x, 363 UINT_32 y, 364 UINT_32 z, 365 UINT_32 s) const; 366 367 UINT_32 ComputeOffsetFromEquation( 368 const ADDR_EQUATION* pEq, 369 UINT_32 x, 370 UINT_32 y, 371 UINT_32 z) const; 372 373 ADDR_E_RETURNCODE ComputeStereoInfo( 374 const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 375 UINT_32* pAlignY, 376 UINT_32* pRightXor) const; 377 378 static void GetMipSize( 379 UINT_32 mip0Width, 380 UINT_32 mip0Height, 381 UINT_32 mip0Depth, 382 UINT_32 mipId, 383 UINT_32* pMipWidth, 384 UINT_32* pMipHeight, 385 UINT_32* pMipDepth = NULL) 386 { 387 *pMipWidth = ShiftCeil(Max(mip0Width, 1u), mipId); 388 *pMipHeight = ShiftCeil(Max(mip0Height, 1u), mipId); 389 390 if (pMipDepth != NULL) 391 { 392 *pMipDepth = ShiftCeil(Max(mip0Depth, 1u), mipId); 393 } 394 } 395 396 const ADDR_SW_PATINFO* GetSwizzlePatternInfo( 397 AddrSwizzleMode swizzleMode, 398 AddrResourceType resourceType, 399 UINT_32 log2Elem, 400 UINT_32 numFrag) const; 401 GetSwizzlePatternFromPatternInfo(const ADDR_SW_PATINFO * pPatInfo,ADDR_BIT_SETTING (& pSwizzle)[20])402 VOID GetSwizzlePatternFromPatternInfo( 403 const ADDR_SW_PATINFO* pPatInfo, 404 ADDR_BIT_SETTING (&pSwizzle)[20]) const 405 { 406 memcpy(pSwizzle, 407 GFX10_SW_PATTERN_NIBBLE01[pPatInfo->nibble01Idx], 408 sizeof(GFX10_SW_PATTERN_NIBBLE01[pPatInfo->nibble01Idx])); 409 410 memcpy(&pSwizzle[8], 411 GFX10_SW_PATTERN_NIBBLE2[pPatInfo->nibble2Idx], 412 sizeof(GFX10_SW_PATTERN_NIBBLE2[pPatInfo->nibble2Idx])); 413 414 memcpy(&pSwizzle[12], 415 GFX10_SW_PATTERN_NIBBLE3[pPatInfo->nibble3Idx], 416 sizeof(GFX10_SW_PATTERN_NIBBLE3[pPatInfo->nibble3Idx])); 417 418 memcpy(&pSwizzle[16], 419 GFX10_SW_PATTERN_NIBBLE4[pPatInfo->nibble4Idx], 420 sizeof(GFX10_SW_PATTERN_NIBBLE4[pPatInfo->nibble4Idx])); 421 } 422 423 VOID ConvertSwizzlePatternToEquation( 424 UINT_32 elemLog2, 425 AddrResourceType rsrcType, 426 AddrSwizzleMode swMode, 427 const ADDR_SW_PATINFO* pPatInfo, 428 ADDR_EQUATION* pEquation) const; 429 430 static INT_32 GetMetaElementSizeLog2(Gfx10DataType dataType); 431 432 static INT_32 GetMetaCacheSizeLog2(Gfx10DataType dataType); 433 434 void GetBlk256SizeLog2( 435 AddrResourceType resourceType, 436 AddrSwizzleMode swizzleMode, 437 UINT_32 elemLog2, 438 UINT_32 numSamplesLog2, 439 Dim3d* pBlock) const; 440 441 void GetCompressedBlockSizeLog2( 442 Gfx10DataType dataType, 443 AddrResourceType resourceType, 444 AddrSwizzleMode swizzleMode, 445 UINT_32 elemLog2, 446 UINT_32 numSamplesLog2, 447 Dim3d* pBlock) const; 448 449 INT_32 GetMetaOverlapLog2( 450 Gfx10DataType dataType, 451 AddrResourceType resourceType, 452 AddrSwizzleMode swizzleMode, 453 UINT_32 elemLog2, 454 UINT_32 numSamplesLog2) const; 455 456 INT_32 Get3DMetaOverlapLog2( 457 AddrResourceType resourceType, 458 AddrSwizzleMode swizzleMode, 459 UINT_32 elemLog2) const; 460 461 UINT_32 GetMetaBlkSize( 462 Gfx10DataType dataType, 463 AddrResourceType resourceType, 464 AddrSwizzleMode swizzleMode, 465 UINT_32 elemLog2, 466 UINT_32 numSamplesLog2, 467 BOOL_32 pipeAlign, 468 Dim3d* pBlock) const; 469 470 INT_32 GetPipeRotateAmount( 471 AddrResourceType resourceType, 472 AddrSwizzleMode swizzleMode) const; 473 GetEffectiveNumPipes()474 INT_32 GetEffectiveNumPipes() const 475 { 476 return ((m_settings.supportRbPlus == FALSE) || 477 ((m_numSaLog2 + 1) >= m_pipesLog2)) ? m_pipesLog2 : m_numSaLog2 + 1; 478 } 479 IsRbAligned(AddrResourceType resourceType,AddrSwizzleMode swizzleMode)480 BOOL_32 IsRbAligned( 481 AddrResourceType resourceType, 482 AddrSwizzleMode swizzleMode) const 483 { 484 const BOOL_32 isRtopt = IsRtOptSwizzle(swizzleMode); 485 const BOOL_32 isZ = IsZOrderSwizzle(swizzleMode); 486 const BOOL_32 isDisplay = IsDisplaySwizzle(swizzleMode); 487 488 return (IsTex2d(resourceType) && (isRtopt || isZ)) || 489 (IsTex3d(resourceType) && isDisplay); 490 491 } 492 493 UINT_32 GetValidDisplaySwizzleModes(UINT_32 bpp) const; 494 495 BOOL_32 IsValidDisplaySwizzleMode(const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const; 496 497 UINT_32 GetMaxNumMipsInTail(UINT_32 blockSizeLog2, BOOL_32 isThin) const; 498 GetAllowedBlockSet(ADDR2_SWMODE_SET allowedSwModeSet,AddrResourceType rsrcType)499 static ADDR2_BLOCK_SET GetAllowedBlockSet(ADDR2_SWMODE_SET allowedSwModeSet, AddrResourceType rsrcType) 500 { 501 ADDR2_BLOCK_SET allowedBlockSet = {}; 502 503 allowedBlockSet.micro = (allowedSwModeSet.value & Gfx10Blk256BSwModeMask) ? TRUE : FALSE; 504 allowedBlockSet.linear = (allowedSwModeSet.value & Gfx10LinearSwModeMask) ? TRUE : FALSE; 505 allowedBlockSet.var = (allowedSwModeSet.value & Gfx10BlkVarSwModeMask) ? TRUE : FALSE; 506 507 if (rsrcType == ADDR_RSRC_TEX_3D) 508 { 509 allowedBlockSet.macroThick4KB = (allowedSwModeSet.value & Gfx10Rsrc3dThick4KBSwModeMask) ? TRUE : FALSE; 510 allowedBlockSet.macroThin64KB = (allowedSwModeSet.value & Gfx10Rsrc3dThin64KBSwModeMask) ? TRUE : FALSE; 511 allowedBlockSet.macroThick64KB = (allowedSwModeSet.value & Gfx10Rsrc3dThick64KBSwModeMask) ? TRUE : FALSE; 512 } 513 else 514 { 515 allowedBlockSet.macroThin4KB = (allowedSwModeSet.value & Gfx10Blk4KBSwModeMask) ? TRUE : FALSE; 516 allowedBlockSet.macroThin64KB = (allowedSwModeSet.value & Gfx10Blk64KBSwModeMask) ? TRUE : FALSE; 517 } 518 519 return allowedBlockSet; 520 } 521 GetAllowedSwSet(ADDR2_SWMODE_SET allowedSwModeSet)522 static ADDR2_SWTYPE_SET GetAllowedSwSet(ADDR2_SWMODE_SET allowedSwModeSet) 523 { 524 ADDR2_SWTYPE_SET allowedSwSet = {}; 525 526 allowedSwSet.sw_Z = (allowedSwModeSet.value & Gfx10ZSwModeMask) ? TRUE : FALSE; 527 allowedSwSet.sw_S = (allowedSwModeSet.value & Gfx10StandardSwModeMask) ? TRUE : FALSE; 528 allowedSwSet.sw_D = (allowedSwModeSet.value & Gfx10DisplaySwModeMask) ? TRUE : FALSE; 529 allowedSwSet.sw_R = (allowedSwModeSet.value & Gfx10RenderSwModeMask) ? TRUE : FALSE; 530 531 return allowedSwSet; 532 } 533 IsInMipTail(Dim3d mipTailDim,UINT_32 maxNumMipsInTail,UINT_32 mipWidth,UINT_32 mipHeight,UINT_32 numMipsToTheEnd)534 BOOL_32 IsInMipTail( 535 Dim3d mipTailDim, 536 UINT_32 maxNumMipsInTail, 537 UINT_32 mipWidth, 538 UINT_32 mipHeight, 539 UINT_32 numMipsToTheEnd) const 540 { 541 BOOL_32 inTail = ((mipWidth <= mipTailDim.w) && 542 (mipHeight <= mipTailDim.h) && 543 (numMipsToTheEnd <= maxNumMipsInTail)); 544 545 return inTail; 546 } 547 GetBankXorBits(UINT_32 blockBits)548 UINT_32 GetBankXorBits(UINT_32 blockBits) const 549 { 550 return (blockBits > m_pipeInterleaveLog2 + m_pipesLog2 + ColumnBits) ? 551 Min(blockBits - m_pipeInterleaveLog2 - m_pipesLog2 - ColumnBits, BankBits) : 0; 552 } 553 554 BOOL_32 ValidateNonSwModeParams(const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const; 555 BOOL_32 ValidateSwModeParams(const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const; 556 557 static const UINT_32 ColumnBits = 2; 558 static const UINT_32 BankBits = 4; 559 static const UINT_32 UnalignedDccType = 3; 560 561 static const Dim3d Block256_3d[MaxNumOfBpp]; 562 static const Dim3d Block64K_Log2_3d[MaxNumOfBpp]; 563 static const Dim3d Block4K_Log2_3d[MaxNumOfBpp]; 564 565 static const SwizzleModeFlags SwizzleModeTable[ADDR_SW_MAX_TYPE]; 566 567 // Number of packers log2 568 UINT_32 m_numPkrLog2; 569 // Number of shader array log2 570 UINT_32 m_numSaLog2; 571 572 Gfx10ChipSettings m_settings; 573 574 UINT_32 m_colorBaseIndex; 575 UINT_32 m_xmaskBaseIndex; 576 UINT_32 m_dccBaseIndex; 577 }; 578 579 } // V2 580 } // Addr 581 582 #endif 583 584