Performance questions for a 2D game

Started by
13 comments, last by zedzeek 18 years, 8 months ago
Yes, I've tried it on Nvidia, ATI, and some onboard Intel chips. On my 5500fx it does make slow things down a little to leave out the redundancy check, but overall it's not a big change. Other Nvidia boards seem to not care one way or the other. I've only been able to test it on two ATI cards, but neither of them showed any difference between the two methods. The Intel chip, predictably, did show a good chunk of slowdown though. (Not quite as much as you'd expect, mind you.)

Really it should be a non issue, though. Like I said: Just stay on the safe side and implement your own anyways.
// The user formerly known as Tojiro67445, formerly known as Toji [smile]
Advertisement
just tested again + yes there is a huge difference, i assume with your testing u didnt do so many loops (im doing 10million below) + so the differences were so small that the results looked the same, anyways try this if theres still doubt (doing the checking yourself is >20x quicker) which does make sense for one thing its a comparrions vs a function call

//#define ALWAYSBIND

int start = timeGetTime();
int current_tex;
for ( int i=0; i<10000000; i++ )
{
#ifdef ALWAYSBIND
glBindTexture( GL_TEXTURE_2D, 1 );
#else
if ( current_tex != 1 )
{
glBindTexture( GL_TEXTURE_2D, 1 );
current_tex = 1;
}
#endif
}
int end = timeGetTime();
cout << (end - start) / 1000.0 << endl;

times with
glBindTexture( GL_TEXTURE_2D, 1 );

0.562 0.562 0.563 0.563 0.561 0.564 0.563 0.562 0.563 0.562 0.581 0.562 0.565 0.561 0.563 0.564 0.563 0.563 0.561 0.565
0.562 0.564 0.563 0.562 0.562 0.562 0.562 0.562 0.562 0.564 0.563 0.564 0.561 0.562 0.563 0.561 0.563 0.562 0.562 0.561

times with
if ( current_tex != 1 )
{
glBindTexture( GL_TEXTURE_2D, 1 );
current_tex = 1;
}

0.021 0.019 0.021 0.021 0.02 0.022 0.02 0.021 0.02 0.02 0.019 0.021 0.02 0.02 0.02 0.019 0.021 0.021 0.02 0.02
0.02 0.021 0.02 0.021 0.02 0.021 0.02 0.02 0.021 0.02 0.021 0.02 0.021 0.019 0.021 0.019 0.02 0.021 0.021 0.02
0.019 0.021 0.02 0.02 0.021 0.02 0.021 0.021 0.02 0.02 0.02 0.02 0.021 0.02 0.021 0.019 0.021 0.021 0.02 0.021
0.021 0.02 0.021 0.02 0.022 0.02 0.021 0.02 0.021 0.02 0.02 0.02 0.019 0.021 0.02 0.021 0.021 0.021 0.019 0.02
0.021 0.02 0.021 0.02 0.022 0.02 0.02 0.021 0.021 0.021 0.021 0.021 0.019 0.02 0.02 0.021 0.02 0.021 0.019 0.021
zedzeek... your example is terribly flawed. You are only checking the overhead of that many function calls. Not the binding overhead. A function call is going to be much more expensive than a simple conditional statement. The compiler may even optimize that conditional out since it's very simple. You would need to have an effectively empty function which is called (and must make sure it's not optimized out)... and then compare the runtime to glBindTexture... then you can see what kind of overhead the body of glBindTexture really has.
Quote:Original post by TojiI think the best path for a game programmer is to implement one yourself regaurdless, as a double redundancy check (yours and the drivers) is certainly going to be less painful than none at all.


Hehe, anyway I think Toji's idea is right. I implemented this in my game, took like 5 minutes and now I don't have to worry about it :D

roos
Quote:Original post by iambile
zedzeek... your example is terribly flawed. You are only checking the overhead of that many function calls. Not the binding overhead. A function call is going to be much more expensive than a simple conditional statement. The compiler may even optimize that conditional out since it's very simple. You would need to have an effectively empty function which is called (and must make sure it's not optimized out)... and then compare the runtime to glBindTexture... then you can see what kind of overhead the body of glBindTexture really has.

yes i mentioned that in my post,
but even making the test + bind a seperate function instead of using a straight glBindTexture.(..) is magnitudes faster

This topic is closed to new replies.

Advertisement