2
0

GFX12: Update addrlib

Updated address lib to mesa amd-temp-gfx12 branch.
Commit: 6e5244bd3184f0720197270a10e031b5ecd5fe75

Signed-off-by: David Belanger <david.belanger@amd.com>
Change-Id: Icaead4f38c5f3019c375116070b1f97a927f09b0
Signed-off-by: Chris Freehill <cfreehil@amd.com>


[ROCm/ROCR-Runtime commit: bb02f4e9a7]
Este cometimento está contido em:
David Belanger
2024-02-02 11:06:06 -05:00
cometido por Chris Freehill
ascendente 1b5596a7f2
cometimento bb0a28b8c5
41 ficheiros modificados com 5329 adições e 1159 eliminações
@@ -2,24 +2,7 @@
************************************************************************************************************************
*
* 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
* SPDX-License-Identifier: MIT
*
***********************************************************************************************************************/
@@ -32,10 +15,10 @@
#include "addrinterface.h"
#include "addrlib1.h"
#include "addrlib2.h"
#include "addrlib3.h"
#include "addrcommon.h"
namespace rocr {
using namespace Addr;
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1796,7 +1779,376 @@ ADDR_E_RETURNCODE ADDR_API Addr2IsValidDisplaySwizzleMode(
returnCode = ADDR_ERROR;
}
return returnCode;
return returnCode;
}
} // namespace rocr
/**
****************************************************************************************************
* Addr2GetPossibleSwizzleModes
*
* @brief
* Returns a list of swizzle modes that are valid from the hardware's perspective for the
* client to choose from
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr2GetPossibleSwizzleModes(
ADDR_HANDLE hLib, ///< handle of addrlib
const ADDR2_GET_PREFERRED_SURF_SETTING_INPUT* pIn, ///< [in] input
ADDR2_GET_PREFERRED_SURF_SETTING_OUTPUT* pOut) ///< [out] output
{
ADDR_E_RETURNCODE returnCode;
V2::Lib* pLib = V2::Lib::GetLib(hLib);
if (pLib != NULL)
{
returnCode = pLib->GetPossibleSwizzleModes(pIn, pOut);
}
else
{
returnCode = ADDR_ERROR;
}
return returnCode;
}
/**
****************************************************************************************************
* Addr2GetAllowedBlockSet
*
* @brief
* Returns the set of allowed block sizes given the allowed swizzle modes and resource type
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr2GetAllowedBlockSet(
ADDR_HANDLE hLib, ///< handle of addrlib
ADDR2_SWMODE_SET allowedSwModeSet, ///< [in] allowed swizzle modes
AddrResourceType rsrcType, ///< [in] resource type
ADDR2_BLOCK_SET* pAllowedBlockSet) ///< [out] allowed block sizes
{
ADDR_E_RETURNCODE returnCode;
V2::Lib* pLib = V2::Lib::GetLib(hLib);
if (pLib != NULL)
{
returnCode = pLib->GetAllowedBlockSet(allowedSwModeSet, rsrcType, pAllowedBlockSet);
}
else
{
returnCode = ADDR_ERROR;
}
return returnCode;
}
/**
****************************************************************************************************
* Addr2GetAllowedSwSet
*
* @brief
* Returns the set of allowed swizzle types given the allowed swizzle modes
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr2GetAllowedSwSet(
ADDR_HANDLE hLib, ///< handle of addrlib
ADDR2_SWMODE_SET allowedSwModeSet, ///< [in] allowed swizzle modes
ADDR2_SWTYPE_SET* pAllowedSwSet) ///< [out] allowed swizzle types
{
ADDR_E_RETURNCODE returnCode;
V2::Lib* pLib = V2::Lib::GetLib(hLib);
if (pLib != NULL)
{
returnCode = pLib->GetAllowedSwSet(allowedSwModeSet, pAllowedSwSet);
}
else
{
returnCode = ADDR_ERROR;
}
return returnCode;
}
/**
****************************************************************************************************
* Addr2IsBlockTypeAvailable
*
* @brief
* Determine whether a block type is allowed in a given blockSet
****************************************************************************************************
*/
BOOL_32 Addr2IsBlockTypeAvailable(
ADDR2_BLOCK_SET blockSet,
AddrBlockType blockType)
{
BOOL_32 avail;
if (blockType == AddrBlockLinear)
{
avail = blockSet.linear ? TRUE : FALSE;
}
else
{
avail = blockSet.value & (1 << (static_cast<UINT_32>(blockType) - 1)) ? TRUE : FALSE;
}
return avail;
}
/**
****************************************************************************************************
* Addr2BlockTypeWithinMemoryBudget
*
* @brief
* Determine whether a new block type is acceptable based on memory waste ratio. Will favor
* larger block types.
****************************************************************************************************
*/
BOOL_32 Addr2BlockTypeWithinMemoryBudget(
UINT_64 minSize,
UINT_64 newBlockTypeSize,
UINT_32 ratioLow,
UINT_32 ratioHi,
DOUBLE memoryBudget,
BOOL_32 newBlockTypeBigger)
{
BOOL_32 accept = FALSE;
if (memoryBudget >= 1.0)
{
if (newBlockTypeBigger)
{
if ((static_cast<DOUBLE>(newBlockTypeSize) / minSize) <= memoryBudget)
{
accept = TRUE;
}
}
else
{
if ((static_cast<DOUBLE>(minSize) / newBlockTypeSize) > memoryBudget)
{
accept = TRUE;
}
}
}
else
{
if (newBlockTypeBigger)
{
if ((newBlockTypeSize * ratioHi) <= (minSize * ratioLow))
{
accept = TRUE;
}
}
else
{
if ((newBlockTypeSize * ratioLow) < (minSize * ratioHi))
{
accept = TRUE;
}
}
}
return accept;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Surface functions for Addr3
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
****************************************************************************************************
* Addr3ComputeSurfaceInfo
*
* @brief
* Calculate surface width/height/depth/alignments and suitable tiling mode
*
* @return
* ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr3ComputeSurfaceInfo(
ADDR_HANDLE hLib, ///< address lib handle
const ADDR3_COMPUTE_SURFACE_INFO_INPUT* pIn, ///< [in] surface information
ADDR3_COMPUTE_SURFACE_INFO_OUTPUT* pOut) ///< [out] surface parameters and alignments
{
V3::Lib* pLib = V3::Lib::GetLib(hLib);
ADDR_E_RETURNCODE returnCode = ADDR_OK;
if (pLib != NULL)
{
returnCode = pLib->ComputeSurfaceInfo(pIn, pOut);
}
return returnCode;
}
/**
****************************************************************************************************
* Addr3GetPossibleSwizzleModes
*
* @brief
* Get valid swizzle mode options given image input for further optimal selection
*
* @return
* ADDR_OK if successful, otherwise an error code of ADDR_PARAMSIZEMISMATCH
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr3GetPossibleSwizzleModes(
ADDR_HANDLE hLib, ///< address lib handle
const ADDR3_GET_POSSIBLE_SWIZZLE_MODE_INPUT* pIn, ///< [in] surface information
ADDR3_GET_POSSIBLE_SWIZZLE_MODE_OUTPUT* pOut) ///< [out] allowable swizzle mdoes
{
V3::Lib* pLib = V3::Lib::GetLib(hLib);
ADDR_E_RETURNCODE returnCode = ADDR_OK;
if (pLib != NULL)
{
returnCode = pLib->GetPossibleSwizzleModes(pIn, pOut);
}
return returnCode;
}
/**
****************************************************************************************************
* Addr3ComputeSurfaceAddrFromCoord
*
* @brief
* Compute surface address according to coordinates
*
* @return
* ADDR_OK if successful, otherwise an error code of ADDR_E_RETURNCODE
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr3ComputeSurfaceAddrFromCoord(
ADDR_HANDLE hLib, ///< address lib handle
const ADDR3_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT* pIn, ///< [in] surface info and coordinates
ADDR3_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT* pOut) ///< [out] surface address
{
V3::Lib* pLib = V3::Lib::GetLib(hLib);
ADDR_E_RETURNCODE returnCode = ADDR_OK;
if (pLib != NULL)
{
returnCode = pLib->ComputeSurfaceAddrFromCoord(pIn, pOut);
}
else
{
returnCode = ADDR_ERROR;
}
return returnCode;
}
/**
****************************************************************************************************
* Addr3ComputePipeBankXor
*
* @brief
* Calculate a valid bank pipe xor value for client to use.
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr3ComputePipeBankXor(
ADDR_HANDLE hLib, ///< handle of addrlib
const ADDR3_COMPUTE_PIPEBANKXOR_INPUT* pIn, ///< [in] input
ADDR3_COMPUTE_PIPEBANKXOR_OUTPUT* pOut) ///< [out] output
{
ADDR_E_RETURNCODE returnCode;
V3::Lib* pLib = V3::Lib::GetLib(hLib);
if (pLib != NULL)
{
returnCode = pLib->ComputePipeBankXor(pIn, pOut);
}
else
{
returnCode = ADDR_ERROR;
}
return returnCode;
}
/**
****************************************************************************************************
* Addr3ComputeNonBlockCompressedView
*
* @brief
* Compute non-block-compressed view for a given mipmap level/slice.
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr3ComputeNonBlockCompressedView(
ADDR_HANDLE hLib, ///< handle of addrlib
const ADDR3_COMPUTE_NONBLOCKCOMPRESSEDVIEW_INPUT* pIn, ///< [in] input
ADDR3_COMPUTE_NONBLOCKCOMPRESSEDVIEW_OUTPUT* pOut) ///< [out] output
{
ADDR_E_RETURNCODE returnCode;
V3::Lib* pLib = V3::Lib::GetLib(hLib);
if (pLib != NULL)
{
returnCode = pLib->ComputeNonBlockCompressedView(pIn, pOut);
}
else
{
returnCode = ADDR_ERROR;
}
return returnCode;
}
/**
****************************************************************************************************
* Addr3ComputeSubResourceOffsetForSwizzlePattern
*
* @brief
* Calculate sub resource offset for swizzle pattern.
****************************************************************************************************
*/
VOID ADDR_API Addr3ComputeSubResourceOffsetForSwizzlePattern(
ADDR_HANDLE hLib, ///< handle of addrlib
const ADDR3_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_INPUT* pIn, ///< [in] input
ADDR3_COMPUTE_SUBRESOURCE_OFFSET_FORSWIZZLEPATTERN_OUTPUT* pOut) ///< [out] output
{
V3::Lib* pLib = V3::Lib::GetLib(hLib);
if (pLib != NULL)
{
pLib->ComputeSubResourceOffsetForSwizzlePattern(pIn, pOut);
}
}
/**
****************************************************************************************************
* Addr3ComputeSlicePipeBankXor
*
* @brief
* Calculate slice pipe bank xor value based on base pipe bank xor and slice id.
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr3ComputeSlicePipeBankXor(
ADDR_HANDLE hLib, ///< handle of addrlib
const ADDR3_COMPUTE_SLICE_PIPEBANKXOR_INPUT* pIn, ///< [in] input
ADDR3_COMPUTE_SLICE_PIPEBANKXOR_OUTPUT* pOut) ///< [out] output
{
ADDR_E_RETURNCODE returnCode;
V3::Lib* pLib = V3::Lib::GetLib(hLib);
if (pLib != NULL)
{
returnCode = pLib->ComputeSlicePipeBankXor(pIn, pOut);
}
else
{
returnCode = ADDR_ERROR;
}
return returnCode;
}