mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-13 15:59:23 +01:00
Add FogParam0::FloatValue and FogParam3::FloatValue
This value will be used in the register description; so expose it in a way that can be re-used instead of calculating it in 2 places later.
This commit is contained in:
parent
f2bea67709
commit
db8ced7e4e
@ -47,16 +47,26 @@ bool FogParams::IsNaNCase() const
|
|||||||
return a.exp == 255 && c_proj_fsel.c_exp == 255;
|
return a.exp == 255 && c_proj_fsel.c_exp == 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float FogParam0::FloatValue() const
|
||||||
|
{
|
||||||
|
// scale mantissa from 11 to 23 bits
|
||||||
|
const u32 integral = (sign << 31) | (exp << 23) | (mant << 12);
|
||||||
|
return Common::BitCast<float>(integral);
|
||||||
|
}
|
||||||
|
|
||||||
|
float FogParam3::FloatValue() const
|
||||||
|
{
|
||||||
|
// scale mantissa from 11 to 23 bits
|
||||||
|
const u32 integral = (c_sign << 31) | (c_exp << 23) | (c_mant << 12);
|
||||||
|
return Common::BitCast<float>(integral);
|
||||||
|
}
|
||||||
|
|
||||||
float FogParams::GetA() const
|
float FogParams::GetA() const
|
||||||
{
|
{
|
||||||
if (IsNaNCase())
|
if (IsNaNCase())
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
// scale mantissa from 11 to 23 bits
|
return a.FloatValue();
|
||||||
const u32 integral = (static_cast<u32>(a.sign) << 31) | (static_cast<u32>(a.exp) << 23) |
|
|
||||||
(static_cast<u32>(a.mant) << 12);
|
|
||||||
|
|
||||||
return Common::BitCast<float>(integral);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float FogParams::GetC() const
|
float FogParams::GetC() const
|
||||||
@ -67,9 +77,5 @@ float FogParams::GetC() const
|
|||||||
return !a.sign && !c_proj_fsel.c_sign ? -inf : inf;
|
return !a.sign && !c_proj_fsel.c_sign ? -inf : inf;
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale mantissa from 11 to 23 bits
|
return c_proj_fsel.FloatValue();
|
||||||
const u32 integral = (c_proj_fsel.c_sign.Value() << 31) | (c_proj_fsel.c_exp.Value() << 23) |
|
|
||||||
(c_proj_fsel.c_mant.Value() << 12);
|
|
||||||
|
|
||||||
return Common::BitCast<float>(integral);
|
|
||||||
}
|
}
|
||||||
|
@ -661,6 +661,7 @@ union FogParam0
|
|||||||
BitField<19, 1, u32> sign;
|
BitField<19, 1, u32> sign;
|
||||||
|
|
||||||
u32 hex;
|
u32 hex;
|
||||||
|
float FloatValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
union FogParam3
|
union FogParam3
|
||||||
@ -673,6 +674,7 @@ union FogParam3
|
|||||||
// backward exp, 7 - backward exp2
|
// backward exp, 7 - backward exp2
|
||||||
|
|
||||||
u32 hex;
|
u32 hex;
|
||||||
|
float FloatValue() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
union FogRangeKElement
|
union FogRangeKElement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user