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 AddrLib1 base class..
31 ***************************************************************************************************
34 #include "addrinterface.h"
36 #include "addrcommon.h"
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 // Static Const Member
41 ///////////////////////////////////////////////////////////////////////////////////////////////////
43 const AddrTileModeFlags
AddrLib1::m_modeFlags
[ADDR_TM_COUNT
] =
45 {1, 1, 0, 0, 0, 0, 0, 0}, // ADDR_TM_LINEAR_GENERAL
46 {1, 1, 0, 0, 0, 0, 0, 0}, // ADDR_TM_LINEAR_ALIGNED
47 {1, 0, 1, 0, 0, 0, 0, 0}, // ADDR_TM_1D_TILED_THIN1
48 {4, 0, 1, 0, 0, 0, 0, 0}, // ADDR_TM_1D_TILED_THICK
49 {1, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THIN1
50 {1, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THIN2
51 {1, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THIN4
52 {4, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THICK
53 {1, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THIN1
54 {1, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THIN2
55 {1, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THIN4
56 {4, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THICK
57 {1, 0, 0, 1, 1, 0, 0, 0}, // ADDR_TM_3D_TILED_THIN1
58 {4, 0, 0, 1, 1, 0, 0, 0}, // ADDR_TM_3D_TILED_THICK
59 {1, 0, 0, 1, 1, 0, 0, 1}, // ADDR_TM_3B_TILED_THIN1
60 {4, 0, 0, 1, 1, 0, 0, 1}, // ADDR_TM_3B_TILED_THICK
61 {8, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_XTHICK
62 {8, 0, 0, 1, 1, 0, 0, 0}, // ADDR_TM_3D_TILED_XTHICK
63 {1, 0, 0, 0, 0, 0, 0, 0}, // ADDR_TM_POWER_SAVE
64 {1, 0, 0, 1, 0, 1, 1, 0}, // ADDR_TM_PRT_TILED_THIN1
65 {1, 0, 0, 1, 0, 1, 0, 0}, // ADDR_TM_PRT_2D_TILED_THIN1
66 {1, 0, 0, 1, 1, 1, 0, 0}, // ADDR_TM_PRT_3D_TILED_THIN1
67 {4, 0, 0, 1, 0, 1, 1, 0}, // ADDR_TM_PRT_TILED_THICK
68 {4, 0, 0, 1, 0, 1, 0, 0}, // ADDR_TM_PRT_2D_TILED_THICK
69 {4, 0, 0, 1, 1, 1, 0, 0}, // ADDR_TM_PRT_3D_TILED_THICK
72 ///////////////////////////////////////////////////////////////////////////////////////////////////
73 // Constructor/Destructor
74 ///////////////////////////////////////////////////////////////////////////////////////////////////
77 ***************************************************************************************************
81 * Constructor for the AddrLib1 class
83 ***************************************************************************************************
85 AddrLib1::AddrLib1() :
91 ***************************************************************************************************
95 * Constructor for the AddrLib1 class with hClient as parameter
97 ***************************************************************************************************
99 AddrLib1::AddrLib1(const AddrClient
* pClient
) :
105 ***************************************************************************************************
106 * AddrLib1::~AddrLib1
109 * Destructor for the AddrLib1 class
111 ***************************************************************************************************
113 AddrLib1::~AddrLib1()
118 ***************************************************************************************************
119 * AddrLib1::GetAddrLib1
122 * Get AddrLib1 pointer
125 * An AddrLib1 class pointer
126 ***************************************************************************************************
128 AddrLib1
* AddrLib1::GetAddrLib1(
129 ADDR_HANDLE hLib
) ///< [in] handle of ADDR_HANDLE
131 AddrLib
* pAddrLib
= AddrLib::GetAddrLib(hLib
);
132 if ((pAddrLib
!= NULL
) &&
133 ((pAddrLib
->GetAddrChipFamily() == ADDR_CHIP_FAMILY_IVLD
) ||
134 (pAddrLib
->GetAddrChipFamily() > ADDR_CHIP_FAMILY_VI
)))
136 // only valid and pre-VI AISC can use AddrLib1 function.
137 ADDR_ASSERT_ALWAYS();
140 return static_cast<AddrLib1
*>(hLib
);
144 ///////////////////////////////////////////////////////////////////////////////////////////////////
146 ///////////////////////////////////////////////////////////////////////////////////////////////////
150 ***************************************************************************************************
151 * AddrLib1::ComputeSurfaceInfo
154 * Interface function stub of AddrComputeSurfaceInfo.
158 ***************************************************************************************************
160 ADDR_E_RETURNCODE
AddrLib1::ComputeSurfaceInfo(
161 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] input structure
162 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
///< [out] output structure
165 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
167 if (GetFillSizeFieldsFlags() == TRUE
)
169 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SURFACE_INFO_INPUT
)) ||
170 (pOut
->size
!= sizeof(ADDR_COMPUTE_SURFACE_INFO_OUTPUT
)))
172 returnCode
= ADDR_PARAMSIZEMISMATCH
;
176 // We suggest client do sanity check but a check here is also good
179 returnCode
= ADDR_INVALIDPARAMS
;
182 // Thick modes don't support multisample
183 if (Thickness(pIn
->tileMode
) > 1 && pIn
->numSamples
> 1)
185 returnCode
= ADDR_INVALIDPARAMS
;
188 if (returnCode
== ADDR_OK
)
190 // Get a local copy of input structure and only reference pIn for unadjusted values
191 ADDR_COMPUTE_SURFACE_INFO_INPUT localIn
= *pIn
;
192 ADDR_TILEINFO tileInfoNull
= {0};
196 // If the original input has a valid ADDR_TILEINFO pointer then copy its contents.
197 // Otherwise the default 0's in tileInfoNull are used.
200 tileInfoNull
= *pIn
->pTileInfo
;
202 localIn
.pTileInfo
= &tileInfoNull
;
205 localIn
.numSamples
= pIn
->numSamples
== 0 ? 1 : pIn
->numSamples
;
207 // Do mipmap check first
208 // If format is BCn, pre-pad dimension to power-of-two according to HWL
209 ComputeMipLevel(&localIn
);
211 if (m_configFlags
.checkLast2DLevel
)
213 // Save this level's original height in pixels
214 pOut
->height
= pIn
->height
;
219 AddrElemMode elemMode
;
221 // Save outputs that may not go through HWL
222 pOut
->pixelBits
= localIn
.bpp
;
223 pOut
->numSamples
= localIn
.numSamples
;
224 pOut
->last2DLevel
= FALSE
;
225 pOut
->tcCompatible
= FALSE
;
228 if (localIn
.numSamples
> 1)
230 ADDR_ASSERT(localIn
.mipLevel
== 0);
234 if (localIn
.format
!= ADDR_FMT_INVALID
) // Set format to INVALID will skip this conversion
236 // Get compression/expansion factors and element mode
237 // (which indicates compression/expansion
238 localIn
.bpp
= GetElemLib()->GetBitsPerPixel(localIn
.format
,
243 // Special flag for 96 bit surface. 96 (or 48 if we support) bit surface's width is
244 // pre-multiplied by 3 and bpp is divided by 3. So pitch alignment for linear-
245 // aligned does not meet 64-pixel in real. We keep special handling in hwl since hw
246 // restrictions are different.
247 // Also Mip 1+ needs an element pitch of 32 bits so we do not need this workaround
248 // but we use this flag to skip RestoreSurfaceInfo below
250 if ((elemMode
== ADDR_EXPANDED
) &&
253 ADDR_ASSERT(localIn
.tileMode
== ADDR_TM_LINEAR_ALIGNED
|| localIn
.height
== 1);
256 GetElemLib()->AdjustSurfaceInfo(elemMode
,
264 // Overwrite these parameters if we have a valid format
266 else if (localIn
.bpp
!= 0)
268 localIn
.width
= (localIn
.width
!= 0) ? localIn
.width
: 1;
269 localIn
.height
= (localIn
.height
!= 0) ? localIn
.height
: 1;
271 else // Rule out some invalid parameters
273 ADDR_ASSERT_ALWAYS();
275 returnCode
= ADDR_INVALIDPARAMS
;
278 // Check mipmap after surface expansion
279 if (returnCode
== ADDR_OK
)
281 returnCode
= PostComputeMipLevel(&localIn
, pOut
);
284 if (returnCode
== ADDR_OK
)
286 if (UseTileIndex(localIn
.tileIndex
))
288 // Make sure pTileInfo is not NULL
289 ADDR_ASSERT(localIn
.pTileInfo
);
291 UINT_32 numSamples
= GetNumFragments(localIn
.numSamples
, localIn
.numFrags
);
293 INT_32 macroModeIndex
= TileIndexNoMacroIndex
;
295 if (localIn
.tileIndex
!= TileIndexLinearGeneral
)
297 // Try finding a macroModeIndex
298 macroModeIndex
= HwlComputeMacroModeIndex(localIn
.tileIndex
,
307 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
308 if (macroModeIndex
== TileIndexNoMacroIndex
)
310 returnCode
= HwlSetupTileCfg(localIn
.bpp
,
311 localIn
.tileIndex
, macroModeIndex
,
313 &localIn
.tileMode
, &localIn
.tileType
);
315 // If macroModeIndex is invalid, then assert this is not macro tiled
316 else if (macroModeIndex
== TileIndexInvalid
)
318 ADDR_ASSERT(!IsMacroTiled(localIn
.tileMode
));
321 pOut
->macroModeIndex
= macroModeIndex
;
325 if (returnCode
== ADDR_OK
)
327 // HWL layer may override tile mode if necessary
328 HwlOverrideTileMode(&localIn
);
330 AddrTileMode tileMode
= localIn
.tileMode
;
332 // Optimize tile mode if possible
333 if (OptimizeTileMode(&localIn
, &tileMode
))
335 localIn
.tileMode
= tileMode
;
339 // Call main function to compute surface info
340 if (returnCode
== ADDR_OK
)
342 returnCode
= HwlComputeSurfaceInfo(&localIn
, pOut
);
345 if (returnCode
== ADDR_OK
)
347 // Since bpp might be changed we just pass it through
348 pOut
->bpp
= localIn
.bpp
;
350 // Also original width/height/bpp
351 pOut
->pixelPitch
= pOut
->pitch
;
352 pOut
->pixelHeight
= pOut
->height
;
355 if (localIn
.flags
.display
)
357 ADDR_ASSERT((pOut
->pitchAlign
% 32) == 0);
361 if (localIn
.format
!= ADDR_FMT_INVALID
)
364 // 96 bits surface of level 1+ requires element pitch of 32 bits instead
365 // In hwl function we skip multiplication of 3 then we should skip division of 3
366 // We keep pitch that represents 32 bit element instead of 96 bits since we
367 // will get an odd number if divided by 3.
369 if (!((expandX
== 3) && (localIn
.mipLevel
> 0)))
372 GetElemLib()->RestoreSurfaceInfo(elemMode
,
381 if (localIn
.flags
.qbStereo
)
383 if (pOut
->pStereoInfo
)
385 ComputeQbStereoInfo(pOut
);
389 if (localIn
.flags
.volume
) // For volume sliceSize equals to all z-slices
391 pOut
->sliceSize
= pOut
->surfSize
;
393 else // For array: sliceSize is likely to have slice-padding (the last one)
395 pOut
->sliceSize
= pOut
->surfSize
/ pOut
->depth
;
398 if (pIn
->numSlices
> 1)
400 // If this is the last slice then add the padding size to this slice
401 if (pIn
->slice
== (pIn
->numSlices
- 1))
403 pOut
->sliceSize
+= pOut
->sliceSize
* (pOut
->depth
- pIn
->numSlices
);
405 else if (m_configFlags
.checkLast2DLevel
)
407 // Reset last2DLevel flag if this is not the last array slice
408 pOut
->last2DLevel
= FALSE
;
413 pOut
->pitchTileMax
= pOut
->pitch
/ 8 - 1;
414 pOut
->heightTileMax
= pOut
->height
/ 8 - 1;
415 pOut
->sliceTileMax
= pOut
->pitch
* pOut
->height
/ 64 - 1;
423 ***************************************************************************************************
424 * AddrLib1::ComputeSurfaceInfo
427 * Interface function stub of AddrComputeSurfaceInfo.
431 ***************************************************************************************************
433 ADDR_E_RETURNCODE
AddrLib1::ComputeSurfaceAddrFromCoord(
434 const ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
435 ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
438 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
440 if (GetFillSizeFieldsFlags() == TRUE
)
442 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT
)) ||
443 (pOut
->size
!= sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT
)))
445 returnCode
= ADDR_PARAMSIZEMISMATCH
;
449 if (returnCode
== ADDR_OK
)
451 ADDR_TILEINFO tileInfoNull
;
452 ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT input
;
454 if (UseTileIndex(pIn
->tileIndex
))
457 // Use temp tile info for calcalation
458 input
.pTileInfo
= &tileInfoNull
;
460 const ADDR_SURFACE_FLAGS flags
= {{0}};
461 UINT_32 numSamples
= GetNumFragments(pIn
->numSamples
, pIn
->numFrags
);
463 // Try finding a macroModeIndex
464 INT_32 macroModeIndex
= HwlComputeMacroModeIndex(input
.tileIndex
,
472 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
473 if (macroModeIndex
== TileIndexNoMacroIndex
)
475 returnCode
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
, macroModeIndex
,
476 input
.pTileInfo
, &input
.tileMode
, &input
.tileType
);
478 // If macroModeIndex is invalid, then assert this is not macro tiled
479 else if (macroModeIndex
== TileIndexInvalid
)
481 ADDR_ASSERT(!IsMacroTiled(input
.tileMode
));
484 // Change the input structure
488 if (returnCode
== ADDR_OK
)
490 returnCode
= HwlComputeSurfaceAddrFromCoord(pIn
, pOut
);
492 if (returnCode
== ADDR_OK
)
494 pOut
->prtBlockIndex
= static_cast<UINT_32
>(pOut
->addr
/ (64 * 1024));
503 ***************************************************************************************************
504 * AddrLib1::ComputeSurfaceCoordFromAddr
507 * Interface function stub of ComputeSurfaceCoordFromAddr.
511 ***************************************************************************************************
513 ADDR_E_RETURNCODE
AddrLib1::ComputeSurfaceCoordFromAddr(
514 const ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
515 ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
518 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
520 if (GetFillSizeFieldsFlags() == TRUE
)
522 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT
)) ||
523 (pOut
->size
!= sizeof(ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT
)))
525 returnCode
= ADDR_PARAMSIZEMISMATCH
;
529 if (returnCode
== ADDR_OK
)
531 ADDR_TILEINFO tileInfoNull
;
532 ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT input
;
534 if (UseTileIndex(pIn
->tileIndex
))
537 // Use temp tile info for calcalation
538 input
.pTileInfo
= &tileInfoNull
;
540 const ADDR_SURFACE_FLAGS flags
= {{0}};
541 UINT_32 numSamples
= GetNumFragments(pIn
->numSamples
, pIn
->numFrags
);
543 // Try finding a macroModeIndex
544 INT_32 macroModeIndex
= HwlComputeMacroModeIndex(input
.tileIndex
,
552 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
553 if (macroModeIndex
== TileIndexNoMacroIndex
)
555 returnCode
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
, macroModeIndex
,
556 input
.pTileInfo
, &input
.tileMode
, &input
.tileType
);
558 // If macroModeIndex is invalid, then assert this is not macro tiled
559 else if (macroModeIndex
== TileIndexInvalid
)
561 ADDR_ASSERT(!IsMacroTiled(input
.tileMode
));
564 // Change the input structure
568 if (returnCode
== ADDR_OK
)
570 returnCode
= HwlComputeSurfaceCoordFromAddr(pIn
, pOut
);
578 ***************************************************************************************************
579 * AddrLib1::ComputeSliceTileSwizzle
582 * Interface function stub of ComputeSliceTileSwizzle.
586 ***************************************************************************************************
588 ADDR_E_RETURNCODE
AddrLib1::ComputeSliceTileSwizzle(
589 const ADDR_COMPUTE_SLICESWIZZLE_INPUT
* pIn
, ///< [in] input structure
590 ADDR_COMPUTE_SLICESWIZZLE_OUTPUT
* pOut
///< [out] output structure
593 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
595 if (GetFillSizeFieldsFlags() == TRUE
)
597 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SLICESWIZZLE_INPUT
)) ||
598 (pOut
->size
!= sizeof(ADDR_COMPUTE_SLICESWIZZLE_OUTPUT
)))
600 returnCode
= ADDR_PARAMSIZEMISMATCH
;
604 if (returnCode
== ADDR_OK
)
606 ADDR_TILEINFO tileInfoNull
;
607 ADDR_COMPUTE_SLICESWIZZLE_INPUT input
;
609 if (UseTileIndex(pIn
->tileIndex
))
612 // Use temp tile info for calcalation
613 input
.pTileInfo
= &tileInfoNull
;
615 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
,
616 input
.pTileInfo
, &input
.tileMode
);
617 // Change the input structure
621 if (returnCode
== ADDR_OK
)
623 returnCode
= HwlComputeSliceTileSwizzle(pIn
, pOut
);
631 ***************************************************************************************************
632 * AddrLib1::ExtractBankPipeSwizzle
635 * Interface function stub of AddrExtractBankPipeSwizzle.
639 ***************************************************************************************************
641 ADDR_E_RETURNCODE
AddrLib1::ExtractBankPipeSwizzle(
642 const ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT
* pIn
, ///< [in] input structure
643 ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT
* pOut
///< [out] output structure
646 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
648 if (GetFillSizeFieldsFlags() == TRUE
)
650 if ((pIn
->size
!= sizeof(ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT
)) ||
651 (pOut
->size
!= sizeof(ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT
)))
653 returnCode
= ADDR_PARAMSIZEMISMATCH
;
657 if (returnCode
== ADDR_OK
)
659 ADDR_TILEINFO tileInfoNull
;
660 ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT input
;
662 if (UseTileIndex(pIn
->tileIndex
))
665 // Use temp tile info for calcalation
666 input
.pTileInfo
= &tileInfoNull
;
668 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
669 // Change the input structure
673 if (returnCode
== ADDR_OK
)
675 returnCode
= HwlExtractBankPipeSwizzle(pIn
, pOut
);
683 ***************************************************************************************************
684 * AddrLib1::CombineBankPipeSwizzle
687 * Interface function stub of AddrCombineBankPipeSwizzle.
691 ***************************************************************************************************
693 ADDR_E_RETURNCODE
AddrLib1::CombineBankPipeSwizzle(
694 const ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT
* pIn
, ///< [in] input structure
695 ADDR_COMBINE_BANKPIPE_SWIZZLE_OUTPUT
* pOut
///< [out] output structure
698 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
700 if (GetFillSizeFieldsFlags() == TRUE
)
702 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_INPUT
)) ||
703 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT
)))
705 returnCode
= ADDR_PARAMSIZEMISMATCH
;
709 if (returnCode
== ADDR_OK
)
711 ADDR_TILEINFO tileInfoNull
;
712 ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT input
;
714 if (UseTileIndex(pIn
->tileIndex
))
717 // Use temp tile info for calcalation
718 input
.pTileInfo
= &tileInfoNull
;
720 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
721 // Change the input structure
725 if (returnCode
== ADDR_OK
)
727 returnCode
= HwlCombineBankPipeSwizzle(pIn
->bankSwizzle
,
739 ***************************************************************************************************
740 * AddrLib1::ComputeBaseSwizzle
743 * Interface function stub of AddrCompueBaseSwizzle.
746 ***************************************************************************************************
748 ADDR_E_RETURNCODE
AddrLib1::ComputeBaseSwizzle(
749 const ADDR_COMPUTE_BASE_SWIZZLE_INPUT
* pIn
,
750 ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT
* pOut
) const
752 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
754 if (GetFillSizeFieldsFlags() == TRUE
)
756 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_INPUT
)) ||
757 (pOut
->size
!= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT
)))
759 returnCode
= ADDR_PARAMSIZEMISMATCH
;
763 if (returnCode
== ADDR_OK
)
765 ADDR_TILEINFO tileInfoNull
;
766 ADDR_COMPUTE_BASE_SWIZZLE_INPUT input
;
768 if (UseTileIndex(pIn
->tileIndex
))
771 // Use temp tile info for calcalation
772 input
.pTileInfo
= &tileInfoNull
;
774 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
775 // Change the input structure
779 if (returnCode
== ADDR_OK
)
781 if (IsMacroTiled(pIn
->tileMode
))
783 returnCode
= HwlComputeBaseSwizzle(pIn
, pOut
);
787 pOut
->tileSwizzle
= 0;
796 ***************************************************************************************************
797 * AddrLib1::ComputeFmaskInfo
800 * Interface function stub of ComputeFmaskInfo.
804 ***************************************************************************************************
806 ADDR_E_RETURNCODE
AddrLib1::ComputeFmaskInfo(
807 const ADDR_COMPUTE_FMASK_INFO_INPUT
* pIn
, ///< [in] input structure
808 ADDR_COMPUTE_FMASK_INFO_OUTPUT
* pOut
///< [out] output structure
811 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
813 if (GetFillSizeFieldsFlags() == TRUE
)
815 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_INPUT
)) ||
816 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT
)))
818 returnCode
= ADDR_PARAMSIZEMISMATCH
;
823 if (Thickness(pIn
->tileMode
) > 1)
825 returnCode
= ADDR_INVALIDPARAMS
;
828 if (returnCode
== ADDR_OK
)
830 ADDR_TILEINFO tileInfoNull
;
831 ADDR_COMPUTE_FMASK_INFO_INPUT input
;
833 if (UseTileIndex(pIn
->tileIndex
))
839 // Use temp tile info for calcalation
840 input
.pTileInfo
= pOut
->pTileInfo
;
844 input
.pTileInfo
= &tileInfoNull
;
847 ADDR_SURFACE_FLAGS flags
= {{0}};
850 // Try finding a macroModeIndex
851 INT_32 macroModeIndex
= HwlComputeMacroModeIndex(pIn
->tileIndex
,
853 HwlComputeFmaskBits(pIn
, NULL
),
858 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
859 if (macroModeIndex
== TileIndexNoMacroIndex
)
861 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, macroModeIndex
,
862 input
.pTileInfo
, &input
.tileMode
);
865 ADDR_ASSERT(macroModeIndex
!= TileIndexInvalid
);
867 // Change the input structure
871 if (returnCode
== ADDR_OK
)
873 if (pIn
->numSamples
> 1)
875 returnCode
= HwlComputeFmaskInfo(pIn
, pOut
);
879 memset(pOut
, 0, sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT
));
881 returnCode
= ADDR_INVALIDPARAMS
;
890 ***************************************************************************************************
891 * AddrLib1::ComputeFmaskAddrFromCoord
894 * Interface function stub of ComputeFmaskAddrFromCoord.
898 ***************************************************************************************************
900 ADDR_E_RETURNCODE
AddrLib1::ComputeFmaskAddrFromCoord(
901 const ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
902 ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
905 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
907 if (GetFillSizeFieldsFlags() == TRUE
)
909 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT
)) ||
910 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT
)))
912 returnCode
= ADDR_PARAMSIZEMISMATCH
;
916 if (returnCode
== ADDR_OK
)
918 ADDR_ASSERT(pIn
->numSamples
> 1);
920 if (pIn
->numSamples
> 1)
922 returnCode
= HwlComputeFmaskAddrFromCoord(pIn
, pOut
);
926 returnCode
= ADDR_INVALIDPARAMS
;
934 ***************************************************************************************************
935 * AddrLib1::ComputeFmaskCoordFromAddr
938 * Interface function stub of ComputeFmaskAddrFromCoord.
942 ***************************************************************************************************
944 ADDR_E_RETURNCODE
AddrLib1::ComputeFmaskCoordFromAddr(
945 const ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
946 ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
949 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
951 if (GetFillSizeFieldsFlags() == TRUE
)
953 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT
)) ||
954 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT
)))
956 returnCode
= ADDR_PARAMSIZEMISMATCH
;
960 if (returnCode
== ADDR_OK
)
962 ADDR_ASSERT(pIn
->numSamples
> 1);
964 if (pIn
->numSamples
> 1)
966 returnCode
= HwlComputeFmaskCoordFromAddr(pIn
, pOut
);
970 returnCode
= ADDR_INVALIDPARAMS
;
978 ***************************************************************************************************
979 * AddrLib1::ConvertTileInfoToHW
982 * Convert tile info from real value to HW register value in HW layer
986 ***************************************************************************************************
988 ADDR_E_RETURNCODE
AddrLib1::ConvertTileInfoToHW(
989 const ADDR_CONVERT_TILEINFOTOHW_INPUT
* pIn
, ///< [in] input structure
990 ADDR_CONVERT_TILEINFOTOHW_OUTPUT
* pOut
///< [out] output structure
993 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
995 if (GetFillSizeFieldsFlags() == TRUE
)
997 if ((pIn
->size
!= sizeof(ADDR_CONVERT_TILEINFOTOHW_INPUT
)) ||
998 (pOut
->size
!= sizeof(ADDR_CONVERT_TILEINFOTOHW_OUTPUT
)))
1000 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1004 if (returnCode
== ADDR_OK
)
1006 ADDR_TILEINFO tileInfoNull
;
1007 ADDR_CONVERT_TILEINFOTOHW_INPUT input
;
1008 // if pIn->reverse is TRUE, indices are ignored
1009 if (pIn
->reverse
== FALSE
&& UseTileIndex(pIn
->tileIndex
))
1012 input
.pTileInfo
= &tileInfoNull
;
1014 returnCode
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
,
1015 input
.macroModeIndex
, input
.pTileInfo
);
1020 if (returnCode
== ADDR_OK
)
1022 returnCode
= HwlConvertTileInfoToHW(pIn
, pOut
);
1030 ***************************************************************************************************
1031 * AddrLib1::ConvertTileIndex
1034 * Convert tile index to tile mode/type/info
1038 ***************************************************************************************************
1040 ADDR_E_RETURNCODE
AddrLib1::ConvertTileIndex(
1041 const ADDR_CONVERT_TILEINDEX_INPUT
* pIn
, ///< [in] input structure
1042 ADDR_CONVERT_TILEINDEX_OUTPUT
* pOut
///< [out] output structure
1045 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1047 if (GetFillSizeFieldsFlags() == TRUE
)
1049 if ((pIn
->size
!= sizeof(ADDR_CONVERT_TILEINDEX_INPUT
)) ||
1050 (pOut
->size
!= sizeof(ADDR_CONVERT_TILEINDEX_OUTPUT
)))
1052 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1056 if (returnCode
== ADDR_OK
)
1059 returnCode
= HwlSetupTileCfg(pIn
->bpp
, pIn
->tileIndex
, pIn
->macroModeIndex
,
1060 pOut
->pTileInfo
, &pOut
->tileMode
, &pOut
->tileType
);
1062 if (returnCode
== ADDR_OK
&& pIn
->tileInfoHw
)
1064 ADDR_CONVERT_TILEINFOTOHW_INPUT hwInput
= {0};
1065 ADDR_CONVERT_TILEINFOTOHW_OUTPUT hwOutput
= {0};
1067 hwInput
.pTileInfo
= pOut
->pTileInfo
;
1068 hwInput
.tileIndex
= -1;
1069 hwOutput
.pTileInfo
= pOut
->pTileInfo
;
1071 returnCode
= HwlConvertTileInfoToHW(&hwInput
, &hwOutput
);
1079 ***************************************************************************************************
1080 * AddrLib1::GetMacroModeIndex
1083 * Get macro mode index based on input info
1087 ***************************************************************************************************
1089 ADDR_E_RETURNCODE
AddrLib1::GetMacroModeIndex(
1090 const ADDR_GET_MACROMODEINDEX_INPUT
* pIn
, ///< [in] input structure
1091 ADDR_GET_MACROMODEINDEX_OUTPUT
* pOut
///< [out] output structure
1094 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1096 if (GetFillSizeFieldsFlags())
1098 if ((pIn
->size
!= sizeof(ADDR_GET_MACROMODEINDEX_INPUT
)) ||
1099 (pOut
->size
!= sizeof(ADDR_GET_MACROMODEINDEX_OUTPUT
)))
1101 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1105 if (returnCode
== ADDR_OK
)
1107 ADDR_TILEINFO tileInfo
= {0};
1108 pOut
->macroModeIndex
= HwlComputeMacroModeIndex(pIn
->tileIndex
, pIn
->flags
, pIn
->bpp
,
1109 pIn
->numFrags
, &tileInfo
);
1116 ***************************************************************************************************
1117 * AddrLib1::ConvertTileIndex1
1120 * Convert tile index to tile mode/type/info
1124 ***************************************************************************************************
1126 ADDR_E_RETURNCODE
AddrLib1::ConvertTileIndex1(
1127 const ADDR_CONVERT_TILEINDEX1_INPUT
* pIn
, ///< [in] input structure
1128 ADDR_CONVERT_TILEINDEX_OUTPUT
* pOut
///< [out] output structure
1131 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1133 if (GetFillSizeFieldsFlags() == TRUE
)
1135 if ((pIn
->size
!= sizeof(ADDR_CONVERT_TILEINDEX1_INPUT
)) ||
1136 (pOut
->size
!= sizeof(ADDR_CONVERT_TILEINDEX_OUTPUT
)))
1138 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1142 if (returnCode
== ADDR_OK
)
1144 ADDR_SURFACE_FLAGS flags
= {{0}};
1146 HwlComputeMacroModeIndex(pIn
->tileIndex
, flags
, pIn
->bpp
, pIn
->numSamples
,
1147 pOut
->pTileInfo
, &pOut
->tileMode
, &pOut
->tileType
);
1149 if (pIn
->tileInfoHw
)
1151 ADDR_CONVERT_TILEINFOTOHW_INPUT hwInput
= {0};
1152 ADDR_CONVERT_TILEINFOTOHW_OUTPUT hwOutput
= {0};
1154 hwInput
.pTileInfo
= pOut
->pTileInfo
;
1155 hwInput
.tileIndex
= -1;
1156 hwOutput
.pTileInfo
= pOut
->pTileInfo
;
1158 returnCode
= HwlConvertTileInfoToHW(&hwInput
, &hwOutput
);
1166 ***************************************************************************************************
1167 * AddrLib1::GetTileIndex
1170 * Get tile index from tile mode/type/info
1174 ***************************************************************************************************
1176 ADDR_E_RETURNCODE
AddrLib1::GetTileIndex(
1177 const ADDR_GET_TILEINDEX_INPUT
* pIn
, ///< [in] input structure
1178 ADDR_GET_TILEINDEX_OUTPUT
* pOut
///< [out] output structure
1181 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1183 if (GetFillSizeFieldsFlags() == TRUE
)
1185 if ((pIn
->size
!= sizeof(ADDR_GET_TILEINDEX_INPUT
)) ||
1186 (pOut
->size
!= sizeof(ADDR_GET_TILEINDEX_OUTPUT
)))
1188 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1192 if (returnCode
== ADDR_OK
)
1194 returnCode
= HwlGetTileIndex(pIn
, pOut
);
1201 ***************************************************************************************************
1202 * AddrLib1::Thickness
1205 * Get tile mode thickness
1208 * Tile mode thickness
1209 ***************************************************************************************************
1211 UINT_32
AddrLib1::Thickness(
1212 AddrTileMode tileMode
) ///< [in] tile mode
1214 return m_modeFlags
[tileMode
].thickness
;
1219 ///////////////////////////////////////////////////////////////////////////////////////////////////
1221 ///////////////////////////////////////////////////////////////////////////////////////////////////
1224 ***************************************************************************************************
1225 * AddrLib1::ComputeHtileInfo
1228 * Interface function stub of AddrComputeHtilenfo
1232 ***************************************************************************************************
1234 ADDR_E_RETURNCODE
AddrLib1::ComputeHtileInfo(
1235 const ADDR_COMPUTE_HTILE_INFO_INPUT
* pIn
, ///< [in] input structure
1236 ADDR_COMPUTE_HTILE_INFO_OUTPUT
* pOut
///< [out] output structure
1239 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1241 BOOL_32 isWidth8
= (pIn
->blockWidth
== 8) ? TRUE
: FALSE
;
1242 BOOL_32 isHeight8
= (pIn
->blockHeight
== 8) ? TRUE
: FALSE
;
1244 if (GetFillSizeFieldsFlags() == TRUE
)
1246 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_HTILE_INFO_INPUT
)) ||
1247 (pOut
->size
!= sizeof(ADDR_COMPUTE_HTILE_INFO_OUTPUT
)))
1249 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1253 if (returnCode
== ADDR_OK
)
1255 ADDR_TILEINFO tileInfoNull
;
1256 ADDR_COMPUTE_HTILE_INFO_INPUT input
;
1258 if (UseTileIndex(pIn
->tileIndex
))
1261 // Use temp tile info for calcalation
1262 input
.pTileInfo
= &tileInfoNull
;
1264 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1266 // Change the input structure
1270 if (returnCode
== ADDR_OK
)
1272 pOut
->bpp
= ComputeHtileInfo(pIn
->flags
,
1294 ***************************************************************************************************
1295 * AddrLib1::ComputeCmaskInfo
1298 * Interface function stub of AddrComputeCmaskInfo
1302 ***************************************************************************************************
1304 ADDR_E_RETURNCODE
AddrLib1::ComputeCmaskInfo(
1305 const ADDR_COMPUTE_CMASK_INFO_INPUT
* pIn
, ///< [in] input structure
1306 ADDR_COMPUTE_CMASK_INFO_OUTPUT
* pOut
///< [out] output structure
1309 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1311 if (GetFillSizeFieldsFlags() == TRUE
)
1313 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_CMASK_INFO_INPUT
)) ||
1314 (pOut
->size
!= sizeof(ADDR_COMPUTE_CMASK_INFO_OUTPUT
)))
1316 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1320 if (returnCode
== ADDR_OK
)
1322 ADDR_TILEINFO tileInfoNull
;
1323 ADDR_COMPUTE_CMASK_INFO_INPUT input
;
1325 if (UseTileIndex(pIn
->tileIndex
))
1328 // Use temp tile info for calcalation
1329 input
.pTileInfo
= &tileInfoNull
;
1331 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1333 // Change the input structure
1337 if (returnCode
== ADDR_OK
)
1339 returnCode
= ComputeCmaskInfo(pIn
->flags
,
1360 ***************************************************************************************************
1361 * AddrLib1::ComputeDccInfo
1364 * Interface function to compute DCC key info
1367 * return code of HwlComputeDccInfo
1368 ***************************************************************************************************
1370 ADDR_E_RETURNCODE
AddrLib1::ComputeDccInfo(
1371 const ADDR_COMPUTE_DCCINFO_INPUT
* pIn
, ///< [in] input structure
1372 ADDR_COMPUTE_DCCINFO_OUTPUT
* pOut
///< [out] output structure
1375 ADDR_E_RETURNCODE ret
= ADDR_OK
;
1377 if (GetFillSizeFieldsFlags() == TRUE
)
1379 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_DCCINFO_INPUT
)) ||
1380 (pOut
->size
!= sizeof(ADDR_COMPUTE_DCCINFO_OUTPUT
)))
1382 ret
= ADDR_PARAMSIZEMISMATCH
;
1388 ADDR_COMPUTE_DCCINFO_INPUT input
;
1390 if (UseTileIndex(pIn
->tileIndex
))
1394 ret
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
, input
.macroModeIndex
,
1395 &input
.tileInfo
, &input
.tileMode
);
1402 ret
= HwlComputeDccInfo(pIn
, pOut
);
1410 ***************************************************************************************************
1411 * AddrLib1::ComputeHtileAddrFromCoord
1414 * Interface function stub of AddrComputeHtileAddrFromCoord
1418 ***************************************************************************************************
1420 ADDR_E_RETURNCODE
AddrLib1::ComputeHtileAddrFromCoord(
1421 const ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
1422 ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
1425 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1427 BOOL_32 isWidth8
= (pIn
->blockWidth
== 8) ? TRUE
: FALSE
;
1428 BOOL_32 isHeight8
= (pIn
->blockHeight
== 8) ? TRUE
: FALSE
;
1430 if (GetFillSizeFieldsFlags() == TRUE
)
1432 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT
)) ||
1433 (pOut
->size
!= sizeof(ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT
)))
1435 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1439 if (returnCode
== ADDR_OK
)
1441 ADDR_TILEINFO tileInfoNull
;
1442 ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT input
;
1444 if (UseTileIndex(pIn
->tileIndex
))
1447 // Use temp tile info for calcalation
1448 input
.pTileInfo
= &tileInfoNull
;
1450 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1452 // Change the input structure
1456 if (returnCode
== ADDR_OK
)
1458 if (pIn
->flags
.tcCompatible
)
1460 HwlComputeHtileAddrFromCoord(pIn
, pOut
);
1464 pOut
->addr
= HwlComputeXmaskAddrFromCoord(pIn
->pitch
,
1475 &pOut
->bitPosition
);
1485 ***************************************************************************************************
1486 * AddrLib1::ComputeHtileCoordFromAddr
1489 * Interface function stub of AddrComputeHtileCoordFromAddr
1493 ***************************************************************************************************
1495 ADDR_E_RETURNCODE
AddrLib1::ComputeHtileCoordFromAddr(
1496 const ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
1497 ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
1500 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1502 BOOL_32 isWidth8
= (pIn
->blockWidth
== 8) ? TRUE
: FALSE
;
1503 BOOL_32 isHeight8
= (pIn
->blockHeight
== 8) ? TRUE
: FALSE
;
1505 if (GetFillSizeFieldsFlags() == TRUE
)
1507 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT
)) ||
1508 (pOut
->size
!= sizeof(ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT
)))
1510 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1514 if (returnCode
== ADDR_OK
)
1516 ADDR_TILEINFO tileInfoNull
;
1517 ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT input
;
1519 if (UseTileIndex(pIn
->tileIndex
))
1522 // Use temp tile info for calcalation
1523 input
.pTileInfo
= &tileInfoNull
;
1525 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1527 // Change the input structure
1531 if (returnCode
== ADDR_OK
)
1533 HwlComputeXmaskCoordFromAddr(pIn
->addr
,
1553 ***************************************************************************************************
1554 * AddrLib1::ComputeCmaskAddrFromCoord
1557 * Interface function stub of AddrComputeCmaskAddrFromCoord
1561 ***************************************************************************************************
1563 ADDR_E_RETURNCODE
AddrLib1::ComputeCmaskAddrFromCoord(
1564 const ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
1565 ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
1568 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1570 if (GetFillSizeFieldsFlags() == TRUE
)
1572 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT
)) ||
1573 (pOut
->size
!= sizeof(ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT
)))
1575 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1579 if (returnCode
== ADDR_OK
)
1581 ADDR_TILEINFO tileInfoNull
;
1582 ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT input
;
1584 if (UseTileIndex(pIn
->tileIndex
))
1587 // Use temp tile info for calcalation
1588 input
.pTileInfo
= &tileInfoNull
;
1590 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1592 // Change the input structure
1596 if (returnCode
== ADDR_OK
)
1598 if (pIn
->flags
.tcCompatible
== TRUE
)
1600 returnCode
= HwlComputeCmaskAddrFromCoord(pIn
, pOut
);
1604 pOut
->addr
= HwlComputeXmaskAddrFromCoord(pIn
->pitch
,
1612 FALSE
, //this is cmask, isWidth8 is not needed
1613 FALSE
, //this is cmask, isHeight8 is not needed
1615 &pOut
->bitPosition
);
1625 ***************************************************************************************************
1626 * AddrLib1::ComputeCmaskCoordFromAddr
1629 * Interface function stub of AddrComputeCmaskCoordFromAddr
1633 ***************************************************************************************************
1635 ADDR_E_RETURNCODE
AddrLib1::ComputeCmaskCoordFromAddr(
1636 const ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
1637 ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
1640 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1642 if (GetFillSizeFieldsFlags() == TRUE
)
1644 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT
)) ||
1645 (pOut
->size
!= sizeof(ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT
)))
1647 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1651 if (returnCode
== ADDR_OK
)
1653 ADDR_TILEINFO tileInfoNull
;
1654 ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT input
;
1656 if (UseTileIndex(pIn
->tileIndex
))
1659 // Use temp tile info for calcalation
1660 input
.pTileInfo
= &tileInfoNull
;
1662 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1664 // Change the input structure
1668 if (returnCode
== ADDR_OK
)
1670 HwlComputeXmaskCoordFromAddr(pIn
->addr
,
1691 ***************************************************************************************************
1692 * AddrLib1::ComputeTileDataWidthAndHeight
1695 * Compute the squared cache shape for per-tile data (CMASK and HTILE)
1701 * MacroWidth and macroHeight are measured in pixels
1702 ***************************************************************************************************
1704 VOID
AddrLib1::ComputeTileDataWidthAndHeight(
1705 UINT_32 bpp
, ///< [in] bits per pixel
1706 UINT_32 cacheBits
, ///< [in] bits of cache
1707 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
1708 UINT_32
* pMacroWidth
, ///< [out] macro tile width
1709 UINT_32
* pMacroHeight
///< [out] macro tile height
1713 UINT_32 width
= cacheBits
/ bpp
;
1714 UINT_32 pipes
= HwlGetPipes(pTileInfo
);
1716 // Double height until the macro-tile is close to square
1717 // Height can only be doubled if width is even
1719 while ((width
> height
* 2 * pipes
) && !(width
& 1))
1725 *pMacroWidth
= 8 * width
;
1726 *pMacroHeight
= 8 * height
* pipes
;
1728 // Note: The above iterative comptuation is equivalent to the following
1730 //int log2_height = ((log2(cacheBits)-log2(bpp)-log2(pipes))/2);
1731 //int macroHeight = pow2( 3+log2(pipes)+log2_height );
1735 ***************************************************************************************************
1736 * AddrLib1::HwlComputeTileDataWidthAndHeightLinear
1739 * Compute the squared cache shape for per-tile data (CMASK and HTILE) for linear layout
1745 * MacroWidth and macroHeight are measured in pixels
1746 ***************************************************************************************************
1748 VOID
AddrLib1::HwlComputeTileDataWidthAndHeightLinear(
1749 UINT_32
* pMacroWidth
, ///< [out] macro tile width
1750 UINT_32
* pMacroHeight
, ///< [out] macro tile height
1751 UINT_32 bpp
, ///< [in] bits per pixel
1752 ADDR_TILEINFO
* pTileInfo
///< [in] tile info
1755 ADDR_ASSERT(bpp
!= 4); // Cmask does not support linear layout prior to SI
1756 *pMacroWidth
= 8 * 512 / bpp
; // Align width to 512-bit memory accesses
1757 *pMacroHeight
= 8 * m_pipes
; // Align height to number of pipes
1761 ***************************************************************************************************
1762 * AddrLib1::ComputeHtileInfo
1765 * Compute htile pitch,width, bytes per 2D slice
1768 * Htile bpp i.e. How many bits for an 8x8 tile
1769 * Also returns by output parameters:
1770 * *Htile pitch, height, total size in bytes, macro-tile dimensions and slice size*
1771 ***************************************************************************************************
1773 UINT_32
AddrLib1::ComputeHtileInfo(
1774 ADDR_HTILE_FLAGS flags
, ///< [in] htile flags
1775 UINT_32 pitchIn
, ///< [in] pitch input
1776 UINT_32 heightIn
, ///< [in] height input
1777 UINT_32 numSlices
, ///< [in] number of slices
1778 BOOL_32 isLinear
, ///< [in] if it is linear mode
1779 BOOL_32 isWidth8
, ///< [in] if htile block width is 8
1780 BOOL_32 isHeight8
, ///< [in] if htile block height is 8
1781 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
1782 UINT_32
* pPitchOut
, ///< [out] pitch output
1783 UINT_32
* pHeightOut
, ///< [out] height output
1784 UINT_64
* pHtileBytes
, ///< [out] bytes per 2D slice
1785 UINT_32
* pMacroWidth
, ///< [out] macro-tile width in pixels
1786 UINT_32
* pMacroHeight
, ///< [out] macro-tile width in pixels
1787 UINT_64
* pSliceSize
, ///< [out] slice size in bytes
1788 UINT_32
* pBaseAlign
///< [out] base alignment
1793 UINT_32 macroHeight
;
1798 numSlices
= Max(1u, numSlices
);
1800 const UINT_32 bpp
= HwlComputeHtileBpp(isWidth8
, isHeight8
);
1801 const UINT_32 cacheBits
= HtileCacheBits
;
1805 HwlComputeTileDataWidthAndHeightLinear(¯oWidth
,
1812 ComputeTileDataWidthAndHeight(bpp
,
1819 *pPitchOut
= PowTwoAlign(pitchIn
, macroWidth
);
1820 *pHeightOut
= PowTwoAlign(heightIn
, macroHeight
);
1822 baseAlign
= HwlComputeHtileBaseAlign(flags
.tcCompatible
, isLinear
, pTileInfo
);
1824 surfBytes
= HwlComputeHtileBytes(*pPitchOut
,
1832 *pHtileBytes
= surfBytes
;
1835 // Use SafeAssign since they are optional
1837 SafeAssign(pMacroWidth
, macroWidth
);
1839 SafeAssign(pMacroHeight
, macroHeight
);
1841 SafeAssign(pSliceSize
, sliceBytes
);
1843 SafeAssign(pBaseAlign
, baseAlign
);
1849 ***************************************************************************************************
1850 * AddrLib1::ComputeCmaskBaseAlign
1853 * Compute cmask base alignment
1856 * Cmask base alignment
1857 ***************************************************************************************************
1859 UINT_32
AddrLib1::ComputeCmaskBaseAlign(
1860 ADDR_CMASK_FLAGS flags
, ///< [in] Cmask flags
1861 ADDR_TILEINFO
* pTileInfo
///< [in] Tile info
1864 UINT_32 baseAlign
= m_pipeInterleaveBytes
* HwlGetPipes(pTileInfo
);
1866 if (flags
.tcCompatible
)
1868 ADDR_ASSERT(pTileInfo
!= NULL
);
1871 baseAlign
*= pTileInfo
->banks
;
1879 ***************************************************************************************************
1880 * AddrLib1::ComputeCmaskBytes
1883 * Compute cmask size in bytes
1886 * Cmask size in bytes
1887 ***************************************************************************************************
1889 UINT_64
AddrLib1::ComputeCmaskBytes(
1890 UINT_32 pitch
, ///< [in] pitch
1891 UINT_32 height
, ///< [in] height
1892 UINT_32 numSlices
///< [in] number of slices
1895 return BITS_TO_BYTES(static_cast<UINT_64
>(pitch
) * height
* numSlices
* CmaskElemBits
) /
1900 ***************************************************************************************************
1901 * AddrLib1::ComputeCmaskInfo
1904 * Compute cmask pitch,width, bytes per 2D slice
1907 * BlockMax. Also by output parameters: Cmask pitch,height, total size in bytes,
1908 * macro-tile dimensions
1909 ***************************************************************************************************
1911 ADDR_E_RETURNCODE
AddrLib1::ComputeCmaskInfo(
1912 ADDR_CMASK_FLAGS flags
, ///< [in] cmask flags
1913 UINT_32 pitchIn
, ///< [in] pitch input
1914 UINT_32 heightIn
, ///< [in] height input
1915 UINT_32 numSlices
, ///< [in] number of slices
1916 BOOL_32 isLinear
, ///< [in] is linear mode
1917 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
1918 UINT_32
* pPitchOut
, ///< [out] pitch output
1919 UINT_32
* pHeightOut
, ///< [out] height output
1920 UINT_64
* pCmaskBytes
, ///< [out] bytes per 2D slice
1921 UINT_32
* pMacroWidth
, ///< [out] macro-tile width in pixels
1922 UINT_32
* pMacroHeight
, ///< [out] macro-tile width in pixels
1923 UINT_64
* pSliceSize
, ///< [out] slice size in bytes
1924 UINT_32
* pBaseAlign
, ///< [out] base alignment
1925 UINT_32
* pBlockMax
///< [out] block max == slice / 128 / 128 - 1
1929 UINT_32 macroHeight
;
1934 numSlices
= Max(1u, numSlices
);
1936 const UINT_32 bpp
= CmaskElemBits
;
1937 const UINT_32 cacheBits
= CmaskCacheBits
;
1939 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1943 HwlComputeTileDataWidthAndHeightLinear(¯oWidth
,
1950 ComputeTileDataWidthAndHeight(bpp
,
1957 *pPitchOut
= (pitchIn
+ macroWidth
- 1) & ~(macroWidth
- 1);
1958 *pHeightOut
= (heightIn
+ macroHeight
- 1) & ~(macroHeight
- 1);
1961 sliceBytes
= ComputeCmaskBytes(*pPitchOut
,
1965 baseAlign
= ComputeCmaskBaseAlign(flags
, pTileInfo
);
1967 while (sliceBytes
% baseAlign
)
1969 *pHeightOut
+= macroHeight
;
1971 sliceBytes
= ComputeCmaskBytes(*pPitchOut
,
1976 surfBytes
= sliceBytes
* numSlices
;
1978 *pCmaskBytes
= surfBytes
;
1981 // Use SafeAssign since they are optional
1983 SafeAssign(pMacroWidth
, macroWidth
);
1985 SafeAssign(pMacroHeight
, macroHeight
);
1987 SafeAssign(pBaseAlign
, baseAlign
);
1989 SafeAssign(pSliceSize
, sliceBytes
);
1991 UINT_32 slice
= (*pPitchOut
) * (*pHeightOut
);
1992 UINT_32 blockMax
= slice
/ 128 / 128 - 1;
1995 if (slice
% (64*256) != 0)
1997 ADDR_ASSERT_ALWAYS();
2001 UINT_32 maxBlockMax
= HwlGetMaxCmaskBlockMax();
2003 if (blockMax
> maxBlockMax
)
2005 blockMax
= maxBlockMax
;
2006 returnCode
= ADDR_INVALIDPARAMS
;
2009 SafeAssign(pBlockMax
, blockMax
);
2015 ***************************************************************************************************
2016 * AddrLib1::ComputeXmaskCoordYFromPipe
2019 * Compute the Y coord from pipe number for cmask/htile
2024 ***************************************************************************************************
2026 UINT_32
AddrLib1::ComputeXmaskCoordYFromPipe(
2027 UINT_32 pipe
, ///< [in] pipe number
2028 UINT_32 x
///< [in] x coordinate
2040 UINT_32 numPipes
= m_pipes
; // SI has its implementation
2042 // Convert pipe + x to y coordinate.
2062 pipeBit0
= pipe
& 0x1;
2066 yBit0
= pipeBit0
^ xBit0
;
2080 pipeBit0
= pipe
& 0x1;
2081 pipeBit1
= (pipe
& 0x2) >> 1;
2084 xBit1
= (x
& 0x2) >> 1;
2086 yBit0
= pipeBit0
^ xBit1
;
2087 yBit1
= pipeBit1
^ xBit0
;
2096 // r600 and r800 have different method
2098 y
= HwlComputeXmaskCoordYFrom8Pipe(pipe
, x
);
2107 ***************************************************************************************************
2108 * AddrLib1::HwlComputeXmaskCoordFromAddr
2111 * Compute the coord from an address of a cmask/htile
2117 * This method is reused by htile, so rename to Xmask
2118 ***************************************************************************************************
2120 VOID
AddrLib1::HwlComputeXmaskCoordFromAddr(
2121 UINT_64 addr
, ///< [in] address
2122 UINT_32 bitPosition
, ///< [in] bitPosition in a byte
2123 UINT_32 pitch
, ///< [in] pitch
2124 UINT_32 height
, ///< [in] height
2125 UINT_32 numSlices
, ///< [in] number of slices
2126 UINT_32 factor
, ///< [in] factor that indicates cmask or htile
2127 BOOL_32 isLinear
, ///< [in] linear or tiled HTILE layout
2128 BOOL_32 isWidth8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2129 BOOL_32 isHeight8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2130 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
2131 UINT_32
* pX
, ///< [out] x coord
2132 UINT_32
* pY
, ///< [out] y coord
2133 UINT_32
* pSlice
///< [out] slice index
2138 UINT_32 numPipeBits
;
2139 UINT_32 macroTilePitch
;
2140 UINT_32 macroTileHeight
;
2144 UINT_32 microTileCoordY
;
2148 UINT_32 pitchAligned
= pitch
;
2149 UINT_32 heightAligned
= height
;
2157 UINT_64 macroNumber
;
2158 UINT_32 microNumber
;
2167 UINT_32 tilesPerMacro
;
2168 UINT_32 macrosPerPitch
;
2169 UINT_32 macrosPerSlice
;
2174 numPipes
= HwlGetPipes(pTileInfo
);
2175 pipe
= ComputePipeFromAddr(addr
, numPipes
);
2178 // Compute the number of group and pipe bits.
2180 numPipeBits
= Log2(numPipes
);
2182 UINT_32 groupBits
= 8 * m_pipeInterleaveBytes
;
2183 UINT_32 pipes
= numPipes
;
2187 // Compute the micro tile size, in bits. And macro tile pitch and height.
2189 if (factor
== 2) //CMASK
2191 ADDR_CMASK_FLAGS flags
= {{0}};
2193 elemBits
= CmaskElemBits
;
2195 ComputeCmaskInfo(flags
,
2209 ADDR_HTILE_FLAGS flags
= {{0}};
2216 elemBits
= HwlComputeHtileBpp(isWidth8
, isHeight8
);
2218 ComputeHtileInfo(flags
,
2233 // Should use aligned dims
2235 pitch
= pitchAligned
;
2236 height
= heightAligned
;
2240 // Convert byte address to bit address.
2242 bitAddr
= BYTES_TO_BITS(addr
) + bitPosition
;
2246 // Remove pipe bits from address.
2249 bitAddr
= (bitAddr
% groupBits
) + ((bitAddr
/groupBits
/pipes
)*groupBits
);
2252 elemOffset
= bitAddr
/ elemBits
;
2254 tilesPerMacro
= (macroTilePitch
/factor
) * macroTileHeight
/ MicroTilePixels
>> numPipeBits
;
2256 macrosPerPitch
= pitch
/ (macroTilePitch
/factor
);
2257 macrosPerSlice
= macrosPerPitch
* height
/ macroTileHeight
;
2259 macroIndex
= elemOffset
/ factor
/ tilesPerMacro
;
2260 microIndex
= static_cast<UINT_32
>(elemOffset
% (tilesPerMacro
* factor
));
2262 macroNumber
= macroIndex
* factor
+ microIndex
% factor
;
2263 microNumber
= microIndex
/ factor
;
2265 macroX
= static_cast<UINT_32
>((macroNumber
% macrosPerPitch
));
2266 macroY
= static_cast<UINT_32
>((macroNumber
% macrosPerSlice
) / macrosPerPitch
);
2267 macroZ
= static_cast<UINT_32
>((macroNumber
/ macrosPerSlice
));
2270 microX
= microNumber
% (macroTilePitch
/ factor
/ MicroTileWidth
);
2271 microY
= (microNumber
/ (macroTilePitch
/ factor
/ MicroTileHeight
));
2273 *pX
= macroX
* (macroTilePitch
/factor
) + microX
* MicroTileWidth
;
2274 *pY
= macroY
* macroTileHeight
+ (microY
* MicroTileHeight
<< numPipeBits
);
2277 microTileCoordY
= ComputeXmaskCoordYFromPipe(pipe
,
2278 *pX
/MicroTileWidth
);
2282 // Assemble final coordinates.
2284 *pY
+= microTileCoordY
* MicroTileHeight
;
2289 ***************************************************************************************************
2290 * AddrLib1::HwlComputeXmaskAddrFromCoord
2293 * Compute the address from an address of cmask (prior to si)
2298 ***************************************************************************************************
2300 UINT_64
AddrLib1::HwlComputeXmaskAddrFromCoord(
2301 UINT_32 pitch
, ///< [in] pitch
2302 UINT_32 height
, ///< [in] height
2303 UINT_32 x
, ///< [in] x coord
2304 UINT_32 y
, ///< [in] y coord
2305 UINT_32 slice
, ///< [in] slice/depth index
2306 UINT_32 numSlices
, ///< [in] number of slices
2307 UINT_32 factor
, ///< [in] factor that indicates cmask(2) or htile(1)
2308 BOOL_32 isLinear
, ///< [in] linear or tiled HTILE layout
2309 BOOL_32 isWidth8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2310 BOOL_32 isHeight8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2311 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
2312 UINT_32
* pBitPosition
///< [out] bit position inside a byte
2316 UINT_32 numGroupBits
;
2317 UINT_32 numPipeBits
;
2318 UINT_32 newPitch
= 0;
2319 UINT_32 newHeight
= 0;
2320 UINT_64 sliceBytes
= 0;
2321 UINT_64 totalBytes
= 0;
2322 UINT_64 sliceOffset
;
2324 UINT_32 macroTileWidth
;
2325 UINT_32 macroTileHeight
;
2326 UINT_32 macroTilesPerRow
;
2327 UINT_32 macroTileBytes
;
2328 UINT_32 macroTileIndexX
;
2329 UINT_32 macroTileIndexY
;
2330 UINT_64 macroTileOffset
;
2331 UINT_32 pixelBytesPerRow
;
2332 UINT_32 pixelOffsetX
;
2333 UINT_32 pixelOffsetY
;
2334 UINT_32 pixelOffset
;
2335 UINT_64 totalOffset
;
2341 UINT_32 elemBits
= 0;
2343 UINT_32 numPipes
= m_pipes
; // This function is accessed prior to si only
2345 if (factor
== 2) //CMASK
2347 elemBits
= CmaskElemBits
;
2349 // For asics before SI, cmask is always tiled
2354 if (factor
!= 1) // Fix compile warning
2359 elemBits
= HwlComputeHtileBpp(isWidth8
, isHeight8
);
2363 // Compute the number of group bits and pipe bits.
2365 numGroupBits
= Log2(m_pipeInterleaveBytes
);
2366 numPipeBits
= Log2(numPipes
);
2369 // Compute macro tile dimensions.
2371 if (factor
== 2) // CMASK
2373 ADDR_CMASK_FLAGS flags
= {{0}};
2375 ComputeCmaskInfo(flags
,
2387 sliceBytes
= totalBytes
/ numSlices
;
2391 ADDR_HTILE_FLAGS flags
= {{0}};
2393 ComputeHtileInfo(flags
,
2409 sliceOffset
= slice
* sliceBytes
;
2412 // Get the pipe. Note that neither slice rotation nor pipe swizzling apply for CMASK.
2414 pipe
= ComputePipeFromCoord(x
,
2417 ADDR_TM_2D_TILED_THIN1
,
2423 // Compute the number of macro tiles per row.
2425 macroTilesPerRow
= newPitch
/ macroTileWidth
;
2428 // Compute the number of bytes per macro tile.
2430 macroTileBytes
= BITS_TO_BYTES((macroTileWidth
* macroTileHeight
* elemBits
) / MicroTilePixels
);
2433 // Compute the offset to the macro tile containing the specified coordinate.
2435 macroTileIndexX
= x
/ macroTileWidth
;
2436 macroTileIndexY
= y
/ macroTileHeight
;
2437 macroTileOffset
= ((macroTileIndexY
* macroTilesPerRow
) + macroTileIndexX
) * macroTileBytes
;
2440 // Compute the pixel offset within the macro tile.
2442 pixelBytesPerRow
= BITS_TO_BYTES(macroTileWidth
* elemBits
) / MicroTileWidth
;
2445 // The nibbles are interleaved (see below), so the part of the offset relative to the x
2446 // coordinate repeats halfway across the row. (Not for HTILE)
2450 pixelOffsetX
= (x
% (macroTileWidth
/ 2)) / MicroTileWidth
;
2454 pixelOffsetX
= (x
% (macroTileWidth
)) / MicroTileWidth
* BITS_TO_BYTES(elemBits
);
2458 // Compute the y offset within the macro tile.
2460 pixelOffsetY
= (((y
% macroTileHeight
) / MicroTileHeight
) / numPipes
) * pixelBytesPerRow
;
2462 pixelOffset
= pixelOffsetX
+ pixelOffsetY
;
2465 // Combine the slice offset and macro tile offset with the pixel offset, accounting for the
2466 // pipe bits in the middle of the address.
2468 totalOffset
= ((sliceOffset
+ macroTileOffset
) >> numPipeBits
) + pixelOffset
;
2471 // Split the offset to put some bits below the pipe bits and some above.
2473 groupMask
= (1 << numGroupBits
) - 1;
2474 offsetLo
= totalOffset
& groupMask
;
2475 offsetHi
= (totalOffset
& ~groupMask
) << numPipeBits
;
2478 // Assemble the address from its components.
2482 // This is to remove warning with /analyze option
2483 UINT_32 pipeBits
= pipe
<< numGroupBits
;
2487 // Compute the bit position. The lower nibble is used when the x coordinate within the macro
2488 // tile is less than half of the macro tile width, and the upper nibble is used when the x
2489 // coordinate within the macro tile is greater than or equal to half the macro tile width.
2491 *pBitPosition
= ((x
% macroTileWidth
) < (macroTileWidth
/ factor
)) ? 0 : 4;
2496 ///////////////////////////////////////////////////////////////////////////////////////////////////
2497 // Surface Addressing Shared
2498 ///////////////////////////////////////////////////////////////////////////////////////////////////
2501 ***************************************************************************************************
2502 * AddrLib1::ComputeSurfaceAddrFromCoordLinear
2505 * Compute address from coord for linear surface
2510 ***************************************************************************************************
2512 UINT_64
AddrLib1::ComputeSurfaceAddrFromCoordLinear(
2513 UINT_32 x
, ///< [in] x coord
2514 UINT_32 y
, ///< [in] y coord
2515 UINT_32 slice
, ///< [in] slice/depth index
2516 UINT_32 sample
, ///< [in] sample index
2517 UINT_32 bpp
, ///< [in] bits per pixel
2518 UINT_32 pitch
, ///< [in] pitch
2519 UINT_32 height
, ///< [in] height
2520 UINT_32 numSlices
, ///< [in] number of slices
2521 UINT_32
* pBitPosition
///< [out] bit position inside a byte
2524 const UINT_64 sliceSize
= static_cast<UINT_64
>(pitch
) * height
;
2526 UINT_64 sliceOffset
= (slice
+ sample
* numSlices
)* sliceSize
;
2527 UINT_64 rowOffset
= static_cast<UINT_64
>(y
) * pitch
;
2528 UINT_64 pixOffset
= x
;
2530 UINT_64 addr
= (sliceOffset
+ rowOffset
+ pixOffset
) * bpp
;
2532 *pBitPosition
= static_cast<UINT_32
>(addr
% 8);
2539 ***************************************************************************************************
2540 * AddrLib1::ComputeSurfaceCoordFromAddrLinear
2543 * Compute the coord from an address of a linear surface
2547 ***************************************************************************************************
2549 VOID
AddrLib1::ComputeSurfaceCoordFromAddrLinear(
2550 UINT_64 addr
, ///< [in] address
2551 UINT_32 bitPosition
, ///< [in] bitPosition in a byte
2552 UINT_32 bpp
, ///< [in] bits per pixel
2553 UINT_32 pitch
, ///< [in] pitch
2554 UINT_32 height
, ///< [in] height
2555 UINT_32 numSlices
, ///< [in] number of slices
2556 UINT_32
* pX
, ///< [out] x coord
2557 UINT_32
* pY
, ///< [out] y coord
2558 UINT_32
* pSlice
, ///< [out] slice/depth index
2559 UINT_32
* pSample
///< [out] sample index
2562 const UINT_64 sliceSize
= static_cast<UINT_64
>(pitch
) * height
;
2563 const UINT_64 linearOffset
= (BYTES_TO_BITS(addr
) + bitPosition
) / bpp
;
2565 *pX
= static_cast<UINT_32
>((linearOffset
% sliceSize
) % pitch
);
2566 *pY
= static_cast<UINT_32
>((linearOffset
% sliceSize
) / pitch
% height
);
2567 *pSlice
= static_cast<UINT_32
>((linearOffset
/ sliceSize
) % numSlices
);
2568 *pSample
= static_cast<UINT_32
>((linearOffset
/ sliceSize
) / numSlices
);
2572 ***************************************************************************************************
2573 * AddrLib1::ComputeSurfaceCoordFromAddrMicroTiled
2576 * Compute the coord from an address of a micro tiled surface
2580 ***************************************************************************************************
2582 VOID
AddrLib1::ComputeSurfaceCoordFromAddrMicroTiled(
2583 UINT_64 addr
, ///< [in] address
2584 UINT_32 bitPosition
, ///< [in] bitPosition in a byte
2585 UINT_32 bpp
, ///< [in] bits per pixel
2586 UINT_32 pitch
, ///< [in] pitch
2587 UINT_32 height
, ///< [in] height
2588 UINT_32 numSamples
, ///< [in] number of samples
2589 AddrTileMode tileMode
, ///< [in] tile mode
2590 UINT_32 tileBase
, ///< [in] base offset within a tile
2591 UINT_32 compBits
, ///< [in] component bits actually needed(for planar surface)
2592 UINT_32
* pX
, ///< [out] x coord
2593 UINT_32
* pY
, ///< [out] y coord
2594 UINT_32
* pSlice
, ///< [out] slice/depth index
2595 UINT_32
* pSample
, ///< [out] sample index,
2596 AddrTileType microTileType
, ///< [in] micro tiling order
2597 BOOL_32 isDepthSampleOrder
///< [in] TRUE if in depth sample order
2601 UINT_32 microTileThickness
;
2602 UINT_32 microTileBits
;
2606 UINT_32 microTileCoordX
;
2607 UINT_32 microTileCoordY
;
2608 UINT_32 pixelOffset
;
2609 UINT_32 pixelCoordX
= 0;
2610 UINT_32 pixelCoordY
= 0;
2611 UINT_32 pixelCoordZ
= 0;
2612 UINT_32 pixelCoordS
= 0;
2615 // Convert byte address to bit address.
2617 bitAddr
= BYTES_TO_BITS(addr
) + bitPosition
;
2620 // Compute the micro tile size, in bits.
2624 case ADDR_TM_1D_TILED_THICK
:
2625 microTileThickness
= ThickTileThickness
;
2628 microTileThickness
= 1;
2632 microTileBits
= MicroTilePixels
* microTileThickness
* bpp
* numSamples
;
2635 // Compute number of bits per slice and number of bits per row of micro tiles.
2637 sliceBits
= static_cast<UINT_64
>(pitch
) * height
* microTileThickness
* bpp
* numSamples
;
2639 rowBits
= (pitch
/ MicroTileWidth
) * microTileBits
;
2642 // Extract the slice index.
2644 sliceIndex
= static_cast<UINT_32
>(bitAddr
/ sliceBits
);
2645 bitAddr
-= sliceIndex
* sliceBits
;
2648 // Extract the y coordinate of the micro tile.
2650 microTileCoordY
= static_cast<UINT_32
>(bitAddr
/ rowBits
) * MicroTileHeight
;
2651 bitAddr
-= (microTileCoordY
/ MicroTileHeight
) * rowBits
;
2654 // Extract the x coordinate of the micro tile.
2656 microTileCoordX
= static_cast<UINT_32
>(bitAddr
/ microTileBits
) * MicroTileWidth
;
2659 // Compute the pixel offset within the micro tile.
2661 pixelOffset
= static_cast<UINT_32
>(bitAddr
% microTileBits
);
2664 // Extract pixel coordinates from the offset.
2666 HwlComputePixelCoordFromOffset(pixelOffset
,
2677 isDepthSampleOrder
);
2680 // Assemble final coordinates.
2682 *pX
= microTileCoordX
+ pixelCoordX
;
2683 *pY
= microTileCoordY
+ pixelCoordY
;
2684 *pSlice
= (sliceIndex
* microTileThickness
) + pixelCoordZ
;
2685 *pSample
= pixelCoordS
;
2687 if (microTileThickness
> 1)
2694 ***************************************************************************************************
2695 * AddrLib1::ComputePipeFromAddr
2698 * Compute the pipe number from an address
2703 ***************************************************************************************************
2705 UINT_32
AddrLib1::ComputePipeFromAddr(
2706 UINT_64 addr
, ///< [in] address
2707 UINT_32 numPipes
///< [in] number of banks
2712 UINT_32 groupBytes
= m_pipeInterleaveBytes
; //just different terms
2715 // The LSBs of the address are arranged as follows:
2716 // bank | pipe | group
2718 // To get the pipe number, shift off the group bits and mask the pipe bits.
2722 // The LSBs of the address are arranged as follows:
2723 // bank | bankInterleave | pipe | pipeInterleave
2725 // To get the pipe number, shift off the pipe interleave bits and mask the pipe bits.
2728 pipe
= static_cast<UINT_32
>(addr
>> Log2(groupBytes
)) & (numPipes
- 1);
2734 ***************************************************************************************************
2735 * AddrLib1::ComputeMicroTileEquation
2738 * Compute micro tile equation
2741 * If equation can be computed
2743 ***************************************************************************************************
2745 ADDR_E_RETURNCODE
AddrLib1::ComputeMicroTileEquation(
2746 UINT_32 log2BytesPP
, ///< [in] log2 of bytes per pixel
2747 AddrTileMode tileMode
, ///< [in] tile mode
2748 AddrTileType microTileType
, ///< [in] pixel order in display/non-display mode
2749 ADDR_EQUATION
* pEquation
///< [out] equation
2752 ADDR_E_RETURNCODE retCode
= ADDR_OK
;
2754 for (UINT_32 i
= 0; i
< log2BytesPP
; i
++)
2756 pEquation
->addr
[i
].valid
= 1;
2757 pEquation
->addr
[i
].channel
= 0;
2758 pEquation
->addr
[i
].index
= i
;
2761 ADDR_CHANNEL_SETTING
* pixelBit
= &pEquation
->addr
[log2BytesPP
];
2763 ADDR_CHANNEL_SETTING x0
= InitChannel(1, 0, log2BytesPP
+ 0);
2764 ADDR_CHANNEL_SETTING x1
= InitChannel(1, 0, log2BytesPP
+ 1);
2765 ADDR_CHANNEL_SETTING x2
= InitChannel(1, 0, log2BytesPP
+ 2);
2766 ADDR_CHANNEL_SETTING y0
= InitChannel(1, 1, 0);
2767 ADDR_CHANNEL_SETTING y1
= InitChannel(1, 1, 1);
2768 ADDR_CHANNEL_SETTING y2
= InitChannel(1, 1, 2);
2769 ADDR_CHANNEL_SETTING z0
= InitChannel(1, 2, 0);
2770 ADDR_CHANNEL_SETTING z1
= InitChannel(1, 2, 1);
2771 ADDR_CHANNEL_SETTING z2
= InitChannel(1, 2, 2);
2773 UINT_32 thickness
= Thickness(tileMode
);
2774 UINT_32 bpp
= 1 << (log2BytesPP
+ 3);
2776 if (microTileType
!= ADDR_THICK
)
2778 if (microTileType
== ADDR_DISPLAYABLE
)
2823 ADDR_ASSERT_ALWAYS();
2827 else if (microTileType
== ADDR_NON_DISPLAYABLE
|| microTileType
== ADDR_DEPTH_SAMPLE_ORDER
)
2836 else if (microTileType
== ADDR_ROTATED
)
2838 ADDR_ASSERT(thickness
== 1);
2875 retCode
= ADDR_NOTSUPPORTED
;
2884 pEquation
->numBits
= 8 + log2BytesPP
;
2888 pEquation
->numBits
= 6 + log2BytesPP
;
2893 ADDR_ASSERT(thickness
> 1);
2924 ADDR_ASSERT_ALWAYS();
2930 pEquation
->numBits
= 8 + log2BytesPP
;
2936 pEquation
->numBits
= 9 + log2BytesPP
;
2939 // stackedDepthSlices is used for addressing mode that a tile block contains multiple slices,
2940 // which is not supported by our address lib
2941 pEquation
->stackedDepthSlices
= FALSE
;
2947 ***************************************************************************************************
2948 * AddrLib1::ComputePixelIndexWithinMicroTile
2951 * Compute the pixel index inside a micro tile of surface
2956 ***************************************************************************************************
2958 UINT_32
AddrLib1::ComputePixelIndexWithinMicroTile(
2959 UINT_32 x
, ///< [in] x coord
2960 UINT_32 y
, ///< [in] y coord
2961 UINT_32 z
, ///< [in] slice/depth index
2962 UINT_32 bpp
, ///< [in] bits per pixel
2963 AddrTileMode tileMode
, ///< [in] tile mode
2964 AddrTileType microTileType
///< [in] pixel order in display/non-display mode
2967 UINT_32 pixelBit0
= 0;
2968 UINT_32 pixelBit1
= 0;
2969 UINT_32 pixelBit2
= 0;
2970 UINT_32 pixelBit3
= 0;
2971 UINT_32 pixelBit4
= 0;
2972 UINT_32 pixelBit5
= 0;
2973 UINT_32 pixelBit6
= 0;
2974 UINT_32 pixelBit7
= 0;
2975 UINT_32 pixelBit8
= 0;
2976 UINT_32 pixelNumber
;
2978 UINT_32 x0
= _BIT(x
, 0);
2979 UINT_32 x1
= _BIT(x
, 1);
2980 UINT_32 x2
= _BIT(x
, 2);
2981 UINT_32 y0
= _BIT(y
, 0);
2982 UINT_32 y1
= _BIT(y
, 1);
2983 UINT_32 y2
= _BIT(y
, 2);
2984 UINT_32 z0
= _BIT(z
, 0);
2985 UINT_32 z1
= _BIT(z
, 1);
2986 UINT_32 z2
= _BIT(z
, 2);
2988 UINT_32 thickness
= Thickness(tileMode
);
2990 // Compute the pixel number within the micro tile.
2992 if (microTileType
!= ADDR_THICK
)
2994 if (microTileType
== ADDR_DISPLAYABLE
)
3039 ADDR_ASSERT_ALWAYS();
3043 else if (microTileType
== ADDR_NON_DISPLAYABLE
|| microTileType
== ADDR_DEPTH_SAMPLE_ORDER
)
3052 else if (microTileType
== ADDR_ROTATED
)
3054 ADDR_ASSERT(thickness
== 1);
3091 ADDR_ASSERT_ALWAYS();
3104 ADDR_ASSERT(thickness
> 1);
3135 ADDR_ASSERT_ALWAYS();
3148 pixelNumber
= ((pixelBit0
) |
3162 ***************************************************************************************************
3163 * AddrLib1::AdjustPitchAlignment
3166 * Adjusts pitch alignment for flipping surface
3171 ***************************************************************************************************
3173 VOID
AddrLib1::AdjustPitchAlignment(
3174 ADDR_SURFACE_FLAGS flags
, ///< [in] Surface flags
3175 UINT_32
* pPitchAlign
///< [out] Pointer to pitch alignment
3178 // Display engine hardwires lower 5 bit of GRPH_PITCH to ZERO which means 32 pixel alignment
3179 // Maybe it will be fixed in future but let's make it general for now.
3180 if (flags
.display
|| flags
.overlay
)
3182 *pPitchAlign
= PowTwoAlign(*pPitchAlign
, 32);
3186 *pPitchAlign
= Max(m_minPitchAlignPixels
, *pPitchAlign
);
3192 ***************************************************************************************************
3193 * AddrLib1::PadDimensions
3196 * Helper function to pad dimensions
3201 ***************************************************************************************************
3203 VOID
AddrLib1::PadDimensions(
3204 AddrTileMode tileMode
, ///< [in] tile mode
3205 UINT_32 bpp
, ///< [in] bits per pixel
3206 ADDR_SURFACE_FLAGS flags
, ///< [in] surface flags
3207 UINT_32 numSamples
, ///< [in] number of samples
3208 ADDR_TILEINFO
* pTileInfo
, ///< [in/out] bank structure.
3209 UINT_32 padDims
, ///< [in] Dimensions to pad valid value 1,2,3
3210 UINT_32 mipLevel
, ///< [in] MipLevel
3211 UINT_32
* pPitch
, ///< [in/out] pitch in pixels
3212 UINT_32 pitchAlign
, ///< [in] pitch alignment
3213 UINT_32
* pHeight
, ///< [in/out] height in pixels
3214 UINT_32 heightAlign
, ///< [in] height alignment
3215 UINT_32
* pSlices
, ///< [in/out] number of slices
3216 UINT_32 sliceAlign
///< [in] number of slice alignment
3219 UINT_32 thickness
= Thickness(tileMode
);
3221 ADDR_ASSERT(padDims
<= 3);
3224 // Override padding for mip levels
3230 // for cubemap, we only pad when client call with 6 faces as an identity
3233 padDims
= 3; // we should pad cubemap sub levels when we treat it as 3d texture
3242 // Any possibilities that padDims is 0?
3248 if (IsPow2(pitchAlign
))
3250 *pPitch
= PowTwoAlign((*pPitch
), pitchAlign
);
3252 else // add this code to pass unit test, r600 linear mode is not align bpp to pow2 for linear
3254 *pPitch
+= pitchAlign
- 1;
3255 *pPitch
/= pitchAlign
;
3256 *pPitch
*= pitchAlign
;
3261 *pHeight
= PowTwoAlign((*pHeight
), heightAlign
);
3264 if (padDims
> 2 || thickness
> 1)
3266 // for cubemap single face, we do not pad slices.
3267 // if we pad it, the slice number should be set to 6 and current mip level > 1
3268 if (flags
.cube
&& (!m_configFlags
.noCubeMipSlicesPad
|| flags
.cubeAsArray
))
3270 *pSlices
= NextPow2(*pSlices
);
3273 // normal 3D texture or arrays or cubemap has a thick mode? (Just pass unit test)
3276 *pSlices
= PowTwoAlign((*pSlices
), sliceAlign
);
3281 HwlPadDimensions(tileMode
,
3298 ***************************************************************************************************
3299 * AddrLib1::HwlPreHandleBaseLvl3xPitch
3302 * Pre-handler of 3x pitch (96 bit) adjustment
3306 ***************************************************************************************************
3308 UINT_32
AddrLib1::HwlPreHandleBaseLvl3xPitch(
3309 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] input
3310 UINT_32 expPitch
///< [in] pitch
3313 ADDR_ASSERT(pIn
->width
== expPitch
);
3315 // If pitch is pre-multiplied by 3, we retrieve original one here to get correct miplevel size
3317 if (AddrElemLib::IsExpand3x(pIn
->format
) &&
3318 pIn
->mipLevel
== 0 &&
3319 pIn
->tileMode
== ADDR_TM_LINEAR_ALIGNED
)
3322 expPitch
= NextPow2(expPitch
);
3329 ***************************************************************************************************
3330 * AddrLib1::HwlPostHandleBaseLvl3xPitch
3333 * Post-handler of 3x pitch adjustment
3337 ***************************************************************************************************
3339 UINT_32
AddrLib1::HwlPostHandleBaseLvl3xPitch(
3340 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] input
3341 UINT_32 expPitch
///< [in] pitch
3345 // 96 bits surface of sub levels require element pitch of 32 bits instead
3346 // So we just return pitch in 32 bit pixels without timing 3
3348 if (AddrElemLib::IsExpand3x(pIn
->format
) &&
3349 pIn
->mipLevel
== 0 &&
3350 pIn
->tileMode
== ADDR_TM_LINEAR_ALIGNED
)
3360 ***************************************************************************************************
3361 * AddrLib1::IsMacroTiled
3364 * Check if the tile mode is macro tiled
3367 * TRUE if it is macro tiled (2D/2B/3D/3B)
3368 ***************************************************************************************************
3370 BOOL_32
AddrLib1::IsMacroTiled(
3371 AddrTileMode tileMode
) ///< [in] tile mode
3373 return m_modeFlags
[tileMode
].isMacro
;
3377 ***************************************************************************************************
3378 * AddrLib1::IsMacro3dTiled
3381 * Check if the tile mode is 3D macro tiled
3384 * TRUE if it is 3D macro tiled
3385 ***************************************************************************************************
3387 BOOL_32
AddrLib1::IsMacro3dTiled(
3388 AddrTileMode tileMode
) ///< [in] tile mode
3390 return m_modeFlags
[tileMode
].isMacro3d
;
3394 ***************************************************************************************************
3395 * AddrLib1::IsMicroTiled
3398 * Check if the tile mode is micro tiled
3401 * TRUE if micro tiled
3402 ***************************************************************************************************
3404 BOOL_32
AddrLib1::IsMicroTiled(
3405 AddrTileMode tileMode
) ///< [in] tile mode
3407 return m_modeFlags
[tileMode
].isMicro
;
3411 ***************************************************************************************************
3412 * AddrLib1::IsLinear
3415 * Check if the tile mode is linear
3419 ***************************************************************************************************
3421 BOOL_32
AddrLib1::IsLinear(
3422 AddrTileMode tileMode
) ///< [in] tile mode
3424 return m_modeFlags
[tileMode
].isLinear
;
3428 ***************************************************************************************************
3429 * AddrLib1::IsPrtNoRotationTileMode
3432 * Return TRUE if it is prt tile without rotation
3434 * This function just used by CI
3435 ***************************************************************************************************
3437 BOOL_32
AddrLib1::IsPrtNoRotationTileMode(
3438 AddrTileMode tileMode
)
3440 return m_modeFlags
[tileMode
].isPrtNoRotation
;
3444 ***************************************************************************************************
3445 * AddrLib1::IsPrtTileMode
3448 * Return TRUE if it is prt tile
3450 * This function just used by CI
3451 ***************************************************************************************************
3453 BOOL_32
AddrLib1::IsPrtTileMode(
3454 AddrTileMode tileMode
)
3456 return m_modeFlags
[tileMode
].isPrt
;
3460 ***************************************************************************************************
3461 * AddrLib1::ComputeMipLevel
3464 * Compute mipmap level width/height/slices
3467 ***************************************************************************************************
3469 VOID
AddrLib1::ComputeMipLevel(
3470 ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
///< [in/out] Input structure
3473 if (AddrElemLib::IsBlockCompressed(pIn
->format
))
3475 if (pIn
->mipLevel
== 0)
3477 // DXTn's level 0 must be multiple of 4
3478 // But there are exceptions:
3479 // 1. Internal surface creation in hostblt/vsblt/etc...
3480 // 2. Runtime doesn't reject ATI1/ATI2 whose width/height are not multiple of 4
3481 pIn
->width
= PowTwoAlign(pIn
->width
, 4);
3482 pIn
->height
= PowTwoAlign(pIn
->height
, 4);
3486 HwlComputeMipLevel(pIn
);
3490 ***************************************************************************************************
3491 * AddrLib1::OptimizeTileMode
3494 * Check if base level's tile mode can be optimized (degraded)
3496 * TRUE if degraded, also returns degraded tile mode (unchanged if not degraded)
3497 ***************************************************************************************************
3499 BOOL_32
AddrLib1::OptimizeTileMode(
3500 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] Input structure for surface info
3501 AddrTileMode
* pTileMode
///< [out] Degraded tile mode
3504 AddrTileMode tileMode
= pIn
->tileMode
;
3505 UINT_32 thickness
= Thickness(tileMode
);
3507 // Optimization can only be done on level 0 and samples <= 1
3508 if ((pIn
->flags
.opt4Space
== TRUE
) &&
3509 (pIn
->mipLevel
== 0) &&
3510 (pIn
->numSamples
<= 1) &&
3511 (pIn
->flags
.display
== FALSE
) &&
3512 (IsPrtTileMode(tileMode
) == FALSE
) &&
3513 (pIn
->flags
.prt
== FALSE
))
3515 // Check if linear mode is optimal
3516 if ((pIn
->height
== 1) &&
3517 (IsLinear(tileMode
) == FALSE
) &&
3518 (AddrElemLib::IsBlockCompressed(pIn
->format
) == FALSE
) &&
3519 (pIn
->flags
.depth
== FALSE
) &&
3520 (pIn
->flags
.stencil
== FALSE
) &&
3521 (m_configFlags
.disableLinearOpt
== FALSE
) &&
3522 (pIn
->flags
.disableLinearOpt
== FALSE
))
3524 tileMode
= ADDR_TM_LINEAR_ALIGNED
;
3526 else if (IsMacroTiled(tileMode
))
3528 if (HwlDegradeBaseLevel(pIn
))
3530 tileMode
= (thickness
== 1) ? ADDR_TM_1D_TILED_THIN1
: ADDR_TM_1D_TILED_THICK
;
3532 else if (thickness
> 1)
3534 // As in the following HwlComputeSurfaceInfo, thick modes may be degraded to
3535 // thinner modes, we should re-evaluate whether the corresponding thinner modes
3536 // need to be degraded. If so, we choose 1D thick mode instead.
3537 tileMode
= DegradeLargeThickTile(pIn
->tileMode
, pIn
->bpp
);
3538 if (tileMode
!= pIn
->tileMode
)
3540 ADDR_COMPUTE_SURFACE_INFO_INPUT input
= *pIn
;
3541 input
.tileMode
= tileMode
;
3542 if (HwlDegradeBaseLevel(&input
))
3544 tileMode
= ADDR_TM_1D_TILED_THICK
;
3551 BOOL_32 optimized
= (tileMode
!= pIn
->tileMode
);
3554 *pTileMode
= tileMode
;
3560 ***************************************************************************************************
3561 * AddrLib1::DegradeLargeThickTile
3564 * Check if the thickness needs to be reduced if a tile is too large
3566 * The degraded tile mode (unchanged if not degraded)
3567 ***************************************************************************************************
3569 AddrTileMode
AddrLib1::DegradeLargeThickTile(
3570 AddrTileMode tileMode
,
3573 // Override tilemode
3574 // When tile_width (8) * tile_height (8) * thickness * element_bytes is > row_size,
3575 // it is better to just use THIN mode in this case
3576 UINT_32 thickness
= Thickness(tileMode
);
3578 if (thickness
> 1 && m_configFlags
.allowLargeThickTile
== 0)
3580 UINT_32 tileSize
= MicroTilePixels
* thickness
* (bpp
>> 3);
3582 if (tileSize
> m_rowSize
)
3586 case ADDR_TM_2D_TILED_XTHICK
:
3587 if ((tileSize
>> 1) <= m_rowSize
)
3589 tileMode
= ADDR_TM_2D_TILED_THICK
;
3592 // else fall through
3593 case ADDR_TM_2D_TILED_THICK
:
3594 tileMode
= ADDR_TM_2D_TILED_THIN1
;
3597 case ADDR_TM_3D_TILED_XTHICK
:
3598 if ((tileSize
>> 1) <= m_rowSize
)
3600 tileMode
= ADDR_TM_3D_TILED_THICK
;
3603 // else fall through
3604 case ADDR_TM_3D_TILED_THICK
:
3605 tileMode
= ADDR_TM_3D_TILED_THIN1
;
3608 case ADDR_TM_PRT_TILED_THICK
:
3609 tileMode
= ADDR_TM_PRT_TILED_THIN1
;
3612 case ADDR_TM_PRT_2D_TILED_THICK
:
3613 tileMode
= ADDR_TM_PRT_2D_TILED_THIN1
;
3616 case ADDR_TM_PRT_3D_TILED_THICK
:
3617 tileMode
= ADDR_TM_PRT_3D_TILED_THIN1
;
3630 ***************************************************************************************************
3631 * AddrLib1::PostComputeMipLevel
3633 * Compute MipLevel info (including level 0) after surface adjustment
3636 ***************************************************************************************************
3638 ADDR_E_RETURNCODE
AddrLib1::PostComputeMipLevel(
3639 ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in/out] Input structure
3640 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
///< [out] Output structure
3643 // Mipmap including level 0 must be pow2 padded since either SI hw expects so or it is
3644 // required by CFX for Hw Compatibility between NI and SI. Otherwise it is only needed for
3645 // mipLevel > 0. Any h/w has different requirement should implement its own virtual function
3647 if (pIn
->flags
.pow2Pad
)
3649 pIn
->width
= NextPow2(pIn
->width
);
3650 pIn
->height
= NextPow2(pIn
->height
);
3651 pIn
->numSlices
= NextPow2(pIn
->numSlices
);
3653 else if (pIn
->mipLevel
> 0)
3655 pIn
->width
= NextPow2(pIn
->width
);
3656 pIn
->height
= NextPow2(pIn
->height
);
3658 if (!pIn
->flags
.cube
)
3660 pIn
->numSlices
= NextPow2(pIn
->numSlices
);
3663 // for cubemap, we keep its value at first
3670 ***************************************************************************************************
3671 * AddrLib1::HwlSetupTileCfg
3674 * Map tile index to tile setting.
3677 ***************************************************************************************************
3679 ADDR_E_RETURNCODE
AddrLib1::HwlSetupTileCfg(
3680 UINT_32 bpp
, ///< Bits per pixel
3681 INT_32 index
, ///< [in] Tile index
3682 INT_32 macroModeIndex
, ///< [in] Index in macro tile mode table(CI)
3683 ADDR_TILEINFO
* pInfo
, ///< [out] Tile Info
3684 AddrTileMode
* pMode
, ///< [out] Tile mode
3685 AddrTileType
* pType
///< [out] Tile type
3688 return ADDR_NOTSUPPORTED
;
3692 ***************************************************************************************************
3693 * AddrLib1::HwlGetPipes
3699 ***************************************************************************************************
3701 UINT_32
AddrLib1::HwlGetPipes(
3702 const ADDR_TILEINFO
* pTileInfo
///< [in] Tile info
3705 //pTileInfo can be NULL when asic is 6xx and 8xx.
3710 ***************************************************************************************************
3711 * AddrLib1::ComputeQbStereoInfo
3714 * Get quad buffer stereo information
3717 ***************************************************************************************************
3719 BOOL_32
AddrLib1::ComputeQbStereoInfo(
3720 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
///< [in/out] updated pOut+pStereoInfo
3723 BOOL_32 success
= FALSE
;
3725 if (pOut
->pStereoInfo
)
3727 ADDR_ASSERT(pOut
->bpp
>= 8);
3728 ADDR_ASSERT((pOut
->surfSize
% pOut
->baseAlign
) == 0);
3730 // Save original height
3731 pOut
->pStereoInfo
->eyeHeight
= pOut
->height
;
3734 pOut
->pStereoInfo
->rightOffset
= static_cast<UINT_32
>(pOut
->surfSize
);
3736 pOut
->pStereoInfo
->rightSwizzle
= HwlComputeQbStereoRightSwizzle(pOut
);
3739 pOut
->pixelHeight
<<= 1;
3742 pOut
->surfSize
<<= 1;
3744 // Right start address meets the base align since it is guaranteed by AddrLib1
3746 // 1D surface on SI may break this rule, but we can force it to meet by checking .qbStereo.
3755 ***************************************************************************************************
3756 * AddrLib1::ComputePrtInfo
3759 * Compute prt surface related info
3763 ***************************************************************************************************
3765 ADDR_E_RETURNCODE
AddrLib1::ComputePrtInfo(
3766 const ADDR_PRT_INFO_INPUT
* pIn
,
3767 ADDR_PRT_INFO_OUTPUT
* pOut
) const
3769 ADDR_ASSERT(pOut
!= NULL
);
3771 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
3773 UINT_32 expandX
= 1;
3774 UINT_32 expandY
= 1;
3775 AddrElemMode elemMode
;
3777 UINT_32 bpp
= GetElemLib()->GetBitsPerPixel(pIn
->format
,
3782 if (bpp
<8 || bpp
== 24 || bpp
== 48 || bpp
== 96)
3784 returnCode
= ADDR_INVALIDPARAMS
;
3787 UINT_32 numFrags
= pIn
->numFrags
;
3788 ADDR_ASSERT(numFrags
<= 8);
3790 UINT_32 tileWidth
= 0;
3791 UINT_32 tileHeight
= 0;
3792 if (returnCode
== ADDR_OK
)
3794 // 3D texture without depth or 2d texture
3795 if (pIn
->baseMipDepth
> 1 || pIn
->baseMipHeight
> 1)
3814 // assume it is BC1/4
3818 if (elemMode
== ADDR_UNCOMPRESSED
)
3824 else if (bpp
== 128)
3826 // assume it is BC2/3/5/6H/7
3830 if (elemMode
== ADDR_UNCOMPRESSED
)
3839 tileWidth
= tileWidth
/ 2;
3841 else if (numFrags
== 4)
3843 tileWidth
= tileWidth
/ 2;
3844 tileHeight
= tileHeight
/ 2;
3846 else if (numFrags
== 8)
3848 tileWidth
= tileWidth
/ 4;
3849 tileHeight
= tileHeight
/ 2;
3871 else if (bpp
== 128)
3878 pOut
->prtTileWidth
= tileWidth
;
3879 pOut
->prtTileHeight
= tileHeight
;