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