Troubles with CL/GL interoperability

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

Troubles with CL/GL interoperability

Andrew
This post was updated on .
I am trying to write very basic program using CL/GL interop, but problem appears -- JVM crashes with access violation exception while creating CLGLContext. Here is the code:

=====
    public static void main(String[] args) {
        JFrame window = new JFrame("test");
        GLCanvas c = new GLCanvas();
        c.addGLEventListener(new GLEventListener() {

            @Override
            public void init(GLAutoDrawable drawable) {
                GLContext context = drawable.getContext();
                CLGLContext clglContext = CLGLContext.create(context, CLDevice.Type.GPU); // access violation here
                System.out.println(clglContext);
            }

            @Override
            public void dispose(GLAutoDrawable drawable) {}
            @Override
            public void display(GLAutoDrawable drawable) {}
            @Override
            public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
        });
        c.setSize(300, 300);
        window.add(c);
        window.setSize(300, 300);
        window.pack();
        window.setVisible(true);
    }
=====

Any ideas/suggestions how to fix that?

UPD: Just realized that there is an official JogAmp GL/CL interop example, but it doesn't help much -- when I run it, the problem remains.
My platforms/GPU devices:
CLPlatform [name: Intel(R) OpenCL, vendor: Intel(R) Corporation, profile: FULL_PROFILE, version: OpenCL 1.2 ]
        CLDevice [id: 468205296 name: Intel(R) HD Graphics 4000 type: GPU profile: FULL_PROFILE]
CLPlatform [name: AMD Accelerated Parallel Processing, vendor: Advanced Micro Devices, Inc., profile: FULL_PROFILE, version: OpenCL 2.0 AMD-APP (2117.14)]
        CLDevice [id: 468587040 name: Capeverde type: GPU profile: FULL_PROFILE]
AMD platform is the one where the error arises. Intel one works perfectly.

UPD2: It seems like the cause is that Intel device is being selected as default device in JOGL, but in JOCL the default device is AMD device, and interoperability obviously isn't going to work. I can easily select which CL device to use, but cannot find a way to do it in JOGL (except for changing the default device globally for OS, but I'm not really comfortable with that).
The question now is: how can I select specific GL device to work with in JOGL?
Reply | Threaded
Open this post in threaded view
|

Re: Troubles with CL/GL interoperability

Wade Walker
Administrator
Hi Andrew,

It looks like the ability to choose a GPU programmatically doesn't currently exist within JOGL (see for example http://forum.jogamp.org/Choosing-a-Graphics-Device-td4031276.html). You might ask in the JOGL forum to confirm, since I'm not an expert on that side of things. I'm sure they'd welcome a code contribution in this area! Or alternately as you said, you could change your system setting -- presumably you'd want the AMD GPU to be the default anyway, since it would be more powerful than the Intel graphics?
Reply | Threaded
Open this post in threaded view
|

Re: Troubles with CL/GL interoperability

Andrew
Thank you for reply! After some internet surfing, I simply changed global settings -- it seems to be the only solution for now, at least for JOGL.