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 

The blit sample

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



Joined: 21 Mar 2009
Posts: 7

PostPosted: Sat Mar 21, 2009 6:42 pm    Post subject: The blit sample Reply with quote

I have a question about this function in the blit example.
Code:

void advancedBlit(int sx, int sy, int sw, int sh, int dx, int dy, int slice)
{
   int start, end;

   // blit maximizing the use of the texture-cache

   for (start = sx, end = sx+sw; start < end; start += slice, dx += slice)
   {
      struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
      int width = (start + slice) < end ? slice : end-start;

      vertices[0].u = start; vertices[0].v = sy;
      vertices[0].color = 0;
      vertices[0].x = dx; vertices[0].y = dy; vertices[0].z = 0;

      vertices[1].u = start + width; vertices[1].v = sy + sh;
      vertices[1].color = 0;
      vertices[1].x = dx + width; vertices[1].y = dy + sh; vertices[1].z = 0;

      sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_4444|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
   }
}

What is the role of the variable
Code:
slice
here?

And should I create vertices for all of my objects and use sceGuDrawArray 1 time or can I just call this function many times? What would be the perfomance impact?

Thanks
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat Mar 21, 2009 8:16 pm    Post subject: Reply with quote

Its drawing an array of pixels with the GU at once. i.e. one vertical line at a time. Slice is the current vertical line its drawing from your source image.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat Mar 21, 2009 8:54 pm    Post subject: Reply with quote

Not quite. It's more than one vertical line. It's because the texture cache inside the GU is limited. Depending on the pixel format, the cache will only hold from 128x128 for 16 color LUT mode to 32x64 for 32 bit ARGB. If you try to draw wider than what fits in the cache, the GU will stall while the cache reloads, and since that would happen on every line, your rendering speed would plummet. So you only make it "slice" wide so that all the lines fit in the cache for much faster rendering speed. Slice has been chosen for 32 bit modes, but you can change that if you use different pixel formats. I do in Basilisk 2. Just seach ps2dev for texture cache for a more complete explanation as well as the exact size that fits in the cache.
Back to top
View user's profile Send private message AIM Address
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