Skip to content

Commit 73f25c9

Browse files
gyrovorbisQuzarDC
authored andcommitted
Optimized pvr_pack_bump() redundant trigonometry.
Our boy, PH3NOM, correctly pointed out that pvr_pack_bump(), by virtue of using our inline ASM routines from fmath.h, SEPARATELY for sin + cosine values, was doing TWO FSCA calls and throwing away a result of each. - Changed pvr_pack_bump() to retrieve both sine + cosine simultaneously from a single fsincos() call. - Tested with the PVR bump map example which uses it... and... she's still bumpy!
1 parent ac2e539 commit 73f25c9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

kernel/arch/dreamcast/math/fmath.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,15 @@ void fsincosr(float f, float *s, float *c) {
6767
}
6868

6969
uint32_t __pure pvr_pack_bump(float h, float t, float q) {
70+
float s, c;
71+
72+
fsincos(t, &s, &c);
73+
7074
uint8_t hp = (uint8_t)(h * 255.0f);
7175
uint8_t k1 = ~hp;
72-
uint8_t k2 = (uint8_t)(hp * __fsin(t));
73-
uint8_t k3 = (uint8_t)(hp * __fcos(t));
74-
uint8_t qp = (uint8_t)((q / (2 * F_PI)) * 255.0f);
76+
uint8_t k2 = (uint8_t)(hp * s);
77+
uint8_t k3 = (uint8_t)(hp * c);
78+
uint8_t qp = (uint8_t)((q / (2.0f * F_PI)) * 255.0f);
7579

7680
return (k1 << 24) | (k2 << 16) | (k3 << 8) | qp;
7781
}

0 commit comments

Comments
 (0)