1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
use vk::*;
use VkHandle;
#[cfg(feature = "Implements")] use VkResultHandler;
use Instance;
#[cfg(feature = "Implements")] use std::ptr::{null, null_mut};
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(), 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 _
}