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 

A proper way to draw

 
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: Sun Mar 22, 2009 3:56 am    Post subject: A proper way to draw Reply with quote

I have written some code for my game. But I have a feeling that its working too slow. Could you guys comment this please?
Code:

/*This is my vertex structure*/
typedef struct
{
   unsigned short u, v;
   unsigned int color;
    short x, y, z;
   unsigned short useless; //for a 16bit struct
} Vertex;

/*In the main loop*/
/*-------------------------------------*/
guStart();
   
//clean screen
sceGuClearColor(0xff554433);
sceGuClearDepth(0);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

sceKernelDcacheWritebackAll();
      sceGuTexImage(0, Alien->textureWidth, Alien->textureHeight, Alien->textureWidth, (void*) Alien->data);
      Vertex* vertices = (Vertex*)sceGuGetMemory(mobsterCount *2 * sizeof(Vertex));

/*Filling the vertex buffer*/
int mix=0,miny=0,maxx=60,maxy=60;
      for (i=0,h=0;i<mobsterCount;i++,h+=2)
      {
         vertices[h].u = minx;
         vertices[h].v = miny;
         vertices[h].color = 0;
         vertices[h].x = mobsters[i].x;
         vertices[h].y = mobsters[i].y;
         vertices[h].z = 0;

         vertices[h+1].u = minx+maxx;
         vertices[h+1].v = miny+maxy;
         vertices[h+1].color = 0;
         vertices[h+1].x = mobsters[i].x+maxx;
         vertices[h+1].y = mobsters[i].y+maxy;
         vertices[h+1].z = 0;
      }
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D,mobsterCount*2,0,vertices);

sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
sceGuSwapBuffers();

This fragment draws mobsterCount number of 60x60 images. Is this a proper blitting? I am realy not satistfied with the drawing speed, but I would like to skip swizzling and cache manipulation.
Back to top
View user's profile Send private message
Smong



Joined: 04 Sep 2007
Posts: 82

PostPosted: Fri Mar 27, 2009 7:51 am    Post subject: Reply with quote

Here are some ideas:
- Take sceKernelDcacheWritebackAll(); out of the mainloop
- Don't call sceGuTexImage if the texture didn't change since the last draw call
- Remove the color component from the vertex data, use sceGuColor or similar instead
- Cut the textures to 32x32 or use swizzling on 64x64
- Use 5551 or 5650 textures instead of 8888.
- Remove texture filtering, use GU_NEAREST
- Store your texture in vram instead of main memory
- Make sure you're not drawing something that is outside of the visible area of the screen, it looks like you're drawing the entire mobster list.
- Turn off blending
_________________
(+[__]%)
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