{"id":16856425,"url":"https://github.com/vallentin/vkel","last_synced_at":"2025-03-22T06:31:08.761Z","repository":{"id":89082146,"uuid":"52431031","full_name":"vallentin/vkel","owner":"vallentin","description":"Simple Dynamic Vulkan Extension Loader","archived":false,"fork":false,"pushed_at":"2017-05-13T11:51:06.000Z","size":238,"stargazers_count":39,"open_issues_count":6,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T08:53:36.409Z","etag":null,"topics":["loader","vulkan","vulkan-api","vulkan-extension-loader","vulkan-library"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vallentin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-24T09:39:50.000Z","updated_at":"2023-12-02T19:20:37.000Z","dependencies_parsed_at":"2023-03-15T19:15:55.644Z","dependency_job_id":null,"html_url":"https://github.com/vallentin/vkel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fvkel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fvkel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fvkel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fvkel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vallentin","download_url":"https://codeload.github.com/vallentin/vkel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244918500,"owners_count":20531682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["loader","vulkan","vulkan-api","vulkan-extension-loader","vulkan-library"],"created_at":"2024-10-13T14:04:13.632Z","updated_at":"2025-03-22T06:31:08.756Z","avatar_url":"https://github.com/vallentin.png","language":"C","readme":"# vkel - Simple Vulkan Extension Loader [![Build Status](https://drone.io/github.com/MrVallentin/vkel/status.png)](https://drone.io/github.com/MrVallentin/vkel/latest)\n\n*Simple Dynamic Cross-Platform Vulkan Extension Loader*\n\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n![Release](https://img.shields.io/badge/release-v2.0.11-blue.svg)\n\n\n## Introduction\n\n[vkel][vkel] is a simple and easy way of dynamically loading\nVulkan and its function pointers.\n[vkel][vkel] can also be used to check which (instance or device)\nextensions and layers are available.\n\n*Also yes, the idea of [vkel][vkel] is indeed\nbased on [GLEW](https://github.com/nigels-com/glew) and [gl3w](https://github.com/skaslev/gl3w).*\n\n**Notice:** ~~Your driver might not support the newest released patch, so instead of using\n`VK_API_VERSION` use something like `VK_MAKE_VERSION(1, 0, 3)`.~~ In Vulkan 1.0.6 the\n`VK_API_VERSION` macro was deprecated and removed, in favor of using `VK_MAKE_VERSION(1, 0, 6)`.\n\n\n#### Vulkan Documentation\n\n- [Khronos Vulkan Registry](https://www.khronos.org/registry/vulkan/)\n\n\n- [Vulkan 1.0 API References](https://www.khronos.org/registry/vulkan/specs/1.0/apispec.html) [[PDF](https://www.khronos.org/registry/vulkan/specs/1.0/apispec.pdf)]\n- [Vulkan 1.0.X Specification](https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html) [[PDF](https://www.khronos.org/registry/vulkan/specs/1.0/pdf/vkspec.pdf)]\n- [Vulkan 1.0.X + WSI Extension Specification](https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html) [[PDF](https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/pdf/vkspec.pdf)]\n\n\n- [Vulkan 1.0 Quick Reference [PDF]](https://www.khronos.org/registry/vulkan/specs/1.0/refguide/Vulkan-1.0-web.pdf)\n\n\n- [The Khronos Vulkan API Registry for Vulkan [PDF]](https://www.khronos.org/registry/vulkan/specs/1.0/readme.pdf)\n- [Vulkan Style Guide](https://www.khronos.org/registry/vulkan/specs/1.0/styleguide.html)\n\n\n## Setup\n\n[vkel][vkel] doesn't (any more) require the vulkan headers.\nSo simply download [vkel.h][vkel.h] and\n[vkel.c][vkel.c] and you're done!\n*Do note that this takes into account, that the Vulkan library and driver exists on the system.*\n\n### Unix-like OS\n\nOn Unix-like OS' you might have to build using `-fPIC` (Position Independent Code).\n\nExample: `gcc -Wall -g -fPIC -shared -o libvkel.so vkel.c`\n\n*Before the building problem on UNIX was encountered, someone responded that he/she\nwas using `gcc -std=c99 -fPIC -shared -o libvkel.so vkel.c` when building.*\n\n## Generating\n\nOverall the only thing needed is [vkel_gen.py][vkel_gen.py].\nWhen executing the script will temporarily download `vulkan.h` and `vk_platform.h`. Though if they already\nexist within the same folder as [vkel_gen.py][vkel_gen.py],\nthen it will fallback to using them. Be aware that when new versions of the Vulkan headers are available,\nthis can create problems.\n\n*There's also two flags you can use when executing the script:*\n\n- `-f`: force, always download `vulkan.h` and `vk_platform.h`\n- `-k`: keep, save `vulkan.h` and `vk_platform.h`\n\n*Note: `vkel_gen.py` is developed and tested using Python 3.5.1.*\n\n## Example: Functionality\n\nVulkan does not have a context unlike OpenGL. You create a Vulkan instance, and compared\nto OpenGL the Vulkan instance is created via the Vulkan API itself.\n*In other words `vkelInit()` can be called as the first thing, without needing anything else beforehand!*\n\nThough along the way function pointers are needed according to the created `VkInstance` and `VkDevice`,\nfor that simply use `vkelInstanceInit()` and `vkelDeviceInit()` to reload function pointers and re-check\nsupport for extensions and layers. This is all done relative to the given instance or device.\n\n```c\n#include \u003cstdio.h\u003e // needed for fprintf()\n\n#include \"vkel.h\"\n\nint main(int argc, char **argv)\n{\n\t// vkelInit() returns VK_TRUE on success or VK_FALSE on failing\n\t// to load the Vulkan library (meaning that the library is most\n\t// likely missing).\n\tif (!vkelInit())\n\t{\n\t\tfprintf(stderr, \"Failed to initialize Vulkan\\n\");\n\t\treturn -1;\n\t}\n\t\n\t\n\tVkInstance instance;\n\t// Do all the stuff to create a VkInstance\n\t\n\tif (!vkelInstanceInit(instance))\n\t{\n\t\tfprintf(stderr, \"Failed to initialize Vulkan with VkInstance\\n\");\n\t\treturn -1;\n\t}\n\t\n\t\n\tVkDevice device;\n\t// Do all the stuff to create a VkDevice\n\t\n\tif (!vkelDeviceInit(device))\n\t{\n\t\tfprintf(stderr, \"Failed to initialize Vulkan with VkDevice\\n\");\n\t\treturn -1;\n\t}\n\t\n\t\n\t// Static checking is checked on vkelInit() where dynamic checking\n\t// always are checked directly against Vulkan (making the dynamic\n\t// version slower).\n\t\n\t// Statically check if the extension is supported\n\tif (VKEL_KHR_android_surface)\n\t{\n\t\t// The extension is supported\n\t}\n\t\n\t// Statically check if the extension is supported\n\tif (VKEL_NV_glsl_shader)\n\t{\n\t\t// The extension is supported\n\t}\n\t\n\t\n\t// Dynamically check if the extension is supported\n\tif (vkelIsInstanceExtensionSupported(NULL, \"VK_KHR_android_surface\"))\n\t{\n\t\t// The extension is supported\n\t}\n\t\n\t\n\t// Check if the function is supported\n\tif (vkCreateAndroidSurfaceKHR)\n\t{\n\t\t// The function is indeed supported\n\t}\n\t\n\t\n\t// All functions found in vulkan.h are automatically loaded making vkelGetProcAddr()\n\t// unneeded unless functions are added which aren't added to vulkan.h\n\t// or when (if ever) using a modified Vulkan library.\n\t\n\t// Manually load function\n\tPFN_vkQueuePresentKHR pfnQueuePresentKHR = (PFN_vkQueuePresentKHR) vkelGetProcAddr(\"vkQueuePresentKHR\");\n\tPFN_vkQueuePresentKHR pfnQueuePresentKHR = (PFN_vkQueuePresentKHR) vkelGetInstanceProcAddr(instance, \"vkQueuePresentKHR\");\n\tPFN_vkQueuePresentKHR pfnQueuePresentKHR = (PFN_vkQueuePresentKHR) vkelGetDeviceProcAddr(device, \"vkQueuePresentKHR\");\n\t\n\t\n\t// Release the Vulkan library again (the OS will also do this automatically of course).\n\tvkelUninit();\n\t\n\t\n\treturn 0;\n}\n```\n\n## Example: List Supported Extensions\n\n[vkel][vkel] can also be used to list all\nsupported extensions and layers using:\n\n- `vkelGetInstanceExtensionNames`\n- `vkelGetInstanceLayerNames`\n- `vkelGetDeviceExtensionNames`\n- `vkelGetDeviceLayerNames`\n\nIndividual extensions and layers can be checked using:\n\n- `vkelIsInstanceLayerSupported`\n- `vkelIsInstanceExtensionSupported`\n- `vkelIsDeviceLayerSupported`\n- `vkelIsDeviceExtensionSupported`\n\n```c\n#include \u003cstdio.h\u003e // needed for getchar(), printf() and fprintf()\n#include \u003cstdlib\u003e // needed for calloc() and free()\n\n#include \"vkel.h\"\n\nint main(int argc, char **argv)\n{\n\tif (!vkelInit())\n\t{\n\t\tfprintf(stderr, \"Failed to initialize Vulkan\\n\");\n\t\treturn -1;\n\t}\n\t\n\t\n\tuint32_t extensionNameCount = 0;\n\tchar **extensionNames = vkelGetInstanceExtensionNames(NULL, \u0026extensionNameCount);\n\t\n\tprintf(\"Count: %d\\n\", extensionNameCount);\n\t\n\tfor (uint32_t extensionNameIndex = 0; extensionNameIndex \u003c extensionNameCount; extensionNameIndex++)\n\t{\n\t\tprintf(\"Extension %d: %s\\n\", (extensionNameIndex + 1), extensionNames[extensionNameIndex]);\n\t}\n\t\n\tprintf(\"\\n\");\n\t\n\tvkelDeleteInstanceExtensionNames(extensionNameCount, extensionNames);\n\textensionNames = NULL;\n\t\n\t\n\t// Pause, so we get to see something before it exits\n\tgetchar();\n\t\n\t\n\t// Release the Vulkan library again (the OS will also do this automatically of course).\n\tvkelUninit();\n\t\n\t\n\treturn 0;\n}\n```\n\n## API Reference\n\n\n### Initialize\n\n`VkBool32 vkelInit(void)`\n\u003e Initialize and load Vulkan along with the function pointers. Returns `VK_TRUE` when vkel was\n\u003e initialized successfully and `VK_FALSE` if the Vulkan library couldn't be loaded (most likely\n\u003e meaning that the library is missing).\n\n`VkBool32 vkelInstanceInit(VkInstance instance)`\n\u003e Reload function pointers according to the given `VkInstance`. This also re-checks\n\u003e support for extensions and layers.\n\n`VkBool32 vkelDeviceInit(VkPhysicalDevice physicalDevice, VkDevice device)`\n\u003e Reload function pointers according to the given `VkDevice`. This also re-checks\n\u003e support for extensions and layers, using the given `VkPhysicalDevice`.\n\n`void vkelUninit(void)`\n\u003e Free the Vulkan library (the OS will do this automatically if `vkelUninit()` isn't called).\n\n### Function Pointers\n\n`PFN_vkVoidFunction vkelGetProcAddr(const char *name)`\n\u003e Get a function pointer from the loaded Vulkan library.\n\n`PFN_vkVoidFunction vkelGetInstanceProcAddr(VkInstance instance, const char *pName)`\n\u003e Shortcut for calling `vkGetInstanceProcAddr()`, but if it returns NULL, then call `vkelGetProcAddr()`.\n\n`PFN_vkVoidFunction vkelGetDeviceProcAddr(VkDevice device, const char *pName)`\n\u003e Shortcut for calling `vkGetDeviceProcAddr()`, but if it returns NULL, then call `vkelGetInstanceProcAddr()`.\n\n\n### Check Supported Extensions/Layers\n\n- `VkBool32 vkelIsInstanceLayerSupported(const char *pLayerName)`\n- `VkBool32 vkelIsDeviceLayerSupported(VkPhysicalDevice physicalDevice, const char *pLayerName)`\n\n\u003e Check if instance/device layer is supported.\n\n- `VkBool32 vkelIsInstanceExtensionSupported(const char *pLayerName, const char *pExtensionName)`\n- `VkBool32 vkelIsDeviceExtensionSupported(VkPhysicalDevice physicalDevice, const char *pLayerName, const char *pExtensionName)`\n\n\u003e Check if instance/device extension is supported.\n\n*Remember that they can be checking using the extension name itself. With the\nminor change of having the prefix `VKEL_` instead of `VK_`. Example, `VK_KHR_win32_surface` would\nbe `VKEL_KHR_win32_surface`.*\n\n\n### Listing Supported Extensions/Layers\n\n*Check the example above.*\n\n- `char** vkelGetInstanceExtensionNames(const char *pLayerName, uint32_t *extensionNameCount)`\n- `char** vkelGetDeviceExtensionNames(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *extensionNameCount)`\n\n\u003e Get an array of all the supported instance/device extension names.\n\n- `char** vkelGetInstanceLayerNames(uint32_t *layerNameCount)`\n- `char** vkelGetDeviceLayerNames(VkPhysicalDevice physicalDevice, uint32_t *layerNameCount)`\n\n\u003e Get an array of all the supported instance/device layer names.\n\n- `void vkelDeleteInstanceExtensionNames(uint32_t extensionNameCount, char **extensionNames)`\n- `void vkelDeleteInstanceLayerNames(uint32_t layerNameCount, char **layerNames)`\n- `void vkelDeleteDeviceExtensionNames(uint32_t extensionNameCount, char **extensionNames)`\n- `void vkelDeleteDeviceLayerNames(uint32_t layerNameCount, char **layerNames)`\n\n\u003e The return `char**` can be manually deleted, but the above function exist for simplifying\n\u003e the process. The above functions are also just `#define`'s of `vkelDeleteNames()`\n\n\n## Reporting Bugs \u0026 Requests\n\nFeel free to use the [issue tracker](https://github.com/MrVallentin/vkel/issues).\nPlease always include the name and version of the OS where the bug occurs.\n\n*I don't have the means to test this on all the different OS'. So any confirmation would be much obliged.*\n\nIf you have a solution, then feel free to fork it as well and the changes will be included.\n\n\n## Dependencies\n\n- Vulkan - *If you're using this in the young days of Vulkan, then make sure that you have the Vulkan driver installed, if any problems occur.*\n- Windows (header) - needed for library loading on Windows\n- dlfcn (header) - needed for library loading on non-Windows OS'\n- Standard C Libraries (stdio, stdlib, string, assert) - needed for NULL, malloc() calloc(), free(), memset(), assert()\n\n\n## What's New? / Changelog\n\n- May 05, 2016\n  - Fixed [issue #2](https://github.com/MrVallentin/vkel/issues/2)\n- May 02, 2016\n  - Fixed \"for loop initial declarations are only allowed in C99 mode\".\n- Feb 26, 2016\n  - Rewrote vkel_gen.py, now it parses and directly adds vulkan.h and vk_platform.h into vkel.h,\n  along with moving the appropriate copyrights to the top of vkel.h.\n  - Fixed/added better differentiation for instance and device related calls.\n  - Removed the need for having the vukan.h and vk_platform.h headers.\n- Feb 24, 2016\n  - Created a Python script for automatically generating all the extensions and their functions. (Developed and tested using Python 3.5.1)\n  - Added cross-platform support, for loading libraries and getting the function addresses.\n  - Fixed so platform specific functions defaults to NULL\n  - Added missing include for dlfcn (used on non-Window OS')\n- Feb 23, 2016\n  - Implemented the basic version supporting a few (manually written) dynamically loaded functions.\n\n\n## License\n\n```\nCopyright (c) 2016 Christian Vallentin \u003cmail@vallentinsource.com\u003e\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not\n   claim that you wrote the original software. If you use this software\n   in a product, an acknowledgment in the product documentation would be\n   appreciated but is not required.\n\n2. Altered source versions must be plainly marked as such, and must not\n   be misrepresented as being the original software.\n\n3. This notice may not be removed or altered from any source\n   distribution.\n```\n\n\n### Additional Copyright\n\nVulkan™ and the Vulkan logo are trademarks of the Khronos Group Inc.\n\n![Vulkan Logo](http://advvulkan.com/Vulkan_500px_Mar15.png)\n\n\n## Specification Updates\n\n- [Vulkan 1.0.24 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/2dd2b3579b64905edafdef1018ba1b39a8474e7a)\n- [Vulkan 1.0.23 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/7f7686d7f2b7c6d780354ca544386476a04c17c4)\n- [Vulkan 1.0.22 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/1ca0ea1ef0ed61ee2e2e818f9616a30e9fc70483)\n- [Vulkan 1.0.21 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/f4c4113d070c0c9b55b4482055be054dd6466c96)\n- [Vulkan 1.0.20 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/e2d981c029105664380e05e61cacc1cab34b1083)\n- [Vulkan 1.0.19 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/e5b16130fe5f5c0a8ffd801aa9ea706ef5b63dc8)\n- [Vulkan 1.0.18 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/eb9997129d954d52d8772c7f4a19a0bccedc8faa)\n- [Vulkan 1.0.17 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/31018cf088c921ab90ec69dee033875807e8faec)\n- [Vulkan 1.0.16 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/5de77cf663c84cc2edfa355c49319dca0a869eb2)\n- [Vulkan 1.0.15 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/36ce3ba5c1454e3649d3ba60791b0c7009670d25)\n- [Vulkan 1.0.14 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/b3d48022bb60ddf67a6699b4c5aa64d52bb1cd4a)\n- [Vulkan 1.0.13 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/2656f459333b3a1dc63619a9ebd83490eea22e93)\n- [Vulkan 1.0.12 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/75bbb5f4d52321eed41337cc463aa036748a1352)\n- [Vulkan 1.0.11 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/ce3204c7dd53a0116ce3a91fd12919d606c306f5)\n- [Vulkan 1.0.10 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/3b32b240f6a71aba8e8b746aaab8bba45883de77)\n- [Vulkan 1.0.9 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/5d10fc3089ba0ec6a4c7d757a4b18a9ef215d2fb)\n- [Vulkan 1.0.8 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/ce3204c7dd53a0116ce3a91fd12919d606c306f5)\n- [Vulkan 1.0.7 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/8c3c9b4c85f2539b67148c2de9e2573154c92786)\n- [Vulkan 1.0.6 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/1f875738fd9bd0aca5d36bf36794b4b2903e74a9)\n- [Vulkan 1.0.5 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/7380aee56b53e9ea3647186ec477202f7f17e28c)\n- [Vulkan 1.0.4 Specification Update](https://github.com/KhronosGroup/Vulkan-Docs/commit/5a4c5e5925c65c6e6677c1fb21571684b4b0a77b)\n\n\n[vkel]: https://github.com/MrVallentin/vkel\n[vkel.h]: https://github.com/MrVallentin/vkel/blob/master/vkel.h\n[vkel.c]: https://github.com/MrVallentin/vkel/blob/master/vkel.c\n[vkel_gen.py]: https://github.com/MrVallentin/vkel/blob/master/vkel_gen.py\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fvkel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvallentin%2Fvkel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fvkel/lists"}