mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 15:30:14 +01:00
amdgpu/addrlib: add explicit Log2NonPow2 function
This commit is contained in:
parent
4a4b7da141
commit
c16e1e2041
1 changed files with 20 additions and 8 deletions
|
|
@ -445,22 +445,17 @@ static inline UINT_32 NextPow2(
|
|||
|
||||
/**
|
||||
***************************************************************************************************
|
||||
* Log2
|
||||
* Log2NonPow2
|
||||
*
|
||||
* @brief
|
||||
* Compute log of base 2
|
||||
* Compute log of base 2 no matter the target is power of 2 or not
|
||||
***************************************************************************************************
|
||||
*/
|
||||
static inline UINT_32 Log2(
|
||||
static inline UINT_32 Log2NonPow2(
|
||||
UINT_32 x) ///< [in] the value should calculate log based 2
|
||||
{
|
||||
UINT_32 y;
|
||||
|
||||
//
|
||||
// Assert that x is a power of two.
|
||||
//
|
||||
ADDR_ASSERT(IsPow2(x));
|
||||
|
||||
y = 0;
|
||||
while (x > 1)
|
||||
{
|
||||
|
|
@ -471,6 +466,23 @@ static inline UINT_32 Log2(
|
|||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
***************************************************************************************************
|
||||
* Log2
|
||||
*
|
||||
* @brief
|
||||
* Compute log of base 2
|
||||
***************************************************************************************************
|
||||
*/
|
||||
static inline UINT_32 Log2(
|
||||
UINT_32 x) ///< [in] the value should calculate log based 2
|
||||
{
|
||||
// Assert that x is a power of two.
|
||||
ADDR_ASSERT(IsPow2(x));
|
||||
|
||||
return Log2NonPow2(x);
|
||||
}
|
||||
|
||||
/**
|
||||
***************************************************************************************************
|
||||
* QLog2
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue