cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

fesc2000
Adept I

Opengl interop / clCreateContextFromType segfault

Hi,

i recently did an ill advised updated of my Debian (sid) installation. This caused my OpenCL/OpenGL interoperability to be broken, and i wonder if anyone else is experiencing this ...

The call to clCreateContextFromType() either fails with a segfault or X error:

Code:

    cl_context_properties cprops[] = {

        CL_CONTEXT_PLATFORM, (cl_context_properties)platform,

        CL_GL_CONTEXT_KHR, (cl_context_properties)glx_context,

        CL_GLX_DISPLAY_KHR, (cl_context_properties)display,

        0 };

    context = clCreateContextFromType(cprops,

                                      CL_DEVICE_TYPE_ALL,

                                      NULL,

                                      NULL,

                                      &status);


Result:

X Error of failed request:  BadMatch (invalid parameter attributes)

  Major opcode of failed request:  157 (GLX)

  Minor opcode of failed request:  5 (X_GLXMakeCurrent)

  Serial number of failed request:  36

  Current serial number in output stream:  36

Removing CL_GLX_DISPLAY_KHR property just produces a segfault

Without CL_GL_CONTEXT_KHR  everything works fine (without using the interop code of course).

This all used to work fine before the update (even without CL_GLX_DISPLAY_KHR property).

EDIT:

This only happens when the calls are done from a separate thread .. my main thread initializes X/OpenGl. The actual work, incl. OpenCL initialization is done in a thread which is spawned later. The context is properly transferred to this thread via glXMakeCurrent().

-> If i do the initialization in the main thread it works, but the first call using GL interoperability (e.g. clCreateFromGLTexture) fails with the same X error ...

The update moved fglrx driver package version from

fglrx-driver (1:14.6~ga14.201-1) unstable

to

fglrx-driver (1:14.9+ga14.201-1) unstable

which is actually the same amd driver package, just a different debian package.

xorg is the latest (1.16).

fglrxinfo:

OpenGL vendor string: Advanced Micro Devices, Inc.

OpenGL renderer string: ATI Radeon HD 5700 Series

OpenGL version string: 4.4.12968 Compatibility Profile Context 14.201.1009

clinfo:

Number of platforms:                             1

  Platform Profile:                              FULL_PROFILE

  Platform Version:                              OpenCL 1.2 AMD-APP (1526.3)

  Platform Name:                                 AMD Accelerated Parallel Processing

  Platform Vendor:                               Advanced Micro Devices, Inc.

  Platform Extensions:                           cl_khr_icd cl_amd_event_callback cl_amd_offline_devices

0 Likes
4 Replies
nan
Adept II

Hi,

I have the same problem with Ubuntu which appeared suddenly after some updates. But OpenCL-OpenGL Interop on Ubuntu 12.10 broken? provides a solution: add /usr/lib/fglrx to your LD_LIBRARY_PATH environment variable.

Furthermore, the OpenCL context has to be created directly after glXCreateContext, i.e. before creating any OpenGL object. Otherwise one observes strange behaviour (at the moment my program is only single threaded).

-- NaN

0 Likes

Thanks for the response. Unfortunately both didn't help .. maybe it's because i'm not calling glXCreateContext directly since i use SDL.

I converted the initialization to happen within the same (main) thread. clCreateContextFromType then works, but now the first call to clCreateFromGLTexture fails.

I reverted to the fglrx package before the update (which is the same driver), but that also didn't help.


I keep digging ...

0 Likes

Could you provide the relevant code snippets? Which error does clCreateFromGLTexture return or does it even crash? If libGL.so cannot be found then a error like

X Error of failed request:  BadMatch (invalid parameter attributes)

  Major opcode of failed request:  157 (GLX)

  Minor opcode of failed request:  5 (X_GLXMakeCurrent)

  Serial number of failed request:  36

  Current serial number in output stream:  36

is raised.

-- NaN

0 Likes

I found the problem ... or at least a workaround:

Obviously the wrong libGL was used for the case that OpenGL interoperability is made use of.

I changed the following symlink:

/etc/alternatives/glx--libGL.so-x86_64-linux-gnu now linked to /usr/lib/x86_64-linux-gnu/fglrx/libGL.so.1

instead of /usr/lib/mesa-diverted/x86_64-linux-gnu/libGL.so

So this all seems to be a Debian packaging/update issue. I don't understand all this crazy library linking and diverting ...

For the records: before the actual error i always got these messages as well:

libGL error: unable to load driver: swrast_dri.so

libGL error: failed to load driver: swrast

This also happened for the samples in the APP SDK as well, so it's not related to my code.

Thanks again,

Felix.

0 Likes