Skip to main content
gamedev.net
🔒 Locked

Huge fps drop from glBindTexture

Started by Ganoosh_ Aug 30, 2006 at 4:58 PM 8 replies 1.4k views
Original Post
Ganoosh_
Ganoosh_
As the title states, I'm getting a huge fps drop from texturing. I'm drawing a sprite 48x48 as a textured quad, and narrowed it down to the glBindTexture call and it's only when I actually call the texture. If I put 0 (no texture), it doesn't drop. I'm talking like a 1800 fps drop, is this supposed to happen? I'm using textured fonts and it's drawing textures for all the letters and the fps isn't dropping? Any idea what the problem could be?
_the_phantom_
_the_phantom_
The drop is irrlivent as your rendering time is already stupidly fast so it doesn't matter. When you start seeing sub-60fps then you start worrying about things like this.

glBindTexture is an expensive call to make as it sets alot of internal state, thus the drop, it's normal, forget about it for now and move on.
Ganoosh_
Ganoosh_
Ok, cuz the drop is bringing me to between 60-70 fps and it's one sprite just wondering if having lots on the screen will keep dropping or keep it at the same.
KulSeran
KulSeran
IMHO i think you are worring too soon. But if you do need lots of sprites, and your current way isn't
working fast enough. There are a few optimiztions you can do. Like stack several sprite textures into one
texture. You then have to offset your UV coords inorder to select the proper texure out of the swatch.
-For example, you can put 4 ground textures into a 96x96 texture. then you can select one texture and
then draw all your ground tiles without the performance hit of a glbind per sprite.

You should also batch your textures, expecially in conjunction with the above sugestion. This meaing
that if you make one texture for all the ground sprites, and then one texuture for all the people sprites
then you should draw all the groud tiles in one go, then switch textures only once, and then draw
all the people.
dave
dave
Just two elaborate on why Phantoms words are true...

If you are running at 1000fps and add a piece of code in that drops it down to around 500fps, the time the frame has taken to be rendered has gone from 1ms to 2ms, its doubled. The operation you added has a time value of 1ms.

If you are running at 100fps and add a piece o code in that drops it down to around 50fps, the time the frame has taken to be rendered has gone from 10ms to 20ms. What you added has a time value of 10ms, which is alot more expensive.

In future, it is more sensible to consider how long it takes a frame to render, rather than the FPS.

Dave
deavik
deavik
Quote:
Original post by Marmin
Possibly the texture size is too large or not the right dimension.

Quoted for emphasis: this is most likely the problem. Otherwise post your hardware and glTexImage2D call.

1870 fps -> 70 fps seems like a bit too drastic to be just setting the right texel read array.
_the_phantom_
_the_phantom_
gah, image size, how could I have missed that.. yes, 48*48 is not a power of two size, given we don't know what hardware and what texture parameters you've setup it's not overly easy to say, but that does look like the most likely cause of your problem.
Yann L
Yann L
Recent ATI drivers switch to software rendering when supplied with a non power of two texture through glTexImage2D, and when a feature such as mipmapping or repeat wrapping mode is enabled.
Ganoosh_
Ganoosh_
Quote:
Original post by KulSeran
IMHO i think you are worring too soon. But if you do need lots of sprites, and your current way isn't
working fast enough. There are a few optimiztions you can do. Like stack several sprite textures into one
texture. You then have to offset your UV coords inorder to select the proper texure out of the swatch.
-For example, you can put 4 ground textures into a 96x96 texture. then you can select one texture and
then draw all your ground tiles without the performance hit of a glbind per sprite.

You should also batch your textures, expecially in conjunction with the above sugestion. This meaing
that if you make one texture for all the ground sprites, and then one texuture for all the people sprites
then you should draw all the groud tiles in one go, then switch textures only once, and then draw
all the people.

That's how I do it with my text, font is all one image and I offset based on letter. Is that really faster?
Yes, the image size is 48x48, which I know isn't good, but it is really that drastic? Would it be faster to use a 64x64 texture and just draw the extra pixels transparent? That's extra pixels + blending, I thought it would be slower.

Also, I have ATI, so then it's probably rendering software. That could be why it's so drastic. Even it's the extra transparent pixels is slower, it's still hardware rendering. I'll try using a 64x64 and post an update.

Edit: yep that was it, thanks for the help guys. Running a little over 1700 fps now.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.