297 changes: 259 additions & 38 deletions src/image/addrlib/inc/addrinterface.h

Large diffs are not rendered by default.

117 changes: 72 additions & 45 deletions src/image/addrlib/inc/addrtypes.h
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

/**
****************************************************************************************************
Expand All @@ -49,6 +48,10 @@ typedef void VOID;
typedef float FLOAT;
#endif

#if !defined(DOUBLE)
typedef double DOUBLE;
#endif

#if !defined(CHAR)
typedef char CHAR;
#endif
Expand All @@ -68,18 +71,22 @@ typedef int INT;
*/
#ifndef ADDR_CDECL
#if defined(__GNUC__)
#define ADDR_CDECL __attribute__((cdecl))
#if defined(__i386__)
#define ADDR_CDECL __attribute__((cdecl))
#else
#define ADDR_CDECL
#endif
#else
#define ADDR_CDECL __cdecl
#endif
#endif

#ifndef ADDR_STDCALL
#if defined(__GNUC__)
#if defined(__amd64__) || defined(__x86_64__)
#define ADDR_STDCALL
#else
#if defined(__i386__)
#define ADDR_STDCALL __attribute__((stdcall))
#else
#define ADDR_STDCALL
#endif
#else
#define ADDR_STDCALL __stdcall
Expand All @@ -88,7 +95,11 @@ typedef int INT;

#ifndef ADDR_FASTCALL
#if defined(__GNUC__)
#define ADDR_FASTCALL __attribute__((regparm(0)))
#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__)
#define ADDR_FASTCALL __attribute__((regparm(0)))
#else
#define ADDR_FASTCALL
#endif
#else
#define ADDR_FASTCALL __fastcall
#endif
Expand All @@ -106,18 +117,15 @@ typedef int INT;
#define GC_FASTCALL ADDR_FASTCALL
#endif


#if defined(__GNUC__)
#define ADDR_INLINE static inline // inline needs to be static to link
#else
// win32, win64, other platforms
#define ADDR_INLINE __inline
#endif // #if defined(__GNUC__)

#if defined(__amd64__) || defined(__x86_64__) || defined(__i386__)
#define ADDR_API ADDR_FASTCALL // default call convention is fast call
#else
#define ADDR_API
#endif
#define ADDR_API ADDR_FASTCALL //default call convention is fast call

