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.
§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 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.
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 — ⚠️ ️Experimental 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§
- The filtering mode for a texture sampler.
- Supported image formats for textures.
- The wrapping (address) mode for a texture sampler.