mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 11:55:59 +01:00
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().
This commit is contained in:
parent
5b23987349
commit
f92d1499cd
1 changed files with 11 additions and 9 deletions
|
@ -369,6 +369,15 @@ VkPhysicalDevice vulkan_find_drm_phdev(struct wlr_vk_instance *ini, int drm_fd)
|
||||||
return VK_NULL_HANDLE;
|
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,
|
struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini,
|
||||||
VkPhysicalDevice phdev) {
|
VkPhysicalDevice phdev) {
|
||||||
VkResult res;
|
VkResult res;
|
||||||
|
@ -469,17 +478,10 @@ struct wlr_vk_device *vulkan_device_create(struct wlr_vk_instance *ini,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vkGetDeviceQueue(dev->dev, dev->queue_family, 0, &dev->queue);
|
vkGetDeviceQueue(dev->dev, dev->queue_family, 0, &dev->queue);
|
||||||
|
|
||||||
// load api
|
load_device_proc(dev, "vkGetMemoryFdPropertiesKHR",
|
||||||
dev->api.getMemoryFdPropertiesKHR = (PFN_vkGetMemoryFdPropertiesKHR)
|
&dev->api.getMemoryFdPropertiesKHR);
|
||||||
vkGetDeviceProcAddr(dev->dev, "vkGetMemoryFdPropertiesKHR");
|
|
||||||
|
|
||||||
if (!dev->api.getMemoryFdPropertiesKHR) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to retrieve required dev function pointers");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// - check device format support -
|
// - check device format support -
|
||||||
size_t max_fmts;
|
size_t max_fmts;
|
||||||
|
|
Loading…
Reference in a new issue