diff options
author | Simon Ser <contact@emersion.fr> | 2022-11-06 15:33:40 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-11-11 19:18:04 +0000 |
commit | f92d1499cd8582949a3c08edbf3db7d4a4471360 (patch) | |
tree | 6a7763cfca484c39076738c2b11b73db5020baee /render/vulkan | |
parent | 5b23987349dde587100c792bb6d180c930e6f2bd (diff) |
render/vulkan: add helper to load command function pointer
If NULL is returned by vkGetDeviceProcAddr(), either the driver
is buggy, either the wlroots code is buggy. For a valid device and
command name, drivers are not allowed to return NULL per the spec.
This mirrors what the GLES2 renderer does in load_gl_proc().
Diffstat (limited to 'render/vulkan')
-rw-r--r-- | render/vulkan/vulkan.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/render/vulkan/vulkan.c b/render/vulkan/vulkan.c index 72b39212..c033ba75 100644 --- a/render/vulkan/vulkan.c +++ b/render/vulkan/vulkan.c @@ -369,6 +369,15 @@ VkPhysicalDevice vulkan_find_drm_phdev(struct wlr_vk_instance *ini, int drm_fd) return VK_NULL_HANDLE; } +static void load_device_proc(struct wlr_vk_device *dev, const char *name, + void *proc_ptr) { + void *proc = (void *)vkGetDeviceProcAddr(dev->dev, name); + if (proc == NULL) { + abort(); + } + *(void **)proc_ptr = proc; +} + struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini, VkPhysicalDevice phdev) { VkResult res; @@ -469,17 +478,10 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini, goto error; } - vkGetDeviceQueue(dev->dev, dev->queue_family, 0, &dev->queue); - // load api - dev->api.getMemoryFdPropertiesKHR = (PFN_vkGetMemoryFdPropertiesKHR) - vkGetDeviceProcAddr(dev->dev, "vkGetMemoryFdPropertiesKHR"); - - if (!dev->api.getMemoryFdPropertiesKHR) { - wlr_log(WLR_ERROR, "Failed to retrieve required dev function pointers"); - goto error; - } + load_device_proc(dev, "vkGetMemoryFdPropertiesKHR", + &dev->api.getMemoryFdPropertiesKHR); // - check device format support - size_t max_fmts; |