2 * Copyright © 2016 Advanced Micro Devices, Inc.
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:
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.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
28 ****************************************************************************************************
30 * @brief Contains the implementation for the Addr::V1::Lib base class.
31 ****************************************************************************************************
34 #include "addrinterface.h"
36 #include "addrcommon.h"
43 ////////////////////////////////////////////////////////////////////////////////////////////////////
44 // Static Const Member
45 ////////////////////////////////////////////////////////////////////////////////////////////////////
47 const TileModeFlags
Lib::ModeFlags
[ADDR_TM_COUNT
] =
49 {1, 1, 0, 0, 0, 0, 0, 0}, // ADDR_TM_LINEAR_GENERAL
50 {1, 1, 0, 0, 0, 0, 0, 0}, // ADDR_TM_LINEAR_ALIGNED
51 {1, 0, 1, 0, 0, 0, 0, 0}, // ADDR_TM_1D_TILED_THIN1
52 {4, 0, 1, 0, 0, 0, 0, 0}, // ADDR_TM_1D_TILED_THICK
53 {1, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THIN1
54 {1, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THIN2
55 {1, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THIN4
56 {4, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THICK
57 {1, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THIN1
58 {1, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THIN2
59 {1, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THIN4
60 {4, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THICK
61 {1, 0, 0, 1, 1, 0, 0, 0}, // ADDR_TM_3D_TILED_THIN1
62 {4, 0, 0, 1, 1, 0, 0, 0}, // ADDR_TM_3D_TILED_THICK
63 {1, 0, 0, 1, 1, 0, 0, 1}, // ADDR_TM_3B_TILED_THIN1
64 {4, 0, 0, 1, 1, 0, 0, 1}, // ADDR_TM_3B_TILED_THICK
65 {8, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_XTHICK
66 {8, 0, 0, 1, 1, 0, 0, 0}, // ADDR_TM_3D_TILED_XTHICK
67 {1, 0, 0, 0, 0, 0, 0, 0}, // ADDR_TM_POWER_SAVE
68 {1, 0, 0, 1, 0, 1, 1, 0}, // ADDR_TM_PRT_TILED_THIN1
69 {1, 0, 0, 1, 0, 1, 0, 0}, // ADDR_TM_PRT_2D_TILED_THIN1
70 {1, 0, 0, 1, 1, 1, 0, 0}, // ADDR_TM_PRT_3D_TILED_THIN1
71 {4, 0, 0, 1, 0, 1, 1, 0}, // ADDR_TM_PRT_TILED_THICK
72 {4, 0, 0, 1, 0, 1, 0, 0}, // ADDR_TM_PRT_2D_TILED_THICK
73 {4, 0, 0, 1, 1, 1, 0, 0}, // ADDR_TM_PRT_3D_TILED_THICK
74 {0, 0, 0, 0, 0, 0, 0, 0}, // ADDR_TM_UNKNOWN
77 ////////////////////////////////////////////////////////////////////////////////////////////////////
78 // Constructor/Destructor
79 ////////////////////////////////////////////////////////////////////////////////////////////////////
82 ****************************************************************************************************
86 * Constructor for the AddrLib1 class
88 ****************************************************************************************************
97 ****************************************************************************************************
101 * Constructor for the Addr::V1::Lib class with hClient as parameter
103 ****************************************************************************************************
105 Lib::Lib(const Client
* pClient
)
112 ****************************************************************************************************
116 * Destructor for the AddrLib1 class
118 ****************************************************************************************************
125 ****************************************************************************************************
129 * Get AddrLib1 pointer
132 * An Addr::V1::Lib class pointer
133 ****************************************************************************************************
136 ADDR_HANDLE hLib
) ///< [in] handle of ADDR_HANDLE
138 Addr::Lib
* pAddrLib
= Addr::Lib::GetLib(hLib
);
139 if ((pAddrLib
!= NULL
) &&
140 ((pAddrLib
->GetChipFamily() == ADDR_CHIP_FAMILY_IVLD
) ||
141 (pAddrLib
->GetChipFamily() > ADDR_CHIP_FAMILY_VI
)))
143 // only valid and pre-VI AISC can use AddrLib1 function.
144 ADDR_ASSERT_ALWAYS();
147 return static_cast<Lib
*>(hLib
);
151 ////////////////////////////////////////////////////////////////////////////////////////////////////
153 ////////////////////////////////////////////////////////////////////////////////////////////////////
157 ****************************************************************************************************
158 * Lib::ComputeSurfaceInfo
161 * Interface function stub of AddrComputeSurfaceInfo.
165 ****************************************************************************************************
167 ADDR_E_RETURNCODE
Lib::ComputeSurfaceInfo(
168 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] input structure
169 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
///< [out] output structure
172 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
174 if (GetFillSizeFieldsFlags() == TRUE
)
176 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SURFACE_INFO_INPUT
)) ||
177 (pOut
->size
!= sizeof(ADDR_COMPUTE_SURFACE_INFO_OUTPUT
)))
179 returnCode
= ADDR_PARAMSIZEMISMATCH
;
183 // We suggest client do sanity check but a check here is also good
186 returnCode
= ADDR_INVALIDPARAMS
;
189 if ((pIn
->tileMode
== ADDR_TM_UNKNOWN
) && (pIn
->mipLevel
> 0))
191 returnCode
= ADDR_INVALIDPARAMS
;
194 // Thick modes don't support multisample
195 if ((Thickness(pIn
->tileMode
) > 1) && (pIn
->numSamples
> 1))
197 returnCode
= ADDR_INVALIDPARAMS
;
200 if (returnCode
== ADDR_OK
)
202 // Get a local copy of input structure and only reference pIn for unadjusted values
203 ADDR_COMPUTE_SURFACE_INFO_INPUT localIn
= *pIn
;
204 ADDR_TILEINFO tileInfoNull
= {0};
208 // If the original input has a valid ADDR_TILEINFO pointer then copy its contents.
209 // Otherwise the default 0's in tileInfoNull are used.
212 tileInfoNull
= *pIn
->pTileInfo
;
214 localIn
.pTileInfo
= &tileInfoNull
;
217 localIn
.numSamples
= (pIn
->numSamples
== 0) ? 1 : pIn
->numSamples
;
219 // Do mipmap check first
220 // If format is BCn, pre-pad dimension to power-of-two according to HWL
221 ComputeMipLevel(&localIn
);
223 if (m_configFlags
.checkLast2DLevel
)
225 // Save this level's original height in pixels
226 pOut
->height
= pIn
->height
;
233 // Save outputs that may not go through HWL
234 pOut
->pixelBits
= localIn
.bpp
;
235 pOut
->numSamples
= localIn
.numSamples
;
236 pOut
->last2DLevel
= FALSE
;
237 pOut
->tcCompatible
= FALSE
;
240 if (localIn
.numSamples
> 1)
242 ADDR_ASSERT(localIn
.mipLevel
== 0);
246 if (localIn
.format
!= ADDR_FMT_INVALID
) // Set format to INVALID will skip this conversion
248 // Get compression/expansion factors and element mode
249 // (which indicates compression/expansion
250 localIn
.bpp
= GetElemLib()->GetBitsPerPixel(localIn
.format
,
255 // Special flag for 96 bit surface. 96 (or 48 if we support) bit surface's width is
256 // pre-multiplied by 3 and bpp is divided by 3. So pitch alignment for linear-
257 // aligned does not meet 64-pixel in real. We keep special handling in hwl since hw
258 // restrictions are different.
259 // Also Mip 1+ needs an element pitch of 32 bits so we do not need this workaround
260 // but we use this flag to skip RestoreSurfaceInfo below
262 if ((elemMode
== ADDR_EXPANDED
) &&
265 ADDR_ASSERT(localIn
.tileMode
== ADDR_TM_LINEAR_ALIGNED
|| localIn
.height
== 1);
268 GetElemLib()->AdjustSurfaceInfo(elemMode
,
276 // Overwrite these parameters if we have a valid format
278 else if (localIn
.bpp
!= 0)
280 localIn
.width
= (localIn
.width
!= 0) ? localIn
.width
: 1;
281 localIn
.height
= (localIn
.height
!= 0) ? localIn
.height
: 1;
283 else // Rule out some invalid parameters
285 ADDR_ASSERT_ALWAYS();
287 returnCode
= ADDR_INVALIDPARAMS
;
290 // Check mipmap after surface expansion
291 if (returnCode
== ADDR_OK
)
293 returnCode
= PostComputeMipLevel(&localIn
, pOut
);
296 if (returnCode
== ADDR_OK
)
298 if (UseTileIndex(localIn
.tileIndex
))
300 // Make sure pTileInfo is not NULL
301 ADDR_ASSERT(localIn
.pTileInfo
);
303 UINT_32 numSamples
= GetNumFragments(localIn
.numSamples
, localIn
.numFrags
);
305 INT_32 macroModeIndex
= TileIndexNoMacroIndex
;
307 if (localIn
.tileIndex
!= TileIndexLinearGeneral
)
309 // Try finding a macroModeIndex
310 macroModeIndex
= HwlComputeMacroModeIndex(localIn
.tileIndex
,
319 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
320 if (macroModeIndex
== TileIndexNoMacroIndex
)
322 returnCode
= HwlSetupTileCfg(localIn
.bpp
,
323 localIn
.tileIndex
, macroModeIndex
,
325 &localIn
.tileMode
, &localIn
.tileType
);
327 // If macroModeIndex is invalid, then assert this is not macro tiled
328 else if (macroModeIndex
== TileIndexInvalid
)
330 ADDR_ASSERT(!IsMacroTiled(localIn
.tileMode
));
333 pOut
->macroModeIndex
= macroModeIndex
;
337 if (returnCode
== ADDR_OK
)
339 if (localIn
.tileMode
== ADDR_TM_UNKNOWN
)
341 // HWL layer may override tile mode if necessary
342 HwlSelectTileMode(&localIn
);
346 // HWL layer may override tile mode if necessary
347 HwlOverrideTileMode(&localIn
);
349 AddrTileMode tileMode
= localIn
.tileMode
;
351 // Optimize tile mode if possible
352 if (OptimizeTileMode(&localIn
, &tileMode
))
354 localIn
.tileMode
= tileMode
;
359 // Call main function to compute surface info
360 if (returnCode
== ADDR_OK
)
362 returnCode
= HwlComputeSurfaceInfo(&localIn
, pOut
);
365 if (returnCode
== ADDR_OK
)
367 // Since bpp might be changed we just pass it through
368 pOut
->bpp
= localIn
.bpp
;
370 // Also original width/height/bpp
371 pOut
->pixelPitch
= pOut
->pitch
;
372 pOut
->pixelHeight
= pOut
->height
;
375 if (localIn
.flags
.display
)
377 ADDR_ASSERT((pOut
->pitchAlign
% 32) == 0);
381 if (localIn
.format
!= ADDR_FMT_INVALID
)
384 // 96 bits surface of level 1+ requires element pitch of 32 bits instead
385 // In hwl function we skip multiplication of 3 then we should skip division of 3
386 // We keep pitch that represents 32 bit element instead of 96 bits since we
387 // will get an odd number if divided by 3.
389 if (!((expandX
== 3) && (localIn
.mipLevel
> 0)))
392 GetElemLib()->RestoreSurfaceInfo(elemMode
,
401 if (localIn
.flags
.qbStereo
)
403 if (pOut
->pStereoInfo
)
405 ComputeQbStereoInfo(pOut
);
409 if (localIn
.flags
.volume
) // For volume sliceSize equals to all z-slices
411 pOut
->sliceSize
= pOut
->surfSize
;
413 else // For array: sliceSize is likely to have slice-padding (the last one)
415 pOut
->sliceSize
= pOut
->surfSize
/ pOut
->depth
;
418 if (pIn
->numSlices
> 1)
420 // If this is the last slice then add the padding size to this slice
421 if (pIn
->slice
== (pIn
->numSlices
- 1))
423 pOut
->sliceSize
+= pOut
->sliceSize
* (pOut
->depth
- pIn
->numSlices
);
425 else if (m_configFlags
.checkLast2DLevel
)
427 // Reset last2DLevel flag if this is not the last array slice
428 pOut
->last2DLevel
= FALSE
;
433 pOut
->pitchTileMax
= pOut
->pitch
/ 8 - 1;
434 pOut
->heightTileMax
= pOut
->height
/ 8 - 1;
435 pOut
->sliceTileMax
= pOut
->pitch
* pOut
->height
/ 64 - 1;
443 ****************************************************************************************************
444 * Lib::ComputeSurfaceInfo
447 * Interface function stub of AddrComputeSurfaceInfo.
451 ****************************************************************************************************
453 ADDR_E_RETURNCODE
Lib::ComputeSurfaceAddrFromCoord(
454 const ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
455 ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
458 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
460 if (GetFillSizeFieldsFlags() == TRUE
)
462 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT
)) ||
463 (pOut
->size
!= sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT
)))
465 returnCode
= ADDR_PARAMSIZEMISMATCH
;
469 if (returnCode
== ADDR_OK
)
471 ADDR_TILEINFO tileInfoNull
;
472 ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT input
;
474 if (UseTileIndex(pIn
->tileIndex
))
477 // Use temp tile info for calcalation
478 input
.pTileInfo
= &tileInfoNull
;
480 const ADDR_SURFACE_FLAGS flags
= {{0}};
481 UINT_32 numSamples
= GetNumFragments(pIn
->numSamples
, pIn
->numFrags
);
483 // Try finding a macroModeIndex
484 INT_32 macroModeIndex
= HwlComputeMacroModeIndex(input
.tileIndex
,
492 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
493 if (macroModeIndex
== TileIndexNoMacroIndex
)
495 returnCode
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
, macroModeIndex
,
496 input
.pTileInfo
, &input
.tileMode
, &input
.tileType
);
498 // If macroModeIndex is invalid, then assert this is not macro tiled
499 else if (macroModeIndex
== TileIndexInvalid
)
501 ADDR_ASSERT(!IsMacroTiled(input
.tileMode
));
504 // Change the input structure
508 if (returnCode
== ADDR_OK
)
510 returnCode
= HwlComputeSurfaceAddrFromCoord(pIn
, pOut
);
512 if (returnCode
== ADDR_OK
)
514 pOut
->prtBlockIndex
= static_cast<UINT_32
>(pOut
->addr
/ (64 * 1024));
523 ****************************************************************************************************
524 * Lib::ComputeSurfaceCoordFromAddr
527 * Interface function stub of ComputeSurfaceCoordFromAddr.
531 ****************************************************************************************************
533 ADDR_E_RETURNCODE
Lib::ComputeSurfaceCoordFromAddr(
534 const ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
535 ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
538 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
540 if (GetFillSizeFieldsFlags() == TRUE
)
542 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT
)) ||
543 (pOut
->size
!= sizeof(ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT
)))
545 returnCode
= ADDR_PARAMSIZEMISMATCH
;
549 if (returnCode
== ADDR_OK
)
551 ADDR_TILEINFO tileInfoNull
;
552 ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT input
;
554 if (UseTileIndex(pIn
->tileIndex
))
557 // Use temp tile info for calcalation
558 input
.pTileInfo
= &tileInfoNull
;
560 const ADDR_SURFACE_FLAGS flags
= {{0}};
561 UINT_32 numSamples
= GetNumFragments(pIn
->numSamples
, pIn
->numFrags
);
563 // Try finding a macroModeIndex
564 INT_32 macroModeIndex
= HwlComputeMacroModeIndex(input
.tileIndex
,
572 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
573 if (macroModeIndex
== TileIndexNoMacroIndex
)
575 returnCode
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
, macroModeIndex
,
576 input
.pTileInfo
, &input
.tileMode
, &input
.tileType
);
578 // If macroModeIndex is invalid, then assert this is not macro tiled
579 else if (macroModeIndex
== TileIndexInvalid
)
581 ADDR_ASSERT(!IsMacroTiled(input
.tileMode
));
584 // Change the input structure
588 if (returnCode
== ADDR_OK
)
590 returnCode
= HwlComputeSurfaceCoordFromAddr(pIn
, pOut
);
598 ****************************************************************************************************
599 * Lib::ComputeSliceTileSwizzle
602 * Interface function stub of ComputeSliceTileSwizzle.
606 ****************************************************************************************************
608 ADDR_E_RETURNCODE
Lib::ComputeSliceTileSwizzle(
609 const ADDR_COMPUTE_SLICESWIZZLE_INPUT
* pIn
, ///< [in] input structure
610 ADDR_COMPUTE_SLICESWIZZLE_OUTPUT
* pOut
///< [out] output structure
613 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
615 if (GetFillSizeFieldsFlags() == TRUE
)
617 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SLICESWIZZLE_INPUT
)) ||
618 (pOut
->size
!= sizeof(ADDR_COMPUTE_SLICESWIZZLE_OUTPUT
)))
620 returnCode
= ADDR_PARAMSIZEMISMATCH
;
624 if (returnCode
== ADDR_OK
)
626 ADDR_TILEINFO tileInfoNull
;
627 ADDR_COMPUTE_SLICESWIZZLE_INPUT input
;
629 if (UseTileIndex(pIn
->tileIndex
))
632 // Use temp tile info for calcalation
633 input
.pTileInfo
= &tileInfoNull
;
635 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
,
636 input
.pTileInfo
, &input
.tileMode
);
637 // Change the input structure
641 if (returnCode
== ADDR_OK
)
643 returnCode
= HwlComputeSliceTileSwizzle(pIn
, pOut
);
651 ****************************************************************************************************
652 * Lib::ExtractBankPipeSwizzle
655 * Interface function stub of AddrExtractBankPipeSwizzle.
659 ****************************************************************************************************
661 ADDR_E_RETURNCODE
Lib::ExtractBankPipeSwizzle(
662 const ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT
* pIn
, ///< [in] input structure
663 ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT
* pOut
///< [out] output structure
666 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
668 if (GetFillSizeFieldsFlags() == TRUE
)
670 if ((pIn
->size
!= sizeof(ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT
)) ||
671 (pOut
->size
!= sizeof(ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT
)))
673 returnCode
= ADDR_PARAMSIZEMISMATCH
;
677 if (returnCode
== ADDR_OK
)
679 ADDR_TILEINFO tileInfoNull
;
680 ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT input
;
682 if (UseTileIndex(pIn
->tileIndex
))
685 // Use temp tile info for calcalation
686 input
.pTileInfo
= &tileInfoNull
;
688 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
689 // Change the input structure
693 if (returnCode
== ADDR_OK
)
695 returnCode
= HwlExtractBankPipeSwizzle(pIn
, pOut
);
703 ****************************************************************************************************
704 * Lib::CombineBankPipeSwizzle
707 * Interface function stub of AddrCombineBankPipeSwizzle.
711 ****************************************************************************************************
713 ADDR_E_RETURNCODE
Lib::CombineBankPipeSwizzle(
714 const ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT
* pIn
, ///< [in] input structure
715 ADDR_COMBINE_BANKPIPE_SWIZZLE_OUTPUT
* pOut
///< [out] output structure
718 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
720 if (GetFillSizeFieldsFlags() == TRUE
)
722 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_INPUT
)) ||
723 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT
)))
725 returnCode
= ADDR_PARAMSIZEMISMATCH
;
729 if (returnCode
== ADDR_OK
)
731 ADDR_TILEINFO tileInfoNull
;
732 ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT input
;
734 if (UseTileIndex(pIn
->tileIndex
))
737 // Use temp tile info for calcalation
738 input
.pTileInfo
= &tileInfoNull
;
740 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
741 // Change the input structure
745 if (returnCode
== ADDR_OK
)
747 returnCode
= HwlCombineBankPipeSwizzle(pIn
->bankSwizzle
,
759 ****************************************************************************************************
760 * Lib::ComputeBaseSwizzle
763 * Interface function stub of AddrCompueBaseSwizzle.
766 ****************************************************************************************************
768 ADDR_E_RETURNCODE
Lib::ComputeBaseSwizzle(
769 const ADDR_COMPUTE_BASE_SWIZZLE_INPUT
* pIn
,
770 ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT
* pOut
) const
772 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
774 if (GetFillSizeFieldsFlags() == TRUE
)
776 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_INPUT
)) ||
777 (pOut
->size
!= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT
)))
779 returnCode
= ADDR_PARAMSIZEMISMATCH
;
783 if (returnCode
== ADDR_OK
)
785 ADDR_TILEINFO tileInfoNull
;
786 ADDR_COMPUTE_BASE_SWIZZLE_INPUT input
;
788 if (UseTileIndex(pIn
->tileIndex
))
791 // Use temp tile info for calcalation
792 input
.pTileInfo
= &tileInfoNull
;
794 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
795 // Change the input structure
799 if (returnCode
== ADDR_OK
)
801 if (IsMacroTiled(pIn
->tileMode
))
803 returnCode
= HwlComputeBaseSwizzle(pIn
, pOut
);
807 pOut
->tileSwizzle
= 0;
816 ****************************************************************************************************
817 * Lib::ComputeFmaskInfo
820 * Interface function stub of ComputeFmaskInfo.
824 ****************************************************************************************************
826 ADDR_E_RETURNCODE
Lib::ComputeFmaskInfo(
827 const ADDR_COMPUTE_FMASK_INFO_INPUT
* pIn
, ///< [in] input structure
828 ADDR_COMPUTE_FMASK_INFO_OUTPUT
* pOut
///< [out] output structure
831 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
833 if (GetFillSizeFieldsFlags() == TRUE
)
835 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_INPUT
)) ||
836 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT
)))
838 returnCode
= ADDR_PARAMSIZEMISMATCH
;
843 if (Thickness(pIn
->tileMode
) > 1)
845 returnCode
= ADDR_INVALIDPARAMS
;
848 if (returnCode
== ADDR_OK
)
850 ADDR_TILEINFO tileInfoNull
;
851 ADDR_COMPUTE_FMASK_INFO_INPUT input
;
853 if (UseTileIndex(pIn
->tileIndex
))
859 // Use temp tile info for calcalation
860 input
.pTileInfo
= pOut
->pTileInfo
;
864 input
.pTileInfo
= &tileInfoNull
;
867 ADDR_SURFACE_FLAGS flags
= {{0}};
870 // Try finding a macroModeIndex
871 INT_32 macroModeIndex
= HwlComputeMacroModeIndex(pIn
->tileIndex
,
873 HwlComputeFmaskBits(pIn
, NULL
),
878 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
879 if (macroModeIndex
== TileIndexNoMacroIndex
)
881 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, macroModeIndex
,
882 input
.pTileInfo
, &input
.tileMode
);
885 ADDR_ASSERT(macroModeIndex
!= TileIndexInvalid
);
887 // Change the input structure
891 if (returnCode
== ADDR_OK
)
893 if (pIn
->numSamples
> 1)
895 returnCode
= HwlComputeFmaskInfo(pIn
, pOut
);
899 memset(pOut
, 0, sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT
));
901 returnCode
= ADDR_INVALIDPARAMS
;
910 ****************************************************************************************************
911 * Lib::ComputeFmaskAddrFromCoord
914 * Interface function stub of ComputeFmaskAddrFromCoord.
918 ****************************************************************************************************
920 ADDR_E_RETURNCODE
Lib::ComputeFmaskAddrFromCoord(
921 const ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
922 ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
925 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
927 if (GetFillSizeFieldsFlags() == TRUE
)
929 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT
)) ||
930 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT
)))
932 returnCode
= ADDR_PARAMSIZEMISMATCH
;
936 if (returnCode
== ADDR_OK
)
938 ADDR_ASSERT(pIn
->numSamples
> 1);
940 if (pIn
->numSamples
> 1)
942 returnCode
= HwlComputeFmaskAddrFromCoord(pIn
, pOut
);
946 returnCode
= ADDR_INVALIDPARAMS
;
954 ****************************************************************************************************
955 * Lib::ComputeFmaskCoordFromAddr
958 * Interface function stub of ComputeFmaskAddrFromCoord.
962 ****************************************************************************************************
964 ADDR_E_RETURNCODE
Lib::ComputeFmaskCoordFromAddr(
965 const ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
966 ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
969 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
971 if (GetFillSizeFieldsFlags() == TRUE
)
973 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT
)) ||
974 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT
)))
976 returnCode
= ADDR_PARAMSIZEMISMATCH
;
980 if (returnCode
== ADDR_OK
)
982 ADDR_ASSERT(pIn
->numSamples
> 1);
984 if (pIn
->numSamples
> 1)
986 returnCode
= HwlComputeFmaskCoordFromAddr(pIn
, pOut
);
990 returnCode
= ADDR_INVALIDPARAMS
;
998 ****************************************************************************************************
999 * Lib::ConvertTileInfoToHW
1002 * Convert tile info from real value to HW register value in HW layer
1006 ****************************************************************************************************
1008 ADDR_E_RETURNCODE
Lib::ConvertTileInfoToHW(
1009 const ADDR_CONVERT_TILEINFOTOHW_INPUT
* pIn
, ///< [in] input structure
1010 ADDR_CONVERT_TILEINFOTOHW_OUTPUT
* pOut
///< [out] output structure
1013 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1015 if (GetFillSizeFieldsFlags() == TRUE
)
1017 if ((pIn
->size
!= sizeof(ADDR_CONVERT_TILEINFOTOHW_INPUT
)) ||
1018 (pOut
->size
!= sizeof(ADDR_CONVERT_TILEINFOTOHW_OUTPUT
)))
1020 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1024 if (returnCode
== ADDR_OK
)
1026 ADDR_TILEINFO tileInfoNull
;
1027 ADDR_CONVERT_TILEINFOTOHW_INPUT input
;
1028 // if pIn->reverse is TRUE, indices are ignored
1029 if (pIn
->reverse
== FALSE
&& UseTileIndex(pIn
->tileIndex
))
1032 input
.pTileInfo
= &tileInfoNull
;
1034 returnCode
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
,
1035 input
.macroModeIndex
, input
.pTileInfo
);
1040 if (returnCode
== ADDR_OK
)
1042 returnCode
= HwlConvertTileInfoToHW(pIn
, pOut
);
1050 ****************************************************************************************************
1051 * Lib::ConvertTileIndex
1054 * Convert tile index to tile mode/type/info
1058 ****************************************************************************************************
1060 ADDR_E_RETURNCODE
Lib::ConvertTileIndex(
1061 const ADDR_CONVERT_TILEINDEX_INPUT
* pIn
, ///< [in] input structure
1062 ADDR_CONVERT_TILEINDEX_OUTPUT
* pOut
///< [out] output structure
1065 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1067 if (GetFillSizeFieldsFlags() == TRUE
)
1069 if ((pIn
->size
!= sizeof(ADDR_CONVERT_TILEINDEX_INPUT
)) ||
1070 (pOut
->size
!= sizeof(ADDR_CONVERT_TILEINDEX_OUTPUT
)))
1072 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1076 if (returnCode
== ADDR_OK
)
1079 returnCode
= HwlSetupTileCfg(pIn
->bpp
, pIn
->tileIndex
, pIn
->macroModeIndex
,
1080 pOut
->pTileInfo
, &pOut
->tileMode
, &pOut
->tileType
);
1082 if (returnCode
== ADDR_OK
&& pIn
->tileInfoHw
)
1084 ADDR_CONVERT_TILEINFOTOHW_INPUT hwInput
= {0};
1085 ADDR_CONVERT_TILEINFOTOHW_OUTPUT hwOutput
= {0};
1087 hwInput
.pTileInfo
= pOut
->pTileInfo
;
1088 hwInput
.tileIndex
= -1;
1089 hwOutput
.pTileInfo
= pOut
->pTileInfo
;
1091 returnCode
= HwlConvertTileInfoToHW(&hwInput
, &hwOutput
);
1099 ****************************************************************************************************
1100 * Lib::GetMacroModeIndex
1103 * Get macro mode index based on input info
1107 ****************************************************************************************************
1109 ADDR_E_RETURNCODE
Lib::GetMacroModeIndex(
1110 const ADDR_GET_MACROMODEINDEX_INPUT
* pIn
, ///< [in] input structure
1111 ADDR_GET_MACROMODEINDEX_OUTPUT
* pOut
///< [out] output structure
1114 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1116 if (GetFillSizeFieldsFlags())
1118 if ((pIn
->size
!= sizeof(ADDR_GET_MACROMODEINDEX_INPUT
)) ||
1119 (pOut
->size
!= sizeof(ADDR_GET_MACROMODEINDEX_OUTPUT
)))
1121 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1125 if (returnCode
== ADDR_OK
)
1127 ADDR_TILEINFO tileInfo
= {0};
1128 pOut
->macroModeIndex
= HwlComputeMacroModeIndex(pIn
->tileIndex
, pIn
->flags
, pIn
->bpp
,
1129 pIn
->numFrags
, &tileInfo
);
1136 ****************************************************************************************************
1137 * Lib::ConvertTileIndex1
1140 * Convert tile index to tile mode/type/info
1144 ****************************************************************************************************
1146 ADDR_E_RETURNCODE
Lib::ConvertTileIndex1(
1147 const ADDR_CONVERT_TILEINDEX1_INPUT
* pIn
, ///< [in] input structure
1148 ADDR_CONVERT_TILEINDEX_OUTPUT
* pOut
///< [out] output structure
1151 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1153 if (GetFillSizeFieldsFlags() == TRUE
)
1155 if ((pIn
->size
!= sizeof(ADDR_CONVERT_TILEINDEX1_INPUT
)) ||
1156 (pOut
->size
!= sizeof(ADDR_CONVERT_TILEINDEX_OUTPUT
)))
1158 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1162 if (returnCode
== ADDR_OK
)
1164 ADDR_SURFACE_FLAGS flags
= {{0}};
1166 HwlComputeMacroModeIndex(pIn
->tileIndex
, flags
, pIn
->bpp
, pIn
->numSamples
,
1167 pOut
->pTileInfo
, &pOut
->tileMode
, &pOut
->tileType
);
1169 if (pIn
->tileInfoHw
)
1171 ADDR_CONVERT_TILEINFOTOHW_INPUT hwInput
= {0};
1172 ADDR_CONVERT_TILEINFOTOHW_OUTPUT hwOutput
= {0};
1174 hwInput
.pTileInfo
= pOut
->pTileInfo
;
1175 hwInput
.tileIndex
= -1;
1176 hwOutput
.pTileInfo
= pOut
->pTileInfo
;
1178 returnCode
= HwlConvertTileInfoToHW(&hwInput
, &hwOutput
);
1186 ****************************************************************************************************
1190 * Get tile index from tile mode/type/info
1194 ****************************************************************************************************
1196 ADDR_E_RETURNCODE
Lib::GetTileIndex(
1197 const ADDR_GET_TILEINDEX_INPUT
* pIn
, ///< [in] input structure
1198 ADDR_GET_TILEINDEX_OUTPUT
* pOut
///< [out] output structure
1201 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1203 if (GetFillSizeFieldsFlags() == TRUE
)
1205 if ((pIn
->size
!= sizeof(ADDR_GET_TILEINDEX_INPUT
)) ||
1206 (pOut
->size
!= sizeof(ADDR_GET_TILEINDEX_OUTPUT
)))
1208 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1212 if (returnCode
== ADDR_OK
)
1214 returnCode
= HwlGetTileIndex(pIn
, pOut
);
1221 ****************************************************************************************************
1225 * Get tile mode thickness
1228 * Tile mode thickness
1229 ****************************************************************************************************
1231 UINT_32
Lib::Thickness(
1232 AddrTileMode tileMode
) ///< [in] tile mode
1234 return ModeFlags
[tileMode
].thickness
;
1239 ////////////////////////////////////////////////////////////////////////////////////////////////////
1241 ////////////////////////////////////////////////////////////////////////////////////////////////////
1244 ****************************************************************************************************
1245 * Lib::ComputeHtileInfo
1248 * Interface function stub of AddrComputeHtilenfo
1252 ****************************************************************************************************
1254 ADDR_E_RETURNCODE
Lib::ComputeHtileInfo(
1255 const ADDR_COMPUTE_HTILE_INFO_INPUT
* pIn
, ///< [in] input structure
1256 ADDR_COMPUTE_HTILE_INFO_OUTPUT
* pOut
///< [out] output structure
1259 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1261 BOOL_32 isWidth8
= (pIn
->blockWidth
== 8) ? TRUE
: FALSE
;
1262 BOOL_32 isHeight8
= (pIn
->blockHeight
== 8) ? TRUE
: FALSE
;
1264 if (GetFillSizeFieldsFlags() == TRUE
)
1266 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_HTILE_INFO_INPUT
)) ||
1267 (pOut
->size
!= sizeof(ADDR_COMPUTE_HTILE_INFO_OUTPUT
)))
1269 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1273 if (returnCode
== ADDR_OK
)
1275 ADDR_TILEINFO tileInfoNull
;
1276 ADDR_COMPUTE_HTILE_INFO_INPUT input
;
1278 if (UseTileIndex(pIn
->tileIndex
))
1281 // Use temp tile info for calcalation
1282 input
.pTileInfo
= &tileInfoNull
;
1284 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1286 // Change the input structure
1290 if (returnCode
== ADDR_OK
)
1292 pOut
->bpp
= ComputeHtileInfo(pIn
->flags
,
1314 ****************************************************************************************************
1315 * Lib::ComputeCmaskInfo
1318 * Interface function stub of AddrComputeCmaskInfo
1322 ****************************************************************************************************
1324 ADDR_E_RETURNCODE
Lib::ComputeCmaskInfo(
1325 const ADDR_COMPUTE_CMASK_INFO_INPUT
* pIn
, ///< [in] input structure
1326 ADDR_COMPUTE_CMASK_INFO_OUTPUT
* pOut
///< [out] output structure
1329 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1331 if (GetFillSizeFieldsFlags() == TRUE
)
1333 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_CMASK_INFO_INPUT
)) ||
1334 (pOut
->size
!= sizeof(ADDR_COMPUTE_CMASK_INFO_OUTPUT
)))
1336 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1340 if (returnCode
== ADDR_OK
)
1342 ADDR_TILEINFO tileInfoNull
;
1343 ADDR_COMPUTE_CMASK_INFO_INPUT input
;
1345 if (UseTileIndex(pIn
->tileIndex
))
1348 // Use temp tile info for calcalation
1349 input
.pTileInfo
= &tileInfoNull
;
1351 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1353 // Change the input structure
1357 if (returnCode
== ADDR_OK
)
1359 returnCode
= ComputeCmaskInfo(pIn
->flags
,
1380 ****************************************************************************************************
1381 * Lib::ComputeDccInfo
1384 * Interface function to compute DCC key info
1387 * return code of HwlComputeDccInfo
1388 ****************************************************************************************************
1390 ADDR_E_RETURNCODE
Lib::ComputeDccInfo(
1391 const ADDR_COMPUTE_DCCINFO_INPUT
* pIn
, ///< [in] input structure
1392 ADDR_COMPUTE_DCCINFO_OUTPUT
* pOut
///< [out] output structure
1395 ADDR_E_RETURNCODE ret
= ADDR_OK
;
1397 if (GetFillSizeFieldsFlags() == TRUE
)
1399 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_DCCINFO_INPUT
)) ||
1400 (pOut
->size
!= sizeof(ADDR_COMPUTE_DCCINFO_OUTPUT
)))
1402 ret
= ADDR_PARAMSIZEMISMATCH
;
1408 ADDR_COMPUTE_DCCINFO_INPUT input
;
1410 if (UseTileIndex(pIn
->tileIndex
))
1414 ret
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
, input
.macroModeIndex
,
1415 &input
.tileInfo
, &input
.tileMode
);
1422 ret
= HwlComputeDccInfo(pIn
, pOut
);
1430 ****************************************************************************************************
1431 * Lib::ComputeHtileAddrFromCoord
1434 * Interface function stub of AddrComputeHtileAddrFromCoord
1438 ****************************************************************************************************
1440 ADDR_E_RETURNCODE
Lib::ComputeHtileAddrFromCoord(
1441 const ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
1442 ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
1445 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1447 BOOL_32 isWidth8
= (pIn
->blockWidth
== 8) ? TRUE
: FALSE
;
1448 BOOL_32 isHeight8
= (pIn
->blockHeight
== 8) ? TRUE
: FALSE
;
1450 if (GetFillSizeFieldsFlags() == TRUE
)
1452 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT
)) ||
1453 (pOut
->size
!= sizeof(ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT
)))
1455 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1459 if (returnCode
== ADDR_OK
)
1461 ADDR_TILEINFO tileInfoNull
;
1462 ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT input
;
1464 if (UseTileIndex(pIn
->tileIndex
))
1467 // Use temp tile info for calcalation
1468 input
.pTileInfo
= &tileInfoNull
;
1470 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1472 // Change the input structure
1476 if (returnCode
== ADDR_OK
)
1478 if (pIn
->flags
.tcCompatible
)
1480 HwlComputeHtileAddrFromCoord(pIn
, pOut
);
1484 pOut
->addr
= HwlComputeXmaskAddrFromCoord(pIn
->pitch
,
1495 &pOut
->bitPosition
);
1505 ****************************************************************************************************
1506 * Lib::ComputeHtileCoordFromAddr
1509 * Interface function stub of AddrComputeHtileCoordFromAddr
1513 ****************************************************************************************************
1515 ADDR_E_RETURNCODE
Lib::ComputeHtileCoordFromAddr(
1516 const ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
1517 ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
1520 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1522 BOOL_32 isWidth8
= (pIn
->blockWidth
== 8) ? TRUE
: FALSE
;
1523 BOOL_32 isHeight8
= (pIn
->blockHeight
== 8) ? TRUE
: FALSE
;
1525 if (GetFillSizeFieldsFlags() == TRUE
)
1527 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT
)) ||
1528 (pOut
->size
!= sizeof(ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT
)))
1530 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1534 if (returnCode
== ADDR_OK
)
1536 ADDR_TILEINFO tileInfoNull
;
1537 ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT input
;
1539 if (UseTileIndex(pIn
->tileIndex
))
1542 // Use temp tile info for calcalation
1543 input
.pTileInfo
= &tileInfoNull
;
1545 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1547 // Change the input structure
1551 if (returnCode
== ADDR_OK
)
1553 HwlComputeXmaskCoordFromAddr(pIn
->addr
,
1573 ****************************************************************************************************
1574 * Lib::ComputeCmaskAddrFromCoord
1577 * Interface function stub of AddrComputeCmaskAddrFromCoord
1581 ****************************************************************************************************
1583 ADDR_E_RETURNCODE
Lib::ComputeCmaskAddrFromCoord(
1584 const ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
1585 ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
1588 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1590 if (GetFillSizeFieldsFlags() == TRUE
)
1592 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT
)) ||
1593 (pOut
->size
!= sizeof(ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT
)))
1595 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1599 if (returnCode
== ADDR_OK
)
1601 ADDR_TILEINFO tileInfoNull
;
1602 ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT input
;
1604 if (UseTileIndex(pIn
->tileIndex
))
1607 // Use temp tile info for calcalation
1608 input
.pTileInfo
= &tileInfoNull
;
1610 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1612 // Change the input structure
1616 if (returnCode
== ADDR_OK
)
1618 if (pIn
->flags
.tcCompatible
== TRUE
)
1620 returnCode
= HwlComputeCmaskAddrFromCoord(pIn
, pOut
);
1624 pOut
->addr
= HwlComputeXmaskAddrFromCoord(pIn
->pitch
,
1632 FALSE
, //this is cmask, isWidth8 is not needed
1633 FALSE
, //this is cmask, isHeight8 is not needed
1635 &pOut
->bitPosition
);
1645 ****************************************************************************************************
1646 * Lib::ComputeCmaskCoordFromAddr
1649 * Interface function stub of AddrComputeCmaskCoordFromAddr
1653 ****************************************************************************************************
1655 ADDR_E_RETURNCODE
Lib::ComputeCmaskCoordFromAddr(
1656 const ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
1657 ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
1660 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1662 if (GetFillSizeFieldsFlags() == TRUE
)
1664 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT
)) ||
1665 (pOut
->size
!= sizeof(ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT
)))
1667 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1671 if (returnCode
== ADDR_OK
)
1673 ADDR_TILEINFO tileInfoNull
;
1674 ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT input
;
1676 if (UseTileIndex(pIn
->tileIndex
))
1679 // Use temp tile info for calcalation
1680 input
.pTileInfo
= &tileInfoNull
;
1682 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1684 // Change the input structure
1688 if (returnCode
== ADDR_OK
)
1690 HwlComputeXmaskCoordFromAddr(pIn
->addr
,
1710 ****************************************************************************************************
1711 * Lib::ComputeTileDataWidthAndHeight
1714 * Compute the squared cache shape for per-tile data (CMASK and HTILE)
1720 * MacroWidth and macroHeight are measured in pixels
1721 ****************************************************************************************************
1723 VOID
Lib::ComputeTileDataWidthAndHeight(
1724 UINT_32 bpp
, ///< [in] bits per pixel
1725 UINT_32 cacheBits
, ///< [in] bits of cache
1726 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
1727 UINT_32
* pMacroWidth
, ///< [out] macro tile width
1728 UINT_32
* pMacroHeight
///< [out] macro tile height
1732 UINT_32 width
= cacheBits
/ bpp
;
1733 UINT_32 pipes
= HwlGetPipes(pTileInfo
);
1735 // Double height until the macro-tile is close to square
1736 // Height can only be doubled if width is even
1738 while ((width
> height
* 2 * pipes
) && !(width
& 1))
1744 *pMacroWidth
= 8 * width
;
1745 *pMacroHeight
= 8 * height
* pipes
;
1747 // Note: The above iterative comptuation is equivalent to the following
1749 //int log2_height = ((log2(cacheBits)-log2(bpp)-log2(pipes))/2);
1750 //int macroHeight = pow2( 3+log2(pipes)+log2_height );
1754 ****************************************************************************************************
1755 * Lib::HwlComputeTileDataWidthAndHeightLinear
1758 * Compute the squared cache shape for per-tile data (CMASK and HTILE) for linear layout
1764 * MacroWidth and macroHeight are measured in pixels
1765 ****************************************************************************************************
1767 VOID
Lib::HwlComputeTileDataWidthAndHeightLinear(
1768 UINT_32
* pMacroWidth
, ///< [out] macro tile width
1769 UINT_32
* pMacroHeight
, ///< [out] macro tile height
1770 UINT_32 bpp
, ///< [in] bits per pixel
1771 ADDR_TILEINFO
* pTileInfo
///< [in] tile info
1774 ADDR_ASSERT(bpp
!= 4); // Cmask does not support linear layout prior to SI
1775 *pMacroWidth
= 8 * 512 / bpp
; // Align width to 512-bit memory accesses
1776 *pMacroHeight
= 8 * m_pipes
; // Align height to number of pipes
1780 ****************************************************************************************************
1781 * Lib::ComputeHtileInfo
1784 * Compute htile pitch,width, bytes per 2D slice
1787 * Htile bpp i.e. How many bits for an 8x8 tile
1788 * Also returns by output parameters:
1789 * *Htile pitch, height, total size in bytes, macro-tile dimensions and slice size*
1790 ****************************************************************************************************
1792 UINT_32
Lib::ComputeHtileInfo(
1793 ADDR_HTILE_FLAGS flags
, ///< [in] htile flags
1794 UINT_32 pitchIn
, ///< [in] pitch input
1795 UINT_32 heightIn
, ///< [in] height input
1796 UINT_32 numSlices
, ///< [in] number of slices
1797 BOOL_32 isLinear
, ///< [in] if it is linear mode
1798 BOOL_32 isWidth8
, ///< [in] if htile block width is 8
1799 BOOL_32 isHeight8
, ///< [in] if htile block height is 8
1800 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
1801 UINT_32
* pPitchOut
, ///< [out] pitch output
1802 UINT_32
* pHeightOut
, ///< [out] height output
1803 UINT_64
* pHtileBytes
, ///< [out] bytes per 2D slice
1804 UINT_32
* pMacroWidth
, ///< [out] macro-tile width in pixels
1805 UINT_32
* pMacroHeight
, ///< [out] macro-tile width in pixels
1806 UINT_64
* pSliceSize
, ///< [out] slice size in bytes
1807 UINT_32
* pBaseAlign
///< [out] base alignment
1812 UINT_32 macroHeight
;
1817 numSlices
= Max(1u, numSlices
);
1819 const UINT_32 bpp
= HwlComputeHtileBpp(isWidth8
, isHeight8
);
1820 const UINT_32 cacheBits
= HtileCacheBits
;
1824 HwlComputeTileDataWidthAndHeightLinear(¯oWidth
,
1831 ComputeTileDataWidthAndHeight(bpp
,
1838 *pPitchOut
= PowTwoAlign(pitchIn
, macroWidth
);
1839 *pHeightOut
= PowTwoAlign(heightIn
, macroHeight
);
1841 baseAlign
= HwlComputeHtileBaseAlign(flags
.tcCompatible
, isLinear
, pTileInfo
);
1843 surfBytes
= HwlComputeHtileBytes(*pPitchOut
,
1851 *pHtileBytes
= surfBytes
;
1854 // Use SafeAssign since they are optional
1856 SafeAssign(pMacroWidth
, macroWidth
);
1858 SafeAssign(pMacroHeight
, macroHeight
);
1860 SafeAssign(pSliceSize
, sliceBytes
);
1862 SafeAssign(pBaseAlign
, baseAlign
);
1868 ****************************************************************************************************
1869 * Lib::ComputeCmaskBaseAlign
1872 * Compute cmask base alignment
1875 * Cmask base alignment
1876 ****************************************************************************************************
1878 UINT_32
Lib::ComputeCmaskBaseAlign(
1879 ADDR_CMASK_FLAGS flags
, ///< [in] Cmask flags
1880 ADDR_TILEINFO
* pTileInfo
///< [in] Tile info
1883 UINT_32 baseAlign
= m_pipeInterleaveBytes
* HwlGetPipes(pTileInfo
);
1885 if (flags
.tcCompatible
)
1887 ADDR_ASSERT(pTileInfo
!= NULL
);
1890 baseAlign
*= pTileInfo
->banks
;
1898 ****************************************************************************************************
1899 * Lib::ComputeCmaskBytes
1902 * Compute cmask size in bytes
1905 * Cmask size in bytes
1906 ****************************************************************************************************
1908 UINT_64
Lib::ComputeCmaskBytes(
1909 UINT_32 pitch
, ///< [in] pitch
1910 UINT_32 height
, ///< [in] height
1911 UINT_32 numSlices
///< [in] number of slices
1914 return BITS_TO_BYTES(static_cast<UINT_64
>(pitch
) * height
* numSlices
* CmaskElemBits
) /
1919 ****************************************************************************************************
1920 * Lib::ComputeCmaskInfo
1923 * Compute cmask pitch,width, bytes per 2D slice
1926 * BlockMax. Also by output parameters: Cmask pitch,height, total size in bytes,
1927 * macro-tile dimensions
1928 ****************************************************************************************************
1930 ADDR_E_RETURNCODE
Lib::ComputeCmaskInfo(
1931 ADDR_CMASK_FLAGS flags
, ///< [in] cmask flags
1932 UINT_32 pitchIn
, ///< [in] pitch input
1933 UINT_32 heightIn
, ///< [in] height input
1934 UINT_32 numSlices
, ///< [in] number of slices
1935 BOOL_32 isLinear
, ///< [in] is linear mode
1936 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
1937 UINT_32
* pPitchOut
, ///< [out] pitch output
1938 UINT_32
* pHeightOut
, ///< [out] height output
1939 UINT_64
* pCmaskBytes
, ///< [out] bytes per 2D slice
1940 UINT_32
* pMacroWidth
, ///< [out] macro-tile width in pixels
1941 UINT_32
* pMacroHeight
, ///< [out] macro-tile width in pixels
1942 UINT_64
* pSliceSize
, ///< [out] slice size in bytes
1943 UINT_32
* pBaseAlign
, ///< [out] base alignment
1944 UINT_32
* pBlockMax
///< [out] block max == slice / 128 / 128 - 1
1948 UINT_32 macroHeight
;
1953 numSlices
= Max(1u, numSlices
);
1955 const UINT_32 bpp
= CmaskElemBits
;
1956 const UINT_32 cacheBits
= CmaskCacheBits
;
1958 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1962 HwlComputeTileDataWidthAndHeightLinear(¯oWidth
,
1969 ComputeTileDataWidthAndHeight(bpp
,
1976 *pPitchOut
= (pitchIn
+ macroWidth
- 1) & ~(macroWidth
- 1);
1977 *pHeightOut
= (heightIn
+ macroHeight
- 1) & ~(macroHeight
- 1);
1980 sliceBytes
= ComputeCmaskBytes(*pPitchOut
,
1984 baseAlign
= ComputeCmaskBaseAlign(flags
, pTileInfo
);
1986 while (sliceBytes
% baseAlign
)
1988 *pHeightOut
+= macroHeight
;
1990 sliceBytes
= ComputeCmaskBytes(*pPitchOut
,
1995 surfBytes
= sliceBytes
* numSlices
;
1997 *pCmaskBytes
= surfBytes
;
2000 // Use SafeAssign since they are optional
2002 SafeAssign(pMacroWidth
, macroWidth
);
2004 SafeAssign(pMacroHeight
, macroHeight
);
2006 SafeAssign(pBaseAlign
, baseAlign
);
2008 SafeAssign(pSliceSize
, sliceBytes
);
2010 UINT_32 slice
= (*pPitchOut
) * (*pHeightOut
);
2011 UINT_32 blockMax
= slice
/ 128 / 128 - 1;
2014 if (slice
% (64*256) != 0)
2016 ADDR_ASSERT_ALWAYS();
2020 UINT_32 maxBlockMax
= HwlGetMaxCmaskBlockMax();
2022 if (blockMax
> maxBlockMax
)
2024 blockMax
= maxBlockMax
;
2025 returnCode
= ADDR_INVALIDPARAMS
;
2028 SafeAssign(pBlockMax
, blockMax
);
2034 ****************************************************************************************************
2035 * Lib::ComputeXmaskCoordYFromPipe
2038 * Compute the Y coord from pipe number for cmask/htile
2043 ****************************************************************************************************
2045 UINT_32
Lib::ComputeXmaskCoordYFromPipe(
2046 UINT_32 pipe
, ///< [in] pipe number
2047 UINT_32 x
///< [in] x coordinate
2059 UINT_32 numPipes
= m_pipes
; // SI has its implementation
2061 // Convert pipe + x to y coordinate.
2081 pipeBit0
= pipe
& 0x1;
2085 yBit0
= pipeBit0
^ xBit0
;
2099 pipeBit0
= pipe
& 0x1;
2100 pipeBit1
= (pipe
& 0x2) >> 1;
2103 xBit1
= (x
& 0x2) >> 1;
2105 yBit0
= pipeBit0
^ xBit1
;
2106 yBit1
= pipeBit1
^ xBit0
;
2115 // r600 and r800 have different method
2117 y
= HwlComputeXmaskCoordYFrom8Pipe(pipe
, x
);
2126 ****************************************************************************************************
2127 * Lib::HwlComputeXmaskCoordFromAddr
2130 * Compute the coord from an address of a cmask/htile
2136 * This method is reused by htile, so rename to Xmask
2137 ****************************************************************************************************
2139 VOID
Lib::HwlComputeXmaskCoordFromAddr(
2140 UINT_64 addr
, ///< [in] address
2141 UINT_32 bitPosition
, ///< [in] bitPosition in a byte
2142 UINT_32 pitch
, ///< [in] pitch
2143 UINT_32 height
, ///< [in] height
2144 UINT_32 numSlices
, ///< [in] number of slices
2145 UINT_32 factor
, ///< [in] factor that indicates cmask or htile
2146 BOOL_32 isLinear
, ///< [in] linear or tiled HTILE layout
2147 BOOL_32 isWidth8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2148 BOOL_32 isHeight8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2149 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
2150 UINT_32
* pX
, ///< [out] x coord
2151 UINT_32
* pY
, ///< [out] y coord
2152 UINT_32
* pSlice
///< [out] slice index
2157 UINT_32 numPipeBits
;
2158 UINT_32 macroTilePitch
;
2159 UINT_32 macroTileHeight
;
2163 UINT_32 microTileCoordY
;
2167 UINT_32 pitchAligned
= pitch
;
2168 UINT_32 heightAligned
= height
;
2176 UINT_64 macroNumber
;
2177 UINT_32 microNumber
;
2186 UINT_32 tilesPerMacro
;
2187 UINT_32 macrosPerPitch
;
2188 UINT_32 macrosPerSlice
;
2193 numPipes
= HwlGetPipes(pTileInfo
);
2194 pipe
= ComputePipeFromAddr(addr
, numPipes
);
2197 // Compute the number of group and pipe bits.
2199 numPipeBits
= Log2(numPipes
);
2201 UINT_32 groupBits
= 8 * m_pipeInterleaveBytes
;
2202 UINT_32 pipes
= numPipes
;
2206 // Compute the micro tile size, in bits. And macro tile pitch and height.
2208 if (factor
== 2) //CMASK
2210 ADDR_CMASK_FLAGS flags
= {{0}};
2212 elemBits
= CmaskElemBits
;
2214 ComputeCmaskInfo(flags
,
2228 ADDR_HTILE_FLAGS flags
= {{0}};
2235 elemBits
= HwlComputeHtileBpp(isWidth8
, isHeight8
);
2237 ComputeHtileInfo(flags
,
2252 // Should use aligned dims
2254 pitch
= pitchAligned
;
2255 height
= heightAligned
;
2259 // Convert byte address to bit address.
2261 bitAddr
= BYTES_TO_BITS(addr
) + bitPosition
;
2265 // Remove pipe bits from address.
2268 bitAddr
= (bitAddr
% groupBits
) + ((bitAddr
/groupBits
/pipes
)*groupBits
);
2271 elemOffset
= bitAddr
/ elemBits
;
2273 tilesPerMacro
= (macroTilePitch
/factor
) * macroTileHeight
/ MicroTilePixels
>> numPipeBits
;
2275 macrosPerPitch
= pitch
/ (macroTilePitch
/factor
);
2276 macrosPerSlice
= macrosPerPitch
* height
/ macroTileHeight
;
2278 macroIndex
= elemOffset
/ factor
/ tilesPerMacro
;
2279 microIndex
= static_cast<UINT_32
>(elemOffset
% (tilesPerMacro
* factor
));
2281 macroNumber
= macroIndex
* factor
+ microIndex
% factor
;
2282 microNumber
= microIndex
/ factor
;
2284 macroX
= static_cast<UINT_32
>((macroNumber
% macrosPerPitch
));
2285 macroY
= static_cast<UINT_32
>((macroNumber
% macrosPerSlice
) / macrosPerPitch
);
2286 macroZ
= static_cast<UINT_32
>((macroNumber
/ macrosPerSlice
));
2289 microX
= microNumber
% (macroTilePitch
/ factor
/ MicroTileWidth
);
2290 microY
= (microNumber
/ (macroTilePitch
/ factor
/ MicroTileHeight
));
2292 *pX
= macroX
* (macroTilePitch
/factor
) + microX
* MicroTileWidth
;
2293 *pY
= macroY
* macroTileHeight
+ (microY
* MicroTileHeight
<< numPipeBits
);
2296 microTileCoordY
= ComputeXmaskCoordYFromPipe(pipe
,
2297 *pX
/MicroTileWidth
);
2301 // Assemble final coordinates.
2303 *pY
+= microTileCoordY
* MicroTileHeight
;
2308 ****************************************************************************************************
2309 * Lib::HwlComputeXmaskAddrFromCoord
2312 * Compute the address from an address of cmask (prior to si)
2317 ****************************************************************************************************
2319 UINT_64
Lib::HwlComputeXmaskAddrFromCoord(
2320 UINT_32 pitch
, ///< [in] pitch
2321 UINT_32 height
, ///< [in] height
2322 UINT_32 x
, ///< [in] x coord
2323 UINT_32 y
, ///< [in] y coord
2324 UINT_32 slice
, ///< [in] slice/depth index
2325 UINT_32 numSlices
, ///< [in] number of slices
2326 UINT_32 factor
, ///< [in] factor that indicates cmask(2) or htile(1)
2327 BOOL_32 isLinear
, ///< [in] linear or tiled HTILE layout
2328 BOOL_32 isWidth8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2329 BOOL_32 isHeight8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2330 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
2331 UINT_32
* pBitPosition
///< [out] bit position inside a byte
2335 UINT_32 numGroupBits
;
2336 UINT_32 numPipeBits
;
2337 UINT_32 newPitch
= 0;
2338 UINT_32 newHeight
= 0;
2339 UINT_64 sliceBytes
= 0;
2340 UINT_64 totalBytes
= 0;
2341 UINT_64 sliceOffset
;
2343 UINT_32 macroTileWidth
;
2344 UINT_32 macroTileHeight
;
2345 UINT_32 macroTilesPerRow
;
2346 UINT_32 macroTileBytes
;
2347 UINT_32 macroTileIndexX
;
2348 UINT_32 macroTileIndexY
;
2349 UINT_64 macroTileOffset
;
2350 UINT_32 pixelBytesPerRow
;
2351 UINT_32 pixelOffsetX
;
2352 UINT_32 pixelOffsetY
;
2353 UINT_32 pixelOffset
;
2354 UINT_64 totalOffset
;
2360 UINT_32 elemBits
= 0;
2362 UINT_32 numPipes
= m_pipes
; // This function is accessed prior to si only
2364 if (factor
== 2) //CMASK
2366 elemBits
= CmaskElemBits
;
2368 // For asics before SI, cmask is always tiled
2373 if (factor
!= 1) // Fix compile warning
2378 elemBits
= HwlComputeHtileBpp(isWidth8
, isHeight8
);
2382 // Compute the number of group bits and pipe bits.
2384 numGroupBits
= Log2(m_pipeInterleaveBytes
);
2385 numPipeBits
= Log2(numPipes
);
2388 // Compute macro tile dimensions.
2390 if (factor
== 2) // CMASK
2392 ADDR_CMASK_FLAGS flags
= {{0}};
2394 ComputeCmaskInfo(flags
,
2406 sliceBytes
= totalBytes
/ numSlices
;
2410 ADDR_HTILE_FLAGS flags
= {{0}};
2412 ComputeHtileInfo(flags
,
2428 sliceOffset
= slice
* sliceBytes
;
2431 // Get the pipe. Note that neither slice rotation nor pipe swizzling apply for CMASK.
2433 pipe
= ComputePipeFromCoord(x
,
2436 ADDR_TM_2D_TILED_THIN1
,
2442 // Compute the number of macro tiles per row.
2444 macroTilesPerRow
= newPitch
/ macroTileWidth
;
2447 // Compute the number of bytes per macro tile.
2449 macroTileBytes
= BITS_TO_BYTES((macroTileWidth
* macroTileHeight
* elemBits
) / MicroTilePixels
);
2452 // Compute the offset to the macro tile containing the specified coordinate.
2454 macroTileIndexX
= x
/ macroTileWidth
;
2455 macroTileIndexY
= y
/ macroTileHeight
;
2456 macroTileOffset
= ((macroTileIndexY
* macroTilesPerRow
) + macroTileIndexX
) * macroTileBytes
;
2459 // Compute the pixel offset within the macro tile.
2461 pixelBytesPerRow
= BITS_TO_BYTES(macroTileWidth
* elemBits
) / MicroTileWidth
;
2464 // The nibbles are interleaved (see below), so the part of the offset relative to the x
2465 // coordinate repeats halfway across the row. (Not for HTILE)
2469 pixelOffsetX
= (x
% (macroTileWidth
/ 2)) / MicroTileWidth
;
2473 pixelOffsetX
= (x
% (macroTileWidth
)) / MicroTileWidth
* BITS_TO_BYTES(elemBits
);
2477 // Compute the y offset within the macro tile.
2479 pixelOffsetY
= (((y
% macroTileHeight
) / MicroTileHeight
) / numPipes
) * pixelBytesPerRow
;
2481 pixelOffset
= pixelOffsetX
+ pixelOffsetY
;
2484 // Combine the slice offset and macro tile offset with the pixel offset, accounting for the
2485 // pipe bits in the middle of the address.
2487 totalOffset
= ((sliceOffset
+ macroTileOffset
) >> numPipeBits
) + pixelOffset
;
2490 // Split the offset to put some bits below the pipe bits and some above.
2492 groupMask
= (1 << numGroupBits
) - 1;
2493 offsetLo
= totalOffset
& groupMask
;
2494 offsetHi
= (totalOffset
& ~groupMask
) << numPipeBits
;
2497 // Assemble the address from its components.
2501 // This is to remove warning with /analyze option
2502 UINT_32 pipeBits
= pipe
<< numGroupBits
;
2506 // Compute the bit position. The lower nibble is used when the x coordinate within the macro
2507 // tile is less than half of the macro tile width, and the upper nibble is used when the x
2508 // coordinate within the macro tile is greater than or equal to half the macro tile width.
2510 *pBitPosition
= ((x
% macroTileWidth
) < (macroTileWidth
/ factor
)) ? 0 : 4;
2515 ////////////////////////////////////////////////////////////////////////////////////////////////////
2516 // Surface Addressing Shared
2517 ////////////////////////////////////////////////////////////////////////////////////////////////////
2520 ****************************************************************************************************
2521 * Lib::ComputeSurfaceAddrFromCoordLinear
2524 * Compute address from coord for linear surface
2529 ****************************************************************************************************
2531 UINT_64
Lib::ComputeSurfaceAddrFromCoordLinear(
2532 UINT_32 x
, ///< [in] x coord
2533 UINT_32 y
, ///< [in] y coord
2534 UINT_32 slice
, ///< [in] slice/depth index
2535 UINT_32 sample
, ///< [in] sample index
2536 UINT_32 bpp
, ///< [in] bits per pixel
2537 UINT_32 pitch
, ///< [in] pitch
2538 UINT_32 height
, ///< [in] height
2539 UINT_32 numSlices
, ///< [in] number of slices
2540 UINT_32
* pBitPosition
///< [out] bit position inside a byte
2543 const UINT_64 sliceSize
= static_cast<UINT_64
>(pitch
) * height
;
2545 UINT_64 sliceOffset
= (slice
+ sample
* numSlices
)* sliceSize
;
2546 UINT_64 rowOffset
= static_cast<UINT_64
>(y
) * pitch
;
2547 UINT_64 pixOffset
= x
;
2549 UINT_64 addr
= (sliceOffset
+ rowOffset
+ pixOffset
) * bpp
;
2551 *pBitPosition
= static_cast<UINT_32
>(addr
% 8);
2558 ****************************************************************************************************
2559 * Lib::ComputeSurfaceCoordFromAddrLinear
2562 * Compute the coord from an address of a linear surface
2566 ****************************************************************************************************
2568 VOID
Lib::ComputeSurfaceCoordFromAddrLinear(
2569 UINT_64 addr
, ///< [in] address
2570 UINT_32 bitPosition
, ///< [in] bitPosition in a byte
2571 UINT_32 bpp
, ///< [in] bits per pixel
2572 UINT_32 pitch
, ///< [in] pitch
2573 UINT_32 height
, ///< [in] height
2574 UINT_32 numSlices
, ///< [in] number of slices
2575 UINT_32
* pX
, ///< [out] x coord
2576 UINT_32
* pY
, ///< [out] y coord
2577 UINT_32
* pSlice
, ///< [out] slice/depth index
2578 UINT_32
* pSample
///< [out] sample index
2581 const UINT_64 sliceSize
= static_cast<UINT_64
>(pitch
) * height
;
2582 const UINT_64 linearOffset
= (BYTES_TO_BITS(addr
) + bitPosition
) / bpp
;
2584 *pX
= static_cast<UINT_32
>((linearOffset
% sliceSize
) % pitch
);
2585 *pY
= static_cast<UINT_32
>((linearOffset
% sliceSize
) / pitch
% height
);
2586 *pSlice
= static_cast<UINT_32
>((linearOffset
/ sliceSize
) % numSlices
);
2587 *pSample
= static_cast<UINT_32
>((linearOffset
/ sliceSize
) / numSlices
);
2591 ****************************************************************************************************
2592 * Lib::ComputeSurfaceCoordFromAddrMicroTiled
2595 * Compute the coord from an address of a micro tiled surface
2599 ****************************************************************************************************
2601 VOID
Lib::ComputeSurfaceCoordFromAddrMicroTiled(
2602 UINT_64 addr
, ///< [in] address
2603 UINT_32 bitPosition
, ///< [in] bitPosition in a byte
2604 UINT_32 bpp
, ///< [in] bits per pixel
2605 UINT_32 pitch
, ///< [in] pitch
2606 UINT_32 height
, ///< [in] height
2607 UINT_32 numSamples
, ///< [in] number of samples
2608 AddrTileMode tileMode
, ///< [in] tile mode
2609 UINT_32 tileBase
, ///< [in] base offset within a tile
2610 UINT_32 compBits
, ///< [in] component bits actually needed(for planar surface)
2611 UINT_32
* pX
, ///< [out] x coord
2612 UINT_32
* pY
, ///< [out] y coord
2613 UINT_32
* pSlice
, ///< [out] slice/depth index
2614 UINT_32
* pSample
, ///< [out] sample index,
2615 AddrTileType microTileType
, ///< [in] micro tiling order
2616 BOOL_32 isDepthSampleOrder
///< [in] TRUE if in depth sample order
2620 UINT_32 microTileThickness
;
2621 UINT_32 microTileBits
;
2625 UINT_32 microTileCoordX
;
2626 UINT_32 microTileCoordY
;
2627 UINT_32 pixelOffset
;
2628 UINT_32 pixelCoordX
= 0;
2629 UINT_32 pixelCoordY
= 0;
2630 UINT_32 pixelCoordZ
= 0;
2631 UINT_32 pixelCoordS
= 0;
2634 // Convert byte address to bit address.
2636 bitAddr
= BYTES_TO_BITS(addr
) + bitPosition
;
2639 // Compute the micro tile size, in bits.
2643 case ADDR_TM_1D_TILED_THICK
:
2644 microTileThickness
= ThickTileThickness
;
2647 microTileThickness
= 1;
2651 microTileBits
= MicroTilePixels
* microTileThickness
* bpp
* numSamples
;
2654 // Compute number of bits per slice and number of bits per row of micro tiles.
2656 sliceBits
= static_cast<UINT_64
>(pitch
) * height
* microTileThickness
* bpp
* numSamples
;
2658 rowBits
= (pitch
/ MicroTileWidth
) * microTileBits
;
2661 // Extract the slice index.
2663 sliceIndex
= static_cast<UINT_32
>(bitAddr
/ sliceBits
);
2664 bitAddr
-= sliceIndex
* sliceBits
;
2667 // Extract the y coordinate of the micro tile.
2669 microTileCoordY
= static_cast<UINT_32
>(bitAddr
/ rowBits
) * MicroTileHeight
;
2670 bitAddr
-= (microTileCoordY
/ MicroTileHeight
) * rowBits
;
2673 // Extract the x coordinate of the micro tile.
2675 microTileCoordX
= static_cast<UINT_32
>(bitAddr
/ microTileBits
) * MicroTileWidth
;
2678 // Compute the pixel offset within the micro tile.
2680 pixelOffset
= static_cast<UINT_32
>(bitAddr
% microTileBits
);
2683 // Extract pixel coordinates from the offset.
2685 HwlComputePixelCoordFromOffset(pixelOffset
,
2696 isDepthSampleOrder
);
2699 // Assemble final coordinates.
2701 *pX
= microTileCoordX
+ pixelCoordX
;
2702 *pY
= microTileCoordY
+ pixelCoordY
;
2703 *pSlice
= (sliceIndex
* microTileThickness
) + pixelCoordZ
;
2704 *pSample
= pixelCoordS
;
2706 if (microTileThickness
> 1)
2713 ****************************************************************************************************
2714 * Lib::ComputePipeFromAddr
2717 * Compute the pipe number from an address
2722 ****************************************************************************************************
2724 UINT_32
Lib::ComputePipeFromAddr(
2725 UINT_64 addr
, ///< [in] address
2726 UINT_32 numPipes
///< [in] number of banks
2731 UINT_32 groupBytes
= m_pipeInterleaveBytes
; //just different terms
2734 // The LSBs of the address are arranged as follows:
2735 // bank | pipe | group
2737 // To get the pipe number, shift off the group bits and mask the pipe bits.
2741 // The LSBs of the address are arranged as follows:
2742 // bank | bankInterleave | pipe | pipeInterleave
2744 // To get the pipe number, shift off the pipe interleave bits and mask the pipe bits.
2747 pipe
= static_cast<UINT_32
>(addr
>> Log2(groupBytes
)) & (numPipes
- 1);
2753 ****************************************************************************************************
2754 * Lib::ComputeMicroTileEquation
2757 * Compute micro tile equation
2760 * If equation can be computed
2762 ****************************************************************************************************
2764 ADDR_E_RETURNCODE
Lib::ComputeMicroTileEquation(
2765 UINT_32 log2BytesPP
, ///< [in] log2 of bytes per pixel
2766 AddrTileMode tileMode
, ///< [in] tile mode
2767 AddrTileType microTileType
, ///< [in] pixel order in display/non-display mode
2768 ADDR_EQUATION
* pEquation
///< [out] equation
2771 ADDR_E_RETURNCODE retCode
= ADDR_OK
;
2773 for (UINT_32 i
= 0; i
< log2BytesPP
; i
++)
2775 pEquation
->addr
[i
].valid
= 1;
2776 pEquation
->addr
[i
].channel
= 0;
2777 pEquation
->addr
[i
].index
= i
;
2780 ADDR_CHANNEL_SETTING
* pixelBit
= &pEquation
->addr
[log2BytesPP
];
2782 ADDR_CHANNEL_SETTING x0
= InitChannel(1, 0, log2BytesPP
+ 0);
2783 ADDR_CHANNEL_SETTING x1
= InitChannel(1, 0, log2BytesPP
+ 1);
2784 ADDR_CHANNEL_SETTING x2
= InitChannel(1, 0, log2BytesPP
+ 2);
2785 ADDR_CHANNEL_SETTING y0
= InitChannel(1, 1, 0);
2786 ADDR_CHANNEL_SETTING y1
= InitChannel(1, 1, 1);
2787 ADDR_CHANNEL_SETTING y2
= InitChannel(1, 1, 2);
2788 ADDR_CHANNEL_SETTING z0
= InitChannel(1, 2, 0);
2789 ADDR_CHANNEL_SETTING z1
= InitChannel(1, 2, 1);
2790 ADDR_CHANNEL_SETTING z2
= InitChannel(1, 2, 2);
2792 UINT_32 thickness
= Thickness(tileMode
);
2793 UINT_32 bpp
= 1 << (log2BytesPP
+ 3);
2795 if (microTileType
!= ADDR_THICK
)
2797 if (microTileType
== ADDR_DISPLAYABLE
)
2842 ADDR_ASSERT_ALWAYS();
2846 else if (microTileType
== ADDR_NON_DISPLAYABLE
|| microTileType
== ADDR_DEPTH_SAMPLE_ORDER
)
2855 else if (microTileType
== ADDR_ROTATED
)
2857 ADDR_ASSERT(thickness
== 1);
2894 retCode
= ADDR_NOTSUPPORTED
;
2903 pEquation
->numBits
= 8 + log2BytesPP
;
2907 pEquation
->numBits
= 6 + log2BytesPP
;
2912 ADDR_ASSERT(thickness
> 1);
2943 ADDR_ASSERT_ALWAYS();
2949 pEquation
->numBits
= 8 + log2BytesPP
;
2955 pEquation
->numBits
= 9 + log2BytesPP
;
2958 // stackedDepthSlices is used for addressing mode that a tile block contains multiple slices,
2959 // which is not supported by our address lib
2960 pEquation
->stackedDepthSlices
= FALSE
;
2966 ****************************************************************************************************
2967 * Lib::ComputePixelIndexWithinMicroTile
2970 * Compute the pixel index inside a micro tile of surface
2975 ****************************************************************************************************
2977 UINT_32
Lib::ComputePixelIndexWithinMicroTile(
2978 UINT_32 x
, ///< [in] x coord
2979 UINT_32 y
, ///< [in] y coord
2980 UINT_32 z
, ///< [in] slice/depth index
2981 UINT_32 bpp
, ///< [in] bits per pixel
2982 AddrTileMode tileMode
, ///< [in] tile mode
2983 AddrTileType microTileType
///< [in] pixel order in display/non-display mode
2986 UINT_32 pixelBit0
= 0;
2987 UINT_32 pixelBit1
= 0;
2988 UINT_32 pixelBit2
= 0;
2989 UINT_32 pixelBit3
= 0;
2990 UINT_32 pixelBit4
= 0;
2991 UINT_32 pixelBit5
= 0;
2992 UINT_32 pixelBit6
= 0;
2993 UINT_32 pixelBit7
= 0;
2994 UINT_32 pixelBit8
= 0;
2995 UINT_32 pixelNumber
;
2997 UINT_32 x0
= _BIT(x
, 0);
2998 UINT_32 x1
= _BIT(x
, 1);
2999 UINT_32 x2
= _BIT(x
, 2);
3000 UINT_32 y0
= _BIT(y
, 0);
3001 UINT_32 y1
= _BIT(y
, 1);
3002 UINT_32 y2
= _BIT(y
, 2);
3003 UINT_32 z0
= _BIT(z
, 0);
3004 UINT_32 z1
= _BIT(z
, 1);
3005 UINT_32 z2
= _BIT(z
, 2);
3007 UINT_32 thickness
= Thickness(tileMode
);
3009 // Compute the pixel number within the micro tile.
3011 if (microTileType
!= ADDR_THICK
)
3013 if (microTileType
== ADDR_DISPLAYABLE
)
3058 ADDR_ASSERT_ALWAYS();
3062 else if (microTileType
== ADDR_NON_DISPLAYABLE
|| microTileType
== ADDR_DEPTH_SAMPLE_ORDER
)
3071 else if (microTileType
== ADDR_ROTATED
)
3073 ADDR_ASSERT(thickness
== 1);
3110 ADDR_ASSERT_ALWAYS();
3123 ADDR_ASSERT(thickness
> 1);
3154 ADDR_ASSERT_ALWAYS();
3167 pixelNumber
= ((pixelBit0
) |
3181 ****************************************************************************************************
3182 * Lib::AdjustPitchAlignment
3185 * Adjusts pitch alignment for flipping surface
3190 ****************************************************************************************************
3192 VOID
Lib::AdjustPitchAlignment(
3193 ADDR_SURFACE_FLAGS flags
, ///< [in] Surface flags
3194 UINT_32
* pPitchAlign
///< [out] Pointer to pitch alignment
3197 // Display engine hardwires lower 5 bit of GRPH_PITCH to ZERO which means 32 pixel alignment
3198 // Maybe it will be fixed in future but let's make it general for now.
3199 if (flags
.display
|| flags
.overlay
)
3201 *pPitchAlign
= PowTwoAlign(*pPitchAlign
, 32);
3205 *pPitchAlign
= Max(m_minPitchAlignPixels
, *pPitchAlign
);
3211 ****************************************************************************************************
3212 * Lib::PadDimensions
3215 * Helper function to pad dimensions
3220 ****************************************************************************************************
3222 VOID
Lib::PadDimensions(
3223 AddrTileMode tileMode
, ///< [in] tile mode
3224 UINT_32 bpp
, ///< [in] bits per pixel
3225 ADDR_SURFACE_FLAGS flags
, ///< [in] surface flags
3226 UINT_32 numSamples
, ///< [in] number of samples
3227 ADDR_TILEINFO
* pTileInfo
, ///< [in,out] bank structure.
3228 UINT_32 padDims
, ///< [in] Dimensions to pad valid value 1,2,3
3229 UINT_32 mipLevel
, ///< [in] MipLevel
3230 UINT_32
* pPitch
, ///< [in,out] pitch in pixels
3231 UINT_32 pitchAlign
, ///< [in] pitch alignment
3232 UINT_32
* pHeight
, ///< [in,out] height in pixels
3233 UINT_32 heightAlign
, ///< [in] height alignment
3234 UINT_32
* pSlices
, ///< [in,out] number of slices
3235 UINT_32 sliceAlign
///< [in] number of slice alignment
3238 UINT_32 thickness
= Thickness(tileMode
);
3240 ADDR_ASSERT(padDims
<= 3);
3243 // Override padding for mip levels
3249 // for cubemap, we only pad when client call with 6 faces as an identity
3252 padDims
= 3; // we should pad cubemap sub levels when we treat it as 3d texture
3261 // Any possibilities that padDims is 0?
3267 if (IsPow2(pitchAlign
))
3269 *pPitch
= PowTwoAlign((*pPitch
), pitchAlign
);
3271 else // add this code to pass unit test, r600 linear mode is not align bpp to pow2 for linear
3273 *pPitch
+= pitchAlign
- 1;
3274 *pPitch
/= pitchAlign
;
3275 *pPitch
*= pitchAlign
;
3280 *pHeight
= PowTwoAlign((*pHeight
), heightAlign
);
3283 if (padDims
> 2 || thickness
> 1)
3285 // for cubemap single face, we do not pad slices.
3286 // if we pad it, the slice number should be set to 6 and current mip level > 1
3287 if (flags
.cube
&& (!m_configFlags
.noCubeMipSlicesPad
|| flags
.cubeAsArray
))
3289 *pSlices
= NextPow2(*pSlices
);
3292 // normal 3D texture or arrays or cubemap has a thick mode? (Just pass unit test)
3295 *pSlices
= PowTwoAlign((*pSlices
), sliceAlign
);
3300 HwlPadDimensions(tileMode
,
3317 ****************************************************************************************************
3318 * Lib::HwlPreHandleBaseLvl3xPitch
3321 * Pre-handler of 3x pitch (96 bit) adjustment
3325 ****************************************************************************************************
3327 UINT_32
Lib::HwlPreHandleBaseLvl3xPitch(
3328 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] input
3329 UINT_32 expPitch
///< [in] pitch
3332 ADDR_ASSERT(pIn
->width
== expPitch
);
3334 // If pitch is pre-multiplied by 3, we retrieve original one here to get correct miplevel size
3336 if (ElemLib::IsExpand3x(pIn
->format
) &&
3337 pIn
->mipLevel
== 0 &&
3338 pIn
->tileMode
== ADDR_TM_LINEAR_ALIGNED
)
3341 expPitch
= NextPow2(expPitch
);
3348 ****************************************************************************************************
3349 * Lib::HwlPostHandleBaseLvl3xPitch
3352 * Post-handler of 3x pitch adjustment
3356 ****************************************************************************************************
3358 UINT_32
Lib::HwlPostHandleBaseLvl3xPitch(
3359 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] input
3360 UINT_32 expPitch
///< [in] pitch
3364 // 96 bits surface of sub levels require element pitch of 32 bits instead
3365 // So we just return pitch in 32 bit pixels without timing 3
3367 if (ElemLib::IsExpand3x(pIn
->format
) &&
3368 pIn
->mipLevel
== 0 &&
3369 pIn
->tileMode
== ADDR_TM_LINEAR_ALIGNED
)
3379 ****************************************************************************************************
3383 * Check if the tile mode is macro tiled
3386 * TRUE if it is macro tiled (2D/2B/3D/3B)
3387 ****************************************************************************************************
3389 BOOL_32
Lib::IsMacroTiled(
3390 AddrTileMode tileMode
) ///< [in] tile mode
3392 return ModeFlags
[tileMode
].isMacro
;
3396 ****************************************************************************************************
3397 * Lib::IsMacro3dTiled
3400 * Check if the tile mode is 3D macro tiled
3403 * TRUE if it is 3D macro tiled
3404 ****************************************************************************************************
3406 BOOL_32
Lib::IsMacro3dTiled(
3407 AddrTileMode tileMode
) ///< [in] tile mode
3409 return ModeFlags
[tileMode
].isMacro3d
;
3413 ****************************************************************************************************
3417 * Check if the tile mode is micro tiled
3420 * TRUE if micro tiled
3421 ****************************************************************************************************
3423 BOOL_32
Lib::IsMicroTiled(
3424 AddrTileMode tileMode
) ///< [in] tile mode
3426 return ModeFlags
[tileMode
].isMicro
;
3430 ****************************************************************************************************
3434 * Check if the tile mode is linear
3438 ****************************************************************************************************
3440 BOOL_32
Lib::IsLinear(
3441 AddrTileMode tileMode
) ///< [in] tile mode
3443 return ModeFlags
[tileMode
].isLinear
;
3447 ****************************************************************************************************
3448 * Lib::IsPrtNoRotationTileMode
3451 * Return TRUE if it is prt tile without rotation
3453 * This function just used by CI
3454 ****************************************************************************************************
3456 BOOL_32
Lib::IsPrtNoRotationTileMode(
3457 AddrTileMode tileMode
)
3459 return ModeFlags
[tileMode
].isPrtNoRotation
;
3463 ****************************************************************************************************
3464 * Lib::IsPrtTileMode
3467 * Return TRUE if it is prt tile
3469 * This function just used by CI
3470 ****************************************************************************************************
3472 BOOL_32
Lib::IsPrtTileMode(
3473 AddrTileMode tileMode
)
3475 return ModeFlags
[tileMode
].isPrt
;
3479 ****************************************************************************************************
3480 * Lib::ComputeMipLevel
3483 * Compute mipmap level width/height/slices
3486 ****************************************************************************************************
3488 VOID
Lib::ComputeMipLevel(
3489 ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
///< [in,out] Input structure
3492 if (ElemLib::IsBlockCompressed(pIn
->format
))
3494 if (pIn
->mipLevel
== 0)
3496 // DXTn's level 0 must be multiple of 4
3497 // But there are exceptions:
3498 // 1. Internal surface creation in hostblt/vsblt/etc...
3499 // 2. Runtime doesn't reject ATI1/ATI2 whose width/height are not multiple of 4
3500 pIn
->width
= PowTwoAlign(pIn
->width
, 4);
3501 pIn
->height
= PowTwoAlign(pIn
->height
, 4);
3505 HwlComputeMipLevel(pIn
);
3509 ****************************************************************************************************
3510 * Lib::OptimizeTileMode
3513 * Check if base level's tile mode can be optimized (degraded)
3515 * TRUE if degraded, also returns degraded tile mode (unchanged if not degraded)
3516 ****************************************************************************************************
3518 BOOL_32
Lib::OptimizeTileMode(
3519 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] Input structure for surface info
3520 AddrTileMode
* pTileMode
///< [out] Degraded tile mode
3523 AddrTileMode tileMode
= pIn
->tileMode
;
3524 UINT_32 thickness
= Thickness(tileMode
);
3526 // Optimization can only be done on level 0 and samples <= 1
3527 if ((pIn
->flags
.opt4Space
== TRUE
) &&
3528 (pIn
->mipLevel
== 0) &&
3529 (pIn
->numSamples
<= 1) &&
3530 (pIn
->flags
.display
== FALSE
) &&
3531 (IsPrtTileMode(tileMode
) == FALSE
) &&
3532 (pIn
->flags
.prt
== FALSE
))
3534 // Check if linear mode is optimal
3535 if ((pIn
->height
== 1) &&
3536 (IsLinear(tileMode
) == FALSE
) &&
3537 (ElemLib::IsBlockCompressed(pIn
->format
) == FALSE
) &&
3538 (pIn
->flags
.depth
== FALSE
) &&
3539 (pIn
->flags
.stencil
== FALSE
) &&
3540 (m_configFlags
.disableLinearOpt
== FALSE
) &&
3541 (pIn
->flags
.disableLinearOpt
== FALSE
))
3543 tileMode
= ADDR_TM_LINEAR_ALIGNED
;
3545 else if (IsMacroTiled(tileMode
))
3547 if (HwlDegradeBaseLevel(pIn
))
3549 tileMode
= (thickness
== 1) ? ADDR_TM_1D_TILED_THIN1
: ADDR_TM_1D_TILED_THICK
;
3551 else if (thickness
> 1)
3553 // As in the following HwlComputeSurfaceInfo, thick modes may be degraded to
3554 // thinner modes, we should re-evaluate whether the corresponding thinner modes
3555 // need to be degraded. If so, we choose 1D thick mode instead.
3556 tileMode
= DegradeLargeThickTile(pIn
->tileMode
, pIn
->bpp
);
3557 if (tileMode
!= pIn
->tileMode
)
3559 ADDR_COMPUTE_SURFACE_INFO_INPUT input
= *pIn
;
3560 input
.tileMode
= tileMode
;
3561 if (HwlDegradeBaseLevel(&input
))
3563 tileMode
= ADDR_TM_1D_TILED_THICK
;
3570 BOOL_32 optimized
= (tileMode
!= pIn
->tileMode
);
3573 *pTileMode
= tileMode
;
3579 ****************************************************************************************************
3580 * Lib::DegradeLargeThickTile
3583 * Check if the thickness needs to be reduced if a tile is too large
3585 * The degraded tile mode (unchanged if not degraded)
3586 ****************************************************************************************************
3588 AddrTileMode
Lib::DegradeLargeThickTile(
3589 AddrTileMode tileMode
,
3592 // Override tilemode
3593 // When tile_width (8) * tile_height (8) * thickness * element_bytes is > row_size,
3594 // it is better to just use THIN mode in this case
3595 UINT_32 thickness
= Thickness(tileMode
);
3597 if (thickness
> 1 && m_configFlags
.allowLargeThickTile
== 0)
3599 UINT_32 tileSize
= MicroTilePixels
* thickness
* (bpp
>> 3);
3601 if (tileSize
> m_rowSize
)
3605 case ADDR_TM_2D_TILED_XTHICK
:
3606 if ((tileSize
>> 1) <= m_rowSize
)
3608 tileMode
= ADDR_TM_2D_TILED_THICK
;
3611 // else fall through
3612 case ADDR_TM_2D_TILED_THICK
:
3613 tileMode
= ADDR_TM_2D_TILED_THIN1
;
3616 case ADDR_TM_3D_TILED_XTHICK
:
3617 if ((tileSize
>> 1) <= m_rowSize
)
3619 tileMode
= ADDR_TM_3D_TILED_THICK
;
3622 // else fall through
3623 case ADDR_TM_3D_TILED_THICK
:
3624 tileMode
= ADDR_TM_3D_TILED_THIN1
;
3627 case ADDR_TM_PRT_TILED_THICK
:
3628 tileMode
= ADDR_TM_PRT_TILED_THIN1
;
3631 case ADDR_TM_PRT_2D_TILED_THICK
:
3632 tileMode
= ADDR_TM_PRT_2D_TILED_THIN1
;
3635 case ADDR_TM_PRT_3D_TILED_THICK
:
3636 tileMode
= ADDR_TM_PRT_3D_TILED_THIN1
;
3649 ****************************************************************************************************
3650 * Lib::PostComputeMipLevel
3652 * Compute MipLevel info (including level 0) after surface adjustment
3655 ****************************************************************************************************
3657 ADDR_E_RETURNCODE
Lib::PostComputeMipLevel(
3658 ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in,out] Input structure
3659 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
///< [out] Output structure
3662 // Mipmap including level 0 must be pow2 padded since either SI hw expects so or it is
3663 // required by CFX for Hw Compatibility between NI and SI. Otherwise it is only needed for
3664 // mipLevel > 0. Any h/w has different requirement should implement its own virtual function
3666 if (pIn
->flags
.pow2Pad
)
3668 pIn
->width
= NextPow2(pIn
->width
);
3669 pIn
->height
= NextPow2(pIn
->height
);
3670 pIn
->numSlices
= NextPow2(pIn
->numSlices
);
3672 else if (pIn
->mipLevel
> 0)
3674 pIn
->width
= NextPow2(pIn
->width
);
3675 pIn
->height
= NextPow2(pIn
->height
);
3677 if (!pIn
->flags
.cube
)
3679 pIn
->numSlices
= NextPow2(pIn
->numSlices
);
3682 // for cubemap, we keep its value at first
3689 ****************************************************************************************************
3690 * Lib::HwlSetupTileCfg
3693 * Map tile index to tile setting.
3696 ****************************************************************************************************
3698 ADDR_E_RETURNCODE
Lib::HwlSetupTileCfg(
3699 UINT_32 bpp
, ///< Bits per pixel
3700 INT_32 index
, ///< [in] Tile index
3701 INT_32 macroModeIndex
, ///< [in] Index in macro tile mode table(CI)
3702 ADDR_TILEINFO
* pInfo
, ///< [out] Tile Info
3703 AddrTileMode
* pMode
, ///< [out] Tile mode
3704 AddrTileType
* pType
///< [out] Tile type
3707 return ADDR_NOTSUPPORTED
;
3711 ****************************************************************************************************
3718 ****************************************************************************************************
3720 UINT_32
Lib::HwlGetPipes(
3721 const ADDR_TILEINFO
* pTileInfo
///< [in] Tile info
3724 //pTileInfo can be NULL when asic is 6xx and 8xx.
3729 ****************************************************************************************************
3730 * Lib::ComputeQbStereoInfo
3733 * Get quad buffer stereo information
3736 ****************************************************************************************************
3738 BOOL_32
Lib::ComputeQbStereoInfo(
3739 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
///< [in,out] updated pOut+pStereoInfo
3742 BOOL_32 success
= FALSE
;
3744 if (pOut
->pStereoInfo
)
3746 ADDR_ASSERT(pOut
->bpp
>= 8);
3747 ADDR_ASSERT((pOut
->surfSize
% pOut
->baseAlign
) == 0);
3749 // Save original height
3750 pOut
->pStereoInfo
->eyeHeight
= pOut
->height
;
3753 pOut
->pStereoInfo
->rightOffset
= static_cast<UINT_32
>(pOut
->surfSize
);
3755 pOut
->pStereoInfo
->rightSwizzle
= HwlComputeQbStereoRightSwizzle(pOut
);
3758 pOut
->pixelHeight
<<= 1;
3761 pOut
->surfSize
<<= 1;
3763 // Right start address meets the base align since it is guaranteed by AddrLib1
3765 // 1D surface on SI may break this rule, but we can force it to meet by checking .qbStereo.
3774 ****************************************************************************************************
3775 * Lib::ComputePrtInfo
3778 * Compute prt surface related info
3782 ****************************************************************************************************
3784 ADDR_E_RETURNCODE
Lib::ComputePrtInfo(
3785 const ADDR_PRT_INFO_INPUT
* pIn
,
3786 ADDR_PRT_INFO_OUTPUT
* pOut
) const
3788 ADDR_ASSERT(pOut
!= NULL
);
3790 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
3792 UINT_32 expandX
= 1;
3793 UINT_32 expandY
= 1;
3796 UINT_32 bpp
= GetElemLib()->GetBitsPerPixel(pIn
->format
,
3801 if (bpp
<8 || bpp
== 24 || bpp
== 48 || bpp
== 96)
3803 returnCode
= ADDR_INVALIDPARAMS
;
3806 UINT_32 numFrags
= pIn
->numFrags
;
3807 ADDR_ASSERT(numFrags
<= 8);
3809 UINT_32 tileWidth
= 0;
3810 UINT_32 tileHeight
= 0;
3811 if (returnCode
== ADDR_OK
)
3813 // 3D texture without depth or 2d texture
3814 if (pIn
->baseMipDepth
> 1 || pIn
->baseMipHeight
> 1)
3833 // assume it is BC1/4
3837 if (elemMode
== ADDR_UNCOMPRESSED
)
3843 else if (bpp
== 128)
3845 // assume it is BC2/3/5/6H/7
3849 if (elemMode
== ADDR_UNCOMPRESSED
)
3858 tileWidth
= tileWidth
/ 2;
3860 else if (numFrags
== 4)
3862 tileWidth
= tileWidth
/ 2;
3863 tileHeight
= tileHeight
/ 2;
3865 else if (numFrags
== 8)
3867 tileWidth
= tileWidth
/ 4;
3868 tileHeight
= tileHeight
/ 2;
3890 else if (bpp
== 128)
3897 pOut
->prtTileWidth
= tileWidth
;
3898 pOut
->prtTileHeight
= tileHeight
;