https://github.com/rtbo/vkdgen
Vulkan D bindings generator
https://github.com/rtbo/vkdgen
Last synced: 4 months ago
JSON representation
Vulkan D bindings generator
- Host: GitHub
- URL: https://github.com/rtbo/vkdgen
- Owner: rtbo
- License: mit
- Created: 2018-12-31T10:15:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-31T06:11:50.000Z (over 5 years ago)
- Last Synced: 2025-01-30T19:26:33.461Z (over 1 year ago)
- Language: D
- Size: 181 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# vkdgen
Vulkan D bindings generator
This is not a Dub package and is not intended to become one. Users can copy
the files they need from the `d` folder, or generate their own with
`gen_d_files.py`:
```
$ ./gen_d_files.py -h
usage: gen_d_files.py [-h] [--package PACKAGE] [--dest DEST]
Vulkan D bindings generator
optional arguments:
-h, --help show this help message and exit
--package PACKAGE D package of generated modules [vkd]
--dest DEST Destination folder for generated files [(vkdgen)/d]
```
The generated bindings do not include any global symbol such as `vkCreateBuffer`.
Instead there are the following definitions:
```d
final class VkGlobalCmds {
this (PFN_vkGetInstanceProcAddr loader) {
// load all global commands
}
VkResult CreateInstance (...) { ... }
}
final class VkInstanceCmds {
this (VkInstance instance, VkGlobalCmds globalCmds) {
// load all instance commands
}
VkResult CreateDevice (VkInstance inst, ...) { ... }
}
final class VkDeviceCmds {
this (VkDevice device, VkInstanceCmds instanceCmds) {
// load all device commands
}
VkResult CreateBuffer (VkDevice device, ...) { ... }
}
```
Client usage could be as follow
```d
import vkd.vk;
import vkd.loader : loadVulkanGlobalCmds();
// load global commands
auto globVk = loadVulkanGlobalCmds();
// load instance commands
VkInstance inst;
VkInstanceCreateInfo instCreateInfo = // ...
globVk.CreateInstance(&instCreateInfo, null, &inst);
auto instVk = new VkInstanceCmds(inst, globVk);
// load device commands
VkPhysicalDevice phDev = // ...
VkDevice dev;
VkDeviceCreateInfo devCreateInfo = // ...
instVk.CreateDevice(phDev, &devCreateInfo, null, &dev);
auto vk = new VkDeviceCmds(dev, instVk);
// vk.CreateBuffer(dev, ...);
```