mirror of
https://github.com/xemu-project/nv2a_vsh_cpu.git
synced 2024-11-26 19:20:22 +00:00
Fixes LOG.
This commit is contained in:
parent
2de2148592
commit
5aa83ec399
@ -246,10 +246,15 @@ void nv2a_vsh_cpu_log(float *out, const float *inputs) {
|
||||
out[1] = 1.0f;
|
||||
out[2] = INFINITY;
|
||||
} else {
|
||||
int exp = 0;
|
||||
out[1] = frexpf(tmp, &exp);
|
||||
out[0] = (float)exp;
|
||||
out[2] = out[0] + log2f(tmp);
|
||||
// frexpf returns values that do not match nv2a, so the exponent is
|
||||
// extracted manually.
|
||||
uint32_t tmp_int = *(uint32_t*)&tmp;
|
||||
uint32_t exponent = ((tmp_int >> 23) & 0xFF) - 127;
|
||||
uint32_t mantissa = (tmp_int & 0x7FFFFF) | 0x3F800000;
|
||||
|
||||
out[0] = (float)exponent;
|
||||
out[1] = *(float*)&mantissa;
|
||||
out[2] = log2f(tmp);
|
||||
}
|
||||
|
||||
out[3] = 1.0f;
|
||||
|
@ -92,7 +92,10 @@ BOOST_AUTO_TEST_CASE(add_trivial) {
|
||||
// }
|
||||
//}
|
||||
|
||||
// Returned values are very close to correct and could be checked with a more
|
||||
// permissive float equality.
|
||||
//BOOST_AUTO_TEST_CASE(log_trivial) {
|
||||
// // 0xDB5056B0
|
||||
// float inputs[][4] = {
|
||||
// {-5.864211e16f, 0.0f, 0.0f, 0.0f},
|
||||
// {0.0f, 0.0f, 0.0f, 0.0f},
|
||||
|
Loading…
Reference in New Issue
Block a user