amd: update addrlib

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29564>
This commit is contained in:
Marek Olšák 2024-06-06 00:04:54 -04:00
parent 2ea3cb054b
commit ea99c3fcb9
15 changed files with 480 additions and 302 deletions

View file

@ -24,7 +24,7 @@ extern "C"
#endif
#define ADDRLIB_VERSION_MAJOR 9
#define ADDRLIB_VERSION_MINOR 3
#define ADDRLIB_VERSION_MINOR 4
#define ADDRLIB_VERSION ((ADDRLIB_VERSION_MAJOR << 16) | ADDRLIB_VERSION_MINOR)
/// Virtually all interface functions need ADDR_HANDLE as first parameter
@ -4065,7 +4065,8 @@ typedef union _ADDR3_SURFACE_FLAGS
UINT_32 p010 : 1;
UINT_32 view3dAs2dArray : 1;
UINT_32 isVrsImage : 1; ///< This resource is a VRS source image
UINT_32 reserved : 21; ///< Reserved bits
UINT_32 reserved1 : 1;
UINT_32 reserved : 20; ///< Reserved bits
};
UINT_32 value;
@ -4181,7 +4182,8 @@ typedef union _ADDR3_SWMODE_SET
UINT_32 sw3d4kB : 1;
UINT_32 sw3d64kB : 1;
UINT_32 sw3d256kB : 1;
UINT_32 reserved : 24;
UINT_32 reserved1 : 2;
UINT_32 reserved : 22;
};
UINT_32 value;

View file

