PSPGL glDrawElements Extreme slowdown with low poly models.

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

Moderators: cheriff, TyRaNiD

Post Reply
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

PSPGL glDrawElements Extreme slowdown with low poly models.

Post by Kojima »

I have a ship model, that is about 800 tris I guess, and with this it renders fine, at 60fps, the hardware limit.
But if I then add ONE 4 poly quad, with a single 256x256 texture, the framerate drops to 30fps. How can a 800 poly ship render at 60fps, yet one more quad in a seperate entity slaughter the framerate?
If I add just one hundred quads, the framerate drops to 10fps and is unplayable.

Here's my bind/rendering code for pspgl, you can get the full engine in the release forum.

Code: Select all

	virtual void Bind()
	{
		Profile->Enter("Bind\n");
		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(3,GL_FLOAT,0,_verts);
	         _mat->Bind();
		_mat->_texs.start();
		while( _mat->_texs.next() == true )
		{
			Texture *tex = _mat->_texs.get();
			glEnableClientState(GL_TEXTURE_COORD_ARRAY);
			glTexCoordPointer(3,GL_FLOAT,0,_coords[tex->_coordset]->_uv);
		}
		Profile->Leave("Bind\n");
	}
	virtual void Unbind()
	{
		Profile->Enter("Unbind\n");
		glDisableClientState(GL_VERTEX_ARRAY);
	
		glVertexPointer(3,GL_FLOAT,0,NULL);
	
		_mat->Unbind();
		_mat->_texs.start();
		while( _mat->_texs.next() == true )
		{
			Texture *tex = _mat->_texs.get();
			glDisableClientState(GL_TEXTURE_COORD_ARRAY);
			glTexCoordPointer(3,GL_FLOAT,0,NULL);
		}	
		Profile->Leave("Unbind\n");
	}
	virtual void Render()
	{
		Profile->Enter("VL_Render\n");
		glDrawElements(GL_TRIANGLES,_tric*3,GL_UNSIGNED_INT,_tris);
		Profile->Leave("VL_Render\n");
	}
And my profiler output is,

Code: Select all

Function:Unbind
 
Total(Seconds):2.868000 
Avg(Ms):0 
-----------------------Function:VL_Render
 
Total(Seconds):48.893002 
Avg(Ms):0 
-----------------------Function:Bind
 
Total(Seconds):3.407000 
Avg(Ms):0 
-----------------------Function:Main Loop
 
Total(Seconds):83.888000 
Avg(Ms):171 
-----------------------End of profile dump.
Logger deleted
Of the 83 seconds of runtime, a whooping 43 seconds is spend in drawelements. which if I've calculated it right(and i probably havn't) that's 50% of each second going to rendering alone.

So, is there anything faster than glDrawElements? Can I write my own renderer using gu that won't be such a huge bottleneck?

I mean, how do you do a particle engine without using lots of tri-based quads? Do most psp games use a single surface particle system?
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

I more believe your 256x256 texture is the problem. Especially if your drawn quad is pretty large (maybe even fills whole screen?). Try using swizzled textures and try subdividing your quad to more quads which only cover around 1/4 of your texture (ie a 64x64 portion of it). This should improve your texture cache hit ratio greatly and also get you closer to your 60fps again.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

How can a 800 poly ship render at 60fps, yet one more quad in a seperate entity slaughter the framerate?
Perhaps because you're taking 1/60th minus a tiny amount and this extra geometry is pushing you to 1/60th plus a bit. If you're waiting for retrace you will then drop to 1/30th.

Jim
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

How would I use swizzled textures in PspGL ralph? Would I have to use gu? If so could you point me in the direction of an example/thread showing how please?
The thing is, the ship texture is just as big, as the ship covers more of the screen than the code. which covers about 64x64 pixels I guess.
And even when there are an hundred, only about 10 are visible on screen, the rest are off-screen (And are therefore clipped as I've not disabled clipping. so they shouldn't affect fill-rate)


Jim, that doesn't really seem likely unless consoles are a complete different world to pc engines. I mean I've wrote several engines, all of which on a pc, and I've never seen a single quad cause such a dramatic slowdown. Is there a guide or anything about maintaing performance on the psp?
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

I'm not saying I'm right, it's just a suggestion. If you think of each frame as a bucket of polygons you can render in that time, then if you overflow in to the next bucket you're using 2 buckets and hence taking twice the time. Even if there's only a couple of polygons in the 2nd bucket.
At least with the PSP you have a constant goal to aim at, on the PC everything is so volatile you'd be hard pushed to get the same timings twice in a row!

The code for doing the swizzling is on the wiki.

Jim
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

If you scale down a 256x256 texture to 64x64 WITHOUT using mipmaps and swizziling, you are completely destroying all the work the texture cache is doing for you. Think low-level. It likes to cache blocks. And if you're texturing from RAM without the aid of the texture cache, it's just going to be PAINFULLY slow.

You're coding for limited console hardware here, not a fullblown PC graphics card with monster fillrate, monster caches and automatic mipmap generation in the API. To get decent performance, you HAVE to think like the hardware.
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
Post Reply