vbo - DrawArrays - threading question

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

vbo - DrawArrays - threading question

rtayek
hi, i have some code that creates and fills a vertex buffer and draws it using draw arrays (like http://wadeawalker.wordpress.com/2010/12/06/tutorial-displaying-java-opengl-in-an-eclipse-editor-with-a-menu-bar-and-a-runpause-button/). it works fine (please see part of the code below).

my vertices are fixed. the color for each vertex changes over time. i would like to do the following:

                gl2.glBindBuffer(GL.GL_ARRAY_BUFFER,vertexBufferIndices[index]);
                ByteBuffer bytebuffer=gl2.glMapBuffer(GL.GL_ARRAY_BUFFER,GL2.GL_WRITE_ONLY);
                FloatBuffer floatbuffer=bytebuffer.order(ByteOrder.nativeOrder()).asFloatBuffer();
                storeVerticesAndColors(floatbuffer,w); // w has the vertex and color data
                gl2.glUnmapBuffer(GL.GL_ARRAY_BUFFER);

in *another* thread as i get new data.

will this cause blocking problems?

i found a lot of posts on multi-threading vbos, but they are dated. what is the current status of this?

i should probably separate the color and the vertices since the vertices are static, but i don't know how to do that yet.

thanks


        protected int createAndFillVertexBuffer(GL2 gl2,W2 w,int index) {
                int[] n=new int[]{w.points.length};
                System.out.println(n[0]);
                if(vertexBufferIndices[index]==-1)
                        createVbo(gl2,n,index);
                // map the buffer and write vertex and color data directly into it
                gl2.glBindBuffer(GL.GL_ARRAY_BUFFER,vertexBufferIndices[index]);
                ByteBuffer bytebuffer=gl2.glMapBuffer(GL.GL_ARRAY_BUFFER,GL2.GL_WRITE_ONLY);
                FloatBuffer floatbuffer=bytebuffer.order(ByteOrder.nativeOrder()).asFloatBuffer();
                storeVerticesAndColors(floatbuffer,w);
                gl2.glUnmapBuffer(GL.GL_ARRAY_BUFFER);
                return n[0];
        }
        private void renderPiece(GLAutoDrawable drawable,int index) {
                final GL2 gl2=drawable.getGL().getGL2();
                gl2.glColorMaterial(GL.GL_FRONT_AND_BACK,GLLightingFunc.GL_AMBIENT_AND_DIFFUSE);
                gl2.glEnable(GLLightingFunc.GL_COLOR_MATERIAL);
                // draw all objects in vertex buffer
                gl2.glBindBuffer(GL.GL_ARRAY_BUFFER,vertexBufferIndices[index]);
                gl2.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
                gl2.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
                gl2.glVertexPointer(3,GL.GL_FLOAT,6*Buffers.SIZEOF_FLOAT,0);
                gl2.glColorPointer(3,GL.GL_FLOAT,6*Buffers.SIZEOF_FLOAT,3*Buffers.SIZEOF_FLOAT);
                gl2.glPolygonMode(GL.GL_FRONT,GL2GL3.GL_FILL);
                gl2.glDrawArrays(GL.GL_POINTS,0,1*numOfVertices[index]);
                // disable arrays once we're done
                gl2.glBindBuffer(GL.GL_ARRAY_BUFFER,0);
                gl2.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
                gl2.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY);
                gl2.glDisable(GLLightingFunc.GL_COLOR_MATERIAL);
        }
        private void render(GLAutoDrawable drawable) {
                final GL2 gl2=drawable.getGL().getGL2();
                gl2.glScaled(.2,.2,1);
                for(int i=0;i<nVbos;i++)
                        renderPiece(drawable,i);
        }



Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

gouessej
Administrator
Hi

You can do several VBOs, one for vertices, one for colors, etc... I used glMapBuffer in 2010, keep in mind it might fail and it has an impact on performance. It is nice for streaming and displaying very large meshes in my case. Please can you elaborate? Why do you want to use that?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

rtayek
At 01:13 AM 9/6/2012, you wrote:
>Hi You can do several VBOs, one for vertices, one for colors, etc...

can you give me a link that has an example?

>I used glMapBuffer in 2010, keep in mind it might fail and it has an
>impact on performance.

i'm not sure what glMapBuffer() does. i was just using wades example.
i think i could make the vertex buffers and copy them once and not
use glMapBuffer().

>It is nice for streaming and displaying very large meshes in my
>case. Please can you elaborate? Why do you want to use that?
>Julien Gouesse http://tuer.sourceforge.nethttp://gouessej.wordpress.com

