Jump to content
  • Advertisement

Archived

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

Xanthen

Multitexturing HELP! Engine Performance Issue This is stupid

This topic is 5889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

take a look at the following screenshot. Everything is done the EXACT same in code. If you notice there is a 10 fps drop between screenshots and in one screen the ground is flat and the other the ground has a slight curve to it. From my timing I know that the lost framerate is coming from the actual rendering process. Everything else remains the same. The lighting, textures, and world transformations are precalculated and I know that none of that is causing the slow down. Edit: (This is not accurate, read below for more discriptions of the anomaly) Can anyone tell me why I am loosing 10 fps over something so trivial as changing the color of the vertices. I am doing my own lighting and passing the color values to the vertices via glColor3fv. Any help would be greatly appreciated. Edited by - Xanthen on February 18, 2002 11:54:59 AM

Share this post


Link to post
Share on other sites
Advertisement
I''m just hypothesizing here...

When you change the color, you''re changing your opengl state, which means that you have to pause the pipeline & upload the new color to the graphics card. Thus whenever you change the color you reduce performance slightly because you stall the pipeline on the graphics card.

Of course that''s just a guess.

Share this post


Link to post
Share on other sites
Are you also calling glColor3fv() with constant values in the faster case ? If not, well you have extra function calls...
Are you using the color to modulate the texture ?
Have you looked into vertex/color/normal arrays and glDrawElements() ?
Have you tried display lists ?

Exactly WHAT do you have in your render loop ?

Share this post


Link to post
Share on other sites
Hmmm, alright,
I am really confused about whats going on, I've been working on this for a hour. After writing my question I had a few more ideas to try and they just confused me more.

I changed the function in the precalculated lighting so that all vertices have the same lighting, however that did not change the 10 fps loss, so ... well I'm so lost I don't even know where to begin to look for an answer

Edit:
To answer your questions,
I am calling glColor3fv the exact same number of times and in the same manner in both scenarios.

Yes I am using the color to modulate the texture
I am currently using vertex arrays in both screenshots.
Nothing special was written in the second screenshot.

Edited by - Xanthen on February 17, 2002 12:14:15 AM

Share this post


Link to post
Share on other sites

Hmm... Without seeing any code, it''s really impossible to
tell what''s going on. Seeing screenshots is nice, but
useless.

Share this post


Link to post
Share on other sites
The problem is amplified when I change the field of view back to normal. The screen is then filled with the terrain and instead of 80 and 90, at 1024x768 is 30 and 40

I removed code that doesnt' run

        
glDisable(GL_BLEND);
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
float tslope;

glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_INTERPOLATE_EXT);

glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);

glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);

glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PRIMARY_COLOR_EXT);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);

glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_TEXTURE);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);

// TEXTURE-UNIT #1

TexH.SetTextureUnit(1);
glEnable(GL_TEXTURE_2D);

glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE_EXT);

glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);

glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);


glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,RendVert);
TexH.SetTextureUnit(1);
glDisable(GL_TEXTURE_2D);
glFlush();
stime(stimer6);
if (TrisExist1==1)
{
TexH.BindTex(0,16);

glBegin(GL_TRIANGLES);

for (x=0;x<VisX;x++)
for (y=0;y<VisY;y++)
if (VisWorldVisible[x+y*VisX]==1)
if (valt[x][y]==1)
{
tslope=0;
Vert=&RendVert2[x][y];
glTexCoord2f(Vert->s1,Vert->t1);
glColor3fv(&RendVert2[x][y].r);
glArrayElement(y*VisX+x);

glTexCoord2f(Vert->s2,Vert->t1);
glColor3fv(&RendVert2[x+1][y].r);
glArrayElement(y*VisX+x+1);

glTexCoord2f(Vert->s2,Vert->t2);
glColor3fv(&RendVert2[x+1][y+1].r);
glArrayElement((y+1)*VisX+x+1);

glTexCoord2f(Vert->s1,Vert->t1);
glColor3fv(&RendVert2[x][y].r);
glArrayElement(y*VisX+x);

glTexCoord2f(Vert->s2,Vert->t2);
glColor3fv(&RendVert2[x+1][y+1].r);
glArrayElement((y+1)*VisX+x+1);

glTexCoord2f(Vert->s1,Vert->t2);
glColor3fv(&RendVert2[x][y+1].r);
glArrayElement((y+1)*VisX+x);

WorldTriRen+=2;
}
glEnd();
}




