Home | History | Annotate | Download | only in addrlib
      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  addrinterface.cpp
     30 * @brief Contains the addrlib interface functions
     31 ****************************************************************************************************
     32 */
     33 #include "addrinterface.h"
     34 #include "addrlib1.h"
     35 #include "addrlib2.h"
     36 
     37 #include "addrcommon.h"
     38 
     39 using namespace Addr;
     40 
     41 ////////////////////////////////////////////////////////////////////////////////////////////////////
     42 //                               Create/Destroy/Config functions
     43 ////////////////////////////////////////////////////////////////////////////////////////////////////
     44 
     45 /**
     46 ****************************************************************************************************
     47 *   AddrCreate
     48 *
     49 *   @brief
     50 *       Create address lib object
     51 *
     52 *   @return
     53 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
     54 ****************************************************************************************************
     55 */
     56 ADDR_E_RETURNCODE ADDR_API AddrCreate(
     57     const ADDR_CREATE_INPUT*    pAddrCreateIn,  ///< [in] infomation for creating address lib object
     58     ADDR_CREATE_OUTPUT*         pAddrCreateOut) ///< [out] address lib handle
     59 {
     60     ADDR_E_RETURNCODE returnCode = ADDR_OK;
     61 
     62     returnCode = Lib::Create(pAddrCreateIn, pAddrCreateOut);
     63 
     64     return returnCode;
     65 }
     66 
     67 
     68 
     69 /**
     70 ****************************************************************************************************
     71 *   AddrDestroy
     72 *
     73 *   @brief
     74 *       Destroy address lib object
     75 *
     76 *   @return
     77 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
     78 ****************************************************************************************************
     79 */
     80 ADDR_E_RETURNCODE ADDR_API AddrDestroy(
     81     ADDR_HANDLE hLib) ///< address lib handle
     82 {
     83     ADDR_E_RETURNCODE returnCode = ADDR_OK;
     84 
     85     if (hLib)
     86     {
     87         Lib* pLib = Lib::GetLib(hLib);
     88         pLib->Destroy();
     89     }
     90     else
     91     {
     92         returnCode = ADDR_ERROR;
     93     }
     94 
     95     return returnCode;
     96 }
     97 
     98 
     99 
    100 ////////////////////////////////////////////////////////////////////////////////////////////////////
    101 //                                    Surface functions
    102 ////////////////////////////////////////////////////////////////////////////////////////////////////
    103 
    104 /**
    105 ****************************************************************************************************
    106 *   AddrComputeSurfaceInfo
    107 *
    108 *   @brief
    109 *       Calculate surface width/height/depth/alignments and suitable tiling mode
    110 *
    111 *   @return
    112 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    113 ****************************************************************************************************
    114 */
    115 ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceInfo(
    116     ADDR_HANDLE                             hLib, ///< address lib handle
    117     const ADDR_COMPUTE_SURFACE_INFO_INPUT*  pIn,  ///< [in] surface information
    118     ADDR_COMPUTE_SURFACE_INFO_OUTPUT*       pOut) ///< [out] surface parameters and alignments
    119 {
    120     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    121 
    122     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    123 
    124     if (pLib != NULL)
    125     {
    126         returnCode = pLib->ComputeSurfaceInfo(pIn, pOut);
    127     }
    128     else
    129     {
    130         returnCode = ADDR_ERROR;
    131     }
    132 
    133     return returnCode;
    134 }
    135 
    136 
    137 
    138 /**
    139 ****************************************************************************************************
    140 *   AddrComputeSurfaceAddrFromCoord
    141 *
    142 *   @brief
    143 *       Compute surface address according to coordinates
    144 *
    145 *   @return
    146 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    147 ****************************************************************************************************
    148 */
    149 ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceAddrFromCoord(
    150     ADDR_HANDLE                                     hLib, ///< address lib handle
    151     const ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn,  ///< [in] surface info and coordinates
    152     ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT*      pOut) ///< [out] surface address
    153 {
    154     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    155 
    156     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    157 
    158     if (pLib != NULL)
    159     {
    160         returnCode = pLib->ComputeSurfaceAddrFromCoord(pIn, pOut);
    161     }
    162     else
    163     {
    164         returnCode = ADDR_ERROR;
    165     }
    166 
    167     return returnCode;
    168 }
    169 
    170 /**
    171 ****************************************************************************************************
    172 *   AddrComputeSurfaceCoordFromAddr
    173 *
    174 *   @brief
    175 *       Compute coordinates according to surface address
    176 *
    177 *   @return
    178 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    179 ****************************************************************************************************
    180 */
    181 ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceCoordFromAddr(
    182     ADDR_HANDLE                                     hLib, ///< address lib handle
    183     const ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT* pIn,  ///< [in] surface info and address
    184     ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT*      pOut) ///< [out] coordinates
    185 {
    186     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    187 
    188     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    189 
    190     if (pLib != NULL)
    191     {
    192         returnCode = pLib->ComputeSurfaceCoordFromAddr(pIn, pOut);
    193     }
    194     else
    195     {
    196         returnCode = ADDR_ERROR;
    197     }
    198 
    199     return returnCode;
    200 }
    201 
    202 
    203 
    204 ////////////////////////////////////////////////////////////////////////////////////////////////////
    205 //                                   HTile functions
    206 ////////////////////////////////////////////////////////////////////////////////////////////////////
    207 
    208 /**
    209 ****************************************************************************************************
    210 *   AddrComputeHtileInfo
    211 *
    212 *   @brief
    213 *       Compute Htile pitch, height, base alignment and size in bytes
    214 *
    215 *   @return
    216 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    217 ****************************************************************************************************
    218 */
    219 ADDR_E_RETURNCODE ADDR_API AddrComputeHtileInfo(
    220     ADDR_HANDLE                             hLib, ///< address lib handle
    221     const ADDR_COMPUTE_HTILE_INFO_INPUT*    pIn,  ///< [in] Htile information
    222     ADDR_COMPUTE_HTILE_INFO_OUTPUT*         pOut) ///< [out] Htile pitch, height and size in bytes
    223 {
    224     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    225 
    226     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    227 
    228     if (pLib != NULL)
    229     {
    230         returnCode = pLib->ComputeHtileInfo(pIn, pOut);
    231     }
    232     else
    233     {
    234         returnCode = ADDR_ERROR;
    235     }
    236 
    237     return returnCode;
    238 }
    239 
    240 /**
    241 ****************************************************************************************************
    242 *   AddrComputeHtileAddrFromCoord
    243 *
    244 *   @brief
    245 *       Compute Htile address according to coordinates (of depth buffer)
    246 *
    247 *   @return
    248 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    249 ****************************************************************************************************
    250 */
    251 ADDR_E_RETURNCODE ADDR_API AddrComputeHtileAddrFromCoord(
    252     ADDR_HANDLE                                     hLib, ///< address lib handle
    253     const ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT*   pIn,  ///< [in] Htile info and coordinates
    254     ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT*        pOut) ///< [out] Htile address
    255 {
    256     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    257 
    258     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    259 
    260     if (pLib != NULL)
    261     {
    262         returnCode = pLib->ComputeHtileAddrFromCoord(pIn, pOut);
    263     }
    264     else
    265     {
    266         returnCode = ADDR_ERROR;
    267     }
    268 
    269     return returnCode;
    270 }
    271 
    272 /**
    273 ****************************************************************************************************
    274 *   AddrComputeHtileCoordFromAddr
    275 *
    276 *   @brief
    277 *       Compute coordinates within depth buffer (1st pixel of a micro tile) according to
    278 *       Htile address
    279 *
    280 *   @return
    281 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    282 ****************************************************************************************************
    283 */
    284 ADDR_E_RETURNCODE ADDR_API AddrComputeHtileCoordFromAddr(
    285     ADDR_HANDLE                                     hLib, ///< address lib handle
    286     const ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT*   pIn,  ///< [in] Htile info and address
    287     ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT*        pOut) ///< [out] Htile coordinates
    288 {
    289     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    290 
    291     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    292 
    293     if (pLib != NULL)
    294     {
    295         returnCode = pLib->ComputeHtileCoordFromAddr(pIn, pOut);
    296     }
    297     else
    298     {
    299         returnCode = ADDR_ERROR;
    300     }
    301 
    302     return returnCode;
    303 }
    304 
    305 
    306 
    307 ////////////////////////////////////////////////////////////////////////////////////////////////////
    308 //                                     C-mask functions
    309 ////////////////////////////////////////////////////////////////////////////////////////////////////
    310 
    311 /**
    312 ****************************************************************************************************
    313 *   AddrComputeCmaskInfo
    314 *
    315 *   @brief
    316 *       Compute Cmask pitch, height, base alignment and size in bytes from color buffer
    317 *       info
    318 *
    319 *   @return
    320 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    321 ****************************************************************************************************
    322 */
    323 ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskInfo(
    324     ADDR_HANDLE                             hLib, ///< address lib handle
    325     const ADDR_COMPUTE_CMASK_INFO_INPUT*    pIn,  ///< [in] Cmask pitch and height
    326     ADDR_COMPUTE_CMASK_INFO_OUTPUT*         pOut) ///< [out] Cmask pitch, height and size in bytes
    327 {
    328     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    329 
    330     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    331 
    332     if (pLib != NULL)
    333     {
    334         returnCode = pLib->ComputeCmaskInfo(pIn, pOut);
    335     }
    336     else
    337     {
    338         returnCode = ADDR_ERROR;
    339     }
    340 
    341     return returnCode;
    342 }
    343 
    344 /**
    345 ****************************************************************************************************
    346 *   AddrComputeCmaskAddrFromCoord
    347 *
    348 *   @brief
    349 *       Compute Cmask address according to coordinates (of MSAA color buffer)
    350 *
    351 *   @return
    352 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    353 ****************************************************************************************************
    354 */
    355 ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskAddrFromCoord(
    356     ADDR_HANDLE                                     hLib, ///< address lib handle
    357     const ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT*   pIn,  ///< [in] Cmask info and coordinates
    358     ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT*        pOut) ///< [out] Cmask address
    359 {
    360     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    361 
    362     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    363 
    364     if (pLib != NULL)
    365     {
    366         returnCode = pLib->ComputeCmaskAddrFromCoord(pIn, pOut);
    367     }
    368     else
    369     {
    370         returnCode = ADDR_ERROR;
    371     }
    372 
    373     return returnCode;
    374 }
    375 
    376 /**
    377 ****************************************************************************************************
    378 *   AddrComputeCmaskCoordFromAddr
    379 *
    380 *   @brief
    381 *       Compute coordinates within color buffer (1st pixel of a micro tile) according to
    382 *       Cmask address
    383 *
    384 *   @return
    385 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    386 ****************************************************************************************************
    387 */
    388 ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskCoordFromAddr(
    389     ADDR_HANDLE                                     hLib, ///< address lib handle
    390     const ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT*   pIn,  ///< [in] Cmask info and address
    391     ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT*        pOut) ///< [out] Cmask coordinates
    392 {
    393     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    394 
    395     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    396 
    397     if (pLib != NULL)
    398     {
    399         returnCode = pLib->ComputeCmaskCoordFromAddr(pIn, pOut);
    400     }
    401     else
    402     {
    403         returnCode = ADDR_ERROR;
    404     }
    405 
    406     return returnCode;
    407 }
    408 
    409 
    410 
    411 ////////////////////////////////////////////////////////////////////////////////////////////////////
    412 //                                     F-mask functions
    413 ////////////////////////////////////////////////////////////////////////////////////////////////////
    414 
    415 /**
    416 ****************************************************************************************************
    417 *   AddrComputeFmaskInfo
    418 *
    419 *   @brief
    420 *       Compute Fmask pitch/height/depth/alignments and size in bytes
    421 *
    422 *   @return
    423 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    424 ****************************************************************************************************
    425 */
    426 ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskInfo(
    427     ADDR_HANDLE                             hLib, ///< address lib handle
    428     const ADDR_COMPUTE_FMASK_INFO_INPUT*    pIn,  ///< [in] Fmask information
    429     ADDR_COMPUTE_FMASK_INFO_OUTPUT*         pOut) ///< [out] Fmask pitch and height
    430 {
    431     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    432 
    433     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    434 
    435     if (pLib != NULL)
    436     {
    437         returnCode = pLib->ComputeFmaskInfo(pIn, pOut);
    438     }
    439     else
    440     {
    441         returnCode = ADDR_ERROR;
    442     }
    443 
    444     return returnCode;
    445 }
    446 
    447 /**
    448 ****************************************************************************************************
    449 *   AddrComputeFmaskAddrFromCoord
    450 *
    451 *   @brief
    452 *       Compute Fmask address according to coordinates (x,y,slice,sample,plane)
    453 *
    454 *   @return
    455 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    456 ****************************************************************************************************
    457 */
    458 ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskAddrFromCoord(
    459     ADDR_HANDLE                                     hLib, ///< address lib handle
    460     const ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT*   pIn,  ///< [in] Fmask info and coordinates
    461     ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT*        pOut) ///< [out] Fmask address
    462 {
    463     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    464 
    465     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    466 
    467     if (pLib != NULL)
    468     {
    469         returnCode = pLib->ComputeFmaskAddrFromCoord(pIn, pOut);
    470     }
    471     else
    472     {
    473         returnCode = ADDR_ERROR;
    474     }
    475 
    476     return returnCode;
    477 }
    478 
    479 /**
    480 ****************************************************************************************************
    481 *   AddrComputeFmaskCoordFromAddr
    482 *
    483 *   @brief
    484 *       Compute coordinates (x,y,slice,sample,plane) according to Fmask address
    485 *
    486 *   @return
    487 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    488 ****************************************************************************************************
    489 */
    490 ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskCoordFromAddr(
    491     ADDR_HANDLE                                     hLib, ///< address lib handle
    492     const ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT*   pIn,  ///< [in] Fmask info and address
    493     ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT*        pOut) ///< [out] Fmask coordinates
    494 {
    495     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    496 
    497     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    498 
    499     if (pLib != NULL)
    500     {
    501         returnCode = pLib->ComputeFmaskCoordFromAddr(pIn, pOut);
    502     }
    503     else
    504     {
    505         returnCode = ADDR_ERROR;
    506     }
    507 
    508     return returnCode;
    509 }
    510 
    511 
    512 
    513 ////////////////////////////////////////////////////////////////////////////////////////////////////
    514 //                                     DCC key functions
    515 ////////////////////////////////////////////////////////////////////////////////////////////////////
    516 
    517 /**
    518 ****************************************************************************************************
    519 *   AddrComputeDccInfo
    520 *
    521 *   @brief
    522 *       Compute DCC key size, base alignment based on color surface size, tile info or tile index
    523 *
    524 ****************************************************************************************************
    525 */
    526 ADDR_E_RETURNCODE ADDR_API AddrComputeDccInfo(
    527     ADDR_HANDLE                             hLib,   ///< handle of addrlib
    528     const ADDR_COMPUTE_DCCINFO_INPUT*       pIn,    ///< [in] input
    529     ADDR_COMPUTE_DCCINFO_OUTPUT*            pOut)   ///< [out] output
    530 {
    531     ADDR_E_RETURNCODE returnCode;
    532 
    533     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    534 
    535     if (pLib != NULL)
    536     {
    537         returnCode = pLib->ComputeDccInfo(pIn, pOut);
    538     }
    539     else
    540     {
    541         returnCode = ADDR_ERROR;
    542     }
    543 
    544     return returnCode;
    545 }
    546 
    547 
    548 
    549 ///////////////////////////////////////////////////////////////////////////////
    550 // Below functions are element related or helper functions
    551 ///////////////////////////////////////////////////////////////////////////////
    552 
    553 /**
    554 ****************************************************************************************************
    555 *   AddrGetVersion
    556 *
    557 *   @brief
    558 *       Get AddrLib version number. Client may check this return value against ADDRLIB_VERSION
    559 *       defined in addrinterface.h to see if there is a mismatch.
    560 ****************************************************************************************************
    561 */
    562 UINT_32 ADDR_API AddrGetVersion(ADDR_HANDLE hLib)
    563 {
    564     UINT_32 version = 0;
    565 
    566     Addr::Lib* pLib = Lib::GetLib(hLib);
    567 
    568     ADDR_ASSERT(pLib != NULL);
    569 
    570     if (pLib)
    571     {
    572         version = pLib->GetVersion();
    573     }
    574 
    575     return version;
    576 }
    577 
    578 /**
    579 ****************************************************************************************************
    580 *   AddrUseTileIndex
    581 *
    582 *   @brief
    583 *       Return TRUE if tileIndex is enabled in this address library
    584 ****************************************************************************************************
    585 */
    586 BOOL_32 ADDR_API AddrUseTileIndex(ADDR_HANDLE hLib)
    587 {
    588     BOOL_32 useTileIndex = FALSE;
    589 
    590     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    591 
    592     ADDR_ASSERT(pLib != NULL);
    593 
    594     if (pLib)
    595     {
    596         useTileIndex = pLib->UseTileIndex(0);
    597     }
    598 
    599     return useTileIndex;
    600 }
    601 
    602 /**
    603 ****************************************************************************************************
    604 *   AddrUseCombinedSwizzle
    605 *
    606 *   @brief
    607 *       Return TRUE if combined swizzle is enabled in this address library
    608 ****************************************************************************************************
    609 */
    610 BOOL_32 ADDR_API AddrUseCombinedSwizzle(ADDR_HANDLE hLib)
    611 {
    612     BOOL_32 useCombinedSwizzle = FALSE;
    613 
    614     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    615 
    616     ADDR_ASSERT(pLib != NULL);
    617 
    618     if (pLib)
    619     {
    620         useCombinedSwizzle = pLib->UseCombinedSwizzle();
    621     }
    622 
    623     return useCombinedSwizzle;
    624 }
    625 
    626 /**
    627 ****************************************************************************************************
    628 *   AddrExtractBankPipeSwizzle
    629 *
    630 *   @brief
    631 *       Extract Bank and Pipe swizzle from base256b
    632 *   @return
    633 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    634 ****************************************************************************************************
    635 */
    636 ADDR_E_RETURNCODE ADDR_API AddrExtractBankPipeSwizzle(
    637     ADDR_HANDLE                                 hLib,     ///< addrlib handle
    638     const ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT*  pIn,      ///< [in] input structure
    639     ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT*       pOut)     ///< [out] output structure
    640 {
    641     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    642 
    643     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    644 
    645     if (pLib != NULL)
    646     {
    647         returnCode = pLib->ExtractBankPipeSwizzle(pIn, pOut);
    648     }
    649     else
    650     {
    651         returnCode = ADDR_ERROR;
    652     }
    653 
    654     return returnCode;
    655 }
    656 
    657 /**
    658 ****************************************************************************************************
    659 *   AddrCombineBankPipeSwizzle
    660 *
    661 *   @brief
    662 *       Combine Bank and Pipe swizzle
    663 *   @return
    664 *       ADDR_E_RETURNCODE
    665 ****************************************************************************************************
    666 */
    667 ADDR_E_RETURNCODE ADDR_API AddrCombineBankPipeSwizzle(
    668     ADDR_HANDLE                                 hLib,
    669     const ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT*  pIn,
    670     ADDR_COMBINE_BANKPIPE_SWIZZLE_OUTPUT*       pOut)
    671 {
    672     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    673 
    674     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    675 
    676     if (pLib != NULL)
    677     {
    678         returnCode = pLib->CombineBankPipeSwizzle(pIn, pOut);
    679     }
    680     else
    681     {
    682         returnCode = ADDR_ERROR;
    683     }
    684 
    685     return returnCode;
    686 }
    687 
    688 /**
    689 ****************************************************************************************************
    690 *   AddrComputeSliceSwizzle
    691 *
    692 *   @brief
    693 *       Compute a swizzle for slice from a base swizzle
    694 *   @return
    695 *       ADDR_OK if no error
    696 ****************************************************************************************************
    697 */
    698 ADDR_E_RETURNCODE ADDR_API AddrComputeSliceSwizzle(
    699     ADDR_HANDLE                                 hLib,
    700     const ADDR_COMPUTE_SLICESWIZZLE_INPUT*      pIn,
    701     ADDR_COMPUTE_SLICESWIZZLE_OUTPUT*           pOut)
    702 {
    703     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    704 
    705     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    706 
    707     if (pLib != NULL)
    708     {
    709         returnCode = pLib->ComputeSliceTileSwizzle(pIn, pOut);
    710     }
    711     else
    712     {
    713         returnCode = ADDR_ERROR;
    714     }
    715 
    716     return returnCode;
    717 }
    718 
    719 /**
    720 ****************************************************************************************************
    721 *   AddrComputeBaseSwizzle
    722 *
    723 *   @brief
    724 *       Return a Combined Bank and Pipe swizzle base on surface based on surface type/index
    725 *   @return
    726 *       ADDR_OK if no error
    727 ****************************************************************************************************
    728 */
    729 ADDR_E_RETURNCODE ADDR_API AddrComputeBaseSwizzle(
    730     ADDR_HANDLE                             hLib,
    731     const ADDR_COMPUTE_BASE_SWIZZLE_INPUT*  pIn,
    732     ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT*       pOut)
    733 {
    734     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    735 
    736     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    737 
    738     if (pLib != NULL)
    739     {
    740         returnCode = pLib->ComputeBaseSwizzle(pIn, pOut);
    741     }
    742     else
    743     {
    744         returnCode = ADDR_ERROR;
    745     }
    746 
    747     return returnCode;
    748 }
    749 
    750 /**
    751 ****************************************************************************************************
    752 *   ElemFlt32ToDepthPixel
    753 *
    754 *   @brief
    755 *       Convert a FLT_32 value to a depth/stencil pixel value
    756 *
    757 *   @return
    758 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    759 *
    760 ****************************************************************************************************
    761 */
    762 ADDR_E_RETURNCODE ADDR_API ElemFlt32ToDepthPixel(
    763     ADDR_HANDLE                         hLib,    ///< addrlib handle
    764     const ELEM_FLT32TODEPTHPIXEL_INPUT* pIn,     ///< [in] per-component value
    765     ELEM_FLT32TODEPTHPIXEL_OUTPUT*      pOut)    ///< [out] final pixel value
    766 {
    767     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    768 
    769     Lib* pLib = Lib::GetLib(hLib);
    770 
    771     if (pLib != NULL)
    772     {
    773         pLib->Flt32ToDepthPixel(pIn, pOut);
    774     }
    775     else
    776     {
    777         returnCode = ADDR_ERROR;
    778     }
    779 
    780     return returnCode;
    781 }
    782 
    783 /**
    784 ****************************************************************************************************
    785 *   ElemFlt32ToColorPixel
    786 *
    787 *   @brief
    788 *       Convert a FLT_32 value to a red/green/blue/alpha pixel value
    789 *
    790 *   @return
    791 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    792 *
    793 ****************************************************************************************************
    794 */
    795 ADDR_E_RETURNCODE ADDR_API ElemFlt32ToColorPixel(
    796     ADDR_HANDLE                         hLib,    ///< addrlib handle
    797     const ELEM_FLT32TOCOLORPIXEL_INPUT* pIn,     ///< [in] format, surface number and swap value
    798     ELEM_FLT32TOCOLORPIXEL_OUTPUT*      pOut)    ///< [out] final pixel value
    799 {
    800     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    801 
    802     Lib* pLib = Lib::GetLib(hLib);
    803 
    804     if (pLib != NULL)
    805     {
    806         pLib->Flt32ToColorPixel(pIn, pOut);
    807     }
    808     else
    809     {
    810         returnCode = ADDR_ERROR;
    811     }
    812 
    813     return returnCode;
    814 }
    815 
    816 /**
    817 ****************************************************************************************************
    818 *   ElemGetExportNorm
    819 *
    820 *   @brief
    821 *       Helper function to check one format can be EXPORT_NUM,
    822 *       which is a register CB_COLOR_INFO.SURFACE_FORMAT.
    823 *       FP16 can be reported as EXPORT_NORM for rv770 in r600
    824 *       family
    825 *
    826 ****************************************************************************************************
    827 */
    828 BOOL_32 ADDR_API ElemGetExportNorm(
    829     ADDR_HANDLE                     hLib, ///< addrlib handle
    830     const ELEM_GETEXPORTNORM_INPUT* pIn)  ///< [in] input structure
    831 {
    832     Addr::Lib* pLib = Lib::GetLib(hLib);
    833     BOOL_32 enabled = FALSE;
    834 
    835     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    836 
    837     if (pLib != NULL)
    838     {
    839         enabled = pLib->GetExportNorm(pIn);
    840     }
    841     else
    842     {
    843         returnCode = ADDR_ERROR;
    844     }
    845 
    846     ADDR_ASSERT(returnCode == ADDR_OK);
    847 
    848     return enabled;
    849 }
    850 
    851 /**
    852 ****************************************************************************************************
    853 *   AddrConvertTileInfoToHW
    854 *
    855 *   @brief
    856 *       Convert tile info from real value to hardware register value
    857 *
    858 *   @return
    859 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    860 ****************************************************************************************************
    861 */
    862 ADDR_E_RETURNCODE ADDR_API AddrConvertTileInfoToHW(
    863     ADDR_HANDLE                             hLib, ///< address lib handle
    864     const ADDR_CONVERT_TILEINFOTOHW_INPUT*  pIn,  ///< [in] tile info with real value
    865     ADDR_CONVERT_TILEINFOTOHW_OUTPUT*       pOut) ///< [out] tile info with HW register value
    866 {
    867     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    868 
    869     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    870 
    871     if (pLib != NULL)
    872     {
    873         returnCode = pLib->ConvertTileInfoToHW(pIn, pOut);
    874     }
    875     else
    876     {
    877         returnCode = ADDR_ERROR;
    878     }
    879 
    880     return returnCode;
    881 }
    882 
    883 /**
    884 ****************************************************************************************************
    885 *   AddrConvertTileIndex
    886 *
    887 *   @brief
    888 *       Convert tile index to tile mode/type/info
    889 *
    890 *   @return
    891 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    892 ****************************************************************************************************
    893 */
    894 ADDR_E_RETURNCODE ADDR_API AddrConvertTileIndex(
    895     ADDR_HANDLE                          hLib, ///< address lib handle
    896     const ADDR_CONVERT_TILEINDEX_INPUT*  pIn,  ///< [in] input - tile index
    897     ADDR_CONVERT_TILEINDEX_OUTPUT*       pOut) ///< [out] tile mode/type/info
    898 {
    899     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    900 
    901     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    902 
    903     if (pLib != NULL)
    904     {
    905         returnCode = pLib->ConvertTileIndex(pIn, pOut);
    906     }
    907     else
    908     {
    909         returnCode = ADDR_ERROR;
    910     }
    911 
    912     return returnCode;
    913 }
    914 
    915 /**
    916 ****************************************************************************************************
    917 *   AddrGetMacroModeIndex
    918 *
    919 *   @brief
    920 *       Get macro mode index based on input parameters
    921 *
    922 *   @return
    923 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    924 ****************************************************************************************************
    925 */
    926 ADDR_E_RETURNCODE ADDR_API AddrGetMacroModeIndex(
    927     ADDR_HANDLE                          hLib, ///< address lib handle
    928     const ADDR_GET_MACROMODEINDEX_INPUT* pIn,  ///< [in] input
    929     ADDR_GET_MACROMODEINDEX_OUTPUT*      pOut) ///< [out] macro mode index
    930 {
    931     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    932 
    933     ADDR_E_RETURNCODE returnCode;
    934 
    935     if (pLib != NULL)
    936     {
    937         returnCode = pLib->GetMacroModeIndex(pIn, pOut);
    938     }
    939     else
    940     {
    941         returnCode = ADDR_ERROR;
    942     }
    943 
    944     return returnCode;
    945 }
    946 
    947 /**
    948 ****************************************************************************************************
    949 *   AddrConvertTileIndex1
    950 *
    951 *   @brief
    952 *       Convert tile index to tile mode/type/info
    953 *
    954 *   @return
    955 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    956 ****************************************************************************************************
    957 */
    958 ADDR_E_RETURNCODE ADDR_API AddrConvertTileIndex1(
    959     ADDR_HANDLE                          hLib, ///< address lib handle
    960     const ADDR_CONVERT_TILEINDEX1_INPUT* pIn,  ///< [in] input - tile index
    961     ADDR_CONVERT_TILEINDEX_OUTPUT*       pOut) ///< [out] tile mode/type/info
    962 {
    963     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    964 
    965     ADDR_E_RETURNCODE returnCode = ADDR_OK;
    966 
    967     if (pLib != NULL)
    968     {
    969         returnCode = pLib->ConvertTileIndex1(pIn, pOut);
    970     }
    971     else
    972     {
    973         returnCode = ADDR_ERROR;
    974     }
    975 
    976     return returnCode;
    977 }
    978 
    979 /**
    980 ****************************************************************************************************
    981 *   AddrGetTileIndex
    982 *
    983 *   @brief
    984 *       Get tile index from tile mode/type/info
    985 *
    986 *   @return
    987 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
    988 *
    989 *   @note
    990 *       Only meaningful for SI (and above)
    991 ****************************************************************************************************
    992 */
    993 ADDR_E_RETURNCODE ADDR_API AddrGetTileIndex(
    994     ADDR_HANDLE                     hLib,
    995     const ADDR_GET_TILEINDEX_INPUT* pIn,
    996     ADDR_GET_TILEINDEX_OUTPUT*      pOut)
    997 {
    998     V1::Lib* pLib = V1::Lib::GetLib(hLib);
    999 
   1000     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1001 
   1002     if (pLib != NULL)
   1003     {
   1004         returnCode = pLib->GetTileIndex(pIn, pOut);
   1005     }
   1006     else
   1007     {
   1008         returnCode = ADDR_ERROR;
   1009     }
   1010 
   1011     return returnCode;
   1012 }
   1013 
   1014 /**
   1015 ****************************************************************************************************
   1016 *   AddrComputePrtInfo
   1017 *
   1018 *   @brief
   1019 *       Interface function for ComputePrtInfo
   1020 *
   1021 ****************************************************************************************************
   1022 */
   1023 ADDR_E_RETURNCODE ADDR_API AddrComputePrtInfo(
   1024     ADDR_HANDLE                 hLib,
   1025     const ADDR_PRT_INFO_INPUT*  pIn,
   1026     ADDR_PRT_INFO_OUTPUT*       pOut)
   1027 {
   1028     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1029 
   1030     V1::Lib* pLib = V1::Lib::GetLib(hLib);
   1031 
   1032     if (pLib != NULL)
   1033     {
   1034         returnCode = pLib->ComputePrtInfo(pIn, pOut);
   1035     }
   1036     else
   1037     {
   1038         returnCode = ADDR_ERROR;
   1039     }
   1040 
   1041     return returnCode;
   1042 }
   1043 
   1044 /**
   1045 ****************************************************************************************************
   1046 *   AddrGetMaxAlignments
   1047 *
   1048 *   @brief
   1049 *       Convert maximum alignments
   1050 *
   1051 *   @return
   1052 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1053 ****************************************************************************************************
   1054 */
   1055 ADDR_E_RETURNCODE ADDR_API AddrGetMaxAlignments(
   1056     ADDR_HANDLE                     hLib, ///< address lib handle
   1057     ADDR_GET_MAX_ALIGNMENTS_OUTPUT* pOut) ///< [out] output structure
   1058 {
   1059     Addr::Lib* pLib = Lib::GetLib(hLib);
   1060 
   1061     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1062 
   1063     if (pLib != NULL)
   1064     {
   1065         returnCode = pLib->GetMaxAlignments(pOut);
   1066     }
   1067     else
   1068     {
   1069         returnCode = ADDR_ERROR;
   1070     }
   1071 
   1072     return returnCode;
   1073 }
   1074 
   1075 
   1076 
   1077 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1078 //                                    Surface functions for Addr2
   1079 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1080 
   1081 /**
   1082 ****************************************************************************************************
   1083 *   Addr2ComputeSurfaceInfo
   1084 *
   1085 *   @brief
   1086 *       Calculate surface width/height/depth/alignments and suitable tiling mode
   1087 *
   1088 *   @return
   1089 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1090 ****************************************************************************************************
   1091 */
   1092 ADDR_E_RETURNCODE ADDR_API Addr2ComputeSurfaceInfo(
   1093     ADDR_HANDLE                                hLib, ///< address lib handle
   1094     const ADDR2_COMPUTE_SURFACE_INFO_INPUT*    pIn,  ///< [in] surface information
   1095     ADDR2_COMPUTE_SURFACE_INFO_OUTPUT*         pOut) ///< [out] surface parameters and alignments
   1096 {
   1097     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1098 
   1099     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1100 
   1101     if (pLib != NULL)
   1102     {
   1103         returnCode = pLib->ComputeSurfaceInfo(pIn, pOut);
   1104     }
   1105     else
   1106     {
   1107         returnCode = ADDR_ERROR;
   1108     }
   1109 
   1110     return returnCode;
   1111 }
   1112 
   1113 
   1114 /**
   1115 ****************************************************************************************************
   1116 *   Addr2ComputeSurfaceAddrFromCoord
   1117 *
   1118 *   @brief
   1119 *       Compute surface address according to coordinates
   1120 *
   1121 *   @return
   1122 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1123 ****************************************************************************************************
   1124 */
   1125 ADDR_E_RETURNCODE ADDR_API Addr2ComputeSurfaceAddrFromCoord(
   1126     ADDR_HANDLE                                         hLib, ///< address lib handle
   1127     const ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT*    pIn,  ///< [in] surface info and coordinates
   1128     ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT*         pOut) ///< [out] surface address
   1129 {
   1130     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1131 
   1132     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1133 
   1134     if (pLib != NULL)
   1135     {
   1136         returnCode = pLib->ComputeSurfaceAddrFromCoord(pIn, pOut);
   1137     }
   1138     else
   1139     {
   1140         returnCode = ADDR_ERROR;
   1141     }
   1142 
   1143     return returnCode;
   1144 }
   1145 
   1146 
   1147 /**
   1148 ****************************************************************************************************
   1149 *   Addr2ComputeSurfaceCoordFromAddr
   1150 *
   1151 *   @brief
   1152 *       Compute coordinates according to surface address
   1153 *
   1154 *   @return
   1155 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1156 ****************************************************************************************************
   1157 */
   1158 ADDR_E_RETURNCODE ADDR_API Addr2ComputeSurfaceCoordFromAddr(
   1159     ADDR_HANDLE                                         hLib, ///< address lib handle
   1160     const ADDR2_COMPUTE_SURFACE_COORDFROMADDR_INPUT*    pIn,  ///< [in] surface info and address
   1161     ADDR2_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT*         pOut) ///< [out] coordinates
   1162 {
   1163     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1164 
   1165     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1166 
   1167     if (pLib != NULL)
   1168     {
   1169         returnCode = pLib->ComputeSurfaceCoordFromAddr(pIn, pOut);
   1170     }
   1171     else
   1172     {
   1173         returnCode = ADDR_ERROR;
   1174     }
   1175 
   1176     return returnCode;
   1177 }
   1178 
   1179 
   1180 
   1181 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1182 //                                   HTile functions for Addr2
   1183 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1184 
   1185 /**
   1186 ****************************************************************************************************
   1187 *   Addr2ComputeHtileInfo
   1188 *
   1189 *   @brief
   1190 *       Compute Htile pitch, height, base alignment and size in bytes
   1191 *
   1192 *   @return
   1193 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1194 ****************************************************************************************************
   1195 */
   1196 ADDR_E_RETURNCODE ADDR_API Addr2ComputeHtileInfo(
   1197     ADDR_HANDLE                              hLib, ///< address lib handle
   1198     const ADDR2_COMPUTE_HTILE_INFO_INPUT*    pIn,  ///< [in] Htile information
   1199     ADDR2_COMPUTE_HTILE_INFO_OUTPUT*         pOut) ///< [out] Htile pitch, height and size in bytes
   1200 {
   1201     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1202 
   1203     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1204 
   1205     if (pLib != NULL)
   1206     {
   1207         returnCode = pLib->ComputeHtileInfo(pIn, pOut);
   1208     }
   1209     else
   1210     {
   1211         returnCode = ADDR_ERROR;
   1212     }
   1213 
   1214     return returnCode;
   1215 }
   1216 
   1217 
   1218 /**
   1219 ****************************************************************************************************
   1220 *   Addr2ComputeHtileAddrFromCoord
   1221 *
   1222 *   @brief
   1223 *       Compute Htile address according to coordinates (of depth buffer)
   1224 *
   1225 *   @return
   1226 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1227 ****************************************************************************************************
   1228 */
   1229 ADDR_E_RETURNCODE ADDR_API Addr2ComputeHtileAddrFromCoord(
   1230     ADDR_HANDLE                                       hLib, ///< address lib handle
   1231     const ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_INPUT*    pIn,  ///< [in] Htile info and coordinates
   1232     ADDR2_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT*         pOut) ///< [out] Htile address
   1233 {
   1234     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1235 
   1236     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1237 
   1238     if (pLib != NULL)
   1239     {
   1240         returnCode = pLib->ComputeHtileAddrFromCoord(pIn, pOut);
   1241     }
   1242     else
   1243     {
   1244         returnCode = ADDR_ERROR;
   1245     }
   1246 
   1247     return returnCode;
   1248 }
   1249 
   1250 
   1251 /**
   1252 ****************************************************************************************************
   1253 *   Addr2ComputeHtileCoordFromAddr
   1254 *
   1255 *   @brief
   1256 *       Compute coordinates within depth buffer (1st pixel of a micro tile) according to
   1257 *       Htile address
   1258 *
   1259 *   @return
   1260 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1261 ****************************************************************************************************
   1262 */
   1263 ADDR_E_RETURNCODE ADDR_API Addr2ComputeHtileCoordFromAddr(
   1264     ADDR_HANDLE                                       hLib, ///< address lib handle
   1265     const ADDR2_COMPUTE_HTILE_COORDFROMADDR_INPUT*    pIn,  ///< [in] Htile info and address
   1266     ADDR2_COMPUTE_HTILE_COORDFROMADDR_OUTPUT*         pOut) ///< [out] Htile coordinates
   1267 {
   1268     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1269 
   1270     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1271 
   1272     if (pLib != NULL)
   1273     {
   1274         returnCode = pLib->ComputeHtileCoordFromAddr(pIn, pOut);
   1275     }
   1276     else
   1277     {
   1278         returnCode = ADDR_ERROR;
   1279     }
   1280 
   1281     return returnCode;
   1282 }
   1283 
   1284 
   1285 
   1286 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1287 //                                     C-mask functions for Addr2
   1288 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1289 
   1290 /**
   1291 ****************************************************************************************************
   1292 *   Addr2ComputeCmaskInfo
   1293 *
   1294 *   @brief
   1295 *       Compute Cmask pitch, height, base alignment and size in bytes from color buffer
   1296 *       info
   1297 *
   1298 *   @return
   1299 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1300 ****************************************************************************************************
   1301 */
   1302 ADDR_E_RETURNCODE ADDR_API Addr2ComputeCmaskInfo(
   1303     ADDR_HANDLE                              hLib, ///< address lib handle
   1304     const ADDR2_COMPUTE_CMASK_INFO_INPUT*    pIn,  ///< [in] Cmask pitch and height
   1305     ADDR2_COMPUTE_CMASK_INFO_OUTPUT*         pOut) ///< [out] Cmask pitch, height and size in bytes
   1306 {
   1307     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1308 
   1309     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1310 
   1311     if (pLib != NULL)
   1312     {
   1313         returnCode = pLib->ComputeCmaskInfo(pIn, pOut);
   1314     }
   1315     else
   1316     {
   1317         returnCode = ADDR_ERROR;
   1318     }
   1319 
   1320     return returnCode;
   1321 }
   1322 
   1323 
   1324 /**
   1325 ****************************************************************************************************
   1326 *   Addr2ComputeCmaskAddrFromCoord
   1327 *
   1328 *   @brief
   1329 *       Compute Cmask address according to coordinates (of MSAA color buffer)
   1330 *
   1331 *   @return
   1332 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1333 ****************************************************************************************************
   1334 */
   1335 ADDR_E_RETURNCODE ADDR_API Addr2ComputeCmaskAddrFromCoord(
   1336     ADDR_HANDLE                                       hLib, ///< address lib handle
   1337     const ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_INPUT*    pIn,  ///< [in] Cmask info and coordinates
   1338     ADDR2_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT*         pOut) ///< [out] Cmask address
   1339 {
   1340     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1341 
   1342     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1343 
   1344     if (pLib != NULL)
   1345     {
   1346         returnCode = pLib->ComputeCmaskAddrFromCoord(pIn, pOut);
   1347     }
   1348     else
   1349     {
   1350         returnCode = ADDR_ERROR;
   1351     }
   1352 
   1353     return returnCode;
   1354 }
   1355 
   1356 
   1357 /**
   1358 ****************************************************************************************************
   1359 *   Addr2ComputeCmaskCoordFromAddr
   1360 *
   1361 *   @brief
   1362 *       Compute coordinates within color buffer (1st pixel of a micro tile) according to
   1363 *       Cmask address
   1364 *
   1365 *   @return
   1366 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1367 ****************************************************************************************************
   1368 */
   1369 ADDR_E_RETURNCODE ADDR_API Addr2ComputeCmaskCoordFromAddr(
   1370     ADDR_HANDLE                                       hLib, ///< address lib handle
   1371     const ADDR2_COMPUTE_CMASK_COORDFROMADDR_INPUT*    pIn,  ///< [in] Cmask info and address
   1372     ADDR2_COMPUTE_CMASK_COORDFROMADDR_OUTPUT*         pOut) ///< [out] Cmask coordinates
   1373 {
   1374     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1375 
   1376     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1377 
   1378     if (pLib != NULL)
   1379     {
   1380         returnCode = pLib->ComputeCmaskCoordFromAddr(pIn, pOut);
   1381     }
   1382     else
   1383     {
   1384         returnCode = ADDR_ERROR;
   1385     }
   1386 
   1387     return returnCode;
   1388 }
   1389 
   1390 
   1391 
   1392 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1393 //                                     F-mask functions for Addr2
   1394 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1395 
   1396 /**
   1397 ****************************************************************************************************
   1398 *   Addr2ComputeFmaskInfo
   1399 *
   1400 *   @brief
   1401 *       Compute Fmask pitch/height/depth/alignments and size in bytes
   1402 *
   1403 *   @return
   1404 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1405 ****************************************************************************************************
   1406 */
   1407 ADDR_E_RETURNCODE ADDR_API Addr2ComputeFmaskInfo(
   1408     ADDR_HANDLE                              hLib, ///< address lib handle
   1409     const ADDR2_COMPUTE_FMASK_INFO_INPUT*    pIn,  ///< [in] Fmask information
   1410     ADDR2_COMPUTE_FMASK_INFO_OUTPUT*         pOut) ///< [out] Fmask pitch and height
   1411 {
   1412     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1413 
   1414     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1415 
   1416     if (pLib != NULL)
   1417     {
   1418         returnCode = pLib->ComputeFmaskInfo(pIn, pOut);
   1419     }
   1420     else
   1421     {
   1422         returnCode = ADDR_ERROR;
   1423     }
   1424 
   1425     return returnCode;
   1426 }
   1427 
   1428 
   1429 /**
   1430 ****************************************************************************************************
   1431 *   Addr2ComputeFmaskAddrFromCoord
   1432 *
   1433 *   @brief
   1434 *       Compute Fmask address according to coordinates (x,y,slice,sample,plane)
   1435 *
   1436 *   @return
   1437 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1438 ****************************************************************************************************
   1439 */
   1440 ADDR_E_RETURNCODE ADDR_API Addr2ComputeFmaskAddrFromCoord(
   1441     ADDR_HANDLE                                       hLib, ///< address lib handle
   1442     const ADDR2_COMPUTE_FMASK_ADDRFROMCOORD_INPUT*    pIn,  ///< [in] Fmask info and coordinates
   1443     ADDR2_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT*         pOut) ///< [out] Fmask address
   1444 {
   1445     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1446 
   1447     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1448 
   1449     if (pLib != NULL)
   1450     {
   1451         returnCode = pLib->ComputeFmaskAddrFromCoord(pIn, pOut);
   1452     }
   1453     else
   1454     {
   1455         returnCode = ADDR_ERROR;
   1456     }
   1457 
   1458     return returnCode;
   1459 }
   1460 
   1461 
   1462 /**
   1463 ****************************************************************************************************
   1464 *   Addr2ComputeFmaskCoordFromAddr
   1465 *
   1466 *   @brief
   1467 *       Compute coordinates (x,y,slice,sample,plane) according to Fmask address
   1468 *
   1469 *   @return
   1470 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1471 ****************************************************************************************************
   1472 */
   1473 ADDR_E_RETURNCODE ADDR_API Addr2ComputeFmaskCoordFromAddr(
   1474     ADDR_HANDLE                                       hLib, ///< address lib handle
   1475     const ADDR2_COMPUTE_FMASK_COORDFROMADDR_INPUT*    pIn,  ///< [in] Fmask info and address
   1476     ADDR2_COMPUTE_FMASK_COORDFROMADDR_OUTPUT*         pOut) ///< [out] Fmask coordinates
   1477 {
   1478     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1479 
   1480     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1481 
   1482     if (pLib != NULL)
   1483     {
   1484         returnCode = pLib->ComputeFmaskCoordFromAddr(pIn, pOut);
   1485     }
   1486     else
   1487     {
   1488         returnCode = ADDR_ERROR;
   1489     }
   1490 
   1491     return returnCode;
   1492 }
   1493 
   1494 
   1495 
   1496 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1497 //                                     DCC key functions for Addr2
   1498 ////////////////////////////////////////////////////////////////////////////////////////////////////
   1499 
   1500 /**
   1501 ****************************************************************************************************
   1502 *   Addr2ComputeDccInfo
   1503 *
   1504 *   @brief
   1505 *       Compute DCC key size, base alignment based on color surface size, tile info or tile index
   1506 *
   1507 ****************************************************************************************************
   1508 */
   1509 ADDR_E_RETURNCODE ADDR_API Addr2ComputeDccInfo(
   1510     ADDR_HANDLE                           hLib,   ///< handle of addrlib
   1511     const ADDR2_COMPUTE_DCCINFO_INPUT*    pIn,    ///< [in] input
   1512     ADDR2_COMPUTE_DCCINFO_OUTPUT*         pOut)   ///< [out] output
   1513 {
   1514     ADDR_E_RETURNCODE returnCode;
   1515 
   1516     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1517 
   1518     if (pLib != NULL)
   1519     {
   1520         returnCode = pLib->ComputeDccInfo(pIn, pOut);
   1521     }
   1522     else
   1523     {
   1524         returnCode = ADDR_ERROR;
   1525     }
   1526 
   1527     return returnCode;
   1528 }
   1529 
   1530 /**
   1531 ****************************************************************************************************
   1532 *   Addr2ComputeDccAddrFromCoord
   1533 *
   1534 *   @brief
   1535 *       Compute DCC key address according to coordinates
   1536 *
   1537 *   @return
   1538 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
   1539 ****************************************************************************************************
   1540 */
   1541 ADDR_E_RETURNCODE ADDR_API Addr2ComputeDccAddrFromCoord(
   1542     ADDR_HANDLE                                     hLib, ///< address lib handle
   1543     const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT*    pIn,  ///< [in] Dcc info and coordinates
   1544     ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT*         pOut) ///< [out] Dcc address
   1545 {
   1546     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1547 
   1548     ADDR_E_RETURNCODE returnCode = ADDR_OK;
   1549 
   1550     if (pLib != NULL)
   1551     {
   1552         returnCode = pLib->ComputeDccAddrFromCoord(pIn, pOut);
   1553     }
   1554     else
   1555     {
   1556         returnCode = ADDR_ERROR;
   1557     }
   1558 
   1559     return returnCode;
   1560 }
   1561 
   1562 /**
   1563 ****************************************************************************************************
   1564 *   Addr2ComputePipeBankXor
   1565 *
   1566 *   @brief
   1567 *       Calculate a valid bank pipe xor value for client to use.
   1568 ****************************************************************************************************
   1569 */
   1570 ADDR_E_RETURNCODE ADDR_API Addr2ComputePipeBankXor(
   1571     ADDR_HANDLE                            hLib, ///< handle of addrlib
   1572     const ADDR2_COMPUTE_PIPEBANKXOR_INPUT* pIn,  ///< [in] input
   1573     ADDR2_COMPUTE_PIPEBANKXOR_OUTPUT*      pOut) ///< [out] output
   1574 {
   1575     ADDR_E_RETURNCODE returnCode;
   1576 
   1577     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1578 
   1579     if (pLib != NULL)
   1580     {
   1581         returnCode = pLib->ComputePipeBankXor(pIn, pOut);
   1582     }
   1583     else
   1584     {
   1585         returnCode = ADDR_ERROR;
   1586     }
   1587 
   1588     return returnCode;
   1589 }
   1590 
   1591 /**
   1592 ****************************************************************************************************
   1593 *   Addr2ComputeSlicePipeBankXor
   1594 *
   1595 *   @brief
   1596 *       Calculate slice pipe bank xor value based on base pipe bank xor and slice id.
   1597 ****************************************************************************************************
   1598 */
   1599 ADDR_E_RETURNCODE ADDR_API Addr2ComputeSlicePipeBankXor(
   1600     ADDR_HANDLE                                  hLib, ///< handle of addrlib
   1601     const ADDR2_COMPUTE_SLICE_PIPEBANKXOR_INPUT* pIn,  ///< [in] input
   1602     ADDR2_COMPUTE_SLICE_PIPEBANKXOR_OUTPUT*      pOut) ///< [out] output
   1603 {
   1604     ADDR_E_RETURNCODE returnCode;
   1605 
   1606     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1607 
   1608     if (pLib != NULL)
   1609     {
   1610         returnCode = pLib->ComputeSlicePipeBankXor(pIn, pOut);
   1611     }
   1612     else
   1613     {
   1614         returnCode = ADDR_ERROR;
   1615     }
   1616 
   1617     return returnCode;
   1618 }
   1619 
   1620 /**
   1621 ****************************************************************************************************
   1622 *   Addr2ComputeSubResourceOffsetForSwizzlePattern
   1623 *
   1624 *   @brief
   1625 *       Calculate sub resource offset for swizzle pattern.
   1626 ****************************************************************************************************
   1627 */
   1628 ADDR_E_RETURNCODE ADDR_API Addr2ComputeSubResourceOffsetForSwizzlePattern(
   1629     ADDR_HANDLE                                                     hLib, ///< handle of addrlib
   1630     const ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_INPUT* pIn,  ///< [in] input
   1631     ADDR2_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_OUTPUT*      pOut) ///< [out] output
   1632 {
   1633     ADDR_E_RETURNCODE returnCode;
   1634 
   1635     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1636 
   1637     if (pLib != NULL)
   1638     {
   1639         returnCode = pLib->ComputeSubResourceOffsetForSwizzlePattern(pIn, pOut);
   1640     }
   1641     else
   1642     {
   1643         returnCode = ADDR_ERROR;
   1644     }
   1645 
   1646     return returnCode;
   1647 }
   1648 
   1649 /**
   1650 ****************************************************************************************************
   1651 *   Addr2GetPreferredSurfaceSetting
   1652 *
   1653 *   @brief
   1654 *       Suggest a preferred setting for client driver to program HW register
   1655 ****************************************************************************************************
   1656 */
   1657 ADDR_E_RETURNCODE ADDR_API Addr2GetPreferredSurfaceSetting(
   1658     ADDR_HANDLE                                   hLib, ///< handle of addrlib
   1659     const ADDR2_GET_PREFERRED_SURF_SETTING_INPUT* pIn,  ///< [in] input
   1660     ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT*      pOut) ///< [out] output
   1661 {
   1662     ADDR_E_RETURNCODE returnCode;
   1663 
   1664     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1665 
   1666     if (pLib != NULL)
   1667     {
   1668         returnCode = pLib->Addr2GetPreferredSurfaceSetting(pIn, pOut);
   1669     }
   1670     else
   1671     {
   1672         returnCode = ADDR_ERROR;
   1673     }
   1674 
   1675     return returnCode;
   1676 }
   1677 
   1678 /**
   1679 ****************************************************************************************************
   1680 *   Addr2IsValidDisplaySwizzleMode
   1681 *
   1682 *   @brief
   1683 *       Return whether the swizzle mode is supported by DCE / DCN.
   1684 ****************************************************************************************************
   1685 */
   1686 ADDR_E_RETURNCODE ADDR_API Addr2IsValidDisplaySwizzleMode(
   1687     ADDR_HANDLE     hLib,
   1688     AddrSwizzleMode swizzleMode,
   1689     UINT_32         bpp,
   1690     bool            *result)
   1691 {
   1692     ADDR_E_RETURNCODE returnCode;
   1693 
   1694     V2::Lib* pLib = V2::Lib::GetLib(hLib);
   1695 
   1696     if (pLib != NULL)
   1697     {
   1698         ADDR2_COMPUTE_SURFACE_INFO_INPUT in;
   1699         in.swizzleMode = swizzleMode;
   1700         in.bpp = bpp;
   1701 
   1702         *result = pLib->IsValidDisplaySwizzleMode(&in);
   1703         returnCode = ADDR_OK;
   1704     }
   1705     else
   1706     {
   1707         returnCode = ADDR_ERROR;
   1708     }
   1709 
   1710     return returnCode;
   1711 }
   1712