test: add test for shader preprocess
This commit is contained in:
parent
2128945c06
commit
44b2a797b4
|
@ -5,7 +5,7 @@ The following shaders are known to be broken due to various issues.
|
|||
|
||||
This list is updated as of [slang-shaders@`356678e`](https://github.com/libretro/slang-shaders/commit/356678ec53ca940a53fa509eff0b65bb63a403bb)
|
||||
|
||||
## Parsing errors
|
||||
## Broken due to parsing errors
|
||||
librashader's preset parser is somewhat stricter than RetroArch in what it accepts. All shaders and textures in a preset must
|
||||
resolve to a fully canonical path to properly parse. The following shaders have broken paths.
|
||||
|
||||
|
@ -40,3 +40,9 @@ librashader's parser is fuzzed with slang-shaders and will accept invalid keys l
|
|||
to account for shader presets that use these invalid constructs. No known shader presets fail to parse due to syntax errors
|
||||
that haven't already been accounted for.
|
||||
|
||||
## Broken due to preprocessing errors
|
||||
|
||||
The preprocessor resolves `#include` pragmas in each `.slang` shader and recursively flattens files into a single compute unit.
|
||||
|
||||
* `misc/shaders/glass.slang`: Missing `misc/include/img/param_floats.h`.
|
||||
* Looks like this was moved too deep, it references `../include/img/param_floats.h`, but the shader lives in the `misc/shaders/` folder.
|
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -793,6 +793,7 @@ dependencies = [
|
|||
"librashader-common",
|
||||
"librashader-presets",
|
||||
"nom",
|
||||
"rayon",
|
||||
"rustc-hash",
|
||||
"thiserror",
|
||||
]
|
||||
|
|
|
@ -24,4 +24,5 @@ line_directives = []
|
|||
|
||||
[dev-dependencies]
|
||||
glob = "0.3.1"
|
||||
librashader-presets = { version = "0.1.0-beta.16", path = "../librashader-presets"}
|
||||
librashader-presets = { version = "0.1.0-beta.16", path = "../librashader-presets"}
|
||||
rayon = "1.6.1"
|
|
@ -1,18 +1,23 @@
|
|||
use glob::glob;
|
||||
use librashader_preprocess::{PreprocessError, ShaderSource};
|
||||
use librashader_preprocess::ShaderSource;
|
||||
use librashader_presets::ShaderPreset;
|
||||
use rayon::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn preprocess_all_slang_presets_parsed() {
|
||||
for entry in glob("../test/slang-shaders/**/*.slangp").unwrap() {
|
||||
if let Ok(path) = entry {
|
||||
if let Ok(preset) = ShaderPreset::try_parse(&path) {
|
||||
for shader in preset.shaders {
|
||||
ShaderSource::load(&shader.name).expect(&format!(
|
||||
"Failed to preprocess shader {} from preset {}",
|
||||
shader.name.display(),
|
||||
path.display()
|
||||
));
|
||||
}
|
||||
preset.shaders.into_par_iter().for_each(|shader| {
|
||||
if let Err(e) = ShaderSource::load(&shader.name) {
|
||||
println!(
|
||||
"Failed to preprocess shader {} from preset {}: {:?}",
|
||||
shader.name.display(),
|
||||
path.display(),
|
||||
e
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue