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 

what is the correct way using a pregenerated command list

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



Joined: 19 Mar 2006
Posts: 22

PostPosted: Sat Apr 15, 2006 8:21 am    Post subject: what is the correct way using a pregenerated command list Reply with quote

hi guys,

i've simply modified the cube sample to display 120 cubes (each one textured with the same texture)
my first try give me some very poor performance and so i decided to pre generated 2 command lists (one for the texture and another one for the cube)

i must be missing something because i changes nothing to the performance i got !! => 15 fps !!

here is the full code, just replace the main file from the cube sample with this file and it should compile
why is there no performance gain ?

thanks in advance for any help !!


Code:


/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <pspdebug.h>

#include <time.h>

#include <pspgu.h>
#include <pspgum.h>

#include "../common/callbacks.h"
#include "../common/vram.h"

PSP_MODULE_INFO("Cube Sample", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

static unsigned int __attribute__((aligned(16))) list[262144];
extern unsigned char logo_start[];

#define printf   pspDebugScreenPrintf

struct Vertex
{
   float u, v;
   unsigned int color;
   float x,y,z;
};

struct Vertex __attribute__((aligned(16))) vertices[12*3] =
{
   {0, 0, 0xff7f0000,-1,-1, 1}, // 0
   {1, 0, 0xff7f0000,-1, 1, 1}, // 4
   {1, 1, 0xff7f0000, 1, 1, 1}, // 5

   {0, 0, 0xff7f0000,-1,-1, 1}, // 0
   {1, 1, 0xff7f0000, 1, 1, 1}, // 5
   {0, 1, 0xff7f0000, 1,-1, 1}, // 1

   {0, 0, 0xff7f0000,-1,-1,-1}, // 3
   {1, 0, 0xff7f0000, 1,-1,-1}, // 2
   {1, 1, 0xff7f0000, 1, 1,-1}, // 6

   {0, 0, 0xff7f0000,-1,-1,-1}, // 3
   {1, 1, 0xff7f0000, 1, 1,-1}, // 6
   {0, 1, 0xff7f0000,-1, 1,-1}, // 7

   {0, 0, 0xff007f00, 1,-1,-1}, // 0
   {1, 0, 0xff007f00, 1,-1, 1}, // 3
   {1, 1, 0xff007f00, 1, 1, 1}, // 7

   {0, 0, 0xff007f00, 1,-1,-1}, // 0
   {1, 1, 0xff007f00, 1, 1, 1}, // 7
   {0, 1, 0xff007f00, 1, 1,-1}, // 4

   {0, 0, 0xff007f00,-1,-1,-1}, // 0
   {1, 0, 0xff007f00,-1, 1,-1}, // 3
   {1, 1, 0xff007f00,-1, 1, 1}, // 7

   {0, 0, 0xff007f00,-1,-1,-1}, // 0
   {1, 1, 0xff007f00,-1, 1, 1}, // 7
   {0, 1, 0xff007f00,-1,-1, 1}, // 4

   {0, 0, 0xff00007f,-1, 1,-1}, // 0
   {1, 0, 0xff00007f, 1, 1,-1}, // 1
   {1, 1, 0xff00007f, 1, 1, 1}, // 2

   {0, 0, 0xff00007f,-1, 1,-1}, // 0
   {1, 1, 0xff00007f, 1, 1, 1}, // 2
   {0, 1, 0xff00007f,-1, 1, 1}, // 3

   {0, 0, 0xff00007f,-1,-1,-1}, // 4
   {1, 0, 0xff00007f,-1,-1, 1}, // 7
   {1, 1, 0xff00007f, 1,-1, 1}, // 6

   {0, 0, 0xff00007f,-1,-1,-1}, // 4
   {1, 1, 0xff00007f, 1,-1, 1}, // 6
   {0, 1, 0xff00007f, 1,-1,-1}, // 5
};

#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)

#define SET_TEXTURE()         sceGuCallList(smallList1);   
#define DISPLAY_CUBE()   SET_TEXTURE(); sceGumUpdateMatrix(); sceGuCallList(smallList2);   

static unsigned int __attribute__((aligned(16))) smallList1[1024];
static unsigned int __attribute__((aligned(16))) smallList2[1024];

int main(int argc, char* argv[])
{
   pspDebugScreenInit();
   setupCallbacks();

   // setup GU

   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);

   sceGuInit();

   sceGuStart(GU_DIRECT,list);
   sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH);
   sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
   sceGuDepthBuffer(zbp,BUF_WIDTH);
   sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
   sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
   sceGuDepthRange(65535,0);
   sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
   sceGuEnable(GU_SCISSOR_TEST);
   sceGuDepthFunc(GU_GEQUAL);
   sceGuEnable(GU_DEPTH_TEST);
   sceGuFrontFace(GU_CW);
   sceGuShadeModel(GU_SMOOTH);
   sceGuEnable(GU_CULL_FACE);
   sceGuEnable(GU_TEXTURE_2D);
   sceGuEnable(GU_CLIP_PLANES);
   sceGuFinish();
   sceGuSync(0,0);

   sceDisplayWaitVblankStart();
   sceGuDisplay(GU_TRUE);

   // run sample

   int val = 0;
   long oldMS, curMS;

   struct timeval tval;
   gettimeofday(&tval,0);

   oldMS = tval.tv_sec * 1000 + tval.tv_usec;


   // generate callable command-list for cube rendering
   {
      sceGuStart(GU_CALL, smallList2);

      // draw cube
      sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,vertices);

      sceGuFinish();
      sceGuSync(0,0);
   }

   {
      sceGuStart(GU_CALL, smallList1);
   
      sceGuTexMode(GU_PSM_4444,0,0,0);            
      sceGuTexImage(0,64,64,64,logo_start);         
      sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGB);         
      sceGuTexEnvColor(0xffff00);                  
      sceGuTexFilter(GU_LINEAR,GU_LINEAR);         
      sceGuTexScale(1.0f,1.0f);                  
      sceGuTexOffset(0.0f,0.0f);                  
      sceGuAmbientColor(0xffffffff);

      sceGuFinish();
      sceGuSync(0,0);
   }



   

   while(running())
   {
      pspDebugScreenSetXY(1, 1);

      struct timeval tval;
      gettimeofday(&tval,0);

      curMS = tval.tv_sec * 1000000 + tval.tv_usec;
      long diff = curMS - oldMS;
      
      float fff = 1000000.f / diff;

      printf("%d %d %f\n", tval.tv_sec, tval.tv_usec, fff);

      oldMS = curMS;

      sceGuStart(GU_DIRECT,list);

      // clear screen

      sceGuClearColor(0xff554433);
      sceGuClearDepth(0);
      sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

      // setup matrices for cube

      sceGumMatrixMode(GU_PROJECTION);
      sceGumLoadIdentity();
      sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);

      sceGumMatrixMode(GU_VIEW);
      sceGumLoadIdentity();

      // setup texture

      float Y = 2;
      float Z = -7.5f;
      int IMAX = 4;
      int i;

      for (i = 0; i < IMAX; ++i)
      {

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         Y = 4;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = 0;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = -2;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = -4;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         Z = -10.0f;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         Y = 4;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = 0;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = -2;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = -4;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Z = -12.5f;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         Y = 4;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = 0;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = -2;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = -4;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();



         Z = -15.0f;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         Y = 4;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = 0;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = -2;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();


         Y = -4;

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -2, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -4, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { 6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();

         sceGumMatrixMode(GU_MODEL);
         sceGumLoadIdentity();
         {
            ScePspFVector3 pos = { -6, Y, Z };
            ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) };
            sceGumTranslate(&pos);
            sceGumRotateXYZ(&rot);
         }
         // draw cube
         DISPLAY_CUBE();
      }


      sceGuFinish();
      sceGuSync(0,0);

      sceDisplayWaitVblankStart();
      sceGuSwapBuffers();

      val++;
   }

   sceGuTerm();

   sceKernelExitGame();
   return 0;
}




