When RetroArch added support for the Vulkan graphics API back in 2016, we made a new shader spec that was intended to replace the older shader specifications like Cg and GLSL moving forward.

The problem at the time was that only the Vulkan video driver could make use of these shaders. Therefore, if you were using the OpenGL video driver, you could not use the slang shaders but had to resort back to GLSL (or even Cg). This made it cumbersome to switch between video drivers, say starting one game/core that uses OpenGL, then switching back to Vulkan to start another core that uses Vulkan. You couldn’t just load a shader preset for one of the two and expect that to work as well for the other core with a new video driver.

A new OpenGL driver has been made that targets OpenGL 3.2 and up. And unlike the older GL driver, this one supports only slang shaders. This means that this OpenGL driver can now finally use the same shaders as Vulkan, Direct3D 10/11/12, and Metal. This marks an important milestone for us since we are well on our way to having a true universal shader spec now that can cross around graphics API barriers.

List of video drivers supporting slang

Here is a listing of video drivers that support slang in RetroArch:

    1. OpenGL (Core – requires 3.2 or higher)
    2. Vulkan
    3. Metal
    4. Direct3D 10/11/12
    5. WiiU

How to use it

In order to use this video driver, you need to have a GPU with modernday OpenGL drivers. By default, RetroArch starts out on most platforms with the regular GL driver, which requires OpenGL2. We will therefore have to switch over manually to GL Core in order to use it.

Once inside RetroArch, go to Settings – Drivers. Go to Video Driver. Select ‘glcore’. After this, go back to the main menu inside RetroArch, and select ‘Quit RetroArch’.

What platforms are supported as of v1.7.7?

So far, the Windows and Linux builds come with the GL Core driver. macOS might follow later for OSX 10.7 and up.

The GL Core driver is OpenGL ES 3.x compatible, so a port to mobile devices is not inconceivable. We would certainly like to see this driver appearing on Android and iOS.

If for whatever reason your GPU or driver does not supper OpenGL 3.2, RetroArch will quit and set your video driver to “gl”. You will then just have to restart the program in order to boot with the regular OpenGL 2 driver.


Future plans/current limitations

    1. The glcore driver does not support GLSL or Cg shaders, only slang. If you still need to use such shaders, you have to go back to the older OpenGL video driver.
    2. We’d like slang to appear on even more platforms, such as the Microsoft Visual Studio builds below 2012. What prevents this from happening is the usage of C++11. Slang as a shader spec leverages several technologies such as the excellent SPIRV-Cross and glslang, both of which are also C++11 projects. Now, SPIRV-Cross has a C API, so this could be a potential solution towards making a wholly C based solution so that slang could appear in more builds. However, the C API for glslang has been abandoned and deprecated for one or two years. So after 1.7.7, we will have to research alternatives such as Google’s shaderc (which is supposed to still have a C API), and hope they will allow us what we want to do – have wholly C code for the slang shader code for the sake of backwards compatibility and being able to port it to more platforms.


Developing Slang Shaders