mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-22 15:01:31 +11:00
Check for None
in gfxGet{Instance|Device}ProcAddr
This commit is contained in:
parent
967cd9b445
commit
321cc54f81
|
@ -312,7 +312,7 @@ pub extern "C" fn gfxGetPhysicalDeviceMemoryProperties(
|
|||
}
|
||||
#[inline]
|
||||
pub extern "C" fn gfxGetInstanceProcAddr(
|
||||
_instance: VkInstance,
|
||||
instance: VkInstance,
|
||||
pName: *const ::std::os::raw::c_char,
|
||||
) -> PFN_vkVoidFunction {
|
||||
let name = unsafe { CStr::from_ptr(pName) };
|
||||
|
@ -326,6 +326,22 @@ pub extern "C" fn gfxGetInstanceProcAddr(
|
|||
return device_addr;
|
||||
}
|
||||
|
||||
match name {
|
||||
|
||||
"vkEnumerateInstanceVersion" |
|
||||
"vkEnumerateInstanceExtensionProperties" |
|
||||
"vkEnumerateInstanceLayerProperties" |
|
||||
"vkCreateInstance" => {
|
||||
// Instance is not required for these special cases
|
||||
// See https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetInstanceProcAddr.html
|
||||
},
|
||||
_ => {
|
||||
if instance.as_ref().is_none() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc_addr!{ name,
|
||||
vkCreateInstance, PFN_vkCreateInstance => gfxCreateInstance,
|
||||
vkDestroyInstance, PFN_vkDestroyInstance => gfxDestroyInstance,
|
||||
|
@ -360,7 +376,7 @@ pub extern "C" fn gfxGetInstanceProcAddr(
|
|||
|
||||
#[inline]
|
||||
pub extern "C" fn gfxGetDeviceProcAddr(
|
||||
_device: VkDevice,
|
||||
device: VkDevice,
|
||||
pName: *const ::std::os::raw::c_char,
|
||||
) -> PFN_vkVoidFunction {
|
||||
let name = unsafe { CStr::from_ptr(pName) };
|
||||
|
@ -369,6 +385,10 @@ pub extern "C" fn gfxGetDeviceProcAddr(
|
|||
Err(_) => return None,
|
||||
};
|
||||
|
||||
if device.as_ref().is_none() {
|
||||
return None;
|
||||
}
|
||||
|
||||
proc_addr!{ name,
|
||||
vkGetDeviceProcAddr, PFN_vkGetDeviceProcAddr => gfxGetDeviceProcAddr,
|
||||
vkDestroyDevice, PFN_vkDestroyDevice => gfxDestroyDevice,
|
||||
|
|
Loading…
Reference in a new issue