summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Halase <jordan@halase.me>2019-11-03 15:15:21 -0600
committerJordan Halase <jordan@halase.me>2019-11-03 15:15:21 -0600
commitd57e38324f5d1c611d23f08a9c3d489be7ad01a6 (patch)
treedf8c6374c081b640d6168cfba3f5db743e522bdd
parent073ff1de55b0d380eedd31c61bb9eaae6551ba7c (diff)
Change loader functions
-rw-r--r--main.c76
1 files changed, 31 insertions, 45 deletions
diff --git a/main.c b/main.c
index 1cf5001..db10000 100644
--- a/main.c
+++ b/main.c
@@ -479,8 +479,7 @@ int rvkCreateWorld(struct RenderVulkan **vkOut)
return -1;
}
- uintptr_t *const ulCreateInstance = (uintptr_t*)&vk->api->vkCreateInstance;
- *ulCreateInstance = (uintptr_t)vk->api->vkGetInstanceProcAddr(NULL, "vkCreateInstance");
+ vk->api->vkCreateInstance = (PFN_vkCreateInstance)vk->api->vkGetInstanceProcAddr(NULL, "vkCreateInstance");
if (!vk->api->vkCreateInstance) {
rvkSetErrMsg(vk, "Error loading `vkCreateInstance`");
return -1;
@@ -494,20 +493,16 @@ int rvkCreateWorld(struct RenderVulkan **vkOut)
static const char *const strErrLd = "Error loading instance function %s";
- static const char *const strDestroyInstance = "vkDestroyInstance";
- uintptr_t *const ulDestroyInstance = (uintptr_t*)&vk->api->vkDestroyInstance;
- *ulDestroyInstance = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, strDestroyInstance);
+ static const char *const _vkDestroyInstance = "vkDestroyInstance";
+ vk->api->vkDestroyInstance = (PFN_vkDestroyInstance)vk->api->vkGetInstanceProcAddr(vk->instance, _vkDestroyInstance);
if (!vk->api->vkDestroyInstance) {
- rvkSetErrMsg(vk, strErrLd, strDestroyInstance);
+ rvkSetErrMsg(vk, strErrLd, _vkDestroyInstance);
return -1;
}
/* It is okay if debug reporter functions are not resolved (for now) */
- uintptr_t *ulCreateDebugReportCallbackEXT = (uintptr_t*)&vk->api->vkCreateDebugReportCallbackEXT;
- *ulCreateDebugReportCallbackEXT = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, "vkCreateDebugReportCallbackEXT");
-
- uintptr_t *ulDestroyDebugReportCallbackEXT = (uintptr_t*)&vk->api->vkDestroyDebugReportCallbackEXT;
- *ulDestroyDebugReportCallbackEXT = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, "vkDestroyDebugReportCallbackEXT");
+ vk->api->vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vk->api->vkGetInstanceProcAddr(vk->instance, "vkCreateDebugReportCallbackEXT");
+ vk->api->vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vk->api->vkGetInstanceProcAddr(vk->instance, "vkDestroyDebugReportCallbackEXT");
/* But not if we are unable to destroy a created debug reporter */
if (vk->api->vkCreateDebugReportCallbackEXT && !vk->api->vkDestroyDebugReportCallbackEXT) {
@@ -519,75 +514,66 @@ int rvkCreateWorld(struct RenderVulkan **vkOut)
*
* TODO: This could perhaps be generated by a script and put into a separate "loader" file
*/
- static const char *const strDestroySurfaceKHR = "vkDestroySurfaceKHR";
- uintptr_t *ulDestroySurfaceKHR = (uintptr_t*)&vk->api->vkDestroySurfaceKHR;
- *ulDestroySurfaceKHR = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, strDestroySurfaceKHR);
+ static const char *const _vkDestroySurfaceKHR = "vkDestroySurfaceKHR";
+ vk->api->vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)vk->api->vkGetInstanceProcAddr(vk->instance, _vkDestroySurfaceKHR);
if (!vk->api->vkDestroySurfaceKHR) {
- rvkSetErrMsg(vk, strErrLd, strDestroySurfaceKHR);
+ rvkSetErrMsg(vk, strErrLd, _vkDestroySurfaceKHR);
return -1;
}
- static const char *const strEnumeratePhysicalDevices = "vkEnumeratePhysicalDevices";
- uintptr_t *ulEnumeratePhysicalDevices = (uintptr_t*)&vk->api->vkEnumeratePhysicalDevices;
- *ulEnumeratePhysicalDevices = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, strEnumeratePhysicalDevices);
+ static const char *const _vkEnumeratePhysicalDevices = "vkEnumeratePhysicalDevices";
+ vk->api->vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices)vk->api->vkGetInstanceProcAddr(vk->instance, _vkEnumeratePhysicalDevices);
if (!vk->api->vkEnumeratePhysicalDevices) {
- rvkSetErrMsg(vk, strErrLd, strEnumeratePhysicalDevices);
+ rvkSetErrMsg(vk, strErrLd, _vkEnumeratePhysicalDevices);
return -1;
}
- static const char *const strGetPhysicalDeviceProperties = "vkGetPhysicalDeviceProperties";
- uintptr_t *ulGetPhysicalDeviceProperties = (uintptr_t*)&vk->api->vkGetPhysicalDeviceProperties;
- *ulGetPhysicalDeviceProperties = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, strGetPhysicalDeviceProperties);
+ static const char *const _vkGetPhysicalDeviceProperties = "vkGetPhysicalDeviceProperties";
+ vk->api->vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties)vk->api->vkGetInstanceProcAddr(vk->instance, _vkGetPhysicalDeviceProperties);
if (!vk->api->vkGetPhysicalDeviceProperties) {
- rvkSetErrMsg(vk, strErrLd, strGetPhysicalDeviceProperties);
+ rvkSetErrMsg(vk, strErrLd, _vkGetPhysicalDeviceProperties);
return -1;
}
- static const char *const strGetPhysicalDeviceQueueFamilyProperties = "vkGetPhysicalDeviceQueueFamilyProperties";
- uintptr_t *ulGetPhysicalDeviceQueueFamilyProperties = (uintptr_t*)&vk->api->vkGetPhysicalDeviceQueueFamilyProperties;
- *ulGetPhysicalDeviceQueueFamilyProperties = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, strGetPhysicalDeviceQueueFamilyProperties);
+ static const char *const _vkGetPhysicalDeviceQueueFamilyProperties = "vkGetPhysicalDeviceQueueFamilyProperties";
+ vk->api->vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties)vk->api->vkGetInstanceProcAddr(vk->instance, _vkGetPhysicalDeviceQueueFamilyProperties);
if (!vk->api->vkGetPhysicalDeviceQueueFamilyProperties) {
- rvkSetErrMsg(vk, strErrLd, strGetPhysicalDeviceQueueFamilyProperties);
+ rvkSetErrMsg(vk, strErrLd, _vkGetPhysicalDeviceQueueFamilyProperties);
return -1;
}
- static const char *const strGetPhysicalDeviceSurfaceSupportKHR = "vkGetPhysicalDeviceSurfaceSupportKHR";
- uintptr_t *ulGetPhysicalDeviceSurfaceSupportKHR = (uintptr_t*)&vk->api->vkGetPhysicalDeviceSurfaceSupportKHR;
- *ulGetPhysicalDeviceSurfaceSupportKHR = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, strGetPhysicalDeviceSurfaceSupportKHR);
+ static const char *const _vkGetPhysicalDeviceSurfaceSupportKHR = "vkGetPhysicalDeviceSurfaceSupportKHR";
+ vk->api->vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR)vk->api->vkGetInstanceProcAddr(vk->instance, _vkGetPhysicalDeviceSurfaceSupportKHR);
if (!vk->api->vkGetPhysicalDeviceSurfaceSupportKHR) {
- rvkSetErrMsg(vk, strErrLd, strGetPhysicalDeviceSurfaceSupportKHR);
+ rvkSetErrMsg(vk, strErrLd, _vkGetPhysicalDeviceSurfaceSupportKHR);
return -1;
}
- static const char *const strGetPhysicalDeviceMemoryProperties = "vkGetPhysicalDeviceMemoryProperties";
- uintptr_t *ulGetPhysicalDeviceMemoryProperties = (uintptr_t*)&vk->api->vkGetPhysicalDeviceMemoryProperties;
- *ulGetPhysicalDeviceMemoryProperties = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, strGetPhysicalDeviceMemoryProperties);
+ static const char *const _vkGetPhysicalDeviceMemoryProperties = "vkGetPhysicalDeviceMemoryProperties";
+ vk->api->vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties)vk->api->vkGetInstanceProcAddr(vk->instance, _vkGetPhysicalDeviceMemoryProperties);
if (!vk->api->vkGetPhysicalDeviceMemoryProperties) {
- rvkSetErrMsg(vk, strErrLd, strGetPhysicalDeviceMemoryProperties);
+ rvkSetErrMsg(vk, strErrLd, _vkGetPhysicalDeviceMemoryProperties);
return -1;
}
- static const char *const strEnumerateDeviceExtensionProperties = "vkEnumerateDeviceExtensionProperties";
- uintptr_t *ulEnumerateDeviceExtensionProperties = (uintptr_t*)&vk->api->vkEnumerateDeviceExtensionProperties;
- *ulEnumerateDeviceExtensionProperties = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, strEnumerateDeviceExtensionProperties);
+ static const char *const _vkEnumerateDeviceExtensionProperties = "vkEnumerateDeviceExtensionProperties";
+ vk->api->vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties)vk->api->vkGetInstanceProcAddr(vk->instance, _vkEnumerateDeviceExtensionProperties);
if (!vk->api->vkEnumerateDeviceExtensionProperties) {
- rvkSetErrMsg(vk, strErrLd, strEnumerateDeviceExtensionProperties);
+ rvkSetErrMsg(vk, strErrLd, _vkEnumerateDeviceExtensionProperties);
return -1;
}
static const char *const _vkCreateDevice = "vkCreateDevice";
- uintptr_t *__vkCreateDevice = (uintptr_t*)&vk->api->vkCreateDevice;
- *__vkCreateDevice = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, _vkCreateDevice);
+ vk->api->vkCreateDevice = (PFN_vkCreateDevice)vk->api->vkGetInstanceProcAddr(vk->instance, _vkCreateDevice);
if (!vk->api->vkCreateDevice) {
rvkSetErrMsg(vk, strErrLd, _vkCreateDevice);
return -1;
}
- static const char *const strGetDeviceProcAddr = "vkGetDeviceProcAddr";
- uintptr_t *ulGetDeviceProcAddr = (uintptr_t*)&vk->api->vkGetDeviceProcAddr;
- *ulGetDeviceProcAddr = (uintptr_t)vk->api->vkGetInstanceProcAddr(vk->instance, strGetDeviceProcAddr);
+ static const char *const _vkGetDeviceProcAddr = "vkGetDeviceProcAddr";
+ vk->api->vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)vk->api->vkGetInstanceProcAddr(vk->instance, _vkGetDeviceProcAddr);
if (!vk->api->vkGetDeviceProcAddr) {
- rvkSetErrMsg(vk, strErrLd, strGetDeviceProcAddr);
+ rvkSetErrMsg(vk, strErrLd, _vkGetDeviceProcAddr);
return -1;
}