my app is for a radar. the data comes in in a wedge shaped area that
sweeps around the screen. the vertices are constant (1024x1024)
unless we are panning or zooming. the colors change. the sweep period
is 2 seconds. the user wants a smooth display.

i have tried the 1024x1024 using image and texture
(http://forum.jogamp.org/vbo-draw-elements-vs-image-draw-pixels-strange-difference-td4026002.html)
and they all seem slow doing all of the pixels at once, so i thought
i would try breaking it up into pieces (the data comes to me in 400
pieces anyway).

thanks



---
co-chair http://ocjug.org/

Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

gouessej
Administrator
Look at how we support VBOs in Ardor3D, it's open source. But you can put everything into the same VBO if it is easier for you.

glMapBuffer maps the data store located in the GPU in your physical memory. If you don't want to modify the content of a VBO very often and to use less physical memory, you can directly create a VBO without using a NIO buffer whose memory is allocated in the native heap. However, this operation may fail.

Using VBO with vertices and colors should be faster than creating and updating a texture, I already had to do that at work in 2010 for a 2D hardware accelerated map. It was really very smooth even when zooming :) Even a trivial implementation should be enough in your case, the vertices for the quads or triangles representing your grid (1024*1024) and their colors.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

rtayek
At 02:44 PM 9/6/2012, you wrote:
>Look at how we support VBOs in Ardor3D, it's open source.

i'll take a look at it.

>But you can put everything into the same VBO if it is easier for you.

i have it that way now. but since the vertices are constant, i will
split it up later.

>  glMapBuffer maps the data store located in the GPU in your
> physical memory. If you don't want to modify the content of a VBO
> very often and to use less physical memory, you can directly create
> a VBO without using a NIO buffer whose memory is allocated in the native heap.

so using glMapBuffer is directly creating a VBO?

>  However, this operation may fail.

eek. maybe i will avoid it after all.


>Using VBO with vertices and colors should be faster than creating
>and updating a texture,

i did some timing, but the results are confusing:
http://forum.jogamp.org/over-80-of-time-is-in-AWTAnimatorImpl-display-amp-GLDrawableHelper-displayImpl-td4026033.html

>I already had to do that at work in 2010 for a 2D hardware
>accelerated map. It was really very smooth even when zooming :) Even
>a trivial implementation should be enough in your case, the vertices
>for the quads or triangles representing your grid (1024*1024) and
>their colors.
>Julien Gouesse http://tuer.sourceforge.nethttp://gouessej.wordpress.com

yes, i am getting sub millisecond times for the cpu when i render.

thanks



---
co-chair http://ocjug.org/

Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

gouessej
Administrator
glMapBuffer does not create the VBO but it allows you to map its data store (in the GPU) into the physical memory so that you can manipulate it. When you unmap it, the changes are reflected into the data store in the GPU. If glMapBuffer didn't exist, it would be impossible to modify a data store whose content is stored on the GPU from the CPU.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

rtayek
hi, trying to update some vbos in another thread. my code (please see below) hangs, when the timer thread tries to do a: FloatBuffer floatbuffer=bytebuffer.order(ByteOrder.nativeOrder()).asFloatBuffer(); after the buffer was mapped.

any pointers will be appreciated.

thanks