Edit:

I have found a major cause but I don't know why this is a problem:

once this code runs once, this problem occurs. If this code never runs it will work fine and then the moment it runs, everything gets screwy again:
this code is located right after glVertexPointer
but doesn't run except in certain circumstances. It does not run when in the scenes that I took the screenshots but it was running in a different scene before that.

        
if (TrisExist2==1)
{
TexH.BindTex(0,0); //Changes to Tex Unit 0 and binds a texture

TexH.BindTex(1,16); //Changes to Tex Unit 1 and binds a texture


glBegin(GL_TRIANGLES);

for (x=0;x<VisX;x++)
for (y=0;y<VisY;y++)
if (VisWorldVisible[x+y*VisX]==1)
if (valt[x][y]==2)
{
tslope=0;
if ((Editor==1) && (DisplayVertices==0))
tslope=TileSlope(Pos.x+x-(VisX/2),Pos.y+y-VisY);
if (tslope<800)
{
Vert=&RendVert2[x][y];
tx=Vert->u1;
ty=Vert->v1;

glMultiTexCoord2fARB(GL_TEXTURE0_ARB,tx+s,ty+s);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,Vert->s1,Vert->t1);
glColor4fv(&RendVert2[x][y].r);
glArrayElement(y*VisX+x);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB,tx+ind-s,ty+s);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,Vert->s2,Vert->t1);
glColor4fv(&RendVert2[x+1][y].r);
glArrayElement(y*VisX+x+1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB,tx+ind-s,ty+ind-s);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,Vert->s2,Vert->t2);
glColor4fv(&RendVert2[x+1][y+1].r);
glArrayElement((y+1)*VisX+x+1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB,tx+s,ty+s);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,Vert->s1,Vert->t1);
glColor4fv(&RendVert2[x][y].r);
glArrayElement(y*VisX+x);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB,tx+ind-s,ty+ind-s);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,Vert->s2,Vert->t2);
glColor4fv(&RendVert2[x+1][y+1].r);
glArrayElement((y+1)*VisX+x+1);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB,tx+s,ty+ind-s);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,Vert->s1,Vert->t2);
glColor4fv(&RendVert2[x][y+1].r);
glArrayElement((y+1)*VisX+x);

WorldTriRen+=2;
}
}
glEnd();
}





Edited by - Xanthen on February 18, 2002 1:27:15 AM

Share this post


Link to post
Share on other sites
I''d tend to agree with sjelkjd. Most GL implementations don''t modify the GFX card state when you call glColor repeatedly with the same parameters.

From your code I can tell you are not using vertex/color/texture arrays properly: use glDrawElements instead of glDrawElement : build an array with all your triangles, associated color and texture coordinates, then do one (1) single call to glDrawElements.

The way you are doing it is even less efficient than calls to glVertex.

Share this post


Link to post
Share on other sites
your confusing glDrawElement with glArrayElement.

glDrawElements and glDrawElement is used when doing display lists. I however am doing indexed vertices.

Share this post


Link to post
Share on other sites
>>glDrawElements and glDrawElement is used when doing display list<<
aye?

if youre doing mipmapping (or even if u are not)
a drop could be cause the hill is using say 64x64sized textures (cause its closer) + the flat stuff is using 32x32

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
Oops, a braino, sorry. Yet I really meant glDrawElements (or glDrawArrays if you'd rather use that one).

glArrayElement is meant to be used with combined vertex/color/texture/normal arrays, saving separate function call overhead*. Since you're really only using the vertex arrays, you could as well call glVertex3fv();

* And that's not even guaranteed, cf Red Book p73.

Edited by - Fruny on February 18, 2002 1:45:54 AM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!