Ruby Opengl Speed

D

Diego Bernardes

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 :)
 
J

Jason Roelofs

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

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
 
J

Jan Dvorak

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
 
D

Diego Bernardes

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

Bill Kelly

From: "Diego Bernardes said:
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
 
J

Jason Roelofs

studies, you said "offload anything on GPU", how can this offload can be
done?
display lists, so get almost the same speed of c, this is what you say about
"offload anything on GPU"?

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

http://ogrerb.rubyforge.org/


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
 
J

Jan Dvorak

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,291
Messages
2,571,455
Members
48,132
Latest member
KatlynC08

Latest Threads

Top