@ -284,15 +284,15 @@ typedef enum _AddrSwizzleMode
*/
typedef enum _Addr3SwizzleMode
{
ADDR3_LINEAR = 0,
ADDR3_256B_2D = 1,
ADDR3_4KB_2D = 2,
ADDR3_64KB_2D = 3,
ADDR3_256KB_2D = 4,
ADDR3_4KB_3D = 5,
ADDR3_64KB_3D = 6,
ADDR3_256KB_3D = 7,
ADDR3_MAX_TYPE = 8,
ADDR3_LINEAR = 0,
ADDR3_256B_2D = 1,
ADDR3_4KB_2D = 2,
ADDR3_64KB_2D = 3,
ADDR3_256KB_2D = 4,
ADDR3_4KB_3D = 5,
ADDR3_64KB_3D = 6,
ADDR3_256KB_3D = 7,
ADDR3_MAX_TYPE,
} Addr3SwizzleMode;
/**

View file

@ -45,6 +45,7 @@ ADDR_E_RETURNCODE ADDR_API AddrCreate(
returnCode = Lib::Create(pAddrCreateIn, pAddrCreateOut);
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -76,6 +77,7 @@ ADDR_E_RETURNCODE ADDR_API AddrDestroy(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -113,6 +115,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -147,6 +150,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -179,6 +183,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceCoordFromAddr(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -217,6 +222,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeHtileInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -249,6 +255,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeHtileAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -282,6 +289,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeHtileCoordFromAddr(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -321,6 +329,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -353,6 +362,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -386,6 +396,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskCoordFromAddr(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -424,6 +435,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -456,6 +468,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -488,6 +501,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskCoordFromAddr(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -524,6 +538,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeDccInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -554,6 +569,7 @@ UINT_32 ADDR_API AddrGetVersion(ADDR_HANDLE hLib)
version = pLib->GetVersion();
}
ADDR_RESET_DEBUG_PRINTERS();
return version;
}
@ -578,6 +594,7 @@ BOOL_32 ADDR_API AddrUseTileIndex(ADDR_HANDLE hLib)
useTileIndex = pLib->UseTileIndex(0);
}
ADDR_RESET_DEBUG_PRINTERS();
return useTileIndex;
}
@ -602,6 +619,7 @@ BOOL_32 ADDR_API AddrUseCombinedSwizzle(ADDR_HANDLE hLib)
useCombinedSwizzle = pLib->UseCombinedSwizzle();
}
ADDR_RESET_DEBUG_PRINTERS();
return useCombinedSwizzle;
}
@ -633,6 +651,7 @@ ADDR_E_RETURNCODE ADDR_API AddrExtractBankPipeSwizzle(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -664,6 +683,7 @@ ADDR_E_RETURNCODE ADDR_API AddrCombineBankPipeSwizzle(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -695,6 +715,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeSliceSwizzle(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -726,6 +747,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeBaseSwizzle(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -759,6 +781,7 @@ ADDR_E_RETURNCODE ADDR_API ElemFlt32ToDepthPixel(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -792,6 +815,7 @@ ADDR_E_RETURNCODE ADDR_API ElemFlt32ToColorPixel(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -827,6 +851,7 @@ BOOL_32 ADDR_API ElemGetExportNorm(
ADDR_ASSERT(returnCode == ADDR_OK);
ADDR_RESET_DEBUG_PRINTERS();
return enabled;
}
@ -855,6 +880,7 @@ UINT_32 ADDR_API ElemSize(
bpe = pLib->GetBpe(format);
}
ADDR_RESET_DEBUG_PRINTERS();
return bpe;
}
@ -887,6 +913,7 @@ ADDR_E_RETURNCODE ADDR_API AddrConvertTileInfoToHW(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -919,6 +946,7 @@ ADDR_E_RETURNCODE ADDR_API AddrConvertTileIndex(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -951,6 +979,7 @@ ADDR_E_RETURNCODE ADDR_API AddrGetMacroModeIndex(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -983,6 +1012,7 @@ ADDR_E_RETURNCODE ADDR_API AddrConvertTileIndex1(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1018,6 +1048,7 @@ ADDR_E_RETURNCODE ADDR_API AddrGetTileIndex(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1048,6 +1079,7 @@ ADDR_E_RETURNCODE ADDR_API AddrComputePrtInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1079,6 +1111,7 @@ ADDR_E_RETURNCODE ADDR_API AddrGetMaxAlignments(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1110,6 +1143,7 @@ ADDR_E_RETURNCODE ADDR_API AddrGetMaxMetaAlignments(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1147,6 +1181,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeSurfaceInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1180,6 +1215,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeSurfaceAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1213,6 +1249,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeSurfaceCoordFromAddr(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1251,6 +1288,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeHtileInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1284,6 +1322,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeHtileAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1318,6 +1357,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeHtileCoordFromAddr(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1357,6 +1397,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeCmaskInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1390,6 +1431,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeCmaskAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1424,6 +1466,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeCmaskCoordFromAddr(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1462,6 +1505,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeFmaskInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1495,6 +1539,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeFmaskAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1528,6 +1573,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeFmaskCoordFromAddr(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1564,6 +1610,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeDccInfo(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1596,6 +1643,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeDccAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1625,6 +1673,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputePipeBankXor(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1654,6 +1703,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeSlicePipeBankXor(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1683,6 +1733,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeSubResourceOffsetForSwizzlePattern(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1712,6 +1763,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeNonBlockCompressedView(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1741,6 +1793,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2GetPreferredSurfaceSetting(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1777,6 +1830,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2IsValidDisplaySwizzleMode(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1807,6 +1861,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2GetPossibleSwizzleModes(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
/**
@ -1836,6 +1891,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2GetAllowedBlockSet(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1865,6 +1921,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2GetAllowedSwSet(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -1891,6 +1948,7 @@ BOOL_32 Addr2IsBlockTypeAvailable(
avail = blockSet.value & (1 << (static_cast<UINT_32>(blockType) - 1)) ? TRUE : FALSE;
}
ADDR_RESET_DEBUG_PRINTERS();
return avail;
}
@ -1948,6 +2006,7 @@ BOOL_32 Addr2BlockTypeWithinMemoryBudget(
}
}
ADDR_RESET_DEBUG_PRINTERS();
return accept;
}
@ -1980,6 +2039,7 @@ ADDR_E_RETURNCODE ADDR_API Addr3ComputeSurfaceInfo(
returnCode = pLib->ComputeSurfaceInfo(pIn, pOut);
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -2008,6 +2068,7 @@ ADDR_E_RETURNCODE ADDR_API Addr3GetPossibleSwizzleModes(
returnCode = pLib->GetPossibleSwizzleModes(pIn, pOut);
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -2040,6 +2101,7 @@ ADDR_E_RETURNCODE ADDR_API Addr3ComputeSurfaceAddrFromCoord(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -2069,6 +2131,7 @@ ADDR_E_RETURNCODE ADDR_API Addr3ComputePipeBankXor(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -2098,6 +2161,7 @@ ADDR_E_RETURNCODE ADDR_API Addr3ComputeNonBlockCompressedView(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}
@ -2120,6 +2184,7 @@ VOID ADDR_API Addr3ComputeSubResourceOffsetForSwizzlePattern(
{
pLib->ComputeSubResourceOffsetForSwizzlePattern(pIn, pOut);
}
ADDR_RESET_DEBUG_PRINTERS();
}
/**
@ -2148,5 +2213,6 @@ ADDR_E_RETURNCODE ADDR_API Addr3ComputeSlicePipeBankXor(
returnCode = ADDR_ERROR;
}
ADDR_RESET_DEBUG_PRINTERS();
return returnCode;
}

View file

@ -58,64 +58,44 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Debug assertions used in AddrLib
////////////////////////////////////////////////////////////////////////////////////////////////////
#if defined(_WIN32) && (_MSC_VER >= 1400)
#define ADDR_ANALYSIS_ASSUME(expr) __analysis_assume(expr)
#else
#define ADDR_ANALYSIS_ASSUME(expr) do { (void)(expr); } while (0)
#endif
#if DEBUG
#if defined( _WIN32 )
#define ADDR_ASSERT(__e) \
{ \
ADDR_ANALYSIS_ASSUME(__e); \
if ( !((__e) ? TRUE : FALSE)) { ADDR_DBG_BREAK(); } \
}
#else
#define ADDR_ASSERT(__e) if ( !((__e) ? TRUE : FALSE)) { ADDR_DBG_BREAK(); }
#endif
#if ADDR_SILENCE_ASSERT_ALWAYS
#define ADDR_ASSERT_ALWAYS()
#else
#define ADDR_ASSERT_ALWAYS() ADDR_DBG_BREAK()
#endif
#define ADDR_UNHANDLED_CASE() ADDR_ASSERT(!"Unhandled case")
#define ADDR_NOT_IMPLEMENTED() ADDR_ASSERT(!"Not implemented");
#else //DEBUG
#if defined( _WIN32 )
#define ADDR_ASSERT(__e) { ADDR_ANALYSIS_ASSUME(__e); }
#else
#define ADDR_ASSERT(__e)
#endif
#define ADDR_ASSERT_ALWAYS()
#define ADDR_UNHANDLED_CASE()
#define ADDR_NOT_IMPLEMENTED()
#endif //DEBUG
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Debug print macro from legacy address library
// Debug print macro
////////////////////////////////////////////////////////////////////////////////////////////////////
#if DEBUG
#define ADDR_PRNT(a) Object::DebugPrint a
// Forward decl.
namespace Addr {
/// @brief Debug print helper
/// This function sends messages to thread-local callbacks for printing. If no callback is present
/// it is sent to stderr.
///
VOID DebugPrint( const CHAR* pDebugString, ...);
/// This function sets thread-local callbacks (or NULL) for printing. It should be called when
/// entering addrlib and is implicitly called by GetLib().
VOID ApplyDebugPrinters(ADDR_DEBUGPRINT pfnDebugPrint, ADDR_CLIENT_HANDLE pClientHandle);
}
/// @brief Printf-like macro for printing messages
#define ADDR_PRNT(msg, ...) Addr::DebugPrint(msg, ##__VA_ARGS__)
/// @brief Resets thread-local debug state
/// @ingroup util
///
/// This macro resets any thread-local state on where to print a message.
/// It should be called before returning from addrlib.
#define ADDR_RESET_DEBUG_PRINTERS() Addr::ApplyDebugPrinters(NULL, NULL)
/// @brief Macro for reporting informational messages
/// @ingroup util
///
/// This macro optionally prints an informational message to stdout.
/// The first parameter is a condition -- if it is true, nothing is done.
/// The second pararmeter MUST be a parenthesis-enclosed list of arguments,
/// starting with a string. This is passed to printf() or an equivalent
/// in order to format the informational message. For example,
/// ADDR_INFO(0, ("test %d",3) ); prints out "test 3".
/// The second parameter is a message that may have printf-like args.
/// Any remaining parameters are used to format the message.
///
#define ADDR_INFO(cond, a) \
{ if (!(cond)) { ADDR_PRNT(a); } }
#define ADDR_INFO(cond, msg, ...) \
do { if (!(cond)) { Addr::DebugPrint(msg, ##__VA_ARGS__); } } while (0)
/// @brief Macro for reporting error warning messages
@ -124,17 +104,14 @@
/// This macro optionally prints an error warning message to stdout,
/// followed by the file name and line number where the macro was called.
/// The first parameter is a condition -- if it is true, nothing is done.
/// The second pararmeter MUST be a parenthesis-enclosed list of arguments,
/// starting with a string. This is passed to printf() or an equivalent
/// in order to format the informational message. For example,
/// ADDR_WARN(0, ("test %d",3) ); prints out "test 3" followed by
/// a second line with the file name and line number.
/// The second parameter is a message that may have printf-like args.
/// Any remaining parameters are used to format the message.
///
#define ADDR_WARN(cond, a) \
{ if (!(cond)) \
{ ADDR_PRNT(a); \
ADDR_PRNT((" WARNING in file %s, line %d\n", __FILE__, __LINE__)); \
} }
#define ADDR_WARN(cond, msg, ...) \
do { if (!(cond)) \
{ Addr::DebugPrint(msg, ##__VA_ARGS__); \
Addr::DebugPrint(" WARNING in file %s, line %d\n", __FILE__, __LINE__); \
} } while (0)
/// @brief Macro for reporting fatal error conditions
@ -144,34 +121,76 @@
/// after printing an error warning message to stdout,
/// followed by the file name and line number where the macro was called.
/// The first parameter is a condition -- if it is true, nothing is done.
/// The second pararmeter MUST be a parenthesis-enclosed list of arguments,
/// starting with a string. This is passed to printf() or an equivalent
/// in order to format the informational message. For example,
/// ADDR_EXIT(0, ("test %d",3) ); prints out "test 3" followed by
/// a second line with the file name and line number, then stops execution.
/// The second parameter is a message that may have printf-like args.
/// Any remaining parameters are used to format the message.
///
#define ADDR_EXIT(cond, a) \
{ if (!(cond)) \
{ ADDR_PRNT(a); ADDR_DBG_BREAK();\
} }
#define ADDR_EXIT(cond, msg, ...) \
do { if (!(cond)) \
{ Addr::DebugPrint(msg, ##__VA_ARGS__); ADDR_DBG_BREAK(); \
} } while (0)
#else // DEBUG
#define ADDRDPF 1 ? (void)0 : (void)
#define ADDR_RESET_DEBUG_PRINTERS()
#define ADDR_PRNT(a)
#define ADDR_PRNT(msg, ...)
#define ADDR_DBG_BREAK()
#define ADDR_INFO(cond, a)
#define ADDR_INFO(cond, msg, ...)
#define ADDR_WARN(cond, a)
#define ADDR_WARN(cond, msg, ...)
#define ADDR_EXIT(cond, a)
#define ADDR_EXIT(cond, msg, ...)
#endif // DEBUG
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// Debug assertions used in AddrLib
////////////////////////////////////////////////////////////////////////////////////////////////////
#if defined(_WIN32) && (_MSC_VER >= 1400)
#define ADDR_ANALYSIS_ASSUME(expr) __analysis_assume(expr)
#else
#define ADDR_ANALYSIS_ASSUME(expr) do { (void)(expr); } while (0)
#endif
#if DEBUG
#define ADDR_BREAK_WITH_MSG(msg) \
do { \
Addr::DebugPrint(msg " in file %s:%d\n", __FILE__, __LINE__); \
ADDR_DBG_BREAK(); \
} while (0)
#define ADDR_ASSERT(__e) \
do { \
ADDR_ANALYSIS_ASSUME(__e); \
if ( !((__e) ? TRUE : FALSE)) { \
ADDR_BREAK_WITH_MSG("Assertion '" #__e "' failed"); \
} \
} while (0)
#if ADDR_SILENCE_ASSERT_ALWAYS
#define ADDR_ASSERT_ALWAYS()
#else
#define ADDR_ASSERT_ALWAYS() ADDR_BREAK_WITH_MSG("Unconditional assert failed")
#endif
#define ADDR_UNHANDLED_CASE() ADDR_BREAK_WITH_MSG("Unhandled case")
#define ADDR_NOT_IMPLEMENTED() ADDR_BREAK_WITH_MSG("Not implemented");
#else //DEBUG
#if defined( _WIN32 )
#define ADDR_ASSERT(__e) ADDR_ANALYSIS_ASSUME(__e)
#else
#define ADDR_ASSERT(__e)
#endif
#define ADDR_ASSERT_ALWAYS()
#define ADDR_UNHANDLED_CASE()
#define ADDR_NOT_IMPLEMENTED()
#endif //DEBUG
////////////////////////////////////////////////////////////////////////////////////////////////////
#if defined(static_assert)
#define ADDR_C_ASSERT(__e) static_assert(__e, "")
#else

View file

@ -173,6 +173,10 @@ ADDR_E_RETURNCODE Lib::Create(
}
}
#if DEBUG
ApplyDebugPrinters(pCreateIn->callbacks.debugPrint, pCreateIn->hClient);
#endif
if ((returnCode == ADDR_OK) &&
(pCreateIn->callbacks.allocSysMem != NULL) &&
(pCreateIn->callbacks.freeSysMem != NULL))
@ -370,7 +374,14 @@ VOID Lib::SetMaxAlignments()
Lib* Lib::GetLib(
ADDR_HANDLE hLib) ///< [in] handle of ADDR_HANDLE
{
return static_cast<Addr::Lib*>(hLib);
Lib* pLib = static_cast<Addr::Lib*>(hLib);
#if DEBUG
if (pLib != NULL)
{
pLib->SetDebugPrinters();
}
#endif
return pLib;
}
/**

View file

@ -126,7 +126,7 @@ Lib* Lib::GetLib(
ADDR_ASSERT_ALWAYS();
hLib = NULL;
}
return static_cast<Lib*>(hLib);
return static_cast<Lib*>(pAddrLib);
}

View file

@ -115,7 +115,6 @@ Lib* Lib::GetLib(
ADDR_HANDLE hLib) ///< [in] handle of ADDR_HANDLE
{
Addr::Lib* pAddrLib = Addr::Lib::GetLib(hLib);
if ((pAddrLib != NULL) &&
(pAddrLib->GetChipFamily() <= ADDR_CHIP_FAMILY_VI))
{
@ -124,7 +123,7 @@ Lib* Lib::GetLib(
hLib = NULL;
}
return static_cast<Lib*>(hLib);
return static_cast<Lib*>(pAddrLib);
}

View file

@ -77,7 +77,6 @@ Lib::Lib(
*/
void Lib::Init()
{
memset(m_equationTable, 0, sizeof(m_equationTable));
memset(m_blockDimensionTable, 0, sizeof(m_blockDimensionTable));
// There is no equation table entry for linear, so start at the "next" swizzle mode entry.
@ -125,7 +124,7 @@ Lib* Lib::GetLib(
{
Addr::Lib* pAddrLib = Addr::Lib::GetLib(hLib);
return static_cast<Lib*>(hLib);
return static_cast<Lib*>(pAddrLib);
}
/**
@ -334,16 +333,16 @@ ADDR_E_RETURNCODE Lib::ComputeSurfaceInfo(
* Lib::GetPossibleSwizzleModes
*
* @brief
* Interface function stub of AddrComputeSurfaceInfo.
* Populates pOut with a list of the possible swizzle modes for the described surface.
*
* @return
* ADDR_E_RETURNCODE
************************************************************************************************************************
*/
ADDR_E_RETURNCODE Lib::GetPossibleSwizzleModes(
const ADDR3_GET_POSSIBLE_SWIZZLE_MODE_INPUT* pIn, ///< [in] input structure
ADDR3_GET_POSSIBLE_SWIZZLE_MODE_OUTPUT* pOut ///< [out] output structure
) const
const ADDR3_GET_POSSIBLE_SWIZZLE_MODE_INPUT* pIn,
ADDR3_GET_POSSIBLE_SWIZZLE_MODE_OUTPUT* pOut
) const
{
ADDR_E_RETURNCODE returnCode = ADDR_OK;
@ -358,130 +357,7 @@ ADDR_E_RETURNCODE Lib::GetPossibleSwizzleModes(
if (returnCode == ADDR_OK)
{
const ADDR3_SURFACE_FLAGS flags = pIn->flags;
// VRS images can only be 2D from the client API rules.
ADDR_ASSERT((flags.isVrsImage == 0) || IsTex2d(pIn->resourceType));
if (pIn->bpp == 96)
{
pOut->validModes.swLinear = 1;
}
// Depth/Stencil images can't be linear and must be 2D swizzle modes.
// These three are related to DB block that supports only SW_64KB_2D and SW_256KB_2D for DSV.
else if (flags.depth || flags.stencil)
{
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
// The organization of elements in the hierarchical surface is the same as any other surface, and it can support
// any 2D swizzle mode (SW_256_2D, SW_4KB_2D, SW_64KB_2D, or SW_256KB_2D). The swizzle mode can be selected
// orthogonally to the underlying z or stencil surface.
else if (pIn->flags.hiZHiS)
{
pOut->validModes.sw2d256B = 1;
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
// MSAA can't be linear and must be 2D swizzle modes.
else if (pIn->numSamples > 1)
{
// NOTE: SW_256B_2D still supports MSAA. The removal of 256B for MSAA is reverted in HW Doc.
pOut->validModes.sw2d256B = 1;
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
// Block-compressed images need to be either using 2D or linear swizzle modes.
else if (flags.blockCompressed)
{
pOut->validModes.swLinear = 1;
// We find cases where Tex3d BlockCompressed image adopts 2D_256B should be prohibited.
if (IsTex3d(pIn->resourceType) == FALSE)
{
pOut->validModes.sw2d256B = 1;
}
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
else if (IsTex1d(pIn->resourceType))
{
pOut->validModes.swLinear = 1;
pOut->validModes.sw2d256B = 1;
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
else if (flags.nv12 || flags.p010 || IsTex2d(pIn->resourceType) || flags.view3dAs2dArray)
{
// NV12 and P010 support
// SW_LINEAR, SW_256B_2D, SW_4KB_2D, SW_64KB_2D, SW_256KB_2D
// There could be more multimedia formats that require more hw specific tiling modes...
// The exception is VRS images.
// Linear is not allowed and the VRS surface needs to be 8BPP format.
if (flags.isVrsImage)
{
ADDR_ASSERT(pIn->bpp == 8);
}
else
{
pOut->validModes.swLinear = 1;
}
if (flags.view3dAs2dArray == 0)
{
// ADDR3_256B_2D can't support 3D images.
pOut->validModes.sw2d256B = 1;
}
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
else if (IsTex3d(pIn->resourceType))
{
// An eventual determination would be based on pal setting of height_watermark and depth_watermark.
// However, we just adopt the simpler logic currently.
// For 3D images w/ view3dAs2dArray = 0, SW_3D is preferred.
// For 3D images w/ view3dAs2dArray = 1, it should go to 2D path above.
// Enable linear since client may force linear tiling for 3D texture that does not set view3dAs2dArray.
pOut->validModes.swLinear = 1;
pOut->validModes.sw3d4kB = 1;
pOut->validModes.sw3d64kB = 1;
pOut->validModes.sw3d256kB = 1;
}
}
constexpr UINT_32 Size256 = 256u;
constexpr UINT_32 Size4K = 4 * 1024;
constexpr UINT_32 Size64K = 64 * 1024;
constexpr UINT_32 Size256K = 256 * 1024;
// If client specifies a max alignment, remove swizzles that require alignment beyond it.
if (pIn->maxAlign != 0)
{
if (pIn->maxAlign < Size256K)
{
pOut->validModes.value &= ~Gfx12Blk256KBSwModeMask;
}
if (pIn->maxAlign < Size64K)
{
pOut->validModes.value &= ~Gfx12Blk64KBSwModeMask;
}
if (pIn->maxAlign < Size4K)
{
pOut->validModes.value &= ~Gfx12Blk4KBSwModeMask;
}
if (pIn->maxAlign < Size256)
{
pOut->validModes.value &= ~Gfx12Blk256BSwModeMask;
}
returnCode = HwlGetPossibleSwizzleModes(pIn, pOut);
}
return returnCode;

View file

@ -24,6 +24,11 @@ namespace Addr
namespace V3
{
constexpr UINT_32 Size256 = 256u;
constexpr UINT_32 Size4K = 4 * 1024;
constexpr UINT_32 Size64K = 64 * 1024;
constexpr UINT_32 Size256K = 256 * 1024;
struct ADDR3_COORD
{
INT_32 x;
@ -41,22 +46,6 @@ struct ADDR3_COMPUTE_SURFACE_INFO_PARAMS_INPUT
void* pvAddrParams;
};
/**
************************************************************************************************************************
* @brief Bitmasks for swizzle mode determination on GFX12
************************************************************************************************************************
*/
const UINT_32 Gfx12Blk256KBSwModeMask = (1u << ADDR3_256KB_2D) |
(1u << ADDR3_256KB_3D);
const UINT_32 Gfx12Blk64KBSwModeMask = (1u << ADDR3_64KB_2D) |
(1u << ADDR3_64KB_3D);
const UINT_32 Gfx12Blk4KBSwModeMask = (1u << ADDR3_4KB_2D) |
(1u << ADDR3_4KB_3D);
const UINT_32 Gfx12Blk256BSwModeMask = (1u << ADDR3_256B_2D);
/**
************************************************************************************************************************
* @brief Bit setting for swizzle pattern
@ -228,8 +217,6 @@ protected:
static const UINT_32 MaxMsaaRateLog2 = 4;
// Max number of bpp (8bpp/16bpp/32bpp/64bpp/128bpp)
static const UINT_32 MaxElementBytesLog2 = 5;
// Number of unique swizzle patterns (one entry per swizzle mode + MSAA + bpp configuration)
static const UINT_32 NumSwizzlePatterns = 19 * MaxElementBytesLog2;
// Number of equation entries in the table
UINT_32 m_numEquations;
@ -237,9 +224,6 @@ protected:
// Swizzle equation lookup table according to swizzle mode, MSAA sample rate and bpp. This does not include linear.
UINT_32 m_equationLookupTable[ADDR3_MAX_TYPE - 1][MaxMsaaRateLog2][MaxElementBytesLog2];
// Equation table
ADDR_EQUATION m_equationTable[NumSwizzlePatterns];
// Block dimension lookup table according to swizzle mode, MSAA sample rate and bpp. This includes linear.
ADDR_EXTENT3D m_blockDimensionTable[ADDR3_MAX_TYPE][MaxMsaaRateLog2][MaxElementBytesLog2];
@ -249,6 +233,8 @@ protected:
UINT_32 elementBytesLog2,
UINT_32 value)
{
// m_equationLookupTable doesn't include linear, so we must exclude linear when calling this function.
ADDR_ASSERT(swMode != ADDR3_LINEAR);
m_equationLookupTable[swMode - 1][msaaLog2][elementBytesLog2] = value;
}
@ -257,7 +243,14 @@ protected:
UINT_32 msaaLog2,
UINT_32 elementBytesLog2) const
{
return m_equationLookupTable[swMode - 1][msaaLog2][elementBytesLog2];
UINT_32 res = ADDR_INVALID_EQUATION_INDEX;
// m_equationLookupTable doesn't include linear
if (swMode != ADDR3_LINEAR)
{
res = m_equationLookupTable[swMode - 1][msaaLog2][elementBytesLog2];
}
return res;
}
const ADDR_EXTENT3D GetBlockDimensionTableEntry(
@ -337,7 +330,11 @@ protected:
// The max alignment is tied to the swizzle mode and since the largest swizzle mode is 256kb, so the maximal
// alignment is also 256kb.
virtual UINT_32 HwlComputeMaxBaseAlignments() const { return 262144u; }
virtual UINT_32 HwlComputeMaxBaseAlignments() const { return Size256K; }
virtual ADDR_E_RETURNCODE HwlGetPossibleSwizzleModes(
const ADDR3_GET_POSSIBLE_SWIZZLE_MODE_INPUT* pIn,
ADDR3_GET_POSSIBLE_SWIZZLE_MODE_OUTPUT* pOut) const = 0;
virtual BOOL_32 HwlInitGlobalParams(const ADDR_CREATE_INPUT* pCreateIn)
{

View file

@ -17,9 +17,18 @@
#include "addrinterface.h"
#include "addrobject.h"
#if DEBUG
#include <stdio.h>
#endif
namespace Addr
{
#if DEBUG && ADDR_ALLOW_TLS
thread_local ADDR_CLIENT_HANDLE g_clientHandle = nullptr;
thread_local ADDR_DEBUGPRINT g_pfnDebugPrint = nullptr;
#endif
/**
****************************************************************************************************
* Object::Object
@ -181,9 +190,32 @@ VOID Object::operator delete(
ClientFree(pObjMem, &pObj->m_client);
}
#if DEBUG
/**
****************************************************************************************************
* Object::DebugPrint
* ApplyDebugPrinters
*
* @brief
* Sets the debug printers via TLS
*
* @return
* N/A
****************************************************************************************************
*/
VOID ApplyDebugPrinters(
ADDR_DEBUGPRINT pfnDebugPrint,
ADDR_CLIENT_HANDLE pClientHandle)
{
#if ADDR_ALLOW_TLS
g_clientHandle = pClientHandle;
g_pfnDebugPrint = pfnDebugPrint;
#endif
}
/**
****************************************************************************************************
* DebugPrint
*
* @brief
* Print debug message
@ -192,31 +224,38 @@ VOID Object::operator delete(
* N/A
****************************************************************************************************
*/
VOID Object::DebugPrint(
VOID DebugPrint(
const CHAR* pDebugString, ///< [in] Debug string
...
) const
)
{
#if DEBUG
if (m_client.callbacks.debugPrint != NULL)
va_list ap;
va_start(ap, pDebugString);
#if ADDR_ALLOW_TLS
if (g_pfnDebugPrint != NULL)
{
va_list ap;
va_start(ap, pDebugString);
ADDR_DEBUGPRINT_INPUT debugPrintInput = {0};
debugPrintInput.size = sizeof(ADDR_DEBUGPRINT_INPUT);
debugPrintInput.pDebugString = const_cast<CHAR*>(pDebugString);
debugPrintInput.hClient = m_client.handle;
debugPrintInput.hClient = g_clientHandle;
va_copy(debugPrintInput.ap, ap);
m_client.callbacks.debugPrint(&debugPrintInput);
g_pfnDebugPrint(&debugPrintInput);
va_end(ap);
va_end(debugPrintInput.ap);
}
else
#endif
{
#if ADDR_ALLOW_STDIO
fprintf(stderr, "Warning: Addrlib assert function called without corresponding 'ApplyDebugPrinters'\n");
vfprintf(stderr, pDebugString, ap);
#endif
}
va_end(ap);
}
#endif
} // Addr

View file

@ -55,7 +55,10 @@ public:
VOID* Alloc(size_t size) const;
VOID Free(VOID* pObj) const;
VOID DebugPrint(const CHAR* pDebugString, ...) const;
#if DEBUG
// This function should be called on every addrlib entrypoint (usually implicit by GetLib())
VOID SetDebugPrinters() const { ApplyDebugPrinters(m_client.callbacks.debugPrint, m_client.handle); }
#endif
const Client* GetClient() const {return &m_client;}

View file

@ -1003,7 +1003,9 @@ UINT_32 Gfx11Lib::GetMetaBlkSize(
if ((pipeRotateLog2 > 0) &&
(elemLog2 == 4) &&
(numSamplesLog2 == 3) &&
(IsZOrderSwizzle(swizzleMode) || (GetEffectiveNumPipes() > 3)))
(IsZOrderSwizzle(swizzleMode) ||
IsRtOptSwizzle(swizzleMode) ||
(GetEffectiveNumPipes() > 3)))
{
overlapLog2++;
}

View file

@ -184,39 +184,35 @@ VOID Gfx12Lib::InitEquationTable()
{
const Addr3SwizzleMode swMode = static_cast<Addr3SwizzleMode>(swModeIdx);
ADDR_ASSERT(IsValidSwMode(swMode));
if (IsLinear(swMode))
// Skip linear equation (data table is not useful for 2D/3D images-- only contains x-coordinate bits)
if (IsValidSwMode(swMode) && (IsLinear(swMode) == false))
{
// Skip linear equation (data table is not useful for 2D/3D images-- only contains x-coordinate bits)
continue;
}
const UINT_32 maxMsaa = Is2dSwizzle(swMode) ? MaxMsaaRateLog2 : 1;
const UINT_32 maxMsaa = Is2dSwizzle(swMode) ? MaxMsaaRateLog2 : 1;
for (UINT_32 msaaIdx = 0; msaaIdx < maxMsaa; msaaIdx++)
{
for (UINT_32 elemLog2 = 0; elemLog2 < MaxElementBytesLog2; elemLog2++)
for (UINT_32 msaaIdx = 0; msaaIdx < maxMsaa; msaaIdx++)
{
UINT_32 equationIndex = ADDR_INVALID_EQUATION_INDEX;
const ADDR_SW_PATINFO* pPatInfo = GetSwizzlePatternInfo(swMode, elemLog2, 1 << msaaIdx);
if (pPatInfo != NULL)
for (UINT_32 elemLog2 = 0; elemLog2 < MaxElementBytesLog2; elemLog2++)
{
ADDR_EQUATION equation = {};
UINT_32 equationIndex = ADDR_INVALID_EQUATION_INDEX;
const ADDR_SW_PATINFO* pPatInfo = GetSwizzlePatternInfo(swMode, elemLog2, 1 << msaaIdx);
ConvertSwizzlePatternToEquation(elemLog2, swMode, pPatInfo, &equation);
if (pPatInfo != NULL)
{
ADDR_EQUATION equation = {};
equationIndex = m_numEquations;
ADDR_ASSERT(equationIndex < NumSwizzlePatterns);
ConvertSwizzlePatternToEquation(elemLog2, swMode, pPatInfo, &equation);
m_equationTable[equationIndex] = equation;
m_numEquations++;
}
SetEquationTableEntry(swMode, msaaIdx, elemLog2, equationIndex);
}
}
}
equationIndex = m_numEquations;
ADDR_ASSERT(equationIndex < NumSwizzlePatterns);
m_equationTable[equationIndex] = equation;
m_numEquations++;
}
SetEquationTableEntry(swMode, msaaIdx, elemLog2, equationIndex);
} // loop through bpp sizes
} // loop through MSAA rates
} // End check for valid non-linear modes
} // loop through swizzle modes
}
/**
@ -239,11 +235,7 @@ UINT_32 Gfx12Lib::HwlGetEquationIndex(
if ((pIn->resourceType == ADDR_RSRC_TEX_2D) ||
(pIn->resourceType == ADDR_RSRC_TEX_3D))
{
const UINT_32 swMode = static_cast<UINT_32>(pIn->swizzleMode);
const UINT_32 msaaIdx = Log2(pIn->numSamples);
const UINT_32 elemLog2 = Log2(pIn->bpp >> 3);
equationIdx = m_equationLookupTable[swMode][msaaIdx][elemLog2];
equationIdx = GetEquationTableEntry(pIn->swizzleMode, Log2(pIn->numSamples), Log2(pIn->bpp >> 3));
}
return equationIdx;
@ -270,22 +262,24 @@ VOID Gfx12Lib::InitBlockDimensionTable()
for (UINT_32 swModeIdx = 0; swModeIdx < ADDR3_MAX_TYPE; swModeIdx++)
{
const Addr3SwizzleMode swMode = static_cast<Addr3SwizzleMode>(swModeIdx);
ADDR_ASSERT(IsValidSwMode(swMode));
surfaceInfo.swizzleMode = swMode;
const UINT_32 maxMsaa = Is2dSwizzle(swMode) ? MaxMsaaRateLog2 : 1;
for (UINT_32 msaaIdx = 0; msaaIdx < maxMsaa; msaaIdx++)
if (IsValidSwMode(swMode))
{
surfaceInfo.numSamples = (1u << msaaIdx);
for (UINT_32 elementBytesLog2 = 0; elementBytesLog2 < MaxElementBytesLog2; elementBytesLog2++)
surfaceInfo.swizzleMode = swMode;
const UINT_32 maxMsaa = Is2dSwizzle(swMode) ? MaxMsaaRateLog2 : 1;
for (UINT_32 msaaIdx = 0; msaaIdx < maxMsaa; msaaIdx++)
{
surfaceInfo.bpp = (1u << (elementBytesLog2 + 3));
ADDR3_COMPUTE_SURFACE_INFO_PARAMS_INPUT input{ &surfaceInfo };
ComputeBlockDimensionForSurf(&input, &m_blockDimensionTable[swModeIdx][msaaIdx][elementBytesLog2]);
}
}
}
surfaceInfo.numSamples = (1u << msaaIdx);
for (UINT_32 elementBytesLog2 = 0; elementBytesLog2 < MaxElementBytesLog2; elementBytesLog2++)
{
surfaceInfo.bpp = (1u << (elementBytesLog2 + 3));
ADDR3_COMPUTE_SURFACE_INFO_PARAMS_INPUT input{ &surfaceInfo };
ComputeBlockDimensionForSurf(&input, &m_blockDimensionTable[swModeIdx][msaaIdx][elementBytesLog2]);
} // end loop through bpp sizes
} // end loop through MSAA rates
} // end check for valid swizzle modes
} // end loop through swizzle modes
}
/**
@ -788,6 +782,9 @@ ADDR_E_RETURNCODE Gfx12Lib::HwlComputeSurfaceAddrFromCoordTiled(
{
const UINT_32 elemLog2 = Log2(pIn->bpp >> 3);
const UINT_32 blkSizeLog2 = GetBlockSizeLog2(pIn->swizzleMode);
// Addr3 equation table excludes linear swizzle mode, and fortunately HwlComputeSurfaceAddrFromCoordTiled() is
// only called for non-linear swizzle mode.
const UINT_32 eqIndex = GetEquationTableEntry(pIn->swizzleMode, Log2(localIn.numSamples), elemLog2);
if (eqIndex != ADDR_INVALID_EQUATION_INDEX)
@ -1367,6 +1364,10 @@ ADDR_E_RETURNCODE Gfx12Lib::HwlComputeSlicePipeBankXor(
if (pPatInfo != NULL)
{
const UINT_32 elemLog2 = Log2(pIn->bpe >> 3);
// Addr3 equation table excludes linear swizzle mode, and fortunately when calling
// HwlComputeSlicePipeBankXor the swizzle mode is non-linear, so we don't need to worry about negative
// table index.
const UINT_32 eqIndex = GetEquationTableEntry(pIn->swizzleMode, Log2(pIn->numSamples), elemLog2);
const UINT_32 pipeBankXorOffset = ComputeOffsetFromEquation(&m_equationTable[eqIndex],
@ -1636,5 +1637,145 @@ ADDR_EXTENT3D Gfx12Lib::HwlGetMipInTailMaxSize(
return mipTailDim;
}
/**
************************************************************************************************************************
* Lib::GetPossibleSwizzleModes
*
* @brief
* GFX12 specific implementation of Addr3GetPossibleSwizzleModes
*
* @return
* ADDR_E_RETURNCODE
************************************************************************************************************************
*/
ADDR_E_RETURNCODE Gfx12Lib::HwlGetPossibleSwizzleModes(
const ADDR3_GET_POSSIBLE_SWIZZLE_MODE_INPUT* pIn, ///< [in] input structure
ADDR3_GET_POSSIBLE_SWIZZLE_MODE_OUTPUT* pOut ///< [out] output structure
) const
{
ADDR_E_RETURNCODE returnCode = ADDR_OK;
const ADDR3_SURFACE_FLAGS flags = pIn->flags;
// VRS images can only be 2D from the client API rules.
ADDR_ASSERT((flags.isVrsImage == 0) || IsTex2d(pIn->resourceType));
if (pIn->bpp == 96)
{
pOut->validModes.swLinear = 1;
}
// Depth/Stencil images can't be linear and must be 2D swizzle modes.
// These three are related to DB block that supports only SW_64KB_2D and SW_256KB_2D for DSV.
else if (flags.depth || flags.stencil)
{
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
// The organization of elements in the hierarchical surface is the same as any other surface, and it can support
// any 2D swizzle mode (SW_256_2D, SW_4KB_2D, SW_64KB_2D, or SW_256KB_2D). The swizzle mode can be selected
// orthogonally to the underlying z or stencil surface.
else if (pIn->flags.hiZHiS)
{
pOut->validModes.sw2d256B = 1;
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
// MSAA can't be linear and must be 2D swizzle modes.
else if (pIn->numSamples > 1)
{
pOut->validModes.sw2d256B = 1;
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
// Block-compressed images need to be either using 2D or linear swizzle modes.
else if (flags.blockCompressed)
{
pOut->validModes.swLinear = 1;
// We find cases where Tex3d BlockCompressed image adopts 2D_256B should be prohibited.
if (IsTex3d(pIn->resourceType) == FALSE)
{
pOut->validModes.sw2d256B = 1;
}
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
else if (IsTex1d(pIn->resourceType))
{
pOut->validModes.swLinear = 1;
pOut->validModes.sw2d256B = 1;
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
else if (flags.nv12 || flags.p010 || IsTex2d(pIn->resourceType) || flags.view3dAs2dArray)
{
// NV12 and P010 support
// SW_LINEAR, SW_256B_2D, SW_4KB_2D, SW_64KB_2D, SW_256KB_2D
// There could be more multimedia formats that require more hw specific tiling modes...
// The exception is VRS images.
// Linear is not allowed and the VRS surface needs to be 8BPP format.
if (flags.isVrsImage)
{
ADDR_ASSERT(pIn->bpp == 8);
}
else
{
pOut->validModes.swLinear = 1;
}
if (flags.view3dAs2dArray == 0)
{
// ADDR3_256B_2D can't support 3D images.
pOut->validModes.sw2d256B = 1;
}
pOut->validModes.sw2d4kB = 1;
pOut->validModes.sw2d64kB = 1;
pOut->validModes.sw2d256kB = 1;
}
else if (IsTex3d(pIn->resourceType))
{
// An eventual determination would be based on pal setting of height_watermark and depth_watermark.
// However, we just adopt the simpler logic currently.
// For 3D images w/ view3dAs2dArray = 0, SW_3D is preferred.
// For 3D images w/ view3dAs2dArray = 1, it should go to 2D path above.
// Enable linear since client may force linear tiling for 3D texture that does not set view3dAs2dArray.
pOut->validModes.swLinear = 1;
pOut->validModes.sw3d4kB = 1;
pOut->validModes.sw3d64kB = 1;
pOut->validModes.sw3d256kB = 1;
}
// If client specifies a max alignment, remove swizzles that require alignment beyond it.
if (pIn->maxAlign != 0)
{
if (pIn->maxAlign < Size256K)
{
pOut->validModes.value &= ~Blk256KBSwModeMask;
}
if (pIn->maxAlign < Size64K)
{
pOut->validModes.value &= ~Blk64KBSwModeMask;
}
if (pIn->maxAlign < Size4K)
{
pOut->validModes.value &= ~Blk4KBSwModeMask;
}
if (pIn->maxAlign < Size256)
{
pOut->validModes.value &= ~Blk256BSwModeMask;
}
}
return returnCode;
}
} // V3
} // Addr

View file

@ -97,6 +97,10 @@ protected:
return m_numEquations;
}
virtual ADDR_E_RETURNCODE HwlGetPossibleSwizzleModes(
const ADDR3_GET_POSSIBLE_SWIZZLE_MODE_INPUT* pIn,
ADDR3_GET_POSSIBLE_SWIZZLE_MODE_OUTPUT* pOut) const override;
virtual ChipFamily HwlConvertChipFamily(UINT_32 uChipFamily, UINT_32 uChipRevision) override;
protected:
@ -111,6 +115,25 @@ protected:
private:
static const SwizzleModeFlags SwizzleModeTable[ADDR3_MAX_TYPE];
// Number of unique swizzle patterns (one entry per swizzle mode + MSAA + bpp configuration)
static const UINT_32 NumSwizzlePatterns = 19 * MaxElementBytesLog2;
// Equation table
ADDR_EQUATION m_equationTable[NumSwizzlePatterns];
/**
************************************************************************************************************************
* @brief Bitmasks for swizzle mode determination on GFX12
************************************************************************************************************************
*/
static const UINT_32 Blk256KBSwModeMask = (1u << ADDR3_256KB_2D) |
(1u << ADDR3_256KB_3D);
static const UINT_32 Blk64KBSwModeMask = (1u << ADDR3_64KB_2D) |
(1u << ADDR3_64KB_3D);
static const UINT_32 Blk4KBSwModeMask = (1u << ADDR3_4KB_2D) |
(1u << ADDR3_4KB_3D);
static const UINT_32 Blk256BSwModeMask = (1u << ADDR3_256B_2D);
virtual ADDR_E_RETURNCODE HwlComputePipeBankXor(
const ADDR3_COMPUTE_PIPEBANKXOR_INPUT* pIn,
ADDR3_COMPUTE_PIPEBANKXOR_OUTPUT* pOut) const override;

View file

@ -829,8 +829,8 @@ BOOL_32 EgBasedLib::HwlReduceBankWidthHeight(
if (valid == FALSE)
{
ADDR_WARN(
0, ("TILE_SIZE(%d)*BANK_WIDTH(%d)*BANK_HEIGHT(%d) <= ROW_SIZE(%d)",
tileSize, pTileInfo->bankWidth, pTileInfo->bankHeight, m_rowSize));
0, "TILE_SIZE(%d)*BANK_WIDTH(%d)*BANK_HEIGHT(%d) <= ROW_SIZE(%d)",
tileSize, pTileInfo->bankWidth, pTileInfo->bankHeight, m_rowSize);
}
}
@ -1031,7 +1031,7 @@ BOOL_32 EgBasedLib::SanityCheckMacroTiled(
{
if (pTileInfo->tileSplitBytes > m_rowSize)
{
ADDR_WARN(0, ("tileSplitBytes is bigger than row size"));
ADDR_WARN(0, "tileSplitBytes is bigger than row size");
}
}