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 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.

APIStatuslibrashader feature
OpenGL 3.3+gl
OpenGL 4.6gl
Vulkanvk
Direct3D 9🆗️d3d9
Direct3D 11d3d11
Direct3D 12d3d12
Metalmetal
wgpuwgpu

✅ Full Support — 🆗 Secondary Support

§C API

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

Modules§

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.

Enums§

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

Type Aliases§

FastHashMap
A hashmap optimized for small sets of size less than 32 with a fast hash implementation.
ShortString
A string with small string optimizations up to 23 bytes.