Ruby Opengl Speed

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 :slight_smile:

ยทยทยท

--
Posted via http://www.ruby-forum.com/.

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

ยทยทยท

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 :slight_smile:
--
Posted via http://www.ruby-forum.com/\.

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

ยทยทยท

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?

Yea, this is what i want to know, thanks Jan :slight_smile:
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-talk/2574414

ยทยทยท

--
Posted via http://www.ruby-forum.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
ActiveState Community - Boosting coder and team productivity with ready-to-use open source languages and tools.

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

http://ogrerb.rubyforge.org/

Regards,

Bill

ยทยทยท

From: "Diego Bernardes" <di3go.bernardes@gmail.com>

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

ยทยทยท

On Thursday 17 April 2008 02:08:16 Diego Bernardes wrote:

Yea, this is what i want to know, thanks Jan :slight_smile:
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"?

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

ยทยทยท

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-talk/2574414
>

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

http://ogrerb.rubyforge.org/

Regards,

Bill