presets: initial structs for representing presets
This commit is contained in:
parent
c17796f309
commit
25f0cd31c4
8 changed files with 143 additions and 13 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/src/target/
|
8
src/.idea/.gitignore
generated
vendored
Normal file
8
src/.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
8
src/.idea/modules.xml
generated
Normal file
8
src/.idea/modules.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/src.iml" filepath="$PROJECT_DIR$/.idea/src.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
11
src/.idea/src.iml
generated
Normal file
11
src/.idea/src.iml
generated
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="CPP_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/librashader-presets/src" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
src/.idea/vcs.xml
generated
Normal file
6
src/.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
7
src/Cargo.lock
generated
Normal file
7
src/Cargo.lock
generated
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "librashader-presets"
|
||||||
|
version = "0.1.0"
|
|
@ -1,14 +1,3 @@
|
||||||
pub fn add(left: usize, right: usize) -> usize {
|
mod preset;
|
||||||
left + right
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
pub use preset::*;
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
let result = add(2, 2);
|
|
||||||
assert_eq!(result, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
100
src/librashader-presets/src/preset.rs
Normal file
100
src/librashader-presets/src/preset.rs
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::convert::Infallible;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
pub enum FilterMode {
|
||||||
|
Linear,
|
||||||
|
Nearest,
|
||||||
|
Unspecified
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
pub enum WrapMode {
|
||||||
|
ClampToBorder,
|
||||||
|
ClampToEdge,
|
||||||
|
Repeat,
|
||||||
|
MirroredRepeat,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
pub enum ScaleType {
|
||||||
|
Input,
|
||||||
|
Absolute,
|
||||||
|
Viewport
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for WrapMode {
|
||||||
|
type Err = Infallible;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
Ok(match s {
|
||||||
|
"clamp_to_border" => WrapMode::ClampToBorder,
|
||||||
|
"clamp_to_edge" => WrapMode::ClampToEdge,
|
||||||
|
"repeat" => WrapMode::Repeat,
|
||||||
|
"mirrored_repeat" => WrapMode::MirroredRepeat,
|
||||||
|
_ => WrapMode::ClampToBorder
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for ScaleType {
|
||||||
|
type Err = Infallible;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
Ok(match s {
|
||||||
|
"source" => ScaleType::Input,
|
||||||
|
"viewport" => ScaleType::Viewport,
|
||||||
|
"absolute" => ScaleType::Absolute,
|
||||||
|
_ => ScaleType::Input
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum ScaleFactor {
|
||||||
|
Float(f32),
|
||||||
|
Absolute(i32)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Scaling {
|
||||||
|
pub scale_type: ScaleType,
|
||||||
|
pub factor: ScaleFactor
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Scale2D {
|
||||||
|
pub x: Scaling,
|
||||||
|
pub y: Scaling
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ShaderConfig {
|
||||||
|
pub name: String,
|
||||||
|
pub alias: String,
|
||||||
|
pub filter: FilterMode,
|
||||||
|
pub wrap_mode: WrapMode,
|
||||||
|
pub frame_count_mod: usize,
|
||||||
|
pub srgb_framebuffer: bool,
|
||||||
|
pub float_framebuffer: bool,
|
||||||
|
pub mipmap_input: bool,
|
||||||
|
pub scaling: Scale2D
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TextureConfig {
|
||||||
|
pub name: String,
|
||||||
|
pub path: PathBuf,
|
||||||
|
pub wrap_mode: WrapMode,
|
||||||
|
pub filter: FilterMode,
|
||||||
|
pub mipmap: bool
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Parameter {
|
||||||
|
pub name: String,
|
||||||
|
pub value: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Preset {
|
||||||
|
// Everything is in Vecs because the expect number of values is well below 64.
|
||||||
|
pub shaders: Vec<ShaderConfig>,
|
||||||
|
pub textures: Vec<TextureConfig>,
|
||||||
|
pub parameters: Vec<Parameter>
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue