|
Post by bugothecat on May 11, 2022 13:49:42 GMT
I was trying to use sin/cos for something and got multiple linker errors. I am not sure if in the current toolchain these are supported. Or maybe I need a specific linker flag. I am including <math.h> in the code of course. In case math functions are not supported for some reason, I can resort back on using LUTs for everything, but would be cool to know first if I am not doing something wrong to avoid the unneccesary hassle.
v810-ld -L/opt/v810-gcc/lib/ -L/opt/v810-gcc/v810/lib/ -L/opt/v810-gcc/lib/gcc/v810/4.7.4/ /opt/v810-gcc/v810/lib/crt0.o tinyfont.o procgen_texture.o engine_main.o script.o engine_mesh.o system.o procgen_mesh.o main.o engine_soft.o engine_texture.o tools.o mathutil.o fastking.o -leris -lc -lsim -lgcc -o mytest.elf -Map mytest.map
v810-ld: warning: section `.sbss' type changed to PROGBITS
procgen_texture.o: In function `genTexture':
procgen_texture.c:(.text+0xd8): undefined reference to `__extendsfdf2'
procgen_texture.c:(.text+0xe0): undefined reference to `sin'
procgen_texture.c:(.text+0xec): undefined reference to `__muldf3'
procgen_texture.c:(.text+0xf4): undefined reference to `__fixdfsi'
procgen_texture.c:(.text+0x4a2): undefined reference to `__divdf3'
procgen_texture.c:(.text+0x4aa): undefined reference to `__fixdfsi'
procgen_texture.c:(.text+0x9a8): undefined reference to `__floatsidf'
procgen_texture.c:(.text+0x9b0): undefined reference to `sqrt'
|
|
|
Post by elmer on May 11, 2022 14:27:26 GMT
The V810 CPU does not support double-precision floating point, so no, the standard double-precision sin() function is not going to work.
IIRC, I compile NEWLIB with software-support for single-precision trancendental functions, so if you try sinf(), it might be found ... but it's going to be slow.
Realtime sin and cos? Are you deliberately trying to kill your performance?
|
|
|
Post by dshadoff on May 11, 2022 15:30:56 GMT
I really do appreciate the interest that the PC-FX is starting to get recently, but I think people do need to consider that this machine is from a completely different era, and programming techniques of today may not translate very well. For example, with a ~20MHz processor, the CPU is easily over 1000 times slower than CPUs of today, and effectively no modern GPU functions are available.
The programmers even back then were often judged based on the types of "tricks" they could create, in order to overcome the limitations of the system for which general-purpose functions would be insufficient.
Since the resolution of the machine is not so high, I'm assuming that you probably don't need such a high precision, and a lookup table would probably be the best bet (unless I misunderstand the use case).
|
|
|
Post by bugothecat on May 11, 2022 15:43:05 GMT
The V810 CPU does not support double-precision floating point, so no, the standard double-precision sin() function is not going to work. IIRC, I compile NEWLIB with software-support for single-precision trancendental functions, so if you try sinf(), it might be found ... but it's going to be slow. Realtime sin and cos? Are you deliberately trying to kill your performance? Oh, ok it was because of 'doubles' not sin. I forgot sin is taking double as argument for some reason. I will try with sinf. As for performance no, I use it only to precalculate. I'll be porting an engine from 3DO which has even slower CPU and no FPU, I do the realtime stuff with fixed point and LUTs, just some math to precalc things. EDIT: I am trying sinf now and it tells me undefined reference to `sinf'
|
|
|
Post by elmer on May 11, 2022 16:59:37 GMT
As for performance no, I use it only to precalculate. I'll be porting an engine from 3DO which has even slower CPU and no FPU, I do the realtime stuff with fixed point and LUTs, just some math to precalc things. OK, thank gawd! But still ... if you're going to precalc and use LUTs anyway, just generate the LUTs separately, otherwise you waste a bunch of memory pulling in long-and-slow software functions to do the math. The V810 only has simple float add/sub/mul/div in hardware, and they're not exactly fast. EDIT: I am trying sinf now and it tells me undefined reference to `sinf' They're definitely being compiled. I'm going to bet that you didn't include libm.a ... i.e. "-lm" to the linker.
|
|
|
Post by bugothecat on May 12, 2022 6:09:24 GMT
As for performance no, I use it only to precalculate. I'll be porting an engine from 3DO which has even slower CPU and no FPU, I do the realtime stuff with fixed point and LUTs, just some math to precalc things. OK, thank gawd! But still ... if you're going to precalc and use LUTs anyway, just generate the LUTs separately, otherwise you waste a bunch of memory pulling in long-and-slow software functions to do the math. The V810 only has simple float add/sub/mul/div in hardware, and they're not exactly fast. EDIT: I am trying sinf now and it tells me undefined reference to `sinf' They're definitely being compiled. I'm going to bet that you didn't include libm.a ... i.e. "-lm" to the linker. I tried that now, suddenly I get a lot of other linker errors. I think I will results to LUTs at this point.
|
|
|
Post by elmer on May 12, 2022 15:24:28 GMT
I tried that now, suddenly I get a lot of other linker errors. I think I will results to LUTs at this point. OK, if you've got a solution, that's great. I'll remember the problem with the float math, and try to find and fix it when I next get back to PC-FX development.
|
|