/**
****************************************************************************************************
Expand Down Expand Up @@ -205,9 +213,10 @@ typedef enum _AddrTileMode
* @note
*
* ADDR_SW_LINEAR linear aligned addressing mode, for 1D/2D/3D resource
* ADDR_SW_256B_* addressing block aligned size is 256B, for 2D/3D resource
* ADDR_SW_256B_* addressing block aligned size is 256B, for 2D resource
* ADDR_SW_4KB_* addressing block aligned size is 4KB, for 2D/3D resource
* ADDR_SW_64KB_* addressing block aligned size is 64KB, for 2D/3D resource
* ADDR_SW_64KB_* addressing block aligned size is 64KB, for 1D/2D/3D resource
* ADDR_SW_VAR_* addressing block aligned size is ASIC specific
*
* ADDR_SW_*_Z For GFX9:
- for 2D resource, represents Z-order swizzle mode for depth/stencil/FMask
Expand Down Expand Up @@ -244,10 +253,10 @@ typedef enum _AddrSwizzleMode
ADDR_SW_64KB_S = 9,
ADDR_SW_64KB_D = 10,
ADDR_SW_64KB_R = 11,
ADDR_SW_RESERVED0 = 12,
ADDR_SW_RESERVED1 = 13,
ADDR_SW_RESERVED2 = 14,
ADDR_SW_RESERVED3 = 15,
ADDR_SW_MISCDEF12 = 12,
ADDR_SW_MISCDEF13 = 13,
ADDR_SW_MISCDEF14 = 14,
ADDR_SW_MISCDEF15 = 15,
ADDR_SW_64KB_Z_T = 16,
ADDR_SW_64KB_S_T = 17,
ADDR_SW_64KB_D_T = 18,
Expand All @@ -260,12 +269,27 @@ typedef enum _AddrSwizzleMode
ADDR_SW_64KB_S_X = 25,
ADDR_SW_64KB_D_X = 26,
ADDR_SW_64KB_R_X = 27,
ADDR_SW_VAR_Z_X = 28,
ADDR_SW_RESERVED4 = 29,
ADDR_SW_RESERVED5 = 30,
ADDR_SW_VAR_R_X = 31,
ADDR_SW_MISCDEF28 = 28,
ADDR_SW_MISCDEF29 = 29,
ADDR_SW_MISCDEF30 = 30,
ADDR_SW_MISCDEF31 = 31,
ADDR_SW_LINEAR_GENERAL = 32,
ADDR_SW_MAX_TYPE = 33,

ADDR_SW_RESERVED0 = ADDR_SW_MISCDEF12,
ADDR_SW_RESERVED1 = ADDR_SW_MISCDEF13,
ADDR_SW_RESERVED2 = ADDR_SW_MISCDEF14,
ADDR_SW_RESERVED3 = ADDR_SW_MISCDEF15,
ADDR_SW_RESERVED4 = ADDR_SW_MISCDEF29,
ADDR_SW_RESERVED5 = ADDR_SW_MISCDEF30,

ADDR_SW_VAR_Z_X = ADDR_SW_MISCDEF28,
ADDR_SW_VAR_R_X = ADDR_SW_MISCDEF31,

ADDR_SW_256KB_Z_X = ADDR_SW_MISCDEF28,
ADDR_SW_256KB_S_X = ADDR_SW_MISCDEF29,
ADDR_SW_256KB_D_X = ADDR_SW_MISCDEF30,
ADDR_SW_256KB_R_X = ADDR_SW_MISCDEF31,
} AddrSwizzleMode;

/**
Expand Down Expand Up @@ -553,6 +577,7 @@ typedef enum _AddrHtileBlockSize
ADDR_HTILE_BLOCKSIZE_8 = 8,
} AddrHtileBlockSize;


/**
****************************************************************************************************
* AddrPipeCfg
Expand Down Expand Up @@ -638,7 +663,7 @@ typedef enum _AddrTileType
#endif

#ifndef INT_8
#define INT_8 char
#define INT_8 signed char // signed must be used because of aarch64
#endif

#ifndef UINT_8
Expand Down Expand Up @@ -715,6 +740,7 @@ typedef enum _AddrTileType
#define ADDR64D "lld" OR "I64d"
#endif


/// @brief Union for storing a 32-bit float or 32-bit integer
/// @ingroup type
///
Expand All @@ -730,6 +756,7 @@ typedef union {
float f;
} ADDR_FLT_32;


////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Macros for controlling linking and building on multiple systems
Expand Down
129 changes: 94 additions & 35 deletions src/image/addrlib/src/addrinterface.cpp
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

/**
****************************************************************************************************
Expand All @@ -36,8 +35,6 @@

#include "addrcommon.h"

#include "util/macros.h"

namespace rocr {
using namespace Addr;

Expand Down Expand Up @@ -68,6 +65,8 @@ ADDR_E_RETURNCODE ADDR_API AddrCreate(
return returnCode;
}



/**
****************************************************************************************************
* AddrDestroy
Expand Down Expand Up @@ -97,6 +96,8 @@ ADDR_E_RETURNCODE ADDR_API AddrDestroy(
return returnCode;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// Surface functions
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -133,6 +134,8 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceInfo(
return returnCode;
}



/**
****************************************************************************************************
* AddrComputeSurfaceAddrFromCoord
Expand Down Expand Up @@ -197,6 +200,8 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeSurfaceCoordFromAddr(
return returnCode;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// HTile functions
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -298,6 +303,8 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeHtileCoordFromAddr(
return returnCode;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// C-mask functions
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -400,6 +407,8 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeCmaskCoordFromAddr(
return returnCode;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// F-mask functions
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -500,6 +509,8 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeFmaskCoordFromAddr(
return returnCode;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// DCC key functions
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -534,6 +545,8 @@ ADDR_E_RETURNCODE ADDR_API AddrComputeDccInfo(
return returnCode;
}



///////////////////////////////////////////////////////////////////////////////
// Below functions are element related or helper functions
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -820,7 +833,7 @@ BOOL_32 ADDR_API ElemGetExportNorm(
Addr::Lib* pLib = Lib::GetLib(hLib);
BOOL_32 enabled = FALSE;

ASSERTED ADDR_E_RETURNCODE returnCode = ADDR_OK;
ADDR_E_RETURNCODE returnCode = ADDR_OK;

if (pLib != NULL)
{
Expand Down Expand Up @@ -1119,6 +1132,7 @@ ADDR_E_RETURNCODE ADDR_API AddrGetMaxMetaAlignments(
return returnCode;
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// Surface functions for Addr2
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1155,6 +1169,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeSurfaceInfo(
return returnCode;
}


/**
****************************************************************************************************
* Addr2ComputeSurfaceAddrFromCoord
Expand Down Expand Up @@ -1187,6 +1202,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeSurfaceAddrFromCoord(
return returnCode;
}


/**
****************************************************************************************************
* Addr2ComputeSurfaceCoordFromAddr
Expand Down Expand Up @@ -1219,6 +1235,8 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeSurfaceCoordFromAddr(
return returnCode;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// HTile functions for Addr2
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1255,6 +1273,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeHtileInfo(
return returnCode;
}


/**
****************************************************************************************************
* Addr2ComputeHtileAddrFromCoord
Expand Down Expand Up @@ -1287,6 +1306,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeHtileAddrFromCoord(
return returnCode;
}


/**
****************************************************************************************************
* Addr2ComputeHtileCoordFromAddr
Expand Down Expand Up @@ -1320,6 +1340,8 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeHtileCoordFromAddr(
return returnCode;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// C-mask functions for Addr2
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1357,6 +1379,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeCmaskInfo(
return returnCode;
}


/**
****************************************************************************************************
* Addr2ComputeCmaskAddrFromCoord
Expand Down Expand Up @@ -1389,6 +1412,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeCmaskAddrFromCoord(
return returnCode;
}


/**
****************************************************************************************************
* Addr2ComputeCmaskCoordFromAddr
Expand Down Expand Up @@ -1422,6 +1446,8 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeCmaskCoordFromAddr(
return returnCode;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// F-mask functions for Addr2
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1458,6 +1484,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeFmaskInfo(
return returnCode;
}


/**
****************************************************************************************************
* Addr2ComputeFmaskAddrFromCoord
Expand Down Expand Up @@ -1490,6 +1517,7 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeFmaskAddrFromCoord(
return returnCode;
}


/**
****************************************************************************************************
* Addr2ComputeFmaskCoordFromAddr
Expand Down Expand Up @@ -1522,6 +1550,8 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeFmaskCoordFromAddr(
return returnCode;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// DCC key functions for Addr2
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1675,6 +1705,35 @@ ADDR_E_RETURNCODE ADDR_API Addr2ComputeSubResourceOffsetForSwizzlePattern(
return returnCode;
}

/**
****************************************************************************************************
* Addr2ComputeNonBlockCompressedView
*
* @brief
* Compute non-block-compressed view for a given mipmap level/slice.
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr2ComputeNonBlockCompressedView(
ADDR_HANDLE hLib, ///< handle of addrlib
const ADDR2_COMPUTE_NONBLOCKCOMPRESSEDVIEW_INPUT* pIn, ///< [in] input
ADDR2_COMPUTE_NONBLOCKCOMPRESSEDVIEW_OUTPUT* pOut) ///< [out] output
{
ADDR_E_RETURNCODE returnCode;

V2::Lib* pLib = V2::Lib::GetLib(hLib);

if (pLib != NULL)
{
returnCode = pLib->ComputeNonBlockCompressedView(pIn, pOut);
}
else
{
returnCode = ADDR_ERROR;
}

return returnCode;
}

/**
****************************************************************************************************
* Addr2GetPreferredSurfaceSetting
Expand Down Expand Up @@ -1709,35 +1768,35 @@ ADDR_E_RETURNCODE ADDR_API Addr2GetPreferredSurfaceSetting(
* Addr2IsValidDisplaySwizzleMode
*
* @brief
* Return whether the swizzle mode is supported by DCE / DCN.
* Return whether the swizzle mode is supported by display engine
****************************************************************************************************
*/
ADDR_E_RETURNCODE ADDR_API Addr2IsValidDisplaySwizzleMode(
ADDR_HANDLE hLib,
AddrSwizzleMode swizzleMode,
UINT_32 bpp,
bool *result)
BOOL_32 *pResult)
{
ADDR_E_RETURNCODE returnCode;

V2::Lib* pLib = V2::Lib::GetLib(hLib);

if (pLib != NULL)
{
ADDR2_COMPUTE_SURFACE_INFO_INPUT in;
ADDR2_COMPUTE_SURFACE_INFO_INPUT in = {};
in.resourceType = ADDR_RSRC_TEX_2D;
in.swizzleMode = swizzleMode;
in.bpp = bpp;
in.swizzleMode = swizzleMode;
in.bpp = bpp;

*result = pLib->IsValidDisplaySwizzleMode(&in);
*pResult = pLib->IsValidDisplaySwizzleMode(&in);
returnCode = ADDR_OK;
}
else
{
returnCode = ADDR_ERROR;
}

return returnCode;
return returnCode;
}

} // rocr
} // namespace rocr
109 changes: 80 additions & 29 deletions src/image/addrlib/src/amdgpu_asic_addr.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
/*
* Copyright © 2017-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) 2017-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
*
***********************************************************************************************************************/

