PDA

View Full Version : Very stange TMUs



TurboCG
07-08-2002, 11:32 AM
I'm experiencing a very strange behavior.
I've two TMU's enabled for cube mapping on the first pass. The second pass requires only the first TMU; and disabling the second TMU drops down the performance from 60/70 fps to nearly single/sec. This happens only when I disable it. What's wrong?
My 3d card is GeForce 2 MX
OpenGL driver version 1.3 (latest)

Nutty
07-08-2002, 11:36 AM
Are you resetting the 1st TMU as the active texture unit, after you've disabled the 2nd?

TurboCG
07-08-2002, 12:26 PM
Yes. TMU0 is initially enabled for 2D texuring and cube-mapping. On the second pass, I disable both TMU0 and TMU1 cube-mapping, leaving TMU0 only enabled for 2d texturing.

Dan82181
07-08-2002, 12:47 PM
For disabling cube mapping, you could just call

glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);

because that has pretty much the same effect as calling

glDisable(GL_TEXTURE_CUBE_MAP_ARB);

My stupid question of the day:
why do you have both 2D and CUBE_MAP_ARB texture modes enabled at the same time on TEXTURE0_ARB?!?!

Dan

TurboCG
07-08-2002, 08:30 PM
I'm trying to do per pixel lighting. The first pass requires both TMU0 and TMU1 to dot product normalized vectors. The second
rendering pass requires 2d texturing enabled for TMU0 to blend a decal texture.
I think it would be faster to disable TMU0-cube-map instead of rebinding a 2d texture object.

Dan82181
07-09-2002, 05:30 AM
OK, that answers that. Well, what you could try to do is on your first pass...

glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, _tex1num_);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, _tex2num_);

Then on your second pass, you could try this...

glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, _tex3num_);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);

Binding to texture 0 shouldn't cause any rendering problems (hopefully.) Although I would think that there _might_ be a small performance hit because the extra texturing is still enabled in both the first and the second passes. But it certainly shouldn't be as bad as going down to ~1 frame/sec. Something else you should try is see if you can benchmark your own program to see if keeping TEXTURE_2D disabled, then enabling TEXTRE_2D and disabling TEXTURE_CUBE_MAP_ARB and seeing if there is much of a speed difference. From what it sounds like your saying, your GF2MX is sampling TEXTURE_2D with the same texcoords as your using for TEXTURE_CUBE_MAP_ARB, except that your TEXTURE_CUBE_MAP_ARB is replacing the pixel value used, so you're actually wasting some texturing power sampling that extra 2D texture, unless there's some way of telling OpenGL to not sample an active texture?

Dan

wis mak
07-10-2002, 12:21 PM
I tried your suggestion and bound TMU1 cube-mapping to the default texture name 0.
I got undesirable results. It seems that TMU1 is still enabled but with a different texture. And since it's not disabled, no weird frame rate drop down.