package stanalone;
import static java.awt.Color.cyan;
import static java.awt.Color.magenta;
import static java.awt.Color.white;
import static java.awt.Color.yellow;
import static java.lang.Math.PI;
import static java.lang.Math.cos;
import static java.lang.Math.min;
import static java.lang.Math.signum;
import static java.lang.Math.sin;
import static javax.media.opengl.GL.GL_ARRAY_BUFFER;
import static javax.media.opengl.GL.GL_COLOR_BUFFER_BIT;
import static javax.media.opengl.GL.GL_DEPTH_BUFFER_BIT;
import static javax.media.opengl.GL.GL_DEPTH_TEST;
import static javax.media.opengl.GL.GL_FLOAT;
import static javax.media.opengl.GL.GL_FRONT;
import static javax.media.opengl.GL.GL_FRONT_AND_BACK;
import static javax.media.opengl.GL.GL_LEQUAL;
import static javax.media.opengl.GL.GL_MAX_TEXTURE_SIZE;
import static javax.media.opengl.GL.GL_NICEST;
import static javax.media.opengl.GL.GL_POINTS;
import static javax.media.opengl.GL.GL_WRITE_ONLY;
import static javax.media.opengl.GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT;
import static javax.media.opengl.GL2GL3.GL_FILL;
import static javax.media.opengl.fixedfunc.GLLightingFunc.GL_SMOOTH;
import static javax.media.opengl.fixedfunc.GLMatrixFunc.GL_MODELVIEW;
import static javax.media.opengl.fixedfunc.GLMatrixFunc.GL_PROJECTION;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Point2D;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLJPanel;
import javax.media.opengl.fixedfunc.GLLightingFunc;
import javax.media.opengl.fixedfunc.GLPointerFunc;
import javax.media.opengl.glu.GLU;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.util.FPSAnimator;
import com.jogamp.opengl.util.gl2.GLUT;
class MyDataObject {
        MyDataObject(Point2D[] points) {
                this(points,white);
        }
        MyDataObject(Point2D[] points,Color color) {
                this.points=points;
                this.color=color;
        }
        Point2D[] points;
        Color color;
        static Point2D[] randomPoints(Random random,Point2D offset) {
                List<Point2D> l=new LinkedList<Point2D>();
                int n=1000000/pieces.length;
                for(int j=0;j<n;j++)
                        l.add(new Point2D.Double(offset.getX()+random.nextFloat(),offset.getY()+random.nextFloat()));
                return l.toArray(new Point2D[0]);
        }
        static MyDataObject[] pieces;
        static Color[] colors=new Color[]{cyan,magenta,yellow,white};
}
class StandAlone implements GLEventListener {
        StandAlone(GLAutoDrawable drawable) {
                this.drawable=drawable;
                drawable.addGLEventListener(this);
                init();
        }
        void init() {
                nVbos=4;
                vertexBufferIndices=new int[nVbos];
                for(int i=0;i<vertexBufferIndices.length;i++)
                        vertexBufferIndices[i]=-1;
                numberOFVertices=new int[nVbos];
                // drawAxes=true;
                MyDataObject.pieces=new MyDataObject[nVbos];
                for(int i=0;i<nVbos;i++) {
                        Point2D offset=new Point.Double(min(0,signum(cos(PI/4+i*PI/2))),min(0,signum(sin(PI/4+i*PI/2))));
                        MyDataObject.pieces[i]=new MyDataObject(MyDataObject.randomPoints(random,offset),MyDataObject.colors[i%MyDataObject.colors.length]);
                        System.out.println("offset="+offset);
                }
        }
        static void setupFrame(Component component) {
                setupFrame(component,defaultFps);
        }
        static void setupFrame(Component component,int fps) {
                component.setPreferredSize(new Dimension(displayWidth,displayHeight));
                final FPSAnimator animator=new FPSAnimator((GLAutoDrawable)component,fps,true);
                final JFrame frame=new JFrame();
                frame.getContentPane().add(component);
                frame.addWindowListener(new WindowAdapter() {
                        @Override public void windowClosing(WindowEvent e) {
                                new Thread() {
                                        @Override public void run() {
                                                if(animator.isStarted())
                                                        animator.stop();
                                                System.exit(0);
                                        }
                                }.start();
                        }
                });
                frame.setTitle(TITLE);
                frame.pack();
                frame.setVisible(true);
                animator.start();
        }
        static void setup() {
                GLProfile glprofile=GLProfile.getDefault();
                GLCapabilities glcapabilities=new GLCapabilities(glprofile);
                GLJPanel panel=new GLJPanel(glcapabilities);
                new StandAlone(panel);
                setupFrame(panel,200);
        }
        public static void main(String[] args) {
                SwingUtilities.invokeLater(new Runnable() {
                        @Override public void run() {
                                setup();
                        }
                });
        }
        private void createVbo(GL2 gl2,int[] n,int index) {
                if(!gl2.isFunctionAvailable("glGenBuffers")||!gl2.isFunctionAvailable("glBindBuffer")||!gl2.isFunctionAvailable("glBufferData")||!gl2.isFunctionAvailable("glDeleteBuffers")) { throw new RuntimeException("Vertex buffer objects not supported."); }
                gl2.glGenBuffers(1,vertexBufferIndices,index);
                System.out.println("created "+vertexBufferIndices[index]);
                // create vertex buffer data store without initial copy
                gl2.glBindBuffer(GL_ARRAY_BUFFER,vertexBufferIndices[index]);
                gl2.glBufferData(GL_ARRAY_BUFFER,n[0]*3*Buffers.SIZEOF_FLOAT*2,null,GL.GL_DYNAMIC_DRAW);
        }
        private static void storeVerticesAndColors(FloatBuffer floatbuffer,MyDataObject w) {
                for(Point2D p:w.points) {
                        floatbuffer.put((float)p.getX()).put((float)p.getY()).put(0);
                        floatbuffer.put((float)(w.color.getRed()/255.));
                        floatbuffer.put((float)(w.color.getGreen()/255.));
                        floatbuffer.put((float)(w.color.getBlue()/255.));
                }
                floatbuffer.rewind();
        }
        private void fillVertexBuffer(GL2 gl2,MyDataObject piece,int index) {
                // map the buffer and write vertex and color data directly into it
                gl2.glBindBuffer(GL_ARRAY_BUFFER,vertexBufferIndices[index]);
                ByteBuffer bytebuffer=gl2.glMapBuffer(GL_ARRAY_BUFFER,GL_WRITE_ONLY);
                System.out.println("buffer was mapped");
                FloatBuffer floatbuffer=bytebuffer.order(ByteOrder.nativeOrder()).asFloatBuffer(); // hangs here!
                System.out.println("store");
                storeVerticesAndColors(floatbuffer,piece);
                gl2.glUnmapBuffer(GL_ARRAY_BUFFER);
        }
        protected int createAndFillVertexBuffer(GL2 gl2,MyDataObject piece,int index) {
                int[] n=new int[]{piece.points.length};
                if(vertexBufferIndices[index]==-1)
                        createVbo(gl2,n,index);
                fillVertexBuffer(gl2,piece,index);
                return n[0];
        }
        private void renderPiece(GLAutoDrawable drawable,int index) {
                final GL2 gl2=drawable.getGL().getGL2();
                gl2.glColorMaterial(GL_FRONT_AND_BACK,GLLightingFunc.GL_AMBIENT_AND_DIFFUSE);
                gl2.glEnable(GLLightingFunc.GL_COLOR_MATERIAL);
                // draw all objects in vertex buffer
                gl2.glBindBuffer(GL_ARRAY_BUFFER,vertexBufferIndices[index]);
                gl2.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
                gl2.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
                gl2.glVertexPointer(3,GL_FLOAT,6*Buffers.SIZEOF_FLOAT,0);
                gl2.glColorPointer(3,GL_FLOAT,6*Buffers.SIZEOF_FLOAT,3*Buffers.SIZEOF_FLOAT);
                gl2.glPolygonMode(GL_FRONT,GL_FILL);
                gl2.glDrawArrays(GL_POINTS,0,1*numberOFVertices[index]);
                // disable arrays once we're done
                gl2.glBindBuffer(GL_ARRAY_BUFFER,0);
                gl2.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
                gl2.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY);
                gl2.glDisable(GLLightingFunc.GL_COLOR_MATERIAL);
        }
        void update() {
                angle+=1;
        }
        @Override public void reshape(GLAutoDrawable drawable,int x,int y,int width,int height) {
                System.out.println("super.reshape "+drawable);
                GL2 gl=drawable.getGL().getGL2();
                if(height==0)
                        height=1;
                float aspect=(float)width/height;
                gl.glViewport(0,0,width,height);
                gl.glMatrixMode(GL_PROJECTION);
                gl.glLoadIdentity();
                // glu.gluPerspective(45.0,aspect,0.1,100.0);
                gl.glMatrixMode(GL_MODELVIEW);
                gl.glLoadIdentity();
        }
        @Override public void init(final GLAutoDrawable drawable) {
                GL2 gl=drawable.getGL().getGL2();
                glu=new GLU();
                glut=new GLUT();
                gl.glClearColor(0.0f,0.0f,0.0f,0.0f);
                gl.glClearDepth(1.0f);
                gl.glEnable(GL_DEPTH_TEST);
                gl.glDepthFunc(GL_LEQUAL);
                gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
                gl.glShadeModel(GL_SMOOTH);
                for(int i=0;i<nVbos;i++)
                        numberOFVertices[i]=createAndFillVertexBuffer(drawable.getGL().getGL2(),MyDataObject.pieces[i],i);
                stpe.scheduleAtFixedRate(new Runnable() {
                        @Override public void run() {
                                int i=n%nVbos;
                                // MyDataObject.pieces[i].color=MyDataObject.colors[random.nextInt(MyDataObject.colors.length)];
                                MyDataObject.pieces[i].color=Color.red;
                                fillVertexBuffer(drawable.getGL().getGL2(),MyDataObject.pieces[i],i);
                                n++;
                        }
                        int n;
                },500,100,TimeUnit.MILLISECONDS);
        }
        @Override public void display(GLAutoDrawable drawable) {
                update();
                GL2 gl=drawable.getGL().getGL2();
                gl.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
                gl.glLoadIdentity();
                gl.glRotated(2,1,0,0); // rotate a small amount so we can see the z axis
                gl.glRotated(-2,0,1,0); // rotate a small amount so we can see the z axis
                gl.glRotated(angle,0,1,0);
                gl.glColor3d(1,1,1);
                for(int i=0;i<nVbos;i++)
                        renderPiece(drawable,i);
        }
        @Override public void dispose(GLAutoDrawable drawable) {
                System.out.println("super.dispose "+drawable);
        }
        final GLAutoDrawable drawable;
        double angle;
        int nVbos;
        int[] vertexBufferIndices;
        int[] numberOFVertices;
        Random random=new Random();
        final ScheduledThreadPoolExecutor stpe=new ScheduledThreadPoolExecutor(4);
        int fps=defaultFps;
        protected GLU glu;
        protected GLUT glut;
        protected static String TITLE="JOGL 2.0 Setup (GLJPanel)";
        protected static final int displayWidth=1024;
        protected static final int displayHeight=1024;
        protected static final int defaultFps=60;
}
Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

