 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Tue Jul 25, 2006 2:34 am Post subject: PSPGL glDrawElements Extreme slowdown with low poly models. |
|
|
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: |
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: |
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? |
|
| Back to top |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Tue Jul 25, 2006 2:41 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Tue Jul 25, 2006 5:32 pm Post subject: |
|
|
| Quote: | | 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 _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Tue Jul 25, 2006 8:06 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Wed Jul 26, 2006 7:56 am Post subject: |
|
|
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 _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
ector
Joined: 12 May 2005 Posts: 195
|
Posted: Wed Jul 26, 2006 9:36 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|
|
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
|