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.
§Usage
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.
§Runtimes
librashader supports most modern graphics runtimes, including Vulkan, OpenGL 3.3+ and 4.6 (with DSA), Direct3D 11, Direct3D 12, and Metal. Secondary support is available for wgpu and Direct3D 9.
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.
Shader compatibility is not guaranteed on render APIs with secondary support.
wgpu has restrictions on shaders that can not be converted to WGSL, such as those that use inverse
.
Direct3D 9 does not support shaders that need Direct3D 10+ only features, or shaders that can not be
compiled to Shader Model 3.0.
wgpu support is not available in the librashader C API.
API | Status | librashader feature |
---|---|---|
OpenGL 3.3+ | ✅ | gl |
OpenGL 4.6 | ✅ | gl |
Vulkan | ✅ | vk |
Direct3D 9 | 🆗️ | d3d9 |
Direct3D 11 | ✅ | d3d11 |
Direct3D 12 | ✅ | d3d12 |
Metal | ✅ | metal |
wgpu | ✅ | wgpu |
✅ Full Support — 🆗 Secondary Support
§C API
For documentation on the librashader C API, see librashader-capi,
or librashader.h
.
Modules§
- preprocess
preprocess
- Loading and preprocessing of ‘slang’ shader source files.
- presets
presets
- Parsing and usage of shader presets.
- reflect
reflect
- Shader reflection and cross-compilation.
- runtime
runtime
- Shader runtimes to execute a filter chain on a GPU surface.
Enums§
- Filter
Mode - The filtering mode for a texture sampler.
- Image
Format - Supported image formats for textures.
- Wrap
Mode - The wrapping (address) mode for a texture sampler.
Type Aliases§
- Fast
Hash Map - A hashmap optimized for small sets of size less than 32 with a fast hash implementation.
- Short
String - A string with small string optimizations up to 23 bytes.