[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby Opengl Speed

Diego Bernardes

4/16/2008 9:45:00 PM

Ruby has a Opengl binding, but well, its kind slow compared to c or
java, this is because of the language or the binding? If ruby get more
fast the overall performance gonna increase? or the bottleneck its the
binding?


Thanks :)
--
Posted via http://www.ruby-....

6 Answers

Jason Roelofs

4/16/2008 10:19:00 PM

0

On Wed, Apr 16, 2008 at 5:44 PM, Diego Bernardes
<di3go.bernardes@gmail.com> wrote:
> Ruby has a Opengl binding, but well, its kind slow compared to c or
> java, this is because of the language or the binding? If ruby get more
> fast the overall performance gonna increase? or the bottleneck its the
> binding?
>
>
> Thanks :)
> --
> Posted via http://www.ruby-....
>
>

The binding layer doesn't really add much to the execution time, the
majority of slowdown comes from the Ruby code itself outside of the
OpenGL calls.

Jason

Jan Dvorak

4/16/2008 10:29:00 PM

0

On Wednesday 16 April 2008 23:44:51 Diego Bernardes wrote:
> Ruby has a Opengl binding, but well, its kind slow compared to c or
> java, this is because of the language or the binding? If ruby get more
> fast the overall performance gonna increase? or the bottleneck its the
> binding?

In short: language and/or interpreter is the bottleneck.

The OpenGL API is mostly straightforward, and while ruby-opengl bindings do
additional state checks, most functions just boils down to:

1. convert data between ruby a C types (simple shift for Fixnum, pointer
access for Float)
2. call OpenGL function
3. convert return parameter the same way (most OpenGL function does not return
anything)

The overhead is fairly small, to the point that when in ruby-opengl 0.60 we
added glGetError() call (and raise on error) after each OpenGL function call,
there was no measurable slowdown.

With ruby 1.9 the bindings are about 2x-5x faster than with ruby1.8, and
basically the performance is the same as Perl's POGL bindings (as measured by
trislam benchmark), and few times faster than Python's. That is probably as
fast as it gets with interpreted languages.

Of course when you talk about fast/slow, you need to put that in context -
computing all data on CPU and calling glVertex* milion times will be always
*much* slower than in C (or Java), but does that mean anything ? If it's
possible to offload anything on GPU, do it. With today's videocards with
SM4.0 and all, it is possible to write applications where the CPU is not
bottleneck, and so they can be as fast as if written in C/Java.

Jan

Diego Bernardes

4/17/2008 12:08:00 AM

0

Yea, this is what i want to know, thanks Jan :)
I already made some 2d games in ruby using gosu and now im going to 3d
Just another question, i'm dont know opengl already, i'm just starting
my studies, you said "offload anything on GPU", how can this offload can
be done?

There is a Gears demo made in ruby with opengl comparing with c, it uses
display lists, so get almost the same speed of c, this is what you say
about "offload anything on GPU"?

link about the gears demo
http://aspn.activestate.com/ASPN/Mail/Message/ruby-ta...
--
Posted via http://www.ruby-....

Bill Kelly

4/17/2008 12:52:00 AM

0


From: "Diego Bernardes" <di3go.bernardes@gmail.com>
>
> I already made some 2d games in ruby using gosu and now im going to 3d
> Just another question, i'm dont know opengl already, i'm just starting
> my studies, you said "offload anything on GPU", how can this offload can
> be done?
>
> There is a Gears demo made in ruby with opengl comparing with c, it uses
> display lists, so get almost the same speed of c, this is what you say
> about "offload anything on GPU"?
>
> link about the gears demo
> http://aspn.activestate.com/ASPN/Mail/Message/ruby-ta...

You might be interested in the ruby bindings for the Ogre3D engine:

http://ogrerb.ruby...


Regards,

Bill



Jason Roelofs

4/17/2008 11:24:00 AM

0

On Wed, Apr 16, 2008 at 8:52 PM, Bill Kelly <billk@cts.com> wrote:
>
> From: "Diego Bernardes" <di3go.bernardes@gmail.com>
>
>
> >
> > I already made some 2d games in ruby using gosu and now im going to 3d
> > Just another question, i'm dont know opengl already, i'm just starting my
> studies, you said "offload anything on GPU", how can this offload can be
> done?
> >
> > There is a Gears demo made in ruby with opengl comparing with c, it uses
> display lists, so get almost the same speed of c, this is what you say about
> "offload anything on GPU"?
> >
> > link about the gears demo
> > http://aspn.activestate.com/ASPN/Mail/Message/ruby-ta...
> >
>
> You might be interested in the ruby bindings for the Ogre3D engine:
>
> http://ogrerb.ruby...
>
>
> Regards,
>
> Bill
>

Heh, yes, there is that, but I didn't mention it because it's woefully
incomplete (based on SWIG and I just ran into too many problems). I'm
working on a framework like python-ogre to replace SWIG (rbgccxml /
rb++) and will then use that for Ogre.rb and should have a much better
wrapper in usability and maintainability.

But for now, Ogre.rb will serve as a good starting point into using Ogre.

Jason

Jan Dvorak

4/18/2008 9:05:00 PM

0

On Thursday 17 April 2008 02:08:16 Diego Bernardes wrote:
> Yea, this is what i want to know, thanks Jan :)
> I already made some 2d games in ruby using gosu and now im going to 3d
> Just another question, i'm dont know opengl already, i'm just starting
> my studies, you said "offload anything on GPU", how can this offload can
> be done?
>
> There is a Gears demo made in ruby with opengl comparing with c, it uses
> display lists, so get almost the same speed of c, this is what you say
> about "offload anything on GPU"?

Yes, display lists and vertex arrays/VBO for static objects are good start,
but you can do any general per-vertex or per-pixel processing on GPU via
shaders. Common example in games is skeletal-bone animation done in vertex
shader (a.k.a. hardware skinning) where you send only mesh's base pose in
array/VBO and bone matrices as uniform variables or attributes and the shader
computes the desired pose.

Jan