Optional flag/bitfield Debug impls

This commit is contained in:
Benjamin Saunders 2021-12-21 15:43:48 -08:00
parent 1700dcdf05
commit 45301fffa4
6 changed files with 172 additions and 133 deletions

View file

@ -25,6 +25,7 @@
* *
**********************************************************************************************************************/ **********************************************************************************************************************/
#[cfg(feature = "debug")]
use crate::prelude::debug_flags; use crate::prelude::debug_flags;
use crate::vk::*; use crate::vk::*;
@ -37,6 +38,7 @@ use std::os::raw::*;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct GpaSqShaderStageFlags(pub(crate) Flags); pub struct GpaSqShaderStageFlags(pub(crate) Flags);
vk_bitflags_wrapped!(GpaSqShaderStageFlags, Flags); vk_bitflags_wrapped!(GpaSqShaderStageFlags, Flags);
#[cfg(feature = "debug")]
impl fmt::Debug for GpaSqShaderStageFlags { impl fmt::Debug for GpaSqShaderStageFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
const KNOWN: &[(Flags, &str)] = &[ const KNOWN: &[(Flags, &str)] = &[
@ -69,7 +71,8 @@ impl StructureType {
pub const GPA_DEVICE_CLOCK_MODE_INFO_AMD: Self = Self(1000133004); pub const GPA_DEVICE_CLOCK_MODE_INFO_AMD: Self = Self(1000133004);
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[cfg_attr(feature = "debug", derive(Debug))]
#[repr(transparent)] #[repr(transparent)]
pub struct GpaDeviceClockModeAmd(pub(crate) i32); pub struct GpaDeviceClockModeAmd(pub(crate) i32);
impl GpaDeviceClockModeAmd { impl GpaDeviceClockModeAmd {
@ -89,7 +92,8 @@ impl GpaDeviceClockModeAmd {
pub const PEAK: Self = Self(5); pub const PEAK: Self = Self(5);
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[cfg_attr(feature = "debug", derive(Debug))]
#[repr(transparent)] #[repr(transparent)]
pub struct GpaPerfBlockAmd(pub(crate) i32); pub struct GpaPerfBlockAmd(pub(crate) i32);
impl GpaPerfBlockAmd { impl GpaPerfBlockAmd {
@ -135,7 +139,8 @@ impl GpaPerfBlockAmd {
pub const RMI: Self = Self(31); pub const RMI: Self = Self(31);
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[cfg_attr(feature = "debug", derive(Debug))]
#[repr(transparent)] #[repr(transparent)]
pub struct GpaSampleTypeAmd(pub(crate) i32); pub struct GpaSampleTypeAmd(pub(crate) i32);
impl GpaSampleTypeAmd { impl GpaSampleTypeAmd {
@ -155,7 +160,8 @@ impl GpaSampleTypeAmd {
handle_nondispatchable!(GpaSessionAmd, UNKNOWN); handle_nondispatchable!(GpaSessionAmd, UNKNOWN);
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaSessionCreateInfoAmd { pub struct GpaSessionCreateInfoAmd {
pub s_type: StructureType, pub s_type: StructureType,
pub p_next: *const c_void, pub p_next: *const c_void,
@ -163,7 +169,8 @@ pub struct GpaSessionCreateInfoAmd {
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaPerfBlockPropertiesAmd { pub struct GpaPerfBlockPropertiesAmd {
pub block_type: GpaPerfBlockAmd, pub block_type: GpaPerfBlockAmd,
pub flags: Flags, pub flags: Flags,
@ -175,7 +182,8 @@ pub struct GpaPerfBlockPropertiesAmd {
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct PhysicalDeviceGpaFeaturesAmd { pub struct PhysicalDeviceGpaFeaturesAmd {
pub s_type: StructureType, pub s_type: StructureType,
pub p_next: *const c_void, pub p_next: *const c_void,
@ -186,7 +194,8 @@ pub struct PhysicalDeviceGpaFeaturesAmd {
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct PhysicalDeviceGpaPropertiesAmd { pub struct PhysicalDeviceGpaPropertiesAmd {
pub s_type: StructureType, pub s_type: StructureType,
pub p_next: *const c_void, pub p_next: *const c_void,
@ -244,7 +253,8 @@ impl<'a> PhysicalDeviceGpaPropertiesAmdBuilder<'a> {
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaPerfCounterAmd { pub struct GpaPerfCounterAmd {
pub block_type: GpaPerfBlockAmd, pub block_type: GpaPerfBlockAmd,
pub block_instance: u32, pub block_instance: u32,
@ -252,7 +262,8 @@ pub struct GpaPerfCounterAmd {
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaSampleBeginInfoAmd { pub struct GpaSampleBeginInfoAmd {
pub s_type: StructureType, pub s_type: StructureType,
pub p_next: *const c_void, pub p_next: *const c_void,
@ -273,7 +284,8 @@ pub struct GpaSampleBeginInfoAmd {
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaDeviceClockModeInfoAmd { pub struct GpaDeviceClockModeInfoAmd {
pub s_type: StructureType, pub s_type: StructureType,
pub p_next: *const c_void, pub p_next: *const c_void,
@ -632,7 +644,8 @@ impl StructureType {
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct PhysicalDeviceWaveLimitPropertiesAmd { pub struct PhysicalDeviceWaveLimitPropertiesAmd {
pub s_type: StructureType, pub s_type: StructureType,
pub p_next: *const c_void, pub p_next: *const c_void,
@ -692,7 +705,8 @@ impl<'a> PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> {
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct PipelineShaderStageCreateInfoWaveLimitAmd { pub struct PipelineShaderStageCreateInfoWaveLimitAmd {
pub s_type: StructureType, pub s_type: StructureType,
pub p_next: *const c_void, pub p_next: *const c_void,

View file

@ -1,4 +1,5 @@
use std::convert::TryInto; use std::convert::TryInto;
#[cfg(feature = "debug")]
use std::fmt; use std::fmt;
use crate::vk; use crate::vk;
@ -83,6 +84,7 @@ where
} }
} }
#[cfg(feature = "debug")]
pub(crate) fn debug_flags<Value: Into<u64> + Copy>( pub(crate) fn debug_flags<Value: Into<u64> + Copy>(
f: &mut fmt::Formatter, f: &mut fmt::Formatter,
known: &[(Value, &'static str)], known: &[(Value, &'static str)],

View file

@ -10,6 +10,7 @@ mod aliases;
pub use aliases::*; pub use aliases::*;
mod bitflags; mod bitflags;
pub use bitflags::*; pub use bitflags::*;
#[cfg(feature = "debug")]
mod const_debugs; mod const_debugs;
mod constants; mod constants;
pub use constants::*; pub use constants::*;

View file

@ -2548,64 +2548,6 @@ impl fmt::Debug for MetalSurfaceCreateFlagsEXT {
debug_flags(f, KNOWN, self.0) debug_flags(f, KNOWN, self.0)
} }
} }
impl fmt::Debug for ObjectType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let name = match *self {
Self::UNKNOWN => Some("UNKNOWN"),
Self::INSTANCE => Some("INSTANCE"),
Self::PHYSICAL_DEVICE => Some("PHYSICAL_DEVICE"),
Self::DEVICE => Some("DEVICE"),
Self::QUEUE => Some("QUEUE"),
Self::SEMAPHORE => Some("SEMAPHORE"),
Self::COMMAND_BUFFER => Some("COMMAND_BUFFER"),
Self::FENCE => Some("FENCE"),
Self::DEVICE_MEMORY => Some("DEVICE_MEMORY"),
Self::BUFFER => Some("BUFFER"),
Self::IMAGE => Some("IMAGE"),
Self::EVENT => Some("EVENT"),
Self::QUERY_POOL => Some("QUERY_POOL"),
Self::BUFFER_VIEW => Some("BUFFER_VIEW"),
Self::IMAGE_VIEW => Some("IMAGE_VIEW"),
Self::SHADER_MODULE => Some("SHADER_MODULE"),
Self::PIPELINE_CACHE => Some("PIPELINE_CACHE"),
Self::PIPELINE_LAYOUT => Some("PIPELINE_LAYOUT"),
Self::RENDER_PASS => Some("RENDER_PASS"),
Self::PIPELINE => Some("PIPELINE"),
Self::DESCRIPTOR_SET_LAYOUT => Some("DESCRIPTOR_SET_LAYOUT"),
Self::SAMPLER => Some("SAMPLER"),
Self::DESCRIPTOR_POOL => Some("DESCRIPTOR_POOL"),
Self::DESCRIPTOR_SET => Some("DESCRIPTOR_SET"),
Self::FRAMEBUFFER => Some("FRAMEBUFFER"),
Self::COMMAND_POOL => Some("COMMAND_POOL"),
Self::SURFACE_KHR => Some("SURFACE_KHR"),
Self::SWAPCHAIN_KHR => Some("SWAPCHAIN_KHR"),
Self::DISPLAY_KHR => Some("DISPLAY_KHR"),
Self::DISPLAY_MODE_KHR => Some("DISPLAY_MODE_KHR"),
Self::DEBUG_REPORT_CALLBACK_EXT => Some("DEBUG_REPORT_CALLBACK_EXT"),
Self::VIDEO_SESSION_KHR => Some("VIDEO_SESSION_KHR"),
Self::VIDEO_SESSION_PARAMETERS_KHR => Some("VIDEO_SESSION_PARAMETERS_KHR"),
Self::CU_MODULE_NVX => Some("CU_MODULE_NVX"),
Self::CU_FUNCTION_NVX => Some("CU_FUNCTION_NVX"),
Self::DEBUG_UTILS_MESSENGER_EXT => Some("DEBUG_UTILS_MESSENGER_EXT"),
Self::ACCELERATION_STRUCTURE_KHR => Some("ACCELERATION_STRUCTURE_KHR"),
Self::VALIDATION_CACHE_EXT => Some("VALIDATION_CACHE_EXT"),
Self::ACCELERATION_STRUCTURE_NV => Some("ACCELERATION_STRUCTURE_NV"),
Self::PERFORMANCE_CONFIGURATION_INTEL => Some("PERFORMANCE_CONFIGURATION_INTEL"),
Self::DEFERRED_OPERATION_KHR => Some("DEFERRED_OPERATION_KHR"),
Self::INDIRECT_COMMANDS_LAYOUT_NV => Some("INDIRECT_COMMANDS_LAYOUT_NV"),
Self::PRIVATE_DATA_SLOT_EXT => Some("PRIVATE_DATA_SLOT_EXT"),
Self::BUFFER_COLLECTION_FUCHSIA => Some("BUFFER_COLLECTION_FUCHSIA"),
Self::SAMPLER_YCBCR_CONVERSION => Some("SAMPLER_YCBCR_CONVERSION"),
Self::DESCRIPTOR_UPDATE_TEMPLATE => Some("DESCRIPTOR_UPDATE_TEMPLATE"),
_ => None,
};
if let Some(x) = name {
f.write_str(x)
} else {
self.0.fmt(f)
}
}
}
impl fmt::Debug for PeerMemoryFeatureFlags { impl fmt::Debug for PeerMemoryFeatureFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
const KNOWN: &[(Flags, &str)] = &[ const KNOWN: &[(Flags, &str)] = &[
@ -3556,62 +3498,6 @@ impl fmt::Debug for ResolveModeFlags {
debug_flags(f, KNOWN, self.0) debug_flags(f, KNOWN, self.0)
} }
} }
impl fmt::Debug for Result {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let name = match *self {
Self::SUCCESS => Some("SUCCESS"),
Self::NOT_READY => Some("NOT_READY"),
Self::TIMEOUT => Some("TIMEOUT"),
Self::EVENT_SET => Some("EVENT_SET"),
Self::EVENT_RESET => Some("EVENT_RESET"),
Self::INCOMPLETE => Some("INCOMPLETE"),
Self::ERROR_OUT_OF_HOST_MEMORY => Some("ERROR_OUT_OF_HOST_MEMORY"),
Self::ERROR_OUT_OF_DEVICE_MEMORY => Some("ERROR_OUT_OF_DEVICE_MEMORY"),
Self::ERROR_INITIALIZATION_FAILED => Some("ERROR_INITIALIZATION_FAILED"),
Self::ERROR_DEVICE_LOST => Some("ERROR_DEVICE_LOST"),
Self::ERROR_MEMORY_MAP_FAILED => Some("ERROR_MEMORY_MAP_FAILED"),
Self::ERROR_LAYER_NOT_PRESENT => Some("ERROR_LAYER_NOT_PRESENT"),
Self::ERROR_EXTENSION_NOT_PRESENT => Some("ERROR_EXTENSION_NOT_PRESENT"),
Self::ERROR_FEATURE_NOT_PRESENT => Some("ERROR_FEATURE_NOT_PRESENT"),
Self::ERROR_INCOMPATIBLE_DRIVER => Some("ERROR_INCOMPATIBLE_DRIVER"),
Self::ERROR_TOO_MANY_OBJECTS => Some("ERROR_TOO_MANY_OBJECTS"),
Self::ERROR_FORMAT_NOT_SUPPORTED => Some("ERROR_FORMAT_NOT_SUPPORTED"),
Self::ERROR_FRAGMENTED_POOL => Some("ERROR_FRAGMENTED_POOL"),
Self::ERROR_UNKNOWN => Some("ERROR_UNKNOWN"),
Self::ERROR_SURFACE_LOST_KHR => Some("ERROR_SURFACE_LOST_KHR"),
Self::ERROR_NATIVE_WINDOW_IN_USE_KHR => Some("ERROR_NATIVE_WINDOW_IN_USE_KHR"),
Self::SUBOPTIMAL_KHR => Some("SUBOPTIMAL_KHR"),
Self::ERROR_OUT_OF_DATE_KHR => Some("ERROR_OUT_OF_DATE_KHR"),
Self::ERROR_INCOMPATIBLE_DISPLAY_KHR => Some("ERROR_INCOMPATIBLE_DISPLAY_KHR"),
Self::ERROR_VALIDATION_FAILED_EXT => Some("ERROR_VALIDATION_FAILED_EXT"),
Self::ERROR_INVALID_SHADER_NV => Some("ERROR_INVALID_SHADER_NV"),
Self::ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT => {
Some("ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT")
}
Self::ERROR_NOT_PERMITTED_EXT => Some("ERROR_NOT_PERMITTED_EXT"),
Self::ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT => {
Some("ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT")
}
Self::THREAD_IDLE_KHR => Some("THREAD_IDLE_KHR"),
Self::THREAD_DONE_KHR => Some("THREAD_DONE_KHR"),
Self::OPERATION_DEFERRED_KHR => Some("OPERATION_DEFERRED_KHR"),
Self::OPERATION_NOT_DEFERRED_KHR => Some("OPERATION_NOT_DEFERRED_KHR"),
Self::PIPELINE_COMPILE_REQUIRED_EXT => Some("PIPELINE_COMPILE_REQUIRED_EXT"),
Self::ERROR_OUT_OF_POOL_MEMORY => Some("ERROR_OUT_OF_POOL_MEMORY"),
Self::ERROR_INVALID_EXTERNAL_HANDLE => Some("ERROR_INVALID_EXTERNAL_HANDLE"),
Self::ERROR_FRAGMENTATION => Some("ERROR_FRAGMENTATION"),
Self::ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS => {
Some("ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS")
}
_ => None,
};
if let Some(x) = name {
f.write_str(x)
} else {
self.0.fmt(f)
}
}
}
impl fmt::Debug for SampleCountFlags { impl fmt::Debug for SampleCountFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
const KNOWN: &[(Flags, &str)] = &[ const KNOWN: &[(Flags, &str)] = &[

View file

@ -2242,3 +2242,117 @@ impl QueryResultStatusKHR {
pub const NOT_READY: Self = Self(0); pub const NOT_READY: Self = Self(0);
pub const COMPLETE: Self = Self(1); pub const COMPLETE: Self = Self(1);
} }
impl fmt::Debug for ObjectType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let name = match *self {
Self::UNKNOWN => Some("UNKNOWN"),
Self::INSTANCE => Some("INSTANCE"),
Self::PHYSICAL_DEVICE => Some("PHYSICAL_DEVICE"),
Self::DEVICE => Some("DEVICE"),
Self::QUEUE => Some("QUEUE"),
Self::SEMAPHORE => Some("SEMAPHORE"),
Self::COMMAND_BUFFER => Some("COMMAND_BUFFER"),
Self::FENCE => Some("FENCE"),
Self::DEVICE_MEMORY => Some("DEVICE_MEMORY"),
Self::BUFFER => Some("BUFFER"),
Self::IMAGE => Some("IMAGE"),
Self::EVENT => Some("EVENT"),
Self::QUERY_POOL => Some("QUERY_POOL"),
Self::BUFFER_VIEW => Some("BUFFER_VIEW"),
Self::IMAGE_VIEW => Some("IMAGE_VIEW"),
Self::SHADER_MODULE => Some("SHADER_MODULE"),
Self::PIPELINE_CACHE => Some("PIPELINE_CACHE"),
Self::PIPELINE_LAYOUT => Some("PIPELINE_LAYOUT"),
Self::RENDER_PASS => Some("RENDER_PASS"),
Self::PIPELINE => Some("PIPELINE"),
Self::DESCRIPTOR_SET_LAYOUT => Some("DESCRIPTOR_SET_LAYOUT"),
Self::SAMPLER => Some("SAMPLER"),
Self::DESCRIPTOR_POOL => Some("DESCRIPTOR_POOL"),
Self::DESCRIPTOR_SET => Some("DESCRIPTOR_SET"),
Self::FRAMEBUFFER => Some("FRAMEBUFFER"),
Self::COMMAND_POOL => Some("COMMAND_POOL"),
Self::SURFACE_KHR => Some("SURFACE_KHR"),
Self::SWAPCHAIN_KHR => Some("SWAPCHAIN_KHR"),
Self::DISPLAY_KHR => Some("DISPLAY_KHR"),
Self::DISPLAY_MODE_KHR => Some("DISPLAY_MODE_KHR"),
Self::DEBUG_REPORT_CALLBACK_EXT => Some("DEBUG_REPORT_CALLBACK_EXT"),
Self::VIDEO_SESSION_KHR => Some("VIDEO_SESSION_KHR"),
Self::VIDEO_SESSION_PARAMETERS_KHR => Some("VIDEO_SESSION_PARAMETERS_KHR"),
Self::CU_MODULE_NVX => Some("CU_MODULE_NVX"),
Self::CU_FUNCTION_NVX => Some("CU_FUNCTION_NVX"),
Self::DEBUG_UTILS_MESSENGER_EXT => Some("DEBUG_UTILS_MESSENGER_EXT"),
Self::ACCELERATION_STRUCTURE_KHR => Some("ACCELERATION_STRUCTURE_KHR"),
Self::VALIDATION_CACHE_EXT => Some("VALIDATION_CACHE_EXT"),
Self::ACCELERATION_STRUCTURE_NV => Some("ACCELERATION_STRUCTURE_NV"),
Self::PERFORMANCE_CONFIGURATION_INTEL => Some("PERFORMANCE_CONFIGURATION_INTEL"),
Self::DEFERRED_OPERATION_KHR => Some("DEFERRED_OPERATION_KHR"),
Self::INDIRECT_COMMANDS_LAYOUT_NV => Some("INDIRECT_COMMANDS_LAYOUT_NV"),
Self::PRIVATE_DATA_SLOT_EXT => Some("PRIVATE_DATA_SLOT_EXT"),
Self::BUFFER_COLLECTION_FUCHSIA => Some("BUFFER_COLLECTION_FUCHSIA"),
Self::SAMPLER_YCBCR_CONVERSION => Some("SAMPLER_YCBCR_CONVERSION"),
Self::DESCRIPTOR_UPDATE_TEMPLATE => Some("DESCRIPTOR_UPDATE_TEMPLATE"),
_ => None,
};
if let Some(x) = name {
f.write_str(x)
} else {
self.0.fmt(f)
}
}
}
impl fmt::Debug for Result {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let name = match *self {
Self::SUCCESS => Some("SUCCESS"),
Self::NOT_READY => Some("NOT_READY"),
Self::TIMEOUT => Some("TIMEOUT"),
Self::EVENT_SET => Some("EVENT_SET"),
Self::EVENT_RESET => Some("EVENT_RESET"),
Self::INCOMPLETE => Some("INCOMPLETE"),
Self::ERROR_OUT_OF_HOST_MEMORY => Some("ERROR_OUT_OF_HOST_MEMORY"),
Self::ERROR_OUT_OF_DEVICE_MEMORY => Some("ERROR_OUT_OF_DEVICE_MEMORY"),
Self::ERROR_INITIALIZATION_FAILED => Some("ERROR_INITIALIZATION_FAILED"),
Self::ERROR_DEVICE_LOST => Some("ERROR_DEVICE_LOST"),
Self::ERROR_MEMORY_MAP_FAILED => Some("ERROR_MEMORY_MAP_FAILED"),
Self::ERROR_LAYER_NOT_PRESENT => Some("ERROR_LAYER_NOT_PRESENT"),
Self::ERROR_EXTENSION_NOT_PRESENT => Some("ERROR_EXTENSION_NOT_PRESENT"),
Self::ERROR_FEATURE_NOT_PRESENT => Some("ERROR_FEATURE_NOT_PRESENT"),
Self::ERROR_INCOMPATIBLE_DRIVER => Some("ERROR_INCOMPATIBLE_DRIVER"),
Self::ERROR_TOO_MANY_OBJECTS => Some("ERROR_TOO_MANY_OBJECTS"),
Self::ERROR_FORMAT_NOT_SUPPORTED => Some("ERROR_FORMAT_NOT_SUPPORTED"),
Self::ERROR_FRAGMENTED_POOL => Some("ERROR_FRAGMENTED_POOL"),
Self::ERROR_UNKNOWN => Some("ERROR_UNKNOWN"),
Self::ERROR_SURFACE_LOST_KHR => Some("ERROR_SURFACE_LOST_KHR"),
Self::ERROR_NATIVE_WINDOW_IN_USE_KHR => Some("ERROR_NATIVE_WINDOW_IN_USE_KHR"),
Self::SUBOPTIMAL_KHR => Some("SUBOPTIMAL_KHR"),
Self::ERROR_OUT_OF_DATE_KHR => Some("ERROR_OUT_OF_DATE_KHR"),
Self::ERROR_INCOMPATIBLE_DISPLAY_KHR => Some("ERROR_INCOMPATIBLE_DISPLAY_KHR"),
Self::ERROR_VALIDATION_FAILED_EXT => Some("ERROR_VALIDATION_FAILED_EXT"),
Self::ERROR_INVALID_SHADER_NV => Some("ERROR_INVALID_SHADER_NV"),
Self::ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT => {
Some("ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT")
}
Self::ERROR_NOT_PERMITTED_EXT => Some("ERROR_NOT_PERMITTED_EXT"),
Self::ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT => {
Some("ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT")
}
Self::THREAD_IDLE_KHR => Some("THREAD_IDLE_KHR"),
Self::THREAD_DONE_KHR => Some("THREAD_DONE_KHR"),
Self::OPERATION_DEFERRED_KHR => Some("OPERATION_DEFERRED_KHR"),
Self::OPERATION_NOT_DEFERRED_KHR => Some("OPERATION_NOT_DEFERRED_KHR"),
Self::PIPELINE_COMPILE_REQUIRED_EXT => Some("PIPELINE_COMPILE_REQUIRED_EXT"),
Self::ERROR_OUT_OF_POOL_MEMORY => Some("ERROR_OUT_OF_POOL_MEMORY"),
Self::ERROR_INVALID_EXTERNAL_HANDLE => Some("ERROR_INVALID_EXTERNAL_HANDLE"),
Self::ERROR_FRAGMENTATION => Some("ERROR_FRAGMENTATION"),
Self::ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS => {
Some("ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS")
}
_ => None,
};
if let Some(x) = name {
f.write_str(x)
} else {
self.0.fmt(f)
}
}
}

View file

@ -2407,10 +2407,17 @@ pub struct ConstantTypeInfo {
bitwidth: Option<u32>, bitwidth: Option<u32>,
} }
pub fn generate_const_debugs(const_values: &BTreeMap<Ident, ConstantTypeInfo>) -> TokenStream { pub struct ConstDebugs {
let impls = const_values.iter().map(|(ty, values)| { core: TokenStream,
extras: TokenStream,
}
pub fn generate_const_debugs(const_values: &BTreeMap<Ident, ConstantTypeInfo>) -> ConstDebugs {
let mut core = Vec::new();
let mut extras = Vec::new();
for (ty, values) in const_values {
let ConstantTypeInfo { values, bitwidth } = values; let ConstantTypeInfo { values, bitwidth } = values;
if ty.to_string().contains("Flags") { let out = if ty.to_string().contains("Flags") {
let cases = values.iter().filter_map(|value| { let cases = values.iter().filter_map(|value| {
if value.is_alias { if value.is_alias {
None None
@ -2460,10 +2467,21 @@ pub fn generate_const_debugs(const_values: &BTreeMap<Ident, ConstantTypeInfo>) -
} }
} }
} }
};
if ty == "Result" || ty == "ObjectType" {
core.push(out);
} else {
extras.push(out);
} }
}); }
quote! {
#(#impls)* ConstDebugs {
core: quote! {
#(#core)*
},
extras: quote! {
#(#extras)*
},
} }
} }
pub fn extract_native_types(registry: &vk_parse::Registry) -> (Vec<(String, String)>, Vec<String>) { pub fn extract_native_types(registry: &vk_parse::Registry) -> (Vec<(String, String)>, Vec<String>) {
@ -2708,7 +2726,10 @@ pub fn write_source_code<P: AsRef<Path>>(vk_headers_dir: &Path, src_dir: P) {
let feature_extensions_code = let feature_extensions_code =
generate_feature_extension(&spec2, &mut const_cache, &mut const_values); generate_feature_extension(&spec2, &mut const_cache, &mut const_values);
let const_debugs = generate_const_debugs(&const_values); let ConstDebugs {
core: core_debugs,
extras: const_debugs,
} = generate_const_debugs(&const_values);
let bitflags_macro = vk_bitflags_wrapped_macro(); let bitflags_macro = vk_bitflags_wrapped_macro();
let handle_nondispatchable_macro = handle_nondispatchable_macro(); let handle_nondispatchable_macro = handle_nondispatchable_macro();
@ -2765,6 +2786,7 @@ pub fn write_source_code<P: AsRef<Path>>(vk_headers_dir: &Path, src_dir: P) {
let enum_code = quote! { let enum_code = quote! {
use std::fmt; use std::fmt;
#(#enum_code)* #(#enum_code)*
#core_debugs
}; };
let bitflags_code = quote! { let bitflags_code = quote! {