"Fossies" - the Fresh Open Source Software Archive

Member "mesa-20.1.8/src/amd/addrlib/src/core/addrlib2.h" (16 Sep 2020, 27941 Bytes) of package /linux/misc/mesa-20.1.8.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "addrlib2.h" see the Fossies "Dox" file reference documentation.

    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  addrlib2.h
   30 * @brief Contains the Addr::V2::Lib class definition.
   31 ************************************************************************************************************************
   32 */
   33 
   34 #ifndef __ADDR2_LIB2_H__
   35 #define __ADDR2_LIB2_H__
   36 
   37 #include "addrlib.h"
   38 
   39 namespace Addr
   40 {
   41 namespace V2
   42 {
   43 
   44 /**
   45 ************************************************************************************************************************
   46 * @brief Flags for SwizzleModeTable
   47 ************************************************************************************************************************
   48 */
   49 struct SwizzleModeFlags
   50 {
   51     // Swizzle mode
   52     UINT_32 isLinear        : 1;    // Linear
   53 
   54     // Block size
   55     UINT_32 is256b          : 1;    // Block size is 256B
   56     UINT_32 is4kb           : 1;    // Block size is 4KB
   57     UINT_32 is64kb          : 1;    // Block size is 64KB
   58     UINT_32 isVar           : 1;    // Block size is variable
   59 
   60     UINT_32 isZ             : 1;    // Z order swizzle mode
   61     UINT_32 isStd           : 1;    // Standard swizzle mode
   62     UINT_32 isDisp          : 1;    // Display swizzle mode
   63     UINT_32 isRot           : 1;    // Rotate swizzle mode
   64 
   65     // XOR mode
   66     UINT_32 isXor           : 1;    // XOR after swizzle if set
   67 
   68     UINT_32 isT             : 1;    // T mode
   69 
   70     UINT_32 isRtOpt         : 1;    // mode opt for render target
   71 
   72     UINT_32 reserved        : 20;   // Reserved bits
   73 };
   74 
   75 struct Dim2d
   76 {
   77     UINT_32 w;
   78     UINT_32 h;
   79 };
   80 
   81 struct Dim3d
   82 {
   83     UINT_32 w;
   84     UINT_32 h;
   85     UINT_32 d;
   86 };
   87 
   88 // Macro define resource block type
   89 enum AddrBlockType
   90 {
   91     AddrBlockMicro     = 0, // Resource uses 256B block
   92     AddrBlockThin4KB   = 1, // Resource uses thin 4KB block
   93     AddrBlockThick4KB  = 2, // Resource uses thick 4KB block
   94     AddrBlockThin64KB  = 3, // Resource uses thin 64KB block
   95     AddrBlockThick64KB = 4, // Resource uses thick 64KB block
   96     AddrBlockVar       = 5, // Resource uses var block, only valid for GFX9
   97     AddrBlockLinear    = 6, // Resource uses linear swizzle mode
   98 
   99     AddrBlockMaxTiledType = AddrBlockVar + 1,
  100 };
  101 
  102 enum AddrSwSet
  103 {
  104     AddrSwSetZ = 1 << ADDR_SW_Z,
  105     AddrSwSetS = 1 << ADDR_SW_S,
  106     AddrSwSetD = 1 << ADDR_SW_D,
  107     AddrSwSetR = 1 << ADDR_SW_R,
  108 
  109     AddrSwSetAll = AddrSwSetZ | AddrSwSetS | AddrSwSetD | AddrSwSetR,
  110 };
  111 
  112 const UINT_32 Size256 = 256u;
  113 const UINT_32 Size4K  = 4096u;
  114 const UINT_32 Size64K = 65536u;
  115 
  116 const UINT_32 Log2Size256 = 8u;
  117 const UINT_32 Log2Size4K  = 12u;
  118 const UINT_32 Log2Size64K = 16u;
  119 
  120 /**
  121 ************************************************************************************************************************
  122 * @brief This class contains asic independent address lib functionalities
  123 ************************************************************************************************************************
  124 */
  125 class Lib : public Addr::Lib
  126 {
  127 public:
  128     virtual ~Lib();
  129 
  130     static Lib* GetLib(
  131         ADDR_HANDLE hLib);
  132 
  133     //
  134     // Interface stubs
  135     //
  136 
  137     // For data surface
  138     ADDR_E_RETURNCODE ComputeSurfaceInfo(
  139         const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn,
  140         ADDR2_COMPUTE_SURFACE_INFO_OUTPUT*      pOut) const;
  141 
  142     ADDR_E_RETURNCODE ComputeSurfaceAddrFromCoord(
  143         const ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn,
  144         ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT*      pOut) const;
  145 
  146     ADDR_E_RETURNCODE ComputeSurfaceCoordFromAddr(
  147         const ADDR2_COMPUTE_SURFACE_COORDFROMADDR_INPUT* pIn,
  148         ADDR2_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT*      pOut) const;
  149 
  150     // For HTile
  151     ADDR_E_RETURNCODE ComputeHtileInfo(
  152         const ADDR2_COMPUTE_HTILE_INFO_INPUT* pIn,
  153         ADDR2_COMPUTE_HTILE_INFO_OUTPUT*      pOut) const;
  154 
  155     ADDR_E_RETURNCODE ComputeHtileAddrFromCoord(
  156         const ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_INPUT* pIn,
  157         ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT*      pOut);
  158 
  159     ADDR_E_RETURNCODE ComputeHtileCoordFromAddr(
  160         const ADDR2_COMPUTE_HTILE_COORDFROMADDR_INPUT* pIn,
  161         ADDR2_COMPUTE_HTILE_COORDFROMADDR_OUTPUT*      pOut);
  162 
  163     // For CMask
  164     ADDR_E_RETURNCODE ComputeCmaskInfo(
  165         const ADDR2_COMPUTE_CMASK_INFO_INPUT* pIn,
  166         ADDR2_COMPUTE_CMASK_INFO_OUTPUT*      pOut) const;
  167 
  168     ADDR_E_RETURNCODE ComputeCmaskAddrFromCoord(
  169         const ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_INPUT* pIn,
  170         ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT*      pOut);
  171 
  172     ADDR_E_RETURNCODE ComputeCmaskCoordFromAddr(
  173         const ADDR2_COMPUTE_CMASK_COORDFROMADDR_INPUT* pIn,
  174         ADDR2_COMPUTE_CMASK_COORDFROMADDR_OUTPUT*      pOut) const;
  175 
  176     // For FMask
  177     ADDR_E_RETURNCODE ComputeFmaskInfo(
  178         const ADDR2_COMPUTE_FMASK_INFO_INPUT* pIn,
  179         ADDR2_COMPUTE_FMASK_INFO_OUTPUT*      pOut);
  180 
  181     ADDR_E_RETURNCODE ComputeFmaskAddrFromCoord(
  182         const ADDR2_COMPUTE_FMASK_ADDRFROMCOORD_INPUT* pIn,
  183         ADDR2_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT*      pOut) const;
  184 
  185     ADDR_E_RETURNCODE ComputeFmaskCoordFromAddr(
  186         const ADDR2_COMPUTE_FMASK_COORDFROMADDR_INPUT* pIn,
  187         ADDR2_COMPUTE_FMASK_COORDFROMADDR_OUTPUT*      pOut) const;
  188 
  189     // For DCC key
  190     ADDR_E_RETURNCODE ComputeDccInfo(
  191         const ADDR2_COMPUTE_DCCINFO_INPUT* pIn,
  192         ADDR2_COMPUTE_DCCINFO_OUTPUT*      pOut) const;
  193 
  194     ADDR_E_RETURNCODE ComputeDccAddrFromCoord(
  195         const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT* pIn,
  196         ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT*      pOut);
  197 
  198     // Misc
  199     ADDR_E_RETURNCODE ComputePipeBankXor(
  200         const ADDR2_COMPUTE_PIPEBANKXOR_INPUT* pIn,
  201         ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT*      pOut);
  202 
  203     ADDR_E_RETURNCODE ComputeSlicePipeBankXor(
  204         const ADDR2_COMPUTE_SLICE_PIPEBANKXOR_INPUT* pIn,
  205         ADDR2_COMPUTE_SLICE_PIPEBANKXOR_OUTPUT*      pOut);
  206 
  207     ADDR_E_RETURNCODE ComputeSubResourceOffsetForSwizzlePattern(
  208         const ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_INPUT* pIn,
  209         ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_OUTPUT*      pOut);
  210 
  211     ADDR_E_RETURNCODE Addr2GetPreferredSurfaceSetting(
  212         const ADDR2_GET_PREFERRED_SURF_SETTING_INPUT* pIn,
  213         ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT*      pOut) const;
  214 
  215     virtual BOOL_32 IsValidDisplaySwizzleMode(
  216         const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const
  217     {
  218         ADDR_NOT_IMPLEMENTED();
  219         return ADDR_NOTIMPLEMENTED;
  220     }
  221 
  222 protected:
  223     Lib();  // Constructor is protected
  224     Lib(const Client* pClient);
  225 
  226     static const UINT_32 MaxNumOfBpp = 5;
  227     static const UINT_32 MaxNumOfAA  = 4;
  228 
  229     static const Dim2d Block256_2d[MaxNumOfBpp];
  230     static const Dim3d Block1K_3d[MaxNumOfBpp];
  231 
  232     static const UINT_32 PrtAlignment = 64 * 1024;
  233     static const UINT_32 MaxMacroBits = 20;
  234 
  235     static const UINT_32 MaxMipLevels = 16;
  236 
  237     BOOL_32 IsValidSwMode(AddrSwizzleMode swizzleMode) const
  238     {
  239         // Don't dereference a reinterpret_cast pointer so as not to break
  240         // strict-aliasing rules.
  241         UINT_32 mode;
  242         memcpy(&mode, &m_swizzleModeTable[swizzleMode], sizeof(UINT_32));
  243         return mode != 0;
  244     }
  245 
  246     // Checking block size
  247     BOOL_32 IsBlock256b(AddrSwizzleMode swizzleMode) const
  248     {
  249         return m_swizzleModeTable[swizzleMode].is256b;
  250     }
  251 
  252     BOOL_32 IsBlock4kb(AddrSwizzleMode swizzleMode) const
  253     {
  254         return m_swizzleModeTable[swizzleMode].is4kb;
  255     }
  256 
  257     BOOL_32 IsBlock64kb(AddrSwizzleMode swizzleMode) const
  258     {
  259         return m_swizzleModeTable[swizzleMode].is64kb;
  260     }
  261 
  262     BOOL_32 IsBlockVariable(AddrSwizzleMode swizzleMode) const
  263     {
  264         return m_swizzleModeTable[swizzleMode].isVar;
  265     }
  266 
  267     // Checking swizzle mode
  268     BOOL_32 IsLinear(AddrSwizzleMode swizzleMode) const
  269     {
  270         return m_swizzleModeTable[swizzleMode].isLinear;
  271     }
  272 
  273     BOOL_32 IsRtOptSwizzle(AddrSwizzleMode swizzleMode) const
  274     {
  275         return m_swizzleModeTable[swizzleMode].isRtOpt;
  276     }
  277 
  278     BOOL_32 IsZOrderSwizzle(AddrSwizzleMode swizzleMode) const
  279     {
  280         return m_swizzleModeTable[swizzleMode].isZ;
  281     }
  282 
  283     BOOL_32 IsStandardSwizzle(AddrSwizzleMode swizzleMode) const
  284     {
  285         return m_swizzleModeTable[swizzleMode].isStd;
  286     }
  287 
  288     BOOL_32 IsDisplaySwizzle(AddrSwizzleMode swizzleMode) const
  289     {
  290         return m_swizzleModeTable[swizzleMode].isDisp;
  291     }
  292 
  293     BOOL_32 IsRotateSwizzle(AddrSwizzleMode swizzleMode) const
  294     {
  295         return m_swizzleModeTable[swizzleMode].isRot;
  296     }
  297 
  298     BOOL_32 IsStandardSwizzle(AddrResourceType resourceType, AddrSwizzleMode swizzleMode) const
  299     {
  300         return HwlIsStandardSwizzle(resourceType, swizzleMode);
  301     }
  302 
  303     BOOL_32 IsDisplaySwizzle(AddrResourceType resourceType, AddrSwizzleMode swizzleMode) const
  304     {
  305         return HwlIsDisplaySwizzle(resourceType, swizzleMode);
  306     }
  307 
  308     BOOL_32 IsXor(AddrSwizzleMode swizzleMode) const
  309     {
  310         return m_swizzleModeTable[swizzleMode].isXor;
  311     }
  312 
  313     BOOL_32 IsPrt(AddrSwizzleMode swizzleMode) const
  314     {
  315         return m_swizzleModeTable[swizzleMode].isT;
  316     }
  317 
  318     BOOL_32 IsNonPrtXor(AddrSwizzleMode swizzleMode) const
  319     {
  320         return (IsXor(swizzleMode) && (IsPrt(swizzleMode) == FALSE));
  321     }
  322 
  323     // Checking resource type
  324     static BOOL_32 IsTex1d(AddrResourceType resourceType)
  325     {
  326         return (resourceType == ADDR_RSRC_TEX_1D);
  327     }
  328 
  329     static BOOL_32 IsTex2d(AddrResourceType resourceType)
  330     {
  331         return (resourceType == ADDR_RSRC_TEX_2D);
  332     }
  333 
  334     static BOOL_32 IsTex3d(AddrResourceType resourceType)
  335     {
  336         return (resourceType == ADDR_RSRC_TEX_3D);
  337     }
  338 
  339     BOOL_32 IsThick(AddrResourceType resourceType, AddrSwizzleMode swizzleMode) const
  340     {
  341         return HwlIsThick(resourceType, swizzleMode);
  342     }
  343 
  344     BOOL_32 IsThin(AddrResourceType resourceType, AddrSwizzleMode swizzleMode) const
  345     {
  346         return HwlIsThin(resourceType, swizzleMode);
  347     }
  348 
  349     UINT_32 GetBlockSizeLog2(AddrSwizzleMode swizzleMode) const
  350     {
  351         UINT_32 blockSizeLog2 = 0;
  352 
  353         if (IsBlock256b(swizzleMode) || IsLinear(swizzleMode))
  354         {
  355             blockSizeLog2 = 8;
  356         }
  357         else if (IsBlock4kb(swizzleMode))
  358         {
  359             blockSizeLog2 = 12;
  360         }
  361         else if (IsBlock64kb(swizzleMode))
  362         {
  363             blockSizeLog2 = 16;
  364         }
  365         else if (IsBlockVariable(swizzleMode) && (m_blockVarSizeLog2 != 0))
  366         {
  367             blockSizeLog2 = m_blockVarSizeLog2;
  368         }
  369         else
  370         {
  371             ADDR_ASSERT_ALWAYS();
  372         }
  373 
  374         return blockSizeLog2;
  375     }
  376 
  377     UINT_32 GetBlockSize(AddrSwizzleMode swizzleMode) const
  378     {
  379         return (1 << GetBlockSizeLog2(swizzleMode));
  380     }
  381 
  382     static UINT_32 GetFmaskBpp(UINT_32 sample, UINT_32 frag)
  383     {
  384         sample = (sample == 0) ? 1 : sample;
  385         frag   = (frag   == 0) ? sample : frag;
  386 
  387         UINT_32 fmaskBpp = QLog2(frag);
  388 
  389         if (sample > frag)
  390         {
  391             fmaskBpp++;
  392         }
  393 
  394         if (fmaskBpp == 3)
  395         {
  396             fmaskBpp = 4;
  397         }
  398 
  399         fmaskBpp = Max(8u, fmaskBpp * sample);
  400 
  401         return fmaskBpp;
  402     }
  403 
  404     virtual BOOL_32 HwlIsStandardSwizzle(
  405         AddrResourceType resourceType,
  406         AddrSwizzleMode  swizzleMode) const
  407     {
  408         ADDR_NOT_IMPLEMENTED();
  409         return FALSE;
  410     }
  411 
  412     virtual BOOL_32 HwlIsDisplaySwizzle(
  413         AddrResourceType resourceType,
  414         AddrSwizzleMode  swizzleMode) const
  415     {
  416         ADDR_NOT_IMPLEMENTED();
  417         return FALSE;
  418     }
  419 
  420     virtual BOOL_32 HwlIsThin(
  421         AddrResourceType resourceType,
  422         AddrSwizzleMode  swizzleMode) const
  423     {
  424         ADDR_NOT_IMPLEMENTED();
  425         return FALSE;
  426     }
  427 
  428     virtual BOOL_32 HwlIsThick(
  429         AddrResourceType resourceType,
  430         AddrSwizzleMode  swizzleMode) const
  431     {
  432         ADDR_NOT_IMPLEMENTED();
  433         return FALSE;
  434     }
  435 
  436     virtual ADDR_E_RETURNCODE HwlComputeHtileInfo(
  437         const ADDR2_COMPUTE_HTILE_INFO_INPUT*    pIn,
  438         ADDR2_COMPUTE_HTILE_INFO_OUTPUT*         pOut) const
  439     {
  440         ADDR_NOT_IMPLEMENTED();
  441         return ADDR_NOTSUPPORTED;
  442     }
  443 
  444     virtual ADDR_E_RETURNCODE HwlComputeCmaskInfo(
  445         const ADDR2_COMPUTE_CMASK_INFO_INPUT*    pIn,
  446         ADDR2_COMPUTE_CMASK_INFO_OUTPUT*         pOut) const
  447     {
  448         ADDR_NOT_IMPLEMENTED();
  449         return ADDR_NOTSUPPORTED;
  450     }
  451 
  452     virtual ADDR_E_RETURNCODE HwlComputeDccInfo(
  453         const ADDR2_COMPUTE_DCCINFO_INPUT*    pIn,
  454         ADDR2_COMPUTE_DCCINFO_OUTPUT*         pOut) const
  455     {
  456         ADDR_NOT_IMPLEMENTED();
  457         return ADDR_NOTSUPPORTED;
  458     }
  459 
  460     virtual ADDR_E_RETURNCODE HwlComputeDccAddrFromCoord(
  461         const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT* pIn,
  462         ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT*      pOut)
  463     {
  464         ADDR_NOT_IMPLEMENTED();
  465         return ADDR_NOTSUPPORTED;
  466     }
  467 
  468     virtual ADDR_E_RETURNCODE HwlComputeCmaskAddrFromCoord(
  469         const ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_INPUT* pIn,
  470         ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT*      pOut)
  471     {
  472         ADDR_NOT_IMPLEMENTED();
  473         return ADDR_NOTSUPPORTED;
  474     }
  475 
  476     virtual ADDR_E_RETURNCODE HwlComputeHtileAddrFromCoord(
  477         const ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_INPUT* pIn,
  478         ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT*      pOut)
  479     {
  480         ADDR_NOT_IMPLEMENTED();
  481         return ADDR_NOTSUPPORTED;
  482     }
  483 
  484     virtual ADDR_E_RETURNCODE HwlComputeHtileCoordFromAddr(
  485         const ADDR2_COMPUTE_HTILE_COORDFROMADDR_INPUT* pIn,
  486         ADDR2_COMPUTE_HTILE_COORDFROMADDR_OUTPUT*      pOut)
  487     {
  488         ADDR_NOT_IMPLEMENTED();
  489         return ADDR_NOTSUPPORTED;
  490     }
  491 
  492     virtual ADDR_E_RETURNCODE HwlComputeBlock256Equation(
  493         AddrResourceType rsrcType,
  494         AddrSwizzleMode swMode,
  495         UINT_32 elementBytesLog2,
  496         ADDR_EQUATION* pEquation) const
  497     {
  498         ADDR_NOT_IMPLEMENTED();
  499         return ADDR_NOTSUPPORTED;
  500     }
  501 
  502     virtual ADDR_E_RETURNCODE HwlComputeThinEquation(
  503         AddrResourceType rsrcType,
  504         AddrSwizzleMode swMode,
  505         UINT_32 elementBytesLog2,
  506         ADDR_EQUATION* pEquation) const
  507     {
  508         ADDR_NOT_IMPLEMENTED();
  509         return ADDR_NOTSUPPORTED;
  510     }
  511 
  512     virtual ADDR_E_RETURNCODE HwlComputeThickEquation(
  513         AddrResourceType rsrcType,
  514         AddrSwizzleMode swMode,
  515         UINT_32 elementBytesLog2,
  516         ADDR_EQUATION* pEquation) const
  517     {
  518         ADDR_NOT_IMPLEMENTED();
  519         return ADDR_NOTSUPPORTED;
  520     }
  521 
  522     virtual UINT_32 HwlGetEquationIndex(
  523         const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn,
  524         ADDR2_COMPUTE_SURFACE_INFO_OUTPUT*      pOut) const
  525     {
  526         ADDR_NOT_IMPLEMENTED();
  527         return ADDR_INVALID_EQUATION_INDEX;
  528     }
  529 
  530     UINT_32 GetEquationIndex(
  531         const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn,
  532         ADDR2_COMPUTE_SURFACE_INFO_OUTPUT*      pOut) const
  533     {
  534         return HwlGetEquationIndex(pIn, pOut);
  535     }
  536 
  537     virtual ADDR_E_RETURNCODE HwlComputePipeBankXor(
  538         const ADDR2_COMPUTE_PIPEBANKXOR_INPUT* pIn,
  539         ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT*      pOut) const
  540     {
  541         ADDR_NOT_IMPLEMENTED();
  542         return ADDR_NOTSUPPORTED;
  543     }
  544 
  545     virtual ADDR_E_RETURNCODE HwlComputeSlicePipeBankXor(
  546         const ADDR2_COMPUTE_SLICE_PIPEBANKXOR_INPUT* pIn,
  547         ADDR2_COMPUTE_SLICE_PIPEBANKXOR_OUTPUT*      pOut) const
  548     {
  549         ADDR_NOT_IMPLEMENTED();
  550         return ADDR_NOTSUPPORTED;
  551     }
  552 
  553     virtual ADDR_E_RETURNCODE HwlComputeSubResourceOffsetForSwizzlePattern(
  554         const ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_INPUT* pIn,
  555         ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_OUTPUT*      pOut) const
  556     {
  557         ADDR_NOT_IMPLEMENTED();
  558         return ADDR_NOTSUPPORTED;
  559     }
  560 
  561     virtual ADDR_E_RETURNCODE HwlGetPreferredSurfaceSetting(
  562         const ADDR2_GET_PREFERRED_SURF_SETTING_INPUT* pIn,
  563         ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT*      pOut) const
  564     {
  565         ADDR_NOT_IMPLEMENTED();
  566         return ADDR_NOTSUPPORTED;
  567     }
  568 
  569     virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfoSanityCheck(
  570         const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const
  571     {
  572         ADDR_NOT_IMPLEMENTED();
  573         return ADDR_NOTSUPPORTED;
  574     }
  575 
  576     virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfoTiled(
  577          const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn,
  578          ADDR2_COMPUTE_SURFACE_INFO_OUTPUT*      pOut) const
  579     {
  580         ADDR_NOT_IMPLEMENTED();
  581         return ADDR_NOTIMPLEMENTED;
  582     }
  583 
  584     virtual ADDR_E_RETURNCODE HwlComputeSurfaceInfoLinear(
  585          const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn,
  586          ADDR2_COMPUTE_SURFACE_INFO_OUTPUT*      pOut) const
  587     {
  588         ADDR_NOT_IMPLEMENTED();
  589         return ADDR_NOTIMPLEMENTED;
  590     }
  591 
  592     virtual ADDR_E_RETURNCODE HwlComputeSurfaceAddrFromCoordTiled(
  593         const ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn,
  594         ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT*      pOut) const
  595     {
  596         ADDR_NOT_IMPLEMENTED();
  597         return ADDR_NOTIMPLEMENTED;
  598     }
  599 
  600     ADDR_E_RETURNCODE ComputeBlock256Equation(
  601         AddrResourceType rsrcType,
  602         AddrSwizzleMode swMode,
  603         UINT_32 elementBytesLog2,
  604         ADDR_EQUATION* pEquation) const;
  605 
  606     ADDR_E_RETURNCODE ComputeThinEquation(
  607         AddrResourceType rsrcType,
  608         AddrSwizzleMode swMode,
  609         UINT_32 elementBytesLog2,
  610         ADDR_EQUATION* pEquation) const;
  611 
  612     ADDR_E_RETURNCODE ComputeThickEquation(
  613         AddrResourceType rsrcType,
  614         AddrSwizzleMode swMode,
  615         UINT_32 elementBytesLog2,
  616         ADDR_EQUATION* pEquation) const;
  617 
  618     ADDR_E_RETURNCODE ComputeSurfaceInfoSanityCheck(
  619         const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const;
  620 
  621     ADDR_E_RETURNCODE ComputeSurfaceInfoLinear(
  622         const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn,
  623         ADDR2_COMPUTE_SURFACE_INFO_OUTPUT*      pOut) const;
  624 
  625     ADDR_E_RETURNCODE ComputeSurfaceInfoTiled(
  626         const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn,
  627         ADDR2_COMPUTE_SURFACE_INFO_OUTPUT*      pOut) const;
  628 
  629     ADDR_E_RETURNCODE ComputeSurfaceAddrFromCoordLinear(
  630         const ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn,
  631         ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT*      pOut) const;
  632 
  633     ADDR_E_RETURNCODE ComputeSurfaceAddrFromCoordTiled(
  634         const ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn,
  635         ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT*      pOut) const;
  636 
  637     ADDR_E_RETURNCODE ComputeSurfaceCoordFromAddrLinear(
  638         const ADDR2_COMPUTE_SURFACE_COORDFROMADDR_INPUT* pIn,
  639         ADDR2_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT*      pOut) const;
  640 
  641     ADDR_E_RETURNCODE ComputeSurfaceCoordFromAddrTiled(
  642         const ADDR2_COMPUTE_SURFACE_COORDFROMADDR_INPUT* pIn,
  643         ADDR2_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT*      pOut) const;
  644 
  645     UINT_32 ComputeSurface2DMicroBlockOffset(
  646         const _ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn) const;
  647 
  648     UINT_32 ComputeSurface3DMicroBlockOffset(
  649         const _ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn) const;
  650 
  651     // Misc
  652     ADDR_E_RETURNCODE ComputeBlockDimensionForSurf(
  653         UINT_32*         pWidth,
  654         UINT_32*         pHeight,
  655         UINT_32*         pDepth,
  656         UINT_32          bpp,
  657         UINT_32          numSamples,
  658         AddrResourceType resourceType,
  659         AddrSwizzleMode  swizzleMode) const;
  660 
  661     ADDR_E_RETURNCODE ComputeBlockDimension(
  662         UINT_32*         pWidth,
  663         UINT_32*         pHeight,
  664         UINT_32*         pDepth,
  665         UINT_32          bpp,
  666         AddrResourceType resourceType,
  667         AddrSwizzleMode  swizzleMode) const;
  668 
  669     virtual VOID ComputeThinBlockDimension(
  670         UINT_32*         pWidth,
  671         UINT_32*         pHeight,
  672         UINT_32*         pDepth,
  673         UINT_32          bpp,
  674         UINT_32          numSamples,
  675         AddrResourceType resourceType,
  676         AddrSwizzleMode  swizzleMode) const;
  677 
  678     VOID ComputeThickBlockDimension(
  679         UINT_32*         pWidth,
  680         UINT_32*         pHeight,
  681         UINT_32*         pDepth,
  682         UINT_32          bpp,
  683         AddrResourceType resourceType,
  684         AddrSwizzleMode  swizzleMode) const;
  685 
  686     static UINT_64 ComputePadSize(
  687         const Dim3d*      pBlkDim,
  688         UINT_32           width,
  689         UINT_32           height,
  690         UINT_32           numSlices,
  691         Dim3d*            pPadDim)
  692     {
  693         pPadDim->w = PowTwoAlign(width ,pBlkDim->w);
  694         pPadDim->h = PowTwoAlign(height ,pBlkDim->h);
  695         pPadDim->d = PowTwoAlign(numSlices, pBlkDim->d);
  696         return static_cast<UINT_64>(pPadDim->w) * pPadDim->h * pPadDim->d;
  697     }
  698 
  699     static ADDR_E_RETURNCODE ExtractPipeBankXor(
  700         UINT_32  pipeBankXor,
  701         UINT_32  bankBits,
  702         UINT_32  pipeBits,
  703         UINT_32* pBankX,
  704         UINT_32* pPipeX);
  705 
  706     static BOOL_32 Valid3DMipSliceIdConstraint(
  707         UINT_32 numSlices,
  708         UINT_32 mipId,
  709         UINT_32 slice)
  710     {
  711         return (Max((numSlices >> mipId), 1u) > slice);
  712     }
  713 
  714     Dim3d GetMipTailDim(
  715         AddrResourceType  resourceType,
  716         AddrSwizzleMode   swizzleMode,
  717         UINT_32           blockWidth,
  718         UINT_32           blockHeight,
  719         UINT_32           blockDepth) const;
  720 
  721     static BOOL_32 IsLocalHeap(AddrResrouceLocation resourceType)
  722     {
  723         return ((resourceType == ADDR_RSRC_LOC_LOCAL) ||
  724                 (resourceType == ADDR_RSRC_LOC_INVIS));
  725     }
  726 
  727     static BOOL_32 IsInvisibleHeap(AddrResrouceLocation resourceType)
  728     {
  729         return (resourceType == ADDR_RSRC_LOC_INVIS);
  730     }
  731 
  732     static BOOL_32 IsNonlocalHeap(AddrResrouceLocation resourceType)
  733     {
  734         return ((resourceType == ADDR_RSRC_LOC_USWC) ||
  735                 (resourceType == ADDR_RSRC_LOC_CACHED));
  736     }
  737 
  738     UINT_32 GetPipeLog2ForMetaAddressing(BOOL_32 pipeAligned, AddrSwizzleMode swizzleMode) const
  739     {
  740         UINT_32 numPipeLog2 = pipeAligned ? Min(m_pipesLog2 + m_seLog2, 5u) : 0;
  741 
  742         if (IsXor(swizzleMode))
  743         {
  744             UINT_32 maxPipeLog2 = GetBlockSizeLog2(swizzleMode) - m_pipeInterleaveLog2;
  745 
  746             numPipeLog2 = Min(numPipeLog2, maxPipeLog2);
  747         }
  748 
  749         return numPipeLog2;
  750     }
  751 
  752     UINT_32 GetPipeNumForMetaAddressing(BOOL_32 pipeAligned, AddrSwizzleMode swizzleMode) const
  753     {
  754         return (1 << GetPipeLog2ForMetaAddressing(pipeAligned, swizzleMode));
  755     }
  756 
  757     VOID VerifyMipLevelInfo(const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn) const
  758     {
  759 #if DEBUG
  760         if (pIn->numMipLevels > 1)
  761         {
  762             UINT_32 actualMipLevels = 1;
  763             switch (pIn->resourceType)
  764             {
  765                 case ADDR_RSRC_TEX_3D:
  766                     // Fall through to share 2D case
  767                     actualMipLevels = Max(actualMipLevels, Log2NonPow2(pIn->numSlices) + 1);
  768                 case ADDR_RSRC_TEX_2D:
  769                     // Fall through to share 1D case
  770                     actualMipLevels = Max(actualMipLevels, Log2NonPow2(pIn->height) + 1);
  771                 case ADDR_RSRC_TEX_1D:
  772                     // Base 1D case
  773                     actualMipLevels = Max(actualMipLevels, Log2NonPow2(pIn->width) + 1);
  774                     break;
  775                 default:
  776                     ADDR_ASSERT_ALWAYS();
  777                     break;
  778             }
  779             // Client pass wrong number of MipLevels to addrlib and result will be bad.
  780             // Not sure if we should fail this calling instead of putting an assertion here.
  781             ADDR_ASSERT(actualMipLevels >= pIn->numMipLevels);
  782         }
  783 #endif
  784     }
  785 
  786     ADDR_E_RETURNCODE ApplyCustomerPipeBankXor(
  787         AddrSwizzleMode swizzleMode,
  788         UINT_32         pipeBankXor,
  789         UINT_32         bankBits,
  790         UINT_32         pipeBits,
  791         UINT_32*        pBlockOffset) const
  792     {
  793         ADDR_E_RETURNCODE returnCode = ADDR_OK;
  794 
  795         if (IsXor(swizzleMode))
  796         {
  797             // Apply driver set bankPipeXor
  798             UINT_32 bankX = 0;
  799             UINT_32 pipeX = 0;
  800             returnCode = ExtractPipeBankXor(pipeBankXor, bankBits, pipeBits, &bankX, &pipeX);
  801             *pBlockOffset ^= (pipeX << m_pipeInterleaveLog2);
  802             *pBlockOffset ^= (bankX << (m_pipeInterleaveLog2 + pipeBits));
  803         }
  804 
  805         return returnCode;
  806     }
  807 
  808     UINT_32 GetPipeXorBits(UINT_32 macroBlockBits) const;
  809 
  810     ADDR_E_RETURNCODE ApplyCustomizedPitchHeight(
  811         const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn,
  812         UINT_32                                 elementBytes,
  813         UINT_32                                 pitchAlignInElement,
  814         UINT_32*                                pPitch,
  815         UINT_32*                                pHeight) const;
  816 
  817     VOID ComputeQbStereoInfo(ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut) const;
  818 
  819     VOID FilterInvalidEqSwizzleMode(
  820         ADDR2_SWMODE_SET& allowedSwModeSet,
  821         AddrResourceType  resourceType,
  822         UINT_32           elemLog2) const;
  823 
  824     UINT_32 m_se;                       ///< Number of shader engine
  825     UINT_32 m_rbPerSe;                  ///< Number of render backend per shader engine
  826     UINT_32 m_maxCompFrag;              ///< Number of max compressed fragment
  827 
  828     UINT_32 m_banksLog2;                ///< Number of bank Log2
  829     UINT_32 m_pipesLog2;                ///< Number of pipe per shader engine Log2
  830     UINT_32 m_seLog2;                   ///< Number of shader engine Log2
  831     UINT_32 m_rbPerSeLog2;              ///< Number of render backend per shader engine Log2
  832     UINT_32 m_maxCompFragLog2;          ///< Number of max compressed fragment Log2
  833 
  834     UINT_32 m_pipeInterleaveLog2;       ///< Log2 of pipe interleave bytes
  835 
  836     UINT_32 m_blockVarSizeLog2;         ///< Log2 of block var size
  837 
  838     SwizzleModeFlags m_swizzleModeTable[ADDR_SW_MAX_TYPE];  ///< Swizzle mode table
  839 
  840     // Max number of swizzle mode supported for equation
  841     static const UINT_32    MaxSwModeType = 32;
  842     // Max number of resource type (2D/3D) supported for equation
  843     static const UINT_32    MaxRsrcType = 2;
  844     // Max number of bpp (8bpp/16bpp/32bpp/64bpp/128bpp)
  845     static const UINT_32    MaxElementBytesLog2  = 5;
  846     // Almost all swizzle mode + resource type support equation
  847     static const UINT_32    EquationTableSize = MaxElementBytesLog2 * MaxSwModeType * MaxRsrcType;
  848     // Equation table
  849     ADDR_EQUATION           m_equationTable[EquationTableSize];
  850 
  851     // Number of equation entries in the table
  852     UINT_32                 m_numEquations;
  853     // Equation lookup table according to bpp and tile index
  854     UINT_32                 m_equationLookupTable[MaxRsrcType][MaxSwModeType][MaxElementBytesLog2];
  855 
  856 private:
  857     // Disallow the copy constructor
  858     Lib(const Lib& a);
  859 
  860     // Disallow the assignment operator
  861     Lib& operator=(const Lib& a);
  862 };
  863 
  864 } // V2
  865 } // Addr
  866 
  867 #endif
  868