{"id":16856430,"url":"https://github.com/vallentin/vku","last_synced_at":"2025-03-18T11:14:17.018Z","repository":{"id":89082145,"uuid":"52670448","full_name":"vallentin/vku","owner":"vallentin","description":"Vulkan Utilities - Simplifying Vulkan","archived":false,"fork":false,"pushed_at":"2016-07-31T14:18:09.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-24T17:34:52.804Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"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-27T14:27:38.000Z","updated_at":"2022-10-22T19:48:50.000Z","dependencies_parsed_at":"2023-07-07T04:33:41.448Z","dependency_job_id":null,"html_url":"https://github.com/vallentin/vku","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%2Fvku","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fvku/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fvku/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fvku/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vallentin","download_url":"https://codeload.github.com/vallentin/vku/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244207746,"owners_count":20416109,"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":[],"created_at":"2024-10-13T14:04:13.956Z","updated_at":"2025-03-18T11:14:17.011Z","avatar_url":"https://github.com/vallentin.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Status:** This library needs to be revisioned, as the approach the library took from the get-go isn't overall great.\r\n\r\n# vku - Vulkan Utilities\r\n\r\n## Introduction\r\n\r\n*Vulkan Utilities simplifies a lot of by supplying extension/layer support checking,\r\neasy instance and device creation and much more.*\r\n\r\n**Notice:** This library is still very young, so it will be updated frequently/daily,\r\nuntil everything in Vulkan this library should cover is covered.\r\n\r\nUpdated for Vulkan 1.0.4.\r\n\r\n\r\n\r\n## Setup\r\n\r\n[vku](https://github.com/MrVallentin/vku) is a header only library (this might change in later revisions).\r\n[vku](https://github.com/MrVallentin/vku) doesn't include any Vulkan headers, this means that prior to including\r\n[vku.h](https://github.com/MrVallentin/vku/vlu.h), the appropriate Vulkan related headers needs\r\nto be included. In the following examples [vku](https://github.com/MrVallentin/vku) will be using\r\n[vkel](https://github.com/MrVallentin/vkel), as the resource for dynamically loading Vulkan function pointers.\r\n\r\n\r\n\r\n## Example: Functionality\r\n\r\nThe following example isn't a full program! It just shows how much everything has been simplified.\r\nCreating a `VkInstance` isn't a hassle anymore, this is taken care of by a simply call to `vkuCreateSimpleInstance()`.\r\n\r\n\r\n```c\r\n#include \u003cstdio.h\u003e // needed for getchar(), printf() and fprintf()\r\n#include \u003cstdlib\u003e // needed for calloc() and free()\r\n\r\n#include \"vkel.h\"\r\n#include \"vku.h\"\r\n\r\nint main(int argc, char **argv)\r\n{\r\n\tif (!vkelInit())\r\n\t{\r\n\t\tfprintf(stderr, \"Failed to initialize Vulkan\\n\");\r\n\t\treturn -1;\r\n\t}\r\n\t\r\n\t\r\n\tVkResult err;\r\n\tVkBool32 res;\r\n\t\r\n\t\r\n\tVkBool32 surfaceExtensionSupported =\r\n\t\tvkuIsInstanceExtensionSupported(NULL, VK_KHR_SURFACE_EXTENSION_NAME);\r\n\t\r\n\t\r\n\tVkBool32 platformSurfaceExtensionSupported = VK_FALSE;\r\n\r\n#if defined(VK_USE_PLATFORM_WIN32_KHR)\r\n\tplatformSurfaceExtensionSupported = vkuIsInstanceExtensionSupported(NULL, VK_KHR_SURFACE_EXTENSION_NAME);\r\n#elif defined(VK_USE_PLATFORM_XCB_KHR)\r\n\tplatformSurfaceExtensionSupported = vkuIsInstanceExtensionSupported(NULL, VK_KHR_XCB_SURFACE_EXTENSION_NAME);\r\n#else\r\n\t// Add more if needed\r\n#endif\r\n\r\n\r\n\t// These extensions are necessary for drawing to a surface\r\n\tassert(surfaceExtensionSupported);\r\n\tassert(platformSurfaceExtensionSupported);\r\n\r\n\r\n\tconst VkBool32 debugReportExtensionSupported =\r\n\t\tvkuIsInstanceExtensionSupported(NULL, VK_EXT_DEBUG_REPORT_EXTENSION_NAME);\r\n\r\n\r\n\t// Set to TRUE/FALSE depending on if validation/error reporting is needed\r\n\tVkBool32 enableValidation = VK_FALSE\r\n\t\t\u0026\u0026 debugReportExtensionSupported;\r\n\r\n\r\n\tVkInstance instance;\r\n\r\n\t// err = vkuCreateSimpleInstance(VK_API_VERSION, VK_FALSE, NULL, \u0026instance);\r\n\terr = vkuCreateSimpleInstance(VK_MAKE_VERSION(1, 0, 3), VK_FALSE, NULL, \u0026instance);\r\n\r\n\tif (err)\r\n\t\tprintf(\"vkCreateInstance Error %d: %s\\n\", err, vkuGetResultString(err));\r\n\tassert(!err);\r\n\r\n\t\r\n\tVkPhysicalDevice physicalDevice;\r\n\terr = vkuGetPhysicalDevice(instance, \u0026physicalDevice);\r\n\r\n\tif (err)\r\n\t\tprintf(\"vkCreateInstance Error %d: %s\\n\", err, vkuGetResultString(err));\r\n\tassert(!err);\r\n\r\n\r\n\tVkBool32 swapchainExtensionSupported =\r\n\t\tvkuIsDeviceExtensionSupported(physicalDevice, NULL, VK_KHR_SWAPCHAIN_EXTENSION_NAME);\r\n\r\n\t// This extension is necessary\r\n\tassert(swapchainExtensionSupported);\r\n\r\n\r\n\tuint32_t queueCount;\r\n\tvkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, \u0026queueCount, NULL);\r\n\tassert(queueCount \u003e 0);\r\n\r\n\r\n\tuint32_t queueFamilyIndex;\r\n\tres = vkuGetQueueFamilyIndex(physicalDevice, \u0026queueFamilyIndex);\r\n\tassert(res);\r\n\r\n\r\n\tVkPhysicalDeviceFeatures physicalDeviceFeatures;\r\n\tvkGetPhysicalDeviceFeatures(physicalDevice, \u0026physicalDeviceFeatures);\r\n\r\n\r\n\tVkDevice device;\r\n\terr = vkuCreateSimpleDevice(enableValidation, NULL, physicalDevice, queueFamilyIndex, \u0026device);\r\n\t\r\n\tif (err)\r\n\t\tprintf(\"vkCreateInstance Error %d: %s\\n\", err, vkuGetResultString(err));\r\n\tassert(!err);\r\n\t\r\n\t\r\n\t\r\n\t// Vulkan is being simplified, so more is coming soon!\r\n\t\r\n\t\r\n\t\r\n\t// Pause, so we get to see something before it exits\r\n\tgetchar();\r\n\t\r\n\t\r\n\t// Release the Vulkan library again (the OS will also do this automatically of course).\r\n\tvkelUninit();\r\n\t\r\n\t\r\n\treturn 0;\r\n}\r\n```\r\n\r\n\r\n\r\n## Example: Support Checking\r\n\r\n\r\n```c\r\nVkInstance instance;\r\n// Do all the stuff to create a VkInstance\r\n\r\nVkPhysicalDevice physicalDevice\r\n// Do all the stuff to create a VkPhysicalDevice\r\n\r\n\r\nif (vkuIsInstanceLayerSupported(\"VK_LAYER_LUNARG_api_dump\"))\r\n\t// Instance layer is supported\r\n\r\nif (vkuIsInstanceExtensionSupported(NULL, \"VK_KHR_win32_surface\"))\r\n\t// Instance extension is supported\r\n\r\nif (vkuIsInstanceExtensionSupported(\"VK_LAYER_LUNARG_device_limits\", \"VK_KHR_win32_surface\"))\r\n\t// Instance extension is supported in layer\r\n\r\n\r\nif (vkuIsDeviceLayerSupported(physicalDevice, \"VK_LAYER_LUNARG_vktrace\"))\r\n\t// Device layer is supported\r\n\r\nif (vkuIsDeviceExtensionSupported(physicalDevice, NULL, \"VK_NV_glsl_shader\"))\r\n\t// Device extension is supported\r\n\r\nif (vkuIsInstanceExtensionSupported(physicalDevice, \"VK_LAYER_LUNARG_draw_state\", \"VK_LUNARG_DEBUG_MARKER\"))\r\n\t// Device extension is supported in layer\r\n```\r\n\r\n\r\n## Example: List Supported Extensions\r\n\r\n[vku](https://github.com/MrVallentin/vku) can also be used to list all\r\nsupported extensions and layers using:\r\n\r\n- `vkuGetInstanceExtensionNames`\r\n- `vkuGetInstanceLayerNames`\r\n- `vkuGetDeviceExtensionNames`\r\n- `vkuGetDeviceLayerNames`\r\n\r\nIndividual extensions and layers can be checked using:\r\n\r\n- `vkuIsInstanceLayerSupported`\r\n- `vkuIsInstanceExtensionSupported`\r\n- `vkuIsDeviceLayerSupported`\r\n- `vkuIsDeviceExtensionSupported`\r\n\r\n```c\r\n#include \u003cstdio.h\u003e // needed for getchar(), printf() and fprintf()\r\n#include \u003cstdlib\u003e // needed for calloc() and free()\r\n\r\n#include \"vkel.h\"\r\n#include \"vku.h\"\r\n\r\nint main(int argc, char **argv)\r\n{\r\n\tif (!vkelInit())\r\n\t{\r\n\t\tfprintf(stderr, \"Failed to initialize Vulkan\\n\");\r\n\t\treturn -1;\r\n\t}\r\n\t\r\n\t\r\n\tuint32_t extensionNameCount = 0;\r\n\tchar **extensionNames = vkuGetInstanceExtensionNames(NULL, \u0026extensionNameCount);\r\n\t\r\n\tprintf(\"Count: %d\\n\", extensionNameCount);\r\n\t\r\n\tfor (uint32_t extensionNameIndex = 0; extensionNameIndex \u003c extensionNameCount; extensionNameIndex++)\r\n\t{\r\n\t\tprintf(\"Extension %d: %s\\n\", (extensionNameIndex + 1), extensionNames[extensionNameIndex]);\r\n\t}\r\n\t\r\n\tprintf(\"\\n\");\r\n\t\r\n\tvkuDeleteInstanceExtensionNames(extensionNameCount, extensionNames);\r\n\textensionNames = NULL;\r\n\t\r\n\t\r\n\t// Pause, so we get to see something before it exits\r\n\tgetchar();\r\n\t\r\n\t\r\n\t// Release the Vulkan library again (the OS will also do this automatically of course).\r\n\tvkelUninit();\r\n\t\r\n\t\r\n\treturn 0;\r\n}\r\n```\r\n\r\n\r\n\r\n## API Reference\r\n\r\n\r\n\r\n### VkInstance Creation\r\n\r\n`VkResult vkuCreateSimpleInstance(uint32_t apiVersion, VkBool32 enableValidation, const VkAllocationCallbacks *pAllocator, VkInstance *instance)`\r\n\r\n\u003e Creates a `VkInstance` without any hassle. It simply adds all extensions which the system\r\n\u003e supports. Though if `enableValidation` is set to `VK_FALSE`, then `VK_EXT_debug_report` isn't added.\r\n\u003e Further if `enableValidation` is set to `VK_TRUE` then all supported layers are added as well.\r\n\r\n\r\n```c\r\nVkResult vkuCreateInstance(uint32_t apiVersion,\r\n\tuint32_t enabledExtensionCount, const char* const* ppEnabledExtensionNames,\r\n\tuint32_t enabledLayerCount, const char* const* ppEnabledLayerNames,\r\n\tconst VkAllocationCallbacks *pAllocator,\r\n\tVkInstance *instance)\r\n```\r\n\r\n\u003e This overall just serves as a shortcut for creating a `VkInstance`.\r\n\r\n\r\n### VkPhysicalDevice \u0026 VkDevice Creation\r\n\r\n`VkResult vkuGetPhysicalDevice(VkInstance instance, VkPhysicalDevice *physicalDevice)`\r\n\u003e Get a `VkPhysicalDevice` using an `VkInstance`.\r\n\r\n`VkBool32 vkuGetQueueFamilyIndex(VkPhysicalDevice physicalDevice, uint32_t *queueFamilyIndex)`\r\n\u003e Get a QueueFamilyIndex a `VkPhysicalDevice`.\r\n\r\n\r\n`VkResult vkuCreateSimpleDevice(VkBool32 enableValidation, const VkAllocationCallbacks *pAllocator, VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkDevice *device)`\r\n\r\n\u003e Creates a `VkDevice` using a `VkPhysicalDevice` and a QueueFamilyIndex,\r\n\u003e without any hassle. It simply adds all extensions which the system\r\n\u003e supports. Though if `enableValidation` is set to `VK_FALSE`, then `VK_EXT_debug_report` isn't added.\r\n\u003e Further if `enableValidation` is set to `VK_TRUE` then all supported layers are added as well.\r\n\r\n```c\r\nVkResult vkuCreateDevice(\r\n\tuint32_t enabledExtensionCount, const char* const* ppEnabledExtensionNames,\r\n\tuint32_t enabledLayerCount, const char* const* ppEnabledLayerNames,\r\n\tconst VkAllocationCallbacks *pAllocator,\r\n\tVkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkDevice *device)\r\n```\r\n\r\n\u003e This overall just serves as a shortcut for creating a `VkDevice`.\r\n\r\n\r\n\r\n\r\n\r\n### Check Supported Extensions/Layers\r\n\r\n- `VkBool32 vkuIsInstanceLayerSupported(const char *pLayerName)`\r\n- `VkBool32 vkuIsDeviceLayerSupported(VkPhysicalDevice physicalDevice, const char *pLayerName)`\r\n\r\n\u003e Check if instance/device layer is supported.\r\n\r\n- `VkBool32 vkuIsInstanceExtensionSupported(const char *pLayerName, const char *pExtensionName)`\r\n- `VkBool32 vkuIsDeviceExtensionSupported(VkPhysicalDevice physicalDevice, const char *pLayerName, const char *pExtensionName)`\r\n\r\n\u003e Check if instance/device extension is supported.\r\n\r\n*Remember that they can be checking using the extension name itself. With the\r\nminor change of having the prefix `vku_` instead of `VK_`. Example, `VK_KHR_win32_surface` would\r\nbe `vku_KHR_win32_surface`.*\r\n\r\n\r\n### Listing Supported Extensions/Layers\r\n\r\n*Check the example above.*\r\n\r\n- `char** vkuGetInstanceExtensionNames(const char *pLayerName, uint32_t *extensionNameCount)`\r\n- `char** vkuGetDeviceExtensionNames(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *extensionNameCount)`\r\n\r\n\u003e Get an array of all the supported instance/device extension names.\r\n\r\n- `char** vkuGetInstanceLayerNames(uint32_t *layerNameCount)`\r\n- `char** vkuGetDeviceLayerNames(VkPhysicalDevice physicalDevice, uint32_t *layerNameCount)`\r\n\r\n\u003e Get an array of all the supported instance/device layer names.\r\n\r\n- `void vkuDeleteInstanceExtensionNames(uint32_t extensionNameCount, char **extensionNames)`\r\n- `void vkuDeleteInstanceLayerNames(uint32_t layerNameCount, char **layerNames)`\r\n- `void vkuDeleteDeviceExtensionNames(uint32_t extensionNameCount, char **extensionNames)`\r\n- `void vkuDeleteDeviceLayerNames(uint32_t layerNameCount, char **layerNames)`\r\n\r\n\u003e The return `char**` can be manually deleted, but the above function exist for simplifying\r\n\u003e the process. The above functions are also just `#define`'s of `vkuDeleteNames()`\r\n\r\n\r\n### Extra\r\n\r\n- `const char* vkuGetResultString(const VkResult err)`\r\n\u003e Converts a `VkResult` to a string (`const char*`). The returned\r\n\u003e string is static, so you do not need to delete it.\r\n\r\n\r\n\r\n## Reporting Bugs \u0026 Requests\r\n\r\nFeel free to use the [issue tracker](https://github.com/MrVallentin/vku/issues).\r\nPlease always include the name and version of the OS where the bug occurs.\r\n\r\n\r\n## Dependencies\r\n\r\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.*\r\n- Windows (header) - needed for library loading on Windows\r\n- Standard C Libraries (stdio, stdlib, string, assert) - needed for NULL, malloc() calloc(), free(), memset(), assert()\r\n\r\n\r\n### License \u0026 Copyright\r\n\r\n```\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\r\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\r\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r\nOTHER DEALINGS IN THE SOFTWARE.\r\n\r\nPermission is granted to anyone to use this software for any purpose,\r\nincluding commercial applications, and to alter it and redistribute it\r\nfreely, subject to the following restrictions:\r\n\r\n1. The origin of this software must not be misrepresented; you must not\r\n   claim that you wrote the original software. If you use this software\r\n   in a product, an acknowledgment in the product documentation would\r\n   be appreciated but is not required.\r\n\r\n2. Altered source versions must be plainly marked as such, and must not\r\n   be misrepresented as being the original software.\r\n\r\n3. This notice may not be removed or altered from any source\r\n   distribution.\r\n```\r\n\r\n#### Additional Copyright\r\n\r\nVulkan™ and the Vulkan logo are trademarks of the Khronos Group Inc.\r\n\r\n![Vulkan Logo](http://advvulkan.com/Vulkan_500px_Mar15.png)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fvku","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvallentin%2Fvku","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fvku/lists"}