gouessej
Administrator
Hi

Use glBufferSubData to modify the data store. Mapping and unmapping should be done on the rendering thread and when the OpenGL context is current. I would rather use a timer only to know when the data needs to be refreshed but I would perform this refresh on the rendering thread when the OpenGL context is current. You could modify your code by using GLDrawable.invoke() and put your call to fillVertexBuffer into a GLRunnable.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

rtayek
At 06:56 AM 9/8/2012, you wrote:
>Hi Use glBufferSubData to modify the data store. Mapping and
>unmapping should be done on the rendering thread and when the OpenGL
>context is current.

ok.

>  I would rather use a timer only to know when the data needs to be
> refreshed but I would perform this refresh on the rendering thread
> when the OpenGL context is current.

are you suggesting that i can get by with just rendering the data
that has changed as opposed to the entire screen?

>  You could modify your code by using GLDrawable.invoke() and put
> your call to fillVertexBuffer into a GLRunnable.
>Julien Gouesse http://tuer.sourceforge.nethttp://gouessej.wordpress.com

i will look into invoke in a runnable.

but i am currently stuck on this
http://forum.jogamp.org/over-80-of-time-is-in-AWTAnimatorImpl-display-amp-GLDrawableHelper-displayImpl-td4026033.html.

if i can only get 70 fps when drawing 1000000 pixels, then i may have
to ditch java and use c++ (which i would really rather avoid doing).

