forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VFPU math lib

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
evilo



Joined: 22 Apr 2004
Posts: 230

PostPosted: Wed Jun 20, 2007 8:51 am    Post subject: VFPU math lib Reply with quote

see http://forums.ps2dev.org/viewtopic.php?t=7539

Do we have a similar lib on the PS2 ?


Too bad that we don't have closer SDK between the PS2 and the PSP (seeing how much the PSP scene is active comparing to the PS2 one).
_________________
http://psxdev.info/evilo/
Back to top
View user's profile Send private message Visit poster's website
ooPo
Site Admin


Joined: 17 Jan 2004
Posts: 2032
Location: Canada

PostPosted: Wed Jun 20, 2007 10:22 am    Post subject: Reply with quote

Its a lot easier to set up a PSP for development, and its new and shiny so more people are interested in it.

You can use vu0 in macro mode and get similar results. Take a look at the math3d code in ps2sdk for an example.
Back to top
View user's profile Send private message Visit poster's website
evilo



Joined: 22 Apr 2004
Posts: 230

PostPosted: Wed Jun 20, 2007 4:57 pm    Post subject: Reply with quote

the toolchain script is almost the same, and apart the fact that you need a way to run unsigned code on the PS2, it's not difficult!

anyway, as soon as I will get my PS2 back (that is still travelling across europe), I'll have a closer look at it, I have a few things that would benefits of such optimizations.

evilo.
_________________
http://psxdev.info/evilo/
Back to top
View user's profile Send private message Visit poster's website
Lukasz



Joined: 19 Jan 2004
Posts: 248
Location: Denmark

PostPosted: Wed Jun 20, 2007 11:49 pm    Post subject: Reply with quote

You can also look for inspiration in some of the VU0 macro code in libito:

http://svn.ps2dev.org/filedetails.php?repname=ps2&path=%2Ftrunk%2Flibito%2Fsource%2FVu0MathAsm.S&rev=0&sc=0
http://svn.ps2dev.org/filedetails.php?repname=ps2&path=%2Ftrunk%2Flibito%2Fsource%2FVu0Math.cpp&rev=0&sc=0
_________________
Lukasz.dk
Back to top
View user's profile Send private message Visit poster's website
emoon



Joined: 18 Jan 2004
Posts: 91
Location: Stockholm, Sweden

PostPosted: Fri Jun 22, 2007 5:40 am    Post subject: Reply with quote

If you really want to do math calculation in an efficient manner on the PS2 you need to use vu0 micromode.

What that means is that you do something like this (a basic mul example)

Code:

Vu0 code (or something like this)

               mul       vf01, vf02, vf03  nop
               nop[e]                      nop



And then the ee code:

Code:


..upload MyMathFunction to Vu0 goes here..

Then:

// set some input registers

   __asm__ volatile ("lqc2   vf02,0x00(%0)\n" : : "r" (&myValue1) :  "memory");
   __asm__ volatile ("lqc2   vf03,0x00(%0)\n" : : "r" (&myValue2) :  "memory");

// calls the vu0 program (start from address 0 in vu0)

   __asm__ volatile ("vcallms 0\n");

// do something on the ee while vu0 is calculating...

// ...

// Get the result from vu0 (3 vnops to make sure the calulation has finished if it takes 4 cycles)

         __asm__ volatile ("vnop\n");
         __asm__ volatile ("vnop\n");
         __asm__ volatile ("vnop\n");
         __asm__ volatile ("sqc2   vf01,0x00(%0)\n" : : "r" (&myResult) :  "memory");


Sure to use vu0 in macromode (similar to vfpu on psp) you get better performance than not using vu0 at all.

But infact its even faster to use vu0 micromode even if you block on it directly afterwards because you dont need to fetch any extra instructions to the I-cache and vu0 just runs more efficient in micromode.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group