Page 1 of 2

ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 10:48
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.

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 11:00
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)
	

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 11:04
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.

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 16:29
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

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 18:42
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.

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 22:44
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.

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 23:10
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 :|

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 23:15
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

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 23:20
by aegis
how do you propose we draw lines?

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 23:24
by trepan
buy Nvidia...
Is there a specific ATI driver version that provoked this problem?

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 14 Feb 2010, 23:24
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.

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 15 Feb 2010, 00:04
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).

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 15 Feb 2010, 01:11
by Master-Athmos

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 15 Feb 2010, 09:33
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).

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 15 Feb 2010, 09:39
by aegis
if (ati) { return; }

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 15 Feb 2010, 13:05
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.

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 15 Feb 2010, 17:08
by imbaczek
btw reported this problem on that amd survey site.

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 15 Feb 2010, 17:08
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).

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 16 Feb 2010, 20:52
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?

Re: ATTN: do NOT use GL_LINES and immediate mode

Posted: 16 Feb 2010, 20:56
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?