Improve Snapshot Test Configuration Deserialization (#6661)

This commit is contained in:
Connor Fitzgerald 2024-12-05 10:32:23 -06:00 committed by GitHub
parent b876b8c281
commit c933487697
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 28 deletions

View File

@ -258,6 +258,7 @@ bitflags::bitflags! {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[cfg_attr(feature = "deserialize", serde(default))]
pub struct Options { pub struct Options {
/// The GLSL version to be used. /// The GLSL version to be used.
pub version: Version, pub version: Version,

View File

@ -193,6 +193,7 @@ pub enum EntryPointError {
#[derive(Clone, Debug, Hash, PartialEq, Eq)] #[derive(Clone, Debug, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[cfg_attr(feature = "deserialize", serde(default))]
pub struct Options { pub struct Options {
/// The hlsl shader model to be used /// The hlsl shader model to be used
pub shader_model: ShaderModel, pub shader_model: ShaderModel,

View File

@ -195,6 +195,7 @@ enum LocationMode {
#[derive(Clone, Debug, Hash, PartialEq, Eq)] #[derive(Clone, Debug, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[cfg_attr(feature = "deserialize", serde(default))]
pub struct Options { pub struct Options {
/// (Major, Minor) target version of the Metal Shading Language. /// (Major, Minor) target version of the Metal Shading Language.
pub lang_version: (u8, u8), pub lang_version: (u8, u8),
@ -207,7 +208,6 @@ pub struct Options {
/// Don't panic on missing bindings, instead generate invalid MSL. /// Don't panic on missing bindings, instead generate invalid MSL.
pub fake_missing_bindings: bool, pub fake_missing_bindings: bool,
/// Bounds checking policies. /// Bounds checking policies.
#[cfg_attr(feature = "deserialize", serde(default))]
pub bounds_check_policies: index::BoundsCheckPolicies, pub bounds_check_policies: index::BoundsCheckPolicies,
/// Should workgroup variables be zero initialized (by polyfilling)? /// Should workgroup variables be zero initialized (by polyfilling)?
pub zero_initialize_workgroup_memory: bool, pub zero_initialize_workgroup_memory: bool,
@ -341,6 +341,7 @@ pub struct VertexBufferMapping {
#[derive(Debug, Default, Clone)] #[derive(Debug, Default, Clone)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[cfg_attr(feature = "deserialize", serde(default))]
pub struct PipelineOptions { pub struct PipelineOptions {
/// Allow `BuiltIn::PointSize` and inject it if doesn't exist. /// Allow `BuiltIn::PointSize` and inject it if doesn't exist.
/// ///

View File

@ -64,10 +64,10 @@ pub enum BoundsCheckPolicy {
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] #[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[cfg_attr(feature = "deserialize", serde(default))]
pub struct BoundsCheckPolicies { pub struct BoundsCheckPolicies {
/// How should the generated code handle array, vector, or matrix indices /// How should the generated code handle array, vector, or matrix indices
/// that are out of range? /// that are out of range?
#[cfg_attr(feature = "deserialize", serde(default))]
pub index: BoundsCheckPolicy, pub index: BoundsCheckPolicy,
/// How should the generated code handle array, vector, or matrix indices /// How should the generated code handle array, vector, or matrix indices
@ -103,7 +103,6 @@ pub struct BoundsCheckPolicies {
/// [`AccessIndex`]: crate::Expression::AccessIndex /// [`AccessIndex`]: crate::Expression::AccessIndex
/// [`Storage`]: crate::AddressSpace::Storage /// [`Storage`]: crate::AddressSpace::Storage
/// [`Uniform`]: crate::AddressSpace::Uniform /// [`Uniform`]: crate::AddressSpace::Uniform
#[cfg_attr(feature = "deserialize", serde(default))]
pub buffer: BoundsCheckPolicy, pub buffer: BoundsCheckPolicy,
/// How should the generated code handle image texel loads that are out /// How should the generated code handle image texel loads that are out
@ -119,11 +118,9 @@ pub struct BoundsCheckPolicies {
/// [`ImageLoad`]: crate::Expression::ImageLoad /// [`ImageLoad`]: crate::Expression::ImageLoad
/// [`ImageStore`]: crate::Statement::ImageStore /// [`ImageStore`]: crate::Statement::ImageStore
/// [`ReadZeroSkipWrite`]: BoundsCheckPolicy::ReadZeroSkipWrite /// [`ReadZeroSkipWrite`]: BoundsCheckPolicy::ReadZeroSkipWrite
#[cfg_attr(feature = "deserialize", serde(default))]
pub image_load: BoundsCheckPolicy, pub image_load: BoundsCheckPolicy,
/// How should the generated code handle binding array indexes that are out of bounds. /// How should the generated code handle binding array indexes that are out of bounds.
#[cfg_attr(feature = "deserialize", serde(default))]
pub binding_array: BoundsCheckPolicy, pub binding_array: BoundsCheckPolicy,
} }

View File

@ -39,61 +39,60 @@ impl Default for SpvOutVersion {
} }
#[derive(Default, serde::Deserialize)] #[derive(Default, serde::Deserialize)]
#[serde(default)]
struct SpirvOutParameters { struct SpirvOutParameters {
version: SpvOutVersion, version: SpvOutVersion,
#[serde(default)]
capabilities: naga::FastHashSet<spirv::Capability>, capabilities: naga::FastHashSet<spirv::Capability>,
#[serde(default)]
debug: bool, debug: bool,
#[serde(default)]
adjust_coordinate_space: bool, adjust_coordinate_space: bool,
#[serde(default)]
force_point_size: bool, force_point_size: bool,
#[serde(default)]
clamp_frag_depth: bool, clamp_frag_depth: bool,
#[serde(default)]
separate_entry_points: bool, separate_entry_points: bool,
#[serde(default)]
#[cfg(all(feature = "deserialize", spv_out))] #[cfg(all(feature = "deserialize", spv_out))]
binding_map: naga::back::spv::BindingMap, binding_map: naga::back::spv::BindingMap,
} }
#[derive(Default, serde::Deserialize)] #[derive(Default, serde::Deserialize)]
#[serde(default)]
struct WgslOutParameters { struct WgslOutParameters {
#[serde(default)]
explicit_types: bool, explicit_types: bool,
} }
#[derive(Default, serde::Deserialize)] #[derive(Default, serde::Deserialize)]
#[serde(default)]
struct Parameters { struct Parameters {
#[serde(default)] // -- GOD MODE --
god_mode: bool, god_mode: bool,
#[cfg(feature = "deserialize")]
#[serde(default)] // -- SPIR-V options --
bounds_check_policies: naga::proc::BoundsCheckPolicies,
#[serde(default)]
spv: SpirvOutParameters, spv: SpirvOutParameters,
// -- MSL options --
#[cfg(all(feature = "deserialize", msl_out))] #[cfg(all(feature = "deserialize", msl_out))]
#[serde(default)]
msl: naga::back::msl::Options, msl: naga::back::msl::Options,
#[cfg(all(feature = "deserialize", msl_out))] #[cfg(all(feature = "deserialize", msl_out))]
#[serde(default)] #[serde(default)]
msl_pipeline: naga::back::msl::PipelineOptions, msl_pipeline: naga::back::msl::PipelineOptions,
// -- GLSL options --
#[cfg(all(feature = "deserialize", glsl_out))] #[cfg(all(feature = "deserialize", glsl_out))]
#[serde(default)]
glsl: naga::back::glsl::Options, glsl: naga::back::glsl::Options,
#[serde(default)]
glsl_exclude_list: naga::FastHashSet<String>, glsl_exclude_list: naga::FastHashSet<String>,
#[cfg(all(feature = "deserialize", hlsl_out))]
#[serde(default)]
hlsl: naga::back::hlsl::Options,
#[serde(default)]
wgsl: WgslOutParameters,
#[cfg(all(feature = "deserialize", glsl_out))] #[cfg(all(feature = "deserialize", glsl_out))]
#[serde(default)]
glsl_multiview: Option<std::num::NonZeroU32>, glsl_multiview: Option<std::num::NonZeroU32>,
// -- HLSL options --
#[cfg(all(feature = "deserialize", hlsl_out))]
hlsl: naga::back::hlsl::Options,
// -- WGSL options --
wgsl: WgslOutParameters,
// -- General options --
#[cfg(feature = "deserialize")]
bounds_check_policies: naga::proc::BoundsCheckPolicies,
#[cfg(all(feature = "deserialize", any(hlsl_out, msl_out, spv_out, glsl_out)))] #[cfg(all(feature = "deserialize", any(hlsl_out, msl_out, spv_out, glsl_out)))]
#[serde(default)]
pipeline_constants: naga::back::PipelineConstants, pipeline_constants: naga::back::PipelineConstants,
} }