Optimizing the GU (how to get best performances)

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
skwi
Posts: 22
Joined: Tue May 16, 2006 4:28 am

Optimizing the GU (how to get best performances)

Post by skwi »

I searched how to get the best performances with the GU

here is what I found :



Textures :
-use indexed textures
-use swizzled textures
-load textures in VRAM

Vertices array :
-use vertices between 8-12 bytes
-EDIT : DON'T use vertex index
-use stripped triangles



ok, now i want to know what is the best vertex format to use, I have :
-texture coordinates
-normals
-vertices position

because I need 16 bit for the vertices position, i don't need more than 8 bit for the normals, and 8 bits texture coordinates can be well
this is : 3*2+3*1+2*1 = 11 bytes
11 is between 8-12 but vertex data must be aligned to 4 bytes, this mean i can't use 11 bytes vertices
i think the best thing to do is to use 16 bit for each : 2*3+2*3+2*2 =16
but 16 is'nt between 8-12






I read that I should use double buffered display list, but i can't find how to do this, can anybody help me please ?


and if you know any optimization I haven't listed, please tell it

thanks for replying
Last edited by skwi on Mon Aug 14, 2006 1:19 am, edited 1 time in total.
skwi
Posts: 22
Joined: Tue May 16, 2006 4:28 am

Post by skwi »

User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Well, to my finding, I could also just supply a 8Bit Vertex position structure, which will have 3bytes per vertex and therefore isn't aligned to 4bytes, but still worked well. So maybe just try to go with your 11byte structure and see if it works. If it does, it should be at best speed already so nothing to worry
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Post by weak »

texture stripping would be another option
skwi
Posts: 22
Joined: Tue May 16, 2006 4:28 am

Post by skwi »

thanks for your answers

