• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "addrlib.h"
35 
36 #include "addrcommon.h"
37 
38 ///////////////////////////////////////////////////////////////////////////////////////////////////
39 //                               Create/Destroy/Config functions
40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 
42 /**
43 ***************************************************************************************************
44 *   AddrCreate
45 *
46 *   @brief
47 *       Create address lib object
48 *
49 *   @return
50 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
51 ***************************************************************************************************
52 */
AddrCreate(const ADDR_CREATE_INPUT * pAddrCreateIn,ADDR_CREATE_OUTPUT * pAddrCreateOut)53 ADDR_E_RETURNCODE ADDR_API AddrCreate(
54     const ADDR_CREATE_INPUT*    pAddrCreateIn,  ///< [in] infomation for creating address lib object
55     ADDR_CREATE_OUTPUT*         pAddrCreateOut) ///< [out] address lib handle
56 {
57     ADDR_E_RETURNCODE returnCode = ADDR_OK;
58 
59     returnCode = AddrLib::Create(pAddrCreateIn, pAddrCreateOut);
60 
61     return returnCode;
62 }
63 
64 
65 
66 /**
67 ***************************************************************************************************
68 *   AddrDestroy
69 *
70 *   @brief
71 *       Destroy address lib object
72 *
73 *   @return
74 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
75 ***************************************************************************************************
76 */
AddrDestroy(ADDR_HANDLE hLib)77 ADDR_E_RETURNCODE ADDR_API AddrDestroy(
78     ADDR_HANDLE hLib) ///< [in] address lib handle
79 {
80     ADDR_E_RETURNCODE returnCode = ADDR_OK;
81 
82     if (hLib)
83     {
84         AddrLib* pLib = AddrLib::GetAddrLib(hLib);
85         pLib->Destroy();
86     }
87     else
88     {
89         returnCode = ADDR_ERROR;
90     }
91 
92     return returnCode;
93 }
94 
95 
96 
97 ///////////////////////////////////////////////////////////////////////////////////////////////////
98 //                                    Surface functions
99 ///////////////////////////////////////////////////////////////////////////////////////////////////
100 
101 /**
102 ***************************************************************************************************
103 *   AddrComputeSurfaceInfo
104 *
105 *   @brief
106 *       Calculate surface width/height/depth/alignments and suitable tiling mode
107 *
108 *   @return
109 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
110 ***************************************************************************************************
111 */
AddrComputeSurfaceInfo(ADDR_HANDLE hLib,const ADDR_COMPUTE_SURFACE_INFO_INPUT * pIn,ADDR_COMPUTE_SURFACE_INFO_OUTPUT * pOut)112 ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceInfo(
113     ADDR_HANDLE                             hLib, ///< [in] address lib handle
114     const ADDR_COMPUTE_SURFACE_INFO_INPUT*  pIn,  ///< [in] surface information
115     ADDR_COMPUTE_SURFACE_INFO_OUTPUT*       pOut) ///< [out] surface parameters and alignments
116 {
117     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
118 
119     ADDR_E_RETURNCODE returnCode = ADDR_OK;
120 
121     if (pLib != NULL)
122     {
123         returnCode = pLib->ComputeSurfaceInfo(pIn, pOut);
124     }
125     else
126     {
127         returnCode = ADDR_ERROR;
128     }
129 
130     return returnCode;
131 }
132 
133 
134 
135 /**
136 ***************************************************************************************************
137 *   AddrComputeSurfaceAddrFromCoord
138 *
139 *   @brief
140 *       Compute surface address according to coordinates
141 *
142 *   @return
143 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
144 ***************************************************************************************************
145 */
AddrComputeSurfaceAddrFromCoord(ADDR_HANDLE hLib,const ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT * pIn,ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT * pOut)146 ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceAddrFromCoord(
147     ADDR_HANDLE                                     hLib, ///< [in] address lib handle
148     const ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn,  ///< [in] surface info and coordinates
149     ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT*      pOut) ///< [out] surface address
150 {
151     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
152 
153     ADDR_E_RETURNCODE returnCode = ADDR_OK;
154 
155     if (pLib != NULL)
156     {
157         returnCode = pLib->ComputeSurfaceAddrFromCoord(pIn, pOut);
158     }
159     else
160     {
161         returnCode = ADDR_ERROR;
162     }
163 
164     return returnCode;
165 }
166 
167 /**
168 ***************************************************************************************************
169 *   AddrComputeSurfaceCoordFromAddr
170 *
171 *   @brief
172 *       Compute coordinates according to surface address
173 *
174 *   @return
175 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
176 ***************************************************************************************************
177 */
AddrComputeSurfaceCoordFromAddr(ADDR_HANDLE hLib,const ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT * pIn,ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT * pOut)178 ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceCoordFromAddr(
179     ADDR_HANDLE                                     hLib, ///< [in] address lib handle
180     const ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT* pIn,  ///< [in] surface info and address
181     ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT*      pOut) ///< [out] coordinates
182 {
183     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
184 
185     ADDR_E_RETURNCODE returnCode = ADDR_OK;
186 
187     if (pLib != NULL)
188     {
189         returnCode = pLib->ComputeSurfaceCoordFromAddr(pIn, pOut);
190     }
191     else
192     {
193         returnCode = ADDR_ERROR;
194     }
195 
196     return returnCode;
197 }
198 
199 
200 
201 ///////////////////////////////////////////////////////////////////////////////////////////////////
202 //                                   HTile functions
203 ///////////////////////////////////////////////////////////////////////////////////////////////////
204 
205 /**
206 ***************************************************************************************************
207 *   AddrComputeHtileInfo
208 *
209 *   @brief
210 *       Compute Htile pitch, height, base alignment and size in bytes
211 *
212 *   @return
213 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
214 ***************************************************************************************************
215 */
AddrComputeHtileInfo(ADDR_HANDLE hLib,const ADDR_COMPUTE_HTILE_INFO_INPUT * pIn,ADDR_COMPUTE_HTILE_INFO_OUTPUT * pOut)216 ADDR_E_RETURNCODE ADDR_API AddrComputeHtileInfo(
217     ADDR_HANDLE                             hLib, ///< [in] address lib handle
218     const ADDR_COMPUTE_HTILE_INFO_INPUT*    pIn,  ///< [in] Htile information
219     ADDR_COMPUTE_HTILE_INFO_OUTPUT*         pOut) ///< [out] Htile pitch, height and size in bytes
220 {
221     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
222 
223     ADDR_E_RETURNCODE returnCode = ADDR_OK;
224 
225     if (pLib != NULL)
226     {
227         returnCode = pLib->ComputeHtileInfo(pIn, pOut);
228     }
229     else
230     {
231         returnCode = ADDR_ERROR;
232     }
233 
234     return returnCode;
235 }
236 
237 /**
238 ***************************************************************************************************
239 *   AddrComputeHtileAddrFromCoord
240 *
241 *   @brief
242 *       Compute Htile address according to coordinates (of depth buffer)
243 *
244 *   @return
245 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
246 ***************************************************************************************************
247 */
AddrComputeHtileAddrFromCoord(ADDR_HANDLE hLib,const ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT * pIn,ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT * pOut)248 ADDR_E_RETURNCODE ADDR_API AddrComputeHtileAddrFromCoord(
249     ADDR_HANDLE                                     hLib, ///< [in] address lib handle
250     const ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT*   pIn,  ///< [in] Htile info and coordinates
251     ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT*        pOut) ///< [out] Htile address
252 {
253     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
254 
255     ADDR_E_RETURNCODE returnCode = ADDR_OK;
256 
257     if (pLib != NULL)
258     {
259         returnCode = pLib->ComputeHtileAddrFromCoord(pIn, pOut);
260     }
261     else
262     {
263         returnCode = ADDR_ERROR;
264     }
265 
266     return returnCode;
267 }
268 
269 /**
270 ***************************************************************************************************
271 *   AddrComputeHtileCoordFromAddr
272 *
273 *   @brief
274 *       Compute coordinates within depth buffer (1st pixel of a micro tile) according to
275 *       Htile address
276 *
277 *   @return
278 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
279 ***************************************************************************************************
280 */
AddrComputeHtileCoordFromAddr(ADDR_HANDLE hLib,const ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT * pIn,ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT * pOut)281 ADDR_E_RETURNCODE ADDR_API AddrComputeHtileCoordFromAddr(
282     ADDR_HANDLE                                     hLib, ///< [in] address lib handle
283     const ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT*   pIn,  ///< [in] Htile info and address
284     ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT*        pOut) ///< [out] Htile coordinates
285 {
286     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
287 
288     ADDR_E_RETURNCODE returnCode = ADDR_OK;
289 
290     if (pLib != NULL)
291     {
292         returnCode = pLib->ComputeHtileCoordFromAddr(pIn, pOut);
293     }
294     else
295     {
296         returnCode = ADDR_ERROR;
297     }
298 
299     return returnCode;
300 }
301 
302 
303 
304 ///////////////////////////////////////////////////////////////////////////////////////////////////
305 //                                     C-mask functions
306 ///////////////////////////////////////////////////////////////////////////////////////////////////
307 
308 /**
309 ***************************************************************************************************
310 *   AddrComputeCmaskInfo
311 *
312 *   @brief
313 *       Compute Cmask pitch, height, base alignment and size in bytes from color buffer
314 *       info
315 *
316 *   @return
317 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
318 ***************************************************************************************************
319 */
AddrComputeCmaskInfo(ADDR_HANDLE hLib,const ADDR_COMPUTE_CMASK_INFO_INPUT * pIn,ADDR_COMPUTE_CMASK_INFO_OUTPUT * pOut)320 ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskInfo(
321     ADDR_HANDLE                             hLib, ///< [in] address lib handle
322     const ADDR_COMPUTE_CMASK_INFO_INPUT*    pIn,  ///< [in] Cmask pitch and height
323     ADDR_COMPUTE_CMASK_INFO_OUTPUT*         pOut) ///< [out] Cmask pitch, height and size in bytes
324 {
325     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
326 
327     ADDR_E_RETURNCODE returnCode = ADDR_OK;
328 
329     if (pLib != NULL)
330     {
331         returnCode = pLib->ComputeCmaskInfo(pIn, pOut);
332     }
333     else
334     {
335         returnCode = ADDR_ERROR;
336     }
337 
338     return returnCode;
339 }
340 
341 /**
342 ***************************************************************************************************
343 *   AddrComputeCmaskAddrFromCoord
344 *
345 *   @brief
346 *       Compute Cmask address according to coordinates (of MSAA color buffer)
347 *
348 *   @return
349 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
350 ***************************************************************************************************
351 */
AddrComputeCmaskAddrFromCoord(ADDR_HANDLE hLib,const ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT * pIn,ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT * pOut)352 ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskAddrFromCoord(
353     ADDR_HANDLE                                     hLib, ///< [in] address lib handle
354     const ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT*   pIn,  ///< [in] Cmask info and coordinates
355     ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT*        pOut) ///< [out] Cmask address
356 {
357     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
358 
359     ADDR_E_RETURNCODE returnCode = ADDR_OK;
360 
361     if (pLib != NULL)
362     {
363         returnCode = pLib->ComputeCmaskAddrFromCoord(pIn, pOut);
364     }
365     else
366     {
367         returnCode = ADDR_ERROR;
368     }
369 
370     return returnCode;
371 }
372 
373 /**
374 ***************************************************************************************************
375 *   AddrComputeCmaskCoordFromAddr
376 *
377 *   @brief
378 *       Compute coordinates within color buffer (1st pixel of a micro tile) according to
379 *       Cmask address
380 *
381 *   @return
382 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
383 ***************************************************************************************************
384 */
AddrComputeCmaskCoordFromAddr(ADDR_HANDLE hLib,const ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT * pIn,ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT * pOut)385 ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskCoordFromAddr(
386     ADDR_HANDLE                                     hLib, ///< [in] address lib handle
387     const ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT*   pIn,  ///< [in] Cmask info and address
388     ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT*        pOut) ///< [out] Cmask coordinates
389 {
390     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
391 
392     ADDR_E_RETURNCODE returnCode = ADDR_OK;
393 
394     if (pLib != NULL)
395     {
396         returnCode = pLib->ComputeCmaskCoordFromAddr(pIn, pOut);
397     }
398     else
399     {
400         returnCode = ADDR_ERROR;
401     }
402 
403     return returnCode;
404 }
405 
406 
407 
408 ///////////////////////////////////////////////////////////////////////////////////////////////////
409 //                                     F-mask functions
410 ///////////////////////////////////////////////////////////////////////////////////////////////////
411 
412 /**
413 ***************************************************************************************************
414 *   AddrComputeFmaskInfo
415 *
416 *   @brief
417 *       Compute Fmask pitch/height/depth/alignments and size in bytes
418 *
419 *   @return
420 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
421 ***************************************************************************************************
422 */
AddrComputeFmaskInfo(ADDR_HANDLE hLib,const ADDR_COMPUTE_FMASK_INFO_INPUT * pIn,ADDR_COMPUTE_FMASK_INFO_OUTPUT * pOut)423 ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskInfo(
424     ADDR_HANDLE                             hLib, ///< [in] address lib handle
425     const ADDR_COMPUTE_FMASK_INFO_INPUT*    pIn,  ///< [in] Fmask information
426     ADDR_COMPUTE_FMASK_INFO_OUTPUT*         pOut) ///< [out] Fmask pitch and height
427 {
428     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
429 
430     ADDR_E_RETURNCODE returnCode = ADDR_OK;
431 
432     if (pLib != NULL)
433     {
434         returnCode = pLib->ComputeFmaskInfo(pIn, pOut);
435     }
436     else
437     {
438         returnCode = ADDR_ERROR;
439     }
440 
441     return returnCode;
442 }
443 
444 /**
445 ***************************************************************************************************
446 *   AddrComputeFmaskAddrFromCoord
447 *
448 *   @brief
449 *       Compute Fmask address according to coordinates (x,y,slice,sample,plane)
450 *
451 *   @return
452 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
453 ***************************************************************************************************
454 */
AddrComputeFmaskAddrFromCoord(ADDR_HANDLE hLib,const ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT * pIn,ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT * pOut)455 ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskAddrFromCoord(
456     ADDR_HANDLE                                     hLib, ///< [in] address lib handle
457     const ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT*   pIn,  ///< [in] Fmask info and coordinates
458     ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT*        pOut) ///< [out] Fmask address
459 {
460     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
461 
462     ADDR_E_RETURNCODE returnCode = ADDR_OK;
463 
464     if (pLib != NULL)
465     {
466         returnCode = pLib->ComputeFmaskAddrFromCoord(pIn, pOut);
467     }
468     else
469     {
470         returnCode = ADDR_ERROR;
471     }
472 
473     return returnCode;
474 }
475 
476 /**
477 ***************************************************************************************************
478 *   AddrComputeFmaskCoordFromAddr
479 *
480 *   @brief
481 *       Compute coordinates (x,y,slice,sample,plane) according to Fmask address
482 *
483 *   @return
484 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
485 ***************************************************************************************************
486 */
AddrComputeFmaskCoordFromAddr(ADDR_HANDLE hLib,const ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT * pIn,ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT * pOut)487 ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskCoordFromAddr(
488     ADDR_HANDLE                                     hLib, ///< [in] address lib handle
489     const ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT*   pIn,  ///< [in] Fmask info and address
490     ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT*        pOut) ///< [out] Fmask coordinates
491 {
492     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
493 
494     ADDR_E_RETURNCODE returnCode = ADDR_OK;
495 
496     if (pLib != NULL)
497     {
498         returnCode = pLib->ComputeFmaskCoordFromAddr(pIn, pOut);
499     }
500     else
501     {
502         returnCode = ADDR_ERROR;
503     }
504 
505     return returnCode;
506 }
507 
508 
509 
510 ///////////////////////////////////////////////////////////////////////////////////////////////////
511 //                                     DCC key functions
512 ///////////////////////////////////////////////////////////////////////////////////////////////////
513 
514 /**
515 ***************************************************************************************************
516 *   AddrComputeDccInfo
517 *
518 *   @brief
519 *       Compute DCC key size, base alignment based on color surface size, tile info or tile index
520 *
521 ***************************************************************************************************
522 */
AddrComputeDccInfo(ADDR_HANDLE hLib,const ADDR_COMPUTE_DCCINFO_INPUT * pIn,ADDR_COMPUTE_DCCINFO_OUTPUT * pOut)523 ADDR_E_RETURNCODE ADDR_API AddrComputeDccInfo(
524     ADDR_HANDLE                             hLib,   ///< [in] handle of addrlib
525     const ADDR_COMPUTE_DCCINFO_INPUT*       pIn,    ///< [in] input
526     ADDR_COMPUTE_DCCINFO_OUTPUT*            pOut)   ///< [out] output
527 {
528     ADDR_E_RETURNCODE returnCode;
529 
530     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
531 
532     if (pLib != NULL)
533     {
534        returnCode = pLib->ComputeDccInfo(pIn, pOut);
535     }
536     else
537     {
538        returnCode = ADDR_ERROR;
539     }
540 
541     return returnCode;
542 }
543 
544 
545 
546 ///////////////////////////////////////////////////////////////////////////////
547 // Below functions are element related or helper functions
548 ///////////////////////////////////////////////////////////////////////////////
549 
550 /**
551 ***************************************************************************************************
552 *   AddrGetVersion
553 *
554 *   @brief
555 *       Get AddrLib version number. Client may check this return value against ADDRLIB_VERSION
556 *       defined in addrinterface.h to see if there is a mismatch.
557 ***************************************************************************************************
558 */
AddrGetVersion(ADDR_HANDLE hLib)559 UINT_32 ADDR_API AddrGetVersion(ADDR_HANDLE hLib)
560 {
561     UINT_32 version = 0;
562 
563     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
564 
565     ADDR_ASSERT(pLib != NULL);
566 
567     if (pLib)
568     {
569         version = pLib->GetVersion();
570     }
571 
572     return version;
573 }
574 
575 /**
576 ***************************************************************************************************
577 *   AddrUseTileIndex
578 *
579 *   @brief
580 *       Return TRUE if tileIndex is enabled in this address library
581 ***************************************************************************************************
582 */
AddrUseTileIndex(ADDR_HANDLE hLib)583 BOOL_32 ADDR_API AddrUseTileIndex(ADDR_HANDLE hLib)
584 {
585     BOOL_32 useTileIndex = FALSE;
586 
587     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
588 
589     ADDR_ASSERT(pLib != NULL);
590 
591     if (pLib)
592     {
593         useTileIndex = pLib->UseTileIndex(0);
594     }
595 
596     return useTileIndex;
597 }
598 
599 /**
600 ***************************************************************************************************
601 *   AddrUseCombinedSwizzle
602 *
603 *   @brief
604 *       Return TRUE if combined swizzle is enabled in this address library
605 ***************************************************************************************************
606 */
AddrUseCombinedSwizzle(ADDR_HANDLE hLib)607 BOOL_32 ADDR_API AddrUseCombinedSwizzle(ADDR_HANDLE hLib)
608 {
609     BOOL_32 useCombinedSwizzle = FALSE;
610 
611     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
612 
613     ADDR_ASSERT(pLib != NULL);
614 
615     if (pLib)
616     {
617         useCombinedSwizzle = pLib->UseCombinedSwizzle();
618     }
619 
620     return useCombinedSwizzle;
621 }
622 
623 /**
624 ***************************************************************************************************
625 *   AddrExtractBankPipeSwizzle
626 *
627 *   @brief
628 *       Extract Bank and Pipe swizzle from base256b
629 *   @return
630 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
631 ***************************************************************************************************
632 */
AddrExtractBankPipeSwizzle(ADDR_HANDLE hLib,const ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT * pIn,ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT * pOut)633 ADDR_E_RETURNCODE ADDR_API AddrExtractBankPipeSwizzle(
634     ADDR_HANDLE                                 hLib,     ///< [in] addrlib handle
635     const ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT*  pIn,      ///< [in] input structure
636     ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT*       pOut)     ///< [out] output structure
637 {
638     ADDR_E_RETURNCODE returnCode = ADDR_OK;
639 
640     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
641 
642     if (pLib != NULL)
643     {
644         returnCode = pLib->ExtractBankPipeSwizzle(pIn, pOut);
645     }
646     else
647     {
648         returnCode = ADDR_ERROR;
649     }
650 
651     return returnCode;
652 }
653 
654 /**
655 ***************************************************************************************************
656 *   AddrCombineBankPipeSwizzle
657 *
658 *   @brief
659 *       Combine Bank and Pipe swizzle
660 *   @return
661 *       ADDR_E_RETURNCODE
662 ***************************************************************************************************
663 */
AddrCombineBankPipeSwizzle(ADDR_HANDLE hLib,const ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT * pIn,ADDR_COMBINE_BANKPIPE_SWIZZLE_OUTPUT * pOut)664 ADDR_E_RETURNCODE ADDR_API AddrCombineBankPipeSwizzle(
665     ADDR_HANDLE                                 hLib,
666     const ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT*  pIn,
667     ADDR_COMBINE_BANKPIPE_SWIZZLE_OUTPUT*       pOut)
668 {
669     ADDR_E_RETURNCODE returnCode = ADDR_OK;
670 
671     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
672 
673     if (pLib != NULL)
674     {
675         returnCode = pLib->CombineBankPipeSwizzle(pIn, pOut);
676     }
677     else
678     {
679         returnCode = ADDR_ERROR;
680     }
681 
682     return returnCode;
683 }
684 
685 /**
686 ***************************************************************************************************
687 *   AddrComputeSliceSwizzle
688 *
689 *   @brief
690 *       Compute a swizzle for slice from a base swizzle
691 *   @return
692 *       ADDR_OK if no error
693 ***************************************************************************************************
694 */
AddrComputeSliceSwizzle(ADDR_HANDLE hLib,const ADDR_COMPUTE_SLICESWIZZLE_INPUT * pIn,ADDR_COMPUTE_SLICESWIZZLE_OUTPUT * pOut)695 ADDR_E_RETURNCODE ADDR_API AddrComputeSliceSwizzle(
696     ADDR_HANDLE                                 hLib,
697     const ADDR_COMPUTE_SLICESWIZZLE_INPUT*      pIn,
698     ADDR_COMPUTE_SLICESWIZZLE_OUTPUT*           pOut)
699 {
700     ADDR_E_RETURNCODE returnCode = ADDR_OK;
701 
702     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
703 
704     if (pLib != NULL)
705     {
706         returnCode = pLib->ComputeSliceTileSwizzle(pIn, pOut);
707     }
708     else
709     {
710         returnCode = ADDR_ERROR;
711     }
712 
713     return returnCode;
714 }
715 
716 /**
717 ***************************************************************************************************
718 *   AddrComputeBaseSwizzle
719 *
720 *   @brief
721 *       Return a Combined Bank and Pipe swizzle base on surface based on surface type/index
722 *   @return
723 *       ADDR_OK if no error
724 ***************************************************************************************************
725 */
AddrComputeBaseSwizzle(ADDR_HANDLE hLib,const ADDR_COMPUTE_BASE_SWIZZLE_INPUT * pIn,ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT * pOut)726 ADDR_E_RETURNCODE ADDR_API AddrComputeBaseSwizzle(
727     ADDR_HANDLE                             hLib,
728     const ADDR_COMPUTE_BASE_SWIZZLE_INPUT*  pIn,
729     ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT*       pOut)
730 {
731     ADDR_E_RETURNCODE returnCode = ADDR_OK;
732 
733     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
734 
735     if (pLib != NULL)
736     {
737         returnCode = pLib->ComputeBaseSwizzle(pIn, pOut);
738     }
739     else
740     {
741         returnCode = ADDR_ERROR;
742     }
743 
744     return returnCode;
745 }
746 
747 /**
748 ***************************************************************************************************
749 *   ElemFlt32ToDepthPixel
750 *
751 *   @brief
752 *       Convert a FLT_32 value to a depth/stencil pixel value
753 *
754 *   @return
755 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
756 *
757 ***************************************************************************************************
758 */
ElemFlt32ToDepthPixel(ADDR_HANDLE hLib,const ELEM_FLT32TODEPTHPIXEL_INPUT * pIn,ELEM_FLT32TODEPTHPIXEL_OUTPUT * pOut)759 ADDR_E_RETURNCODE ADDR_API ElemFlt32ToDepthPixel(
760     ADDR_HANDLE                         hLib,    ///< [in] addrlib handle
761     const ELEM_FLT32TODEPTHPIXEL_INPUT* pIn,     ///< [in] per-component value
762     ELEM_FLT32TODEPTHPIXEL_OUTPUT*      pOut)    ///< [out] final pixel value
763 {
764     ADDR_E_RETURNCODE returnCode = ADDR_OK;
765 
766     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
767 
768     if (pLib != NULL)
769     {
770         pLib->Flt32ToDepthPixel(pIn, pOut);
771     }
772     else
773     {
774         returnCode = ADDR_ERROR;
775     }
776 
777     return returnCode;
778 }
779 
780 /**
781 ***************************************************************************************************
782 *   ElemFlt32ToColorPixel
783 *
784 *   @brief
785 *       Convert a FLT_32 value to a red/green/blue/alpha pixel value
786 *
787 *   @return
788 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
789 *
790 ***************************************************************************************************
791 */
ElemFlt32ToColorPixel(ADDR_HANDLE hLib,const ELEM_FLT32TOCOLORPIXEL_INPUT * pIn,ELEM_FLT32TOCOLORPIXEL_OUTPUT * pOut)792 ADDR_E_RETURNCODE ADDR_API ElemFlt32ToColorPixel(
793     ADDR_HANDLE                         hLib,    ///< [in] addrlib handle
794     const ELEM_FLT32TOCOLORPIXEL_INPUT* pIn,     ///< [in] format, surface number and swap value
795     ELEM_FLT32TOCOLORPIXEL_OUTPUT*      pOut)    ///< [out] final pixel value
796 {
797     ADDR_E_RETURNCODE returnCode = ADDR_OK;
798 
799     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
800 
801     if (pLib != NULL)
802     {
803         pLib->Flt32ToColorPixel(pIn, pOut);
804     }
805     else
806     {
807         returnCode = ADDR_ERROR;
808     }
809 
810     return returnCode;
811 }
812 
813 /**
814 ***************************************************************************************************
815 *   ElemGetExportNorm
816 *
817 *   @brief
818 *       Helper function to check one format can be EXPORT_NUM,
819 *       which is a register CB_COLOR_INFO.SURFACE_FORMAT.
820 *       FP16 can be reported as EXPORT_NORM for rv770 in r600
821 *       family
822 *
823 ***************************************************************************************************
824 */
ElemGetExportNorm(ADDR_HANDLE hLib,const ELEM_GETEXPORTNORM_INPUT * pIn)825 BOOL_32 ADDR_API ElemGetExportNorm(
826     ADDR_HANDLE                     hLib, ///< [in] addrlib handle
827     const ELEM_GETEXPORTNORM_INPUT* pIn)  ///< [in] input structure
828 {
829     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
830     BOOL_32 enabled = FALSE;
831 
832     ADDR_E_RETURNCODE returnCode = ADDR_OK;
833 
834     if (pLib != NULL)
835     {
836         enabled = pLib->GetExportNorm(pIn);
837     }
838     else
839     {
840         returnCode = ADDR_ERROR;
841     }
842 
843     ADDR_ASSERT(returnCode == ADDR_OK);
844 
845     return enabled;
846 }
847 
848 /**
849 ***************************************************************************************************
850 *   AddrConvertTileInfoToHW
851 *
852 *   @brief
853 *       Convert tile info from real value to hardware register value
854 *
855 *   @return
856 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
857 ***************************************************************************************************
858 */
AddrConvertTileInfoToHW(ADDR_HANDLE hLib,const ADDR_CONVERT_TILEINFOTOHW_INPUT * pIn,ADDR_CONVERT_TILEINFOTOHW_OUTPUT * pOut)859 ADDR_E_RETURNCODE ADDR_API AddrConvertTileInfoToHW(
860     ADDR_HANDLE                             hLib, ///< [in] address lib handle
861     const ADDR_CONVERT_TILEINFOTOHW_INPUT*  pIn,  ///< [in] tile info with real value
862     ADDR_CONVERT_TILEINFOTOHW_OUTPUT*       pOut) ///< [out] tile info with HW register value
863 {
864     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
865 
866     ADDR_E_RETURNCODE returnCode = ADDR_OK;
867 
868     if (pLib != NULL)
869     {
870         returnCode = pLib->ConvertTileInfoToHW(pIn, pOut);
871     }
872     else
873     {
874         returnCode = ADDR_ERROR;
875     }
876 
877     return returnCode;
878 }
879 
880 /**
881 ***************************************************************************************************
882 *   AddrConvertTileIndex
883 *
884 *   @brief
885 *       Convert tile index to tile mode/type/info
886 *
887 *   @return
888 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
889 ***************************************************************************************************
890 */
AddrConvertTileIndex(ADDR_HANDLE hLib,const ADDR_CONVERT_TILEINDEX_INPUT * pIn,ADDR_CONVERT_TILEINDEX_OUTPUT * pOut)891 ADDR_E_RETURNCODE ADDR_API AddrConvertTileIndex(
892     ADDR_HANDLE                          hLib, ///< [in] address lib handle
893     const ADDR_CONVERT_TILEINDEX_INPUT*  pIn,  ///< [in] input - tile index
894     ADDR_CONVERT_TILEINDEX_OUTPUT*       pOut) ///< [out] tile mode/type/info
895 {
896     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
897 
898     ADDR_E_RETURNCODE returnCode = ADDR_OK;
899 
900     if (pLib != NULL)
901     {
902         returnCode = pLib->ConvertTileIndex(pIn, pOut);
903     }
904     else
905     {
906         returnCode = ADDR_ERROR;
907     }
908 
909     return returnCode;
910 }
911 
912 /**
913 ***************************************************************************************************
914 *   AddrConvertTileIndex1
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 */
AddrConvertTileIndex1(ADDR_HANDLE hLib,const ADDR_CONVERT_TILEINDEX1_INPUT * pIn,ADDR_CONVERT_TILEINDEX_OUTPUT * pOut)923 ADDR_E_RETURNCODE ADDR_API AddrConvertTileIndex1(
924     ADDR_HANDLE                          hLib, ///< [in] address lib handle
925     const ADDR_CONVERT_TILEINDEX1_INPUT* pIn,  ///< [in] input - tile index
926     ADDR_CONVERT_TILEINDEX_OUTPUT*       pOut) ///< [out] tile mode/type/info
927 {
928     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
929 
930     ADDR_E_RETURNCODE returnCode = ADDR_OK;
931 
932     if (pLib != NULL)
933     {
934         returnCode = pLib->ConvertTileIndex1(pIn, pOut);
935     }
936     else
937     {
938         returnCode = ADDR_ERROR;
939     }
940 
941     return returnCode;
942 }
943 
944 /**
945 ***************************************************************************************************
946 *   AddrGetTileIndex
947 *
948 *   @brief
949 *       Get tile index from tile mode/type/info
950 *
951 *   @return
952 *       ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
953 *
954 *   @note
955 *       Only meaningful for SI (and above)
956 ***************************************************************************************************
957 */
AddrGetTileIndex(ADDR_HANDLE hLib,const ADDR_GET_TILEINDEX_INPUT * pIn,ADDR_GET_TILEINDEX_OUTPUT * pOut)958 ADDR_E_RETURNCODE ADDR_API AddrGetTileIndex(
959     ADDR_HANDLE                     hLib,
960     const ADDR_GET_TILEINDEX_INPUT* pIn,
961     ADDR_GET_TILEINDEX_OUTPUT*      pOut)
962 {
963     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
964 
965     ADDR_E_RETURNCODE returnCode = ADDR_OK;
966 
967     if (pLib != NULL)
968     {
969         returnCode = pLib->GetTileIndex(pIn, pOut);
970     }
971     else
972     {
973         returnCode = ADDR_ERROR;
974     }
975 
976     return returnCode;
977 }
978 
979 /**
980 ***************************************************************************************************
981 *   AddrComputePrtInfo
982 *
983 *   @brief
984 *       Interface function for ComputePrtInfo
985 *
986 ***************************************************************************************************
987 */
AddrComputePrtInfo(ADDR_HANDLE hLib,const ADDR_PRT_INFO_INPUT * pIn,ADDR_PRT_INFO_OUTPUT * pOut)988 ADDR_E_RETURNCODE ADDR_API AddrComputePrtInfo(
989     ADDR_HANDLE                 hLib,
990     const ADDR_PRT_INFO_INPUT*  pIn,
991     ADDR_PRT_INFO_OUTPUT*       pOut)
992 {
993     ADDR_E_RETURNCODE returnCode = ADDR_OK;
994 
995     AddrLib* pLib = AddrLib::GetAddrLib(hLib);
996 
997     if (pLib != NULL)
998     {
999         returnCode = pLib->ComputePrtInfo(pIn, pOut);
1000     }
1001     else
1002     {
1003         returnCode = ADDR_ERROR;
1004     }
1005 
1006     return returnCode;
1007 }
1008 
1009