do i need to try something like full screen mode and write my own
repain manager?

thanks

---
co-chair http://ocjug.org/

Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

gouessej
Administrator
rtayek wrote
are you suggesting that i can get by with just rendering the data
that has changed as opposed to the entire screen?
No. Just update your data at the beginning of the method GLEventListener.display(GLAutoDrawable) only when needed.

rtayek wrote
i will look into invoke in a runnable.

but i am currently stuck on this
http://forum.jogamp.org/over-80-of-time-is-in-AWTAnimatorImpl-display-amp-GLDrawableHelper-displayImpl-td4026033.html.

if i can only get 70 fps when drawing 1000000 pixels, then i may have
to ditch java and use c++ (which i would really rather avoid doing).

do i need to try something like full screen mode and write my own
repain manager?

thanks

---
co-chair http://ocjug.org/
Your problem has nothing to do with Java. Ditching it would probably not solve it and maybe you have just forgotten to disable the vertical synchronization or maybe you use OpenGL in a very unoptimized way, it would be the same in C/C++. Why not trying to use NEWT? You can put a NEWT GLWindow into a NewtCanvasAWT and use it inside your AWT-based GUI.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

Sven Gothel
Administrator
In reply to this post by rtayek
On 09/08/2012 07:48 PM, rtayek [via jogamp] wrote:
> but i am currently stuck on this
> http://forum.jogamp.org/over-80-of-time-is-in-AWTAnimatorImpl-display-amp-GLDrawableHelper-displayImpl-td4026033.html.
>
>
> if i can only get 70 fps when drawing 1000000 pixels, then i may have
> to ditch java and use c++ (which i would really rather avoid doing).

