1b8e80941Smrg/* 2b8e80941Smrg * Copyright © 2007-2018 Advanced Micro Devices, Inc. 3b8e80941Smrg * All Rights Reserved. 4b8e80941Smrg * 5b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining 6b8e80941Smrg * a copy of this software and associated documentation files (the 7b8e80941Smrg * "Software"), to deal in the Software without restriction, including 8b8e80941Smrg * without limitation the rights to use, copy, modify, merge, publish, 9b8e80941Smrg * distribute, sub license, and/or sell copies of the Software, and to 10b8e80941Smrg * permit persons to whom the Software is furnished to do so, subject to 11b8e80941Smrg * the following conditions: 12b8e80941Smrg * 13b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14b8e80941Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15b8e80941Smrg * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16b8e80941Smrg * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS 17b8e80941Smrg * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19b8e80941Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20b8e80941Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 21b8e80941Smrg * 22b8e80941Smrg * The above copyright notice and this permission notice (including the 23b8e80941Smrg * next paragraph) shall be included in all copies or substantial portions 24b8e80941Smrg * of the Software. 25b8e80941Smrg */ 26b8e80941Smrg 27b8e80941Smrg/** 28b8e80941Smrg************************************************************************************************************************ 29b8e80941Smrg* @file gfx9addrlib.h 30b8e80941Smrg* @brief Contgfx9ns the Gfx9Lib class definition. 31b8e80941Smrg************************************************************************************************************************ 32b8e80941Smrg*/ 33b8e80941Smrg 34b8e80941Smrg#ifndef __GFX9_ADDR_LIB_H__ 35b8e80941Smrg#define __GFX9_ADDR_LIB_H__ 36b8e80941Smrg 37b8e80941Smrg#include "addrlib2.h" 38b8e80941Smrg#include "coord.h" 39b8e80941Smrg 40b8e80941Smrgnamespace Addr 41b8e80941Smrg{ 42b8e80941Smrgnamespace V2 43b8e80941Smrg{ 44b8e80941Smrg 45b8e80941Smrg/** 46b8e80941Smrg************************************************************************************************************************ 47b8e80941Smrg* @brief GFX9 specific settings structure. 48b8e80941Smrg************************************************************************************************************************ 49b8e80941Smrg*/ 50b8e80941Smrgstruct Gfx9ChipSettings 51b8e80941Smrg{ 52b8e80941Smrg struct 53b8e80941Smrg { 54b8e80941Smrg // Asic/Generation name 55b8e80941Smrg UINT_32 isArcticIsland : 1; 56b8e80941Smrg UINT_32 isVega10 : 1; 57b8e80941Smrg UINT_32 isRaven : 1; 58b8e80941Smrg UINT_32 isVega12 : 1; 59b8e80941Smrg UINT_32 isVega20 : 1; 60b8e80941Smrg UINT_32 reserved0 : 27; 61b8e80941Smrg 62b8e80941Smrg // Display engine IP version name 63b8e80941Smrg UINT_32 isDce12 : 1; 64b8e80941Smrg UINT_32 isDcn1 : 1; 65b8e80941Smrg 66b8e80941Smrg // Misc configuration bits 67b8e80941Smrg UINT_32 metaBaseAlignFix : 1; 68b8e80941Smrg UINT_32 depthPipeXorDisable : 1; 69b8e80941Smrg UINT_32 htileAlignFix : 1; 70b8e80941Smrg UINT_32 applyAliasFix : 1; 71b8e80941Smrg UINT_32 htileCacheRbConflict: 1; 72b8e80941Smrg UINT_32 reserved2 : 27; 73b8e80941Smrg }; 74b8e80941Smrg}; 75b8e80941Smrg 76b8e80941Smrg/** 77b8e80941Smrg************************************************************************************************************************ 78b8e80941Smrg* @brief GFX9 data surface type. 79b8e80941Smrg************************************************************************************************************************ 80b8e80941Smrg*/ 81b8e80941Smrgenum Gfx9DataType 82b8e80941Smrg{ 83b8e80941Smrg Gfx9DataColor, 84b8e80941Smrg Gfx9DataDepthStencil, 85b8e80941Smrg Gfx9DataFmask 86b8e80941Smrg}; 87b8e80941Smrg 88b8e80941Smrgconst UINT_32 Gfx9LinearSwModeMask = (1u << ADDR_SW_LINEAR); 89b8e80941Smrg 90b8e80941Smrgconst UINT_32 Gfx9Blk256BSwModeMask = (1u << ADDR_SW_256B_S) | 91b8e80941Smrg (1u << ADDR_SW_256B_D) | 92b8e80941Smrg (1u << ADDR_SW_256B_R); 93b8e80941Smrg 94b8e80941Smrgconst UINT_32 Gfx9Blk4KBSwModeMask = (1u << ADDR_SW_4KB_Z) | 95b8e80941Smrg (1u << ADDR_SW_4KB_S) | 96b8e80941Smrg (1u << ADDR_SW_4KB_D) | 97b8e80941Smrg (1u << ADDR_SW_4KB_R) | 98b8e80941Smrg (1u << ADDR_SW_4KB_Z_X) | 99b8e80941Smrg (1u << ADDR_SW_4KB_S_X) | 100b8e80941Smrg (1u << ADDR_SW_4KB_D_X) | 101b8e80941Smrg (1u << ADDR_SW_4KB_R_X); 102b8e80941Smrg 103b8e80941Smrgconst UINT_32 Gfx9Blk64KBSwModeMask = (1u << ADDR_SW_64KB_Z) | 104b8e80941Smrg (1u << ADDR_SW_64KB_S) | 105b8e80941Smrg (1u << ADDR_SW_64KB_D) | 106b8e80941Smrg (1u << ADDR_SW_64KB_R) | 107b8e80941Smrg (1u << ADDR_SW_64KB_Z_T) | 108b8e80941Smrg (1u << ADDR_SW_64KB_S_T) | 109b8e80941Smrg (1u << ADDR_SW_64KB_D_T) | 110b8e80941Smrg (1u << ADDR_SW_64KB_R_T) | 111b8e80941Smrg (1u << ADDR_SW_64KB_Z_X) | 112b8e80941Smrg (1u << ADDR_SW_64KB_S_X) | 113b8e80941Smrg (1u << ADDR_SW_64KB_D_X) | 114b8e80941Smrg (1u << ADDR_SW_64KB_R_X); 115b8e80941Smrg 116b8e80941Smrgconst UINT_32 Gfx9BlkVarSwModeMask = (1u << ADDR_SW_VAR_Z) | 117b8e80941Smrg (1u << ADDR_SW_VAR_S) | 118b8e80941Smrg (1u << ADDR_SW_VAR_D) | 119b8e80941Smrg (1u << ADDR_SW_VAR_R) | 120b8e80941Smrg (1u << ADDR_SW_VAR_Z_X) | 121b8e80941Smrg (1u << ADDR_SW_VAR_S_X) | 122b8e80941Smrg (1u << ADDR_SW_VAR_D_X) | 123b8e80941Smrg (1u << ADDR_SW_VAR_R_X); 124b8e80941Smrg 125b8e80941Smrgconst UINT_32 Gfx9ZSwModeMask = (1u << ADDR_SW_4KB_Z) | 126b8e80941Smrg (1u << ADDR_SW_64KB_Z) | 127b8e80941Smrg (1u << ADDR_SW_VAR_Z) | 128b8e80941Smrg (1u << ADDR_SW_64KB_Z_T) | 129b8e80941Smrg (1u << ADDR_SW_4KB_Z_X) | 130b8e80941Smrg (1u << ADDR_SW_64KB_Z_X) | 131b8e80941Smrg (1u << ADDR_SW_VAR_Z_X); 132b8e80941Smrg 133b8e80941Smrgconst UINT_32 Gfx9StandardSwModeMask = (1u << ADDR_SW_256B_S) | 134b8e80941Smrg (1u << ADDR_SW_4KB_S) | 135b8e80941Smrg (1u << ADDR_SW_64KB_S) | 136b8e80941Smrg (1u << ADDR_SW_VAR_S) | 137b8e80941Smrg (1u << ADDR_SW_64KB_S_T) | 138b8e80941Smrg (1u << ADDR_SW_4KB_S_X) | 139b8e80941Smrg (1u << ADDR_SW_64KB_S_X) | 140b8e80941Smrg (1u << ADDR_SW_VAR_S_X); 141b8e80941Smrg 142b8e80941Smrgconst UINT_32 Gfx9DisplaySwModeMask = (1u << ADDR_SW_256B_D) | 143b8e80941Smrg (1u << ADDR_SW_4KB_D) | 144b8e80941Smrg (1u << ADDR_SW_64KB_D) | 145b8e80941Smrg (1u << ADDR_SW_VAR_D) | 146b8e80941Smrg (1u << ADDR_SW_64KB_D_T) | 147b8e80941Smrg (1u << ADDR_SW_4KB_D_X) | 148b8e80941Smrg (1u << ADDR_SW_64KB_D_X) | 149b8e80941Smrg (1u << ADDR_SW_VAR_D_X); 150b8e80941Smrg 151b8e80941Smrgconst UINT_32 Gfx9RotateSwModeMask = (1u << ADDR_SW_256B_R) | 152b8e80941Smrg (1u << ADDR_SW_4KB_R) | 153b8e80941Smrg (1u << ADDR_SW_64KB_R) | 154b8e80941Smrg (1u << ADDR_SW_VAR_R) | 155b8e80941Smrg (1u << ADDR_SW_64KB_R_T) | 156b8e80941Smrg (1u << ADDR_SW_4KB_R_X) | 157b8e80941Smrg (1u << ADDR_SW_64KB_R_X) | 158b8e80941Smrg (1u << ADDR_SW_VAR_R_X); 159b8e80941Smrg 160b8e80941Smrgconst UINT_32 Gfx9XSwModeMask = (1u << ADDR_SW_4KB_Z_X) | 161b8e80941Smrg (1u << ADDR_SW_4KB_S_X) | 162b8e80941Smrg (1u << ADDR_SW_4KB_D_X) | 163b8e80941Smrg (1u << ADDR_SW_4KB_R_X) | 164b8e80941Smrg (1u << ADDR_SW_64KB_Z_X) | 165b8e80941Smrg (1u << ADDR_SW_64KB_S_X) | 166b8e80941Smrg (1u << ADDR_SW_64KB_D_X) | 167b8e80941Smrg (1u << ADDR_SW_64KB_R_X) | 168b8e80941Smrg (1u << ADDR_SW_VAR_Z_X) | 169b8e80941Smrg (1u << ADDR_SW_VAR_S_X) | 170b8e80941Smrg (1u << ADDR_SW_VAR_D_X) | 171b8e80941Smrg (1u << ADDR_SW_VAR_R_X); 172b8e80941Smrg 173b8e80941Smrgconst UINT_32 Gfx9TSwModeMask = (1u << ADDR_SW_64KB_Z_T) | 174b8e80941Smrg (1u << ADDR_SW_64KB_S_T) | 175b8e80941Smrg (1u << ADDR_SW_64KB_D_T) | 176b8e80941Smrg (1u << ADDR_SW_64KB_R_T); 177b8e80941Smrg 178b8e80941Smrgconst UINT_32 Gfx9XorSwModeMask = Gfx9XSwModeMask | 179b8e80941Smrg Gfx9TSwModeMask; 180b8e80941Smrg 181b8e80941Smrgconst UINT_32 Gfx9AllSwModeMask = Gfx9LinearSwModeMask | 182b8e80941Smrg Gfx9ZSwModeMask | 183b8e80941Smrg Gfx9StandardSwModeMask | 184b8e80941Smrg Gfx9DisplaySwModeMask | 185b8e80941Smrg Gfx9RotateSwModeMask; 186b8e80941Smrg 187b8e80941Smrgconst UINT_32 Gfx9Rsrc1dSwModeMask = Gfx9LinearSwModeMask; 188b8e80941Smrg 189b8e80941Smrgconst UINT_32 Gfx9Rsrc2dSwModeMask = Gfx9AllSwModeMask; 190b8e80941Smrg 191b8e80941Smrgconst UINT_32 Gfx9Rsrc3dSwModeMask = Gfx9AllSwModeMask & ~Gfx9Blk256BSwModeMask & ~Gfx9RotateSwModeMask; 192b8e80941Smrg 193b8e80941Smrgconst UINT_32 Gfx9Rsrc2dPrtSwModeMask = (Gfx9Blk4KBSwModeMask | Gfx9Blk64KBSwModeMask) & ~Gfx9XSwModeMask; 194b8e80941Smrg 195b8e80941Smrgconst UINT_32 Gfx9Rsrc3dPrtSwModeMask = Gfx9Rsrc2dPrtSwModeMask & ~Gfx9RotateSwModeMask & ~Gfx9DisplaySwModeMask; 196b8e80941Smrg 197b8e80941Smrgconst UINT_32 Gfx9Rsrc3dThinSwModeMask = Gfx9DisplaySwModeMask & ~Gfx9Blk256BSwModeMask; 198b8e80941Smrg 199b8e80941Smrgconst UINT_32 Gfx9MsaaSwModeMask = Gfx9AllSwModeMask & ~Gfx9Blk256BSwModeMask & ~Gfx9LinearSwModeMask; 200b8e80941Smrg 201b8e80941Smrgconst UINT_32 Dce12NonBpp32SwModeMask = (1u << ADDR_SW_LINEAR) | 202b8e80941Smrg (1u << ADDR_SW_4KB_D) | 203b8e80941Smrg (1u << ADDR_SW_4KB_R) | 204b8e80941Smrg (1u << ADDR_SW_64KB_D) | 205b8e80941Smrg (1u << ADDR_SW_64KB_R) | 206b8e80941Smrg (1u << ADDR_SW_VAR_D) | 207b8e80941Smrg (1u << ADDR_SW_VAR_R) | 208b8e80941Smrg (1u << ADDR_SW_4KB_D_X) | 209b8e80941Smrg (1u << ADDR_SW_4KB_R_X) | 210b8e80941Smrg (1u << ADDR_SW_64KB_D_X) | 211b8e80941Smrg (1u << ADDR_SW_64KB_R_X) | 212b8e80941Smrg (1u << ADDR_SW_VAR_D_X) | 213b8e80941Smrg (1u << ADDR_SW_VAR_R_X); 214b8e80941Smrg 215b8e80941Smrgconst UINT_32 Dce12Bpp32SwModeMask = (1u << ADDR_SW_256B_D) | 216b8e80941Smrg (1u << ADDR_SW_256B_R) | 217b8e80941Smrg Dce12NonBpp32SwModeMask; 218b8e80941Smrg 219b8e80941Smrgconst UINT_32 Dcn1NonBpp64SwModeMask = (1u << ADDR_SW_LINEAR) | 220b8e80941Smrg (1u << ADDR_SW_4KB_S) | 221b8e80941Smrg (1u << ADDR_SW_64KB_S) | 222b8e80941Smrg (1u << ADDR_SW_VAR_S) | 223b8e80941Smrg (1u << ADDR_SW_64KB_S_T) | 224b8e80941Smrg (1u << ADDR_SW_4KB_S_X) | 225b8e80941Smrg (1u << ADDR_SW_64KB_S_X) | 226b8e80941Smrg (1u << ADDR_SW_VAR_S_X); 227b8e80941Smrg 228b8e80941Smrgconst UINT_32 Dcn1Bpp64SwModeMask = (1u << ADDR_SW_4KB_D) | 229b8e80941Smrg (1u << ADDR_SW_64KB_D) | 230b8e80941Smrg (1u << ADDR_SW_VAR_D) | 231b8e80941Smrg (1u << ADDR_SW_64KB_D_T) | 232b8e80941Smrg (1u << ADDR_SW_4KB_D_X) | 233b8e80941Smrg (1u << ADDR_SW_64KB_D_X) | 234b8e80941Smrg (1u << ADDR_SW_VAR_D_X) | 235b8e80941Smrg Dcn1NonBpp64SwModeMask; 236b8e80941Smrg 237b8e80941Smrg/** 238b8e80941Smrg************************************************************************************************************************ 239b8e80941Smrg* @brief GFX9 meta equation parameters 240b8e80941Smrg************************************************************************************************************************ 241b8e80941Smrg*/ 242b8e80941Smrgstruct MetaEqParams 243b8e80941Smrg{ 244b8e80941Smrg UINT_32 maxMip; 245b8e80941Smrg UINT_32 elementBytesLog2; 246b8e80941Smrg UINT_32 numSamplesLog2; 247b8e80941Smrg ADDR2_META_FLAGS metaFlag; 248b8e80941Smrg Gfx9DataType dataSurfaceType; 249b8e80941Smrg AddrSwizzleMode swizzleMode; 250b8e80941Smrg AddrResourceType resourceType; 251b8e80941Smrg UINT_32 metaBlkWidthLog2; 252b8e80941Smrg UINT_32 metaBlkHeightLog2; 253b8e80941Smrg UINT_32 metaBlkDepthLog2; 254b8e80941Smrg UINT_32 compBlkWidthLog2; 255b8e80941Smrg UINT_32 compBlkHeightLog2; 256b8e80941Smrg UINT_32 compBlkDepthLog2; 257b8e80941Smrg}; 258b8e80941Smrg 259b8e80941Smrg/** 260b8e80941Smrg************************************************************************************************************************ 261b8e80941Smrg* @brief This class is the GFX9 specific address library 262b8e80941Smrg* function set. 263b8e80941Smrg************************************************************************************************************************ 264b8e80941Smrg*/ 265b8e80941Smrgclass Gfx9Lib : public Lib 266b8e80941Smrg{ 267b8e80941Smrgpublic: 268b8e80941Smrg /// Creates Gfx9Lib object 269b8e80941Smrg static Addr::Lib* CreateObj(const Client* pClient) 270b8e80941Smrg { 271b8e80941Smrg VOID* pMem = Object::ClientAlloc(sizeof(Gfx9Lib), pClient); 272b8e80941Smrg return (pMem != NULL) ? new (pMem) Gfx9Lib(pClient) : NULL; 273b8e80941Smrg } 274b8e80941Smrg 275b8e80941Smrg virtual BOOL_32 IsValidDisplaySwizzleMode( 276b8e80941Smrg const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const; 277b8e80941Smrg 278b8e80941Smrgprotected: 279b8e80941Smrg Gfx9Lib(const Client* pClient); 280b8e80941Smrg virtual ~Gfx9Lib(); 281b8e80941Smrg 282b8e80941Smrg virtual BOOL_32 HwlIsStandardSwizzle( 283b8e80941Smrg AddrResourceType resourceType, 284b8e80941Smrg AddrSwizzleMode swizzleMode) const 285b8e80941Smrg { 286b8e80941Smrg return m_swizzleModeTable[swizzleMode].isStd || 287b8e80941Smrg (IsTex3d(resourceType) && m_swizzleModeTable[swizzleMode].isDisp); 288b8e80941Smrg } 289b8e80941Smrg 290b8e80941Smrg virtual BOOL_32 HwlIsDisplaySwizzle( 291b8e80941Smrg AddrResourceType resourceType, 292b8e80941Smrg AddrSwizzleMode swizzleMode) const 293b8e80941Smrg { 294b8e80941Smrg return IsTex2d(resourceType) && m_swizzleModeTable[swizzleMode].isDisp; 295b8e80941Smrg } 296b8e80941Smrg 297b8e80941Smrg virtual BOOL_32 HwlIsThin( 298b8e80941Smrg AddrResourceType resourceType, 299b8e80941Smrg AddrSwizzleMode swizzleMode) const 300b8e80941Smrg { 301b8e80941Smrg return ((IsTex2d(resourceType) == TRUE) || 302b8e80941Smrg ((IsTex3d(resourceType) == TRUE) && 303b8e80941Smrg (m_swizzleModeTable[swizzleMode].isZ == FALSE) && 304b8e80941Smrg (m_swizzleModeTable[swizzleMode].isStd == FALSE))); 305b8e80941Smrg } 306b8e80941Smrg 307b8e80941Smrg virtual BOOL_32 HwlIsThick( 308b8e80941Smrg AddrResourceType resourceType, 309b8e80941Smrg AddrSwizzleMode swizzleMode) const 310b8e80941Smrg { 311b8e80941Smrg return (IsTex3d(resourceType) && 312b8e80941Smrg (m_swizzleModeTable[swizzleMode].isZ || m_swizzleModeTable[swizzleMode].isStd)); 313b8e80941Smrg } 314b8e80941Smrg 315b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeHtileInfo( 316b8e80941Smrg const ADDR2_COMPUTE_HTILE_INFO_INPUT* pIn, 317b8e80941Smrg ADDR2_COMPUTE_HTILE_INFO_OUTPUT* pOut) const; 318b8e80941Smrg 319b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeCmaskInfo( 320b8e80941Smrg const ADDR2_COMPUTE_CMASK_INFO_INPUT* pIn, 321b8e80941Smrg ADDR2_COMPUTE_CMASK_INFO_OUTPUT* pOut) const; 322b8e80941Smrg 323b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeDccInfo( 324b8e80941Smrg const ADDR2_COMPUTE_DCCINFO_INPUT* pIn, 325b8e80941Smrg ADDR2_COMPUTE_DCCINFO_OUTPUT* pOut) const; 326b8e80941Smrg 327b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeCmaskAddrFromCoord( 328b8e80941Smrg const ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_INPUT* pIn, 329b8e80941Smrg ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT* pOut); 330b8e80941Smrg 331b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeHtileAddrFromCoord( 332b8e80941Smrg const ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_INPUT* pIn, 333b8e80941Smrg ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT* pOut); 334b8e80941Smrg 335b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeHtileCoordFromAddr( 336b8e80941Smrg const ADDR2_COMPUTE_HTILE_COORDFROMADDR_INPUT* pIn, 337b8e80941Smrg ADDR2_COMPUTE_HTILE_COORDFROMADDR_OUTPUT* pOut); 338b8e80941Smrg 339b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeDccAddrFromCoord( 340b8e80941Smrg const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT* pIn, 341b8e80941Smrg ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT* pOut); 342b8e80941Smrg 343b8e80941Smrg virtual UINT_32 HwlGetEquationIndex( 344b8e80941Smrg const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 345b8e80941Smrg ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const; 346b8e80941Smrg 347b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeBlock256Equation( 348b8e80941Smrg AddrResourceType rsrcType, 349b8e80941Smrg AddrSwizzleMode swMode, 350b8e80941Smrg UINT_32 elementBytesLog2, 351b8e80941Smrg ADDR_EQUATION* pEquation) const; 352b8e80941Smrg 353b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeThinEquation( 354b8e80941Smrg AddrResourceType rsrcType, 355b8e80941Smrg AddrSwizzleMode swMode, 356b8e80941Smrg UINT_32 elementBytesLog2, 357b8e80941Smrg ADDR_EQUATION* pEquation) const; 358b8e80941Smrg 359b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeThickEquation( 360b8e80941Smrg AddrResourceType rsrcType, 361b8e80941Smrg AddrSwizzleMode swMode, 362b8e80941Smrg UINT_32 elementBytesLog2, 363b8e80941Smrg ADDR_EQUATION* pEquation) const; 364b8e80941Smrg 365b8e80941Smrg // Get equation table pointer and number of equations 366b8e80941Smrg virtual UINT_32 HwlGetEquationTableInfo(const ADDR_EQUATION** ppEquationTable) const 367b8e80941Smrg { 368b8e80941Smrg *ppEquationTable = m_equationTable; 369b8e80941Smrg 370b8e80941Smrg return m_numEquations; 371b8e80941Smrg } 372b8e80941Smrg 373b8e80941Smrg virtual BOOL_32 IsEquationSupported( 374b8e80941Smrg AddrResourceType rsrcType, 375b8e80941Smrg AddrSwizzleMode swMode, 376b8e80941Smrg UINT_32 elementBytesLog2) const; 377b8e80941Smrg 378b8e80941Smrg UINT_32 ComputeSurfaceBaseAlignTiled(AddrSwizzleMode swizzleMode) const 379b8e80941Smrg { 380b8e80941Smrg UINT_32 baseAlign; 381b8e80941Smrg 382b8e80941Smrg if (IsXor(swizzleMode)) 383b8e80941Smrg { 384b8e80941Smrg baseAlign = GetBlockSize(swizzleMode); 385b8e80941Smrg } 386b8e80941Smrg else 387b8e80941Smrg { 388b8e80941Smrg baseAlign = 256; 389b8e80941Smrg } 390b8e80941Smrg 391b8e80941Smrg return baseAlign; 392b8e80941Smrg } 393b8e80941Smrg 394b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputePipeBankXor( 395b8e80941Smrg const ADDR2_COMPUTE_PIPEBANKXOR_INPUT* pIn, 396b8e80941Smrg ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT* pOut) const; 397b8e80941Smrg 398b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeSlicePipeBankXor( 399b8e80941Smrg const ADDR2_COMPUTE_SLICE_PIPEBANKXOR_INPUT* pIn, 400b8e80941Smrg ADDR2_COMPUTE_SLICE_PIPEBANKXOR_OUTPUT* pOut) const; 401b8e80941Smrg 402b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeSubResourceOffsetForSwizzlePattern( 403b8e80941Smrg const ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_INPUT* pIn, 404b8e80941Smrg ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_OUTPUT* pOut) const; 405b8e80941Smrg 406b8e80941Smrg virtual ADDR_E_RETURNCODE HwlGetPreferredSurfaceSetting( 407b8e80941Smrg const ADDR2_GET_PREFERRED_SURF_SETTING_INPUT* pIn, 408b8e80941Smrg ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT* pOut) const; 409b8e80941Smrg 410b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfoSanityCheck( 411b8e80941Smrg const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const; 412b8e80941Smrg 413b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfoTiled( 414b8e80941Smrg const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 415b8e80941Smrg ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const; 416b8e80941Smrg 417b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfoLinear( 418b8e80941Smrg const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 419b8e80941Smrg ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const; 420b8e80941Smrg 421b8e80941Smrg virtual ADDR_E_RETURNCODE HwlComputeSurfaceAddrFromCoordTiled( 422b8e80941Smrg const ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn, 423b8e80941Smrg ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT* pOut) const; 424b8e80941Smrg 425b8e80941Smrg // Initialize equation table 426b8e80941Smrg VOID InitEquationTable(); 427b8e80941Smrg 428b8e80941Smrg ADDR_E_RETURNCODE ComputeStereoInfo( 429b8e80941Smrg const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 430b8e80941Smrg ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut, 431b8e80941Smrg UINT_32* pHeightAlign) const; 432b8e80941Smrg 433b8e80941Smrg UINT_32 GetMipChainInfo( 434b8e80941Smrg AddrResourceType resourceType, 435b8e80941Smrg AddrSwizzleMode swizzleMode, 436b8e80941Smrg UINT_32 bpp, 437b8e80941Smrg UINT_32 mip0Width, 438b8e80941Smrg UINT_32 mip0Height, 439b8e80941Smrg UINT_32 mip0Depth, 440b8e80941Smrg UINT_32 blockWidth, 441b8e80941Smrg UINT_32 blockHeight, 442b8e80941Smrg UINT_32 blockDepth, 443b8e80941Smrg UINT_32 numMipLevel, 444b8e80941Smrg ADDR2_MIP_INFO* pMipInfo) const; 445b8e80941Smrg 446b8e80941Smrg VOID GetMetaMiptailInfo( 447b8e80941Smrg ADDR2_META_MIP_INFO* pInfo, 448b8e80941Smrg Dim3d mipCoord, 449b8e80941Smrg UINT_32 numMipInTail, 450b8e80941Smrg Dim3d* pMetaBlkDim) const; 451b8e80941Smrg 452b8e80941Smrg Dim3d GetMipStartPos( 453b8e80941Smrg AddrResourceType resourceType, 454b8e80941Smrg AddrSwizzleMode swizzleMode, 455b8e80941Smrg UINT_32 width, 456b8e80941Smrg UINT_32 height, 457b8e80941Smrg UINT_32 depth, 458b8e80941Smrg UINT_32 blockWidth, 459b8e80941Smrg UINT_32 blockHeight, 460b8e80941Smrg UINT_32 blockDepth, 461b8e80941Smrg UINT_32 mipId, 462b8e80941Smrg UINT_32 log2ElementBytes, 463b8e80941Smrg UINT_32* pMipTailBytesOffset) const; 464b8e80941Smrg 465b8e80941Smrg AddrMajorMode GetMajorMode( 466b8e80941Smrg AddrResourceType resourceType, 467b8e80941Smrg AddrSwizzleMode swizzleMode, 468b8e80941Smrg UINT_32 mip0WidthInBlk, 469b8e80941Smrg UINT_32 mip0HeightInBlk, 470b8e80941Smrg UINT_32 mip0DepthInBlk) const 471b8e80941Smrg { 472b8e80941Smrg BOOL_32 yMajor = (mip0WidthInBlk < mip0HeightInBlk); 473b8e80941Smrg BOOL_32 xMajor = (yMajor == FALSE); 474b8e80941Smrg 475b8e80941Smrg if (IsThick(resourceType, swizzleMode)) 476b8e80941Smrg { 477b8e80941Smrg yMajor = yMajor && (mip0HeightInBlk >= mip0DepthInBlk); 478b8e80941Smrg xMajor = xMajor && (mip0WidthInBlk >= mip0DepthInBlk); 479b8e80941Smrg } 480b8e80941Smrg 481b8e80941Smrg AddrMajorMode majorMode; 482b8e80941Smrg if (xMajor) 483b8e80941Smrg { 484b8e80941Smrg majorMode = ADDR_MAJOR_X; 485b8e80941Smrg } 486b8e80941Smrg else if (yMajor) 487b8e80941Smrg { 488b8e80941Smrg majorMode = ADDR_MAJOR_Y; 489b8e80941Smrg } 490b8e80941Smrg else 491b8e80941Smrg { 492b8e80941Smrg majorMode = ADDR_MAJOR_Z; 493b8e80941Smrg } 494b8e80941Smrg 495b8e80941Smrg return majorMode; 496b8e80941Smrg } 497b8e80941Smrg 498b8e80941Smrg Dim3d GetDccCompressBlk( 499b8e80941Smrg AddrResourceType resourceType, 500b8e80941Smrg AddrSwizzleMode swizzleMode, 501b8e80941Smrg UINT_32 bpp) const 502b8e80941Smrg { 503b8e80941Smrg UINT_32 index = Log2(bpp >> 3); 504b8e80941Smrg Dim3d compressBlkDim; 505b8e80941Smrg 506b8e80941Smrg if (IsThin(resourceType, swizzleMode)) 507b8e80941Smrg { 508b8e80941Smrg compressBlkDim.w = Block256_2d[index].w; 509b8e80941Smrg compressBlkDim.h = Block256_2d[index].h; 510b8e80941Smrg compressBlkDim.d = 1; 511b8e80941Smrg } 512b8e80941Smrg else if (IsStandardSwizzle(resourceType, swizzleMode)) 513b8e80941Smrg { 514b8e80941Smrg compressBlkDim = Block256_3dS[index]; 515b8e80941Smrg } 516b8e80941Smrg else 517b8e80941Smrg { 518b8e80941Smrg compressBlkDim = Block256_3dZ[index]; 519b8e80941Smrg } 520b8e80941Smrg 521b8e80941Smrg return compressBlkDim; 522b8e80941Smrg } 523b8e80941Smrg 524b8e80941Smrg static const UINT_32 MaxSeLog2 = 3; 525b8e80941Smrg static const UINT_32 MaxRbPerSeLog2 = 2; 526b8e80941Smrg 527b8e80941Smrg static const Dim3d Block256_3dS[MaxNumOfBpp]; 528b8e80941Smrg static const Dim3d Block256_3dZ[MaxNumOfBpp]; 529b8e80941Smrg 530b8e80941Smrg static const UINT_32 MipTailOffset256B[]; 531b8e80941Smrg 532b8e80941Smrg static const SwizzleModeFlags SwizzleModeTable[ADDR_SW_MAX_TYPE]; 533b8e80941Smrg 534b8e80941Smrg // Max number of swizzle mode supported for equation 535b8e80941Smrg static const UINT_32 MaxSwMode = 32; 536b8e80941Smrg // Max number of resource type (2D/3D) supported for equation 537b8e80941Smrg static const UINT_32 MaxRsrcType = 2; 538b8e80941Smrg // Max number of bpp (8bpp/16bpp/32bpp/64bpp/128bpp) 539b8e80941Smrg static const UINT_32 MaxElementBytesLog2 = 5; 540b8e80941Smrg // Almost all swizzle mode + resource type support equation 541b8e80941Smrg static const UINT_32 EquationTableSize = MaxElementBytesLog2 * MaxSwMode * MaxRsrcType; 542b8e80941Smrg // Equation table 543b8e80941Smrg ADDR_EQUATION m_equationTable[EquationTableSize]; 544b8e80941Smrg 545b8e80941Smrg // Number of equation entries in the table 546b8e80941Smrg UINT_32 m_numEquations; 547b8e80941Smrg // Equation lookup table according to bpp and tile index 548b8e80941Smrg UINT_32 m_equationLookupTable[MaxRsrcType][MaxSwMode][MaxElementBytesLog2]; 549b8e80941Smrg 550b8e80941Smrg static const UINT_32 MaxCachedMetaEq = 2; 551b8e80941Smrg 552b8e80941Smrgprivate: 553b8e80941Smrg virtual UINT_32 HwlComputeMaxBaseAlignments() const; 554b8e80941Smrg 555b8e80941Smrg virtual UINT_32 HwlComputeMaxMetaBaseAlignments() const; 556b8e80941Smrg 557b8e80941Smrg virtual BOOL_32 HwlInitGlobalParams(const ADDR_CREATE_INPUT* pCreateIn); 558b8e80941Smrg 559b8e80941Smrg VOID GetRbEquation(CoordEq* pRbEq, UINT_32 rbPerSeLog2, UINT_32 seLog2) const; 560b8e80941Smrg 561b8e80941Smrg VOID GetDataEquation(CoordEq* pDataEq, Gfx9DataType dataSurfaceType, 562b8e80941Smrg AddrSwizzleMode swizzleMode, AddrResourceType resourceType, 563b8e80941Smrg UINT_32 elementBytesLog2, UINT_32 numSamplesLog2) const; 564b8e80941Smrg 565b8e80941Smrg VOID GetPipeEquation(CoordEq* pPipeEq, CoordEq* pDataEq, 566b8e80941Smrg UINT_32 pipeInterleaveLog2, UINT_32 numPipesLog2, 567b8e80941Smrg UINT_32 numSamplesLog2, Gfx9DataType dataSurfaceType, 568b8e80941Smrg AddrSwizzleMode swizzleMode, AddrResourceType resourceType) const; 569b8e80941Smrg 570b8e80941Smrg VOID GenMetaEquation(CoordEq* pMetaEq, UINT_32 maxMip, 571b8e80941Smrg UINT_32 elementBytesLog2, UINT_32 numSamplesLog2, 572b8e80941Smrg ADDR2_META_FLAGS metaFlag, Gfx9DataType dataSurfaceType, 573b8e80941Smrg AddrSwizzleMode swizzleMode, AddrResourceType resourceType, 574b8e80941Smrg UINT_32 metaBlkWidthLog2, UINT_32 metaBlkHeightLog2, 575b8e80941Smrg UINT_32 metaBlkDepthLog2, UINT_32 compBlkWidthLog2, 576b8e80941Smrg UINT_32 compBlkHeightLog2, UINT_32 compBlkDepthLog2) const; 577b8e80941Smrg 578b8e80941Smrg const CoordEq* GetMetaEquation(const MetaEqParams& metaEqParams); 579b8e80941Smrg 580b8e80941Smrg virtual ChipFamily HwlConvertChipFamily(UINT_32 uChipFamily, UINT_32 uChipRevision); 581b8e80941Smrg 582b8e80941Smrg VOID GetMetaMipInfo(UINT_32 numMipLevels, Dim3d* pMetaBlkDim, 583b8e80941Smrg BOOL_32 dataThick, ADDR2_META_MIP_INFO* pInfo, 584b8e80941Smrg UINT_32 mip0Width, UINT_32 mip0Height, UINT_32 mip0Depth, 585b8e80941Smrg UINT_32* pNumMetaBlkX, UINT_32* pNumMetaBlkY, UINT_32* pNumMetaBlkZ) const; 586b8e80941Smrg 587b8e80941Smrg ADDR_E_RETURNCODE ComputeSurfaceLinearPadding( 588b8e80941Smrg const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, 589b8e80941Smrg UINT_32* pMipmap0PaddedWidth, 590b8e80941Smrg UINT_32* pSlice0PaddedHeight, 591b8e80941Smrg ADDR2_MIP_INFO* pMipInfo = NULL) const; 592b8e80941Smrg 593b8e80941Smrg static ADDR2_BLOCK_SET GetAllowedBlockSet(ADDR2_SWMODE_SET allowedSwModeSet) 594b8e80941Smrg { 595b8e80941Smrg ADDR2_BLOCK_SET allowedBlockSet = {}; 596b8e80941Smrg 597b8e80941Smrg allowedBlockSet.micro = (allowedSwModeSet.value & Gfx9Blk256BSwModeMask) ? TRUE : FALSE; 598b8e80941Smrg allowedBlockSet.macro4KB = (allowedSwModeSet.value & Gfx9Blk4KBSwModeMask) ? TRUE : FALSE; 599b8e80941Smrg allowedBlockSet.macro64KB = (allowedSwModeSet.value & Gfx9Blk64KBSwModeMask) ? TRUE : FALSE; 600b8e80941Smrg allowedBlockSet.var = (allowedSwModeSet.value & Gfx9BlkVarSwModeMask) ? TRUE : FALSE; 601b8e80941Smrg allowedBlockSet.linear = (allowedSwModeSet.value & Gfx9LinearSwModeMask) ? TRUE : FALSE; 602b8e80941Smrg 603b8e80941Smrg return allowedBlockSet; 604b8e80941Smrg } 605b8e80941Smrg 606b8e80941Smrg static ADDR2_SWTYPE_SET GetAllowedSwSet(ADDR2_SWMODE_SET allowedSwModeSet) 607b8e80941Smrg { 608b8e80941Smrg ADDR2_SWTYPE_SET allowedSwSet = {}; 609b8e80941Smrg 610b8e80941Smrg allowedSwSet.sw_Z = (allowedSwModeSet.value & Gfx9ZSwModeMask) ? TRUE : FALSE; 611b8e80941Smrg allowedSwSet.sw_S = (allowedSwModeSet.value & Gfx9StandardSwModeMask) ? TRUE : FALSE; 612b8e80941Smrg allowedSwSet.sw_D = (allowedSwModeSet.value & Gfx9DisplaySwModeMask) ? TRUE : FALSE; 613b8e80941Smrg allowedSwSet.sw_R = (allowedSwModeSet.value & Gfx9RotateSwModeMask) ? TRUE : FALSE; 614b8e80941Smrg 615b8e80941Smrg return allowedSwSet; 616b8e80941Smrg } 617b8e80941Smrg 618b8e80941Smrg Gfx9ChipSettings m_settings; 619b8e80941Smrg 620b8e80941Smrg CoordEq m_cachedMetaEq[MaxCachedMetaEq]; 621b8e80941Smrg MetaEqParams m_cachedMetaEqKey[MaxCachedMetaEq]; 622b8e80941Smrg UINT_32 m_metaEqOverrideIndex; 623b8e80941Smrg}; 624b8e80941Smrg 625b8e80941Smrg} // V2 626b8e80941Smrg} // Addr 627b8e80941Smrg 628b8e80941Smrg#endif 629b8e80941Smrg 630