Browse Source

math: add a few comments.

legacy
Sam Hocevar sam 12 years ago
parent
commit
130071bd6a
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      src/math/half.cpp

+ 4
- 2
src/math/half.cpp View File

@@ -1,7 +1,7 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To // modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See // Public License, Version 2, as published by Sam Hocevar. See
@@ -40,7 +40,8 @@ namespace lol


/* Lookup table-based algorithm from “Fast Half Float Conversions” /* Lookup table-based algorithm from “Fast Half Float Conversions”
* by Jeroen van der Zijp, November 2008. No rounding is performed, * by Jeroen van der Zijp, November 2008. No rounding is performed,
* and some NaN values may be incorrectly converted to Inf. */
* and some NaN values may be incorrectly converted to Inf (because
* the lowest order bits in the mantissa are ignored). */
static inline uint16_t float_to_half_nobranch(uint32_t x) static inline uint16_t float_to_half_nobranch(uint32_t x)
{ {
static uint16_t const basetable[512] = static uint16_t const basetable[512] =
@@ -157,6 +158,7 @@ static inline void float_to_half_vector(half *dst, float const *src)
} }
#endif #endif


/* We use this De Bruijn sequence to compute a branchless integer log2 */
static int const shifttable[32] = static int const shifttable[32] =
{ {
23, 14, 22, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 20, 0, 23, 14, 22, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 20, 0,


Loading…
Cancel
Save