Neither JOGL nor the JVM impose fundamental performance costs
on the few GL function calls, as Julien suggested,
performance hits are usually due to costly operations for every frame.

~Sven


signature.asc (907 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

rtayek
In reply to this post by gouessej
At 12:23 PM 9/8/2012, you wrote:
>rtayek wrote
>are you suggesting that i can get by with just rendering the data
>that has changed as opposed to the entire screen?
>
>No. Just update your data at the beginning of the method
>GLEventListener.display(GLAutoDrawable) only when needed.

ok.

>rtayek wrote
>i will look into invoke in a runnable. but i am currently stuck on
>this
><http://forum.jogamp.org/over-80-of-time-is-in-AWTAnimatorImpl-display-amp-GLDrawableHelper-displayImpl-td4026033.html>http://forum.jogamp.org/over-80-of-time-is-in-AWTAnimatorImpl-display-amp-GLDrawableHelper-displayImpl-td4026033.html.
>...
>
>Your problem has nothing to do with Java.

i hope not.

>  Ditching it would probably not solve it and maybe you have just
> forgotten to disable the vertical synchronization

tried that, no joy, but i did run a furmark and got only 2 fps at
1080 preset. so most of the problem may be in my on-chip graphics. i
have ordered a graphics card.

>or maybe you use OpenGL in a very unoptimized way, it would be the
>same in C/C++.

the code here
http://stackoverflow.com/questions/12324994/how-do-i-get-more-frames-per-second-from-this-jogl-program 
is a self contained example (if you have jogl 2). i hope someone can
try it and report some results. afaik, i am doing things in a normal manner.

>  Why not trying to use NEWT? You can put a NEWT GLWindow into a
> NewtCanvasAWT and use it inside your AWT-based GUI.
>Julien Gouesse http://tuer.sourceforge.nethttp://gouessej.wordpress.com

i may try that.

thanks

---
co-chair http://ocjug.org/

Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

rtayek
In reply to this post by Sven Gothel
At 04:26 PM 9/8/2012, you wrote:
>On 09/08/2012 07:48 PM, rtayek [via jogamp] wrote: > but i am
>currently stuck on this >
><http://forum.jogamp.org/over-80-of-time-is-in-AWTAnimatorImpl-display-amp-GLDrawableHelper-displayImpl-td4026033.html>http://forum.jogamp.org/over-80-of-time-is-in-AWTAnimatorImpl-display-amp-GLDrawableHelper-displayImpl-td4026033.html.  
> > > > if i can only get 70 fps when drawing 1000000 pixels, then i
>may have > to ditch java and use c++ (which i would really rather
>avoid doing).


>Neither JOGL nor the JVM impose fundamental performance costs on the
>few GL function calls, as Julien suggested, performance hits are
>usually due to costly operations for every frame. ~Sven

can you give me some idea of what those "costly" operations might be?

there is an ssce at
http://stackoverflow.com/questions/12324994/how-do-i-get-more-frames-per-second-from-this-jogl-program.
perhaps some one could run it and let me know if i am doing something
really stupid.

thanks

---
co-chair http://ocjug.org/

Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

gouessej
Administrator
Just avoid using GLJPanel except if you have excellent reasons to use it.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

rtayek
using a GLJPanel instead of a GLCanvas does not seem to make any difference.

maybe i need to go into full screen mode and write my own display loop?

thanks
Reply | Threaded
Open this post in threaded view
|

Re: vbo - DrawArrays - threading question

Sven Gothel
Administrator
In reply to this post by rtayek
On 09/09/2012 03:12 AM, rtayek [via jogamp] wrote:
>>Neither JOGL nor the JVM impose fundamental performance costs on the
>>few GL function calls, as Julien suggested, performance hits are
>>usually due to costly operations for every frame. ~Sven
>
> can you give me some idea of what those "costly" operations might be?

- CPU/GPU memory transfers
  - Textures, VBO, ..

- object destruction/creation (OpenGL (textures, VBO, ..), maybe even Java)
  - FBO, VBO, ..
  - Textures
  - Shader Programs
  - ..

For example, if you use the GLEventListener model,
one would like to initialize things once in the init method
and release it in destroy.
Display and reshape shall be as cheap as possible,
i.e. (GL) object [re]creation only when necessary.

For example .. if some initialization is really expensive
and has to be done on the fly, it is recommended to use
another thread (e.g. to stream in data) and maybe even a shared context
(to fill a texture object or VBO).

The fact you are using Java or JOGL is irrelevant here.

~Sven




signature.asc (907 bytes) Download Attachment