PSPSDK/Gum : Different behavior VPFU/Core

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Shazz
Posts: 244
Joined: Tue Aug 31, 2004 11:42 pm
Location: Somewhere over the rainbow
Contact:

PSPSDK/Gum : Different behavior VPFU/Core

Post by Shazz »

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: Select all

#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
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

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
User avatar
Shazz
Posts: 244
Joined: Tue Aug 31, 2004 11:42 pm
Location: Somewhere over the rainbow
Contact:

Post by Shazz »

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: Select all

	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: Select all

	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
User avatar
Shazz
Posts: 244
Joined: Tue Aug 31, 2004 11:42 pm
Location: Somewhere over the rainbow
Contact:

Post by Shazz »

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: Select all

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: Select all

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
User avatar
Shazz
Posts: 244
Joined: Tue Aug 31, 2004 11:42 pm
Location: Somewhere over the rainbow
Contact:

Post by Shazz »

This is the patch I propose...

Code: Select all

#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
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

Thanks, I'll look into fixing this asap.
GE Dominator
Post Reply