Hardware OpenGL rendering in MATLAB

5,921

For me the followed works (under ArchLinux with R2017a (prerelease) with a laptop having only intel graphics):

export LD_PRELOAD=/usr/lib/libstdc++.so
export LD_LIBRARY_PATH=/usr/lib/xorg/modules/dri/
/net/sw/MATLAB/R2017a/bin/glnxa64/MATLAB

Note that in the last step I'm calling the MATLAB executable directly (not the helper script that performs some LD_* manipulation)

>> opengl info
                          Version: '3.0 Mesa 17.0.0'
                           Vendor: 'Intel Open Source Technology Center'
                         Renderer: 'Mesa DRI Intel(R) Haswell Mobile '
                   MaxTextureSize: 16384
                           Visual: 'Visual 0xcb, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 8 samples)'
                         Software: 'false'
             HardwareSupportLevel: 'full'
        SupportsGraphicsSmoothing: 1
    SupportsDepthPeelTransparency: 1
       SupportsAlignVertexCenters: 1
                       Extensions: {230×1 cell}
               MaxFrameBufferSize: 16384
Share:
5,921

Related videos on Youtube

StrongBad
Author by

StrongBad

Updated on September 18, 2022

Comments

  • StrongBad
    StrongBad almost 2 years

    I am unable to get hardware based OpenGL rendering to work in MATLAB R2015a or R2014b. Prior to R2014b, and the rewrite of the MATLAB graphics stack, everything worked fine. From MATLAB

    >> opengl info
                              Version: '3.0 Mesa 10.6.5'
                               Vendor: 'Intel Open Source Technology Center'
                             Renderer: 'Mesa DRI Intel(R) Sandybridge Mobile '
                       MaxTextureSize: 8192
                               Visual: 'Visual 0xac, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 4 samples)'
                             Software: 'true'
            SupportsGraphicsSmoothing: 1
        SupportsDepthPeelTransparency: 1
           SupportsAlignVertexCenters: 1
                           Extensions: {199x1 cell}
                   MaxFrameBufferSize: 8192
    

    I was expecting/wanting "Software" to be false.

    $ ldd /opt/tmw/matlab/bin/glnxa64/glren.so | grep libGL
        libGL.so.1 => /usr/lib/libGL.so.1 (0x00007f0a3b871000)
        libGLU.so.1 => /usr/lib/libGLU.so.1 (0x00007f0a3b5ef000)
    

    suggests that MATLAB is finding the system libraries (which is what TMW says I want) and TMW confirms that the library versions libGL.so.1.2.0 and libGLU.so.1.3.1 are compatible.

    $ LIBGL_DEBUG=verbose matlab
    libGL: OpenDriver: trying /usr/lib/xorg/modules/dri/tls/i965_dri.so
    libGL: OpenDriver: trying /usr/lib/xorg/modules/dri/i965_dri.so
    libGL: Using DRI2 for screen 0
    

    Does not provide any useful info. I have been in contact with TMW technical support and they have decided it is not a MATLAB issue despite

    $ glxinfo | grep render
    direct rendering: Yes
    OpenGL renderer string: Mesa DRI Intel(R) Sandybridge Mobile
    

    suggesting hardware based OpenGL is working outside MATLAB. I have done most of my testing on Arch Linux with an Intel graphics card, but have also tried ATI and Nvidia cards without any luck. I recently created a Debian 7 chroot, since that is an officially supported OS, but still had no luck with the Intel card.

    Everything has been done with the stock Arch kernel. Could that be the cause of the problem? How do I debug/trace the issue?

  • StrongBad
    StrongBad over 8 years
    I can remove the file, but as mentioned in my question both ldd and LIBGL_DEBUG tell me I am using the system libraries.
  • MJD
    MJD over 8 years
    MATLAB starts with a custom LD_LIBRARY_PATH which overrides the version of libstdc++.so that is used. It doesn't override the i965_dri.so used though, nor the libGL.so. I know this library creates issues for various things with MATLAB for me, so I figured this may be your problem too.