Skip to content

Commit

Permalink
Optional flag/bitfield Debug impls
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Dec 22, 2021
1 parent 1700dcd commit 45301ff
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 133 deletions.
38 changes: 26 additions & 12 deletions ash/src/extensions/experimental/amd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*
**********************************************************************************************************************/

#[cfg(feature = "debug")]
use crate::prelude::debug_flags;
use crate::vk::*;

Expand All @@ -37,6 +38,7 @@ use std::os::raw::*;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct GpaSqShaderStageFlags(pub(crate) Flags);
vk_bitflags_wrapped!(GpaSqShaderStageFlags, Flags);
#[cfg(feature = "debug")]
impl fmt::Debug for GpaSqShaderStageFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
const KNOWN: &[(Flags, &str)] = &[
Expand Down Expand Up @@ -69,7 +71,8 @@ impl StructureType {
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)]
pub struct GpaDeviceClockModeAmd(pub(crate) i32);
impl GpaDeviceClockModeAmd {
Expand All @@ -89,7 +92,8 @@ impl GpaDeviceClockModeAmd {
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)]
pub struct GpaPerfBlockAmd(pub(crate) i32);
impl GpaPerfBlockAmd {
Expand Down Expand Up @@ -135,7 +139,8 @@ impl GpaPerfBlockAmd {
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)]
pub struct GpaSampleTypeAmd(pub(crate) i32);
impl GpaSampleTypeAmd {
Expand All @@ -155,15 +160,17 @@ impl GpaSampleTypeAmd {
handle_nondispatchable!(GpaSessionAmd, UNKNOWN);

#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaSessionCreateInfoAmd {
pub s_type: StructureType,
pub p_next: *const c_void,
pub secondary_copy_source: GpaSessionAmd,
}

#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaPerfBlockPropertiesAmd {
pub block_type: GpaPerfBlockAmd,
pub flags: Flags,
Expand All @@ -175,7 +182,8 @@ pub struct GpaPerfBlockPropertiesAmd {
}

#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct PhysicalDeviceGpaFeaturesAmd {
pub s_type: StructureType,
pub p_next: *const c_void,
Expand All @@ -186,7 +194,8 @@ pub struct PhysicalDeviceGpaFeaturesAmd {
}

#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct PhysicalDeviceGpaPropertiesAmd {
pub s_type: StructureType,
pub p_next: *const c_void,
Expand Down Expand Up @@ -244,15 +253,17 @@ impl<'a> PhysicalDeviceGpaPropertiesAmdBuilder<'a> {
}

#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaPerfCounterAmd {
pub block_type: GpaPerfBlockAmd,
pub block_instance: u32,
pub event_id: u32,
}

#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaSampleBeginInfoAmd {
pub s_type: StructureType,
pub p_next: *const c_void,
Expand All @@ -273,7 +284,8 @@ pub struct GpaSampleBeginInfoAmd {
}

#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct GpaDeviceClockModeInfoAmd {
pub s_type: StructureType,
pub p_next: *const c_void,
Expand Down Expand Up @@ -632,7 +644,8 @@ impl StructureType {
}

#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct PhysicalDeviceWaveLimitPropertiesAmd {
pub s_type: StructureType,
pub p_next: *const c_void,
Expand Down Expand Up @@ -692,7 +705,8 @@ impl<'a> PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> {
}

#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct PipelineShaderStageCreateInfoWaveLimitAmd {
pub s_type: StructureType,
pub p_next: *const c_void,
Expand Down
2 changes: 2 additions & 0 deletions ash/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::convert::TryInto;
#[cfg(feature = "debug")]
use std::fmt;

use crate::vk;
Expand Down Expand Up @@ -83,6 +84,7 @@ where
}
}

#[cfg(feature = "debug")]
pub(crate) fn debug_flags<Value: Into<u64> + Copy>(
f: &mut fmt::Formatter,
known: &[(Value, &'static str)],
Expand Down
1 change: 1 addition & 0 deletions ash/src/vk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod aliases;
pub use aliases::*;
mod bitflags;
pub use bitflags::*;
#[cfg(feature = "debug")]
mod const_debugs;
mod constants;
pub use constants::*;
Expand Down
114 changes: 0 additions & 114 deletions ash/src/vk/const_debugs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2548,64 +2548,6 @@ impl fmt::Debug for MetalSurfaceCreateFlagsEXT {
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 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
const KNOWN: &[(Flags, &str)] = &[
Expand Down Expand Up @@ -3556,62 +3498,6 @@ impl fmt::Debug for ResolveModeFlags {
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 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
const KNOWN: &[(Flags, &str)] = &[
Expand Down
Loading

0 comments on commit 45301ff

Please sign in to comment.