diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 8bbc7d2..602e97d 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -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,