Raphael, , sometimes 8 bit can work and it's 4 bytes aligned : 1*3+1*3+1*2 = 8 , but with somes big detailled objects, 256 isn't enough, i'll make a test but i think there is not a huge difference according to this :
8 bytes: 13.67mv/s (13.67mv/s)
10 bytes: 13.67mv/s (13.67mv/s)
12 bytes: 13.67mv/s (13.67mv/s)
16 bytes: 13.62mv/s (13.67mv/s)
(frome here : http://forums.ps2dev.org/viewtopic.php?t=4703)


weak, texture is stripped when I use stripped vertices ?


and do you know something about double buffered display list ?
skwi
Posts: 22
Joined: Tue May 16, 2006 4:28 am

Post by skwi »

I can't make any performance test because i can't go over 60 fps
with somes polygons : 60 fps
with 20000 polygons : 60 fps

i don"t think my fps is wrong because i can move with the same speed with somes polygons or with 20000 polygons

why ?
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

If you're calling sceDisplayWaitVblankStart() then you will never achieve more than 60 FPS.

Remove the call and you will see the true FPS.
skwi
Posts: 22
Joined: Tue May 16, 2006 4:28 am

Post by skwi »

thanks but i know this, I removed it but the fps is still 60 (sorry i forgot to say it in my last post)
PeterM
Posts: 125
Joined: Sat Dec 31, 2005 7:25 pm
Location: Edinburgh, UK
Contact:

Post by PeterM »

There are also two nearly identical functions to get the controller state - but one waits for the vblank.

sceCtrlPeekPadData() vs sceCtrlReadPadData() or something like it.
skwi
Posts: 22
Joined: Tue May 16, 2006 4:28 am

Post by skwi »

but i don't use any of this
this is my main loop :

Code: Select all

while&#40;running&#40;&#41;&#41;
	&#123;
		sceGuStart&#40;GU_DIRECT,list1&#41;;
		
		if&#40;objetest.etat==0&#41;
		&#123;
		if&#40;chargeobj&#40;&objetest&#41;==0&#41;//load the object
	        break;//quit
		&#125;
		
		gettimeofday&#40;&curr_time,0&#41;;
		fcount++;
		if&#40;curr_time.tv_sec!=lastime&#41;//every second
		&#123;
		 fps=fcount;
		 fcount=0;
		&#125;
		
		lastime= curr_time.tv_sec;
		
		
		
		
		pspDebugScreenSetXY&#40;0, 1&#41;;
		pspDebugScreenPrintf&#40;"test nb x &#58; %x\nfps &#58; %d",objetest.texvram,fps&#41;;
		pspDebugScreenSetXY&#40;0, 3&#41;;
		pspDebugScreenPrintf&#40;"near &#58; %f\n",near&#41;;
		
		
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
		
			if &#40;pad.Buttons & PSP_CTRL_UP&#41;&#123;
			x+=-sin&#40;yrot&#41;*.1;
			z+=cos&#40;yrot&#41;*.1;
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_DOWN&#41;&#123;
			x-=-sin&#40;yrot&#41;*.1;
			z-=cos&#40;yrot&#41;*.1;
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_LEFT&#41;&#123;
				
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_RIGHT&#41;&#123;
				
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41;&#123;
				near-=.1;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41;&#123;
				near+=.1;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_SQUARE&#41;&#123;
				xrot+=.1;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41;&#123;
				y-=.1;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;&#123;
				y+=.1;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;&#123;
				xrot-=.1;
			&#125;
			
			if &#40;pad.Lx<100&#41;&#123;//left
				yrot-=&#40;&#40;100.0f-pad.Lx&#41;/1000.0f&#41;;
			&#125;
			if &#40;pad.Lx>160&#41;&#123;//right
				yrot+=&#40;&#40;pad.Lx-160.0f&#41;/1000.0f&#41;;
			&#125;
			if &#40;pad.Ly<100&#41;&#123;//up
			x+=&#40;-sin&#40;yrot&#41;*&#40;100.0f-pad.Ly&#41;/500.0f&#41;;
			z+=&#40;cos&#40;yrot&#41;*&#40;100.0f-pad.Ly&#41;/500.0f&#41;;
			&#125;
			if &#40;pad.Ly>160&#41;&#123;//down
			x-=&#40;-sin&#40;yrot&#41;*&#40;pad.Ly-160.0f&#41;/500.0f&#41;;
			z-=&#40;cos&#40;yrot&#41;*&#40;pad.Ly-160.0f&#41;/500.0f&#41;;
			&#125;
		

		// clear screen

		sceGuClearColor&#40;0xff554433&#41;;
		sceGuClearDepth&#40;0&#41;;
		sceGuClear&#40;GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT&#41;;

				//setup one light
		ScePspFVector3 pos = &#123; 0, 2, 0 &#125;;
			sceGuLight&#40;0,GU_DIRECTIONAL,GU_DIFFUSE_AND_SPECULAR,&pos&#41;;
			sceGuLightColor&#40;0,GU_DIFFUSE,0x88888888&#41;;
			sceGuLightColor&#40;0,GU_SPECULAR,0xFFFFFFFF&#41;;
			sceGuLightAtt&#40;0,0.0f,1.0f,0.0f&#41;;

			
		sceGuSpecular&#40;16.0f&#41;;
		sceGuAmbient&#40;0x00444444&#41;;
		
		

		sceGumMatrixMode&#40;GU_PROJECTION&#41;;
		sceGumLoadIdentity&#40;&#41;;
		sceGumPerspective&#40;45,16.0f/9.0f,near,1000.0f&#41;;

		sceGumMatrixMode&#40;GU_VIEW&#41;;
		sceGumLoadIdentity&#40;&#41;;
		&#123;
			ScePspFVector3 pos = &#123; x, y, z &#125;;
			ScePspFVector3 rot = &#123; xrot, yrot,zrot &#125;;
			sceGumRotateXYZ&#40;&rot&#41;;
			sceGumTranslate&#40;&pos&#41;;
		&#125;
		
		
		
		sceGumMatrixMode&#40;GU_MODEL&#41;;

			
			
		
		dessineobj&#40;&objetest&#41;;
		

		sceGuFinish&#40;&#41;;
		sceGuSync&#40;0,0&#41;;

		//sceDisplayWaitVblankStart&#40;&#41;;
		sceGuSwapBuffers&#40;&#41;;

		
	&#125;
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

PeterM wrote:but one waits for the vblank
...and that's sceCtrlReadBufferPositive (which you're using)
you should use sceCtrlPeekBufferPositive instead.
infj
PeterM
Posts: 125
Joined: Sat Dec 31, 2005 7:25 pm
Location: Edinburgh, UK
Contact:

Post by PeterM »

Yep, I couldn't remember the exact function names, sorry.
skwi
Posts: 22
Joined: Tue May 16, 2006 4:28 am

Post by skwi »

thank you, now this is working
i'm sorry I did'nt understand your first post at first
now i can do somes tests
Post Reply