ATTN: do NOT use GL_LINES and immediate mode

ATTN: do NOT use GL_LINES and immediate mode

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

ATTN: do NOT use GL_LINES and immediate mode

Post by imbaczek »

DO NOT USE GL_LINES AND IMMEDIATE MODE (glBegin/glEnd). i found it to be the cause of ATI driver memory leak, which is (most likely) responsible for crashes without stacktrace that have been recently happening.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by Beherith »

Know of any common widgets/gadgets that combine the two?

Edit: Ouch, even stuff like customformations seems to have this.

Code: Select all

	glBeginEnd(GL_LINE_STRIP, DrawFormationLine, fNodes)
	
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by imbaczek »

Beherith wrote:Know of any common widgets/gadgets that combine the two?

Edit: Ouch, even stuff like customformations seems to have this.

Code: Select all

	glBeginEnd(GL_LINE_STRIP, DrawFormationLine, fNodes)
	
yeah, that was one of the things that led me to this conclusion, unfortunately.
SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by SirMaverick »

Many widgets use that combination, I count at least 4 for BA (CA has same + more):
Loop Select
CustomFormations2
Defense Range
Attack AoE
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by TheFatController »

If anyone wants to step up and fix these widgets for BA and let me know that'd be great otherwise recommendations for the best replacement functions would be appreciated as my GL experience isn't huge.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by imbaczek »

my experimental results indicate that after removing the biggest offenders from the engine, it's relatively safe to use GL_LINES and friends - but the next version will print a warning every 120 frames if you use them.
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by Jazcash »

SirMaverick wrote:Many widgets use that combination, I count at least 4 for BA (CA has same + more):
Loop Select
CustomFormations2
Defense Range
Attack AoE
Great, I use all those widgets :|
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by imbaczek »

as a temporary workaround, you can greatly reduce the leak by disabling unconditional drawing of command queues. edit cmdcolors.txt and replace

Code: Select all

alwaysDrawQueue   1
with

Code: Select all

alwaysDrawQueue   0
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by aegis »

how do you propose we draw lines?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by trepan »

buy Nvidia...
Is there a specific ATI driver version that provoked this problem?
Last edited by trepan on 14 Feb 2010, 23:24, edited 1 time in total.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by imbaczek »

haven't tested it, but a display list may be free of this problem.

trepan: according to testing done here http://springrts.com/mantis/view.php?id=1573, it's catalyst 9.8.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by jK »

There is no replacement for immediate mode in lua, so please just print the warning for ATi users.

PS: And perhaps start a petition, so ATI fixes their drivers. As long as you proved that it is really caused by this (with a small demo app).
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by imbaczek »

jK wrote:There is no replacement for immediate mode in lua, so please just print the warning for ATi users.

PS: And perhaps start a petition, so ATI fixes their drivers. As long as you proved that it is really caused by this (with a small demo app).
This issue seems much more complex, because the leak is triggered by something I haven't determined. E.g. after removing line stipple, the leak was happening only when zoomed out enough to see unit icons instead of proper models.

Printing a warning only for ati users is pointless since it's not a warning for the user, it's for the developer. We can remove it altogether and hope the leak won't come back (my limited testing showed that memory consumption is rather stable after changing line drawer).
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by aegis »

if (ati) { return; }
Umbra
Posts: 46
Joined: 29 Jul 2009, 14:23

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by Umbra »

This is why I'm not a fan of ATI. They have too many issues with their drivers that lead to incompatibilities and performance issues with my favorite games.

Not that nvidia doesn't have their fair share of problems either, it's just that nvidia's are better supported.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by imbaczek »

btw reported this problem on that amd survey site.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by jK »

imbaczek wrote:
jK wrote:There is no replacement for immediate mode in lua, so please just print the warning for ATi users.
Printing a warning only for ati users is pointless since it's not a warning for the user, it's for the developer. We can remove it altogether and hope the leak won't come back (my limited testing showed that memory consumption is rather stable after changing line drawer).
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by Argh »

Er, great... so ATi's drivers are broken for Point Objects and Lines? That's totally ludicrous.

So, what about all of the other code that uses GL.LINES in Spring, i.e., commands and weapon ranges?

What about gl.GroundCircle?
Last edited by Argh on 16 Feb 2010, 21:00, edited 1 time in total.
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: ATTN: do NOT use GL_LINES and immediate mode

Post by Pxtl »

So how do retail developers work around this bug? Simply not including drawn lines in their games, instead drawing them as a system of polygons?
Post Reply

Return to “Lua Scripts”