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)
|
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
|
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.
|
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
|
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.
|
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-common",
|
||||||
"librashader-presets",
|
"librashader-presets",
|
||||||
"nom",
|
"nom",
|
||||||
|
"rayon",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
|
@ -25,3 +25,4 @@ line_directives = []
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
glob = "0.3.1"
|
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 glob::glob;
|
||||||
use librashader_preprocess::{PreprocessError, ShaderSource};
|
use librashader_preprocess::ShaderSource;
|
||||||
use librashader_presets::ShaderPreset;
|
use librashader_presets::ShaderPreset;
|
||||||
|
use rayon::prelude::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn preprocess_all_slang_presets_parsed() {
|
fn preprocess_all_slang_presets_parsed() {
|
||||||
for entry in glob("../test/slang-shaders/**/*.slangp").unwrap() {
|
for entry in glob("../test/slang-shaders/**/*.slangp").unwrap() {
|
||||||
if let Ok(path) = entry {
|
if let Ok(path) = entry {
|
||||||
if let Ok(preset) = ShaderPreset::try_parse(&path) {
|
if let Ok(preset) = ShaderPreset::try_parse(&path) {
|
||||||
for shader in preset.shaders {
|
preset.shaders.into_par_iter().for_each(|shader| {
|
||||||
ShaderSource::load(&shader.name).expect(&format!(
|
if let Err(e) = ShaderSource::load(&shader.name) {
|
||||||
"Failed to preprocess shader {} from preset {}",
|
println!(
|
||||||
|
"Failed to preprocess shader {} from preset {}: {:?}",
|
||||||
shader.name.display(),
|
shader.name.display(),
|
||||||
path.display()
|
path.display(),
|
||||||
));
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue