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 (ComputeSurfaceThickness(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 AddrTileMode tileMode
= localIn
.tileMode
;
328 AddrTileType tileType
= localIn
.tileType
;
330 // HWL layer may override tile mode if necessary
331 if (HwlOverrideTileMode(&localIn
, &tileMode
, &tileType
))
333 localIn
.tileMode
= tileMode
;
334 localIn
.tileType
= tileType
;
336 // Optimize tile mode if possible
337 if (OptimizeTileMode(&localIn
, &tileMode
))
339 localIn
.tileMode
= tileMode
;
343 // Call main function to compute surface info
344 if (returnCode
== ADDR_OK
)
346 returnCode
= HwlComputeSurfaceInfo(&localIn
, pOut
);
349 if (returnCode
== ADDR_OK
)
351 // Since bpp might be changed we just pass it through
352 pOut
->bpp
= localIn
.bpp
;
354 // Also original width/height/bpp
355 pOut
->pixelPitch
= pOut
->pitch
;
356 pOut
->pixelHeight
= pOut
->height
;
359 if (localIn
.flags
.display
)
361 ADDR_ASSERT((pOut
->pitchAlign
% 32) == 0);
365 if (localIn
.format
!= ADDR_FMT_INVALID
)
368 // 96 bits surface of level 1+ requires element pitch of 32 bits instead
369 // In hwl function we skip multiplication of 3 then we should skip division of 3
370 // We keep pitch that represents 32 bit element instead of 96 bits since we
371 // will get an odd number if divided by 3.
373 if (!((expandX
== 3) && (localIn
.mipLevel
> 0)))
376 GetElemLib()->RestoreSurfaceInfo(elemMode
,
385 if (localIn
.flags
.qbStereo
)
387 if (pOut
->pStereoInfo
)
389 ComputeQbStereoInfo(pOut
);
393 if (localIn
.flags
.volume
) // For volume sliceSize equals to all z-slices
395 pOut
->sliceSize
= pOut
->surfSize
;
397 else // For array: sliceSize is likely to have slice-padding (the last one)
399 pOut
->sliceSize
= pOut
->surfSize
/ pOut
->depth
;
402 if (pIn
->numSlices
> 1)
404 // If this is the last slice then add the padding size to this slice
405 if (pIn
->slice
== (pIn
->numSlices
- 1))
407 pOut
->sliceSize
+= pOut
->sliceSize
* (pOut
->depth
- pIn
->numSlices
);
409 else if (m_configFlags
.checkLast2DLevel
)
411 // Reset last2DLevel flag if this is not the last array slice
412 pOut
->last2DLevel
= FALSE
;
417 pOut
->pitchTileMax
= pOut
->pitch
/ 8 - 1;
418 pOut
->heightTileMax
= pOut
->height
/ 8 - 1;
419 pOut
->sliceTileMax
= pOut
->pitch
* pOut
->height
/ 64 - 1;
427 ***************************************************************************************************
428 * AddrLib1::ComputeSurfaceInfo
431 * Interface function stub of AddrComputeSurfaceInfo.
435 ***************************************************************************************************
437 ADDR_E_RETURNCODE
AddrLib1::ComputeSurfaceAddrFromCoord(
438 const ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
439 ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
442 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
444 if (GetFillSizeFieldsFlags() == TRUE
)
446 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT
)) ||
447 (pOut
->size
!= sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT
)))
449 returnCode
= ADDR_PARAMSIZEMISMATCH
;
453 if (returnCode
== ADDR_OK
)
455 ADDR_TILEINFO tileInfoNull
;
456 ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT input
;
458 if (UseTileIndex(pIn
->tileIndex
))
461 // Use temp tile info for calcalation
462 input
.pTileInfo
= &tileInfoNull
;
464 const ADDR_SURFACE_FLAGS flags
= {{0}};
465 UINT_32 numSamples
= GetNumFragments(pIn
->numSamples
, pIn
->numFrags
);
467 // Try finding a macroModeIndex
468 INT_32 macroModeIndex
= HwlComputeMacroModeIndex(input
.tileIndex
,
476 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
477 if (macroModeIndex
== TileIndexNoMacroIndex
)
479 returnCode
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
, macroModeIndex
,
480 input
.pTileInfo
, &input
.tileMode
, &input
.tileType
);
482 // If macroModeIndex is invalid, then assert this is not macro tiled
483 else if (macroModeIndex
== TileIndexInvalid
)
485 ADDR_ASSERT(!IsMacroTiled(input
.tileMode
));
488 // Change the input structure
492 if (returnCode
== ADDR_OK
)
494 returnCode
= HwlComputeSurfaceAddrFromCoord(pIn
, pOut
);
496 if (returnCode
== ADDR_OK
)
498 pOut
->prtBlockIndex
= static_cast<UINT_32
>(pOut
->addr
/ (64 * 1024));
507 ***************************************************************************************************
508 * AddrLib1::ComputeSurfaceCoordFromAddr
511 * Interface function stub of ComputeSurfaceCoordFromAddr.
515 ***************************************************************************************************
517 ADDR_E_RETURNCODE
AddrLib1::ComputeSurfaceCoordFromAddr(
518 const ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
519 ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
522 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
524 if (GetFillSizeFieldsFlags() == TRUE
)
526 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT
)) ||
527 (pOut
->size
!= sizeof(ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT
)))
529 returnCode
= ADDR_PARAMSIZEMISMATCH
;
533 if (returnCode
== ADDR_OK
)
535 ADDR_TILEINFO tileInfoNull
;
536 ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT input
;
538 if (UseTileIndex(pIn
->tileIndex
))
541 // Use temp tile info for calcalation
542 input
.pTileInfo
= &tileInfoNull
;
544 const ADDR_SURFACE_FLAGS flags
= {{0}};
545 UINT_32 numSamples
= GetNumFragments(pIn
->numSamples
, pIn
->numFrags
);
547 // Try finding a macroModeIndex
548 INT_32 macroModeIndex
= HwlComputeMacroModeIndex(input
.tileIndex
,
556 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
557 if (macroModeIndex
== TileIndexNoMacroIndex
)
559 returnCode
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
, macroModeIndex
,
560 input
.pTileInfo
, &input
.tileMode
, &input
.tileType
);
562 // If macroModeIndex is invalid, then assert this is not macro tiled
563 else if (macroModeIndex
== TileIndexInvalid
)
565 ADDR_ASSERT(!IsMacroTiled(input
.tileMode
));
568 // Change the input structure
572 if (returnCode
== ADDR_OK
)
574 returnCode
= HwlComputeSurfaceCoordFromAddr(pIn
, pOut
);
582 ***************************************************************************************************
583 * AddrLib1::ComputeSliceTileSwizzle
586 * Interface function stub of ComputeSliceTileSwizzle.
590 ***************************************************************************************************
592 ADDR_E_RETURNCODE
AddrLib1::ComputeSliceTileSwizzle(
593 const ADDR_COMPUTE_SLICESWIZZLE_INPUT
* pIn
, ///< [in] input structure
594 ADDR_COMPUTE_SLICESWIZZLE_OUTPUT
* pOut
///< [out] output structure
597 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
599 if (GetFillSizeFieldsFlags() == TRUE
)
601 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_SLICESWIZZLE_INPUT
)) ||
602 (pOut
->size
!= sizeof(ADDR_COMPUTE_SLICESWIZZLE_OUTPUT
)))
604 returnCode
= ADDR_PARAMSIZEMISMATCH
;
608 if (returnCode
== ADDR_OK
)
610 ADDR_TILEINFO tileInfoNull
;
611 ADDR_COMPUTE_SLICESWIZZLE_INPUT input
;
613 if (UseTileIndex(pIn
->tileIndex
))
616 // Use temp tile info for calcalation
617 input
.pTileInfo
= &tileInfoNull
;
619 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
,
620 input
.pTileInfo
, &input
.tileMode
);
621 // Change the input structure
625 if (returnCode
== ADDR_OK
)
627 returnCode
= HwlComputeSliceTileSwizzle(pIn
, pOut
);
635 ***************************************************************************************************
636 * AddrLib1::ExtractBankPipeSwizzle
639 * Interface function stub of AddrExtractBankPipeSwizzle.
643 ***************************************************************************************************
645 ADDR_E_RETURNCODE
AddrLib1::ExtractBankPipeSwizzle(
646 const ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT
* pIn
, ///< [in] input structure
647 ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT
* pOut
///< [out] output structure
650 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
652 if (GetFillSizeFieldsFlags() == TRUE
)
654 if ((pIn
->size
!= sizeof(ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT
)) ||
655 (pOut
->size
!= sizeof(ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT
)))
657 returnCode
= ADDR_PARAMSIZEMISMATCH
;
661 if (returnCode
== ADDR_OK
)
663 ADDR_TILEINFO tileInfoNull
;
664 ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT input
;
666 if (UseTileIndex(pIn
->tileIndex
))
669 // Use temp tile info for calcalation
670 input
.pTileInfo
= &tileInfoNull
;
672 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
673 // Change the input structure
677 if (returnCode
== ADDR_OK
)
679 returnCode
= HwlExtractBankPipeSwizzle(pIn
, pOut
);
687 ***************************************************************************************************
688 * AddrLib1::CombineBankPipeSwizzle
691 * Interface function stub of AddrCombineBankPipeSwizzle.
695 ***************************************************************************************************
697 ADDR_E_RETURNCODE
AddrLib1::CombineBankPipeSwizzle(
698 const ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT
* pIn
, ///< [in] input structure
699 ADDR_COMBINE_BANKPIPE_SWIZZLE_OUTPUT
* pOut
///< [out] output structure
702 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
704 if (GetFillSizeFieldsFlags() == TRUE
)
706 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_INPUT
)) ||
707 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT
)))
709 returnCode
= ADDR_PARAMSIZEMISMATCH
;
713 if (returnCode
== ADDR_OK
)
715 ADDR_TILEINFO tileInfoNull
;
716 ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT input
;
718 if (UseTileIndex(pIn
->tileIndex
))
721 // Use temp tile info for calcalation
722 input
.pTileInfo
= &tileInfoNull
;
724 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
725 // Change the input structure
729 if (returnCode
== ADDR_OK
)
731 returnCode
= HwlCombineBankPipeSwizzle(pIn
->bankSwizzle
,
743 ***************************************************************************************************
744 * AddrLib1::ComputeBaseSwizzle
747 * Interface function stub of AddrCompueBaseSwizzle.
750 ***************************************************************************************************
752 ADDR_E_RETURNCODE
AddrLib1::ComputeBaseSwizzle(
753 const ADDR_COMPUTE_BASE_SWIZZLE_INPUT
* pIn
,
754 ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT
* pOut
) const
756 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
758 if (GetFillSizeFieldsFlags() == TRUE
)
760 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_INPUT
)) ||
761 (pOut
->size
!= sizeof(ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT
)))
763 returnCode
= ADDR_PARAMSIZEMISMATCH
;
767 if (returnCode
== ADDR_OK
)
769 ADDR_TILEINFO tileInfoNull
;
770 ADDR_COMPUTE_BASE_SWIZZLE_INPUT input
;
772 if (UseTileIndex(pIn
->tileIndex
))
775 // Use temp tile info for calcalation
776 input
.pTileInfo
= &tileInfoNull
;
778 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
779 // Change the input structure
783 if (returnCode
== ADDR_OK
)
785 if (IsMacroTiled(pIn
->tileMode
))
787 returnCode
= HwlComputeBaseSwizzle(pIn
, pOut
);
791 pOut
->tileSwizzle
= 0;
800 ***************************************************************************************************
801 * AddrLib1::ComputeFmaskInfo
804 * Interface function stub of ComputeFmaskInfo.
808 ***************************************************************************************************
810 ADDR_E_RETURNCODE
AddrLib1::ComputeFmaskInfo(
811 const ADDR_COMPUTE_FMASK_INFO_INPUT
* pIn
, ///< [in] input structure
812 ADDR_COMPUTE_FMASK_INFO_OUTPUT
* pOut
///< [out] output structure
815 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
817 if (GetFillSizeFieldsFlags() == TRUE
)
819 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_INPUT
)) ||
820 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT
)))
822 returnCode
= ADDR_PARAMSIZEMISMATCH
;
827 if (ComputeSurfaceThickness(pIn
->tileMode
) > 1)
829 returnCode
= ADDR_INVALIDPARAMS
;
832 if (returnCode
== ADDR_OK
)
834 ADDR_TILEINFO tileInfoNull
;
835 ADDR_COMPUTE_FMASK_INFO_INPUT input
;
837 if (UseTileIndex(pIn
->tileIndex
))
843 // Use temp tile info for calcalation
844 input
.pTileInfo
= pOut
->pTileInfo
;
848 input
.pTileInfo
= &tileInfoNull
;
851 ADDR_SURFACE_FLAGS flags
= {{0}};
854 // Try finding a macroModeIndex
855 INT_32 macroModeIndex
= HwlComputeMacroModeIndex(pIn
->tileIndex
,
857 HwlComputeFmaskBits(pIn
, NULL
),
862 // If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
863 if (macroModeIndex
== TileIndexNoMacroIndex
)
865 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, macroModeIndex
,
866 input
.pTileInfo
, &input
.tileMode
);
869 ADDR_ASSERT(macroModeIndex
!= TileIndexInvalid
);
871 // Change the input structure
875 if (returnCode
== ADDR_OK
)
877 if (pIn
->numSamples
> 1)
879 returnCode
= HwlComputeFmaskInfo(pIn
, pOut
);
883 memset(pOut
, 0, sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT
));
885 returnCode
= ADDR_INVALIDPARAMS
;
894 ***************************************************************************************************
895 * AddrLib1::ComputeFmaskAddrFromCoord
898 * Interface function stub of ComputeFmaskAddrFromCoord.
902 ***************************************************************************************************
904 ADDR_E_RETURNCODE
AddrLib1::ComputeFmaskAddrFromCoord(
905 const ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
906 ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
909 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
911 if (GetFillSizeFieldsFlags() == TRUE
)
913 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT
)) ||
914 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT
)))
916 returnCode
= ADDR_PARAMSIZEMISMATCH
;
920 if (returnCode
== ADDR_OK
)
922 ADDR_ASSERT(pIn
->numSamples
> 1);
924 if (pIn
->numSamples
> 1)
926 returnCode
= HwlComputeFmaskAddrFromCoord(pIn
, pOut
);
930 returnCode
= ADDR_INVALIDPARAMS
;
938 ***************************************************************************************************
939 * AddrLib1::ComputeFmaskCoordFromAddr
942 * Interface function stub of ComputeFmaskAddrFromCoord.
946 ***************************************************************************************************
948 ADDR_E_RETURNCODE
AddrLib1::ComputeFmaskCoordFromAddr(
949 const ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
950 ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
953 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
955 if (GetFillSizeFieldsFlags() == TRUE
)
957 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT
)) ||
958 (pOut
->size
!= sizeof(ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT
)))
960 returnCode
= ADDR_PARAMSIZEMISMATCH
;
964 if (returnCode
== ADDR_OK
)
966 ADDR_ASSERT(pIn
->numSamples
> 1);
968 if (pIn
->numSamples
> 1)
970 returnCode
= HwlComputeFmaskCoordFromAddr(pIn
, pOut
);
974 returnCode
= ADDR_INVALIDPARAMS
;
982 ***************************************************************************************************
983 * AddrLib1::ConvertTileInfoToHW
986 * Convert tile info from real value to HW register value in HW layer
990 ***************************************************************************************************
992 ADDR_E_RETURNCODE
AddrLib1::ConvertTileInfoToHW(
993 const ADDR_CONVERT_TILEINFOTOHW_INPUT
* pIn
, ///< [in] input structure
994 ADDR_CONVERT_TILEINFOTOHW_OUTPUT
* pOut
///< [out] output structure
997 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
999 if (GetFillSizeFieldsFlags() == TRUE
)
1001 if ((pIn
->size
!= sizeof(ADDR_CONVERT_TILEINFOTOHW_INPUT
)) ||
1002 (pOut
->size
!= sizeof(ADDR_CONVERT_TILEINFOTOHW_OUTPUT
)))
1004 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1008 if (returnCode
== ADDR_OK
)
1010 ADDR_TILEINFO tileInfoNull
;
1011 ADDR_CONVERT_TILEINFOTOHW_INPUT input
;
1012 // if pIn->reverse is TRUE, indices are ignored
1013 if (pIn
->reverse
== FALSE
&& UseTileIndex(pIn
->tileIndex
))
1016 input
.pTileInfo
= &tileInfoNull
;
1018 returnCode
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
,
1019 input
.macroModeIndex
, input
.pTileInfo
);
1024 if (returnCode
== ADDR_OK
)
1026 returnCode
= HwlConvertTileInfoToHW(pIn
, pOut
);
1034 ***************************************************************************************************
1035 * AddrLib1::ConvertTileIndex
1038 * Convert tile index to tile mode/type/info
1042 ***************************************************************************************************
1044 ADDR_E_RETURNCODE
AddrLib1::ConvertTileIndex(
1045 const ADDR_CONVERT_TILEINDEX_INPUT
* pIn
, ///< [in] input structure
1046 ADDR_CONVERT_TILEINDEX_OUTPUT
* pOut
///< [out] output structure
1049 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1051 if (GetFillSizeFieldsFlags() == TRUE
)
1053 if ((pIn
->size
!= sizeof(ADDR_CONVERT_TILEINDEX_INPUT
)) ||
1054 (pOut
->size
!= sizeof(ADDR_CONVERT_TILEINDEX_OUTPUT
)))
1056 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1060 if (returnCode
== ADDR_OK
)
1063 returnCode
= HwlSetupTileCfg(pIn
->bpp
, pIn
->tileIndex
, pIn
->macroModeIndex
,
1064 pOut
->pTileInfo
, &pOut
->tileMode
, &pOut
->tileType
);
1066 if (returnCode
== ADDR_OK
&& pIn
->tileInfoHw
)
1068 ADDR_CONVERT_TILEINFOTOHW_INPUT hwInput
= {0};
1069 ADDR_CONVERT_TILEINFOTOHW_OUTPUT hwOutput
= {0};
1071 hwInput
.pTileInfo
= pOut
->pTileInfo
;
1072 hwInput
.tileIndex
= -1;
1073 hwOutput
.pTileInfo
= pOut
->pTileInfo
;
1075 returnCode
= HwlConvertTileInfoToHW(&hwInput
, &hwOutput
);
1083 ***************************************************************************************************
1084 * AddrLib1::GetMacroModeIndex
1087 * Get macro mode index based on input info
1091 ***************************************************************************************************
1093 ADDR_E_RETURNCODE
AddrLib1::GetMacroModeIndex(
1094 const ADDR_GET_MACROMODEINDEX_INPUT
* pIn
, ///< [in] input structure
1095 ADDR_GET_MACROMODEINDEX_OUTPUT
* pOut
///< [out] output structure
1098 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1100 if (GetFillSizeFieldsFlags())
1102 if ((pIn
->size
!= sizeof(ADDR_GET_MACROMODEINDEX_INPUT
)) ||
1103 (pOut
->size
!= sizeof(ADDR_GET_MACROMODEINDEX_OUTPUT
)))
1105 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1109 if (returnCode
== ADDR_OK
)
1111 ADDR_TILEINFO tileInfo
= {0};
1112 pOut
->macroModeIndex
= HwlComputeMacroModeIndex(pIn
->tileIndex
, pIn
->flags
, pIn
->bpp
,
1113 pIn
->numFrags
, &tileInfo
);
1120 ***************************************************************************************************
1121 * AddrLib1::ConvertTileIndex1
1124 * Convert tile index to tile mode/type/info
1128 ***************************************************************************************************
1130 ADDR_E_RETURNCODE
AddrLib1::ConvertTileIndex1(
1131 const ADDR_CONVERT_TILEINDEX1_INPUT
* pIn
, ///< [in] input structure
1132 ADDR_CONVERT_TILEINDEX_OUTPUT
* pOut
///< [out] output structure
1135 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1137 if (GetFillSizeFieldsFlags() == TRUE
)
1139 if ((pIn
->size
!= sizeof(ADDR_CONVERT_TILEINDEX1_INPUT
)) ||
1140 (pOut
->size
!= sizeof(ADDR_CONVERT_TILEINDEX_OUTPUT
)))
1142 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1146 if (returnCode
== ADDR_OK
)
1148 ADDR_SURFACE_FLAGS flags
= {{0}};
1150 HwlComputeMacroModeIndex(pIn
->tileIndex
, flags
, pIn
->bpp
, pIn
->numSamples
,
1151 pOut
->pTileInfo
, &pOut
->tileMode
, &pOut
->tileType
);
1153 if (pIn
->tileInfoHw
)
1155 ADDR_CONVERT_TILEINFOTOHW_INPUT hwInput
= {0};
1156 ADDR_CONVERT_TILEINFOTOHW_OUTPUT hwOutput
= {0};
1158 hwInput
.pTileInfo
= pOut
->pTileInfo
;
1159 hwInput
.tileIndex
= -1;
1160 hwOutput
.pTileInfo
= pOut
->pTileInfo
;
1162 returnCode
= HwlConvertTileInfoToHW(&hwInput
, &hwOutput
);
1170 ***************************************************************************************************
1171 * AddrLib1::GetTileIndex
1174 * Get tile index from tile mode/type/info
1178 ***************************************************************************************************
1180 ADDR_E_RETURNCODE
AddrLib1::GetTileIndex(
1181 const ADDR_GET_TILEINDEX_INPUT
* pIn
, ///< [in] input structure
1182 ADDR_GET_TILEINDEX_OUTPUT
* pOut
///< [out] output structure
1185 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1187 if (GetFillSizeFieldsFlags() == TRUE
)
1189 if ((pIn
->size
!= sizeof(ADDR_GET_TILEINDEX_INPUT
)) ||
1190 (pOut
->size
!= sizeof(ADDR_GET_TILEINDEX_OUTPUT
)))
1192 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1196 if (returnCode
== ADDR_OK
)
1198 returnCode
= HwlGetTileIndex(pIn
, pOut
);
1205 ***************************************************************************************************
1206 * AddrLib1::ComputeSurfaceThickness
1209 * Compute surface thickness
1213 ***************************************************************************************************
1215 UINT_32
AddrLib1::ComputeSurfaceThickness(
1216 AddrTileMode tileMode
) ///< [in] tile mode
1218 return m_modeFlags
[tileMode
].thickness
;
1223 ///////////////////////////////////////////////////////////////////////////////////////////////////
1225 ///////////////////////////////////////////////////////////////////////////////////////////////////
1228 ***************************************************************************************************
1229 * AddrLib1::ComputeHtileInfo
1232 * Interface function stub of AddrComputeHtilenfo
1236 ***************************************************************************************************
1238 ADDR_E_RETURNCODE
AddrLib1::ComputeHtileInfo(
1239 const ADDR_COMPUTE_HTILE_INFO_INPUT
* pIn
, ///< [in] input structure
1240 ADDR_COMPUTE_HTILE_INFO_OUTPUT
* pOut
///< [out] output structure
1243 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1245 BOOL_32 isWidth8
= (pIn
->blockWidth
== 8) ? TRUE
: FALSE
;
1246 BOOL_32 isHeight8
= (pIn
->blockHeight
== 8) ? TRUE
: FALSE
;
1248 if (GetFillSizeFieldsFlags() == TRUE
)
1250 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_HTILE_INFO_INPUT
)) ||
1251 (pOut
->size
!= sizeof(ADDR_COMPUTE_HTILE_INFO_OUTPUT
)))
1253 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1257 if (returnCode
== ADDR_OK
)
1259 ADDR_TILEINFO tileInfoNull
;
1260 ADDR_COMPUTE_HTILE_INFO_INPUT input
;
1262 if (UseTileIndex(pIn
->tileIndex
))
1265 // Use temp tile info for calcalation
1266 input
.pTileInfo
= &tileInfoNull
;
1268 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1270 // Change the input structure
1274 if (returnCode
== ADDR_OK
)
1276 pOut
->bpp
= ComputeHtileInfo(pIn
->flags
,
1298 ***************************************************************************************************
1299 * AddrLib1::ComputeCmaskInfo
1302 * Interface function stub of AddrComputeCmaskInfo
1306 ***************************************************************************************************
1308 ADDR_E_RETURNCODE
AddrLib1::ComputeCmaskInfo(
1309 const ADDR_COMPUTE_CMASK_INFO_INPUT
* pIn
, ///< [in] input structure
1310 ADDR_COMPUTE_CMASK_INFO_OUTPUT
* pOut
///< [out] output structure
1313 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1315 if (GetFillSizeFieldsFlags() == TRUE
)
1317 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_CMASK_INFO_INPUT
)) ||
1318 (pOut
->size
!= sizeof(ADDR_COMPUTE_CMASK_INFO_OUTPUT
)))
1320 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1324 if (returnCode
== ADDR_OK
)
1326 ADDR_TILEINFO tileInfoNull
;
1327 ADDR_COMPUTE_CMASK_INFO_INPUT input
;
1329 if (UseTileIndex(pIn
->tileIndex
))
1332 // Use temp tile info for calcalation
1333 input
.pTileInfo
= &tileInfoNull
;
1335 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1337 // Change the input structure
1341 if (returnCode
== ADDR_OK
)
1343 returnCode
= ComputeCmaskInfo(pIn
->flags
,
1364 ***************************************************************************************************
1365 * AddrLib1::ComputeDccInfo
1368 * Interface function to compute DCC key info
1371 * return code of HwlComputeDccInfo
1372 ***************************************************************************************************
1374 ADDR_E_RETURNCODE
AddrLib1::ComputeDccInfo(
1375 const ADDR_COMPUTE_DCCINFO_INPUT
* pIn
, ///< [in] input structure
1376 ADDR_COMPUTE_DCCINFO_OUTPUT
* pOut
///< [out] output structure
1379 ADDR_E_RETURNCODE ret
= ADDR_OK
;
1381 if (GetFillSizeFieldsFlags() == TRUE
)
1383 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_DCCINFO_INPUT
)) ||
1384 (pOut
->size
!= sizeof(ADDR_COMPUTE_DCCINFO_OUTPUT
)))
1386 ret
= ADDR_PARAMSIZEMISMATCH
;
1392 ADDR_COMPUTE_DCCINFO_INPUT input
;
1394 if (UseTileIndex(pIn
->tileIndex
))
1398 ret
= HwlSetupTileCfg(input
.bpp
, input
.tileIndex
, input
.macroModeIndex
,
1399 &input
.tileInfo
, &input
.tileMode
);
1406 ret
= HwlComputeDccInfo(pIn
, pOut
);
1414 ***************************************************************************************************
1415 * AddrLib1::ComputeHtileAddrFromCoord
1418 * Interface function stub of AddrComputeHtileAddrFromCoord
1422 ***************************************************************************************************
1424 ADDR_E_RETURNCODE
AddrLib1::ComputeHtileAddrFromCoord(
1425 const ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
1426 ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
1429 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1431 BOOL_32 isWidth8
= (pIn
->blockWidth
== 8) ? TRUE
: FALSE
;
1432 BOOL_32 isHeight8
= (pIn
->blockHeight
== 8) ? TRUE
: FALSE
;
1434 if (GetFillSizeFieldsFlags() == TRUE
)
1436 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT
)) ||
1437 (pOut
->size
!= sizeof(ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT
)))
1439 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1443 if (returnCode
== ADDR_OK
)
1445 ADDR_TILEINFO tileInfoNull
;
1446 ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT input
;
1448 if (UseTileIndex(pIn
->tileIndex
))
1451 // Use temp tile info for calcalation
1452 input
.pTileInfo
= &tileInfoNull
;
1454 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1456 // Change the input structure
1460 if (returnCode
== ADDR_OK
)
1462 if (pIn
->flags
.tcCompatible
)
1464 HwlComputeHtileAddrFromCoord(pIn
, pOut
);
1468 pOut
->addr
= HwlComputeXmaskAddrFromCoord(pIn
->pitch
,
1479 &pOut
->bitPosition
);
1489 ***************************************************************************************************
1490 * AddrLib1::ComputeHtileCoordFromAddr
1493 * Interface function stub of AddrComputeHtileCoordFromAddr
1497 ***************************************************************************************************
1499 ADDR_E_RETURNCODE
AddrLib1::ComputeHtileCoordFromAddr(
1500 const ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
1501 ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
1504 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1506 BOOL_32 isWidth8
= (pIn
->blockWidth
== 8) ? TRUE
: FALSE
;
1507 BOOL_32 isHeight8
= (pIn
->blockHeight
== 8) ? TRUE
: FALSE
;
1509 if (GetFillSizeFieldsFlags() == TRUE
)
1511 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT
)) ||
1512 (pOut
->size
!= sizeof(ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT
)))
1514 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1518 if (returnCode
== ADDR_OK
)
1520 ADDR_TILEINFO tileInfoNull
;
1521 ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT input
;
1523 if (UseTileIndex(pIn
->tileIndex
))
1526 // Use temp tile info for calcalation
1527 input
.pTileInfo
= &tileInfoNull
;
1529 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1531 // Change the input structure
1535 if (returnCode
== ADDR_OK
)
1537 HwlComputeXmaskCoordFromAddr(pIn
->addr
,
1557 ***************************************************************************************************
1558 * AddrLib1::ComputeCmaskAddrFromCoord
1561 * Interface function stub of AddrComputeCmaskAddrFromCoord
1565 ***************************************************************************************************
1567 ADDR_E_RETURNCODE
AddrLib1::ComputeCmaskAddrFromCoord(
1568 const ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT
* pIn
, ///< [in] input structure
1569 ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT
* pOut
///< [out] output structure
1572 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1574 if (GetFillSizeFieldsFlags() == TRUE
)
1576 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT
)) ||
1577 (pOut
->size
!= sizeof(ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT
)))
1579 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1583 if (returnCode
== ADDR_OK
)
1585 ADDR_TILEINFO tileInfoNull
;
1586 ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT input
;
1588 if (UseTileIndex(pIn
->tileIndex
))
1591 // Use temp tile info for calcalation
1592 input
.pTileInfo
= &tileInfoNull
;
1594 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1596 // Change the input structure
1600 if (returnCode
== ADDR_OK
)
1602 if (pIn
->flags
.tcCompatible
== TRUE
)
1604 returnCode
= HwlComputeCmaskAddrFromCoord(pIn
, pOut
);
1608 pOut
->addr
= HwlComputeXmaskAddrFromCoord(pIn
->pitch
,
1616 FALSE
, //this is cmask, isWidth8 is not needed
1617 FALSE
, //this is cmask, isHeight8 is not needed
1619 &pOut
->bitPosition
);
1629 ***************************************************************************************************
1630 * AddrLib1::ComputeCmaskCoordFromAddr
1633 * Interface function stub of AddrComputeCmaskCoordFromAddr
1637 ***************************************************************************************************
1639 ADDR_E_RETURNCODE
AddrLib1::ComputeCmaskCoordFromAddr(
1640 const ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT
* pIn
, ///< [in] input structure
1641 ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT
* pOut
///< [out] output structure
1644 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1646 if (GetFillSizeFieldsFlags() == TRUE
)
1648 if ((pIn
->size
!= sizeof(ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT
)) ||
1649 (pOut
->size
!= sizeof(ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT
)))
1651 returnCode
= ADDR_PARAMSIZEMISMATCH
;
1655 if (returnCode
== ADDR_OK
)
1657 ADDR_TILEINFO tileInfoNull
;
1658 ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT input
;
1660 if (UseTileIndex(pIn
->tileIndex
))
1663 // Use temp tile info for calcalation
1664 input
.pTileInfo
= &tileInfoNull
;
1666 returnCode
= HwlSetupTileCfg(0, input
.tileIndex
, input
.macroModeIndex
, input
.pTileInfo
);
1668 // Change the input structure
1672 if (returnCode
== ADDR_OK
)
1674 HwlComputeXmaskCoordFromAddr(pIn
->addr
,
1695 ***************************************************************************************************
1696 * AddrLib1::ComputeTileDataWidthAndHeight
1699 * Compute the squared cache shape for per-tile data (CMASK and HTILE)
1705 * MacroWidth and macroHeight are measured in pixels
1706 ***************************************************************************************************
1708 VOID
AddrLib1::ComputeTileDataWidthAndHeight(
1709 UINT_32 bpp
, ///< [in] bits per pixel
1710 UINT_32 cacheBits
, ///< [in] bits of cache
1711 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
1712 UINT_32
* pMacroWidth
, ///< [out] macro tile width
1713 UINT_32
* pMacroHeight
///< [out] macro tile height
1717 UINT_32 width
= cacheBits
/ bpp
;
1718 UINT_32 pipes
= HwlGetPipes(pTileInfo
);
1720 // Double height until the macro-tile is close to square
1721 // Height can only be doubled if width is even
1723 while ((width
> height
* 2 * pipes
) && !(width
& 1))
1729 *pMacroWidth
= 8 * width
;
1730 *pMacroHeight
= 8 * height
* pipes
;
1732 // Note: The above iterative comptuation is equivalent to the following
1734 //int log2_height = ((log2(cacheBits)-log2(bpp)-log2(pipes))/2);
1735 //int macroHeight = pow2( 3+log2(pipes)+log2_height );
1739 ***************************************************************************************************
1740 * AddrLib1::HwlComputeTileDataWidthAndHeightLinear
1743 * Compute the squared cache shape for per-tile data (CMASK and HTILE) for linear layout
1749 * MacroWidth and macroHeight are measured in pixels
1750 ***************************************************************************************************
1752 VOID
AddrLib1::HwlComputeTileDataWidthAndHeightLinear(
1753 UINT_32
* pMacroWidth
, ///< [out] macro tile width
1754 UINT_32
* pMacroHeight
, ///< [out] macro tile height
1755 UINT_32 bpp
, ///< [in] bits per pixel
1756 ADDR_TILEINFO
* pTileInfo
///< [in] tile info
1759 ADDR_ASSERT(bpp
!= 4); // Cmask does not support linear layout prior to SI
1760 *pMacroWidth
= 8 * 512 / bpp
; // Align width to 512-bit memory accesses
1761 *pMacroHeight
= 8 * m_pipes
; // Align height to number of pipes
1765 ***************************************************************************************************
1766 * AddrLib1::ComputeHtileInfo
1769 * Compute htile pitch,width, bytes per 2D slice
1772 * Htile bpp i.e. How many bits for an 8x8 tile
1773 * Also returns by output parameters:
1774 * *Htile pitch, height, total size in bytes, macro-tile dimensions and slice size*
1775 ***************************************************************************************************
1777 UINT_32
AddrLib1::ComputeHtileInfo(
1778 ADDR_HTILE_FLAGS flags
, ///< [in] htile flags
1779 UINT_32 pitchIn
, ///< [in] pitch input
1780 UINT_32 heightIn
, ///< [in] height input
1781 UINT_32 numSlices
, ///< [in] number of slices
1782 BOOL_32 isLinear
, ///< [in] if it is linear mode
1783 BOOL_32 isWidth8
, ///< [in] if htile block width is 8
1784 BOOL_32 isHeight8
, ///< [in] if htile block height is 8
1785 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
1786 UINT_32
* pPitchOut
, ///< [out] pitch output
1787 UINT_32
* pHeightOut
, ///< [out] height output
1788 UINT_64
* pHtileBytes
, ///< [out] bytes per 2D slice
1789 UINT_32
* pMacroWidth
, ///< [out] macro-tile width in pixels
1790 UINT_32
* pMacroHeight
, ///< [out] macro-tile width in pixels
1791 UINT_64
* pSliceSize
, ///< [out] slice size in bytes
1792 UINT_32
* pBaseAlign
///< [out] base alignment
1797 UINT_32 macroHeight
;
1802 numSlices
= Max(1u, numSlices
);
1804 const UINT_32 bpp
= HwlComputeHtileBpp(isWidth8
, isHeight8
);
1805 const UINT_32 cacheBits
= HtileCacheBits
;
1809 HwlComputeTileDataWidthAndHeightLinear(¯oWidth
,
1816 ComputeTileDataWidthAndHeight(bpp
,
1823 *pPitchOut
= PowTwoAlign(pitchIn
, macroWidth
);
1824 *pHeightOut
= PowTwoAlign(heightIn
, macroHeight
);
1826 baseAlign
= HwlComputeHtileBaseAlign(flags
.tcCompatible
, isLinear
, pTileInfo
);
1828 surfBytes
= HwlComputeHtileBytes(*pPitchOut
,
1836 *pHtileBytes
= surfBytes
;
1839 // Use SafeAssign since they are optional
1841 SafeAssign(pMacroWidth
, macroWidth
);
1843 SafeAssign(pMacroHeight
, macroHeight
);
1845 SafeAssign(pSliceSize
, sliceBytes
);
1847 SafeAssign(pBaseAlign
, baseAlign
);
1853 ***************************************************************************************************
1854 * AddrLib1::ComputeCmaskBaseAlign
1857 * Compute cmask base alignment
1860 * Cmask base alignment
1861 ***************************************************************************************************
1863 UINT_32
AddrLib1::ComputeCmaskBaseAlign(
1864 ADDR_CMASK_FLAGS flags
, ///< [in] Cmask flags
1865 ADDR_TILEINFO
* pTileInfo
///< [in] Tile info
1868 UINT_32 baseAlign
= m_pipeInterleaveBytes
* HwlGetPipes(pTileInfo
);
1870 if (flags
.tcCompatible
)
1872 ADDR_ASSERT(pTileInfo
!= NULL
);
1875 baseAlign
*= pTileInfo
->banks
;
1883 ***************************************************************************************************
1884 * AddrLib1::ComputeCmaskBytes
1887 * Compute cmask size in bytes
1890 * Cmask size in bytes
1891 ***************************************************************************************************
1893 UINT_64
AddrLib1::ComputeCmaskBytes(
1894 UINT_32 pitch
, ///< [in] pitch
1895 UINT_32 height
, ///< [in] height
1896 UINT_32 numSlices
///< [in] number of slices
1899 return BITS_TO_BYTES(static_cast<UINT_64
>(pitch
) * height
* numSlices
* CmaskElemBits
) /
1904 ***************************************************************************************************
1905 * AddrLib1::ComputeCmaskInfo
1908 * Compute cmask pitch,width, bytes per 2D slice
1911 * BlockMax. Also by output parameters: Cmask pitch,height, total size in bytes,
1912 * macro-tile dimensions
1913 ***************************************************************************************************
1915 ADDR_E_RETURNCODE
AddrLib1::ComputeCmaskInfo(
1916 ADDR_CMASK_FLAGS flags
, ///< [in] cmask flags
1917 UINT_32 pitchIn
, ///< [in] pitch input
1918 UINT_32 heightIn
, ///< [in] height input
1919 UINT_32 numSlices
, ///< [in] number of slices
1920 BOOL_32 isLinear
, ///< [in] is linear mode
1921 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
1922 UINT_32
* pPitchOut
, ///< [out] pitch output
1923 UINT_32
* pHeightOut
, ///< [out] height output
1924 UINT_64
* pCmaskBytes
, ///< [out] bytes per 2D slice
1925 UINT_32
* pMacroWidth
, ///< [out] macro-tile width in pixels
1926 UINT_32
* pMacroHeight
, ///< [out] macro-tile width in pixels
1927 UINT_64
* pSliceSize
, ///< [out] slice size in bytes
1928 UINT_32
* pBaseAlign
, ///< [out] base alignment
1929 UINT_32
* pBlockMax
///< [out] block max == slice / 128 / 128 - 1
1933 UINT_32 macroHeight
;
1938 numSlices
= Max(1u, numSlices
);
1940 const UINT_32 bpp
= CmaskElemBits
;
1941 const UINT_32 cacheBits
= CmaskCacheBits
;
1943 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
1947 HwlComputeTileDataWidthAndHeightLinear(¯oWidth
,
1954 ComputeTileDataWidthAndHeight(bpp
,
1961 *pPitchOut
= (pitchIn
+ macroWidth
- 1) & ~(macroWidth
- 1);
1962 *pHeightOut
= (heightIn
+ macroHeight
- 1) & ~(macroHeight
- 1);
1965 sliceBytes
= ComputeCmaskBytes(*pPitchOut
,
1969 baseAlign
= ComputeCmaskBaseAlign(flags
, pTileInfo
);
1971 while (sliceBytes
% baseAlign
)
1973 *pHeightOut
+= macroHeight
;
1975 sliceBytes
= ComputeCmaskBytes(*pPitchOut
,
1980 surfBytes
= sliceBytes
* numSlices
;
1982 *pCmaskBytes
= surfBytes
;
1985 // Use SafeAssign since they are optional
1987 SafeAssign(pMacroWidth
, macroWidth
);
1989 SafeAssign(pMacroHeight
, macroHeight
);
1991 SafeAssign(pBaseAlign
, baseAlign
);
1993 SafeAssign(pSliceSize
, sliceBytes
);
1995 UINT_32 slice
= (*pPitchOut
) * (*pHeightOut
);
1996 UINT_32 blockMax
= slice
/ 128 / 128 - 1;
1999 if (slice
% (64*256) != 0)
2001 ADDR_ASSERT_ALWAYS();
2005 UINT_32 maxBlockMax
= HwlGetMaxCmaskBlockMax();
2007 if (blockMax
> maxBlockMax
)
2009 blockMax
= maxBlockMax
;
2010 returnCode
= ADDR_INVALIDPARAMS
;
2013 SafeAssign(pBlockMax
, blockMax
);
2019 ***************************************************************************************************
2020 * AddrLib1::ComputeXmaskCoordYFromPipe
2023 * Compute the Y coord from pipe number for cmask/htile
2028 ***************************************************************************************************
2030 UINT_32
AddrLib1::ComputeXmaskCoordYFromPipe(
2031 UINT_32 pipe
, ///< [in] pipe number
2032 UINT_32 x
///< [in] x coordinate
2044 UINT_32 numPipes
= m_pipes
; // SI has its implementation
2046 // Convert pipe + x to y coordinate.
2066 pipeBit0
= pipe
& 0x1;
2070 yBit0
= pipeBit0
^ xBit0
;
2084 pipeBit0
= pipe
& 0x1;
2085 pipeBit1
= (pipe
& 0x2) >> 1;
2088 xBit1
= (x
& 0x2) >> 1;
2090 yBit0
= pipeBit0
^ xBit1
;
2091 yBit1
= pipeBit1
^ xBit0
;
2100 // r600 and r800 have different method
2102 y
= HwlComputeXmaskCoordYFrom8Pipe(pipe
, x
);
2111 ***************************************************************************************************
2112 * AddrLib1::HwlComputeXmaskCoordFromAddr
2115 * Compute the coord from an address of a cmask/htile
2121 * This method is reused by htile, so rename to Xmask
2122 ***************************************************************************************************
2124 VOID
AddrLib1::HwlComputeXmaskCoordFromAddr(
2125 UINT_64 addr
, ///< [in] address
2126 UINT_32 bitPosition
, ///< [in] bitPosition in a byte
2127 UINT_32 pitch
, ///< [in] pitch
2128 UINT_32 height
, ///< [in] height
2129 UINT_32 numSlices
, ///< [in] number of slices
2130 UINT_32 factor
, ///< [in] factor that indicates cmask or htile
2131 BOOL_32 isLinear
, ///< [in] linear or tiled HTILE layout
2132 BOOL_32 isWidth8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2133 BOOL_32 isHeight8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2134 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
2135 UINT_32
* pX
, ///< [out] x coord
2136 UINT_32
* pY
, ///< [out] y coord
2137 UINT_32
* pSlice
///< [out] slice index
2142 UINT_32 numPipeBits
;
2143 UINT_32 macroTilePitch
;
2144 UINT_32 macroTileHeight
;
2148 UINT_32 microTileCoordY
;
2152 UINT_32 pitchAligned
= pitch
;
2153 UINT_32 heightAligned
= height
;
2161 UINT_64 macroNumber
;
2162 UINT_32 microNumber
;
2171 UINT_32 tilesPerMacro
;
2172 UINT_32 macrosPerPitch
;
2173 UINT_32 macrosPerSlice
;
2178 numPipes
= HwlGetPipes(pTileInfo
);
2179 pipe
= ComputePipeFromAddr(addr
, numPipes
);
2182 // Compute the number of group and pipe bits.
2184 numPipeBits
= Log2(numPipes
);
2186 UINT_32 groupBits
= 8 * m_pipeInterleaveBytes
;
2187 UINT_32 pipes
= numPipes
;
2191 // Compute the micro tile size, in bits. And macro tile pitch and height.
2193 if (factor
== 2) //CMASK
2195 ADDR_CMASK_FLAGS flags
= {{0}};
2197 elemBits
= CmaskElemBits
;
2199 ComputeCmaskInfo(flags
,
2213 ADDR_HTILE_FLAGS flags
= {{0}};
2220 elemBits
= HwlComputeHtileBpp(isWidth8
, isHeight8
);
2222 ComputeHtileInfo(flags
,
2237 // Should use aligned dims
2239 pitch
= pitchAligned
;
2240 height
= heightAligned
;
2244 // Convert byte address to bit address.
2246 bitAddr
= BYTES_TO_BITS(addr
) + bitPosition
;
2250 // Remove pipe bits from address.
2253 bitAddr
= (bitAddr
% groupBits
) + ((bitAddr
/groupBits
/pipes
)*groupBits
);
2256 elemOffset
= bitAddr
/ elemBits
;
2258 tilesPerMacro
= (macroTilePitch
/factor
) * macroTileHeight
/ MicroTilePixels
>> numPipeBits
;
2260 macrosPerPitch
= pitch
/ (macroTilePitch
/factor
);
2261 macrosPerSlice
= macrosPerPitch
* height
/ macroTileHeight
;
2263 macroIndex
= elemOffset
/ factor
/ tilesPerMacro
;
2264 microIndex
= static_cast<UINT_32
>(elemOffset
% (tilesPerMacro
* factor
));
2266 macroNumber
= macroIndex
* factor
+ microIndex
% factor
;
2267 microNumber
= microIndex
/ factor
;
2269 macroX
= static_cast<UINT_32
>((macroNumber
% macrosPerPitch
));
2270 macroY
= static_cast<UINT_32
>((macroNumber
% macrosPerSlice
) / macrosPerPitch
);
2271 macroZ
= static_cast<UINT_32
>((macroNumber
/ macrosPerSlice
));
2274 microX
= microNumber
% (macroTilePitch
/ factor
/ MicroTileWidth
);
2275 microY
= (microNumber
/ (macroTilePitch
/ factor
/ MicroTileHeight
));
2277 *pX
= macroX
* (macroTilePitch
/factor
) + microX
* MicroTileWidth
;
2278 *pY
= macroY
* macroTileHeight
+ (microY
* MicroTileHeight
<< numPipeBits
);
2281 microTileCoordY
= ComputeXmaskCoordYFromPipe(pipe
,
2282 *pX
/MicroTileWidth
);
2286 // Assemble final coordinates.
2288 *pY
+= microTileCoordY
* MicroTileHeight
;
2293 ***************************************************************************************************
2294 * AddrLib1::HwlComputeXmaskAddrFromCoord
2297 * Compute the address from an address of cmask (prior to si)
2302 ***************************************************************************************************
2304 UINT_64
AddrLib1::HwlComputeXmaskAddrFromCoord(
2305 UINT_32 pitch
, ///< [in] pitch
2306 UINT_32 height
, ///< [in] height
2307 UINT_32 x
, ///< [in] x coord
2308 UINT_32 y
, ///< [in] y coord
2309 UINT_32 slice
, ///< [in] slice/depth index
2310 UINT_32 numSlices
, ///< [in] number of slices
2311 UINT_32 factor
, ///< [in] factor that indicates cmask(2) or htile(1)
2312 BOOL_32 isLinear
, ///< [in] linear or tiled HTILE layout
2313 BOOL_32 isWidth8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2314 BOOL_32 isHeight8
, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2315 ADDR_TILEINFO
* pTileInfo
, ///< [in] Tile info
2316 UINT_32
* pBitPosition
///< [out] bit position inside a byte
2320 UINT_32 numGroupBits
;
2321 UINT_32 numPipeBits
;
2322 UINT_32 newPitch
= 0;
2323 UINT_32 newHeight
= 0;
2324 UINT_64 sliceBytes
= 0;
2325 UINT_64 totalBytes
= 0;
2326 UINT_64 sliceOffset
;
2328 UINT_32 macroTileWidth
;
2329 UINT_32 macroTileHeight
;
2330 UINT_32 macroTilesPerRow
;
2331 UINT_32 macroTileBytes
;
2332 UINT_32 macroTileIndexX
;
2333 UINT_32 macroTileIndexY
;
2334 UINT_64 macroTileOffset
;
2335 UINT_32 pixelBytesPerRow
;
2336 UINT_32 pixelOffsetX
;
2337 UINT_32 pixelOffsetY
;
2338 UINT_32 pixelOffset
;
2339 UINT_64 totalOffset
;
2345 UINT_32 elemBits
= 0;
2347 UINT_32 numPipes
= m_pipes
; // This function is accessed prior to si only
2349 if (factor
== 2) //CMASK
2351 elemBits
= CmaskElemBits
;
2353 // For asics before SI, cmask is always tiled
2358 if (factor
!= 1) // Fix compile warning
2363 elemBits
= HwlComputeHtileBpp(isWidth8
, isHeight8
);
2367 // Compute the number of group bits and pipe bits.
2369 numGroupBits
= Log2(m_pipeInterleaveBytes
);
2370 numPipeBits
= Log2(numPipes
);
2373 // Compute macro tile dimensions.
2375 if (factor
== 2) // CMASK
2377 ADDR_CMASK_FLAGS flags
= {{0}};
2379 ComputeCmaskInfo(flags
,
2391 sliceBytes
= totalBytes
/ numSlices
;
2395 ADDR_HTILE_FLAGS flags
= {{0}};
2397 ComputeHtileInfo(flags
,
2413 sliceOffset
= slice
* sliceBytes
;
2416 // Get the pipe. Note that neither slice rotation nor pipe swizzling apply for CMASK.
2418 pipe
= ComputePipeFromCoord(x
,
2421 ADDR_TM_2D_TILED_THIN1
,
2427 // Compute the number of macro tiles per row.
2429 macroTilesPerRow
= newPitch
/ macroTileWidth
;
2432 // Compute the number of bytes per macro tile.
2434 macroTileBytes
= BITS_TO_BYTES((macroTileWidth
* macroTileHeight
* elemBits
) / MicroTilePixels
);
2437 // Compute the offset to the macro tile containing the specified coordinate.
2439 macroTileIndexX
= x
/ macroTileWidth
;
2440 macroTileIndexY
= y
/ macroTileHeight
;
2441 macroTileOffset
= ((macroTileIndexY
* macroTilesPerRow
) + macroTileIndexX
) * macroTileBytes
;
2444 // Compute the pixel offset within the macro tile.
2446 pixelBytesPerRow
= BITS_TO_BYTES(macroTileWidth
* elemBits
) / MicroTileWidth
;
2449 // The nibbles are interleaved (see below), so the part of the offset relative to the x
2450 // coordinate repeats halfway across the row. (Not for HTILE)
2454 pixelOffsetX
= (x
% (macroTileWidth
/ 2)) / MicroTileWidth
;
2458 pixelOffsetX
= (x
% (macroTileWidth
)) / MicroTileWidth
* BITS_TO_BYTES(elemBits
);
2462 // Compute the y offset within the macro tile.
2464 pixelOffsetY
= (((y
% macroTileHeight
) / MicroTileHeight
) / numPipes
) * pixelBytesPerRow
;
2466 pixelOffset
= pixelOffsetX
+ pixelOffsetY
;
2469 // Combine the slice offset and macro tile offset with the pixel offset, accounting for the
2470 // pipe bits in the middle of the address.
2472 totalOffset
= ((sliceOffset
+ macroTileOffset
) >> numPipeBits
) + pixelOffset
;
2475 // Split the offset to put some bits below the pipe bits and some above.
2477 groupMask
= (1 << numGroupBits
) - 1;
2478 offsetLo
= totalOffset
& groupMask
;
2479 offsetHi
= (totalOffset
& ~groupMask
) << numPipeBits
;
2482 // Assemble the address from its components.
2486 // This is to remove warning with /analyze option
2487 UINT_32 pipeBits
= pipe
<< numGroupBits
;
2491 // Compute the bit position. The lower nibble is used when the x coordinate within the macro
2492 // tile is less than half of the macro tile width, and the upper nibble is used when the x
2493 // coordinate within the macro tile is greater than or equal to half the macro tile width.
2495 *pBitPosition
= ((x
% macroTileWidth
) < (macroTileWidth
/ factor
)) ? 0 : 4;
2500 ///////////////////////////////////////////////////////////////////////////////////////////////////
2501 // Surface Addressing Shared
2502 ///////////////////////////////////////////////////////////////////////////////////////////////////
2505 ***************************************************************************************************
2506 * AddrLib1::ComputeSurfaceAddrFromCoordLinear
2509 * Compute address from coord for linear surface
2514 ***************************************************************************************************
2516 UINT_64
AddrLib1::ComputeSurfaceAddrFromCoordLinear(
2517 UINT_32 x
, ///< [in] x coord
2518 UINT_32 y
, ///< [in] y coord
2519 UINT_32 slice
, ///< [in] slice/depth index
2520 UINT_32 sample
, ///< [in] sample index
2521 UINT_32 bpp
, ///< [in] bits per pixel
2522 UINT_32 pitch
, ///< [in] pitch
2523 UINT_32 height
, ///< [in] height
2524 UINT_32 numSlices
, ///< [in] number of slices
2525 UINT_32
* pBitPosition
///< [out] bit position inside a byte
2528 const UINT_64 sliceSize
= static_cast<UINT_64
>(pitch
) * height
;
2530 UINT_64 sliceOffset
= (slice
+ sample
* numSlices
)* sliceSize
;
2531 UINT_64 rowOffset
= static_cast<UINT_64
>(y
) * pitch
;
2532 UINT_64 pixOffset
= x
;
2534 UINT_64 addr
= (sliceOffset
+ rowOffset
+ pixOffset
) * bpp
;
2536 *pBitPosition
= static_cast<UINT_32
>(addr
% 8);
2543 ***************************************************************************************************
2544 * AddrLib1::ComputeSurfaceCoordFromAddrLinear
2547 * Compute the coord from an address of a linear surface
2551 ***************************************************************************************************
2553 VOID
AddrLib1::ComputeSurfaceCoordFromAddrLinear(
2554 UINT_64 addr
, ///< [in] address
2555 UINT_32 bitPosition
, ///< [in] bitPosition in a byte
2556 UINT_32 bpp
, ///< [in] bits per pixel
2557 UINT_32 pitch
, ///< [in] pitch
2558 UINT_32 height
, ///< [in] height
2559 UINT_32 numSlices
, ///< [in] number of slices
2560 UINT_32
* pX
, ///< [out] x coord
2561 UINT_32
* pY
, ///< [out] y coord
2562 UINT_32
* pSlice
, ///< [out] slice/depth index
2563 UINT_32
* pSample
///< [out] sample index
2566 const UINT_64 sliceSize
= static_cast<UINT_64
>(pitch
) * height
;
2567 const UINT_64 linearOffset
= (BYTES_TO_BITS(addr
) + bitPosition
) / bpp
;
2569 *pX
= static_cast<UINT_32
>((linearOffset
% sliceSize
) % pitch
);
2570 *pY
= static_cast<UINT_32
>((linearOffset
% sliceSize
) / pitch
% height
);
2571 *pSlice
= static_cast<UINT_32
>((linearOffset
/ sliceSize
) % numSlices
);
2572 *pSample
= static_cast<UINT_32
>((linearOffset
/ sliceSize
) / numSlices
);
2576 ***************************************************************************************************
2577 * AddrLib1::ComputeSurfaceCoordFromAddrMicroTiled
2580 * Compute the coord from an address of a micro tiled surface
2584 ***************************************************************************************************
2586 VOID
AddrLib1::ComputeSurfaceCoordFromAddrMicroTiled(
2587 UINT_64 addr
, ///< [in] address
2588 UINT_32 bitPosition
, ///< [in] bitPosition in a byte
2589 UINT_32 bpp
, ///< [in] bits per pixel
2590 UINT_32 pitch
, ///< [in] pitch
2591 UINT_32 height
, ///< [in] height
2592 UINT_32 numSamples
, ///< [in] number of samples
2593 AddrTileMode tileMode
, ///< [in] tile mode
2594 UINT_32 tileBase
, ///< [in] base offset within a tile
2595 UINT_32 compBits
, ///< [in] component bits actually needed(for planar surface)
2596 UINT_32
* pX
, ///< [out] x coord
2597 UINT_32
* pY
, ///< [out] y coord
2598 UINT_32
* pSlice
, ///< [out] slice/depth index
2599 UINT_32
* pSample
, ///< [out] sample index,
2600 AddrTileType microTileType
, ///< [in] micro tiling order
2601 BOOL_32 isDepthSampleOrder
///< [in] TRUE if in depth sample order
2605 UINT_32 microTileThickness
;
2606 UINT_32 microTileBits
;
2610 UINT_32 microTileCoordX
;
2611 UINT_32 microTileCoordY
;
2612 UINT_32 pixelOffset
;
2613 UINT_32 pixelCoordX
= 0;
2614 UINT_32 pixelCoordY
= 0;
2615 UINT_32 pixelCoordZ
= 0;
2616 UINT_32 pixelCoordS
= 0;
2619 // Convert byte address to bit address.
2621 bitAddr
= BYTES_TO_BITS(addr
) + bitPosition
;
2624 // Compute the micro tile size, in bits.
2628 case ADDR_TM_1D_TILED_THICK
:
2629 microTileThickness
= ThickTileThickness
;
2632 microTileThickness
= 1;
2636 microTileBits
= MicroTilePixels
* microTileThickness
* bpp
* numSamples
;
2639 // Compute number of bits per slice and number of bits per row of micro tiles.
2641 sliceBits
= static_cast<UINT_64
>(pitch
) * height
* microTileThickness
* bpp
* numSamples
;
2643 rowBits
= (pitch
/ MicroTileWidth
) * microTileBits
;
2646 // Extract the slice index.
2648 sliceIndex
= static_cast<UINT_32
>(bitAddr
/ sliceBits
);
2649 bitAddr
-= sliceIndex
* sliceBits
;
2652 // Extract the y coordinate of the micro tile.
2654 microTileCoordY
= static_cast<UINT_32
>(bitAddr
/ rowBits
) * MicroTileHeight
;
2655 bitAddr
-= (microTileCoordY
/ MicroTileHeight
) * rowBits
;
2658 // Extract the x coordinate of the micro tile.
2660 microTileCoordX
= static_cast<UINT_32
>(bitAddr
/ microTileBits
) * MicroTileWidth
;
2663 // Compute the pixel offset within the micro tile.
2665 pixelOffset
= static_cast<UINT_32
>(bitAddr
% microTileBits
);
2668 // Extract pixel coordinates from the offset.
2670 HwlComputePixelCoordFromOffset(pixelOffset
,
2681 isDepthSampleOrder
);
2684 // Assemble final coordinates.
2686 *pX
= microTileCoordX
+ pixelCoordX
;
2687 *pY
= microTileCoordY
+ pixelCoordY
;
2688 *pSlice
= (sliceIndex
* microTileThickness
) + pixelCoordZ
;
2689 *pSample
= pixelCoordS
;
2691 if (microTileThickness
> 1)
2698 ***************************************************************************************************
2699 * AddrLib1::ComputePipeFromAddr
2702 * Compute the pipe number from an address
2707 ***************************************************************************************************
2709 UINT_32
AddrLib1::ComputePipeFromAddr(
2710 UINT_64 addr
, ///< [in] address
2711 UINT_32 numPipes
///< [in] number of banks
2716 UINT_32 groupBytes
= m_pipeInterleaveBytes
; //just different terms
2719 // The LSBs of the address are arranged as follows:
2720 // bank | pipe | group
2722 // To get the pipe number, shift off the group bits and mask the pipe bits.
2726 // The LSBs of the address are arranged as follows:
2727 // bank | bankInterleave | pipe | pipeInterleave
2729 // To get the pipe number, shift off the pipe interleave bits and mask the pipe bits.
2732 pipe
= static_cast<UINT_32
>(addr
>> Log2(groupBytes
)) & (numPipes
- 1);
2738 ***************************************************************************************************
2739 * AddrLib1::ComputePixelIndexWithinMicroTile
2742 * Compute the pixel index inside a micro tile of surface
2747 ***************************************************************************************************
2749 UINT_32
AddrLib1::ComputePixelIndexWithinMicroTile(
2750 UINT_32 x
, ///< [in] x coord
2751 UINT_32 y
, ///< [in] y coord
2752 UINT_32 z
, ///< [in] slice/depth index
2753 UINT_32 bpp
, ///< [in] bits per pixel
2754 AddrTileMode tileMode
, ///< [in] tile mode
2755 AddrTileType microTileType
///< [in] pixel order in display/non-display mode
2758 UINT_32 pixelBit0
= 0;
2759 UINT_32 pixelBit1
= 0;
2760 UINT_32 pixelBit2
= 0;
2761 UINT_32 pixelBit3
= 0;
2762 UINT_32 pixelBit4
= 0;
2763 UINT_32 pixelBit5
= 0;
2764 UINT_32 pixelBit6
= 0;
2765 UINT_32 pixelBit7
= 0;
2766 UINT_32 pixelBit8
= 0;
2767 UINT_32 pixelNumber
;
2769 UINT_32 x0
= _BIT(x
, 0);
2770 UINT_32 x1
= _BIT(x
, 1);
2771 UINT_32 x2
= _BIT(x
, 2);
2772 UINT_32 y0
= _BIT(y
, 0);
2773 UINT_32 y1
= _BIT(y
, 1);
2774 UINT_32 y2
= _BIT(y
, 2);
2775 UINT_32 z0
= _BIT(z
, 0);
2776 UINT_32 z1
= _BIT(z
, 1);
2777 UINT_32 z2
= _BIT(z
, 2);
2779 UINT_32 thickness
= ComputeSurfaceThickness(tileMode
);
2781 // Compute the pixel number within the micro tile.
2783 if (microTileType
!= ADDR_THICK
)
2785 if (microTileType
== ADDR_DISPLAYABLE
)
2830 ADDR_ASSERT_ALWAYS();
2834 else if (microTileType
== ADDR_NON_DISPLAYABLE
|| microTileType
== ADDR_DEPTH_SAMPLE_ORDER
)
2843 else if (microTileType
== ADDR_ROTATED
)
2845 ADDR_ASSERT(thickness
== 1);
2882 ADDR_ASSERT_ALWAYS();
2895 ADDR_ASSERT(thickness
> 1);
2926 ADDR_ASSERT_ALWAYS();
2939 pixelNumber
= ((pixelBit0
) |
2953 ***************************************************************************************************
2954 * AddrLib1::AdjustPitchAlignment
2957 * Adjusts pitch alignment for flipping surface
2962 ***************************************************************************************************
2964 VOID
AddrLib1::AdjustPitchAlignment(
2965 ADDR_SURFACE_FLAGS flags
, ///< [in] Surface flags
2966 UINT_32
* pPitchAlign
///< [out] Pointer to pitch alignment
2969 // Display engine hardwires lower 5 bit of GRPH_PITCH to ZERO which means 32 pixel alignment
2970 // Maybe it will be fixed in future but let's make it general for now.
2971 if (flags
.display
|| flags
.overlay
)
2973 *pPitchAlign
= PowTwoAlign(*pPitchAlign
, 32);
2977 *pPitchAlign
= Max(m_minPitchAlignPixels
, *pPitchAlign
);
2983 ***************************************************************************************************
2984 * AddrLib1::PadDimensions
2987 * Helper function to pad dimensions
2992 ***************************************************************************************************
2994 VOID
AddrLib1::PadDimensions(
2995 AddrTileMode tileMode
, ///< [in] tile mode
2996 UINT_32 bpp
, ///< [in] bits per pixel
2997 ADDR_SURFACE_FLAGS flags
, ///< [in] surface flags
2998 UINT_32 numSamples
, ///< [in] number of samples
2999 ADDR_TILEINFO
* pTileInfo
, ///< [in/out] bank structure.
3000 UINT_32 padDims
, ///< [in] Dimensions to pad valid value 1,2,3
3001 UINT_32 mipLevel
, ///< [in] MipLevel
3002 UINT_32
* pPitch
, ///< [in/out] pitch in pixels
3003 UINT_32 pitchAlign
, ///< [in] pitch alignment
3004 UINT_32
* pHeight
, ///< [in/out] height in pixels
3005 UINT_32 heightAlign
, ///< [in] height alignment
3006 UINT_32
* pSlices
, ///< [in/out] number of slices
3007 UINT_32 sliceAlign
///< [in] number of slice alignment
3010 UINT_32 thickness
= ComputeSurfaceThickness(tileMode
);
3012 ADDR_ASSERT(padDims
<= 3);
3015 // Override padding for mip levels
3021 // for cubemap, we only pad when client call with 6 faces as an identity
3024 padDims
= 3; // we should pad cubemap sub levels when we treat it as 3d texture
3033 // Any possibilities that padDims is 0?
3039 if (IsPow2(pitchAlign
))
3041 *pPitch
= PowTwoAlign((*pPitch
), pitchAlign
);
3043 else // add this code to pass unit test, r600 linear mode is not align bpp to pow2 for linear
3045 *pPitch
+= pitchAlign
- 1;
3046 *pPitch
/= pitchAlign
;
3047 *pPitch
*= pitchAlign
;
3052 *pHeight
= PowTwoAlign((*pHeight
), heightAlign
);
3055 if (padDims
> 2 || thickness
> 1)
3057 // for cubemap single face, we do not pad slices.
3058 // if we pad it, the slice number should be set to 6 and current mip level > 1
3059 if (flags
.cube
&& (!m_configFlags
.noCubeMipSlicesPad
|| flags
.cubeAsArray
))
3061 *pSlices
= NextPow2(*pSlices
);
3064 // normal 3D texture or arrays or cubemap has a thick mode? (Just pass unit test)
3067 *pSlices
= PowTwoAlign((*pSlices
), sliceAlign
);
3072 HwlPadDimensions(tileMode
,
3089 ***************************************************************************************************
3090 * AddrLib1::HwlPreHandleBaseLvl3xPitch
3093 * Pre-handler of 3x pitch (96 bit) adjustment
3097 ***************************************************************************************************
3099 UINT_32
AddrLib1::HwlPreHandleBaseLvl3xPitch(
3100 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] input
3101 UINT_32 expPitch
///< [in] pitch
3104 ADDR_ASSERT(pIn
->width
== expPitch
);
3106 // If pitch is pre-multiplied by 3, we retrieve original one here to get correct miplevel size
3108 if (AddrElemLib::IsExpand3x(pIn
->format
) &&
3109 pIn
->mipLevel
== 0 &&
3110 pIn
->tileMode
== ADDR_TM_LINEAR_ALIGNED
)
3113 expPitch
= NextPow2(expPitch
);
3120 ***************************************************************************************************
3121 * AddrLib1::HwlPostHandleBaseLvl3xPitch
3124 * Post-handler of 3x pitch adjustment
3128 ***************************************************************************************************
3130 UINT_32
AddrLib1::HwlPostHandleBaseLvl3xPitch(
3131 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] input
3132 UINT_32 expPitch
///< [in] pitch
3136 // 96 bits surface of sub levels require element pitch of 32 bits instead
3137 // So we just return pitch in 32 bit pixels without timing 3
3139 if (AddrElemLib::IsExpand3x(pIn
->format
) &&
3140 pIn
->mipLevel
== 0 &&
3141 pIn
->tileMode
== ADDR_TM_LINEAR_ALIGNED
)
3151 ***************************************************************************************************
3152 * AddrLib1::IsMacroTiled
3155 * Check if the tile mode is macro tiled
3158 * TRUE if it is macro tiled (2D/2B/3D/3B)
3159 ***************************************************************************************************
3161 BOOL_32
AddrLib1::IsMacroTiled(
3162 AddrTileMode tileMode
) ///< [in] tile mode
3164 return m_modeFlags
[tileMode
].isMacro
;
3168 ***************************************************************************************************
3169 * AddrLib1::IsMacro3dTiled
3172 * Check if the tile mode is 3D macro tiled
3175 * TRUE if it is 3D macro tiled
3176 ***************************************************************************************************
3178 BOOL_32
AddrLib1::IsMacro3dTiled(
3179 AddrTileMode tileMode
) ///< [in] tile mode
3181 return m_modeFlags
[tileMode
].isMacro3d
;
3185 ***************************************************************************************************
3186 * AddrLib1::IsMicroTiled
3189 * Check if the tile mode is micro tiled
3192 * TRUE if micro tiled
3193 ***************************************************************************************************
3195 BOOL_32
AddrLib1::IsMicroTiled(
3196 AddrTileMode tileMode
) ///< [in] tile mode
3198 return m_modeFlags
[tileMode
].isMicro
;
3202 ***************************************************************************************************
3203 * AddrLib1::IsLinear
3206 * Check if the tile mode is linear
3210 ***************************************************************************************************
3212 BOOL_32
AddrLib1::IsLinear(
3213 AddrTileMode tileMode
) ///< [in] tile mode
3215 return m_modeFlags
[tileMode
].isLinear
;
3219 ***************************************************************************************************
3220 * AddrLib1::IsPrtNoRotationTileMode
3223 * Return TRUE if it is prt tile without rotation
3225 * This function just used by CI
3226 ***************************************************************************************************
3228 BOOL_32
AddrLib1::IsPrtNoRotationTileMode(
3229 AddrTileMode tileMode
)
3231 return m_modeFlags
[tileMode
].isPrtNoRotation
;
3235 ***************************************************************************************************
3236 * AddrLib1::IsPrtTileMode
3239 * Return TRUE if it is prt tile
3241 * This function just used by CI
3242 ***************************************************************************************************
3244 BOOL_32
AddrLib1::IsPrtTileMode(
3245 AddrTileMode tileMode
)
3247 return m_modeFlags
[tileMode
].isPrt
;
3251 ***************************************************************************************************
3252 * AddrLib1::ComputeMipLevel
3255 * Compute mipmap level width/height/slices
3258 ***************************************************************************************************
3260 VOID
AddrLib1::ComputeMipLevel(
3261 ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
///< [in/out] Input structure
3264 if (AddrElemLib::IsBlockCompressed(pIn
->format
))
3266 if (pIn
->mipLevel
== 0)
3268 // DXTn's level 0 must be multiple of 4
3269 // But there are exceptions:
3270 // 1. Internal surface creation in hostblt/vsblt/etc...
3271 // 2. Runtime doesn't reject ATI1/ATI2 whose width/height are not multiple of 4
3272 pIn
->width
= PowTwoAlign(pIn
->width
, 4);
3273 pIn
->height
= PowTwoAlign(pIn
->height
, 4);
3277 HwlComputeMipLevel(pIn
);
3281 ***************************************************************************************************
3282 * AddrLib1::OptimizeTileMode
3285 * Check if base level's tile mode can be optimized (degraded)
3287 * TRUE if degraded, also returns degraded tile mode (unchanged if not degraded)
3288 ***************************************************************************************************
3290 BOOL_32
AddrLib1::OptimizeTileMode(
3291 const ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in] Input structure for surface info
3292 AddrTileMode
* pTileMode
///< [out] Degraded tile mode
3295 AddrTileMode tileMode
= pIn
->tileMode
;
3296 UINT_32 thickness
= ComputeSurfaceThickness(tileMode
);
3298 // Optimization can only be done on level 0 and samples <= 1
3299 if ((pIn
->flags
.opt4Space
== TRUE
) &&
3300 (pIn
->mipLevel
== 0) &&
3301 (pIn
->numSamples
<= 1) &&
3302 (pIn
->flags
.display
== FALSE
) &&
3303 (IsPrtTileMode(tileMode
) == FALSE
) &&
3304 (pIn
->flags
.prt
== FALSE
))
3306 // Check if linear mode is optimal
3307 if ((pIn
->height
== 1) &&
3308 (IsLinear(tileMode
) == FALSE
) &&
3309 (AddrElemLib::IsBlockCompressed(pIn
->format
) == FALSE
) &&
3310 (pIn
->flags
.depth
== FALSE
) &&
3311 (pIn
->flags
.stencil
== FALSE
) &&
3312 (m_configFlags
.disableLinearOpt
== FALSE
) &&
3313 (pIn
->flags
.disableLinearOpt
== FALSE
))
3315 tileMode
= ADDR_TM_LINEAR_ALIGNED
;
3317 else if (IsMacroTiled(tileMode
))
3319 if (HwlDegradeBaseLevel(pIn
))
3321 tileMode
= (thickness
== 1) ? ADDR_TM_1D_TILED_THIN1
: ADDR_TM_1D_TILED_THICK
;
3323 else if (thickness
> 1)
3325 // As in the following HwlComputeSurfaceInfo, thick modes may be degraded to
3326 // thinner modes, we should re-evaluate whether the corresponding thinner modes
3327 // need to be degraded. If so, we choose 1D thick mode instead.
3328 tileMode
= DegradeLargeThickTile(pIn
->tileMode
, pIn
->bpp
);
3329 if (tileMode
!= pIn
->tileMode
)
3331 ADDR_COMPUTE_SURFACE_INFO_INPUT input
= *pIn
;
3332 input
.tileMode
= tileMode
;
3333 if (HwlDegradeBaseLevel(&input
))
3335 tileMode
= ADDR_TM_1D_TILED_THICK
;
3342 BOOL_32 optimized
= (tileMode
!= pIn
->tileMode
);
3345 *pTileMode
= tileMode
;
3351 ***************************************************************************************************
3352 * AddrLib1::DegradeLargeThickTile
3355 * Check if the thickness needs to be reduced if a tile is too large
3357 * The degraded tile mode (unchanged if not degraded)
3358 ***************************************************************************************************
3360 AddrTileMode
AddrLib1::DegradeLargeThickTile(
3361 AddrTileMode tileMode
,
3364 // Override tilemode
3365 // When tile_width (8) * tile_height (8) * thickness * element_bytes is > row_size,
3366 // it is better to just use THIN mode in this case
3367 UINT_32 thickness
= ComputeSurfaceThickness(tileMode
);
3369 if (thickness
> 1 && m_configFlags
.allowLargeThickTile
== 0)
3371 UINT_32 tileSize
= MicroTilePixels
* thickness
* (bpp
>> 3);
3373 if (tileSize
> m_rowSize
)
3377 case ADDR_TM_2D_TILED_XTHICK
:
3378 if ((tileSize
>> 1) <= m_rowSize
)
3380 tileMode
= ADDR_TM_2D_TILED_THICK
;
3383 // else fall through
3384 case ADDR_TM_2D_TILED_THICK
:
3385 tileMode
= ADDR_TM_2D_TILED_THIN1
;
3388 case ADDR_TM_3D_TILED_XTHICK
:
3389 if ((tileSize
>> 1) <= m_rowSize
)
3391 tileMode
= ADDR_TM_3D_TILED_THICK
;
3394 // else fall through
3395 case ADDR_TM_3D_TILED_THICK
:
3396 tileMode
= ADDR_TM_3D_TILED_THIN1
;
3399 case ADDR_TM_PRT_TILED_THICK
:
3400 tileMode
= ADDR_TM_PRT_TILED_THIN1
;
3403 case ADDR_TM_PRT_2D_TILED_THICK
:
3404 tileMode
= ADDR_TM_PRT_2D_TILED_THIN1
;
3407 case ADDR_TM_PRT_3D_TILED_THICK
:
3408 tileMode
= ADDR_TM_PRT_3D_TILED_THIN1
;
3421 ***************************************************************************************************
3422 * AddrLib1::PostComputeMipLevel
3424 * Compute MipLevel info (including level 0) after surface adjustment
3427 ***************************************************************************************************
3429 ADDR_E_RETURNCODE
AddrLib1::PostComputeMipLevel(
3430 ADDR_COMPUTE_SURFACE_INFO_INPUT
* pIn
, ///< [in/out] Input structure
3431 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
///< [out] Output structure
3434 // Mipmap including level 0 must be pow2 padded since either SI hw expects so or it is
3435 // required by CFX for Hw Compatibility between NI and SI. Otherwise it is only needed for
3436 // mipLevel > 0. Any h/w has different requirement should implement its own virtual function
3438 if (pIn
->flags
.pow2Pad
)
3440 pIn
->width
= NextPow2(pIn
->width
);
3441 pIn
->height
= NextPow2(pIn
->height
);
3442 pIn
->numSlices
= NextPow2(pIn
->numSlices
);
3444 else if (pIn
->mipLevel
> 0)
3446 pIn
->width
= NextPow2(pIn
->width
);
3447 pIn
->height
= NextPow2(pIn
->height
);
3449 if (!pIn
->flags
.cube
)
3451 pIn
->numSlices
= NextPow2(pIn
->numSlices
);
3454 // for cubemap, we keep its value at first
3461 ***************************************************************************************************
3462 * AddrLib1::HwlSetupTileCfg
3465 * Map tile index to tile setting.
3468 ***************************************************************************************************
3470 ADDR_E_RETURNCODE
AddrLib1::HwlSetupTileCfg(
3471 UINT_32 bpp
, ///< Bits per pixel
3472 INT_32 index
, ///< [in] Tile index
3473 INT_32 macroModeIndex
, ///< [in] Index in macro tile mode table(CI)
3474 ADDR_TILEINFO
* pInfo
, ///< [out] Tile Info
3475 AddrTileMode
* pMode
, ///< [out] Tile mode
3476 AddrTileType
* pType
///< [out] Tile type
3479 return ADDR_NOTSUPPORTED
;
3483 ***************************************************************************************************
3484 * AddrLib1::HwlGetPipes
3490 ***************************************************************************************************
3492 UINT_32
AddrLib1::HwlGetPipes(
3493 const ADDR_TILEINFO
* pTileInfo
///< [in] Tile info
3496 //pTileInfo can be NULL when asic is 6xx and 8xx.
3501 ***************************************************************************************************
3502 * AddrLib1::ComputeQbStereoInfo
3505 * Get quad buffer stereo information
3508 ***************************************************************************************************
3510 BOOL_32
AddrLib1::ComputeQbStereoInfo(
3511 ADDR_COMPUTE_SURFACE_INFO_OUTPUT
* pOut
///< [in/out] updated pOut+pStereoInfo
3514 BOOL_32 success
= FALSE
;
3516 if (pOut
->pStereoInfo
)
3518 ADDR_ASSERT(pOut
->bpp
>= 8);
3519 ADDR_ASSERT((pOut
->surfSize
% pOut
->baseAlign
) == 0);
3521 // Save original height
3522 pOut
->pStereoInfo
->eyeHeight
= pOut
->height
;
3525 pOut
->pStereoInfo
->rightOffset
= static_cast<UINT_32
>(pOut
->surfSize
);
3527 pOut
->pStereoInfo
->rightSwizzle
= HwlComputeQbStereoRightSwizzle(pOut
);
3530 pOut
->pixelHeight
<<= 1;
3533 pOut
->surfSize
<<= 1;
3535 // Right start address meets the base align since it is guaranteed by AddrLib1
3537 // 1D surface on SI may break this rule, but we can force it to meet by checking .qbStereo.
3546 ***************************************************************************************************
3547 * AddrLib1::ComputePrtInfo
3550 * Compute prt surface related info
3554 ***************************************************************************************************
3556 ADDR_E_RETURNCODE
AddrLib1::ComputePrtInfo(
3557 const ADDR_PRT_INFO_INPUT
* pIn
,
3558 ADDR_PRT_INFO_OUTPUT
* pOut
) const
3560 ADDR_ASSERT(pOut
!= NULL
);
3562 ADDR_E_RETURNCODE returnCode
= ADDR_OK
;
3564 UINT_32 expandX
= 1;
3565 UINT_32 expandY
= 1;
3566 AddrElemMode elemMode
;
3568 UINT_32 bpp
= GetElemLib()->GetBitsPerPixel(pIn
->format
,
3573 if (bpp
<8 || bpp
== 24 || bpp
== 48 || bpp
== 96)
3575 returnCode
= ADDR_INVALIDPARAMS
;
3578 UINT_32 numFrags
= pIn
->numFrags
;
3579 ADDR_ASSERT(numFrags
<= 8);
3581 UINT_32 tileWidth
= 0;
3582 UINT_32 tileHeight
= 0;
3583 if (returnCode
== ADDR_OK
)
3585 // 3D texture without depth or 2d texture
3586 if (pIn
->baseMipDepth
> 1 || pIn
->baseMipHeight
> 1)
3605 // assume it is BC1/4
3609 if (elemMode
== ADDR_UNCOMPRESSED
)
3615 else if (bpp
== 128)
3617 // assume it is BC2/3/5/6H/7
3621 if (elemMode
== ADDR_UNCOMPRESSED
)
3630 tileWidth
= tileWidth
/ 2;
3632 else if (numFrags
== 4)
3634 tileWidth
= tileWidth
/ 2;
3635 tileHeight
= tileHeight
/ 2;
3637 else if (numFrags
== 8)
3639 tileWidth
= tileWidth
/ 4;
3640 tileHeight
= tileHeight
/ 2;
3662 else if (bpp
== 128)
3669 pOut
->prtTileWidth
= tileWidth
;
3670 pOut
->prtTileHeight
= tileHeight
;