7个版本
0.3.0-pre.3 | 2022年10月19日 |
---|---|
0.3.0-pre.2 | 2022年9月30日 |
0.3.0-pre.1 | 2022年1月19日 |
0.2.0 | 2018年12月11日 |
0.1.2 | 2018年12月2日 |
在 图形API 中排名第 168
每月下载量 7,994
37KB
725 行
🥽 shader-prepper
shader-prepper 是一个着色器包含解析器和爬虫器。它主要针对GLSL,因为GLSL本身不提供内置的包含指令支持。
此crate不实现完整的C样式的预处理器,只实现 #include
扫描。其他指令则直接复制到展开的代码中,以便后续由着色器编译器处理。
API支持用户驱动的包含文件提供者,这允许自定义虚拟文件系统、包含路径,并允许构建系统跟踪依赖关系。
源文件不是合并在一起,而是作为SourceChunk
的Vec返回。如果需要一个单独的字符串,可以使用源字符串的join
。否则,可以将单个块传递给图形API,然后SourceChunk
中的源信息可以重新映射编译器的错误回原始代码。
示例
struct FileIncludeProvider;
impl shader_prepper::IncludeProvider for FileIncludeProvider {
type IncludeContext = ();
fn get_include(
&mut self,
path: &str,
_context: &Self::IncludeContext,
) -> Result<(String, Self::IncludeContext), crate::BoxedIncludeProviderError> {
Ok((std::fs::read_to_string(path)?, ()))
}
}
// ...
let chunks = shader_prepper::process_file("myfile.glsl", &mut FileIncludeProvider, ());
许可证:MIT
依赖关系
~0.3–1.3MB
~27K SLoC