Update addrLib to support gfx11

This library was taken from public MESA library:
https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/src/amd/addrlib

with top commit:
2866ae32da0348caf71ad2d11c353321df626ff4

Removing macros.h as it is no longer used by addrlib

Change-Id: I0fdabfe48b74c259b4d29d81beae89604bbc141a
Этот коммит содержится в:
David Yat Sin
2022-04-27 09:25:17 -04:00
коммит произвёл David Yat Sin
родитель c2a60a4d5d
Коммит a742b7e830
40 изменённых файлов: 11317 добавлений и 2361 удалений
+389 -216
Просмотреть файл
@@ -1,28 +1,27 @@
/*
* Copyright © 2007-2019 Advanced Micro Devices, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
* AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*/
************************************************************************************************************************
*
* Copyright (C) 2007-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE
*
***********************************************************************************************************************/
/**
************************************************************************************************************************
@@ -37,13 +36,11 @@
#include "amdgpu_asic_addr.h"
#include "util/macros.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace rocr {
namespace Addr
{
namespace Addr {
/**
************************************************************************************************************************
@@ -70,46 +67,46 @@ namespace V2
const SwizzleModeFlags Gfx9Lib::SwizzleModeTable[ADDR_SW_MAX_TYPE] =
{//Linear 256B 4KB 64KB Var Z Std Disp Rot XOR T RtOpt Reserved
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // ADDR_SW_LINEAR
{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, // ADDR_SW_256B_S
{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, // ADDR_SW_256B_D
{0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, // ADDR_SW_256B_R
{{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, // ADDR_SW_LINEAR
{{0, 1, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, // Reserved
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, // Reserved
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, // Reserved
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, // Reserved
{{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, // ADDR_SW_LINEAR_GENERAL
};
const UINT_32 Gfx9Lib::MipTailOffset256B[] = {2048, 1024, 512, 256, 128, 64, 32, 16, 8, 6, 5, 4, 3, 2, 1, 0};
@@ -131,7 +128,6 @@ Gfx9Lib::Gfx9Lib(const Client* pClient)
:
Lib(pClient)
{
m_class = AI_ADDRLIB;
memset(&m_settings, 0, sizeof(m_settings));
memcpy(m_swizzleModeTable, SwizzleModeTable, sizeof(SwizzleModeTable));
memset(m_cachedMetaEqKey, 0, sizeof(m_cachedMetaEqKey));
@@ -353,6 +349,50 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlComputeCmaskInfo(
pOut->metaBlkNumPerSlice = numMetaBlkX * numMetaBlkY;
// Get the CMASK address equation (copied from CmaskAddrFromCoord)
UINT_32 fmaskBpp = GetFmaskBpp(1, 1);
UINT_32 fmaskElementBytesLog2 = Log2(fmaskBpp >> 3);
UINT_32 metaBlkWidthLog2 = Log2(pOut->metaBlkWidth);
UINT_32 metaBlkHeightLog2 = Log2(pOut->metaBlkHeight);
MetaEqParams metaEqParams = {0, fmaskElementBytesLog2, 0, pIn->cMaskFlags,
Gfx9DataFmask, pIn->swizzleMode, pIn->resourceType,
metaBlkWidthLog2, metaBlkHeightLog2, 0, 3, 3, 0};
CoordEq *eq = (CoordEq *)((Gfx9Lib *)this)->GetMetaEquation(metaEqParams);
// Generate the CMASK address equation.
pOut->equation.gfx9.num_bits = Min(32u, eq->getsize());
bool checked = false;
for (unsigned b = 0; b < pOut->equation.gfx9.num_bits; b++) {
CoordTerm &bit = (*eq)[b];
unsigned c;
for (c = 0; c < bit.getsize(); c++) {
Coordinate &coord = bit[c];
pOut->equation.gfx9.bit[b].coord[c].dim = coord.getdim();
pOut->equation.gfx9.bit[b].coord[c].ord = coord.getord();
}
for (; c < 5; c++)
pOut->equation.gfx9.bit[b].coord[c].dim = 5; /* meaning invalid */
}
// Reduce num_bits because DIM_M fills the rest of the bits monotonically.
for (int b = pOut->equation.gfx9.num_bits - 1; b >= 1; b--) {
CoordTerm &prev = (*eq)[b - 1];
CoordTerm &cur = (*eq)[b];
if (cur.getsize() == 1 && cur[0].getdim() == DIM_M &&
prev.getsize() == 1 && prev[0].getdim() == DIM_M &&
prev[0].getord() + 1 == cur[0].getord())
pOut->equation.gfx9.num_bits = b;
else
break;
}
pOut->equation.gfx9.numPipeBits = GetPipeLog2ForMetaAddressing(pIn->cMaskFlags.pipeAligned,
pIn->swizzleMode);
return ADDR_OK;
}
@@ -663,10 +703,60 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlComputeDccInfo(
pOut->metaBlkWidth = metaBlkDim.w;
pOut->metaBlkHeight = metaBlkDim.h;
pOut->metaBlkDepth = metaBlkDim.d;
pOut->metaBlkSize = numCompressBlkPerMetaBlk * numFrags;
pOut->metaBlkNumPerSlice = numMetaBlkX * numMetaBlkY;
pOut->fastClearSizePerSlice =
pOut->metaBlkNumPerSlice * numCompressBlkPerMetaBlk * Min(numFrags, m_maxCompFrag);
// Get the DCC address equation (copied from DccAddrFromCoord)
UINT_32 elementBytesLog2 = Log2(pIn->bpp >> 3);
UINT_32 numSamplesLog2 = Log2(pIn->numFrags);
UINT_32 metaBlkWidthLog2 = Log2(pOut->metaBlkWidth);
UINT_32 metaBlkHeightLog2 = Log2(pOut->metaBlkHeight);
UINT_32 metaBlkDepthLog2 = Log2(pOut->metaBlkDepth);
UINT_32 compBlkWidthLog2 = Log2(pOut->compressBlkWidth);
UINT_32 compBlkHeightLog2 = Log2(pOut->compressBlkHeight);
UINT_32 compBlkDepthLog2 = Log2(pOut->compressBlkDepth);
MetaEqParams metaEqParams = {0, elementBytesLog2, numSamplesLog2, pIn->dccKeyFlags,
Gfx9DataColor, pIn->swizzleMode, pIn->resourceType,
metaBlkWidthLog2, metaBlkHeightLog2, metaBlkDepthLog2,
compBlkWidthLog2, compBlkHeightLog2, compBlkDepthLog2};
CoordEq *eq = (CoordEq *)((Gfx9Lib *)this)->GetMetaEquation(metaEqParams);
// Generate the DCC address equation.
pOut->equation.gfx9.num_bits = Min(32u, eq->getsize());
bool checked = false;
for (unsigned b = 0; b < pOut->equation.gfx9.num_bits; b++) {
CoordTerm &bit = (*eq)[b];
unsigned c;
for (c = 0; c < bit.getsize(); c++) {
Coordinate &coord = bit[c];
pOut->equation.gfx9.bit[b].coord[c].dim = coord.getdim();
pOut->equation.gfx9.bit[b].coord[c].ord = coord.getord();
}
for (; c < 5; c++)
pOut->equation.gfx9.bit[b].coord[c].dim = 5; /* meaning invalid */
}
// Reduce num_bits because DIM_M fills the rest of the bits monotonically.
for (int b = pOut->equation.gfx9.num_bits - 1; b >= 1; b--) {
CoordTerm &prev = (*eq)[b - 1];
CoordTerm &cur = (*eq)[b];
if (cur.getsize() == 1 && cur[0].getdim() == DIM_M &&
prev.getsize() == 1 && prev[0].getdim() == DIM_M &&
prev[0].getord() + 1 == cur[0].getord())
pOut->equation.gfx9.num_bits = b;
else
break;
}
pOut->equation.gfx9.numPipeBits = GetPipeLog2ForMetaAddressing(pIn->dccKeyFlags.pipeAligned,
pIn->swizzleMode);
}
return ADDR_OK;
@@ -799,12 +889,13 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlComputeCmaskAddrFromCoord(
UINT_32 sliceSizeInBlock = (output.height / output.metaBlkHeight) * pitchInBlock;
UINT_32 blockIndex = zb * sliceSizeInBlock + yb * pitchInBlock + xb;
UINT_32 coords[] = { pIn->x, pIn->y, pIn->slice, 0, blockIndex };
UINT_64 address = pMetaEq->solve(coords);
UINT_32 coords[] = {pIn->x, pIn->y, pIn->slice, 0, blockIndex};
UINT_64 address = pMetaEq->solve(coords);
pOut->addr = address >> 1;
pOut->bitPosition = static_cast<UINT_32>((address & 1) << 2);
UINT_32 numPipeBits = GetPipeLog2ForMetaAddressing(pIn->cMaskFlags.pipeAligned,
pIn->swizzleMode);
@@ -875,8 +966,8 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlComputeHtileAddrFromCoord(
UINT_32 sliceSizeInBlock = (output.height / output.metaBlkHeight) * pitchInBlock;
UINT_32 blockIndex = zb * sliceSizeInBlock + yb * pitchInBlock + xb;
UINT_32 coords[] = { pIn->x, pIn->y, pIn->slice, 0, blockIndex };
UINT_64 address = pMetaEq->solve(coords);
UINT_32 coords[] = {pIn->x, pIn->y, pIn->slice, 0, blockIndex};
UINT_64 address = pMetaEq->solve(coords);
pOut->addr = address >> 1;
@@ -964,6 +1055,42 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlComputeHtileCoordFromAddr(
return returnCode;
}
/**
************************************************************************************************************************
* Gfx9Lib::HwlSupportComputeDccAddrFromCoord
*
* @brief
* Check whether HwlComputeDccAddrFromCoord() can be done for the input parameter
*
* @return
* ADDR_E_RETURNCODE
************************************************************************************************************************
*/
ADDR_E_RETURNCODE Gfx9Lib::HwlSupportComputeDccAddrFromCoord(
const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT* pIn)
{
ADDR_E_RETURNCODE returnCode = ADDR_OK;
if ((pIn->numMipLevels > 1) || (pIn->mipId > 1) || pIn->dccKeyFlags.linear)
{
returnCode = ADDR_NOTSUPPORTED;
}
else if ((pIn->pitch == 0) ||
(pIn->height == 0) ||
(pIn->compressBlkWidth == 0) ||
(pIn->compressBlkHeight == 0) ||
(pIn->compressBlkDepth == 0) ||
(pIn->metaBlkWidth == 0) ||
(pIn->metaBlkHeight == 0) ||
(pIn->metaBlkDepth == 0) ||
(pIn->slice > 0 && pIn->dccRamSliceSize == 0))
{
returnCode = ADDR_NOTSUPPORTED;
}
return returnCode;
}
/**
************************************************************************************************************************
* Gfx9Lib::HwlComputeDccAddrFromCoord
@@ -972,59 +1099,48 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlComputeHtileCoordFromAddr(
* Interface function stub of AddrComputeDccAddrFromCoord
*
* @return
* ADDR_E_RETURNCODE
* N/A
************************************************************************************************************************
*/
ADDR_E_RETURNCODE Gfx9Lib::HwlComputeDccAddrFromCoord(
VOID Gfx9Lib::HwlComputeDccAddrFromCoord(
const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT* pIn,
ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT* pOut)
{
ADDR_E_RETURNCODE returnCode = ADDR_OK;
UINT_32 elementBytesLog2 = Log2(pIn->bpp >> 3);
UINT_32 numSamplesLog2 = Log2(pIn->numFrags);
UINT_32 metaBlkWidthLog2 = Log2(pIn->metaBlkWidth);
UINT_32 metaBlkHeightLog2 = Log2(pIn->metaBlkHeight);
UINT_32 metaBlkDepthLog2 = Log2(pIn->metaBlkDepth);
UINT_32 compBlkWidthLog2 = Log2(pIn->compressBlkWidth);
UINT_32 compBlkHeightLog2 = Log2(pIn->compressBlkHeight);
UINT_32 compBlkDepthLog2 = Log2(pIn->compressBlkDepth);
if ((pIn->numMipLevels > 1) || (pIn->mipId > 1) || pIn->dccKeyFlags.linear)
{
returnCode = ADDR_NOTIMPLEMENTED;
}
else
{
UINT_32 elementBytesLog2 = Log2(pIn->bpp >> 3);
UINT_32 numSamplesLog2 = Log2(pIn->numFrags);
UINT_32 metaBlkWidthLog2 = Log2(pIn->metaBlkWidth);
UINT_32 metaBlkHeightLog2 = Log2(pIn->metaBlkHeight);
UINT_32 metaBlkDepthLog2 = Log2(pIn->metaBlkDepth);
UINT_32 compBlkWidthLog2 = Log2(pIn->compressBlkWidth);
UINT_32 compBlkHeightLog2 = Log2(pIn->compressBlkHeight);
UINT_32 compBlkDepthLog2 = Log2(pIn->compressBlkDepth);
MetaEqParams metaEqParams = {pIn->mipId, elementBytesLog2, numSamplesLog2, pIn->dccKeyFlags,
Gfx9DataColor, pIn->swizzleMode, pIn->resourceType,
metaBlkWidthLog2, metaBlkHeightLog2, metaBlkDepthLog2,
compBlkWidthLog2, compBlkHeightLog2, compBlkDepthLog2};
MetaEqParams metaEqParams = {pIn->mipId, elementBytesLog2, numSamplesLog2, pIn->dccKeyFlags,
Gfx9DataColor, pIn->swizzleMode, pIn->resourceType,
metaBlkWidthLog2, metaBlkHeightLog2, metaBlkDepthLog2,
compBlkWidthLog2, compBlkHeightLog2, compBlkDepthLog2};
const CoordEq* pMetaEq = GetMetaEquation(metaEqParams);
const CoordEq* pMetaEq = GetMetaEquation(metaEqParams);
UINT_32 xb = pIn->x / pIn->metaBlkWidth;
UINT_32 yb = pIn->y / pIn->metaBlkHeight;
UINT_32 zb = pIn->slice / pIn->metaBlkDepth;
UINT_32 xb = pIn->x / pIn->metaBlkWidth;
UINT_32 yb = pIn->y / pIn->metaBlkHeight;
UINT_32 zb = pIn->slice / pIn->metaBlkDepth;
UINT_32 pitchInBlock = pIn->pitch / pIn->metaBlkWidth;
UINT_32 sliceSizeInBlock = (pIn->height / pIn->metaBlkHeight) * pitchInBlock;
UINT_32 blockIndex = zb * sliceSizeInBlock + yb * pitchInBlock + xb;
UINT_32 pitchInBlock = pIn->pitch / pIn->metaBlkWidth;
UINT_32 sliceSizeInBlock = (pIn->height / pIn->metaBlkHeight) * pitchInBlock;
UINT_32 blockIndex = zb * sliceSizeInBlock + yb * pitchInBlock + xb;
UINT_32 coords[] = {pIn->x, pIn->y, pIn->slice, pIn->sample, blockIndex};
UINT_64 address = pMetaEq->solve(coords);
UINT_32 coords[] = { pIn->x, pIn->y, pIn->slice, pIn->sample, blockIndex };
UINT_64 address = pMetaEq->solve(coords);
pOut->addr = address >> 1;
pOut->addr = address >> 1;
UINT_32 numPipeBits = GetPipeLog2ForMetaAddressing(pIn->dccKeyFlags.pipeAligned,
pIn->swizzleMode);
UINT_32 numPipeBits = GetPipeLog2ForMetaAddressing(pIn->dccKeyFlags.pipeAligned,
pIn->swizzleMode);
UINT_64 pipeXor = static_cast<UINT_64>(pIn->pipeXor & ((1 << numPipeBits) - 1));
UINT_64 pipeXor = static_cast<UINT_64>(pIn->pipeXor & ((1 << numPipeBits) - 1));
pOut->addr ^= (pipeXor << m_pipeInterleaveLog2);
}
return returnCode;
pOut->addr ^= (pipeXor << m_pipeInterleaveLog2);
}
/**
@@ -1046,7 +1162,7 @@ BOOL_32 Gfx9Lib::HwlInitGlobalParams(
if (m_settings.isArcticIsland)
{
GB_ADDR_CONFIG_gfx9 gbAddrConfig;
GB_ADDR_CONFIG_GFX9 gbAddrConfig;
gbAddrConfig.u32All = pCreateIn->regValue.gbAddrConfig;
@@ -1206,6 +1322,7 @@ BOOL_32 Gfx9Lib::HwlInitGlobalParams(
((m_pipesLog2 == 2) && ((m_seLog2 == 1) || (m_seLog2 == 2)))))
{
ADDR_ASSERT(m_settings.isVega10 == FALSE);
ADDR_ASSERT(m_settings.isRaven == FALSE);
ADDR_ASSERT(m_settings.isVega20 == FALSE);
@@ -1289,18 +1406,19 @@ ChipFamily Gfx9Lib::HwlConvertChipFamily(
m_settings.applyAliasFix = 1;
}
m_settings.isDcn1 = m_settings.isRaven;
if (ASICREV_IS_RENOIR(uChipRevision))
{
m_settings.isRaven = 1;
m_settings.isDcn2 = 1;
}
m_settings.isDcn1 = m_settings.isRaven;
m_settings.metaBaseAlignFix = 1;
break;
default:
ADDR_ASSERT(!"This should be a Fusion");
ADDR_ASSERT(!"No Chip found");
break;
}
@@ -2466,7 +2584,7 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlComputeBlock256Equation(
// Post validation
if (ret == ADDR_OK)
{
ASSERTED Dim2d microBlockDim = Block256_2d[elementBytesLog2];
Dim2d microBlockDim = Block256_2d[elementBytesLog2];
ADDR_ASSERT((2u << GetMaxValidChannelIndex(pEquation->addr, 8, 0)) ==
(microBlockDim.w * (1 << elementBytesLog2)));
ADDR_ASSERT((2u << GetMaxValidChannelIndex(pEquation->addr, 8, 1)) == microBlockDim.h);
@@ -2918,54 +3036,39 @@ BOOL_32 Gfx9Lib::IsValidDisplaySwizzleMode(
{
BOOL_32 support = FALSE;
const UINT_32 swizzleMask = 1 << pIn->swizzleMode;
if (m_settings.isDce12)
{
switch (pIn->swizzleMode)
if (pIn->bpp == 32)
{
case ADDR_SW_256B_D:
case ADDR_SW_256B_R:
support = (pIn->bpp == 32);
break;
case ADDR_SW_LINEAR:
case ADDR_SW_4KB_D:
case ADDR_SW_4KB_R:
case ADDR_SW_64KB_D:
case ADDR_SW_64KB_R:
case ADDR_SW_4KB_D_X:
case ADDR_SW_4KB_R_X:
case ADDR_SW_64KB_D_X:
case ADDR_SW_64KB_R_X:
support = (pIn->bpp <= 64);
break;
default:
break;
support = (Dce12Bpp32SwModeMask & swizzleMask) ? TRUE : FALSE;
}
else if (pIn->bpp <= 64)
{
support = (Dce12NonBpp32SwModeMask & swizzleMask) ? TRUE : FALSE;
}
}
else if (m_settings.isDcn1)
{
switch (pIn->swizzleMode)
if (pIn->bpp < 64)
{
case ADDR_SW_4KB_D:
case ADDR_SW_64KB_D:
case ADDR_SW_64KB_D_T:
case ADDR_SW_4KB_D_X:
case ADDR_SW_64KB_D_X:
support = (pIn->bpp == 64);
break;
case ADDR_SW_LINEAR:
case ADDR_SW_4KB_S:
case ADDR_SW_64KB_S:
case ADDR_SW_64KB_S_T:
case ADDR_SW_4KB_S_X:
case ADDR_SW_64KB_S_X:
support = (pIn->bpp <= 64);
break;
default:
break;
support = (Dcn1NonBpp64SwModeMask & swizzleMask) ? TRUE : FALSE;
}
else if (pIn->bpp == 64)
{
support = (Dcn1Bpp64SwModeMask & swizzleMask) ? TRUE : FALSE;
}
}
else if (m_settings.isDcn2)
{
if (pIn->bpp < 64)
{
support = (Dcn2NonBpp64SwModeMask & swizzleMask) ? TRUE : FALSE;
}
else if (pIn->bpp == 64)
{
support = (Dcn2Bpp64SwModeMask & swizzleMask) ? TRUE : FALSE;
}
}
else
@@ -3578,6 +3681,10 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlGetPreferredSurfaceSetting(
{
allowedSwModeSet.value &= (bpp == 64) ? Dcn1Bpp64SwModeMask : Dcn1NonBpp64SwModeMask;
}
else if (m_settings.isDcn2)
{
allowedSwModeSet.value &= (bpp == 64) ? Dcn2Bpp64SwModeMask : Dcn2NonBpp64SwModeMask;
}
else
{
ADDR_NOT_IMPLEMENTED();
@@ -3626,16 +3733,24 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlGetPreferredSurfaceSetting(
}
else
{
// Always ignore linear swizzle mode if there is other choice.
allowedSwModeSet.swLinear = 0;
const BOOL_32 computeMinSize = (pIn->flags.minimizeAlign == 1) || (pIn->memoryBudget >= 1.0);
if ((height > 1) && (computeMinSize == FALSE))
{
// Always ignore linear swizzle mode if:
// 1. This is a (2D/3D) resource with height > 1
// 2. Client doesn't require computing minimize size
allowedSwModeSet.swLinear = 0;
}
ADDR2_BLOCK_SET allowedBlockSet = GetAllowedBlockSet(allowedSwModeSet, pOut->resourceType);
// Determine block size if there is 2 or more block type candidates
// Determine block size if there are 2 or more block type candidates
if (IsPow2(allowedBlockSet.value) == FALSE)
{
AddrSwizzleMode swMode[AddrBlockMaxTiledType] = { ADDR_SW_LINEAR };
AddrSwizzleMode swMode[AddrBlockMaxTiledType] = {};
swMode[AddrBlockLinear] = ADDR_SW_LINEAR;
swMode[AddrBlockMicro] = ADDR_SW_256B_D;
swMode[AddrBlockThin4KB] = ADDR_SW_4KB_D;
swMode[AddrBlockThin64KB] = ADDR_SW_64KB_D;
@@ -3646,78 +3761,137 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlGetPreferredSurfaceSetting(
swMode[AddrBlockThick64KB] = ADDR_SW_64KB_S;
}
Dim3d blkDim[AddrBlockMaxTiledType] = {{0}, {0}, {0}, {0}, {0}, {0}};
Dim3d padDim[AddrBlockMaxTiledType] = {{0}, {0}, {0}, {0}, {0}, {0}};
UINT_64 padSize[AddrBlockMaxTiledType] = {0};
UINT_64 padSize[AddrBlockMaxTiledType] = {};
const UINT_32 ratioLow = pIn->flags.minimizeAlign ? 1 : (pIn->flags.opt4space ? 3 : 2);
const UINT_32 ratioHi = pIn->flags.minimizeAlign ? 1 : (pIn->flags.opt4space ? 2 : 1);
const UINT_32 ratioLow = computeMinSize ? 1 : (pIn->flags.opt4space ? 3 : 2);
const UINT_32 ratioHi = computeMinSize ? 1 : (pIn->flags.opt4space ? 2 : 1);
const UINT_64 sizeAlignInElement = Max(NextPow2(pIn->minSizeAlign) / (bpp >> 3), 1u);
UINT_32 minSizeBlk = AddrBlockMicro;
UINT_64 minSize = 0;
for (UINT_32 i = AddrBlockMicro; i < AddrBlockMaxTiledType; i++)
{
if (allowedBlockSet.value & (1 << i))
{
ComputeBlockDimensionForSurf(&blkDim[i].w,
&blkDim[i].h,
&blkDim[i].d,
bpp,
numFrags,
pOut->resourceType,
swMode[i]);
ADDR2_COMPUTE_SURFACE_INFO_OUTPUT localOut = {};
if (displayRsrc)
for (UINT_32 i = AddrBlockLinear; i < AddrBlockMaxTiledType; i++)
{
if (IsBlockTypeAvaiable(allowedBlockSet, static_cast<AddrBlockType>(i)))
{
localIn.swizzleMode = swMode[i];
if (localIn.swizzleMode == ADDR_SW_LINEAR)
{
blkDim[i].w = PowTwoAlign(blkDim[i].w, 32);
returnCode = HwlComputeSurfaceInfoLinear(&localIn, &localOut);
}
else
{
returnCode = HwlComputeSurfaceInfoTiled(&localIn, &localOut);
}
padSize[i] = ComputePadSize(&blkDim[i], width, height, numSlices, &padDim[i]);
padSize[i] = PowTwoAlign(padSize[i] * numFrags, sizeAlignInElement);
if ((minSize == 0) ||
((padSize[i] * ratioHi) <= (minSize * ratioLow)))
if (returnCode == ADDR_OK)
{
minSize = padSize[i];
minSizeBlk = i;
padSize[i] = localOut.surfSize;
if ((minSize == 0) ||
BlockTypeWithinMemoryBudget(minSize, padSize[i], ratioLow, ratioHi))
{
minSize = padSize[i];
minSizeBlk = i;
}
}
else
{
ADDR_ASSERT_ALWAYS();
break;
}
}
}
if ((allowedBlockSet.micro == TRUE) &&
(width <= blkDim[AddrBlockMicro].w) &&
(height <= blkDim[AddrBlockMicro].h) &&
(NextPow2(pIn->minSizeAlign) <= Size256))
if (pIn->memoryBudget > 1.0)
{
minSizeBlk = AddrBlockMicro;
// If minimum size is given by swizzle mode with bigger-block type, then don't ever check
// smaller-block type again in coming loop
switch (minSizeBlk)
{
case AddrBlockThick64KB:
allowedBlockSet.macroThin64KB = 0;
case AddrBlockThin64KB:
allowedBlockSet.macroThick4KB = 0;
case AddrBlockThick4KB:
allowedBlockSet.macroThin4KB = 0;
case AddrBlockThin4KB:
allowedBlockSet.micro = 0;
case AddrBlockMicro:
allowedBlockSet.linear = 0;
case AddrBlockLinear:
break;
default:
ADDR_ASSERT_ALWAYS();
break;
}
for (UINT_32 i = AddrBlockMicro; i < AddrBlockMaxTiledType; i++)
{
if ((i != minSizeBlk) &&
IsBlockTypeAvaiable(allowedBlockSet, static_cast<AddrBlockType>(i)))
{
if (BlockTypeWithinMemoryBudget(minSize, padSize[i], 0, 0, pIn->memoryBudget) == FALSE)
{
// Clear the block type if the memory waste is unacceptable
allowedBlockSet.value &= ~(1u << (i - 1));
}
}
}
// Remove linear block type if 2 or more block types are allowed
if (IsPow2(allowedBlockSet.value) == FALSE)
{
allowedBlockSet.linear = 0;
}
// Select the biggest allowed block type
minSizeBlk = Log2NonPow2(allowedBlockSet.value) + 1;
if (minSizeBlk == static_cast<UINT_32>(AddrBlockMaxTiledType))
{
minSizeBlk = AddrBlockLinear;
}
}
if (minSizeBlk == AddrBlockMicro)
switch (minSizeBlk)
{
ADDR_ASSERT(pOut->resourceType != ADDR_RSRC_TEX_3D);
allowedSwModeSet.value &= Gfx9Blk256BSwModeMask;
}
else if (minSizeBlk == AddrBlockThick4KB)
{
ADDR_ASSERT(pOut->resourceType == ADDR_RSRC_TEX_3D);
allowedSwModeSet.value &= Gfx9Rsrc3dThick4KBSwModeMask;
}
else if (minSizeBlk == AddrBlockThin4KB)
{
allowedSwModeSet.value &= (pOut->resourceType == ADDR_RSRC_TEX_3D) ?
Gfx9Rsrc3dThin4KBSwModeMask : Gfx9Blk4KBSwModeMask;
}
else if (minSizeBlk == AddrBlockThick64KB)
{
ADDR_ASSERT(pOut->resourceType == ADDR_RSRC_TEX_3D);
allowedSwModeSet.value &= Gfx9Rsrc3dThick64KBSwModeMask;
}
else
{
ADDR_ASSERT(minSizeBlk == AddrBlockThin64KB);
allowedSwModeSet.value &= (pOut->resourceType == ADDR_RSRC_TEX_3D) ?
Gfx9Rsrc3dThin64KBSwModeMask : Gfx9Blk64KBSwModeMask;
case AddrBlockLinear:
allowedSwModeSet.value &= Gfx9LinearSwModeMask;
break;
case AddrBlockMicro:
ADDR_ASSERT(pOut->resourceType != ADDR_RSRC_TEX_3D);
allowedSwModeSet.value &= Gfx9Blk256BSwModeMask;
break;
case AddrBlockThin4KB:
allowedSwModeSet.value &= (pOut->resourceType == ADDR_RSRC_TEX_3D) ?
Gfx9Rsrc3dThin4KBSwModeMask : Gfx9Blk4KBSwModeMask;
break;
case AddrBlockThick4KB:
ADDR_ASSERT(pOut->resourceType == ADDR_RSRC_TEX_3D);
allowedSwModeSet.value &= Gfx9Rsrc3dThick4KBSwModeMask;
break;
case AddrBlockThin64KB:
allowedSwModeSet.value &= (pOut->resourceType == ADDR_RSRC_TEX_3D) ?
Gfx9Rsrc3dThin64KBSwModeMask : Gfx9Blk64KBSwModeMask;
break;
case AddrBlockThick64KB:
ADDR_ASSERT(pOut->resourceType == ADDR_RSRC_TEX_3D);
allowedSwModeSet.value &= Gfx9Rsrc3dThick64KBSwModeMask;
break;
default:
ADDR_ASSERT_ALWAYS();
allowedSwModeSet.value = 0;
break;
}
}
@@ -3726,8 +3900,8 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlGetPreferredSurfaceSetting(
ADDR2_SWTYPE_SET allowedSwSet = GetAllowedSwSet(allowedSwModeSet);
// Determine swizzle type if there is 2 or more swizzle type candidates
if (IsPow2(allowedSwSet.value) == FALSE)
// Determine swizzle type if there are 2 or more swizzle type candidates
if ((allowedSwSet.value != 0) && (IsPow2(allowedSwSet.value) == FALSE))
{
if (ElemLib::IsBlockCompressed(pIn->format))
{
@@ -3793,10 +3967,10 @@ ADDR_E_RETURNCODE Gfx9Lib::HwlGetPreferredSurfaceSetting(
allowedSwModeSet.value &= Gfx9ZSwModeMask;
}
}
}
// Swizzle type should be determined.
ADDR_ASSERT(IsPow2(GetAllowedSwSet(allowedSwModeSet).value));
// Swizzle type should be determined.
ADDR_ASSERT(IsPow2(GetAllowedSwSet(allowedSwModeSet).value));
}
// Determine swizzle mode now. Always select the "largest" swizzle mode for a given block type + swizzle
// type combination. For example, for AddrBlockThin64KB + ADDR_SW_S, select SW_64KB_S_X(25) if it's
@@ -5056,5 +5230,4 @@ VOID Gfx9Lib::ComputeThinBlockDimension(
} // V2
} // Addr
} // rocr
} // rocr
+41 -31
Просмотреть файл
@@ -1,28 +1,27 @@
/*
* Copyright © 2007-2019 Advanced Micro Devices, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
* AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*/
************************************************************************************************************************
*
* Copyright (C) 2007-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE
*
***********************************************************************************************************************/
/**
************************************************************************************************************************
@@ -38,10 +37,8 @@
#include "coord.h"
namespace rocr {
namespace Addr
{
namespace V2
{
namespace Addr {
namespace V2 {
/**
************************************************************************************************************************
@@ -63,7 +60,8 @@ struct Gfx9ChipSettings
// Display engine IP version name
UINT_32 isDce12 : 1;
UINT_32 isDcn1 : 1;
UINT_32 reserved1 : 30;
UINT_32 isDcn2 : 1;
UINT_32 reserved1 : 29;
// Misc configuration bits
UINT_32 metaBaseAlignFix : 1;
@@ -216,6 +214,16 @@ const UINT_32 Dcn1Bpp64SwModeMask = (1u << ADDR_SW_4KB_D) |
(1u << ADDR_SW_64KB_D_X) |
Dcn1NonBpp64SwModeMask;
const UINT_32 Dcn2NonBpp64SwModeMask = (1u << ADDR_SW_LINEAR) |
(1u << ADDR_SW_64KB_S) |
(1u << ADDR_SW_64KB_S_T) |
(1u << ADDR_SW_64KB_S_X);
const UINT_32 Dcn2Bpp64SwModeMask = (1u << ADDR_SW_64KB_D) |
(1u << ADDR_SW_64KB_D_T) |
(1u << ADDR_SW_64KB_D_X) |
Dcn2NonBpp64SwModeMask;
/**
************************************************************************************************************************
* @brief GFX9 meta equation parameters
@@ -315,7 +323,10 @@ protected:
const ADDR2_COMPUTE_HTILE_COORDFROMADDR_INPUT* pIn,
ADDR2_COMPUTE_HTILE_COORDFROMADDR_OUTPUT* pOut);
virtual ADDR_E_RETURNCODE HwlComputeDccAddrFromCoord(
virtual ADDR_E_RETURNCODE HwlSupportComputeDccAddrFromCoord(
const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT* pIn);
virtual VOID HwlComputeDccAddrFromCoord(
const ADDR2_COMPUTE_DCC_ADDRFROMCOORD_INPUT* pIn,
ADDR2_COMPUTE_DCC_ADDRFROMCOORD_OUTPUT* pOut);
@@ -638,6 +649,5 @@ private:
} // Addr
} // rocr
#endif