diff --git a/ash/src/vk/bitflags.rs b/ash/src/vk/bitflags.rs index 88f210d..fdb7704 100644 --- a/ash/src/vk/bitflags.rs +++ b/ash/src/vk/bitflags.rs @@ -498,8 +498,6 @@ impl StencilFaceFlags { pub const BACK: Self = Self(0b10); #[doc = "Front and back faces"] pub const FRONT_AND_BACK: Self = Self(0x0000_0003); - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const STENCIL_FRONT_AND_BACK: Self = Self::FRONT_AND_BACK; } #[repr(transparent)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/ash/src/vk/enums.rs b/ash/src/vk/enums.rs index c69bf17..00fbbb3 100644 --- a/ash/src/vk/enums.rs +++ b/ash/src/vk/enums.rs @@ -1090,8 +1090,6 @@ impl ColorSpaceKHR { } impl ColorSpaceKHR { pub const SRGB_NONLINEAR: Self = Self(0); - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const COLORSPACE_SRGB_NONLINEAR: Self = Self::SRGB_NONLINEAR; } #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] @@ -1153,13 +1151,9 @@ impl DebugReportObjectTypeEXT { pub const SURFACE_KHR: Self = Self(26); pub const SWAPCHAIN_KHR: Self = Self(27); pub const DEBUG_REPORT_CALLBACK_EXT: Self = Self(28); - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const DEBUG_REPORT: Self = Self::DEBUG_REPORT_CALLBACK_EXT; pub const DISPLAY_KHR: Self = Self(29); pub const DISPLAY_MODE_KHR: Self = Self(30); pub const VALIDATION_CACHE_EXT: Self = Self(33); - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const VALIDATION_CACHE: Self = Self::VALIDATION_CACHE_EXT; } #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] @@ -1957,12 +1951,6 @@ impl PerformanceCounterScopeKHR { pub const COMMAND_BUFFER: Self = Self(0); pub const RENDER_PASS: Self = Self(1); pub const COMMAND: Self = Self(2); - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const QUERY_SCOPE_COMMAND_BUFFER: Self = Self::COMMAND_BUFFER; - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const QUERY_SCOPE_RENDER_PASS: Self = Self::RENDER_PASS; - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const QUERY_SCOPE_COMMAND: Self = Self::COMMAND; } #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] diff --git a/ash/src/vk/extensions.rs b/ash/src/vk/extensions.rs index 3dd0ac0..05925c4 100644 --- a/ash/src/vk/extensions.rs +++ b/ash/src/vk/extensions.rs @@ -1972,11 +1972,6 @@ impl StructureType { pub const DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT: Self = Self(1_000_011_000); } #[doc = "Generated from 'VK_EXT_debug_report'"] -impl StructureType { - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const DEBUG_REPORT_CREATE_INFO_EXT: Self = Self::DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; -} -#[doc = "Generated from 'VK_EXT_debug_report'"] impl Result { pub const ERROR_VALIDATION_FAILED_EXT: Self = Self(-1_000_011_001); } @@ -4479,12 +4474,6 @@ impl PipelineCreateFlags { Self(0b10_0000_0000_0000_0000_0000); } #[doc = "Generated from 'VK_KHR_dynamic_rendering'"] -impl PipelineCreateFlags { - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const RASTERIZATION_STATE_FRAGMENT_SHADING_RATE_ATTACHMENT_KHR: Self = - Self::RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_KHR; -} -#[doc = "Generated from 'VK_KHR_dynamic_rendering'"] impl StructureType { pub const RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR: Self = Self(1_000_044_006); } @@ -4494,12 +4483,6 @@ impl PipelineCreateFlags { Self(0b100_0000_0000_0000_0000_0000); } #[doc = "Generated from 'VK_KHR_dynamic_rendering'"] -impl PipelineCreateFlags { - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const RASTERIZATION_STATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_EXT: Self = - Self::RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_EXT; -} -#[doc = "Generated from 'VK_KHR_dynamic_rendering'"] impl StructureType { pub const RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_INFO_EXT: Self = Self(1_000_044_007); } @@ -7691,11 +7674,6 @@ impl ExtDisplaySurfaceCounterFn { impl StructureType { pub const SURFACE_CAPABILITIES_2_EXT: Self = Self(1_000_090_000); } -#[doc = "Generated from 'VK_EXT_display_surface_counter'"] -impl StructureType { - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const SURFACE_CAPABILITIES2_EXT: Self = Self::SURFACE_CAPABILITIES_2_EXT; -} impl ExtDisplayControlFn { pub fn name() -> &'static ::std::ffi::CStr { ::std::ffi::CStr::from_bytes_with_nul(b"VK_EXT_display_control\0") @@ -8359,11 +8337,6 @@ impl ColorSpaceKHR { impl ColorSpaceKHR { pub const EXTENDED_SRGB_NONLINEAR_EXT: Self = Self(1_000_104_014); } -#[doc = "Generated from 'VK_EXT_swapchain_colorspace'"] -impl ColorSpaceKHR { - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const DCI_P3_LINEAR_EXT: Self = Self::DISPLAY_P3_LINEAR_EXT; -} impl ExtHdrMetadataFn { pub fn name() -> &'static ::std::ffi::CStr { ::std::ffi::CStr::from_bytes_with_nul(b"VK_EXT_hdr_metadata\0") @@ -16898,12 +16871,6 @@ impl StructureType { pub const QUERY_POOL_PERFORMANCE_QUERY_CREATE_INFO_INTEL: Self = Self(1_000_210_000); } #[doc = "Generated from 'VK_INTEL_performance_query'"] -impl StructureType { - #[deprecated = "Backwards-compatible alias containing a typo"] - pub const QUERY_POOL_CREATE_INFO_INTEL: Self = - Self::QUERY_POOL_PERFORMANCE_QUERY_CREATE_INFO_INTEL; -} -#[doc = "Generated from 'VK_INTEL_performance_query'"] impl StructureType { pub const INITIALIZE_PERFORMANCE_API_INFO_INTEL: Self = Self(1_000_210_001); } diff --git a/generator/src/lib.rs b/generator/src/lib.rs index cc36833..f128afd 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -18,6 +18,8 @@ use std::hash::BuildHasher; use std::path::Path; use syn::Ident; +const BACKWARDS_COMPATIBLE_ALIAS_COMMENT: &str = "Backwards-compatible alias containing a typo"; + pub trait ExtensionExt {} #[derive(Copy, Clone, Debug)] pub enum CType { @@ -360,8 +362,13 @@ pub trait ConstantExt { false } fn doc_attribute(&self) -> TokenStream { + assert_ne!( + self.notation(), + Some(BACKWARDS_COMPATIBLE_ALIAS_COMMENT), + "Backwards-compatible constants should not be emitted" + ); match self.notation() { - Some(n) if n.starts_with("Backwards") || n.starts_with("Alias") => { + Some(n) if n.starts_with("Alias") => { quote!(#[deprecated = #n]) } Some(n) => quote!(#[doc = #n]), @@ -384,7 +391,7 @@ impl ConstantExt for vkxml::ExtensionEnum { impl ConstantExt for vk_parse::Enum { fn constant(&self, enum_name: &str) -> Constant { - Constant::from_vk_parse_enum_spec(&self.spec, Some(enum_name), None) + Constant::from_vk_parse_enum(self, Some(enum_name), None) .unwrap() .0 } @@ -517,14 +524,14 @@ impl Constant { } /// Returns (Constant, optional base type, is_alias) - pub fn from_vk_parse_enum_spec( - spec: &vk_parse::EnumSpec, + pub fn from_vk_parse_enum( + enum_: &vk_parse::Enum, enum_name: Option<&str>, extension_number: Option, ) -> Option<(Self, Option, bool)> { use vk_parse::EnumSpec; - match spec { + match &enum_.spec { EnumSpec::Bitpos { bitpos, extends } => { Some((Self::BitPos(*bitpos as u32), extends.clone(), false)) } @@ -1107,8 +1114,12 @@ pub fn generate_extension_constants<'a>( return None; } + if enum_.comment.as_deref() == Some(BACKWARDS_COMPATIBLE_ALIAS_COMMENT) { + return None; + } + let (constant, extends, is_alias) = - Constant::from_vk_parse_enum_spec(&enum_.spec, None, Some(extension_number))?; + Constant::from_vk_parse_enum(enum_, None, Some(extension_number))?; let extends = extends?; let ext_constant = ExtensionConstant { name: &enum_.name, @@ -1353,19 +1364,6 @@ pub enum EnumType { Enum(TokenStream), } -fn is_enum_variant_with_typo(variant_name: &str) -> bool { - // All these names are aliases and make little sense in our - // enum structure, they are better omitted entirely. - matches!( - variant_name, - "VK_STENCIL_FRONT_AND_BACK" - | "VK_COLORSPACE_SRGB_NONLINEAR" - | "VK_QUERY_SCOPE_COMMAND_BUFFER" - | "VK_QUERY_SCOPE_RENDER_PASS" - | "VK_QUERY_SCOPE_COMMAND" - ) -} - static TRAILING_NUMBER: Lazy = Lazy::new(|| Regex::new("(\\d+)$").unwrap()); pub fn variant_ident(enum_name: &str, variant_name: &str) -> Ident { @@ -1392,16 +1390,8 @@ pub fn variant_ident(enum_name: &str, variant_name: &str) -> Ident { let new_variant_name = variant_name .strip_prefix(struct_name.as_ref()) .unwrap_or_else(|| { - if enum_name == "VkResult" || is_enum_variant_with_typo(variant_name) { + if enum_name == "VkResult" { variant_name.strip_prefix("VK").unwrap() - } else if variant_name - == "VK_PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR" - { - "_RASTERIZATION_STATE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR" - } else if variant_name - == "VK_PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT" - { - "_RASTERIZATION_STATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT" } else { panic!( "Failed to strip {} prefix from enum variant {}", @@ -1434,6 +1424,7 @@ pub fn bitflags_impl_block( ) -> TokenStream { let variants = constants .iter() + .filter(|constant| constant.notation() != Some(BACKWARDS_COMPATIBLE_ALIAS_COMMENT)) .map(|constant| { let variant_ident = constant.variant_ident(enum_name); let constant = constant.constant(enum_name); @@ -1482,6 +1473,7 @@ pub fn generate_enum<'a>( vk_parse::EnumsChild::Enum(ref constant) => Some(constant), _ => None, }) + .filter(|constant| constant.notation() != Some(BACKWARDS_COMPATIBLE_ALIAS_COMMENT)) .filter(|constant| match &constant.spec { vk_parse::EnumSpec::Alias { alias, .. } => { // Remove any alias whose name is identical after name de-mangling. For example