use vk::*;
use VkHandle;
#[cfg(feature = "Implements")] use VkResultHandler;
use Instance;
pub struct DebugReportCallback(VkDebugReportCallbackEXT, ::Instance, PFN_vkDestroyDebugReportCallbackEXT);
#[cfg(feature = "Implements")]
impl Drop for DebugReportCallback
{
fn drop(&mut self) { (self.2)(self.1.native_ptr(), self.native_ptr(), ::std::ptr::null()); }
}
impl VkHandle for DebugReportCallback { type Handle = VkDebugReportCallbackEXT; fn native_ptr(&self) -> VkDebugReportCallbackEXT { self.0 } }
pub struct DebugReportCallbackBuilder<'i>
{
#[cfg_attr(not(feature = "Implements"), allow(dead_code))]
instance: &'i Instance,
flags: VkDebugReportFlagsEXT,
#[cfg_attr(not(feature = "Implements"), allow(dead_code))]
callback: PFN_vkDebugReportCallbackEXT
}
impl<'i> DebugReportCallbackBuilder<'i>
{
pub fn new(instance: &'i Instance, callback: PFN_vkDebugReportCallbackEXT) -> Self
{
DebugReportCallbackBuilder { instance, flags: 0, callback }
}
pub fn report_error(&mut self) -> &mut Self { self.flags |= VK_DEBUG_REPORT_ERROR_BIT_EXT; self }
pub fn report_warning(&mut self) -> &mut Self { self.flags |= VK_DEBUG_REPORT_WARNING_BIT_EXT; self }
pub fn report_performance_warning(&mut self) -> &mut Self { self.flags |= VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; self }
pub fn report_information(&mut self) -> &mut Self { self.flags |= VK_DEBUG_REPORT_INFORMATION_BIT_EXT; self }
pub fn report_debug_information(&mut self) -> &mut Self { self.flags |= VK_DEBUG_REPORT_DEBUG_BIT_EXT; self }
#[cfg(feature = "Implements")]
pub fn create(&mut self) -> ::Result<DebugReportCallback> { DebugReportCallback::new(self.instance, self.flags, self.callback) }
}
#[cfg(feature = "Implements")]
impl DebugReportCallback
{
fn new(instance: &::Instance, flags: VkDebugReportFlagsEXT, callback: PFN_vkDebugReportCallbackEXT) -> ::Result<Self>
{
let ctor: PFN_vkCreateDebugReportCallbackEXT = instance.extra_procedure("vkCreateDebugReportCallbackEXT")
.expect("Requiring vkCreateDebugReportCallbackEXT function");
let dtor: PFN_vkDestroyDebugReportCallbackEXT = instance.extra_procedure("vkDestroyDebugReportCallbackEXT")
.expect("Requiring vkDestroyDebugReportCallbackEXT function");
let s = VkDebugReportCallbackCreateInfoEXT { flags, pfnCallback: callback, .. Default::default() };
let mut h = VK_NULL_HANDLE as _;
ctor(instance.native_ptr(), &s, ::std::ptr::null(), &mut h).into_result().map(|_| DebugReportCallback(h, instance.clone(), dtor))
}
}
#[cfg(feature = "Implements")]
impl Instance
{
pub fn debug_message(&self, flags: VkDebugReportFlagsEXT, object_type: DebugReportObjectType, object: u64, location: ::libc::size_t,
message_count: i32, layer_prefix: &str, message: &str)
{
use std::ffi::CString;
let (lp, msg) = (CString::new(layer_prefix).unwrap(), CString::new(message).unwrap());
let msgf: PFN_vkDebugReportMessageEXT = self.extra_procedure("vkDebugReportMessageEXT")
.expect("Requiring vkDebugReportMessageEXT function");
msgf(self.native_ptr(), flags, object_type as _, object, location, message_count, lp.as_ptr(), msg.as_ptr());
}
}
#[repr(C)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DebugReportObjectType
{
Unknown = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT as _,
Instance = VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT as _,
PhysicalDevice = VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT as _,
Device = VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT as _,
Queue = VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT as _,
Semaphore = VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT as _,
CommandBuffer = VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT as _,
Fence = VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT as _,
DeviceMemory = VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT as _,
Buffer = VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT as _,
Image = VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT as _,
Event = VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT as _,
QueryPool = VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT as _,
BufferView = VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT as _,
ImageView = VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT as _,
ShaderModule = VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT as _,
PipelineCache = VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT as _,
PipelineLayout = VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT as _,
RenderPass = VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT as _,
Pipeline = VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT as _,
DescriptorSetLayout = VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT as _,
Sampler = VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT as _,
DescriptorPool = VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT as _,
DescriptorSet = VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT as _,
Framebuffer = VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT as _,
CommandPool = VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT as _,
Surface = VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT as _,
Swapchain = VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT as _,
DebugReport = VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT as _
}