2
************************************************************************************************************************
4
* Copyright (C) 2007-2022 Advanced Micro Devices, Inc. All rights reserved.
6
* Permission is hereby granted, free of charge, to any person obtaining a
7
* copy of this software and associated documentation files (the "Software"),
8
* to deal in the Software without restriction, including without limitation
9
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
* and/or sell copies of the Software, and to permit persons to whom the
11
* Software is furnished to do so, subject to the following conditions:
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
* OTHER DEALINGS IN THE SOFTWARE
24
***********************************************************************************************************************/
27
****************************************************************************************************
29
* @brief Contains the implementation for the Addr::V1::Lib base class.
30
****************************************************************************************************
33
#include "addrinterface.h"
35
#include "addrcommon.h"
42
////////////////////////////////////////////////////////////////////////////////////////////////////
43
// Static Const Member
44
////////////////////////////////////////////////////////////////////////////////////////////////////
46
const TileModeFlags Lib::ModeFlags[ADDR_TM_COUNT] =
48
{1, 1, 0, 0, 0, 0, 0, 0}, // ADDR_TM_LINEAR_GENERAL
49
{1, 1, 0, 0, 0, 0, 0, 0}, // ADDR_TM_LINEAR_ALIGNED
50
{1, 0, 1, 0, 0, 0, 0, 0}, // ADDR_TM_1D_TILED_THIN1
51
{4, 0, 1, 0, 0, 0, 0, 0}, // ADDR_TM_1D_TILED_THICK
52
{1, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THIN1
53
{1, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THIN2
54
{1, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THIN4
55
{4, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_THICK
56
{1, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THIN1
57
{1, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THIN2
58
{1, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THIN4
59
{4, 0, 0, 1, 0, 0, 0, 1}, // ADDR_TM_2B_TILED_THICK
60
{1, 0, 0, 1, 1, 0, 0, 0}, // ADDR_TM_3D_TILED_THIN1
61
{4, 0, 0, 1, 1, 0, 0, 0}, // ADDR_TM_3D_TILED_THICK
62
{1, 0, 0, 1, 1, 0, 0, 1}, // ADDR_TM_3B_TILED_THIN1
63
{4, 0, 0, 1, 1, 0, 0, 1}, // ADDR_TM_3B_TILED_THICK
64
{8, 0, 0, 1, 0, 0, 0, 0}, // ADDR_TM_2D_TILED_XTHICK
65
{8, 0, 0, 1, 1, 0, 0, 0}, // ADDR_TM_3D_TILED_XTHICK
66
{1, 0, 0, 0, 0, 0, 0, 0}, // ADDR_TM_POWER_SAVE
67
{1, 0, 0, 1, 0, 1, 1, 0}, // ADDR_TM_PRT_TILED_THIN1
68
{1, 0, 0, 1, 0, 1, 0, 0}, // ADDR_TM_PRT_2D_TILED_THIN1
69
{1, 0, 0, 1, 1, 1, 0, 0}, // ADDR_TM_PRT_3D_TILED_THIN1
70
{4, 0, 0, 1, 0, 1, 1, 0}, // ADDR_TM_PRT_TILED_THICK
71
{4, 0, 0, 1, 0, 1, 0, 0}, // ADDR_TM_PRT_2D_TILED_THICK
72
{4, 0, 0, 1, 1, 1, 0, 0}, // ADDR_TM_PRT_3D_TILED_THICK
73
{0, 0, 0, 0, 0, 0, 0, 0}, // ADDR_TM_UNKNOWN
76
////////////////////////////////////////////////////////////////////////////////////////////////////
77
// Constructor/Destructor
78
////////////////////////////////////////////////////////////////////////////////////////////////////
81
****************************************************************************************************
85
* Constructor for the AddrLib1 class
87
****************************************************************************************************
96
****************************************************************************************************
100
* Constructor for the Addr::V1::Lib class with hClient as parameter
102
****************************************************************************************************
104
Lib::Lib(const Client* pClient)
111
****************************************************************************************************
115
* Destructor for the AddrLib1 class
117
****************************************************************************************************
124
****************************************************************************************************
128
* Get AddrLib1 pointer
131
* An Addr::V1::Lib class pointer
132
****************************************************************************************************
135
ADDR_HANDLE hLib) ///< [in] handle of ADDR_HANDLE
137
Addr::Lib* pAddrLib = Addr::Lib::GetLib(hLib);
138
if ((pAddrLib != NULL) &&
139
((pAddrLib->GetChipFamily() == ADDR_CHIP_FAMILY_IVLD) ||
140
(pAddrLib->GetChipFamily() > ADDR_CHIP_FAMILY_VI)))
142
// only valid and pre-VI ASIC can use AddrLib1 function.
143
ADDR_ASSERT_ALWAYS();
146
return static_cast<Lib*>(hLib);
150
////////////////////////////////////////////////////////////////////////////////////////////////////
152
////////////////////////////////////////////////////////////////////////////////////////////////////
156
****************************************************************************************************
157
* Lib::ComputeSurfaceInfo
160
* Interface function stub of AddrComputeSurfaceInfo.
164
****************************************************************************************************
166
ADDR_E_RETURNCODE Lib::ComputeSurfaceInfo(
167
const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn, ///< [in] input structure
168
ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut ///< [out] output structure
171
ADDR_E_RETURNCODE returnCode = ADDR_OK;
173
if (GetFillSizeFieldsFlags() == TRUE)
175
if ((pIn->size != sizeof(ADDR_COMPUTE_SURFACE_INFO_INPUT)) ||
176
(pOut->size != sizeof(ADDR_COMPUTE_SURFACE_INFO_OUTPUT)))
178
returnCode = ADDR_PARAMSIZEMISMATCH;
182
// We suggest client do sanity check but a check here is also good
185
returnCode = ADDR_INVALIDPARAMS;
188
if ((pIn->tileMode == ADDR_TM_UNKNOWN) && (pIn->mipLevel > 0))
190
returnCode = ADDR_INVALIDPARAMS;
193
// Thick modes don't support multisample
194
if ((Thickness(pIn->tileMode) > 1) && (pIn->numSamples > 1))
196
returnCode = ADDR_INVALIDPARAMS;
199
if (returnCode == ADDR_OK)
201
// Get a local copy of input structure and only reference pIn for unadjusted values
202
ADDR_COMPUTE_SURFACE_INFO_INPUT localIn = *pIn;
203
ADDR_TILEINFO tileInfoNull = {0};
207
// If the original input has a valid ADDR_TILEINFO pointer then copy its contents.
208
// Otherwise the default 0's in tileInfoNull are used.
211
tileInfoNull = *pIn->pTileInfo;
213
localIn.pTileInfo = &tileInfoNull;
216
localIn.numSamples = (pIn->numSamples == 0) ? 1 : pIn->numSamples;
218
// Do mipmap check first
219
// If format is BCn, pre-pad dimension to power-of-two according to HWL
220
ComputeMipLevel(&localIn);
222
if (m_configFlags.checkLast2DLevel)
224
// Save this level's original height in pixels
225
pOut->height = pIn->height;
232
// Save outputs that may not go through HWL
233
pOut->pixelBits = localIn.bpp;
234
pOut->numSamples = localIn.numSamples;
235
pOut->last2DLevel = FALSE;
236
pOut->tcCompatible = FALSE;
239
if (localIn.numSamples > 1)
241
ADDR_ASSERT(localIn.mipLevel == 0);
245
if (localIn.format != ADDR_FMT_INVALID) // Set format to INVALID will skip this conversion
247
// Get compression/expansion factors and element mode
248
// (which indicates compression/expansion
249
localIn.bpp = GetElemLib()->GetBitsPerPixel(localIn.format,
254
// Special flag for 96 bit surface. 96 (or 48 if we support) bit surface's width is
255
// pre-multiplied by 3 and bpp is divided by 3. So pitch alignment for linear-
256
// aligned does not meet 64-pixel in real. We keep special handling in hwl since hw
257
// restrictions are different.
258
// Also Mip 1+ needs an element pitch of 32 bits so we do not need this workaround
259
// but we use this flag to skip RestoreSurfaceInfo below
261
if ((elemMode == ADDR_EXPANDED) && (expandX > 1))
263
ADDR_ASSERT(IsLinear(localIn.tileMode));
266
GetElemLib()->AdjustSurfaceInfo(elemMode,
274
// Overwrite these parameters if we have a valid format
276
else if (localIn.bpp != 0)
278
localIn.width = (localIn.width != 0) ? localIn.width : 1;
279
localIn.height = (localIn.height != 0) ? localIn.height : 1;
281
else // Rule out some invalid parameters
283
ADDR_ASSERT_ALWAYS();
285
returnCode = ADDR_INVALIDPARAMS;
288
// Check mipmap after surface expansion
289
if (returnCode == ADDR_OK)
291
returnCode = PostComputeMipLevel(&localIn, pOut);
294
if (returnCode == ADDR_OK)
296
if (UseTileIndex(localIn.tileIndex))
298
// Make sure pTileInfo is not NULL
299
ADDR_ASSERT(localIn.pTileInfo);
301
UINT_32 numSamples = GetNumFragments(localIn.numSamples, localIn.numFrags);
303
INT_32 macroModeIndex = TileIndexNoMacroIndex;
305
if (localIn.tileIndex != TileIndexLinearGeneral)
307
// Try finding a macroModeIndex
308
macroModeIndex = HwlComputeMacroModeIndex(localIn.tileIndex,
317
// If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
318
if (macroModeIndex == TileIndexNoMacroIndex)
320
returnCode = HwlSetupTileCfg(localIn.bpp,
321
localIn.tileIndex, macroModeIndex,
323
&localIn.tileMode, &localIn.tileType);
325
// If macroModeIndex is invalid, then assert this is not macro tiled
326
else if (macroModeIndex == TileIndexInvalid)
328
ADDR_ASSERT(!IsMacroTiled(localIn.tileMode));
331
pOut->macroModeIndex = macroModeIndex;
335
if (returnCode == ADDR_OK)
337
localIn.flags.dccPipeWorkaround = localIn.flags.dccCompatible;
339
if (localIn.tileMode == ADDR_TM_UNKNOWN)
341
// HWL layer may override tile mode if necessary
342
HwlSelectTileMode(&localIn);
346
// HWL layer may override tile mode if necessary
347
HwlOverrideTileMode(&localIn);
349
// Optimize tile mode if possible
350
OptimizeTileMode(&localIn);
354
// Call main function to compute surface info
355
if (returnCode == ADDR_OK)
357
returnCode = HwlComputeSurfaceInfo(&localIn, pOut);
360
if (returnCode == ADDR_OK)
362
// Since bpp might be changed we just pass it through
363
pOut->bpp = localIn.bpp;
365
// Also original width/height/bpp
366
pOut->pixelPitch = pOut->pitch;
367
pOut->pixelHeight = pOut->height;
370
if (localIn.flags.display)
372
ADDR_ASSERT((pOut->pitchAlign % 32) == 0);
376
if (localIn.format != ADDR_FMT_INVALID)
379
// Note: For 96 bit surface, the pixelPitch returned might be an odd number, but it
380
// is okay to program texture pitch as HW's mip calculator would multiply 3 first,
381
// then do the appropriate paddings (linear alignment requirement and possible the
382
// nearest power-of-two for mipmaps), which results in the original pitch.
384
GetElemLib()->RestoreSurfaceInfo(elemMode,
392
if (localIn.flags.qbStereo)
394
if (pOut->pStereoInfo)
396
ComputeQbStereoInfo(pOut);
400
if (localIn.flags.volume) // For volume sliceSize equals to all z-slices
402
pOut->sliceSize = pOut->surfSize;
404
else // For array: sliceSize is likely to have slice-padding (the last one)
406
pOut->sliceSize = pOut->surfSize / pOut->depth;
409
if (pIn->numSlices > 1)
411
// If this is the last slice then add the padding size to this slice
412
if (pIn->slice == (pIn->numSlices - 1))
414
pOut->sliceSize += pOut->sliceSize * (pOut->depth - pIn->numSlices);
416
else if (m_configFlags.checkLast2DLevel)
418
// Reset last2DLevel flag if this is not the last array slice
419
pOut->last2DLevel = FALSE;
424
pOut->pitchTileMax = pOut->pitch / 8 - 1;
425
pOut->heightTileMax = pOut->height / 8 - 1;
426
pOut->sliceTileMax = pOut->pitch * pOut->height / 64 - 1;
430
ValidBaseAlignments(pOut->baseAlign);
436
****************************************************************************************************
437
* Lib::ComputeSurfaceInfo
440
* Interface function stub of AddrComputeSurfaceInfo.
444
****************************************************************************************************
446
ADDR_E_RETURNCODE Lib::ComputeSurfaceAddrFromCoord(
447
const ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn, ///< [in] input structure
448
ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT* pOut ///< [out] output structure
451
ADDR_E_RETURNCODE returnCode = ADDR_OK;
453
if (GetFillSizeFieldsFlags() == TRUE)
455
if ((pIn->size != sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT)) ||
456
(pOut->size != sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT)))
458
returnCode = ADDR_PARAMSIZEMISMATCH;
462
if (returnCode == ADDR_OK)
464
ADDR_TILEINFO tileInfoNull;
465
ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT input;
467
if (UseTileIndex(pIn->tileIndex))
470
// Use temp tile info for calcalation
471
input.pTileInfo = &tileInfoNull;
473
const ADDR_SURFACE_FLAGS flags = {{0}};
474
UINT_32 numSamples = GetNumFragments(pIn->numSamples, pIn->numFrags);
476
// Try finding a macroModeIndex
477
INT_32 macroModeIndex = HwlComputeMacroModeIndex(input.tileIndex,
485
// If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
486
if (macroModeIndex == TileIndexNoMacroIndex)
488
returnCode = HwlSetupTileCfg(input.bpp, input.tileIndex, macroModeIndex,
489
input.pTileInfo, &input.tileMode, &input.tileType);
491
// If macroModeIndex is invalid, then assert this is not macro tiled
492
else if (macroModeIndex == TileIndexInvalid)
494
ADDR_ASSERT(!IsMacroTiled(input.tileMode));
497
// Change the input structure
501
if (returnCode == ADDR_OK)
503
returnCode = HwlComputeSurfaceAddrFromCoord(pIn, pOut);
505
if (returnCode == ADDR_OK)
507
pOut->prtBlockIndex = static_cast<UINT_32>(pOut->addr / (64 * 1024));
516
****************************************************************************************************
517
* Lib::ComputeSurfaceCoordFromAddr
520
* Interface function stub of ComputeSurfaceCoordFromAddr.
524
****************************************************************************************************
526
ADDR_E_RETURNCODE Lib::ComputeSurfaceCoordFromAddr(
527
const ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT* pIn, ///< [in] input structure
528
ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT* pOut ///< [out] output structure
531
ADDR_E_RETURNCODE returnCode = ADDR_OK;
533
if (GetFillSizeFieldsFlags() == TRUE)
535
if ((pIn->size != sizeof(ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT)) ||
536
(pOut->size != sizeof(ADDR_COMPUTE_SURFACE_COORDFROMADDR_OUTPUT)))
538
returnCode = ADDR_PARAMSIZEMISMATCH;
542
if (returnCode == ADDR_OK)
544
ADDR_TILEINFO tileInfoNull;
545
ADDR_COMPUTE_SURFACE_COORDFROMADDR_INPUT input;
547
if (UseTileIndex(pIn->tileIndex))
550
// Use temp tile info for calcalation
551
input.pTileInfo = &tileInfoNull;
553
const ADDR_SURFACE_FLAGS flags = {{0}};
554
UINT_32 numSamples = GetNumFragments(pIn->numSamples, pIn->numFrags);
556
// Try finding a macroModeIndex
557
INT_32 macroModeIndex = HwlComputeMacroModeIndex(input.tileIndex,
565
// If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
566
if (macroModeIndex == TileIndexNoMacroIndex)
568
returnCode = HwlSetupTileCfg(input.bpp, input.tileIndex, macroModeIndex,
569
input.pTileInfo, &input.tileMode, &input.tileType);
571
// If macroModeIndex is invalid, then assert this is not macro tiled
572
else if (macroModeIndex == TileIndexInvalid)
574
ADDR_ASSERT(!IsMacroTiled(input.tileMode));
577
// Change the input structure
581
if (returnCode == ADDR_OK)
583
returnCode = HwlComputeSurfaceCoordFromAddr(pIn, pOut);
591
****************************************************************************************************
592
* Lib::ComputeSliceTileSwizzle
595
* Interface function stub of ComputeSliceTileSwizzle.
599
****************************************************************************************************
601
ADDR_E_RETURNCODE Lib::ComputeSliceTileSwizzle(
602
const ADDR_COMPUTE_SLICESWIZZLE_INPUT* pIn, ///< [in] input structure
603
ADDR_COMPUTE_SLICESWIZZLE_OUTPUT* pOut ///< [out] output structure
606
ADDR_E_RETURNCODE returnCode = ADDR_OK;
608
if (GetFillSizeFieldsFlags() == TRUE)
610
if ((pIn->size != sizeof(ADDR_COMPUTE_SLICESWIZZLE_INPUT)) ||
611
(pOut->size != sizeof(ADDR_COMPUTE_SLICESWIZZLE_OUTPUT)))
613
returnCode = ADDR_PARAMSIZEMISMATCH;
617
if (returnCode == ADDR_OK)
619
ADDR_TILEINFO tileInfoNull;
620
ADDR_COMPUTE_SLICESWIZZLE_INPUT input;
622
if (UseTileIndex(pIn->tileIndex))
625
// Use temp tile info for calcalation
626
input.pTileInfo = &tileInfoNull;
628
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex,
629
input.pTileInfo, &input.tileMode);
630
// Change the input structure
634
if (returnCode == ADDR_OK)
636
returnCode = HwlComputeSliceTileSwizzle(pIn, pOut);
644
****************************************************************************************************
645
* Lib::ExtractBankPipeSwizzle
648
* Interface function stub of AddrExtractBankPipeSwizzle.
652
****************************************************************************************************
654
ADDR_E_RETURNCODE Lib::ExtractBankPipeSwizzle(
655
const ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT* pIn, ///< [in] input structure
656
ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT* pOut ///< [out] output structure
659
ADDR_E_RETURNCODE returnCode = ADDR_OK;
661
if (GetFillSizeFieldsFlags() == TRUE)
663
if ((pIn->size != sizeof(ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT)) ||
664
(pOut->size != sizeof(ADDR_EXTRACT_BANKPIPE_SWIZZLE_OUTPUT)))
666
returnCode = ADDR_PARAMSIZEMISMATCH;
670
if (returnCode == ADDR_OK)
672
ADDR_TILEINFO tileInfoNull;
673
ADDR_EXTRACT_BANKPIPE_SWIZZLE_INPUT input;
675
if (UseTileIndex(pIn->tileIndex))
678
// Use temp tile info for calcalation
679
input.pTileInfo = &tileInfoNull;
681
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex, input.pTileInfo);
682
// Change the input structure
686
if (returnCode == ADDR_OK)
688
returnCode = HwlExtractBankPipeSwizzle(pIn, pOut);
696
****************************************************************************************************
697
* Lib::CombineBankPipeSwizzle
700
* Interface function stub of AddrCombineBankPipeSwizzle.
704
****************************************************************************************************
706
ADDR_E_RETURNCODE Lib::CombineBankPipeSwizzle(
707
const ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT* pIn, ///< [in] input structure
708
ADDR_COMBINE_BANKPIPE_SWIZZLE_OUTPUT* pOut ///< [out] output structure
711
ADDR_E_RETURNCODE returnCode = ADDR_OK;
713
if (GetFillSizeFieldsFlags() == TRUE)
715
if ((pIn->size != sizeof(ADDR_COMPUTE_FMASK_INFO_INPUT)) ||
716
(pOut->size != sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT)))
718
returnCode = ADDR_PARAMSIZEMISMATCH;
722
if (returnCode == ADDR_OK)
724
ADDR_TILEINFO tileInfoNull;
725
ADDR_COMBINE_BANKPIPE_SWIZZLE_INPUT input;
727
if (UseTileIndex(pIn->tileIndex))
730
// Use temp tile info for calcalation
731
input.pTileInfo = &tileInfoNull;
733
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex, input.pTileInfo);
734
// Change the input structure
738
if (returnCode == ADDR_OK)
740
returnCode = HwlCombineBankPipeSwizzle(pIn->bankSwizzle,
752
****************************************************************************************************
753
* Lib::ComputeBaseSwizzle
756
* Interface function stub of AddrCompueBaseSwizzle.
759
****************************************************************************************************
761
ADDR_E_RETURNCODE Lib::ComputeBaseSwizzle(
762
const ADDR_COMPUTE_BASE_SWIZZLE_INPUT* pIn,
763
ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT* pOut) const
765
ADDR_E_RETURNCODE returnCode = ADDR_OK;
767
if (GetFillSizeFieldsFlags() == TRUE)
769
if ((pIn->size != sizeof(ADDR_COMPUTE_BASE_SWIZZLE_INPUT)) ||
770
(pOut->size != sizeof(ADDR_COMPUTE_BASE_SWIZZLE_OUTPUT)))
772
returnCode = ADDR_PARAMSIZEMISMATCH;
776
if (returnCode == ADDR_OK)
778
ADDR_TILEINFO tileInfoNull;
779
ADDR_COMPUTE_BASE_SWIZZLE_INPUT input;
781
if (UseTileIndex(pIn->tileIndex))
784
// Use temp tile info for calcalation
785
input.pTileInfo = &tileInfoNull;
787
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex, input.pTileInfo);
788
// Change the input structure
792
if (returnCode == ADDR_OK)
794
if (IsMacroTiled(pIn->tileMode))
796
returnCode = HwlComputeBaseSwizzle(pIn, pOut);
800
pOut->tileSwizzle = 0;
809
****************************************************************************************************
810
* Lib::ComputeFmaskInfo
813
* Interface function stub of ComputeFmaskInfo.
817
****************************************************************************************************
819
ADDR_E_RETURNCODE Lib::ComputeFmaskInfo(
820
const ADDR_COMPUTE_FMASK_INFO_INPUT* pIn, ///< [in] input structure
821
ADDR_COMPUTE_FMASK_INFO_OUTPUT* pOut ///< [out] output structure
824
ADDR_E_RETURNCODE returnCode = ADDR_OK;
826
if (GetFillSizeFieldsFlags() == TRUE)
828
if ((pIn->size != sizeof(ADDR_COMPUTE_FMASK_INFO_INPUT)) ||
829
(pOut->size != sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT)))
831
returnCode = ADDR_PARAMSIZEMISMATCH;
836
if (Thickness(pIn->tileMode) > 1)
838
returnCode = ADDR_INVALIDPARAMS;
841
if (returnCode == ADDR_OK)
843
ADDR_TILEINFO tileInfoNull;
844
ADDR_COMPUTE_FMASK_INFO_INPUT input;
846
if (UseTileIndex(pIn->tileIndex))
852
// Use temp tile info for calcalation
853
input.pTileInfo = pOut->pTileInfo;
857
input.pTileInfo = &tileInfoNull;
860
ADDR_SURFACE_FLAGS flags = {{0}};
863
// Try finding a macroModeIndex
864
INT_32 macroModeIndex = HwlComputeMacroModeIndex(pIn->tileIndex,
866
HwlComputeFmaskBits(pIn, NULL),
871
// If macroModeIndex is not needed, then call HwlSetupTileCfg to get tile info
872
if (macroModeIndex == TileIndexNoMacroIndex)
874
returnCode = HwlSetupTileCfg(0, input.tileIndex, macroModeIndex,
875
input.pTileInfo, &input.tileMode);
878
ADDR_ASSERT(macroModeIndex != TileIndexInvalid);
880
// Change the input structure
884
if (returnCode == ADDR_OK)
886
if (pIn->numSamples > 1)
888
returnCode = HwlComputeFmaskInfo(pIn, pOut);
892
memset(pOut, 0, sizeof(ADDR_COMPUTE_FMASK_INFO_OUTPUT));
894
returnCode = ADDR_INVALIDPARAMS;
899
ValidBaseAlignments(pOut->baseAlign);
905
****************************************************************************************************
906
* Lib::ComputeFmaskAddrFromCoord
909
* Interface function stub of ComputeFmaskAddrFromCoord.
913
****************************************************************************************************
915
ADDR_E_RETURNCODE Lib::ComputeFmaskAddrFromCoord(
916
const ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT* pIn, ///< [in] input structure
917
ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT* pOut ///< [out] output structure
920
ADDR_E_RETURNCODE returnCode = ADDR_OK;
922
if (GetFillSizeFieldsFlags() == TRUE)
924
if ((pIn->size != sizeof(ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT)) ||
925
(pOut->size != sizeof(ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT)))
927
returnCode = ADDR_PARAMSIZEMISMATCH;
931
if (returnCode == ADDR_OK)
933
ADDR_ASSERT(pIn->numSamples > 1);
935
if (pIn->numSamples > 1)
937
returnCode = HwlComputeFmaskAddrFromCoord(pIn, pOut);
941
returnCode = ADDR_INVALIDPARAMS;
949
****************************************************************************************************
950
* Lib::ComputeFmaskCoordFromAddr
953
* Interface function stub of ComputeFmaskAddrFromCoord.
957
****************************************************************************************************
959
ADDR_E_RETURNCODE Lib::ComputeFmaskCoordFromAddr(
960
const ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT* pIn, ///< [in] input structure
961
ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT* pOut ///< [out] output structure
964
ADDR_E_RETURNCODE returnCode = ADDR_OK;
966
if (GetFillSizeFieldsFlags() == TRUE)
968
if ((pIn->size != sizeof(ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT)) ||
969
(pOut->size != sizeof(ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT)))
971
returnCode = ADDR_PARAMSIZEMISMATCH;
975
if (returnCode == ADDR_OK)
977
ADDR_ASSERT(pIn->numSamples > 1);
979
if (pIn->numSamples > 1)
981
returnCode = HwlComputeFmaskCoordFromAddr(pIn, pOut);
985
returnCode = ADDR_INVALIDPARAMS;
993
****************************************************************************************************
994
* Lib::ConvertTileInfoToHW
997
* Convert tile info from real value to HW register value in HW layer
1001
****************************************************************************************************
1003
ADDR_E_RETURNCODE Lib::ConvertTileInfoToHW(
1004
const ADDR_CONVERT_TILEINFOTOHW_INPUT* pIn, ///< [in] input structure
1005
ADDR_CONVERT_TILEINFOTOHW_OUTPUT* pOut ///< [out] output structure
1008
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1010
if (GetFillSizeFieldsFlags() == TRUE)
1012
if ((pIn->size != sizeof(ADDR_CONVERT_TILEINFOTOHW_INPUT)) ||
1013
(pOut->size != sizeof(ADDR_CONVERT_TILEINFOTOHW_OUTPUT)))
1015
returnCode = ADDR_PARAMSIZEMISMATCH;
1019
if (returnCode == ADDR_OK)
1021
ADDR_TILEINFO tileInfoNull;
1022
ADDR_CONVERT_TILEINFOTOHW_INPUT input;
1023
// if pIn->reverse is TRUE, indices are ignored
1024
if (pIn->reverse == FALSE && UseTileIndex(pIn->tileIndex))
1027
input.pTileInfo = &tileInfoNull;
1029
returnCode = HwlSetupTileCfg(input.bpp, input.tileIndex,
1030
input.macroModeIndex, input.pTileInfo);
1035
if (returnCode == ADDR_OK)
1037
returnCode = HwlConvertTileInfoToHW(pIn, pOut);
1045
****************************************************************************************************
1046
* Lib::ConvertTileIndex
1049
* Convert tile index to tile mode/type/info
1053
****************************************************************************************************
1055
ADDR_E_RETURNCODE Lib::ConvertTileIndex(
1056
const ADDR_CONVERT_TILEINDEX_INPUT* pIn, ///< [in] input structure
1057
ADDR_CONVERT_TILEINDEX_OUTPUT* pOut ///< [out] output structure
1060
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1062
if (GetFillSizeFieldsFlags() == TRUE)
1064
if ((pIn->size != sizeof(ADDR_CONVERT_TILEINDEX_INPUT)) ||
1065
(pOut->size != sizeof(ADDR_CONVERT_TILEINDEX_OUTPUT)))
1067
returnCode = ADDR_PARAMSIZEMISMATCH;
1071
if (returnCode == ADDR_OK)
1074
returnCode = HwlSetupTileCfg(pIn->bpp, pIn->tileIndex, pIn->macroModeIndex,
1075
pOut->pTileInfo, &pOut->tileMode, &pOut->tileType);
1077
if (returnCode == ADDR_OK && pIn->tileInfoHw)
1079
ADDR_CONVERT_TILEINFOTOHW_INPUT hwInput = {0};
1080
ADDR_CONVERT_TILEINFOTOHW_OUTPUT hwOutput = {0};
1082
hwInput.pTileInfo = pOut->pTileInfo;
1083
hwInput.tileIndex = -1;
1084
hwOutput.pTileInfo = pOut->pTileInfo;
1086
returnCode = HwlConvertTileInfoToHW(&hwInput, &hwOutput);
1094
****************************************************************************************************
1095
* Lib::GetMacroModeIndex
1098
* Get macro mode index based on input info
1102
****************************************************************************************************
1104
ADDR_E_RETURNCODE Lib::GetMacroModeIndex(
1105
const ADDR_GET_MACROMODEINDEX_INPUT* pIn, ///< [in] input structure
1106
ADDR_GET_MACROMODEINDEX_OUTPUT* pOut ///< [out] output structure
1109
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1111
if (GetFillSizeFieldsFlags())
1113
if ((pIn->size != sizeof(ADDR_GET_MACROMODEINDEX_INPUT)) ||
1114
(pOut->size != sizeof(ADDR_GET_MACROMODEINDEX_OUTPUT)))
1116
returnCode = ADDR_PARAMSIZEMISMATCH;
1120
if (returnCode == ADDR_OK)
1122
ADDR_TILEINFO tileInfo = {0};
1123
pOut->macroModeIndex = HwlComputeMacroModeIndex(pIn->tileIndex, pIn->flags, pIn->bpp,
1124
pIn->numFrags, &tileInfo);
1131
****************************************************************************************************
1132
* Lib::ConvertTileIndex1
1135
* Convert tile index to tile mode/type/info
1139
****************************************************************************************************
1141
ADDR_E_RETURNCODE Lib::ConvertTileIndex1(
1142
const ADDR_CONVERT_TILEINDEX1_INPUT* pIn, ///< [in] input structure
1143
ADDR_CONVERT_TILEINDEX_OUTPUT* pOut ///< [out] output structure
1146
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1148
if (GetFillSizeFieldsFlags() == TRUE)
1150
if ((pIn->size != sizeof(ADDR_CONVERT_TILEINDEX1_INPUT)) ||
1151
(pOut->size != sizeof(ADDR_CONVERT_TILEINDEX_OUTPUT)))
1153
returnCode = ADDR_PARAMSIZEMISMATCH;
1157
if (returnCode == ADDR_OK)
1159
ADDR_SURFACE_FLAGS flags = {{0}};
1161
HwlComputeMacroModeIndex(pIn->tileIndex, flags, pIn->bpp, pIn->numSamples,
1162
pOut->pTileInfo, &pOut->tileMode, &pOut->tileType);
1164
if (pIn->tileInfoHw)
1166
ADDR_CONVERT_TILEINFOTOHW_INPUT hwInput = {0};
1167
ADDR_CONVERT_TILEINFOTOHW_OUTPUT hwOutput = {0};
1169
hwInput.pTileInfo = pOut->pTileInfo;
1170
hwInput.tileIndex = -1;
1171
hwOutput.pTileInfo = pOut->pTileInfo;
1173
returnCode = HwlConvertTileInfoToHW(&hwInput, &hwOutput);
1181
****************************************************************************************************
1185
* Get tile index from tile mode/type/info
1189
****************************************************************************************************
1191
ADDR_E_RETURNCODE Lib::GetTileIndex(
1192
const ADDR_GET_TILEINDEX_INPUT* pIn, ///< [in] input structure
1193
ADDR_GET_TILEINDEX_OUTPUT* pOut ///< [out] output structure
1196
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1198
if (GetFillSizeFieldsFlags() == TRUE)
1200
if ((pIn->size != sizeof(ADDR_GET_TILEINDEX_INPUT)) ||
1201
(pOut->size != sizeof(ADDR_GET_TILEINDEX_OUTPUT)))
1203
returnCode = ADDR_PARAMSIZEMISMATCH;
1207
if (returnCode == ADDR_OK)
1209
returnCode = HwlGetTileIndex(pIn, pOut);
1216
****************************************************************************************************
1220
* Get tile mode thickness
1223
* Tile mode thickness
1224
****************************************************************************************************
1226
UINT_32 Lib::Thickness(
1227
AddrTileMode tileMode) ///< [in] tile mode
1229
return ModeFlags[tileMode].thickness;
1234
////////////////////////////////////////////////////////////////////////////////////////////////////
1236
////////////////////////////////////////////////////////////////////////////////////////////////////
1239
****************************************************************************************************
1240
* Lib::ComputeHtileInfo
1243
* Interface function stub of AddrComputeHtilenfo
1247
****************************************************************************************************
1249
ADDR_E_RETURNCODE Lib::ComputeHtileInfo(
1250
const ADDR_COMPUTE_HTILE_INFO_INPUT* pIn, ///< [in] input structure
1251
ADDR_COMPUTE_HTILE_INFO_OUTPUT* pOut ///< [out] output structure
1254
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1256
BOOL_32 isWidth8 = (pIn->blockWidth == 8) ? TRUE : FALSE;
1257
BOOL_32 isHeight8 = (pIn->blockHeight == 8) ? TRUE : FALSE;
1259
if (GetFillSizeFieldsFlags() == TRUE)
1261
if ((pIn->size != sizeof(ADDR_COMPUTE_HTILE_INFO_INPUT)) ||
1262
(pOut->size != sizeof(ADDR_COMPUTE_HTILE_INFO_OUTPUT)))
1264
returnCode = ADDR_PARAMSIZEMISMATCH;
1268
if (returnCode == ADDR_OK)
1270
ADDR_TILEINFO tileInfoNull;
1271
ADDR_COMPUTE_HTILE_INFO_INPUT input;
1273
if (UseTileIndex(pIn->tileIndex))
1276
// Use temp tile info for calcalation
1277
input.pTileInfo = &tileInfoNull;
1279
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex, input.pTileInfo);
1281
// Change the input structure
1285
if (returnCode == ADDR_OK)
1287
if (pIn->flags.tcCompatible)
1289
const UINT_32 sliceSize = pIn->pitch * pIn->height * 4 / (8 * 8);
1290
const UINT_32 align = HwlGetPipes(pIn->pTileInfo) * pIn->pTileInfo->banks * m_pipeInterleaveBytes;
1292
if (pIn->numSlices > 1)
1294
const UINT_32 surfBytes = (sliceSize * pIn->numSlices);
1296
pOut->sliceSize = sliceSize;
1297
pOut->htileBytes = pIn->flags.skipTcCompatSizeAlign ?
1298
surfBytes : PowTwoAlign(surfBytes, align);
1299
pOut->sliceInterleaved = ((sliceSize % align) != 0) ? TRUE : FALSE;
1303
pOut->sliceSize = pIn->flags.skipTcCompatSizeAlign ?
1304
sliceSize : PowTwoAlign(sliceSize, align);
1305
pOut->htileBytes = pOut->sliceSize;
1306
pOut->sliceInterleaved = FALSE;
1309
pOut->nextMipLevelCompressible = ((sliceSize % align) == 0) ? TRUE : FALSE;
1311
pOut->pitch = pIn->pitch;
1312
pOut->height = pIn->height;
1313
pOut->baseAlign = align;
1314
pOut->macroWidth = 0;
1315
pOut->macroHeight = 0;
1320
pOut->bpp = ComputeHtileInfo(pIn->flags,
1339
ValidMetaBaseAlignments(pOut->baseAlign);
1345
****************************************************************************************************
1346
* Lib::ComputeCmaskInfo
1349
* Interface function stub of AddrComputeCmaskInfo
1353
****************************************************************************************************
1355
ADDR_E_RETURNCODE Lib::ComputeCmaskInfo(
1356
const ADDR_COMPUTE_CMASK_INFO_INPUT* pIn, ///< [in] input structure
1357
ADDR_COMPUTE_CMASK_INFO_OUTPUT* pOut ///< [out] output structure
1360
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1362
if (GetFillSizeFieldsFlags() == TRUE)
1364
if ((pIn->size != sizeof(ADDR_COMPUTE_CMASK_INFO_INPUT)) ||
1365
(pOut->size != sizeof(ADDR_COMPUTE_CMASK_INFO_OUTPUT)))
1367
returnCode = ADDR_PARAMSIZEMISMATCH;
1371
if (returnCode == ADDR_OK)
1373
ADDR_TILEINFO tileInfoNull;
1374
ADDR_COMPUTE_CMASK_INFO_INPUT input;
1376
if (UseTileIndex(pIn->tileIndex))
1379
// Use temp tile info for calcalation
1380
input.pTileInfo = &tileInfoNull;
1382
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex, input.pTileInfo);
1384
// Change the input structure
1388
if (returnCode == ADDR_OK)
1390
returnCode = ComputeCmaskInfo(pIn->flags,
1407
ValidMetaBaseAlignments(pOut->baseAlign);
1413
****************************************************************************************************
1414
* Lib::ComputeDccInfo
1417
* Interface function to compute DCC key info
1420
* return code of HwlComputeDccInfo
1421
****************************************************************************************************
1423
ADDR_E_RETURNCODE Lib::ComputeDccInfo(
1424
const ADDR_COMPUTE_DCCINFO_INPUT* pIn, ///< [in] input structure
1425
ADDR_COMPUTE_DCCINFO_OUTPUT* pOut ///< [out] output structure
1428
ADDR_E_RETURNCODE ret = ADDR_OK;
1430
if (GetFillSizeFieldsFlags() == TRUE)
1432
if ((pIn->size != sizeof(ADDR_COMPUTE_DCCINFO_INPUT)) ||
1433
(pOut->size != sizeof(ADDR_COMPUTE_DCCINFO_OUTPUT)))
1435
ret = ADDR_PARAMSIZEMISMATCH;
1441
ADDR_COMPUTE_DCCINFO_INPUT input;
1443
if (UseTileIndex(pIn->tileIndex))
1447
ret = HwlSetupTileCfg(input.bpp, input.tileIndex, input.macroModeIndex,
1448
&input.tileInfo, &input.tileMode);
1455
ret = HwlComputeDccInfo(pIn, pOut);
1457
ValidMetaBaseAlignments(pOut->dccRamBaseAlign);
1465
****************************************************************************************************
1466
* Lib::ComputeHtileAddrFromCoord
1469
* Interface function stub of AddrComputeHtileAddrFromCoord
1473
****************************************************************************************************
1475
ADDR_E_RETURNCODE Lib::ComputeHtileAddrFromCoord(
1476
const ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT* pIn, ///< [in] input structure
1477
ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT* pOut ///< [out] output structure
1480
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1482
BOOL_32 isWidth8 = (pIn->blockWidth == 8) ? TRUE : FALSE;
1483
BOOL_32 isHeight8 = (pIn->blockHeight == 8) ? TRUE : FALSE;
1485
if (GetFillSizeFieldsFlags() == TRUE)
1487
if ((pIn->size != sizeof(ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT)) ||
1488
(pOut->size != sizeof(ADDR_COMPUTE_HTILE_ADDRFROMCOORD_OUTPUT)))
1490
returnCode = ADDR_PARAMSIZEMISMATCH;
1494
if (returnCode == ADDR_OK)
1496
ADDR_TILEINFO tileInfoNull;
1497
ADDR_COMPUTE_HTILE_ADDRFROMCOORD_INPUT input;
1499
if (UseTileIndex(pIn->tileIndex))
1502
// Use temp tile info for calcalation
1503
input.pTileInfo = &tileInfoNull;
1505
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex, input.pTileInfo);
1507
// Change the input structure
1511
if (returnCode == ADDR_OK)
1513
if (pIn->flags.tcCompatible)
1515
HwlComputeHtileAddrFromCoord(pIn, pOut);
1519
pOut->addr = HwlComputeXmaskAddrFromCoord(pIn->pitch,
1530
&pOut->bitPosition);
1540
****************************************************************************************************
1541
* Lib::ComputeHtileCoordFromAddr
1544
* Interface function stub of AddrComputeHtileCoordFromAddr
1548
****************************************************************************************************
1550
ADDR_E_RETURNCODE Lib::ComputeHtileCoordFromAddr(
1551
const ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT* pIn, ///< [in] input structure
1552
ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT* pOut ///< [out] output structure
1555
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1557
BOOL_32 isWidth8 = (pIn->blockWidth == 8) ? TRUE : FALSE;
1558
BOOL_32 isHeight8 = (pIn->blockHeight == 8) ? TRUE : FALSE;
1560
if (GetFillSizeFieldsFlags() == TRUE)
1562
if ((pIn->size != sizeof(ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT)) ||
1563
(pOut->size != sizeof(ADDR_COMPUTE_HTILE_COORDFROMADDR_OUTPUT)))
1565
returnCode = ADDR_PARAMSIZEMISMATCH;
1569
if (returnCode == ADDR_OK)
1571
ADDR_TILEINFO tileInfoNull;
1572
ADDR_COMPUTE_HTILE_COORDFROMADDR_INPUT input;
1574
if (UseTileIndex(pIn->tileIndex))
1577
// Use temp tile info for calcalation
1578
input.pTileInfo = &tileInfoNull;
1580
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex, input.pTileInfo);
1582
// Change the input structure
1586
if (returnCode == ADDR_OK)
1588
HwlComputeXmaskCoordFromAddr(pIn->addr,
1608
****************************************************************************************************
1609
* Lib::ComputeCmaskAddrFromCoord
1612
* Interface function stub of AddrComputeCmaskAddrFromCoord
1616
****************************************************************************************************
1618
ADDR_E_RETURNCODE Lib::ComputeCmaskAddrFromCoord(
1619
const ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT* pIn, ///< [in] input structure
1620
ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT* pOut ///< [out] output structure
1623
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1625
if (GetFillSizeFieldsFlags() == TRUE)
1627
if ((pIn->size != sizeof(ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT)) ||
1628
(pOut->size != sizeof(ADDR_COMPUTE_CMASK_ADDRFROMCOORD_OUTPUT)))
1630
returnCode = ADDR_PARAMSIZEMISMATCH;
1634
if (returnCode == ADDR_OK)
1636
ADDR_TILEINFO tileInfoNull;
1637
ADDR_COMPUTE_CMASK_ADDRFROMCOORD_INPUT input;
1639
if (UseTileIndex(pIn->tileIndex))
1642
// Use temp tile info for calcalation
1643
input.pTileInfo = &tileInfoNull;
1645
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex, input.pTileInfo);
1647
// Change the input structure
1651
if (returnCode == ADDR_OK)
1653
if (pIn->flags.tcCompatible == TRUE)
1655
returnCode = HwlComputeCmaskAddrFromCoord(pIn, pOut);
1659
pOut->addr = HwlComputeXmaskAddrFromCoord(pIn->pitch,
1667
FALSE, //this is cmask, isWidth8 is not needed
1668
FALSE, //this is cmask, isHeight8 is not needed
1670
&pOut->bitPosition);
1680
****************************************************************************************************
1681
* Lib::ComputeCmaskCoordFromAddr
1684
* Interface function stub of AddrComputeCmaskCoordFromAddr
1688
****************************************************************************************************
1690
ADDR_E_RETURNCODE Lib::ComputeCmaskCoordFromAddr(
1691
const ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT* pIn, ///< [in] input structure
1692
ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT* pOut ///< [out] output structure
1695
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1697
if (GetFillSizeFieldsFlags() == TRUE)
1699
if ((pIn->size != sizeof(ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT)) ||
1700
(pOut->size != sizeof(ADDR_COMPUTE_CMASK_COORDFROMADDR_OUTPUT)))
1702
returnCode = ADDR_PARAMSIZEMISMATCH;
1706
if (returnCode == ADDR_OK)
1708
ADDR_TILEINFO tileInfoNull;
1709
ADDR_COMPUTE_CMASK_COORDFROMADDR_INPUT input;
1711
if (UseTileIndex(pIn->tileIndex))
1714
// Use temp tile info for calcalation
1715
input.pTileInfo = &tileInfoNull;
1717
returnCode = HwlSetupTileCfg(0, input.tileIndex, input.macroModeIndex, input.pTileInfo);
1719
// Change the input structure
1723
if (returnCode == ADDR_OK)
1725
HwlComputeXmaskCoordFromAddr(pIn->addr,
1745
****************************************************************************************************
1746
* Lib::ComputeTileDataWidthAndHeight
1749
* Compute the squared cache shape for per-tile data (CMASK and HTILE)
1755
* MacroWidth and macroHeight are measured in pixels
1756
****************************************************************************************************
1758
VOID Lib::ComputeTileDataWidthAndHeight(
1759
UINT_32 bpp, ///< [in] bits per pixel
1760
UINT_32 cacheBits, ///< [in] bits of cache
1761
ADDR_TILEINFO* pTileInfo, ///< [in] Tile info
1762
UINT_32* pMacroWidth, ///< [out] macro tile width
1763
UINT_32* pMacroHeight ///< [out] macro tile height
1767
UINT_32 width = cacheBits / bpp;
1768
UINT_32 pipes = HwlGetPipes(pTileInfo);
1770
// Double height until the macro-tile is close to square
1771
// Height can only be doubled if width is even
1773
while ((width > height * 2 * pipes) && !(width & 1))
1779
*pMacroWidth = 8 * width;
1780
*pMacroHeight = 8 * height * pipes;
1782
// Note: The above iterative comptuation is equivalent to the following
1784
//int log2_height = ((log2(cacheBits)-log2(bpp)-log2(pipes))/2);
1785
//int macroHeight = pow2( 3+log2(pipes)+log2_height );
1789
****************************************************************************************************
1790
* Lib::HwlComputeTileDataWidthAndHeightLinear
1793
* Compute the squared cache shape for per-tile data (CMASK and HTILE) for linear layout
1799
* MacroWidth and macroHeight are measured in pixels
1800
****************************************************************************************************
1802
VOID Lib::HwlComputeTileDataWidthAndHeightLinear(
1803
UINT_32* pMacroWidth, ///< [out] macro tile width
1804
UINT_32* pMacroHeight, ///< [out] macro tile height
1805
UINT_32 bpp, ///< [in] bits per pixel
1806
ADDR_TILEINFO* pTileInfo ///< [in] tile info
1809
ADDR_ASSERT(bpp != 4); // Cmask does not support linear layout prior to SI
1810
*pMacroWidth = 8 * 512 / bpp; // Align width to 512-bit memory accesses
1811
*pMacroHeight = 8 * m_pipes; // Align height to number of pipes
1815
****************************************************************************************************
1816
* Lib::ComputeHtileInfo
1819
* Compute htile pitch,width, bytes per 2D slice
1822
* Htile bpp i.e. How many bits for an 8x8 tile
1823
* Also returns by output parameters:
1824
* *Htile pitch, height, total size in bytes, macro-tile dimensions and slice size*
1825
****************************************************************************************************
1827
UINT_32 Lib::ComputeHtileInfo(
1828
ADDR_HTILE_FLAGS flags, ///< [in] htile flags
1829
UINT_32 pitchIn, ///< [in] pitch input
1830
UINT_32 heightIn, ///< [in] height input
1831
UINT_32 numSlices, ///< [in] number of slices
1832
BOOL_32 isLinear, ///< [in] if it is linear mode
1833
BOOL_32 isWidth8, ///< [in] if htile block width is 8
1834
BOOL_32 isHeight8, ///< [in] if htile block height is 8
1835
ADDR_TILEINFO* pTileInfo, ///< [in] Tile info
1836
UINT_32* pPitchOut, ///< [out] pitch output
1837
UINT_32* pHeightOut, ///< [out] height output
1838
UINT_64* pHtileBytes, ///< [out] bytes per 2D slice
1839
UINT_32* pMacroWidth, ///< [out] macro-tile width in pixels
1840
UINT_32* pMacroHeight, ///< [out] macro-tile width in pixels
1841
UINT_64* pSliceSize, ///< [out] slice size in bytes
1842
UINT_32* pBaseAlign ///< [out] base alignment
1847
UINT_32 macroHeight;
1852
numSlices = Max(1u, numSlices);
1854
const UINT_32 bpp = HwlComputeHtileBpp(isWidth8, isHeight8);
1855
const UINT_32 cacheBits = HtileCacheBits;
1859
HwlComputeTileDataWidthAndHeightLinear(¯oWidth,
1866
ComputeTileDataWidthAndHeight(bpp,
1873
*pPitchOut = PowTwoAlign(pitchIn, macroWidth);
1874
*pHeightOut = PowTwoAlign(heightIn, macroHeight);
1876
baseAlign = HwlComputeHtileBaseAlign(flags.tcCompatible, isLinear, pTileInfo);
1878
surfBytes = HwlComputeHtileBytes(*pPitchOut,
1886
*pHtileBytes = surfBytes;
1889
// Use SafeAssign since they are optional
1891
SafeAssign(pMacroWidth, macroWidth);
1893
SafeAssign(pMacroHeight, macroHeight);
1895
SafeAssign(pSliceSize, sliceBytes);
1897
SafeAssign(pBaseAlign, baseAlign);
1903
****************************************************************************************************
1904
* Lib::ComputeCmaskBaseAlign
1907
* Compute cmask base alignment
1910
* Cmask base alignment
1911
****************************************************************************************************
1913
UINT_32 Lib::ComputeCmaskBaseAlign(
1914
ADDR_CMASK_FLAGS flags, ///< [in] Cmask flags
1915
ADDR_TILEINFO* pTileInfo ///< [in] Tile info
1918
UINT_32 baseAlign = m_pipeInterleaveBytes * HwlGetPipes(pTileInfo);
1920
if (flags.tcCompatible)
1922
ADDR_ASSERT(pTileInfo != NULL);
1925
baseAlign *= pTileInfo->banks;
1933
****************************************************************************************************
1934
* Lib::ComputeCmaskBytes
1937
* Compute cmask size in bytes
1940
* Cmask size in bytes
1941
****************************************************************************************************
1943
UINT_64 Lib::ComputeCmaskBytes(
1944
UINT_32 pitch, ///< [in] pitch
1945
UINT_32 height, ///< [in] height
1946
UINT_32 numSlices ///< [in] number of slices
1949
return BITS_TO_BYTES(static_cast<UINT_64>(pitch) * height * numSlices * CmaskElemBits) /
1954
****************************************************************************************************
1955
* Lib::ComputeCmaskInfo
1958
* Compute cmask pitch,width, bytes per 2D slice
1961
* BlockMax. Also by output parameters: Cmask pitch,height, total size in bytes,
1962
* macro-tile dimensions
1963
****************************************************************************************************
1965
ADDR_E_RETURNCODE Lib::ComputeCmaskInfo(
1966
ADDR_CMASK_FLAGS flags, ///< [in] cmask flags
1967
UINT_32 pitchIn, ///< [in] pitch input
1968
UINT_32 heightIn, ///< [in] height input
1969
UINT_32 numSlices, ///< [in] number of slices
1970
BOOL_32 isLinear, ///< [in] is linear mode
1971
ADDR_TILEINFO* pTileInfo, ///< [in] Tile info
1972
UINT_32* pPitchOut, ///< [out] pitch output
1973
UINT_32* pHeightOut, ///< [out] height output
1974
UINT_64* pCmaskBytes, ///< [out] bytes per 2D slice
1975
UINT_32* pMacroWidth, ///< [out] macro-tile width in pixels
1976
UINT_32* pMacroHeight, ///< [out] macro-tile width in pixels
1977
UINT_64* pSliceSize, ///< [out] slice size in bytes
1978
UINT_32* pBaseAlign, ///< [out] base alignment
1979
UINT_32* pBlockMax ///< [out] block max == slice / 128 / 128 - 1
1983
UINT_32 macroHeight;
1988
numSlices = Max(1u, numSlices);
1990
const UINT_32 bpp = CmaskElemBits;
1991
const UINT_32 cacheBits = CmaskCacheBits;
1993
ADDR_E_RETURNCODE returnCode = ADDR_OK;
1997
HwlComputeTileDataWidthAndHeightLinear(¯oWidth,
2004
ComputeTileDataWidthAndHeight(bpp,
2011
*pPitchOut = (pitchIn + macroWidth - 1) & ~(macroWidth - 1);
2012
*pHeightOut = (heightIn + macroHeight - 1) & ~(macroHeight - 1);
2015
sliceBytes = ComputeCmaskBytes(*pPitchOut,
2019
baseAlign = ComputeCmaskBaseAlign(flags, pTileInfo);
2021
while (sliceBytes % baseAlign)
2023
*pHeightOut += macroHeight;
2025
sliceBytes = ComputeCmaskBytes(*pPitchOut,
2030
surfBytes = sliceBytes * numSlices;
2032
*pCmaskBytes = surfBytes;
2035
// Use SafeAssign since they are optional
2037
SafeAssign(pMacroWidth, macroWidth);
2039
SafeAssign(pMacroHeight, macroHeight);
2041
SafeAssign(pBaseAlign, baseAlign);
2043
SafeAssign(pSliceSize, sliceBytes);
2045
UINT_32 slice = (*pPitchOut) * (*pHeightOut);
2046
UINT_32 blockMax = slice / 128 / 128 - 1;
2049
if (slice % (64*256) != 0)
2051
ADDR_ASSERT_ALWAYS();
2055
UINT_32 maxBlockMax = HwlGetMaxCmaskBlockMax();
2057
if (blockMax > maxBlockMax)
2059
blockMax = maxBlockMax;
2060
returnCode = ADDR_INVALIDPARAMS;
2063
SafeAssign(pBlockMax, blockMax);
2069
****************************************************************************************************
2070
* Lib::ComputeXmaskCoordYFromPipe
2073
* Compute the Y coord from pipe number for cmask/htile
2078
****************************************************************************************************
2080
UINT_32 Lib::ComputeXmaskCoordYFromPipe(
2081
UINT_32 pipe, ///< [in] pipe number
2082
UINT_32 x ///< [in] x coordinate
2094
UINT_32 numPipes = m_pipes; // SI has its implementation
2096
// Convert pipe + x to y coordinate.
2116
pipeBit0 = pipe & 0x1;
2120
yBit0 = pipeBit0 ^ xBit0;
2134
pipeBit0 = pipe & 0x1;
2135
pipeBit1 = (pipe & 0x2) >> 1;
2138
xBit1 = (x & 0x2) >> 1;
2140
yBit0 = pipeBit0 ^ xBit1;
2141
yBit1 = pipeBit1 ^ xBit0;
2150
// r600 and r800 have different method
2152
y = HwlComputeXmaskCoordYFrom8Pipe(pipe, x);
2161
****************************************************************************************************
2162
* Lib::HwlComputeXmaskCoordFromAddr
2165
* Compute the coord from an address of a cmask/htile
2171
* This method is reused by htile, so rename to Xmask
2172
****************************************************************************************************
2174
VOID Lib::HwlComputeXmaskCoordFromAddr(
2175
UINT_64 addr, ///< [in] address
2176
UINT_32 bitPosition, ///< [in] bitPosition in a byte
2177
UINT_32 pitch, ///< [in] pitch
2178
UINT_32 height, ///< [in] height
2179
UINT_32 numSlices, ///< [in] number of slices
2180
UINT_32 factor, ///< [in] factor that indicates cmask or htile
2181
BOOL_32 isLinear, ///< [in] linear or tiled HTILE layout
2182
BOOL_32 isWidth8, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2183
BOOL_32 isHeight8, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2184
ADDR_TILEINFO* pTileInfo, ///< [in] Tile info
2185
UINT_32* pX, ///< [out] x coord
2186
UINT_32* pY, ///< [out] y coord
2187
UINT_32* pSlice ///< [out] slice index
2192
UINT_32 numGroupBits;
2193
UINT_32 numPipeBits;
2194
UINT_32 macroTilePitch;
2195
UINT_32 macroTileHeight;
2199
UINT_32 microTileCoordY;
2203
UINT_32 pitchAligned = pitch;
2204
UINT_32 heightAligned = height;
2212
UINT_64 macroNumber;
2213
UINT_32 microNumber;
2222
UINT_32 tilesPerMacro;
2223
UINT_32 macrosPerPitch;
2224
UINT_32 macrosPerSlice;
2229
numPipes = HwlGetPipes(pTileInfo);
2230
pipe = ComputePipeFromAddr(addr, numPipes);
2233
// Compute the number of group and pipe bits.
2235
numGroupBits = Log2(m_pipeInterleaveBytes);
2236
numPipeBits = Log2(numPipes);
2238
UINT_32 groupBits = 8 * m_pipeInterleaveBytes;
2239
UINT_32 pipes = numPipes;
2243
// Compute the micro tile size, in bits. And macro tile pitch and height.
2245
if (factor == 2) //CMASK
2247
ADDR_CMASK_FLAGS flags = {{0}};
2249
elemBits = CmaskElemBits;
2251
ComputeCmaskInfo(flags,
2265
ADDR_HTILE_FLAGS flags = {{0}};
2272
elemBits = HwlComputeHtileBpp(isWidth8, isHeight8);
2274
ComputeHtileInfo(flags,
2289
// Should use aligned dims
2291
pitch = pitchAligned;
2292
height = heightAligned;
2296
// Convert byte address to bit address.
2298
bitAddr = BYTES_TO_BITS(addr) + bitPosition;
2302
// Remove pipe bits from address.
2305
bitAddr = (bitAddr % groupBits) + ((bitAddr/groupBits/pipes)*groupBits);
2308
elemOffset = bitAddr / elemBits;
2310
tilesPerMacro = (macroTilePitch/factor) * macroTileHeight / MicroTilePixels >> numPipeBits;
2312
macrosPerPitch = pitch / (macroTilePitch/factor);
2313
macrosPerSlice = macrosPerPitch * height / macroTileHeight;
2315
macroIndex = elemOffset / factor / tilesPerMacro;
2316
microIndex = static_cast<UINT_32>(elemOffset % (tilesPerMacro * factor));
2318
macroNumber = macroIndex * factor + microIndex % factor;
2319
microNumber = microIndex / factor;
2321
macroX = static_cast<UINT_32>((macroNumber % macrosPerPitch));
2322
macroY = static_cast<UINT_32>((macroNumber % macrosPerSlice) / macrosPerPitch);
2323
macroZ = static_cast<UINT_32>((macroNumber / macrosPerSlice));
2326
microX = microNumber % (macroTilePitch / factor / MicroTileWidth);
2327
microY = (microNumber / (macroTilePitch / factor / MicroTileHeight));
2329
*pX = macroX * (macroTilePitch/factor) + microX * MicroTileWidth;
2330
*pY = macroY * macroTileHeight + (microY * MicroTileHeight << numPipeBits);
2333
microTileCoordY = ComputeXmaskCoordYFromPipe(pipe,
2334
*pX/MicroTileWidth);
2338
// Assemble final coordinates.
2340
*pY += microTileCoordY * MicroTileHeight;
2345
****************************************************************************************************
2346
* Lib::HwlComputeXmaskAddrFromCoord
2349
* Compute the address from an address of cmask (prior to si)
2354
****************************************************************************************************
2356
UINT_64 Lib::HwlComputeXmaskAddrFromCoord(
2357
UINT_32 pitch, ///< [in] pitch
2358
UINT_32 height, ///< [in] height
2359
UINT_32 x, ///< [in] x coord
2360
UINT_32 y, ///< [in] y coord
2361
UINT_32 slice, ///< [in] slice/depth index
2362
UINT_32 numSlices, ///< [in] number of slices
2363
UINT_32 factor, ///< [in] factor that indicates cmask(2) or htile(1)
2364
BOOL_32 isLinear, ///< [in] linear or tiled HTILE layout
2365
BOOL_32 isWidth8, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2366
BOOL_32 isHeight8, ///< [in] TRUE if width is 8, FALSE means 4. It's register value
2367
ADDR_TILEINFO* pTileInfo, ///< [in] Tile info
2368
UINT_32* pBitPosition ///< [out] bit position inside a byte
2372
UINT_32 numGroupBits;
2373
UINT_32 numPipeBits;
2374
UINT_32 newPitch = 0;
2375
UINT_32 newHeight = 0;
2376
UINT_64 sliceBytes = 0;
2377
UINT_64 totalBytes = 0;
2378
UINT_64 sliceOffset;
2380
UINT_32 macroTileWidth;
2381
UINT_32 macroTileHeight;
2382
UINT_32 macroTilesPerRow;
2383
UINT_32 macroTileBytes;
2384
UINT_32 macroTileIndexX;
2385
UINT_32 macroTileIndexY;
2386
UINT_64 macroTileOffset;
2387
UINT_32 pixelBytesPerRow;
2388
UINT_32 pixelOffsetX;
2389
UINT_32 pixelOffsetY;
2390
UINT_32 pixelOffset;
2391
UINT_64 totalOffset;
2397
UINT_32 elemBits = 0;
2399
UINT_32 numPipes = m_pipes; // This function is accessed prior to si only
2401
if (factor == 2) //CMASK
2403
elemBits = CmaskElemBits;
2405
// For asics before SI, cmask is always tiled
2410
if (factor != 1) // Fix compile warning
2415
elemBits = HwlComputeHtileBpp(isWidth8, isHeight8);
2419
// Compute the number of group bits and pipe bits.
2421
numGroupBits = Log2(m_pipeInterleaveBytes);
2422
numPipeBits = Log2(numPipes);
2425
// Compute macro tile dimensions.
2427
if (factor == 2) // CMASK
2429
ADDR_CMASK_FLAGS flags = {{0}};
2431
ComputeCmaskInfo(flags,
2443
sliceBytes = totalBytes / numSlices;
2447
ADDR_HTILE_FLAGS flags = {{0}};
2449
ComputeHtileInfo(flags,
2465
sliceOffset = slice * sliceBytes;
2468
// Get the pipe. Note that neither slice rotation nor pipe swizzling apply for CMASK.
2470
pipe = ComputePipeFromCoord(x,
2473
ADDR_TM_2D_TILED_THIN1,
2479
// Compute the number of macro tiles per row.
2481
macroTilesPerRow = newPitch / macroTileWidth;
2484
// Compute the number of bytes per macro tile.
2486
macroTileBytes = BITS_TO_BYTES((macroTileWidth * macroTileHeight * elemBits) / MicroTilePixels);
2489
// Compute the offset to the macro tile containing the specified coordinate.
2491
macroTileIndexX = x / macroTileWidth;
2492
macroTileIndexY = y / macroTileHeight;
2493
macroTileOffset = ((macroTileIndexY * macroTilesPerRow) + macroTileIndexX) * macroTileBytes;
2496
// Compute the pixel offset within the macro tile.
2498
pixelBytesPerRow = BITS_TO_BYTES(macroTileWidth * elemBits) / MicroTileWidth;
2501
// The nibbles are interleaved (see below), so the part of the offset relative to the x
2502
// coordinate repeats halfway across the row. (Not for HTILE)
2506
pixelOffsetX = (x % (macroTileWidth / 2)) / MicroTileWidth;
2510
pixelOffsetX = (x % (macroTileWidth)) / MicroTileWidth * BITS_TO_BYTES(elemBits);
2514
// Compute the y offset within the macro tile.
2516
pixelOffsetY = (((y % macroTileHeight) / MicroTileHeight) / numPipes) * pixelBytesPerRow;
2518
pixelOffset = pixelOffsetX + pixelOffsetY;
2521
// Combine the slice offset and macro tile offset with the pixel offset, accounting for the
2522
// pipe bits in the middle of the address.
2524
totalOffset = ((sliceOffset + macroTileOffset) >> numPipeBits) + pixelOffset;
2527
// Split the offset to put some bits below the pipe bits and some above.
2529
groupMask = (1 << numGroupBits) - 1;
2530
offsetLo = totalOffset & groupMask;
2531
offsetHi = (totalOffset & ~groupMask) << numPipeBits;
2534
// Assemble the address from its components.
2538
// This is to remove warning with /analyze option
2539
UINT_32 pipeBits = pipe << numGroupBits;
2543
// Compute the bit position. The lower nibble is used when the x coordinate within the macro
2544
// tile is less than half of the macro tile width, and the upper nibble is used when the x
2545
// coordinate within the macro tile is greater than or equal to half the macro tile width.
2547
*pBitPosition = ((x % macroTileWidth) < (macroTileWidth / factor)) ? 0 : 4;
2552
////////////////////////////////////////////////////////////////////////////////////////////////////
2553
// Surface Addressing Shared
2554
////////////////////////////////////////////////////////////////////////////////////////////////////
2557
****************************************************************************************************
2558
* Lib::ComputeSurfaceAddrFromCoordLinear
2561
* Compute address from coord for linear surface
2566
****************************************************************************************************
2568
UINT_64 Lib::ComputeSurfaceAddrFromCoordLinear(
2569
UINT_32 x, ///< [in] x coord
2570
UINT_32 y, ///< [in] y coord
2571
UINT_32 slice, ///< [in] slice/depth index
2572
UINT_32 sample, ///< [in] sample index
2573
UINT_32 bpp, ///< [in] bits per pixel
2574
UINT_32 pitch, ///< [in] pitch
2575
UINT_32 height, ///< [in] height
2576
UINT_32 numSlices, ///< [in] number of slices
2577
UINT_32* pBitPosition ///< [out] bit position inside a byte
2580
const UINT_64 sliceSize = static_cast<UINT_64>(pitch) * height;
2582
UINT_64 sliceOffset = (slice + sample * numSlices)* sliceSize;
2583
UINT_64 rowOffset = static_cast<UINT_64>(y) * pitch;
2584
UINT_64 pixOffset = x;
2586
UINT_64 addr = (sliceOffset + rowOffset + pixOffset) * bpp;
2588
*pBitPosition = static_cast<UINT_32>(addr % 8);
2595
****************************************************************************************************
2596
* Lib::ComputeSurfaceCoordFromAddrLinear
2599
* Compute the coord from an address of a linear surface
2603
****************************************************************************************************
2605
VOID Lib::ComputeSurfaceCoordFromAddrLinear(
2606
UINT_64 addr, ///< [in] address
2607
UINT_32 bitPosition, ///< [in] bitPosition in a byte
2608
UINT_32 bpp, ///< [in] bits per pixel
2609
UINT_32 pitch, ///< [in] pitch
2610
UINT_32 height, ///< [in] height
2611
UINT_32 numSlices, ///< [in] number of slices
2612
UINT_32* pX, ///< [out] x coord
2613
UINT_32* pY, ///< [out] y coord
2614
UINT_32* pSlice, ///< [out] slice/depth index
2615
UINT_32* pSample ///< [out] sample index
2618
const UINT_64 sliceSize = static_cast<UINT_64>(pitch) * height;
2619
const UINT_64 linearOffset = (BYTES_TO_BITS(addr) + bitPosition) / bpp;
2621
*pX = static_cast<UINT_32>((linearOffset % sliceSize) % pitch);
2622
*pY = static_cast<UINT_32>((linearOffset % sliceSize) / pitch % height);
2623
*pSlice = static_cast<UINT_32>((linearOffset / sliceSize) % numSlices);
2624
*pSample = static_cast<UINT_32>((linearOffset / sliceSize) / numSlices);
2628
****************************************************************************************************
2629
* Lib::ComputeSurfaceCoordFromAddrMicroTiled
2632
* Compute the coord from an address of a micro tiled surface
2636
****************************************************************************************************
2638
VOID Lib::ComputeSurfaceCoordFromAddrMicroTiled(
2639
UINT_64 addr, ///< [in] address
2640
UINT_32 bitPosition, ///< [in] bitPosition in a byte
2641
UINT_32 bpp, ///< [in] bits per pixel
2642
UINT_32 pitch, ///< [in] pitch
2643
UINT_32 height, ///< [in] height
2644
UINT_32 numSamples, ///< [in] number of samples
2645
AddrTileMode tileMode, ///< [in] tile mode
2646
UINT_32 tileBase, ///< [in] base offset within a tile
2647
UINT_32 compBits, ///< [in] component bits actually needed(for planar surface)
2648
UINT_32* pX, ///< [out] x coord
2649
UINT_32* pY, ///< [out] y coord
2650
UINT_32* pSlice, ///< [out] slice/depth index
2651
UINT_32* pSample, ///< [out] sample index,
2652
AddrTileType microTileType, ///< [in] micro tiling order
2653
BOOL_32 isDepthSampleOrder ///< [in] TRUE if in depth sample order
2657
UINT_32 microTileThickness;
2658
UINT_32 microTileBits;
2662
UINT_32 microTileCoordX;
2663
UINT_32 microTileCoordY;
2664
UINT_32 pixelOffset;
2665
UINT_32 pixelCoordX = 0;
2666
UINT_32 pixelCoordY = 0;
2667
UINT_32 pixelCoordZ = 0;
2668
UINT_32 pixelCoordS = 0;
2671
// Convert byte address to bit address.
2673
bitAddr = BYTES_TO_BITS(addr) + bitPosition;
2676
// Compute the micro tile size, in bits.
2680
case ADDR_TM_1D_TILED_THICK:
2681
microTileThickness = ThickTileThickness;
2684
microTileThickness = 1;
2688
microTileBits = MicroTilePixels * microTileThickness * bpp * numSamples;
2691
// Compute number of bits per slice and number of bits per row of micro tiles.
2693
sliceBits = static_cast<UINT_64>(pitch) * height * microTileThickness * bpp * numSamples;
2695
rowBits = (pitch / MicroTileWidth) * microTileBits;
2698
// Extract the slice index.
2700
sliceIndex = static_cast<UINT_32>(bitAddr / sliceBits);
2701
bitAddr -= sliceIndex * sliceBits;
2704
// Extract the y coordinate of the micro tile.
2706
microTileCoordY = static_cast<UINT_32>(bitAddr / rowBits) * MicroTileHeight;
2707
bitAddr -= (microTileCoordY / MicroTileHeight) * rowBits;
2710
// Extract the x coordinate of the micro tile.
2712
microTileCoordX = static_cast<UINT_32>(bitAddr / microTileBits) * MicroTileWidth;
2715
// Compute the pixel offset within the micro tile.
2717
pixelOffset = static_cast<UINT_32>(bitAddr % microTileBits);
2720
// Extract pixel coordinates from the offset.
2722
HwlComputePixelCoordFromOffset(pixelOffset,
2733
isDepthSampleOrder);
2736
// Assemble final coordinates.
2738
*pX = microTileCoordX + pixelCoordX;
2739
*pY = microTileCoordY + pixelCoordY;
2740
*pSlice = (sliceIndex * microTileThickness) + pixelCoordZ;
2741
*pSample = pixelCoordS;
2743
if (microTileThickness > 1)
2750
****************************************************************************************************
2751
* Lib::ComputePipeFromAddr
2754
* Compute the pipe number from an address
2759
****************************************************************************************************
2761
UINT_32 Lib::ComputePipeFromAddr(
2762
UINT_64 addr, ///< [in] address
2763
UINT_32 numPipes ///< [in] number of banks
2768
UINT_32 groupBytes = m_pipeInterleaveBytes; //just different terms
2771
// The LSBs of the address are arranged as follows:
2772
// bank | pipe | group
2774
// To get the pipe number, shift off the group bits and mask the pipe bits.
2778
// The LSBs of the address are arranged as follows:
2779
// bank | bankInterleave | pipe | pipeInterleave
2781
// To get the pipe number, shift off the pipe interleave bits and mask the pipe bits.
2784
pipe = static_cast<UINT_32>(addr >> Log2(groupBytes)) & (numPipes - 1);
2790
****************************************************************************************************
2791
* Lib::ComputeMicroTileEquation
2794
* Compute micro tile equation
2797
* If equation can be computed
2799
****************************************************************************************************
2801
ADDR_E_RETURNCODE Lib::ComputeMicroTileEquation(
2802
UINT_32 log2BytesPP, ///< [in] log2 of bytes per pixel
2803
AddrTileMode tileMode, ///< [in] tile mode
2804
AddrTileType microTileType, ///< [in] pixel order in display/non-display mode
2805
ADDR_EQUATION* pEquation ///< [out] equation
2808
ADDR_E_RETURNCODE retCode = ADDR_OK;
2810
for (UINT_32 i = 0; i < log2BytesPP; i++)
2812
pEquation->addr[i].valid = 1;
2813
pEquation->addr[i].channel = 0;
2814
pEquation->addr[i].index = i;
2817
ADDR_CHANNEL_SETTING* pixelBit = &pEquation->addr[log2BytesPP];
2819
ADDR_CHANNEL_SETTING x0 = InitChannel(1, 0, log2BytesPP + 0);
2820
ADDR_CHANNEL_SETTING x1 = InitChannel(1, 0, log2BytesPP + 1);
2821
ADDR_CHANNEL_SETTING x2 = InitChannel(1, 0, log2BytesPP + 2);
2822
ADDR_CHANNEL_SETTING y0 = InitChannel(1, 1, 0);
2823
ADDR_CHANNEL_SETTING y1 = InitChannel(1, 1, 1);
2824
ADDR_CHANNEL_SETTING y2 = InitChannel(1, 1, 2);
2825
ADDR_CHANNEL_SETTING z0 = InitChannel(1, 2, 0);
2826
ADDR_CHANNEL_SETTING z1 = InitChannel(1, 2, 1);
2827
ADDR_CHANNEL_SETTING z2 = InitChannel(1, 2, 2);
2829
UINT_32 thickness = Thickness(tileMode);
2830
UINT_32 bpp = 1 << (log2BytesPP + 3);
2832
if (microTileType != ADDR_THICK)
2834
if (microTileType == ADDR_DISPLAYABLE)
2879
ADDR_ASSERT_ALWAYS();
2883
else if (microTileType == ADDR_NON_DISPLAYABLE || microTileType == ADDR_DEPTH_SAMPLE_ORDER)
2892
else if (microTileType == ADDR_ROTATED)
2894
ADDR_ASSERT(thickness == 1);
2931
retCode = ADDR_NOTSUPPORTED;
2940
pEquation->numBits = 8 + log2BytesPP;
2944
pEquation->numBits = 6 + log2BytesPP;
2949
ADDR_ASSERT(thickness > 1);
2980
ADDR_ASSERT_ALWAYS();
2986
pEquation->numBits = 8 + log2BytesPP;
2992
pEquation->numBits = 9 + log2BytesPP;
2995
// stackedDepthSlices is used for addressing mode that a tile block contains multiple slices,
2996
// which is not supported by our address lib
2997
pEquation->stackedDepthSlices = FALSE;
3003
****************************************************************************************************
3004
* Lib::ComputePixelIndexWithinMicroTile
3007
* Compute the pixel index inside a micro tile of surface
3012
****************************************************************************************************
3014
UINT_32 Lib::ComputePixelIndexWithinMicroTile(
3015
UINT_32 x, ///< [in] x coord
3016
UINT_32 y, ///< [in] y coord
3017
UINT_32 z, ///< [in] slice/depth index
3018
UINT_32 bpp, ///< [in] bits per pixel
3019
AddrTileMode tileMode, ///< [in] tile mode
3020
AddrTileType microTileType ///< [in] pixel order in display/non-display mode
3023
UINT_32 pixelBit0 = 0;
3024
UINT_32 pixelBit1 = 0;
3025
UINT_32 pixelBit2 = 0;
3026
UINT_32 pixelBit3 = 0;
3027
UINT_32 pixelBit4 = 0;
3028
UINT_32 pixelBit5 = 0;
3029
UINT_32 pixelBit6 = 0;
3030
UINT_32 pixelBit7 = 0;
3031
UINT_32 pixelBit8 = 0;
3032
UINT_32 pixelNumber;
3034
UINT_32 x0 = _BIT(x, 0);
3035
UINT_32 x1 = _BIT(x, 1);
3036
UINT_32 x2 = _BIT(x, 2);
3037
UINT_32 y0 = _BIT(y, 0);
3038
UINT_32 y1 = _BIT(y, 1);
3039
UINT_32 y2 = _BIT(y, 2);
3040
UINT_32 z0 = _BIT(z, 0);
3041
UINT_32 z1 = _BIT(z, 1);
3042
UINT_32 z2 = _BIT(z, 2);
3044
UINT_32 thickness = Thickness(tileMode);
3046
// Compute the pixel number within the micro tile.
3048
if (microTileType != ADDR_THICK)
3050
if (microTileType == ADDR_DISPLAYABLE)
3095
ADDR_ASSERT_ALWAYS();
3099
else if (microTileType == ADDR_NON_DISPLAYABLE || microTileType == ADDR_DEPTH_SAMPLE_ORDER)
3108
else if (microTileType == ADDR_ROTATED)
3110
ADDR_ASSERT(thickness == 1);
3147
ADDR_ASSERT_ALWAYS();
3160
ADDR_ASSERT(thickness > 1);
3191
ADDR_ASSERT_ALWAYS();
3204
pixelNumber = ((pixelBit0 ) |
3218
****************************************************************************************************
3219
* Lib::AdjustPitchAlignment
3222
* Adjusts pitch alignment for flipping surface
3227
****************************************************************************************************
3229
VOID Lib::AdjustPitchAlignment(
3230
ADDR_SURFACE_FLAGS flags, ///< [in] Surface flags
3231
UINT_32* pPitchAlign ///< [out] Pointer to pitch alignment
3234
// Display engine hardwires lower 5 bit of GRPH_PITCH to ZERO which means 32 pixel alignment
3235
// Maybe it will be fixed in future but let's make it general for now.
3236
if (flags.display || flags.overlay)
3238
*pPitchAlign = PowTwoAlign(*pPitchAlign, 32);
3242
*pPitchAlign = Max(m_minPitchAlignPixels, *pPitchAlign);
3248
****************************************************************************************************
3249
* Lib::PadDimensions
3252
* Helper function to pad dimensions
3257
****************************************************************************************************
3259
VOID Lib::PadDimensions(
3260
AddrTileMode tileMode, ///< [in] tile mode
3261
UINT_32 bpp, ///< [in] bits per pixel
3262
ADDR_SURFACE_FLAGS flags, ///< [in] surface flags
3263
UINT_32 numSamples, ///< [in] number of samples
3264
ADDR_TILEINFO* pTileInfo, ///< [in,out] bank structure.
3265
UINT_32 padDims, ///< [in] Dimensions to pad valid value 1,2,3
3266
UINT_32 mipLevel, ///< [in] MipLevel
3267
UINT_32* pPitch, ///< [in,out] pitch in pixels
3268
UINT_32* pPitchAlign, ///< [in,out] pitch align could be changed in HwlPadDimensions
3269
UINT_32* pHeight, ///< [in,out] height in pixels
3270
UINT_32 heightAlign, ///< [in] height alignment
3271
UINT_32* pSlices, ///< [in,out] number of slices
3272
UINT_32 sliceAlign ///< [in] number of slice alignment
3275
UINT_32 pitchAlign = *pPitchAlign;
3276
UINT_32 thickness = Thickness(tileMode);
3278
ADDR_ASSERT(padDims <= 3);
3281
// Override padding for mip levels
3287
// for cubemap, we only pad when client call with 6 faces as an identity
3290
padDims = 3; // we should pad cubemap sub levels when we treat it as 3d texture
3299
// Any possibilities that padDims is 0?
3305
if (IsPow2(pitchAlign))
3307
*pPitch = PowTwoAlign((*pPitch), pitchAlign);
3309
else // add this code to pass unit test, r600 linear mode is not align bpp to pow2 for linear
3311
*pPitch += pitchAlign - 1;
3312
*pPitch /= pitchAlign;
3313
*pPitch *= pitchAlign;
3318
if (IsPow2(heightAlign))
3320
*pHeight = PowTwoAlign((*pHeight), heightAlign);
3324
*pHeight += heightAlign - 1;
3325
*pHeight /= heightAlign;
3326
*pHeight *= heightAlign;
3330
if (padDims > 2 || thickness > 1)
3332
// for cubemap single face, we do not pad slices.
3333
// if we pad it, the slice number should be set to 6 and current mip level > 1
3334
if (flags.cube && (!m_configFlags.noCubeMipSlicesPad || flags.cubeAsArray))
3336
*pSlices = NextPow2(*pSlices);
3339
// normal 3D texture or arrays or cubemap has a thick mode? (Just pass unit test)
3342
*pSlices = PowTwoAlign((*pSlices), sliceAlign);
3347
HwlPadDimensions(tileMode,
3361
****************************************************************************************************
3362
* Lib::HwlPreHandleBaseLvl3xPitch
3365
* Pre-handler of 3x pitch (96 bit) adjustment
3369
****************************************************************************************************
3371
UINT_32 Lib::HwlPreHandleBaseLvl3xPitch(
3372
const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn, ///< [in] input
3373
UINT_32 expPitch ///< [in] pitch
3376
ADDR_ASSERT(pIn->width == expPitch);
3378
// If pitch is pre-multiplied by 3, we retrieve original one here to get correct miplevel size
3380
if (ElemLib::IsExpand3x(pIn->format) &&
3381
pIn->mipLevel == 0 &&
3382
pIn->tileMode == ADDR_TM_LINEAR_ALIGNED)
3385
expPitch = NextPow2(expPitch);
3392
****************************************************************************************************
3393
* Lib::HwlPostHandleBaseLvl3xPitch
3396
* Post-handler of 3x pitch adjustment
3400
****************************************************************************************************
3402
UINT_32 Lib::HwlPostHandleBaseLvl3xPitch(
3403
const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn, ///< [in] input
3404
UINT_32 expPitch ///< [in] pitch
3408
// 96 bits surface of sub levels require element pitch of 32 bits instead
3409
// So we just return pitch in 32 bit pixels without timing 3
3411
if (ElemLib::IsExpand3x(pIn->format) &&
3412
pIn->mipLevel == 0 &&
3413
pIn->tileMode == ADDR_TM_LINEAR_ALIGNED)
3423
****************************************************************************************************
3427
* Check if the tile mode is macro tiled
3430
* TRUE if it is macro tiled (2D/2B/3D/3B)
3431
****************************************************************************************************
3433
BOOL_32 Lib::IsMacroTiled(
3434
AddrTileMode tileMode) ///< [in] tile mode
3436
return ModeFlags[tileMode].isMacro;
3440
****************************************************************************************************
3441
* Lib::IsMacro3dTiled
3444
* Check if the tile mode is 3D macro tiled
3447
* TRUE if it is 3D macro tiled
3448
****************************************************************************************************
3450
BOOL_32 Lib::IsMacro3dTiled(
3451
AddrTileMode tileMode) ///< [in] tile mode
3453
return ModeFlags[tileMode].isMacro3d;
3457
****************************************************************************************************
3461
* Check if the tile mode is micro tiled
3464
* TRUE if micro tiled
3465
****************************************************************************************************
3467
BOOL_32 Lib::IsMicroTiled(
3468
AddrTileMode tileMode) ///< [in] tile mode
3470
return ModeFlags[tileMode].isMicro;
3474
****************************************************************************************************
3478
* Check if the tile mode is linear
3482
****************************************************************************************************
3484
BOOL_32 Lib::IsLinear(
3485
AddrTileMode tileMode) ///< [in] tile mode
3487
return ModeFlags[tileMode].isLinear;
3491
****************************************************************************************************
3492
* Lib::IsPrtNoRotationTileMode
3495
* Return TRUE if it is prt tile without rotation
3497
* This function just used by CI
3498
****************************************************************************************************
3500
BOOL_32 Lib::IsPrtNoRotationTileMode(
3501
AddrTileMode tileMode)
3503
return ModeFlags[tileMode].isPrtNoRotation;
3507
****************************************************************************************************
3508
* Lib::IsPrtTileMode
3511
* Return TRUE if it is prt tile
3513
* This function just used by CI
3514
****************************************************************************************************
3516
BOOL_32 Lib::IsPrtTileMode(
3517
AddrTileMode tileMode)
3519
return ModeFlags[tileMode].isPrt;
3523
****************************************************************************************************
3524
* Lib::ComputeMipLevel
3527
* Compute mipmap level width/height/slices
3530
****************************************************************************************************
3532
VOID Lib::ComputeMipLevel(
3533
ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn ///< [in,out] Input structure
3536
// Check if HWL has handled
3537
BOOL_32 hwlHandled = FALSE;
3539
if (ElemLib::IsBlockCompressed(pIn->format))
3541
if (pIn->mipLevel == 0)
3543
// DXTn's level 0 must be multiple of 4
3544
// But there are exceptions:
3545
// 1. Internal surface creation in hostblt/vsblt/etc...
3546
// 2. Runtime doesn't reject ATI1/ATI2 whose width/height are not multiple of 4
3547
pIn->width = PowTwoAlign(pIn->width, 4);
3548
pIn->height = PowTwoAlign(pIn->height, 4);
3552
hwlHandled = HwlComputeMipLevel(pIn);
3556
****************************************************************************************************
3560
* Check if surface can be degraded to 1D
3563
****************************************************************************************************
3565
BOOL_32 Lib::DegradeTo1D(
3566
UINT_32 width, ///< surface width
3567
UINT_32 height, ///< surface height
3568
UINT_32 macroTilePitchAlign, ///< macro tile pitch align
3569
UINT_32 macroTileHeightAlign ///< macro tile height align
3572
BOOL_32 degrade = ((width < macroTilePitchAlign) || (height < macroTileHeightAlign));
3574
// Check whether 2D tiling still has too much footprint
3575
if (degrade == FALSE)
3577
// Only check width and height as slices are aligned to thickness
3578
UINT_64 unalignedSize = width * height;
3580
UINT_32 alignedPitch = PowTwoAlign(width, macroTilePitchAlign);
3581
UINT_32 alignedHeight = PowTwoAlign(height, macroTileHeightAlign);
3582
UINT_64 alignedSize = alignedPitch * alignedHeight;
3584
// alignedSize > 1.5 * unalignedSize
3585
if (2 * alignedSize > 3 * unalignedSize)
3595
****************************************************************************************************
3596
* Lib::OptimizeTileMode
3599
* Check if base level's tile mode can be optimized (degraded)
3602
****************************************************************************************************
3604
VOID Lib::OptimizeTileMode(
3605
ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut ///< [in, out] structure for surface info
3608
AddrTileMode tileMode = pInOut->tileMode;
3610
BOOL_32 doOpt = (pInOut->flags.opt4Space == TRUE) ||
3611
(pInOut->flags.minimizeAlignment == TRUE) ||
3612
(pInOut->maxBaseAlign != 0);
3614
BOOL_32 convertToPrt = FALSE;
3616
// Optimization can only be done on level 0 and samples <= 1
3617
if ((doOpt == TRUE) &&
3618
(pInOut->mipLevel == 0) &&
3619
(IsPrtTileMode(tileMode) == FALSE) &&
3620
(pInOut->flags.prt == FALSE))
3622
UINT_32 width = pInOut->width;
3623
UINT_32 height = pInOut->height;
3624
UINT_32 thickness = Thickness(tileMode);
3625
BOOL_32 macroTiledOK = TRUE;
3626
UINT_32 macroWidthAlign = 0;
3627
UINT_32 macroHeightAlign = 0;
3628
UINT_32 macroSizeAlign = 0;
3630
if (IsMacroTiled(tileMode))
3632
macroTiledOK = HwlGetAlignmentInfoMacroTiled(pInOut,
3640
if ((pInOut->flags.display == FALSE) &&
3641
(pInOut->flags.opt4Space == TRUE) &&
3642
(pInOut->numSamples <= 1))
3644
// Check if linear mode is optimal
3645
if ((pInOut->height == 1) &&
3646
(IsLinear(tileMode) == FALSE) &&
3647
(ElemLib::IsBlockCompressed(pInOut->format) == FALSE) &&
3648
(pInOut->flags.depth == FALSE) &&
3649
(pInOut->flags.stencil == FALSE) &&
3650
(m_configFlags.disableLinearOpt == FALSE) &&
3651
(pInOut->flags.disableLinearOpt == FALSE))
3653
tileMode = ADDR_TM_LINEAR_ALIGNED;
3655
else if (IsMacroTiled(tileMode) && (pInOut->flags.tcCompatible == FALSE))
3657
if (DegradeTo1D(width, height, macroWidthAlign, macroHeightAlign))
3659
tileMode = (thickness == 1) ?
3660
ADDR_TM_1D_TILED_THIN1 : ADDR_TM_1D_TILED_THICK;
3662
else if ((thickness > 1) && (pInOut->flags.disallowLargeThickDegrade == 0))
3664
// As in the following HwlComputeSurfaceInfo, thick modes may be degraded to
3665
// thinner modes, we should re-evaluate whether the corresponding
3666
// thinner modes should be degraded. If so, we choose 1D thick mode instead.
3667
tileMode = DegradeLargeThickTile(pInOut->tileMode, pInOut->bpp);
3669
if (tileMode != pInOut->tileMode)
3671
// Get thickness again after large thick degrade
3672
thickness = Thickness(tileMode);
3674
ADDR_COMPUTE_SURFACE_INFO_INPUT input = *pInOut;
3675
input.tileMode = tileMode;
3677
macroTiledOK = HwlGetAlignmentInfoMacroTiled(&input,
3683
DegradeTo1D(width, height, macroWidthAlign, macroHeightAlign))
3685
tileMode = ADDR_TM_1D_TILED_THICK;
3694
if ((pInOut->flags.minimizeAlignment == TRUE) &&
3695
(pInOut->numSamples <= 1) &&
3696
(IsMacroTiled(tileMode) == TRUE))
3698
UINT_32 macroSize = PowTwoAlign(width, macroWidthAlign) *
3699
PowTwoAlign(height, macroHeightAlign);
3700
UINT_32 microSize = PowTwoAlign(width, MicroTileWidth) *
3701
PowTwoAlign(height, MicroTileHeight);
3703
if (macroSize > microSize)
3705
tileMode = (thickness == 1) ?
3706
ADDR_TM_1D_TILED_THIN1 : ADDR_TM_1D_TILED_THICK;
3710
if ((pInOut->maxBaseAlign != 0) &&
3711
(IsMacroTiled(tileMode) == TRUE))
3713
if (macroSizeAlign > pInOut->maxBaseAlign)
3715
if (pInOut->numSamples > 1)
3717
ADDR_ASSERT(pInOut->maxBaseAlign >= Block64K);
3719
convertToPrt = TRUE;
3721
else if (pInOut->maxBaseAlign < Block64K)
3723
tileMode = (thickness == 1) ?
3724
ADDR_TM_1D_TILED_THIN1 : ADDR_TM_1D_TILED_THICK;
3728
convertToPrt = TRUE;
3738
if ((pInOut->flags.matchStencilTileCfg == TRUE) && (pInOut->numSamples <= 1))
3740
pInOut->tileMode = ADDR_TM_1D_TILED_THIN1;
3744
HwlSetPrtTileMode(pInOut);
3747
else if (tileMode != pInOut->tileMode)
3749
pInOut->tileMode = tileMode;
3752
HwlOptimizeTileMode(pInOut);
3756
****************************************************************************************************
3757
* Lib::DegradeLargeThickTile
3760
* Check if the thickness needs to be reduced if a tile is too large
3762
* The degraded tile mode (unchanged if not degraded)
3763
****************************************************************************************************
3765
AddrTileMode Lib::DegradeLargeThickTile(
3766
AddrTileMode tileMode,
3769
// Override tilemode
3770
// When tile_width (8) * tile_height (8) * thickness * element_bytes is > row_size,
3771
// it is better to just use THIN mode in this case
3772
UINT_32 thickness = Thickness(tileMode);
3774
if (thickness > 1 && m_configFlags.allowLargeThickTile == 0)
3776
UINT_32 tileSize = MicroTilePixels * thickness * (bpp >> 3);
3778
if (tileSize > m_rowSize)
3782
case ADDR_TM_2D_TILED_XTHICK:
3783
if ((tileSize >> 1) <= m_rowSize)
3785
tileMode = ADDR_TM_2D_TILED_THICK;
3788
// else fall through
3789
case ADDR_TM_2D_TILED_THICK:
3790
tileMode = ADDR_TM_2D_TILED_THIN1;
3793
case ADDR_TM_3D_TILED_XTHICK:
3794
if ((tileSize >> 1) <= m_rowSize)
3796
tileMode = ADDR_TM_3D_TILED_THICK;
3799
// else fall through
3800
case ADDR_TM_3D_TILED_THICK:
3801
tileMode = ADDR_TM_3D_TILED_THIN1;
3804
case ADDR_TM_PRT_TILED_THICK:
3805
tileMode = ADDR_TM_PRT_TILED_THIN1;
3808
case ADDR_TM_PRT_2D_TILED_THICK:
3809
tileMode = ADDR_TM_PRT_2D_TILED_THIN1;
3812
case ADDR_TM_PRT_3D_TILED_THICK:
3813
tileMode = ADDR_TM_PRT_3D_TILED_THIN1;
3826
****************************************************************************************************
3827
* Lib::PostComputeMipLevel
3829
* Compute MipLevel info (including level 0) after surface adjustment
3832
****************************************************************************************************
3834
ADDR_E_RETURNCODE Lib::PostComputeMipLevel(
3835
ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn, ///< [in,out] Input structure
3836
ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut ///< [out] Output structure
3839
// Mipmap including level 0 must be pow2 padded since either SI hw expects so or it is
3840
// required by CFX for Hw Compatibility between NI and SI. Otherwise it is only needed for
3841
// mipLevel > 0. Any h/w has different requirement should implement its own virtual function
3843
if (pIn->flags.pow2Pad)
3845
pIn->width = NextPow2(pIn->width);
3846
pIn->height = NextPow2(pIn->height);
3847
pIn->numSlices = NextPow2(pIn->numSlices);
3849
else if (pIn->mipLevel > 0)
3851
pIn->width = NextPow2(pIn->width);
3852
pIn->height = NextPow2(pIn->height);
3854
if (!pIn->flags.cube)
3856
pIn->numSlices = NextPow2(pIn->numSlices);
3859
// for cubemap, we keep its value at first
3866
****************************************************************************************************
3867
* Lib::HwlSetupTileCfg
3870
* Map tile index to tile setting.
3873
****************************************************************************************************
3875
ADDR_E_RETURNCODE Lib::HwlSetupTileCfg(
3876
UINT_32 bpp, ///< Bits per pixel
3877
INT_32 index, ///< [in] Tile index
3878
INT_32 macroModeIndex, ///< [in] Index in macro tile mode table(CI)
3879
ADDR_TILEINFO* pInfo, ///< [out] Tile Info
3880
AddrTileMode* pMode, ///< [out] Tile mode
3881
AddrTileType* pType ///< [out] Tile type
3884
return ADDR_NOTSUPPORTED;
3888
****************************************************************************************************
3895
****************************************************************************************************
3897
UINT_32 Lib::HwlGetPipes(
3898
const ADDR_TILEINFO* pTileInfo ///< [in] Tile info
3901
//pTileInfo can be NULL when asic is 6xx and 8xx.
3906
****************************************************************************************************
3907
* Lib::ComputeQbStereoInfo
3910
* Get quad buffer stereo information
3913
****************************************************************************************************
3915
VOID Lib::ComputeQbStereoInfo(
3916
ADDR_COMPUTE_SURFACE_INFO_OUTPUT* pOut ///< [in,out] updated pOut+pStereoInfo
3919
ADDR_ASSERT(pOut->bpp >= 8);
3920
ADDR_ASSERT((pOut->surfSize % pOut->baseAlign) == 0);
3922
// Save original height
3923
pOut->pStereoInfo->eyeHeight = pOut->height;
3926
pOut->pStereoInfo->rightOffset = static_cast<UINT_32>(pOut->surfSize);
3928
pOut->pStereoInfo->rightSwizzle = HwlComputeQbStereoRightSwizzle(pOut);
3931
pOut->pixelHeight <<= 1;
3934
pOut->surfSize <<= 1;
3936
// Right start address meets the base align since it is guaranteed by AddrLib1
3938
// 1D surface on SI may break this rule, but we can force it to meet by checking .qbStereo.
3943
****************************************************************************************************
3944
* Lib::ComputePrtInfo
3947
* Compute prt surface related info
3951
****************************************************************************************************
3953
ADDR_E_RETURNCODE Lib::ComputePrtInfo(
3954
const ADDR_PRT_INFO_INPUT* pIn,
3955
ADDR_PRT_INFO_OUTPUT* pOut) const
3957
ADDR_ASSERT(pOut != NULL);
3959
ADDR_E_RETURNCODE returnCode = ADDR_OK;
3961
UINT_32 expandX = 1;
3962
UINT_32 expandY = 1;
3965
UINT_32 bpp = GetElemLib()->GetBitsPerPixel(pIn->format,
3970
if (bpp <8 || bpp == 24 || bpp == 48 || bpp == 96)
3972
returnCode = ADDR_INVALIDPARAMS;
3975
UINT_32 numFrags = pIn->numFrags;
3976
ADDR_ASSERT(numFrags <= 8);
3978
UINT_32 tileWidth = 0;
3979
UINT_32 tileHeight = 0;
3980
if (returnCode == ADDR_OK)
3982
// 3D texture without depth or 2d texture
3983
if (pIn->baseMipDepth > 1 || pIn->baseMipHeight > 1)
4002
// assume it is BC1/4
4006
if (elemMode == ADDR_UNCOMPRESSED)
4012
else if (bpp == 128)
4014
// assume it is BC2/3/5/6H/7
4018
if (elemMode == ADDR_UNCOMPRESSED)
4027
tileWidth = tileWidth / 2;
4029
else if (numFrags == 4)
4031
tileWidth = tileWidth / 2;
4032
tileHeight = tileHeight / 2;
4034
else if (numFrags == 8)
4036
tileWidth = tileWidth / 4;
4037
tileHeight = tileHeight / 2;
4059
else if (bpp == 128)
4066
pOut->prtTileWidth = tileWidth;
4067
pOut->prtTileHeight = tileHeight;