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 

Gu inistialisation

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



Joined: 01 Sep 2009
Posts: 18

PostPosted: Sat Sep 05, 2009 3:13 am    Post subject: Gu inistialisation Reply with quote

I see sometimes in pspgu initialisation this lines:
Code:
   void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
   void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
   void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444);

what's their function?
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Sat Sep 05, 2009 6:24 pm    Post subject: Reply with quote

They do exactly that they are named.

They allocate memory in the vram so the GU can use it as a buffer.
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
maroxe



Joined: 01 Sep 2009
Posts: 18

PostPosted: Sun Sep 06, 2009 1:13 am    Post subject: Reply with quote

if those functions are not called, gu will use the RAM?
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Sun Sep 06, 2009 3:12 am    Post subject: Reply with quote

When you watch the sources of those functions:
samples/gu/common/vram.c

you will see what they does.
Code:
static unsigned int staticOffset = 0;

static unsigned int getMemorySize(unsigned int width, unsigned int height, unsigned int psm)
{
   switch (psm)
   {
      case GU_PSM_T4:
         return (width * height) >> 1;

      case GU_PSM_T8:
         return width * height;

      case GU_PSM_5650:
      case GU_PSM_5551:
      case GU_PSM_4444:
      case GU_PSM_T16:
         return 2 * width * height;

      case GU_PSM_8888:
      case GU_PSM_T32:
         return 4 * width * height;

      default:
         return 0;
   }
}

void* getStaticVramBuffer(unsigned int width, unsigned int height, unsigned int psm)
{
   unsigned int memSize = getMemorySize(width,height,psm);
   void* result = (void*)staticOffset;
   staticOffset += memSize;

   return result;
}


As you can see it just keeps track of the used memory in the vram.

If you don't use those functions you will also use vram because the pointers are relative to the vram base.
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
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