#ifndef _AMDGPU_ASIC_ADDR_H
#define _AMDGPU_ASIC_ADDR_H
Expand All @@ -44,6 +43,12 @@
#define FAMILY_AI 0x8D
#define FAMILY_RV 0x8E
#define FAMILY_NV 0x8F
#define FAMILY_VGH 0x90
#define FAMILY_GFX1100 0x91
#define FAMILY_GFX1103 0x94
#define FAMILY_RMB 0x92
#define FAMILY_GC_10_3_6 0x95
#define FAMILY_GC_10_3_7 0x97

// AMDGPU_FAMILY_IS(familyId, familyName)
#define FAMILY_IS(f, fn) (f == FAMILY_##fn)
Expand All @@ -57,6 +62,9 @@
#define FAMILY_IS_AI(f) FAMILY_IS(f, AI)
#define FAMILY_IS_RV(f) FAMILY_IS(f, RV)
#define FAMILY_IS_NV(f) FAMILY_IS(f, NV)
#define FAMILY_IS_RMB(f) FAMILY_IS(f, RMB)
#define FAMILY_IS_GFX1100(f) FAMILY_IS(f, GFX1100)
#define FAMILY_IS_GFX1103(f) FAMILY_IS(f, GFX1103)

#define AMDGPU_UNKNOWN 0xFF

Expand All @@ -77,6 +85,7 @@
#define AMDGPU_ICELAND_RANGE 0x01, 0x14
#define AMDGPU_TONGA_RANGE 0x14, 0x28
#define AMDGPU_FIJI_RANGE 0x3C, 0x50

#define AMDGPU_POLARIS10_RANGE 0x50, 0x5A
#define AMDGPU_POLARIS11_RANGE 0x5A, 0x64
#define AMDGPU_POLARIS12_RANGE 0x64, 0x6E
Expand All @@ -88,7 +97,8 @@
#define AMDGPU_VEGA10_RANGE 0x01, 0x14
#define AMDGPU_VEGA12_RANGE 0x14, 0x28
#define AMDGPU_VEGA20_RANGE 0x28, 0x32
#define AMDGPU_ARCTURUS_RANGE 0x32, 0xFF
#define AMDGPU_ARCTURUS_RANGE 0x32, 0x3C
#define AMDGPU_ALDEBARAN_RANGE 0x3C, 0xFF

#define AMDGPU_RAVEN_RANGE 0x01, 0x81
#define AMDGPU_RAVEN2_RANGE 0x81, 0x91
Expand All @@ -97,12 +107,30 @@
#define AMDGPU_NAVI10_RANGE 0x01, 0x0A
#define AMDGPU_NAVI12_RANGE 0x0A, 0x14
#define AMDGPU_NAVI14_RANGE 0x14, 0x28
#define AMDGPU_SIENNA_RANGE 0x28, 0x32
#define AMDGPU_NAVI21_RANGE 0x28, 0x32
#define AMDGPU_NAVI22_RANGE 0x32, 0x3C
#define AMDGPU_NAVI23_RANGE 0x3C, 0x46
#define AMDGPU_NAVI24_RANGE 0x46, 0x50

#define AMDGPU_VANGOGH_RANGE 0x01, 0xFF

#define AMDGPU_GFX1100_RANGE 0x01, 0x10
#define AMDGPU_GFX1101_RANGE 0x20, 0xFF
#define AMDGPU_GFX1102_RANGE 0x10, 0x20

#define AMDGPU_GFX1103_RANGE 0x01, 0xFF

#define AMDGPU_REMBRANDT_RANGE 0x01, 0xFF

#define AMDGPU_GFX1036_RANGE 0x01, 0xFF

#define AMDGPU_GFX1037_RANGE 0x01, 0xFF

#define AMDGPU_EXPAND_FIX(x) x
#define AMDGPU_RANGE_HELPER(val, min, max) ((val >= min) && (val < max))
#define AMDGPU_IN_RANGE(val, ...) AMDGPU_EXPAND_FIX(AMDGPU_RANGE_HELPER(val, __VA_ARGS__))


// ASICREV_IS(eRevisionId, revisionName)
#define ASICREV_IS(r, rn) AMDGPU_IN_RANGE(r, AMDGPU_##rn##_RANGE)
#define ASICREV_IS_TAHITI_P(r) ASICREV_IS(r, TAHITI)
Expand Down Expand Up @@ -137,14 +165,37 @@
#define ASICREV_IS_VEGA12_p(r) ASICREV_IS(r, VEGA12)
#define ASICREV_IS_VEGA20_P(r) ASICREV_IS(r, VEGA20)
#define ASICREV_IS_ARCTURUS(r) ASICREV_IS(r, ARCTURUS)
#define ASICREV_IS_ALDEBARAN(r) ASICREV_IS(r, ALDEBARAN)

#define ASICREV_IS_RAVEN(r) ASICREV_IS(r, RAVEN)
#define ASICREV_IS_RAVEN2(r) ASICREV_IS(r, RAVEN2)
#define ASICREV_IS_RENOIR(r) ASICREV_IS(r, RENOIR)

#define ASICREV_IS_NAVI10_P(r) ASICREV_IS(r, NAVI10)
#define ASICREV_IS_NAVI12(r) ASICREV_IS(r, NAVI12)
#define ASICREV_IS_NAVI14(r) ASICREV_IS(r, NAVI14)
#define ASICREV_IS_SIENNA_M(r) ASICREV_IS(r, SIENNA)

#define ASICREV_IS_NAVI12_P(r) ASICREV_IS(r, NAVI12)

#define ASICREV_IS_NAVI14_M(r) ASICREV_IS(r, NAVI14)

#define ASICREV_IS_NAVI21_M(r) ASICREV_IS(r, NAVI21)

#define ASICREV_IS_NAVI22_P(r) ASICREV_IS(r, NAVI22)

#define ASICREV_IS_NAVI23_P(r) ASICREV_IS(r, NAVI23)

#define ASICREV_IS_NAVI24_P(r) ASICREV_IS(r, NAVI24)

#define ASICREV_IS_VANGOGH(r) ASICREV_IS(r, VANGOGH)

#define ASICREV_IS_GFX1100(r) ASICREV_IS(r, GFX1100)
#define ASICREV_IS_GFX1101(r) ASICREV_IS(r, GFX1101)
#define ASICREV_IS_GFX1102(r) ASICREV_IS(r, GFX1102)
#define ASICREV_IS_GFX1103(r) ASICREV_IS(r, GFX1103)

#define ASICREV_IS_REMBRANDT(r) ASICREV_IS(r, REMBRANDT)

#define ASICREV_IS_GFX1036(r) ASICREV_IS(r, GFX1036)

#define ASICREV_IS_GFX1037(r) ASICREV_IS(r, GFX1037)

#endif // _AMDGPU_ASIC_ADDR_H
58 changes: 33 additions & 25 deletions src/image/addrlib/src/chip/gfx10/gfx10_gb_reg.h
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

