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 

vu1_triangle

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



Joined: 14 Apr 2004
Posts: 3
Location: Granada, Spain

PostPosted: Fri Apr 22, 2005 8:46 am    Post subject: vu1_triangle Reply with quote

Hello,
observing the code included from vu1_triangle (main.c), there is a while(1) which in each iteration, a variable called final_matrix is uploaded to VU1mem, a triangle prim (packed into a GIF_TAG) is uploaded to VU1mem and finally VIF_NOP-VIF_MSCAL are sent to VIF1.

Now, the question is: why the demo doesn't work fine (the triangle isnt drawn) when i upload the triangle prim just before the while(1) and not in each iteration?

Considering the triangle prim is the same at all iterations, i upload it before the while(1) and not uploading it into the while(1) with the intention to save cycles.

It seems that after each iteration (more in particular, after the execution of the vu-program), the VU1mem is cleared and all the data lost.

Thats my code:

Code:


    ///////////////////////////////////////////////////////////////////////////
    // Add giftag and color of the triangle

    *((u64*)p_data)++ = DMA_CNT_TAG( 5 );
    *((u32*)p_data)++ = VIF_CODE( VIF_STCYL,0,0x0404 );
    *((u32*)p_data)++ = VIF_CODE( VIF_UNPACK_V4_32,5,4 );

    *((u64*)p_data)++ = GIF_TAG( 1, 1, 1, GS_SETREG_PRIM( GS_PRIM_PRIM_TRIANGLE,
                                          0, 0, 0, 0, 0, 0, 0, 0 ), 0, 4 );
    *((u64*)p_data)++ = 0x5551;

    *((u32*)p_data)++  = 127;
    *((u32*)p_data)++  = 127;
    *((u32*)p_data)++  = 127;
    *((u32*)p_data)++  = 0;

    ///////////////////////////////////////////////////////////////////////////
    // add vertex coords of the triangle

    *((float*)p_data)++ = -100.0f;
    *((float*)p_data)++ =  100.0f;
    *((float*)p_data)++ =    0.0f;
    *((float*)p_data)++ =    1.0f;

    *((float*)p_data)++ = -100.0f;
    *((float*)p_data)++ = -100.0f;
    *((float*)p_data)++ =    0.0f;
    *((float*)p_data)++ =    1.0f;

    *((float*)p_data)++ =   50.0f;
    *((float*)p_data)++ =   50.0f;
    *((float*)p_data)++ =  100.0f;
    *((float*)p_data)++ =    1.0f;

  /////////////////////////////////////////////////////////////////////////////
  // Loop of the demo

  while( 1 )
  {
    angle += 0.03f;

    PbScreenClear( 30<<16|20<<8|40 );

    ///////////////////////////////////////////////////////////////////////////
    // Rotate & build final matrix to be used in the vu1 program.

    PbMatrixRotateZ( &rotate_matrix, angle );
    PbMatrixMultiply( &temprot_matrix, &rotate_matrix, &camera_matrix );
    PbMatrixMultiply( &final_matrix, &temprot_matrix, &viewscreen_matrix );
    FlushCache(0); 

    p_data = p_store = PbSprAlloc( 10*16 );

    ///////////////////////////////////////////////////////////////////////////
    // Build the data we need to send to the vu1

    *((u64*)p_data)++ = DMA_REF_TAG( (u32)&final_matrix, 4 );
    *((u32*)p_data)++ = VIF_CODE( VIF_STCYL,0,0x0404 );
    *((u32*)p_data)++ = VIF_CODE( VIF_UNPACK_V4_32,4,0 );

    ///////////////////////////////////////////////////////////////////////////
    // End the list and start the program

    *((u64*)p_data)++ = DMA_END_TAG( 0 );
    *((u32*)p_data)++ = VIF_CODE( VIF_NOP,0,0 );
    *((u32*)p_data)++ = VIF_CODE( VIF_MSCAL,0,0 );

    PbDmaSend01ChainSpr( p_store );

    ///////////////////////////////////////////////////////////////////////////
    // Sync and flipscreen

    PbScreenSyncFlip();
  }


Thanks in advance
Back to top
View user's profile Send private message
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Fri Apr 22, 2005 5:32 pm    Post subject: Reply with quote

because p_data is probably pointing no where near from where you want to send from.
and then you do an alloc for each frame, so its going to be overwritten.
_________________
Kung VU
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