Does sceGeGetMtx even work?

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
tacoSunday
Posts: 34
Joined: Fri Aug 31, 2007 10:05 pm

Does sceGeGetMtx even work?

Post by tacoSunday »

I need to implement billboarding for my particle system. At first I thought this would be trivial with the GU_SPRITES primitive. Alas this does not seem to be the case. GU_SPRITES does not align to the view (ie: you can view the sprites edge on). I then went hunting through the headers for a way to retrieve the current view matrix so I could align the sprites myself. I finally stumbled across sceGeGetMtx(...). Thinking I had this one in the bag I hastily hammered out:

Code: Select all

float viewmat[16];
         ...
sceGeGetMtx(PSP_GE_MATRIX_VIEW, viewmat);
To my utter dismay It didn't work. I fired up gdb and poked around. I discovered that no matter what matrix I requested I received a matrix full of zero's. It definitely seems to be writing to my matrix (I passed it an array initialized to 1's and got back 0's). Needless to say this is mighty frustrating as I just want to align a silly sprite.

Does sceGuGetMtx even work? Other than the meager documentation in pspge.h, I can't find a single reference to it on Google that isn't just a hit on the header file or a syscall index table.

Is this function even referencing the same matrices manipulated by sceGumTranslate and kin? I do find it slightly odd that it is in pspge.h and not pspgu(m).h .

If this is not the correct method to retrieve the transformation matrices could someone kindly point me in the right direction?

many thanks.

P.S. Looking through the source for pspgl's glGetFloatv I noticed that they don't use sceGeGetMtx. They seem to do their own bookkeeping and then switch to a VFPU context based on the requested matrix before directly copying the matrix from the VFPU registers to memory.

Code: Select all

void glGetFloatv (GLenum pname, GLfloat *params)
{
        struct pspgl_matrix_stack *s;

        switch (pname) {
               .
               .
               .
        case GL_MODELVIEW_MATRIX:	s = &pspgl_curctx->modelview_stack; goto get_matrix;
        case GL_TEXTURE_MATRIX:		s = &pspgl_curctx->texture_stack; goto get_matrix;
        case GL_PROJECTION_MATRIX:	s = &pspgl_curctx->projection_stack; goto get_matrix;
        case GL_VIEW_PSP:		s = &pspgl_curctx->view_stack; goto get_matrix;
        case GL_BONE0_PSP ... GL_BONE7_PSP:
                s = &pspgl_curctx->bone_stacks[pname - GL_BONE0_PSP];
                /* FALLTHROUGH */
        get_matrix:
                if (params) {
                        const GLfloat *matrix = s->stack[s->depth].mat;
                        int i;

                        __pspgl_matrix_sync(pspgl_curctx, s);

                        for &#40;i=0; i<16; i++&#41;
                                params&#91;i&#93; = matrix&#91;i&#93;;
                &#125;
                break;
        default&#58;
                GLERROR&#40;GL_INVALID_ENUM&#41;;
        &#125;
&#125;

Code: Select all

void __pspgl_matrix_sync&#40;struct pspgl_context *c, const struct pspgl_matrix_stack *s&#41;
&#123;
        struct pspgl_matrix *m = &s->stack&#91;s->depth&#93;;

        if &#40;&#40;s->flags & MF_VFPU&#41; == 0&#41;
                return;

        pspvfpu_use_matrices&#40;c->vfpu_context, VFPU_STACKTOP, 0&#41;;

        asm volatile&#40;"sv.q	c700,  0 + %0, wb\n"
                     "sv.q	c710, 16 + %0, wb\n"
                     "sv.q	c720, 32 + %0, wb\n"
                     "sv.q	c730, 48 + %0, wb\n"
                     &#58; "=m" &#40;m->mat&#91;0&#93;&#41; &#58; &#58; "memory"&#41;;
&#125;
This leads me to believe thet sceGeGetMtx isn't what I want it to be. I really don't want to jump through all those hoops. I haven't gotten around to looking at a disassembly of the sceGeGetMtx syscall yet. Maybe that will yield some answers...
Sdw
Posts: 29
Joined: Tue Jul 17, 2007 9:50 am

Post by Sdw »

That is strange, I also thought that GU_SPRITES where supposed to act as billboards. So right now a GU_SPRITE is exactly the same as a normal QUAD?
User avatar
tacoSunday
Posts: 34
Joined: Fri Aug 31, 2007 10:05 pm

Post by tacoSunday »

Not exactly like a quad. It seems to me that It's only purpose is to save 2 verts per quad. It really just creates a rectangular quad perpendicular to the XY plane from two opposing corners.

You can see the effect in my particle system.

Edit: new url
http://perniciousbeaver.ath.cx/broken/EBOOT.PBP
Last edited by tacoSunday on Sat Sep 01, 2007 7:35 am, edited 1 time in total.
Vincent_M
Posts: 73
Joined: Tue Apr 03, 2007 4:16 am

Post by Vincent_M »

Use sceGumStoreMatrix right after you're done doing all view matrix operations to store that frame's view matrix in an instance of ScePspFMatrix4.
User avatar
tacoSunday
Posts: 34
Joined: Fri Aug 31, 2007 10:05 pm

Post by tacoSunday »

Thank you so much! I can't believe I overlooked that one!

http://perniciousbeaver.ath.cx/fixed/EBOOT.PBP
Post Reply