Crate librashader

source ·
Expand description

RetroArch shader preset compiler and runtime.

librashader provides convenient and safe access to RetroArch ‘slang’ shaders. The preset parser, shader preprocessor, and shader runtimes have all been reimplemented in Rust to provide easy access to the rich library of shaders.


The core objects in librashader are the ShaderPreset and the filter chain implementations.

The basic workflow involves parsing a ShaderPreset, which can then be used to construct a FilterChain. All shaders will then be compiled, after which FilterChain::frame can be called with appropriate input and output parameters to draw a frame with the shader effect applied.


librashader supports all modern graphics runtimes, including wgpu, Vulkan, OpenGL 3.3+ and 4.6 (with DSA), Direct3D 11, Direct3D 12, and Metal.

The Direct3D 12 runtime requires support for render passes, which have been available since Windows 10, version 1809.

The Vulkan runtime can use VK_KHR_dynamic_rendering for improved performance, if the underlying hardware supports it.

Direct3D 9 support is experimental and is not guaranteed to work with all shaders. In particular, history and feedback is currently not supported. Many shaders will also fail to compile due to missing or insufficient features in Direct3D 9.

wgpu support is not available in the librashader C API.

APIStatuslibrashader feature
OpenGL 3.3+gl
OpenGL 4.6gl
Direct3D 9⚠️d3d9
Direct3D 11d3d11
Direct3D 12d3d12

✅ Full Support — 🆗 Secondary Support — ⚠️ ️Experimental Support


For documentation on the librashader C API, see librashader-capi, or librashader.h.


  • preprocesspreprocess
    Loading and preprocessing of ‘slang’ shader source files.
  • presetspresets
    Parsing and usage of shader presets.
  • reflectreflect
    Shader reflection and cross-compilation.
  • runtimeruntime
    Shader runtimes to execute a filter chain on a GPU surface.


  • The filtering mode for a texture sampler.
  • Supported image formats for textures.
  • The wrapping (address) mode for a texture sampler.