#if !defined (__GFX10_GB_REG_H__)
#define __GFX10_GB_REG_H__
Expand All @@ -34,7 +33,16 @@
*
*/

union GB_ADDR_CONFIG
//
// Make sure the necessary endian defines are there.
//
#if defined(LITTLEENDIAN_CPU)
#elif defined(BIGENDIAN_CPU)
#else
#error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
#endif

union GB_ADDR_CONFIG_GFX10
{
struct
{
Expand Down
76 changes: 76 additions & 0 deletions src/image/addrlib/src/chip/gfx11/gfx11_gb_reg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
************************************************************************************************************************
*
* 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
*
***********************************************************************************************************************/

#if !defined (__GFX11_GB_REG_H__)
#define __GFX11_GB_REG_H__

/*
* gfx11_gb_reg.h
*
* Register Spec Release: 1.0
*
*/

//
// Make sure the necessary endian defines are there.
//
#if defined(LITTLEENDIAN_CPU)
#elif defined(BIGENDIAN_CPU)
#else
#error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
#endif

union GB_ADDR_CONFIG_GFX11
{
struct
{
#if defined(LITTLEENDIAN_CPU)
unsigned int NUM_PIPES : 3;
unsigned int PIPE_INTERLEAVE_SIZE : 3;
unsigned int MAX_COMPRESSED_FRAGS : 2;
unsigned int NUM_PKRS : 3;
unsigned int : 8;
unsigned int NUM_SHADER_ENGINES : 2;
unsigned int : 5;
unsigned int NUM_RB_PER_SE : 2;
unsigned int : 4;
#elif defined(BIGENDIAN_CPU)
unsigned int : 4;
unsigned int NUM_RB_PER_SE : 2;
unsigned int : 5;
unsigned int NUM_SHADER_ENGINES : 2;
unsigned int : 8;
unsigned int NUM_PKRS : 3;
unsigned int MAX_COMPRESSED_FRAGS : 2;
unsigned int PIPE_INTERLEAVE_SIZE : 3;
unsigned int NUM_PIPES : 3;
#endif
} bitfields, bits;
unsigned int u32All;
int i32All;
float f32All;
};

#endif
58 changes: 33 additions & 25 deletions src/image/addrlib/src/chip/gfx9/gfx9_gb_reg.h
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

#if !defined (__GFX9_GB_REG_H__)
#define __GFX9_GB_REG_H__
Expand All @@ -34,7 +33,16 @@
*
*/

union GB_ADDR_CONFIG_gfx9 {
//
// Make sure the necessary endian defines are there.
//
#if defined(LITTLEENDIAN_CPU)
#elif defined(BIGENDIAN_CPU)
#else
#error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
#endif

union GB_ADDR_CONFIG_GFX9 {
struct {
#if defined(LITTLEENDIAN_CPU)
unsigned int NUM_PIPES : 3;
Expand Down
70 changes: 42 additions & 28 deletions src/image/addrlib/src/chip/r800/si_gb_reg.h
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

#if !defined (__SI_GB_REG_H__)
#define __SI_GB_REG_H__
Expand All @@ -35,6 +34,15 @@
*
*****************************************************************************************************************/

//
// Make sure the necessary endian defines are there.
//
#if defined(LITTLEENDIAN_CPU)
#elif defined(BIGENDIAN_CPU)
#else
#error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
#endif

/*
* GB_ADDR_CONFIG struct
*/
Expand Down Expand Up @@ -103,21 +111,24 @@ typedef union {
unsigned int num_banks : 2;
unsigned int micro_tile_mode_new : 3;
unsigned int sample_split : 2;
unsigned int : 5;
unsigned int alt_pipe_config : 5;
} GB_TILE_MODE_T;

typedef struct _GB_MACROTILE_MODE_T {
unsigned int bank_width : 2;
unsigned int bank_height : 2;
unsigned int macro_tile_aspect : 2;
unsigned int num_banks : 2;
unsigned int : 24;
unsigned int alt_bank_height : 2;
unsigned int alt_macro_tile_aspect : 2;
unsigned int alt_num_banks : 2;
unsigned int : 18;
} GB_MACROTILE_MODE_T;

#elif defined(BIGENDIAN_CPU)

typedef struct _GB_TILE_MODE_T {
unsigned int : 5;
unsigned int alt_pipe_config : 5;
unsigned int sample_split : 2;
unsigned int micro_tile_mode_new : 3;
unsigned int num_banks : 2;
Expand All @@ -131,7 +142,10 @@ typedef union {
} GB_TILE_MODE_T;

typedef struct _GB_MACROTILE_MODE_T {
unsigned int : 24;
unsigned int : 18;
unsigned int alt_num_banks : 2;
unsigned int alt_macro_tile_aspect : 2;
unsigned int alt_bank_height : 2;
unsigned int num_banks : 2;
unsigned int macro_tile_aspect : 2;
unsigned int bank_height : 2;
Expand Down
206 changes: 133 additions & 73 deletions src/image/addrlib/src/core/addrcommon.h
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

/**
****************************************************************************************************
Expand All @@ -36,39 +35,38 @@

#include "addrinterface.h"

#if !defined(DEBUG)
#ifdef NDEBUG
#define DEBUG 0
#else
#define DEBUG 1
#endif
#endif

// ADDR_LNX_KERNEL_BUILD is for internal build
// Moved from addrinterface.h so __KERNEL__ is not needed any more
#if ADDR_LNX_KERNEL_BUILD // || (defined(__GNUC__) && defined(__KERNEL__))
#include <string.h>
#elif !defined(__APPLE__) || defined(HAVE_TSERVER)
#if !defined(__APPLE__) || defined(HAVE_TSERVER)
#include <stdlib.h>
#include <string.h>
#endif

#include <assert.h>
#include "util/macros.h"
#if defined(__GNUC__)
#include <assert.h>
#endif


////////////////////////////////////////////////////////////////////////////////////////////////////
// Platform specific debug break defines
////////////////////////////////////////////////////////////////////////////////////////////////////
#if !defined(DEBUG)
#ifdef NDEBUG
#define DEBUG 0
#else
#define DEBUG 1
#endif
#endif

#if DEBUG
#if defined(__GNUC__)
#define ADDR_DBG_BREAK() assert(false)
#define ADDR_DBG_BREAK() { assert(false); }
#elif defined(__APPLE__)
#define ADDR_DBG_BREAK() { IOPanic("");}
#else
#define ADDR_DBG_BREAK() { __debugbreak(); }
#endif
#else
#define ADDR_DBG_BREAK() do {} while(0)
#define ADDR_DBG_BREAK()
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////

Expand All @@ -81,10 +79,29 @@
#define ADDR_ANALYSIS_ASSUME(expr) do { (void)(expr); } while (0)
#endif

#define ADDR_ASSERT(__e) assert(__e)
#define ADDR_ASSERT_ALWAYS() ADDR_DBG_BREAK()
#define ADDR_UNHANDLED_CASE() ADDR_ASSERT(!"Unhandled case")
#define ADDR_NOT_IMPLEMENTED() ADDR_ASSERT(!"Not implemented");
#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
#define ADDR_ASSERT_ALWAYS() ADDR_DBG_BREAK()
#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
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -107,6 +124,7 @@
#define ADDR_INFO(cond, a) \
{ if (!(cond)) { ADDR_PRNT(a); } }


/// @brief Macro for reporting error warning messages
/// @ingroup util
///
Expand All @@ -125,6 +143,7 @@
ADDR_PRNT((" WARNING in file %s, line %d\n", __FILE__, __LINE__)); \
} }


/// @brief Macro for reporting fatal error conditions
/// @ingroup util
///
Expand All @@ -147,27 +166,35 @@

#define ADDRDPF 1 ? (void)0 : (void)

#define ADDR_PRNT(a) do {} while(0)
#define ADDR_PRNT(a)

#define ADDR_DBG_BREAK() do {} while(0)
#define ADDR_DBG_BREAK()

#define ADDR_INFO(cond, a) do {} while(0)
#define ADDR_INFO(cond, a)

#define ADDR_WARN(cond, a) do {} while(0)
#define ADDR_WARN(cond, a)

#define ADDR_EXIT(cond, a) do {} while(0)
#define ADDR_EXIT(cond, a)

#endif // DEBUG
////////////////////////////////////////////////////////////////////////////////////////////////////

#define ADDR_C_ASSERT(__e) STATIC_ASSERT(__e)
#if defined(static_assert)
#define ADDR_C_ASSERT(__e) static_assert(__e, "")
#else
/* This version of STATIC_ASSERT() relies on VLAs. If COND is
* false/zero, the array size will be -1 and we'll get a compile
* error
*/
# define ADDR_C_ASSERT(__e) do { \
(void) sizeof(char [1 - 2*!(__e)]); \
} while (0)
#endif

namespace rocr {
namespace Addr
{
namespace Addr {
namespace V1 {

namespace V1
{
////////////////////////////////////////////////////////////////////////////////////////////////////
// Common constants
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -207,21 +234,6 @@ static const UINT_32 MaxSurfaceHeight = 16384;
/// Helper macros to select a single bit from an int (undefined later in section)
#define _BIT(v,b) (((v) >> (b) ) & 1)

/**
****************************************************************************************************
* @brief Enums to identify AddrLib type
****************************************************************************************************
*/
enum LibClass
{
BASE_ADDRLIB = 0x0,
R600_ADDRLIB = 0x6,
R800_ADDRLIB = 0x8,
SI_ADDRLIB = 0xa,
CI_ADDRLIB = 0xb,
AI_ADDRLIB = 0xd,
};

/**
****************************************************************************************************
* ChipFamily
Expand Down Expand Up @@ -271,8 +283,9 @@ union ConfigFlags
UINT_32 disableLinearOpt : 1; ///< Disallow tile modes to be optimized to linear
UINT_32 use32bppFor422Fmt : 1; ///< View 422 formats as 32 bits per pixel element
UINT_32 forceDccAndTcCompat : 1; ///< Force enable DCC and TC compatibility
UINT_32 nonPower2MemConfig : 1; ///< Physical video memory size is not power of 2
UINT_32 reserved : 19; ///< Reserved bits for future use
UINT_32 nonPower2MemConfig : 1; ///< Video memory bit width is not power of 2
UINT_32 enableAltTiling : 1; ///< Enable alt tile mode
UINT_32 reserved : 18; ///< Reserved bits for future use
};

UINT_32 value;
Expand Down Expand Up @@ -433,6 +446,38 @@ static inline INT_32 Max(
return ((value1 > (value2)) ? (value1) : value2);
}

/**
****************************************************************************************************
* RoundUpQuotient
*
* @brief
* Divides two numbers, rounding up any remainder.
****************************************************************************************************
*/
static inline UINT_32 RoundUpQuotient(
UINT_32 numerator,
UINT_32 denominator)
{
ADDR_ASSERT(denominator > 0);
return ((numerator + (denominator - 1)) / denominator);
}

/**
****************************************************************************************************
* RoundUpQuotient
*
* @brief
* Divides two numbers, rounding up any remainder.
****************************************************************************************************
*/
static inline UINT_64 RoundUpQuotient(
UINT_64 numerator,
UINT_64 denominator)
{
ADDR_ASSERT(denominator > 0);
return ((numerator + (denominator - 1)) / denominator);
}

/**
****************************************************************************************************
* NextPow2
Expand Down Expand Up @@ -856,6 +901,7 @@ static inline VOID InitChannel(
pChanSet->index = index;
}


/**
****************************************************************************************************
* InitChannel
Expand Down Expand Up @@ -933,7 +979,7 @@ static inline UINT_32 GetCoordActiveMask(
* ShiftCeil
*
* @brief
* Apply righ-shift with ceiling
* Apply right-shift with ceiling
****************************************************************************************************
*/
static inline UINT_32 ShiftCeil(
Expand All @@ -943,9 +989,23 @@ static inline UINT_32 ShiftCeil(
return (a >> b) + (((a & ((1 << b) - 1)) != 0) ? 1 : 0);
}

/**
****************************************************************************************************
* ShiftRight
*
* @brief
* Return right-shift value and minimum is 1
****************************************************************************************************
*/
static inline UINT_32 ShiftRight(
UINT_32 a, ///< [in] value to be right-shifted
UINT_32 b) ///< [in] number of bits to shift
{
return Max(a >> b, 1u);
}

} // Addr
} // rocr


#endif // __ADDR_COMMON_H__

53 changes: 26 additions & 27 deletions src/image/addrlib/src/core/addrelemlib.cpp
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

/**
****************************************************************************************************
Expand All @@ -35,8 +34,7 @@
#include "addrlib.h"

namespace rocr {
namespace Addr
{
namespace Addr {

/**
****************************************************************************************************
Expand Down Expand Up @@ -348,6 +346,7 @@ VOID ElemLib::Int32sToPixel(
UINT_32 elemMask=0;
UINT_32 elementXor = 0; // address xor when reading bytes from elements


// @@ NOTE: assert if called on a compressed format!

if (properties.byteAligned) // Components are all byte-sized
Expand Down Expand Up @@ -1273,7 +1272,6 @@ VOID ElemLib::RestoreSurfaceInfo(
UINT_32 bpp;

BOOL_32 bBCnFormat = FALSE;
(void)bBCnFormat;

ADDR_ASSERT(pBpp != NULL);
ADDR_ASSERT(pWidth != NULL && pHeight != NULL);
Expand Down Expand Up @@ -1746,6 +1744,7 @@ BOOL_32 ElemLib::IsBlockCompressed(
((format >= ADDR_FMT_ASTC_4x4) && (format <= ADDR_FMT_ETC2_128BPP)));
}


/**
****************************************************************************************************
* ElemLib::IsCompressed
Expand Down
51 changes: 25 additions & 26 deletions src/image/addrlib/src/core/addrelemlib.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
/*
* 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
*
***********************************************************************************************************************/


/**
****************************************************************************************************
Expand All @@ -39,8 +39,7 @@
#include "addrcommon.h"

namespace rocr {
namespace Addr
{
namespace Addr {

class Lib;

Expand Down
72 changes: 42 additions & 30 deletions src/image/addrlib/src/core/addrlib.cpp
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

/**
****************************************************************************************************
Expand Down Expand Up @@ -82,8 +81,7 @@ UINT_32 __umoddi3(UINT_64 n, UINT_32 base)
#endif // __APPLE__

namespace rocr {
namespace Addr
{
namespace Addr {

////////////////////////////////////////////////////////////////////////////////////////////////////
// Constructor/Destructor
Expand All @@ -99,7 +97,6 @@ namespace Addr
****************************************************************************************************
*/
Lib::Lib() :
m_class(BASE_ADDRLIB),
m_chipFamily(ADDR_CHIP_FAMILY_IVLD),
m_chipRevision(0),
m_version(ADDRLIB_VERSION),
Expand All @@ -109,6 +106,8 @@ Lib::Lib() :
m_rowSize(0),
m_minPitchAlignPixels(1),
m_maxSamples(8),
m_maxBaseAlign(0),
m_maxMetaBaseAlign(0),
m_pElemLib(NULL)
{
m_configFlags.value = 0;
Expand All @@ -125,7 +124,6 @@ Lib::Lib() :
*/
Lib::Lib(const Client* pClient) :
Object(pClient),
m_class(BASE_ADDRLIB),
m_chipFamily(ADDR_CHIP_FAMILY_IVLD),
m_chipRevision(0),
m_version(ADDRLIB_VERSION),
Expand All @@ -135,6 +133,8 @@ Lib::Lib(const Client* pClient) :
m_rowSize(0),
m_minPitchAlignPixels(1),
m_maxSamples(8),
m_maxBaseAlign(0),
m_maxMetaBaseAlign(0),
m_pElemLib(NULL)
{
m_configFlags.value = 0;
Expand All @@ -158,6 +158,7 @@ Lib::~Lib()
}
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialization/Helper
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -207,7 +208,7 @@ ADDR_E_RETURNCODE Lib::Create(
pLib = SiHwlInit(&client);
break;
case FAMILY_VI:
case FAMILY_CZ:
case FAMILY_CZ: // VI based fusion
case FAMILY_CI:
case FAMILY_KV: // CI based fusion
pLib = CiHwlInit(&client);
Expand All @@ -225,8 +226,16 @@ ADDR_E_RETURNCODE Lib::Create(
pLib = Gfx9HwlInit(&client);
break;
case FAMILY_NV:
case FAMILY_VGH:
case FAMILY_RMB:
case FAMILY_GC_10_3_6:
case FAMILY_GC_10_3_7:
pLib = Gfx10HwlInit(&client);
break;
case FAMILY_GFX1100:
case FAMILY_GFX1103:
pLib = Gfx11HwlInit(&client);
break;
default:
ADDR_ASSERT_ALWAYS();
break;
Expand All @@ -252,6 +261,7 @@ ADDR_E_RETURNCODE Lib::Create(
pLib->m_configFlags.allowLargeThickTile = pCreateIn->createFlags.allowLargeThickTile;
pLib->m_configFlags.forceDccAndTcCompat = pCreateIn->createFlags.forceDccAndTcCompat;
pLib->m_configFlags.nonPower2MemConfig = pCreateIn->createFlags.nonPower2MemConfig;
pLib->m_configFlags.enableAltTiling = pCreateIn->createFlags.enableAltTiling;
pLib->m_configFlags.disableLinearOpt = FALSE;

pLib->SetChipFamily(pCreateIn->chipFamily, pCreateIn->chipRevision);
Expand Down Expand Up @@ -491,10 +501,12 @@ UINT_32 Lib::Bits2Number(
return number;
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// Element lib
////////////////////////////////////////////////////////////////////////////////////////////////////


/**
****************************************************************************************************
* Lib::Flt32ToColorPixel
Expand Down Expand Up @@ -610,6 +622,7 @@ ADDR_E_RETURNCODE Lib::Flt32ToColorPixel(
return returnCode;
}


/**
****************************************************************************************************
* Lib::GetExportNorm
Expand Down Expand Up @@ -660,4 +673,3 @@ UINT_32 Lib::GetBpe(AddrFormat format) const

} // Addr
} // rocr

54 changes: 25 additions & 29 deletions src/image/addrlib/src/core/addrlib.h
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

/**
****************************************************************************************************
Expand Down Expand Up @@ -57,8 +56,7 @@
#endif

namespace rocr {
namespace Addr
{
namespace Addr {

/**
****************************************************************************************************
Expand Down Expand Up @@ -371,8 +369,6 @@ class Lib : public Object
VOID SetMaxAlignments();

protected:
LibClass m_class; ///< Store class type (HWL type)

ChipFamily m_chipFamily; ///< Chip family translated from the one in atiid.h

UINT_32 m_chipRevision; ///< Revision id from xxx_id.h
Expand Down Expand Up @@ -411,8 +407,8 @@ Lib* SiHwlInit (const Client* pClient);
Lib* CiHwlInit (const Client* pClient);
Lib* Gfx9HwlInit (const Client* pClient);
Lib* Gfx10HwlInit(const Client* pClient);
Lib* Gfx11HwlInit(const Client* pClient);
} // Addr
} // rocr


#endif
73 changes: 41 additions & 32 deletions src/image/addrlib/src/core/addrlib1.cpp
Original file line number Diff line number Diff line change
@@ -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
*
***********************************************************************************************************************/

/**
****************************************************************************************************
Expand All @@ -36,10 +35,8 @@
#include "addrcommon.h"

namespace rocr {
namespace Addr
{
namespace V1
{
namespace Addr {
namespace V1 {

////////////////////////////////////////////////////////////////////////////////////////////////////
// Static Const Member
Expand Down Expand Up @@ -148,10 +145,12 @@ Lib* Lib::GetLib(
return static_cast<Lib*>(hLib);
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// Surface Methods
////////////////////////////////////////////////////////////////////////////////////////////////////


/**
****************************************************************************************************
* Lib::ComputeSurfaceInfo
Expand Down Expand Up @@ -1229,6 +1228,8 @@ UINT_32 Lib::Thickness(
return ModeFlags[tileMode].thickness;
}



////////////////////////////////////////////////////////////////////////////////////////////////////
// CMASK/HTILE
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2009,6 +2010,7 @@ ADDR_E_RETURNCODE Lib::ComputeCmaskInfo(
*pPitchOut = (pitchIn + macroWidth - 1) & ~(macroWidth - 1);
*pHeightOut = (heightIn + macroHeight - 1) & ~(macroHeight - 1);


sliceBytes = ComputeCmaskBytes(*pPitchOut,
*pHeightOut,
1);
Expand Down Expand Up @@ -2187,7 +2189,6 @@ VOID Lib::HwlComputeXmaskCoordFromAddr(
UINT_32 pipe;
UINT_32 numPipes;
UINT_32 numGroupBits;
(void)numGroupBits;
UINT_32 numPipeBits;
UINT_32 macroTilePitch;
UINT_32 macroTileHeight;
Expand Down Expand Up @@ -2236,6 +2237,7 @@ VOID Lib::HwlComputeXmaskCoordFromAddr(
UINT_32 groupBits = 8 * m_pipeInterleaveBytes;
UINT_32 pipes = numPipes;


//
// Compute the micro tile size, in bits. And macro tile pitch and height.
//
Expand Down Expand Up @@ -2288,17 +2290,20 @@ VOID Lib::HwlComputeXmaskCoordFromAddr(
pitch = pitchAligned;
height = heightAligned;


//
// Convert byte address to bit address.
//
bitAddr = BYTES_TO_BITS(addr) + bitPosition;


//
// Remove pipe bits from address.
//

bitAddr = (bitAddr % groupBits) + ((bitAddr/groupBits/pipes)*groupBits);


elemOffset = bitAddr / elemBits;

tilesPerMacro = (macroTilePitch/factor) * macroTileHeight / MicroTilePixels >> numPipeBits;
Expand All @@ -2316,6 +2321,7 @@ VOID Lib::HwlComputeXmaskCoordFromAddr(
macroY = static_cast<UINT_32>((macroNumber % macrosPerSlice) / macrosPerPitch);
macroZ = static_cast<UINT_32>((macroNumber / macrosPerSlice));


microX = microNumber % (macroTilePitch / factor / MicroTileWidth);
microY = (microNumber / (macroTilePitch / factor / MicroTileHeight));

Expand All @@ -2326,6 +2332,7 @@ VOID Lib::HwlComputeXmaskCoordFromAddr(
microTileCoordY = ComputeXmaskCoordYFromPipe(pipe,
*pX/MicroTileWidth);


//
// Assemble final coordinates.
//
Expand Down Expand Up @@ -2385,6 +2392,7 @@ UINT_64 Lib::HwlComputeXmaskAddrFromCoord(
UINT_64 offsetHi;
UINT_64 groupMask;


UINT_32 elemBits = 0;

UINT_32 numPipes = m_pipes; // This function is accessed prior to si only
Expand Down Expand Up @@ -3347,6 +3355,7 @@ VOID Lib::PadDimensions(
heightAlign);
}


/**
****************************************************************************************************
* Lib::HwlPreHandleBaseLvl3xPitch
Expand Down Expand Up @@ -3408,6 +3417,7 @@ UINT_32 Lib::HwlPostHandleBaseLvl3xPitch(
return expPitch;
}


/**
****************************************************************************************************
* Lib::IsMacroTiled
Expand Down Expand Up @@ -3524,7 +3534,6 @@ VOID Lib::ComputeMipLevel(
{
// Check if HWL has handled
BOOL_32 hwlHandled = FALSE;
(void)hwlHandled;

if (ElemLib::IsBlockCompressed(pIn->format))
{
Expand Down Expand Up @@ -3928,6 +3937,7 @@ VOID Lib::ComputeQbStereoInfo(
// 1D surface on SI may break this rule, but we can force it to meet by checking .qbStereo.
}


/**
****************************************************************************************************
* Lib::ComputePrtInfo
Expand Down Expand Up @@ -4060,5 +4070,4 @@ ADDR_E_RETURNCODE Lib::ComputePrtInfo(

} // V1
} // Addr
} // rocr

} // namespace rocr
58 changes: 28 additions & 30 deletions src/image/addrlib/src/core/addrlib1.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
/*
* 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
*
***********************************************************************************************************************/


/**
****************************************************************************************************
Expand All @@ -37,10 +37,8 @@
#include "addrlib.h"

namespace rocr {
namespace Addr
{
namespace V1
{
namespace Addr {
namespace V1 {

/**
****************************************************************************************************
Expand Down Expand Up @@ -355,6 +353,7 @@ class Lib : public Addr::Lib
const ADDR_COMPUTE_SURFACE_INFO_INPUT* pIn,
UINT_32* pPitchAlign, UINT_32* pHeightAlign, UINT_32* pSizeAlign) const = 0;


virtual VOID HwlOverrideTileMode(ADDR_COMPUTE_SURFACE_INFO_INPUT* pInOut) const
{
// not supported in hwl layer
Expand Down Expand Up @@ -540,8 +539,7 @@ class Lib : public Addr::Lib

} // V1
} // Addr
} // rocr

} // namespace rocr

#endif

278 changes: 245 additions & 33 deletions src/image/addrlib/src/core/addrlib2.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
/*
* 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
*
***********************************************************************************************************************/


/**
************************************************************************************************************************
Expand All @@ -36,10 +36,8 @@
#include "addrcommon.h"

namespace rocr {
namespace Addr
{
namespace V2
{
namespace Addr {
namespace V2 {

////////////////////////////////////////////////////////////////////////////////////////////////////
// Static Const Member
Expand Down Expand Up @@ -143,10 +141,12 @@ Lib* Lib::GetLib(
return static_cast<Lib*>(hLib);
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// Surface Methods
////////////////////////////////////////////////////////////////////////////////////////////////////


/**
************************************************************************************************************************
* Lib::ComputeSurfaceInfo
Expand Down Expand Up @@ -309,11 +309,16 @@ ADDR_E_RETURNCODE Lib::ComputeSurfaceInfo(
if (pOut->pStereoInfo != NULL)
{
ComputeQbStereoInfo(pOut);
#if DEBUG
ValidateStereoInfo(pIn, pOut);
#endif
}
}
}
}

ADDR_ASSERT(pOut->surfSize != 0);

ValidBaseAlignments(pOut->baseAlign);

return returnCode;
Expand Down Expand Up @@ -436,6 +441,7 @@ ADDR_E_RETURNCODE Lib::ComputeSurfaceCoordFromAddr(
return returnCode;
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// CMASK/HTILE
////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -822,7 +828,12 @@ ADDR_E_RETURNCODE Lib::ComputeDccAddrFromCoord(
}
else
{
returnCode = HwlComputeDccAddrFromCoord(pIn, pOut);
returnCode = HwlSupportComputeDccAddrFromCoord(pIn);

if (returnCode == ADDR_OK)
{
HwlComputeDccAddrFromCoord(pIn, pOut);
}
}

return returnCode;
Expand Down Expand Up @@ -888,6 +899,15 @@ ADDR_E_RETURNCODE Lib::ComputeSlicePipeBankXor(
{
returnCode = ADDR_NOTSUPPORTED;
}
else if ((pIn->bpe != 0) &&
(pIn->bpe != 8) &&
(pIn->bpe != 16) &&
(pIn->bpe != 32) &&
(pIn->bpe != 64) &&
(pIn->bpe != 128))
{
returnCode = ADDR_INVALIDPARAMS;
}
else
{
returnCode = HwlComputeSlicePipeBankXor(pIn, pOut);
Expand Down Expand Up @@ -927,6 +947,37 @@ ADDR_E_RETURNCODE Lib::ComputeSubResourceOffsetForSwizzlePattern(
return returnCode;
}

/**
************************************************************************************************************************
* Lib::ComputeNonBlockCompressedView
*
* @brief
* Interface function stub of Addr2ComputeNonBlockCompressedView.
*
* @return
* ADDR_E_RETURNCODE
************************************************************************************************************************
*/
ADDR_E_RETURNCODE Lib::ComputeNonBlockCompressedView(
const ADDR2_COMPUTE_NONBLOCKCOMPRESSEDVIEW_INPUT* pIn,
ADDR2_COMPUTE_NONBLOCKCOMPRESSEDVIEW_OUTPUT* pOut)
{
ADDR_E_RETURNCODE returnCode;

if ((GetFillSizeFieldsFlags() == TRUE) &&
((pIn->size != sizeof(ADDR2_COMPUTE_NONBLOCKCOMPRESSEDVIEW_INPUT)) ||
(pOut->size != sizeof(ADDR2_COMPUTE_NONBLOCKCOMPRESSEDVIEW_OUTPUT))))
{
returnCode = ADDR_INVALIDPARAMS;
}
else
{
returnCode = HwlComputeNonBlockCompressedView(pIn, pOut);
}

return returnCode;
}

/**
************************************************************************************************************************
* Lib::ExtractPipeBankXor
Expand Down Expand Up @@ -1539,11 +1590,11 @@ Dim3d Lib::GetMipTailDim(
{
ADDR_ASSERT(IsThin(resourceType, swizzleMode));

#if DEBUG
// GFX9/GFX10 use different dimension shrinking logic for mipmap tail: say for 128KB block + 2BPE, the maximum
// dimension of mipmap tail level will be [256W * 128H] on GFX9 ASICs and [128W * 256H] on GFX10 ASICs. Since
// GFX10 is newer HWL so we make its implementation into base class, in order to save future change on new HWLs.
// And assert log2BlkSize will always be an even value on GFX9, so we never need the logic wrapped by DEBUG...
#if DEBUG
if ((log2BlkSize & 1) && (m_chipFamily == ADDR_CHIP_FAMILY_AI))
{
// Should never go here...
Expand Down Expand Up @@ -1958,7 +2009,7 @@ VOID Lib::FilterInvalidEqSwizzleMode(
const UINT_32 rsrcTypeIdx = static_cast<UINT_32>(resourceType) - 1;
UINT_32 validSwModeSet = allowedSwModeSetVal;

for (UINT_32 swModeIdx = 0; validSwModeSet != 0; swModeIdx++)
for (UINT_32 swModeIdx = 1; validSwModeSet != 0; swModeIdx++)
{
if (validSwModeSet & 1)
{
Expand All @@ -1979,8 +2030,169 @@ VOID Lib::FilterInvalidEqSwizzleMode(
}
}

/**
************************************************************************************************************************
* Lib::IsBlockTypeAvaiable
*
* @brief
* Determine whether a block type is allowed in a given blockSet
*
* @return
* N/A
************************************************************************************************************************
*/
BOOL_32 Lib::IsBlockTypeAvaiable(
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;
}

/**
************************************************************************************************************************
* Lib::BlockTypeWithinMemoryBudget
*
* @brief
* Determine whether a new block type is acceptible based on memory waste ratio
*
* @return
* N/A
************************************************************************************************************************
*/
BOOL_32 Lib::BlockTypeWithinMemoryBudget(
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;
}

#if DEBUG
/**
************************************************************************************************************************
* Lib::ValidateStereoInfo
*
* @brief
* Validate stereo info by checking a few typical cases
*
* @return
* N/A
************************************************************************************************************************
*/
VOID Lib::ValidateStereoInfo(
const ADDR2_COMPUTE_SURFACE_INFO_INPUT* pIn, ///< [in] input structure
const ADDR2_COMPUTE_SURFACE_INFO_OUTPUT* pOut ///< [in] output structure
) const
{
ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT addrIn = {};
addrIn.size = sizeof(addrIn);
addrIn.swizzleMode = pIn->swizzleMode;
addrIn.flags = pIn->flags;
addrIn.flags.qbStereo = 0;
addrIn.resourceType = pIn->resourceType;
addrIn.bpp = pIn->bpp;
addrIn.unalignedWidth = pIn->width;
addrIn.numSlices = pIn->numSlices;
addrIn.numMipLevels = pIn->numMipLevels;
addrIn.numSamples = pIn->numSamples;
addrIn.numFrags = pIn->numFrags;

// Call Addr2ComputePipeBankXor() and validate different pbXor value if necessary...
const UINT_32 pbXor = 0;

ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT addrOut = {};
addrOut.size = sizeof(addrOut);

// Make the array to be {0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096} for full test
const UINT_32 TestCoord[] = {0};

for (UINT_32 xIdx = 0; xIdx < sizeof(TestCoord) / sizeof(TestCoord[0]); xIdx++)
{
if (TestCoord[xIdx] < pIn->width)
{
addrIn.x = TestCoord[xIdx];

for (UINT_32 yIdx = 0; yIdx < sizeof(TestCoord) / sizeof(TestCoord[0]); yIdx++)
{
if (TestCoord[yIdx] < pIn->height)
{
addrIn.y = TestCoord[yIdx] + pOut->pStereoInfo->eyeHeight;
addrIn.pipeBankXor = pbXor ^ pOut->pStereoInfo->rightSwizzle;
addrIn.unalignedHeight = pIn->height + pOut->pStereoInfo->eyeHeight;

ADDR_E_RETURNCODE ret = ComputeSurfaceAddrFromCoord(&addrIn, &addrOut);
ADDR_ASSERT(ret == ADDR_OK);

const UINT_64 rightEyeOffsetFromBase = addrOut.addr;

addrIn.y = TestCoord[yIdx];
addrIn.pipeBankXor = pbXor;
addrIn.unalignedHeight = pIn->height;

ret = ComputeSurfaceAddrFromCoord(&addrIn, &addrOut);
ADDR_ASSERT(ret == ADDR_OK);

const UINT_64 rightEyeOffsetRelative = addrOut.addr;

ADDR_ASSERT(rightEyeOffsetFromBase == rightEyeOffsetRelative + pOut->pStereoInfo->rightOffset);
}
}
}
}
}
#endif

} // V2
} // Addr
} // rocr


Loading