Hardware accelelartion using JOGL

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

Hardware accelelartion using JOGL

Michael F
How do you ensure that hardware acceleration is enabled ? I've got a simple JOGL app but it uses up 80% of CPU. Do I need to switch hardware acceleation on ? Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Hardware accelelartion using JOGL

gouessej
Administrator
Hi

Please be more accurate about "a simple JOGL app" as JOGL is probably not to blame. It picks the default OpenGL profile if you don't do anything fancy. It might pick the crappy Microsoft GDI renderer in some cases. If you don't show any source code, we won't be able to help you.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Hardware accelelartion using JOGL

gouessej
Administrator
In reply to this post by Michael F
Do you use offscreen rendering? pbuffers? fbo? How do you create the GLCapabilities object?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Hardware accelelartion using JOGL

Michael F
Thanks for the response, Julien.

This is how I create the GLCapabilities object :

                    GLProfile glp = GLProfile.getDefault();
                    GLCapabilities caps = new GLCapabilities(glp);
                    GLWindow window = GLWindow.create(caps);

I don't know much about openGL either. Never heard of pbuffers or fbo. I don't think we're using offscreen rendering. Could you direct me to an example that does ? Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Hardware accelelartion using JOGL

gouessej
Administrator
If you don't need offscreen rendering, don't use it.

Please run this test:
http://jogamp.org/deployment/jogamp-current/jogl-application-version.jnlp

Keep in mind that maybe it's your own code that is to blame. Have you used a profiler? JVisualVM?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Hardware accelelartion using JOGL

Michael F
Hi Julien,

We found out that not rendering images in our app resulted in a 50 percentage point reduction in CPU usage. This is the code we commented out :

    public void draw(GL2 gl)
    {
/*
        gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
        gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
        gl.glEnable(GL2.GL_TEXTURE_2D);
        gl.glBindTexture(GL2.GL_TEXTURE_2D, textureId);
        gl.glEnable(GL2.GL_BLEND);

        gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
       
        gl.glColor3f(1, 1, 1);
        vertexBuffer.position(0);
        gl.glVertexPointer(2, GL2.GL_FLOAT, 16, vertexBuffer);
        vertexBuffer.position(2);
        gl.glTexCoordPointer(2, GL2.GL_FLOAT, 16, vertexBuffer);
        gl.glDrawArrays(GL2.GL_QUADS, 0, 4);

        gl.glDisable(GL2.GL_BLEND);
        gl.glBindTexture(GL2.GL_TEXTURE_2D, 0);
        gl.glDisable(GL2.GL_TEXTURE_2D);
        gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
        gl.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
*/
    }

Is there anything you can see in here that we could do better ? And yes, we are using JVisualVM.

Thanks,

Michael
Reply | Threaded
Open this post in threaded view
|

Re: Hardware accelelartion using JOGL

Sven Gothel
Administrator
On 11/11/2015 10:42 AM, Michael F [via jogamp] wrote:

> Hi Julien,
>
> We found out that not rendering images in our app resulted in a 50 percentage
> point reduction in CPU usage. This is the code we commented out :
>
>     public void draw(GL2 gl)
>     {
> /*
>         gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
>         gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
>         gl.glEnable(GL2.GL_TEXTURE_2D);
>         gl.glBindTexture(GL2.GL_TEXTURE_2D, textureId);
>         gl.glEnable(GL2.GL_BLEND);
>
>         gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
>        
>         gl.glColor3f(1, 1, 1);
>         vertexBuffer.position(0);
>         gl.glVertexPointer(2, GL2.GL_FLOAT, 16, vertexBuffer);
>         vertexBuffer.position(2);
>         gl.glTexCoordPointer(2, GL2.GL_FLOAT, 16, vertexBuffer);
>         gl.glDrawArrays(GL2.GL_QUADS, 0, 4);
>
>         gl.glDisable(GL2.GL_BLEND);
>         gl.glBindTexture(GL2.GL_TEXTURE_2D, 0);
>         gl.glDisable(GL2.GL_TEXTURE_2D);
>         gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
>         gl.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
> */
>     }
>
> Is there anything you can see in here that we could do better ? And yes, we
> are using JVisualVM.
Then you can profile the application and see the culprit
of CPU consumption.

IMHO CPU consumption might be an issue of using the fixed function pipeline
which might be implemented in software using some core GL profile
- by the driver.
Switching those states each frame may also trigger the driver
to issue new 'on the fly shaders' ..

~Sven



signature.asc (828 bytes) Download Attachment