From 5ede06197542233ba30b245580208a25ce37d8db Mon Sep 17 00:00:00 2001 From: chyyran Date: Thu, 26 Sep 2024 02:02:54 -0400 Subject: [PATCH] preprocess: allow shadersource to be serializable with serde --- librashader-preprocess/Cargo.toml | 2 ++ librashader-preprocess/src/lib.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/librashader-preprocess/Cargo.toml b/librashader-preprocess/Cargo.toml index 2aba0fa..d960693 100644 --- a/librashader-preprocess/Cargo.toml +++ b/librashader-preprocess/Cargo.toml @@ -16,10 +16,12 @@ thiserror = "1.0.37" nom = "7.1.1" librashader-common = { path = "../librashader-common", version = "0.4.5" } encoding_rs = "0.8.31" +serde = { version = "1.0", optional = true } [features] default = [ "line_directives" ] line_directives = [] +serde = ["dep:serde", "serde/derive", "librashader-common/serde"] [dev-dependencies] glob = "0.3.1" diff --git a/librashader-preprocess/src/lib.rs b/librashader-preprocess/src/lib.rs index 0f82d93..a969827 100644 --- a/librashader-preprocess/src/lib.rs +++ b/librashader-preprocess/src/lib.rs @@ -21,6 +21,7 @@ use std::path::Path; /// The source file for a single shader pass. #[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ShaderSource { /// The source contents for the vertex shader. pub vertex: String, @@ -40,6 +41,7 @@ pub struct ShaderSource { /// A user tweakable parameter for the shader as declared in source. #[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ShaderParameter { /// The name of the parameter. pub id: ShortString,