├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── docs └── logo.png ├── examples ├── config.nims ├── device.nim ├── enumerate.nim ├── instance.nim └── version.nim ├── nim.cfg ├── src └── vulkan.nim └── vulkan.nimble /.gitignore: -------------------------------------------------------------------------------- 1 | material/ 2 | nimcache/ 3 | .directory 4 | *.dll 5 | *.exe 6 | *.sublime* 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - linux 3 | dist: trusty 4 | 5 | language: c 6 | 7 | install: 8 | - | 9 | wget https://nim-lang.org/download/nim-0.18.0.tar.xz 10 | tar -xf nim-0.18.0.tar.xz 11 | cd nim-0.18.0 12 | sh build.sh 13 | cd .. 14 | before_script: 15 | - set -e 16 | - set -x 17 | - export PATH=`pwd`/nim-0.18.0/bin:$PATH 18 | 19 | script: 20 | - cd src 21 | - nim c -r vulkan 22 | - cd .. 23 | - ./src/vulkan install -y 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 nimio.us 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vulkan [![Build Status](https://travis-ci.com/nimious/vulkan.svg?branch=master)](https://travis-ci.com/nimious/vulkan) 2 | 3 | Nim bindings for Vulkan, the API for access to graphics and compute on GPUs. 4 | 5 | ![vulkan Logo](docs/logo.png) 6 | 7 | 8 | ## About 9 | 10 | This package contains bindings to Vulkan for the [Nim](http://nim-lang.org) 11 | programming language. Vulkan is a unified specification that minimizes driver 12 | overhead and enables multi-threaded GPU command preparation for optimal graphics 13 | and compute performance on diverse mobile, desktop, console and embedded 14 | platforms. 15 | 16 | 17 | ## Supported Platforms 18 | 19 | This package was last built and tested with **Vulkan 1.0.61.1**. The bindings 20 | currently support the following platforms: 21 | 22 | - ~~Android~~ 23 | - Linux 24 | - Windows 25 | 26 | 27 | ## Prerequisites 28 | 29 | Download and install the latest *Vulkan SDK* from the Khronos download page. 30 | 31 | 32 | ## Dependencies 33 | 34 | This package does not have any dependencies to other Nim packages at this time. 35 | 36 | 37 | ## Usage 38 | 39 | Import the *vulkan* module from this package to make the bindings available in 40 | your project: 41 | 42 | ```nimrod 43 | import vulkan 44 | ``` 45 | 46 | 47 | ## Support 48 | 49 | Please [file an issue](https://github.com/nimious/vulkan/issues), submit a 50 | [pull request](https://github.com/nimious/vulkan/pulls?q=is%3Aopen+is%3Apr) 51 | or email us at info@headcrash.industries if this package is out of date or contains bugs. 52 | 53 | 54 | ## References 55 | 56 | * [Khronos Vulkan Homepage](https://www.khronos.org/vulkan/) 57 | * [Khronos Vulkan Registry](https://www.khronos.org/registry/vulkan/) 58 | * [Nim Programming Language](http://nim-lang.org/) 59 | * [MSYS2 on GitHub](http://msys2.github.io/) 60 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nimious/vulkan/1c5cc509b2e8be7f60c95855b7f92b229e99c490/docs/logo.png -------------------------------------------------------------------------------- /examples/config.nims: -------------------------------------------------------------------------------- 1 | switch("debugger", "native") 2 | switch("path", "../src") 3 | 4 | when defined(windows): 5 | switch("passL", r"-Lc:\VulkanSDK\1.0.61.1\Lib") 6 | switch("passL", "-lvulkan-1") 7 | elif defined(linux): 8 | switch("passL", r"/usr/lib/libvulkan.so.1") 9 | -------------------------------------------------------------------------------- /examples/device.nim: -------------------------------------------------------------------------------- 1 | ## *vulkan* - Nim bindings for libusb, the API for access to graphics and 2 | ## compute on GPUs. 3 | ## 4 | ## This file is part of the `Nim I/O `_ package collection. 5 | ## See the file LICENSE included in this distribution for licensing details. 6 | ## GitHub pull requests are encouraged. (c) 2015 Headcrash Industries LLC. 7 | 8 | import vulkan 9 | 10 | var appInfo = VkApplicationInfo( 11 | sType: VkStructureType.applicationInfo, 12 | pNext: nil, 13 | pApplicationName: "Create Device Example", 14 | applicationVersion: 1, 15 | pEngineName: "Nimious", 16 | engineVersion: 1, 17 | apiVersion: vkMakeVersion(1, 0, 2)) 18 | 19 | var instanceCreateInfo = VkInstanceCreateInfo( 20 | sType: VkStructureType.instanceCreateInfo, 21 | pNext: nil, 22 | flags: 0, 23 | pApplicationInfo: addr appInfo, 24 | enabledLayerCount: 0, 25 | ppEnabledLayerNames: nil, 26 | enabledExtensionCount: 0, 27 | ppEnabledExtensionNames: nil) 28 | 29 | # create an instance 30 | var instance: VkInstance 31 | var result = vkCreateInstance(addr instanceCreateInfo, nil, addr instance) 32 | if result != VkResult.success: 33 | quit "Failed to create instance: " & $result 34 | 35 | # get number of physical devices 36 | var deviceCount: uint32 37 | result = vkEnumeratePhysicalDevices(instance, addr deviceCount, nil) 38 | if result != VkResult.success: 39 | quit "Failed to get physical device count: " & $result 40 | if deviceCount == 0: 41 | quit "Didn't find any devices" 42 | 43 | # get devices 44 | var devices = newSeq[VkPhysicalDevice](deviceCount) 45 | result = vkEnumeratePhysicalDevices(instance, addr deviceCount, addr devices[0]) 46 | if result != VkResult.success: 47 | quit "Failed to get devices: " & $result 48 | 49 | # get queues of first device 50 | var queueCount: uint32 51 | vkGetPhysicalDeviceQueueFamilyProperties(devices[0], addr queueCount, nil) 52 | if queueCount == 0: 53 | quit "First device doesn't have any queues" 54 | 55 | # get queue properties 56 | var queueProps = newSeq[VkQueueFamilyProperties](queueCount) 57 | vkGetPhysicalDeviceQueueFamilyProperties(devices[0], addr queueCount, 58 | addr queueProps[0]) 59 | if queueCount == 0: 60 | quit "Failed to get queue properties" 61 | 62 | # find a graphics queue 63 | var queueIndex = -1 64 | for i in 0 .. `_ package collection. 5 | ## See the file LICENSE included in this distribution for licensing details. 6 | ## GitHub pull requests are encouraged. (c) 2015 Headcrash Industries LLC. 7 | 8 | import vulkan 9 | 10 | var appInfo = VkApplicationInfo( 11 | sType: VkStructureType.applicationInfo, 12 | pNext: nil, 13 | pApplicationName: "Enumerate Example", 14 | applicationVersion: 1, 15 | pEngineName: "Nimious", 16 | engineVersion: 1, 17 | apiVersion: vkMakeVersion(1, 0, 2)) 18 | 19 | var instanceCreateInfo = VkInstanceCreateInfo( 20 | sType: VkStructureType.instanceCreateInfo, 21 | pNext: nil, 22 | flags: 0, 23 | pApplicationInfo: addr appInfo, 24 | enabledLayerCount: 0, 25 | ppEnabledLayerNames: nil, 26 | enabledExtensionCount: 0, 27 | ppEnabledExtensionNames: nil) 28 | 29 | # create an instance 30 | var instance: VkInstance 31 | var result = vkCreateInstance(addr instanceCreateInfo, nil, addr instance) 32 | if result != VkResult.success: 33 | quit "Failed to create instance: " & $result 34 | 35 | # get number of physical devices 36 | var deviceCount: uint32 37 | result = vkEnumeratePhysicalDevices(instance, addr deviceCount, nil) 38 | if result != VkResult.success: 39 | quit "Failed to get physical device count: " & $result 40 | if deviceCount == 0: 41 | quit "Didn't find any devices" 42 | 43 | # get devices 44 | var devices = newSeq[VkPhysicalDevice](deviceCount) 45 | result = vkEnumeratePhysicalDevices(instance, addr deviceCount, addr devices[0]) 46 | if result != VkResult.success: 47 | quit "Failed to get devices: " & $result 48 | 49 | # print device info 50 | for d in devices: 51 | var deviceProperties: VkPhysicalDeviceProperties 52 | vkGetPhysicalDeviceProperties(d, addr deviceProperties) 53 | echo $deviceProperties.deviceName & " (" & $deviceProperties.deviceType & ")" 54 | 55 | # clean up 56 | vkDestroyInstance(instance, nil) 57 | -------------------------------------------------------------------------------- /examples/instance.nim: -------------------------------------------------------------------------------- 1 | ## *vulkan* - Nim bindings for libusb, the API for access to graphics and 2 | ## compute on GPUs. 3 | ## 4 | ## This file is part of the `Nim I/O `_ package collection. 5 | ## See the file LICENSE included in this distribution for licensing details. 6 | ## GitHub pull requests are encouraged. (c) 2015 Headcrash Industries LLC. 7 | 8 | import vulkan 9 | 10 | var appInfo = VkApplicationInfo( 11 | sType: VkStructureType.applicationInfo, 12 | pNext: nil, 13 | pApplicationName: "Instance Example", 14 | applicationVersion: 1, 15 | pEngineName: "Nimious", 16 | engineVersion: 1, 17 | apiVersion: vkMakeVersion(1, 0, 2)) 18 | 19 | var instanceCreateInfo = VkInstanceCreateInfo( 20 | sType: VkStructureType.instanceCreateInfo, 21 | pNext: nil, 22 | flags: 0, 23 | pApplicationInfo: addr appInfo, 24 | enabledLayerCount: 0, 25 | ppEnabledLayerNames: nil, 26 | enabledExtensionCount: 0, 27 | ppEnabledExtensionNames: nil) 28 | 29 | # create an instance 30 | var instance: VkInstance 31 | var result = vkCreateInstance(addr instanceCreateInfo, nil, addr instance) 32 | if result == VkResult.errorIncompatibleDriver: 33 | quit "Cannot find a compatible Vulkan ICD" 34 | elif result != VkResult.success: 35 | quit "Failed to create instance: " & $result 36 | else: 37 | echo "Success" 38 | 39 | # clean up 40 | vkDestroyInstance(instance, nil) 41 | -------------------------------------------------------------------------------- /examples/version.nim: -------------------------------------------------------------------------------- 1 | ## *vulkan* - Nim bindings for libusb, the API for access to graphics and 2 | ## compute on GPUs. 3 | ## 4 | ## This file is part of the `Nim I/O `_ package collection. 5 | ## See the file LICENSE included in this distribution for licensing details. 6 | ## GitHub pull requests are encouraged. (c) 2015 Headcrash Industries LLC. 7 | 8 | import strutils, vulkan 9 | 10 | let major = vkApiVersion10 shr 22 11 | let minor = (vkApiVersion10 shr 12) and 0x3ff 12 | let patch = vkApiVersion10 and 0xfff 13 | 14 | echo "Vulkan API Version: $#.$#.$#" % [$major, $minor, $patch] 15 | echo "Vulkan Header Version: $#" % [$vkHeaderVersion] 16 | -------------------------------------------------------------------------------- /nim.cfg: -------------------------------------------------------------------------------- 1 | --path:"src" 2 | -------------------------------------------------------------------------------- /vulkan.nimble: -------------------------------------------------------------------------------- 1 | # Package 2 | 3 | version = "0.2" 4 | author = "Gerke Max Preussner " 5 | description = "Bindings for Vulkan, the API for access to graphics and compute on GPUs." 6 | license = "MIT" 7 | srcDir = "src" 8 | 9 | # Deps 10 | 11 | requires "nim >= 0.13.0" 12 | --------------------------------------------------------------------------------