FPRecipEstimate: Move offset out of function

MSVC has weird lambda capturing rules.
This commit is contained in:
MerryMage 2018-07-25 19:22:16 +01:00
parent ddcff86f9c
commit e76e1186bb

View file

@ -19,17 +19,18 @@
namespace Dynarmic::FP { namespace Dynarmic::FP {
constexpr u64 lut_offset = 256;
/// Input is a u0.9 fixed point number. Only values in [0.5, 1.0) are valid. /// Input is a u0.9 fixed point number. Only values in [0.5, 1.0) are valid.
/// Output is a u0.8 fixed point number, with an implied 1 prefixed. /// Output is a u0.8 fixed point number, with an implied 1 prefixed.
/// i.e.: The output is a value in [1.0, 2.0). /// i.e.: The output is a value in [1.0, 2.0).
static u8 RecipEstimate(u64 a) { static u8 RecipEstimate(u64 a) {
constexpr u64 offset = 256;
using LUT = std::array<u8, 256>; using LUT = std::array<u8, 256>;
static const LUT lut = [] { static const LUT lut = [] {
LUT result{}; LUT result{};
for (u64 i = 0; i < result.size(); i++) { for (u64 i = 0; i < result.size(); i++) {
u64 a = i + offset; u64 a = i + lut_offset;
a = a * 2 + 1; a = a * 2 + 1;
u64 b = (1u << 19) / a; u64 b = (1u << 19) / a;
@ -38,7 +39,7 @@ static u8 RecipEstimate(u64 a) {
return result; return result;
}(); }();
return lut[a - offset]; return lut[a - lut_offset];
} }
template<typename FPT> template<typename FPT>