i know i could have used a loop to display my 120 cubes but i'm a bit loafer ;)
Back to top
View user's profile Send private message Send e-mail
starman2049



Joined: 19 Sep 2005
Posts: 75

PostPosted: Sat Apr 15, 2006 1:29 pm    Post subject: Reply with quote

There are no silver bullets on PSP, just a whole lot of little things that all add up to a bigger performance improvement.

Off the top of my head it looks like you are doing 120 texture sets per frame, and to boot they are from system ram, not vram, and they are not swizzled.

I try to keep the number of textures for a scene to under 20 - but that's also a function of the size of each, and how flexible your artists are.

You want to load textures into VRAM with sceGuCopyImage() and then draw triangles with them. You also will get a big boost if you swizzle them (look elsewhere for swizzle info).

Feel freee to ask more...
Back to top
View user's profile Send private message
zoret



Joined: 19 Mar 2006
Posts: 22

PostPosted: Sat Apr 15, 2006 7:39 pm    Post subject: Reply with quote

ok it sound logical
i will optimize the texture transfer later
for now i've tester with only one SET_TEXTURE, at the beginnning of the frame
all the cubes using the same texture
with that i only multiply the FPS by 2 (15 => 30 FPS)
i will try without the sceDisplayWaitVblankStart() to have a more precise FPS

is that normal 30 FPS to display 480 cubes (not 120, i had forget my hacked loop (int IMAX) ?
480 cubes with 36 vertices by cube => 17280 vertices at 30 FPS

what are the optimisations i can put on the cubes transfert ?

thanks
Back to top
View user's profile Send private message Send e-mail
starman2049



Joined: 19 Sep 2005
Posts: 75

PostPosted: Sun Apr 16, 2006 4:41 am    Post subject: Reply with quote

You can optimize your vertex format. Right now you are using floats for everything (UV, COLOR, XYZ). An easy fix would be to convert your UV from float to 16bit. You can convert the others too, but thats going to require some special transforms.

Drawing 480 cubes on top of each other is a lot of overdraw, and my guess is they are close up to the screen and are big. (I didn't look at your code in detail). For more realistic case, try creating an array of 480 cubes that are offset in x,z so none overlap and then back the camera off so you can see them all (and hence each is smaller).

Yes, taking vsync off will get you a more accurate fps reading.
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