Skip to content

Commit 5235161

Browse files
committed
compile_codegen: add serde derives
1 parent bb5d2e0 commit 5235161

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

Cargo.lock

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rustc_codegen_spirv-types/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ license.workspace = true
88
repository.workspace = true
99

1010
[dependencies]
11+
spirv = { version = "0.3.0", features = ["serialize", "deserialize"] }
1112
rspirv = "0.12"
1213
serde = { version = "1.0", features = ["derive"] }
1314
serde_json = "1.0"

crates/spirv-builder/src/lib.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub enum SpirvBuilderError {
123123

124124
const SPIRV_TARGET_PREFIX: &str = "spirv-unknown-";
125125

126-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
126+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, serde::Deserialize, serde::Serialize)]
127127
pub enum MetadataPrintout {
128128
/// Print no cargo metadata.
129129
None,
@@ -136,7 +136,7 @@ pub enum MetadataPrintout {
136136
Full,
137137
}
138138

139-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
139+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, serde::Deserialize, serde::Serialize)]
140140
pub enum SpirvMetadata {
141141
/// Strip all names and other debug information from SPIR-V output.
142142
#[default]
@@ -149,7 +149,7 @@ pub enum SpirvMetadata {
149149
}
150150

151151
/// Strategy used to handle Rust `panic!`s in shaders compiled to SPIR-V.
152-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
152+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, serde::Deserialize, serde::Serialize)]
153153
pub enum ShaderPanicStrategy {
154154
/// Return from shader entry-point with no side-effects **(default)**.
155155
///
@@ -232,7 +232,7 @@ pub enum ShaderPanicStrategy {
232232

233233
/// Options for specifying the behavior of the validator
234234
/// Copied from `spirv-tools/src/val.rs` struct `ValidatorOptions`, with some fields disabled.
235-
#[derive(Default, Clone)]
235+
#[derive(Default, Clone, serde::Deserialize, serde::Serialize)]
236236
pub struct ValidatorOptions {
237237
/// Record whether or not the validator should relax the rules on types for
238238
/// stores to structs. When relaxed, it will allow a type mismatch as long as
@@ -301,7 +301,7 @@ pub struct ValidatorOptions {
301301

302302
/// Options for specifying the behavior of the optimizer
303303
/// Copied from `spirv-tools/src/opt.rs` struct `Options`, with some fields disabled.
304-
#[derive(Default, Clone)]
304+
#[derive(Default, Clone, serde::Deserialize, serde::Serialize)]
305305
pub struct OptimizerOptions {
306306
// /// Records the validator options that should be passed to the validator,
307307
// /// the validator will run with the options before optimizer.
@@ -316,7 +316,7 @@ pub struct OptimizerOptions {
316316
}
317317

318318
/// Cargo features specification for building the shader crate.
319-
#[derive(Default)]
319+
#[derive(Default, Clone, serde::Deserialize, serde::Serialize)]
320320
pub struct ShaderCrateFeatures {
321321
/// Set --default-features for the target shader crate.
322322
pub default_features: Option<bool>,
@@ -325,6 +325,7 @@ pub struct ShaderCrateFeatures {
325325
}
326326

327327
#[non_exhaustive]
328+
#[derive(Clone, serde::Deserialize, serde::Serialize)]
328329
pub struct SpirvBuilder {
329330
pub path_to_crate: Option<PathBuf>,
330331
/// Whether to print build.rs cargo metadata (e.g. cargo:rustc-env=var=val). Defaults to [`MetadataPrintout::Full`].

0 commit comments

Comments
 (0)