Improve logging

This commit is contained in:
hodasemi 2023-11-29 14:10:22 +01:00
parent 3fdc3a80eb
commit 469328b934
2 changed files with 27 additions and 16 deletions

View file

@ -55,7 +55,9 @@ extern "system" fn get_device_proc_addr(
_device: VkDevice,
function_name: *const c_char,
) -> PFN_vkVoidFunction {
write_log!("get_device_proc_addr");
if cfg!(debug_assertions) {
write_log!("get_device_proc_addr");
}
let func_string = match VkString::try_from(function_name) {
Ok(func) => func,
@ -67,7 +69,9 @@ extern "system" fn get_device_proc_addr(
let s = func_string.as_str();
write_log!(format!("\t{}", s));
if cfg!(debug_assertions) {
write_log!(format!("\t{}", s));
}
if let Some(func) = Functions::get_vk_func(s) {
return func.convert();
@ -77,7 +81,9 @@ extern "system" fn get_device_proc_addr(
return func;
}
write_log!("\t-> returning null");
if cfg!(debug_assertions) {
write_log!("\t-> returning null");
}
Functions::Null.convert()
}
@ -87,7 +93,9 @@ extern "system" fn get_instance_proc_addr(
_instance: VkInstance,
function_name: *const c_char,
) -> PFN_vkVoidFunction {
write_log!("get_instance_proc_addr");
if cfg!(debug_assertions) {
write_log!("get_instance_proc_addr");
}
let func_string = match VkString::try_from(function_name) {
Ok(func) => func,
@ -99,7 +107,9 @@ extern "system" fn get_instance_proc_addr(
let s = func_string.as_str();
write_log!(format!("\t{}", s));
if cfg!(debug_assertions) {
write_log!(format!("\t{}", s));
}
if let Some(func) = Functions::get_vk_func(s) {
return func.convert();
@ -109,7 +119,9 @@ extern "system" fn get_instance_proc_addr(
return func;
}
write_log!("\t-> returning null");
if cfg!(debug_assertions) {
write_log!("\t-> returning null");
}
Functions::Null.convert()
}
@ -366,14 +378,7 @@ pub(crate) extern "system" fn create_swapchain(
*p_swapchain
}));
let swapchain =
match unsafe { Swapchain::from_raw(OVERLAY.device(), &*create_info, *p_swapchain) } {
Ok(swapchain) => swapchain,
Err(err) => {
write_log!(format!("create swapchain failed: {:?}", err));
return VK_ERROR_INITIALIZATION_FAILED;
}
};
let swapchain = unsafe { Swapchain::from_raw(OVERLAY.device(), &*create_info, *p_swapchain) };
write_log!("-> created Arc<Swapchain>");

View file

@ -45,7 +45,10 @@ impl VkTypedefHandles {
let function = proc_addr(instance, name.as_ptr());
if mem::transmute::<PFN_vkVoidFunction, *const c_void>(function) != ptr::null() {
write_log!(format!("layer (instance): successfully read: {}", symbol));
if cfg!(debug_assertions) {
write_log!(format!("layer (instance): successfully read: {}", symbol));
}
self.functions.insert(symbol.clone(), function);
} else {
write_log!(format!("layer (instance): failed reading {}", symbol));
@ -61,7 +64,10 @@ impl VkTypedefHandles {
let function = proc_addr(device, name.as_ptr());
if mem::transmute::<PFN_vkVoidFunction, *const c_void>(function) != ptr::null() {
write_log!(format!("layer (device): successfully read: {}", symbol));
if cfg!(debug_assertions) {
write_log!(format!("layer (device): successfully read: {}", symbol));
}
self.functions.insert(symbol.clone(), function);
} else {
write_log!(format!("layer (device): failed reading {}", symbol));