preprocess: allow shadersource to be serializable with serde

This commit is contained in:
chyyran 2024-09-26 02:02:54 -04:00 committed by Ronny Chan
parent 1676150858
commit 5ede061975
2 changed files with 4 additions and 0 deletions

View file

@ -16,10 +16,12 @@ thiserror = "1.0.37"
nom = "7.1.1" nom = "7.1.1"
librashader-common = { path = "../librashader-common", version = "0.4.5" } librashader-common = { path = "../librashader-common", version = "0.4.5" }
encoding_rs = "0.8.31" encoding_rs = "0.8.31"
serde = { version = "1.0", optional = true }
[features] [features]
default = [ "line_directives" ] default = [ "line_directives" ]
line_directives = [] line_directives = []
serde = ["dep:serde", "serde/derive", "librashader-common/serde"]
[dev-dependencies] [dev-dependencies]
glob = "0.3.1" glob = "0.3.1"

View file

@ -21,6 +21,7 @@ use std::path::Path;
/// The source file for a single shader pass. /// The source file for a single shader pass.
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ShaderSource { pub struct ShaderSource {
/// The source contents for the vertex shader. /// The source contents for the vertex shader.
pub vertex: String, pub vertex: String,
@ -40,6 +41,7 @@ pub struct ShaderSource {
/// A user tweakable parameter for the shader as declared in source. /// A user tweakable parameter for the shader as declared in source.
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ShaderParameter { pub struct ShaderParameter {
/// The name of the parameter. /// The name of the parameter.
pub id: ShortString, pub id: ShortString,