Subject: [Nel] GNU/Linux ... snowballs is running

From: Loic Dachary <[email-masked]>
Date: Wed, 13 Feb 2002 00:07:39 +0100

Hi,

	Thanks to GDB I was able to find a temporary solution. Now
snowballs is running at an incredible 0.5fps rate. It's probably the
first time I'm delighted to see such a slow opengl application ;-) Now
I'll have to buy some RAM (GDB eats ~300Mb) and a decent graphical
card with a Free Software driver.

	I used the following workaround:

Index: nel/src/3d/scene.cpp
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/scene.cpp,v
retrieving revision 1.62
diff -u -r1.62 scene.cpp
--- nel/src/3d/scene.cpp	6 Feb 2002 16:54:56 -0000	1.62
+++ nel/src/3d/scene.cpp	12 Feb 2002 22:53:55 -0000
@@ -463,7 +463,7 @@
 #endif
 
 	// Look if this instance get lightmap information
-	CMeshBase *pMB = dynamic_cast<CMeshBase*>( (IShape*)(pTShp->Shape) );
+	CMeshBase *pMB = (CMeshBase*)((IShape*)(pTShp->Shape));
 	CMeshBaseInstance *pMBI = dynamic_cast<CMeshBaseInstance*>( pTShp );
 	if( ( pMB != NULL ) && ( pMBI != NULL ) )
 	{ // Try to bind to automatic animation

	I managed to get snowballs to run on GNU/Linux. It turns out that
dynamic_cast<CMeshBase*>((IShape*)(pTShp->Shape)) returns a pointer that is
4 bytes below the expected pointer. Replacing the dynamic_cast with a C 
style cast fixes the issue.

	Unless I'm mistaken, there is no reason for dynamic_cast to
return a pointer that is different from a C style cast (except if the
cast is not legitimate). Hence I guess it's some sort of compiler
bug. I'll try to re-compile with gcc-3 (currently using gcc-2.95.4) +
isolate the problem. That one was pretty easy to spot because, we may
run into much more tricky problem if it is not investigated properly.

	Cheers,

-- 
Loic   Dachary         http://www.dachary.org/  [email-masked]
12 bd  Magenta         http://www.senga.org/      [email-masked]
75010    Paris         T: 33 1 42 45 07 97          [email-masked]
        GPG Public Key: http://www.dachary.org/loic/gpg.txt

---

From: "Vianney Lecroart" <[email-masked]>
Date: Wed, 13 Feb 2002 10:54:16 +0100

Hi Loic,

First of all, thank you for your help that is very useful for us.

The problem about dynamic_cast seems to be a gcc bug (???) because the cast
works fine on windows.
dynamic_cast *can* return a pointer that is different from C style cast in
the case a virtual multi inheritence.

For the frame rate, snowballs is slow perhaps because you don't have a good
video card (geforce or better) or because the driver is software.
Anyway, you have to know that there s visual bug that we never fix on linux.
For example, the NeL 3d logo that should be small in the top left of the
screen is very big in the center of the screen on linus (perhaps a Viewport
problem).

For gcc-3, we tried, quickly,  a compilation but there are some error about
throw() qualifier and cast problem. If you fix them, we ll be glad to add
them :)

Regards,

Vianney Lecroart
---
lead network programmer / nevrax.com
icq#: 6870415
homepage: http://ace.planet-d.net
www.geekcode.com: GCS/E d- s+++: a-- C+++$ UL++ P- L+++>+$ E+>- W++ N+ o? K-
w++$ O- M- V- PS- PE? Y PGP t 5? X+ R- tv++ b- DI D+ G e++ h+ r-- y?

---

From: Loic Dachary <[email-masked]>
Date: Wed, 13 Feb 2002 15:52:48 +0100

> First of all, thank you for your help that is very useful for us.

	Your code is also very helpful to me ;-)

 > The problem about dynamic_cast seems to be a gcc bug (???) because the cast

	I think this definitely is a gcc bug. I acknowledged this
by doing the following:

+++ nel/src/3d/scene.cpp	13 Feb 2002 14:39:00 -0000
@@ -463,7 +463,11 @@
 #endif
 
 	// Look if this instance get lightmap information
-	CMeshBase *pMB = dynamic_cast<CMeshBase*>( (IShape*)(pTShp->Shape) );
+#if defined(__GNUC__) && __GNUC__ < 3
+	CMeshBase *pMB = (CMeshBase*)((IShape*)(pTShp->Shape));
+#else // not GNUC
+	CMeshBase *pMB = dynamic_cast<CMeshBase*>((IShape*)(pTShp->Shape));
+#endif // not GNUC
 	CMeshBaseInstance *pMBI = dynamic_cast<CMeshBaseInstance*>( pTShp );
 	if( ( pMB != NULL ) && ( pMBI != NULL ) )
 	{ // Try to bind to automatic animation

	I intentionaly made this hack specific to gcc-2 so that it 
blows again on gcc-3 when we eventually switch to it and if the bug
is still there. For now I guess we'll have to live with it.  

 > the case a virtual multi inheritence.

	Yes, forgot this one. But in this very specific case, there is no
reason for it to return a different pointer. 

 > video card (geforce or better) or because the driver is software.

	Oh, you mean my Matrox G200 is not as powerfull as a geforce
?-) I'm kidding. The issue here is to find a card that runs on
GNU/Linux and has a Free Software driver. All nVidia based products
are discarded right away, thanks to their !@#$!#@$ non free software
policy. The worst of all is that they provide a gratis driver that
runs on GNU/Linux, therefore nobody is apparently motivated to write a
Free Software alternative.

	I figured that an ATI RADEON 7500 / 64 Mo is probably the best
I can get. I'll have to recompile XFree-4.2.0 to take advantage of the
accelerated drivers, though. But not too far in the future it will pop
automagically on my Debian unstable, therefore it's acceptable. From the
benchmarks I saw, it more or less compares to a geforce 2 but is vastly
outperformed by geforce 3. Any input/experience on this subject would be
welcome.

	Who is pressuring nVidia to release their drivers under a Free
Software license ? I'd gladly add my 0.2 euro advocacy bit ;-)

 > screen is very big in the center of the screen on linus (perhaps a Viewport

	Good to know. I was wondering why this huge logo would not go away
after a while. I'll first try to improve the frame rate as much as I can.

 > throw() qualifier and cast problem. If you fix them, we ll be glad to add

	I fixed the minor errors missing throw() in destructors but
finaly ran into a more embarassing problem (gcc aborting on
error). I'm probably playing with fire (using gcc-3.0.4
snapshot). Anyways, I guess it's too early for this and won't
insist. Here are the fixes. One of them is important since there is a
scope mismatch (uint i below).

Index: nel/include/nel/misc/common.h
===================================================================
RCS file: /home/cvsroot/code/nel/include/nel/misc/common.h,v
retrieving revision 1.33
diff -u -r1.33 common.h
--- nel/include/nel/misc/common.h	25 Oct 2001 14:58:23 -0000	1.33
+++ nel/include/nel/misc/common.h	13 Feb 2002 14:38:49 -0000
@@ -239,6 +239,7 @@
 	Exception();
 	Exception(const std::string &reason);
 	Exception(const char *format, ...);
+	virtual ~Exception() throw() {};
 	virtual const char	*what() const throw();
 };
 
Index: nel/include/nel/misc/stream.h
===================================================================
RCS file: /home/cvsroot/code/nel/include/nel/misc/stream.h,v
retrieving revision 1.50
diff -u -r1.50 stream.h
--- nel/include/nel/misc/stream.h	27 Nov 2001 15:59:55 -0000	1.50
+++ nel/include/nel/misc/stream.h	13 Feb 2002 14:38:49 -0000
@@ -77,6 +77,8 @@
 
 	EStream( const IStream &f, const std::string& str );
 
+	virtual ~EStream() throw() {}
+
 	// May Not be Filled...
 	std::string	StreamName;
 };
Index: nel/include/nel/net/buf_net_base.h
===================================================================
RCS file: /home/cvsroot/code/nel/include/nel/net/buf_net_base.h,v
retrieving revision 1.5
diff -u -r1.5 buf_net_base.h
--- nel/include/nel/net/buf_net_base.h	21 Jun 2001 12:35:16 -0000	1.5
+++ nel/include/nel/net/buf_net_base.h	13 Feb 2002 14:38:49 -0000
@@ -135,7 +135,7 @@
 
 protected:
 
-	friend CBufSock;
+	friend class NLNET::CBufSock;
 	
 	/// Constructor
 	CBufNetBase();
Index: nel/src/3d/cube_grid.h
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/cube_grid.h,v
retrieving revision 1.1
diff -u -r1.1 cube_grid.h
--- nel/src/3d/cube_grid.h	6 Feb 2002 16:54:56 -0000	1.1
+++ nel/src/3d/cube_grid.h	13 Feb 2002 14:38:54 -0000
@@ -244,8 +244,8 @@
 
 	// Clear the Selection
 	_Selection= NULL;
-	_CurSel= NULL;
-	_NumSels= NULL;
+	_CurSel= 0;
+	_NumSels= 0;
 }
 
 // ***************************************************************************
Index: nel/src/3d/cube_map_builder.h
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/cube_map_builder.h,v
retrieving revision 1.1
diff -u -r1.1 cube_map_builder.h
--- nel/src/3d/cube_map_builder.h	4 Feb 2002 10:42:31 -0000	1.1
+++ nel/src/3d/cube_map_builder.h	13 Feb 2002 14:38:54 -0000
@@ -57,4 +57,4 @@
 }

-#endif
\ No newline at end of file
+#endif
Index: nel/src/3d/landscape.h
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/landscape.h,v
retrieving revision 1.31
diff -u -r1.31 landscape.h
--- nel/src/3d/landscape.h	6 Feb 2002 16:54:56 -0000	1.31
+++ nel/src/3d/landscape.h	13 Feb 2002 14:38:54 -0000
@@ -104,6 +104,7 @@
 
 public:
 	EBadBind() {}
+	~EBadBind() throw () {}
 	virtual const char	*what() const throw();
 
 };
Index: nel/src/3d/point_light_named_array.cpp
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/point_light_named_array.cpp,v
retrieving revision 1.1
diff -u -r1.1 point_light_named_array.cpp
--- nel/src/3d/point_light_named_array.cpp	6 Feb 2002 16:54:56 -0000	1.1
+++ nel/src/3d/point_light_named_array.cpp	13 Feb 2002 14:38:58 -0000
@@ -96,7 +96,8 @@
 		bool	first= true;
 		string	precName;
 		// for all sorted pointLights
-		for(uint i=0;i<_PointLights.size();i++)
+		uint i;
+		for(i=0;i<_PointLights.size();i++)
 		{
 			const	std::string &curName= _PointLights[i].LightGroupName;
 			if(first || precName!=curName )
Index: nel/src/3d/ps_misc.h
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/ps_misc.h,v
retrieving revision 1.1
diff -u -r1.1 ps_misc.h
--- nel/src/3d/ps_misc.h	2 Oct 2001 16:35:39 -0000	1.1
+++ nel/src/3d/ps_misc.h	13 Feb 2002 14:38:58 -0000
@@ -82,4 +82,4 @@
 
 } // NL3D
 
-#endif
\ No newline at end of file
+#endif

	Cheers,

---

From: Thomas RIBO <[email-masked]>
Date: Wed, 13 Feb 2002 18:58:09 +0100

Le Mercredi 13 Février 2002 15:52, Loic Dachary a écrit :
> runs on GNU/Linux, therefore nobody is apparently motivated to write
> a Free Software alternative.

Yes, but it is the only way for the moment to have a good video card 
and good drivers running on Linux. I would prefer free drivers too, but 
I use the non-free ones and am not too embarrassed with that...

> I can get. I'll have to recompile XFree-4.2.0 to take advantage of
> the accelerated drivers, though. But not too far in the future it
> will pop automagically on my Debian unstable, therefore it's
> acceptable. From the benchmarks I saw, it more or less compares to a
> geforce 2 but is vastly outperformed by geforce 3. Any
> input/experience on this subject would be welcome.

To compare with a GeForce 3, you'll need a Radeon 8500. But I have no 
idea of the support on Linux (I'm talking about free drivers). BTW, 
it's a chance that ATI does not provide drivers on Linux: when we see 
the quality of the Windows ones, we can only be happy about that ;-)!

> Software license ? I'd gladly add my 0.2 euro advocacy bit ;-)

It seemed to me that a petition was somewhere on Internet, but I can't 
find it... There are some discutions about that on Debian lists 
archives, but that's all... :-(

-- 
[email-masked]
"Le temps ne fait rien à l'affaire, quand on est con, on-est-con !"
-- Georges Brassens

---

From: Loic Dachary <[email-masked]>
Date: Thu, 14 Feb 2002 11:51:53 +0100

> the quality of the Windows ones, we can only be happy about that ;-)!

	:-) No 3D support for the Radeon 8500 at present, unfortunately.

 > archives, but that's all... :-(

	Which very well shows the bad consequences of providing proprietary
solutions on GNU/Linux. I found http://nvidia.netexplorer.org/petition.html
which is not the right way to go, IMHO.

	Cheers,

---

From: Vincent Caron <[email-masked]>
Date: 14 Feb 2002 17:13:56 +0100

> Software license ? I'd gladly add my 0.2 euro advocacy bit ;-)

Not quite, but I'm tring to encourage them on this path ... Since nVidia
has based its market on consumer-grade 3D hardware, the Windows+DirectX
patform provides close to 95% of their income. The 'professional' users
are not willing to purchase a new video card every month like gamers ;),
so the Quadro serie seems only a way to tickle 3DLabs. It is a common
belief that the key element which lead nVidia to bring OpenGL support is
more ID's John Carmack than industry needs such as CAD tools. I think it
also reasonable to think that they don't want to be MS-dependent, and
their comitment with both OpenGL and Linux is the best and cheapest way
to keep the evil at a safe distance :). Maybe they also think that
tackling their chipsets with two approaches and two APIs might bring a
better driver/hardware development expertise (let's be idealistic, but
it could prove true since everybody agrees that OpenGL shaders are
better designed than DX8's ... ghossip, etc :)).

I'm currently thanking them for their Linux support. Their driver
developers are rather easy to reach, bug reports are quickly answered,
and they honestly try to keep up with Windows drivers performance and
quality. They also take into account the fact that Linux users tend to
have a more technical background : their Linux FAQ is the kind of
thorough and efficient documentation you'll never find under Windows
(giving away all the hacks to tweak the driver :
http://205.158.109.140/XFree86_40/1.0-2313/README.txt)

They currently focus on driver setup support, their main goal being
letting any user play Quake3 with the best experience under Linux.
I think that the next task is to bring some animation around OpenGL
development under Linux. They have an important code base to show off
all their OpenGL driver abilities, but it's a heavily win32 oriented
code (you'll find spare Makefiles...). They recently setup a CVS as a
distribution alternative (Unix users don't really like tarballs !). I'm
maybe optimistic, but I like this kind of initiative :). The definitive
step further would be to port their 'Effect browser' (the core of their
OpenGL code base) to Linux, and I'm seriously thinking about doing it.
The goal is twofold : 1) showing them people want to develop with their
hardware under Linux & FreeBSD, 2) make their 'nvsdk' available to the
Unix community.

Before thinking about coding, they are some licensing issues that need
to be addressed. Of course, from an advocate point of view, this nvsdk
should be GPL. But I guess developers are encouraged to steal bits from
it, so a MIT/Xfree license might be more accurate. This is where a OSS
adocate expertise could be useful ...

I'm keeping some URLs up to date there :
http://linux-nvidia.sourceforge.net/