-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VFPU: Ensure that sin(4*x) returns 0.0 (and cos 1) for all x. Fixes #2921 #6329
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,39 @@ | |
|
||
#pragma once | ||
|
||
|
||
#include <cmath> | ||
|
||
#define _VD (op & 0x7F) | ||
#define _VS ((op>>8) & 0x7F) | ||
#define _VT ((op>>16) & 0x7F) | ||
|
||
inline int Xpose(int v) | ||
{ | ||
inline int Xpose(int v) { | ||
return v^0x20; | ||
} | ||
|
||
#ifndef M_PI_2 | ||
#define M_PI_2 1.57079632679489661923 | ||
#endif | ||
|
||
inline float vfpu_sin(float angle) { | ||
angle -= floorf(angle * 4.0f) * 0.25f; | ||
angle *= (float)M_PI_2; | ||
return sinf(angle); | ||
} | ||
|
||
inline float vfpu_cos(float angle) { | ||
angle -= floorf(angle * 4.0f) * 0.25f; | ||
angle *= (float)M_PI_2; | ||
return cosf(angle); | ||
} | ||
|
||
inline void vfpu_sincos(float angle, float &sine, float &cosine) { | ||
angle -= floorf(angle * 4.0f) * 0.25f; | ||
angle *= (float)M_PI_2; | ||
sine = sinf(angle); | ||
cosine = cosf(angle); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Android has sincosf() these days (latest ndks) right? Though not sure what our build req is. -[Unknown] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the buildbot upgraded to the latest? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Last I checked it seemed to have ndk-r9b, from October 2013. https://code.google.com/p/android/issues/detail?id=38423 -[Unknown] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it didn't actually make it until d, but not sure. Maybe c. Pretty sure not b. |
||
} | ||
|
||
#define VFPU_FLOAT16_EXP_MAX 0x1f | ||
#define VFPU_SH_FLOAT16_SIGN 15 | ||
#define VFPU_MASK_FLOAT16_SIGN 0x1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not sure this is rounding right?
Angle 1 = 1_pi/2 = sin=1,cos=0
Angle 2 = 2_pi/2 = sin=0,cos=-1
Angle 3 = 3_pi/2 = sin=-1,cos=0
Angle 4 = 4_pi/2 = sin=0,cos=1
However,
3 - floor(3 * 4) * 0.25
=3 - 12 * 0.25
=0
. Should be * 0.25 / 4, right?-[Unknown]