VDU performance

Development directions, tasks, and features being actively implemented or pursued by the development team.
Post Reply
breese
Bounty Hunter
Bounty Hunter
Posts: 152
Joined: Thu Sep 02, 2010 8:00 pm

VDU performance

Post by breese »

I did a bit of profiling today and found that VDU::DrawMessages is quite expensive. Investigating this further I found the following piece of code:

Code: Select all

void DrawSquare( float left, float right, float top, float bot )
{
    GFXBegin( GFXQUAD );
    GFXVertex3f( left, top, 0 );
    GFXVertex3f( left, bot, 0 );
    GFXVertex3f( right, bot, 0 );
    GFXVertex3f( right, top, 0 );
    GFXVertex3f( right, top, 0 );
    GFXVertex3f( right, bot, 0 );
    GFXVertex3f( left, bot, 0 );
    GFXVertex3f( left, top, 0 );
    GFXEnd();
}
Does anybody know why it draws the square twice?

I tried to remove the last four vertices, and I can see no difference (except that it makes the function use 10% less CPU.)
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: VDU performance

Post by klauss »

That makes two quads, one facing forward and one facing backwards.

But you could replace it by one quad with face culling disabled, however, it wouldn't be a big improvement.

The big improvement would be grouping the uses of that function so that only one begin/end pair is used to draw lots of quads, since the most expensive calls there are the begin/end calls.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
breese
Bounty Hunter
Bounty Hunter
Posts: 152
Joined: Thu Sep 02, 2010 8:00 pm

Re: VDU performance

Post by breese »

klauss wrote:That makes two quads, one facing forward and one facing backwards.
Why would a TextPlane need both? This is what I do not understand.
klauss wrote:But you could replace it by one quad with face culling disabled, however, it wouldn't be a big improvement.
Face culling is already disabled before DrawSquare is called.
Post Reply