mirror of
https://github.com/italicsjenga/portability.git
synced 2025-02-17 06:37:43 +11:00
Check for None
in gfxGet{Instance|Device}ProcAddr
This commit is contained in:
parent
967cd9b445
commit
321cc54f81
1 changed files with 22 additions and 2 deletions
|
@ -312,7 +312,7 @@ pub extern "C" fn gfxGetPhysicalDeviceMemoryProperties(
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxGetInstanceProcAddr(
|
pub extern "C" fn gfxGetInstanceProcAddr(
|
||||||
_instance: VkInstance,
|
instance: VkInstance,
|
||||||
pName: *const ::std::os::raw::c_char,
|
pName: *const ::std::os::raw::c_char,
|
||||||
) -> PFN_vkVoidFunction {
|
) -> PFN_vkVoidFunction {
|
||||||
let name = unsafe { CStr::from_ptr(pName) };
|
let name = unsafe { CStr::from_ptr(pName) };
|
||||||
|
@ -326,6 +326,22 @@ pub extern "C" fn gfxGetInstanceProcAddr(
|
||||||
return device_addr;
|
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,
|
proc_addr!{ name,
|
||||||
vkCreateInstance, PFN_vkCreateInstance => gfxCreateInstance,
|
vkCreateInstance, PFN_vkCreateInstance => gfxCreateInstance,
|
||||||
vkDestroyInstance, PFN_vkDestroyInstance => gfxDestroyInstance,
|
vkDestroyInstance, PFN_vkDestroyInstance => gfxDestroyInstance,
|
||||||
|
@ -360,7 +376,7 @@ pub extern "C" fn gfxGetInstanceProcAddr(
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxGetDeviceProcAddr(
|
pub extern "C" fn gfxGetDeviceProcAddr(
|
||||||
_device: VkDevice,
|
device: VkDevice,
|
||||||
pName: *const ::std::os::raw::c_char,
|
pName: *const ::std::os::raw::c_char,
|
||||||
) -> PFN_vkVoidFunction {
|
) -> PFN_vkVoidFunction {
|
||||||
let name = unsafe { CStr::from_ptr(pName) };
|
let name = unsafe { CStr::from_ptr(pName) };
|
||||||
|
@ -369,6 +385,10 @@ pub extern "C" fn gfxGetDeviceProcAddr(
|
||||||
Err(_) => return None,
|
Err(_) => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if device.as_ref().is_none() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
proc_addr!{ name,
|
proc_addr!{ name,
|
||||||
vkGetDeviceProcAddr, PFN_vkGetDeviceProcAddr => gfxGetDeviceProcAddr,
|
vkGetDeviceProcAddr, PFN_vkGetDeviceProcAddr => gfxGetDeviceProcAddr,
|
||||||
vkDestroyDevice, PFN_vkDestroyDevice => gfxDestroyDevice,
|
vkDestroyDevice, PFN_vkDestroyDevice => gfxDestroyDevice,
|
||||||
|
|
Loading…
Add table
Reference in a new issue