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 

PSPSDK/Gum : Different behavior VPFU/Core

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



Joined: 31 Aug 2004
Posts: 244
Location: Somewhere over the rainbow

PostPosted: Sun Apr 23, 2006 6:06 am    Post subject: PSPSDK/Gum : Different behavior VPFU/Core Reply with quote

When I use sceGumLookAt(), it works with the core impl, but black screen when the VFPU handles it. (other sceGum* work well)

Was the VFPU implementation tested ?

Code:

#ifdef F_sceGumLookAt_vfpu
void sceGumLookAt(ScePspFVector3* eye, ScePspFVector3* center, ScePspFVector3* up)
{
   ScePspFMatrix4* t = GUM_ALIGNED_MATRIX();
   gumLookAt(t,eye,center,up);

   pspvfpu_use_matrices(gum_vfpucontext, VMAT3, VMAT0 | VMAT1);

   __asm__ volatile (
      "lv.q C000.q,  0 + %0\n"
      "lv.q C010.q, 16 + %0\n"
      "lv.q C020.q, 32 + %0\n"
      "lv.q C030.q, 48 + %0\n"
      "vmmul.q M100, M300, M000\n"
      "vmmov.q M300, M100\n"
   : : "m"(*t) );

   gum_current_matrix_update = 1;
}
#endif

_________________
- TiTAN Art Division -
http://www.titandemo.org
Back to top
View user's profile Send private message Visit poster's website
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Mon Apr 24, 2006 6:11 pm    Post subject: Reply with quote

It has not been fully tested, no... Do you get a crash or can you put the results side by side and see what happens? If the matrices differ let me know, and I'll look into why this is so... It shouldn't be, since they both call gumLookAt, and the only thing the code does afterwards is load the resulting matrix and multiply it into the stack. This kind of code is used at quite a few places so I dunno why it should act up...
_________________
GE Dominator
Back to top
View user's profile Send private message
Shazz



Joined: 31 Aug 2004
Posts: 244
Location: Somewhere over the rainbow

PostPosted: Mon Apr 24, 2006 6:24 pm    Post subject: Reply with quote

no crash, only a black screen. So something got wrong but no bus error or something like that, the GU seems to refuse the stuff.

For the moment I have recopied the "generic" gumLookAt => pspGumLookAt) with some matrix store/load :

Code:

   sceGumMatrixMode(GU_VIEW);
   sceGumLoadIdentity();

   ScePspFMatrix4 currentMtx;
   sceGumStoreMatrix(&currentMtx);
   pspGumLookAt(&currentMtx, &rotozoom_eye, &rotozoom_center, &rotozoom_up );
   sceGumLoadMatrix(&currentMtx);


That's my 2s patch (but seems to work)

But so yes the issue should be there :

Code:

   pspvfpu_use_matrices(gum_vfpucontext, VMAT3, VMAT0 | VMAT1);

   __asm__ volatile (
      "lv.q C000.q,  0 + %0\n"
      "lv.q C010.q, 16 + %0\n"
      "lv.q C020.q, 32 + %0\n"
      "lv.q C030.q, 48 + %0\n"
      "vmmul.q M100, M300, M000\n"
      "vmmov.q M300, M100\n"
   : : "m"(*t) );

which seems, yep, used elsewhere...

What's mean memory in "=m"(*m) : : "memory"); I see i nother matrix updates ?

I will look into the details of the VFPU implementation and I'll dump the VIEW matrix to see differences as you requested.
_________________
- TiTAN Art Division -
http://www.titandemo.org
Back to top
View user's profile Send private message Visit poster's website
Shazz



Joined: 31 Aug 2004
Posts: 244
Location: Somewhere over the rainbow

PostPosted: Tue May 16, 2006 3:32 am    Post subject: Reply with quote

Sorry for the dealy, some other stuff to code :D

so I dumped the matrcies using CORE & VFPU impl for gum, here are the results :

Code:

CORE
Dump matrix : Mode
[0.000 0.000 0.000 0.000]
[0.000 0.000 0.000 0.000]
[0.000 0.000 0.000 0.000]
[0.000 0.000 0.000 0.000]

Dump matrix : Id
[1.000 0.000 0.000 0.000]
[0.000 1.000 0.000 0.000]
[0.000 0.000 1.000 0.000]
[0.000 0.000 0.000 1.000]

Dump matrix : LookAt
[1.000 0.000 0.000 0.000]
[0.000 0.894 0.447 0.000]
[0.000 -0.447 0.894 0.000]
[0.000 -4.472 -2.236 1.000]

VFPU
Dump matrix : Mode
[0.000 0.000 0.000 0.000]
[0.000 0.000 0.000 0.000]
[0.000 0.000 0.000 0.000]
[0.000 0.000 0.000 0.000]

Dump matrix : Id
[1.000 0.000 0.000 0.000]
[0.000 1.000 0.000 0.000]
[0.000 0.000 1.000 0.000]
[0.000 0.000 0.000 1.000]

Dump matrix : LookAt
[0.000 0.000 0.000 0.000]
[0.000 1.166 0.000 0.000]
[-0.000 -0.583 0.000 0.000]
[-6259853398707798888.200 -6259853398707798888.200 0.000 0.000]


So we see that the matrix generated by the lookAt is not the good one (the CORE lookAt matrix is ok)

I'll try to see where is the bug in the vfpu impl...

EDIT : bug found :

Code:

void sceGumLookAt(ScePspFVector3* eye, ScePspFVector3* center, ScePspFVector3* up)
{
   ScePspFMatrix4* t = GUM_ALIGNED_MATRIX();
   gumLookAt(t,eye,center,up);


you call gumLookAt on t which is null instead of the current matrix : gum_current_matrix, I don't think gumLookAt can be reused here as it does the matrix multiply and so on... Specific impl needed no ?
_________________
- TiTAN Art Division -
http://www.titandemo.org
Back to top
View user's profile Send private message Visit poster's website
Shazz



Joined: 31 Aug 2004
Posts: 244
Location: Somewhere over the rainbow

PostPosted: Tue May 16, 2006 4:03 am    Post subject: Reply with quote

This is the patch I propose...

Code:

#ifdef F_sceGumLookAt_vfpu
void sceGumLookAt(ScePspFVector3* eye, ScePspFVector3* center, ScePspFVector3* up)
{
   ScePspFMatrix4* t = GUM_ALIGNED_MATRIX();
   ScePspFVector3 forward, side, lup,ieye;
   
   forward.x = center->x - eye->x;
   forward.y = center->y - eye->y;
   forward.z = center->z - eye->z;

   gumNormalize(&forward);

   gumCrossProduct(&side,&forward,up);
   gumNormalize(&side);

   gumCrossProduct(&lup,&side,&forward);
   gumLoadIdentity(t);

   t->x.x = side.x;
   t->y.x = side.y;
   t->z.x = side.z;

   t->x.y = lup.x;
   t->y.y = lup.y;
   t->z.y = lup.z;

   t->x.z = -forward.x;
   t->y.z = -forward.y;
   t->z.z = -forward.z;

   ieye.x = -eye->x; ieye.y = -eye->y; ieye.z = -eye->z;

   // multiply t with current matrix
   sceGumMultMatrix(t);

   // translate current matrix from eye vector
   sceGumTranslate(&ieye);

   gum_current_matrix_update = 1;
}
#endif


_________________
- TiTAN Art Division -
http://www.titandemo.org
Back to top
View user's profile Send private message Visit poster's website
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Tue May 16, 2006 8:20 am    Post subject: Reply with quote

Thanks, I'll look into fixing this asap.
_________________
GE Dominator
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP 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