Archived

This topic is now archived and is closed to further replies.

JohnBSmall

Why is my fps so low?

Recommended Posts

I''ve been working on my 2D engine using DirectXGraphics, and have come across a problem - it''s too slow! The results I''m getting are: With alpha blending 36fps. Without alpha blending 40fps. Everything except the actual drawing (which is a single DrawIndexPrimitive call) 272fps. The facts are: - I''m drawing 100 textured quads (200 triangles) - the texture is the same for all the quads, and it is 256x256 in size. - I have alpha testing turned on at all times (and yes - I know there''s a difference between alpha testing and alpha blending) - I am only locking/unlocking the vertex buffer once on the first frame (the data doesn''t change after that, so I don''t lock it again) - I am using an index buffer which I fill on setup, so that I only have to store 4 vertices per quad (not 6) - I don''t lock it after it''s been set-up. - I have a 32mb GeForce2 MX - I''m running WinXP - It''s displaying in an 800x600 window - I am using the z-buffer, I clear it every frame, but I don''t clear the colour (only the z-buffer). - I have a 1.7GHz Pentium 4 When I ran a profiler, it just confirmed what I thought - I''m spending 95% of the time in my low-level render routine (that''s gfxw_RenderScene if you want to check it). If you want to see the source code (you''ll probably need to), there''s an HTMLed version at: http://www.dbaonline.btinternet.co.uk/curiosity/DoesThisFolderExist/index.html (you may think I''m sad for having converted it to HTML - but I didn''t do it manually, so it really isn''t that big a deal) I suspect that the problem is something to do with the setup code (ie I''m setting things up in a bad way). Thanks in advance to anyone that tries to help. John B

Share this post


Link to post
Share on other sites
I''m sorry for posting without a reply, I did look at your code, but I couldn''t find anything severely wrong with it. I was just wondering what you use as a profiler. Thanks

Share this post


Link to post
Share on other sites
Hi,

I looked at the code briefly, nothing really popped out as being obviously slow, but I''m wondering, how "big" (in final screen coordinates) are your quads? (I didn''t dig deep enough to find this).

If you draw 100 quads that each fill up large portions of the screen, it''ll slow it down a lot. Also, if one of your vertex positions happens to have an invalid value (like Vert.Pos.x = 1.0 x 10^9999 hehe) you''ll have a huge triangle that will slow things down.

There isn''t a whole lot of way to fix this except to not overdraw so much, and to render from front to back, as your z buffer will supposedly save a little work for pixels that, being behind another object, don''t need to be drawn.

Try setting all your vertex positions to 0,0,0 -- if this makes it super fast again, fill rate could likely be your problem.

Good luck!


-ns-

Share this post


Link to post
Share on other sites
Each quad is 128x128 pixels (and yes, that means the texture is scaled down by 2 for every quad - but I''m not using bi-linear filtering or anything, so that shouldn''t really be a problem).

I haven''t seen any excessivly large triangles, and I doubt there''s a problem in the vertex setting code, but I''ll try setting everything to 0,0,0 as you said.

Thanks for the help.

John B

Share this post


Link to post
Share on other sites
Well, when I tried setting all the vertices to 0,0,0 the framerate jumped back up to 265 fps.
So I''ll assume (for now) that it''s just a fill-rate problem.

Can anyone suggest another way that I could test whether it is only fill-rate?

What FPS would you expect when drawing 100 textured quads, each 128x128 with a 256x256 texture mapped onto them - on a GeForce2 MX?

John B

Share this post


Link to post
Share on other sites
Well, I''ve done a few more tests (not very many though).

I''ve changed down to displaying 75 quads instead of 100 for all the tests. I''m also locking the vertex buffer every frame now, because realisticly, I''ll have to lock it every frame in the game. And the following results all have alpha blending enabled as well.

Quads all 128x128 texture 256x256 - 48 fps
Quads all 128x128 texture 128x128 - 106 fps
Quads all 128x128 no texture - 83 fps

I guess that the reason it''s slower when I turn off the texture is that a lot of the texture is transparent (and I have alpha testing turned on).

I''ll do more tests when I have time.

Btw, just for reference:
The number of pixels in 75 128x128 size images (what I''m drawing for these tests) is:
1228800
The number of pixels in a 800x600 display is:
480000
The number of pixels in a 1024x768 display is:
786432

So these tests aren''t necessarily awful - I might not be drawing this much in the actual game.

John B

Share this post


Link to post
Share on other sites