Initial Commit

This commit is contained in:
SoraKatadzuma committed 2026-11-11 12:59:00 -06:00
commit 2ca5636fc3
20 files changed
+8665

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
+1
View File
@@ -0,0 +1 @@
.blossom
+86
View File
@@ -0,0 +1,86 @@
# vulkan
Vulkan for Sakura, as its registry, `vk.xml`, declares it: the functions of Vulkan's core, 1.0 to 1.4, and of the extensions bound, the structs and unions they take, laid out as C lays them out, and the constants they're asked for and give. It's Sakura's, built with [blossom](https://git.malunal.studio/sakura/blossom), and every file of its library is written by a tool of its own, `malunal.vulkan.bindings`, from the registry the Vulkan SDK installs, so it's written again as the SDK is updated, rather than edited.
```sakura
import malunal::vulkan;
val app := application_info{ application_name = "game".data, api_version = VK_API_VERSION_1_3 };
val info := instance_create_info{ application_info = address(&app) }; # its `s_type` is its own
var instance: u64 = VK_NULL_HANDLE;
if vkCreateInstance(&info, null, &mut instance) != VK_SUCCESS { ... }
var count: u32 = 0;
_ = vkEnumeratePhysicalDevices(instance, &mut count, null);
var devices: u64[8];
_ = vkEnumeratePhysicalDevices(instance, &mut count, (&mut devices) as *mut u64);
var properties := physical_device_properties{};
vkGetPhysicalDeviceProperties(devices[0], &mut properties); # properties.limits.timestamp_period, ...
# An extension's function the loader doesn't export, found by name and called through its type.
val name := vkGetInstanceProcAddr(instance, "vkSetDebugUtilsObjectNameEXT".data) as u64 as PFN_vkSetDebugUtilsObjectNameEXT;
```
A project reads it by requiring this folder, or its remote, and naming `malunal.vulkan`, whose module is `malunal::vulkan`, among a target's `deps`:
```yaml
requires:
- ../vulkan
targets:
- name: game
type: program
deps: [malunal.vulkan]
```
A program built with it links Vulkan's loader, `vulkan-1.dll` on Windows and `libvulkan.so.1` on Linux, which a GPU's drivers install, and the Vulkan SDK too.
## Names
- **What C names keeps its name**: each function, as `vkCreateInstance`; each constant, as `VK_FORMAT_R8G8B8A8_UNORM`, an enum's values among them; and each function's type, as `PFN_vkCreateInstance`.
- **A struct or a union** with a `VK_STRUCTURE_TYPE_` of its own is named by it, in lower case, as Vulkan's own names are made: `VkPhysicalDeviceVulkan13Features` is `physical_device_vulkan_1_3_features`, by `VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES`. Another is its C name in snake case, without its `Vk`: `VkExtent2D` is `extent_2d`, `VkSurfaceFormatKHR` is `surface_format_khr`. Each says its C name in its documentation.
- **A member or a parameter** is its C name in snake case, without the `p` or `pp` of a pointer or the `pfn` of a function: `ppEnabledLayerNames` is `enabled_layer_names`, `pNext` is `next`, `pfnUserCallback` is `user_callback`. A capital begins a word, as does a run of capitals before one, `deviceUUID` as `device_uuid`; a number stays with the word before it, `shaderFloat64` as `shader_float64`, but for a dimension, `maxImageDimension2D` as `max_image_dimension_2d`. One that would be a word of Sakura's is followed by `_`, as `VkPipelineShaderStageCreateInfo`'s `module` is `module_`.
## Types
- **Handles** are `u64`s, dispatchable or not, and `VK_NULL_HANDLE` is 0.
- **Enums** are their values' numbers, `u32`, or `i32` for `VkResult`, whose errors are below 0; **flags** are `u32`, or `u64` for those of 64 bits, as `VkPipelineStageFlags2`; and `VkBool32` is a `u32`, `VK_TRUE` or `VK_FALSE`. A member of one of these says which C type it is, as `#! VkFormat`.
- **Structs** are laid out as C lays them out: a struct's `s_type` is its own by default, so a literal names only what it means, and every other member is zero unless given. An array of arrays is written as Sakura writes them, innermost first, so `VkTransformMatrixKHR`'s `float matrix[3][4]` is `f32[4][3]`, indexed `matrix[row][column]` as C indexes it. A run of C's bitfields is one member of their type, named for them all, as `instance_custom_index_and_mask`, the first the lowest bits.
- **A function's parameter** that points to one thing, which must be there, is a reference: `&T` where the function reads it, as `create_info: &instance_create_info`, and `&mut T` where it writes it, as `instance: &mut u64`. One that may be null, that points to an array, or that points to bytes is a pointer: `*T` or `*mut T`, as `allocator: *allocation_callbacks`, given `null`. A C array is a reference to one, as `blend_constants: &f32[4]`.
- **A function C calls back** is a `cfn` type of its C name, as `PFN_vkDebugUtilsMessengerCallbackEXT`, its parameters pointers all, which a function of the program's is given as.
## What's bound
- **Vulkan's core**, every version the registry has, 1.0 to 1.4 of the SDK's 1.4.328, each with its `VK_API_VERSION_` constant, and `VK_MAKE_API_VERSION` and the functions taking a version apart.
- **Surfaces and swapchains**, whose functions the loader exports: `VK_KHR_surface`, `VK_KHR_swapchain`, `VK_KHR_display`, `VK_KHR_display_swapchain`, `VK_KHR_get_surface_capabilities2`, `VK_KHR_get_display_properties2`, and `VK_EXT_headless_surface`; and each system's windows': `VK_KHR_win32_surface` on Windows, and `VK_KHR_xlib_surface`, `VK_KHR_xcb_surface`, and `VK_KHR_wayland_surface` on Linux.
- **`VK_EXT_debug_utils`**, which names objects and hears the validation layers: its functions are found with `vkGetInstanceProcAddr`.
The functions the loader exports, the core's and those of surfaces and swapchains, are C's, found in it as the program starts, so they're called by their names; only those a program calls are linked, so binding a function of 1.4 asks nothing of an older loader unless a program calls it. Every command, exported or not, has its type, as `PFN_vkCmdDraw`, to call what `vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` give: a device's own functions, which skip the loader's dispatch, and an extension's the loader doesn't export, which are called only so. Each extension's name and version are constants, as `VK_KHR_SWAPCHAIN_EXTENSION_NAME`, a `strview`.
## Layout
`vulkan/` is the module `malunal::vulkan`, written by `tools/`; `tools/` is the program `malunal.vulkan.bindings`.
| Path | Holds |
|---|---|
| `vulkan/vulkan.sakura` | What the module is, the registry's version, each version of the core bound, and how a version is written |
| `vulkan/constants.sakura` | The API's constants, those the extensions define, and each enum's values, under the enum's C name |
| `vulkan/types.sakura` | The structs and unions, and the functions C calls back |
| `vulkan/commands.sakura` | The functions the loader exports, and every command's type |
| `vulkan/win32.sakura` | Windows' surfaces, a section of the module for Windows alone |
| `vulkan/xlib.sakura`, `xcb.sakura`, `wayland.sakura` | Linux's surfaces, each a section for Linux alone |
| `tools/bindings.sakura` | The tool: the extensions the library binds, which of them the loader exports, and its options |
| `tools/registry.sakura` | `registry`: `vk.xml` read into records of its types, members, enums, commands, features, and extensions, Vulkan SC's left out |
| `tools/picking.sakura` | `picking`: what a version of the core and the extensions need of the registry, the types their structs and functions name among it, and whether each is every system's or one platform's |
| `tools/writing.sakura` | The Sakura written of what's picked: names, each declaration's type, constants' values, and the files |
## Writing it again
From the package's root, with the Vulkan SDK installed and `VULKAN_SDK` naming it:
```sh
blossom run malunal.vulkan.bindings
```
It reads `$VULKAN_SDK/share/vulkan/registry/vk.xml` and writes every file of `vulkan/`. `--from FILE` reads another registry, `--into FOLDER` writes elsewhere, `--version 1.3` binds the core only to that version, and `--extension NAME`, given once for each, binds an extension besides the library's own, with what it needs only where what it depends on is bound too. It refuses an extension the registry hasn't, one that's disabled or Vulkan SC's alone, one of a platform but Windows' and Linux's, and one whose dependencies aren't bound, saying why. The extensions the library binds, and which of them the loader exports, are lists at the top of `tools/bindings.sakura`. A platform's file it no longer writes is left as it was, to be removed.
## Testing
`blossom test` runs two programs of `tests/`:
- `malunal.vulkan.tests` checks the bindings against C: sizes and members' places of structs and unions, as C lays them out on 64-bit Windows and Linux, from `VkExtent2D` to `VkPhysicalDeviceProperties`, its limits, and its features, each `VkBool32` where the specification puts it; structs' own `s_type`s; and constants, versions, flags of 64 bits, `VkResult`'s errors, and extensions' names. Then it calls the loader: the version it has, an instance made, its GPUs found, the first's properties and its Vulkan 1.3 features read through a chain, and a function found by name and called through its type. It needs Vulkan's loader.
- `malunal.vulkan.bindings.tests` runs the tool's code on a small registry of its own, written as `vk.xml` is: the names it gives, from `sType`s, in snake case, without pointers' prefixes, and of Sakura's words; members' types, of pointers, constant pointers to pointers, arrays named by constants, arrays of arrays, flags of 64 bits, bitfields, and callbacks; constants' values, of `(~0U)`, floats, bits, and offsets from an extension's number, negative where they're errors; the functions the loader exports and the types of the rest; a platform's file for its system alone; an older version bound without what's newer, nor what an extension needs only with it; Vulkan SC's parts left out; and each extension refused, with why.
## Not yet
Vulkan Video's extensions, whose structs name the codecs' own headers, `vk_video/*.h`, which `video.xml` declares; platforms but Windows' and Linux's, as Android's, Apple's Metal, and Fuchsia's; handles and enums as types of their own, rather than numbers; and the Linux files built, which are written as Windows' are, but haven't been compiled for Linux.
+55
View File
@@ -0,0 +1,55 @@
name: vulkan
gpid: malunal
semv: 1.0.0
options:
level: 2
requires:
- https://git.malunal.studio/sakura/std@v1.0.0
targets:
# Vulkan, as its registry declares it: the functions of its core and of the
# extensions bound, the structs and unions they take, and the numbers they're
# asked for and give. Every file of it is written by `malunal.vulkan.bindings`.
- name: malunal.vulkan
type: library
root: ./vulkan
# Writes `vulkan/` from the Vulkan registry, `vk.xml`, the Vulkan SDK's unless
# another is named.
- name: malunal.vulkan.bindings
type: program
level: ${level}
deps:
- std.args
- std.containers
- std.io
- std.process
- std.xml
srcs:
- tools/bindings.sakura
- tools/registry.sakura
- tools/picking.sakura
- tools/writing.sakura
tests:
# How the bindings lay out what they hold, against C's own layouts, and calls of
# the loader, which needs Vulkan's: a desktop's drivers, or the SDK's loader.
- name: malunal.vulkan.tests
type: program
deps: [malunal.vulkan, std.testing]
srcs: [tests/main.sakura, tests/layouts.sakura, tests/loader.sakura]
# What the tool writes of a small registry of the tests' own.
- name: malunal.vulkan.bindings.tests
type: program
deps: [std.containers, std.testing, std.xml]
srcs: [tests/main.sakura, tests/bindings.sakura, tools/registry.sakura, tools/picking.sakura, tools/writing.sakura]
exports:
- malunal.vulkan
package:
desc: Vulkan for Sakura, written from its registry, vk.xml, by a tool of its own, as C declares it, with its structs laid out as C lays them out.
auth: John Christman <sorakatadzuma@gmail.com>
+327
View File
@@ -0,0 +1,327 @@
#! Contains the tests of what `malunal.vulkan.bindings` writes, of a small
#! registry of their own, written as `vk.xml` is: the names it gives, the types
#! of members and parameters, constants' values, the functions the loader
#! exports and the types of the rest, a platform's file, the versions and
#! extensions bound, and what it refuses.
import std::containers;
import std::testing;
# A registry of a few of each: Vulkan SC's parts, which are left out, among
# them.
const small_registry: strview = """
<registry>
<types>
<type requires="vk_platform" name="void"/>
<type requires="vk_platform" name="char"/>
<type requires="vk_platform" name="float"/>
<type requires="vk_platform" name="uint32_t"/>
<type requires="vk_platform" name="uint64_t"/>
<type requires="windows.h" name="HWND"/>
<type api="vulkan" category="define">// Version of this file
#define <name>VK_HEADER_VERSION</name> 7</type>
<type api="vulkansc" category="define">// Version of this file
#define <name>VK_HEADER_VERSION</name> 3</type>
<type category="basetype">typedef <type>uint32_t</type> <name>VkFlags</name>;</type>
<type category="basetype">typedef <type>uint64_t</type> <name>VkFlags64</name>;</type>
<type category="basetype">typedef <type>uint32_t</type> <name>VkBool32</name>;</type>
<type category="handle"><type>VK_DEFINE_HANDLE</type>(<name>VkInstance</name>)</type>
<type category="handle"><type>VK_DEFINE_NON_DISPATCHABLE_HANDLE</type>(<name>VkThing</name>)</type>
<type name="VkStructureType" category="enum"/>
<type name="VkResult" category="enum"/>
<type name="VkStageFlagBits2" category="enum"/>
<type category="bitmask" bitvalues="VkStageFlagBits2">typedef <type>VkFlags64</type> <name>VkStageFlags2</name>;</type>
<type category="funcpointer">typedef void (VKAPI_PTR *<name>PFN_vkVoidFunction</name>)(void);</type>
<type category="funcpointer">typedef VkBool32 (VKAPI_PTR *<name>PFN_vkHeardCallback</name>)(
<type>uint32_t</type> severity,
const <type>char</type>* pMessage,
<type>void</type>* pUserData);</type>
<type category="struct" name="VkThingCreateInfo">
<member values="VK_STRUCTURE_TYPE_THING_CREATE_INFO"><type>VkStructureType</type> <name>sType</name></member>
<member optional="true">const <type>void</type>* <name>pNext</name></member>
<member><type>uint32_t</type> <name>nameCount</name></member>
<member len="nameCount">const <type>char</type>* const* <name>ppNames</name></member>
<member><type>char</type> <name>label</name>[<enum>VK_MAX_LABEL_SIZE</enum>]</member>
<member><type>uint64_t</type> <name>module</name><comment>Which module</comment></member>
<member><type>VkStageFlags2</type> <name>stages</name></member>
<member><type>float</type> <name>matrix</name>[3][4]</member>
<member><type>PFN_vkHeardCallback</type> <name>pfnHeard</name></member>
<member api="vulkansc"><type>uint32_t</type> <name>scOnly</name></member>
</type>
<type category="struct" name="VkExtent2D">
<member><type>uint32_t</type> <name>width</name></member>
<member><type>uint32_t</type> <name>height</name></member>
</type>
<type category="struct" name="VkPhysicalDeviceVulkan13Features">
<member values="VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES"><type>VkStructureType</type> <name>sType</name></member>
<member optional="true"><type>void</type>* <name>pNext</name></member>
<member><type>VkBool32</type> <name>shaderFloat64</name></member>
<member><type>uint32_t</type> <name>deviceUUID</name></member>
<member><type>uint32_t</type> <name>maxImageDimension2D</name></member>
</type>
<type category="struct" name="VkPackedKHR">
<member><type>uint32_t</type> <name>index</name>:24</member>
<member><type>uint32_t</type> <name>mask</name>:8</member>
</type>
<type category="struct" name="VkWin32ThingCreateInfoKHR">
<member values="VK_STRUCTURE_TYPE_WIN32_THING_CREATE_INFO_KHR"><type>VkStructureType</type> <name>sType</name></member>
<member optional="true">const <type>void</type>* <name>pNext</name></member>
<member><type>HWND</type> <name>hwnd</name></member>
</type>
<type category="struct" name="VkThingCreateInfoKHR" alias="VkThingCreateInfo"/>
</types>
<enums name="API Constants">
<enum type="uint32_t" value="64" name="VK_MAX_LABEL_SIZE"/>
<enum type="uint32_t" value="(~0U)" name="VK_REMAINING"/>
<enum type="uint64_t" value="(~0ULL)" name="VK_WHOLE"/>
<enum type="float" value="1000.0F" name="VK_CLAMP"/>
</enums>
<enums name="VkStructureType" type="enum">
<enum value="0" name="VK_STRUCTURE_TYPE_THING_CREATE_INFO"/>
</enums>
<enums name="VkResult" type="enum">
<enum value="0" name="VK_SUCCESS"/>
<enum value="-1" name="VK_ERROR_OUT_OF_HOST_MEMORY"/>
</enums>
<enums name="VkStageFlagBits2" type="bitmask" bitwidth="64">
<enum bitpos="0" name="VK_STAGE_2_FIRST_BIT"/>
<enum bitpos="40" name="VK_STAGE_2_FAR_BIT"/>
</enums>
<commands>
<command export="vulkan,vulkansc">
<proto><type>VkResult</type> <name>vkCreateThing</name></proto>
<param><type>VkInstance</type> <name>instance</name></param>
<param>const <type>VkThingCreateInfo</type>* <name>pCreateInfo</name></param>
<param optional="true">const <type>void</type>* <name>pAllocator</name></param>
<param><type>VkThing</type>* <name>pThing</name></param>
</command>
<command export="vulkan">
<proto><type>void</type> <name>vkListThings</name></proto>
<param><type>VkInstance</type> <name>instance</name></param>
<param optional="false,true"><type>uint32_t</type>* <name>pCount</name></param>
<param optional="true" len="pCount"><type>VkExtent2D</type>* <name>pThings</name></param>
<param>const <type>float</type> <name>blend</name>[4]</param>
</command>
<command export="vulkan">
<proto><type>PFN_vkVoidFunction</type> <name>vkGetInstanceProcAddr</name></proto>
<param><type>VkInstance</type> <name>instance</name></param>
<param len="null-terminated">const <type>char</type>* <name>pName</name></param>
</command>
<command>
<proto><type>void</type> <name>vkHearEXT</name></proto>
<param><type>VkInstance</type> <name>instance</name></param>
<param><type>VkPhysicalDeviceVulkan13Features</type>* <name>pFeatures</name></param>
</command>
<command>
<proto><type>VkResult</type> <name>vkCreateWin32ThingKHR</name></proto>
<param><type>VkInstance</type> <name>instance</name></param>
<param>const <type>VkWin32ThingCreateInfoKHR</type>* <name>pCreateInfo</name></param>
</command>
<command name="vkCreateThingKHR" alias="vkCreateThing"/>
</commands>
<feature api="vulkan,vulkansc" name="VK_VERSION_1_0" number="1.0">
<require>
<type name="VkThingCreateInfo"/>
<type name="VkResult"/>
<enum name="VK_REMAINING"/>
<enum name="VK_WHOLE"/>
<enum name="VK_CLAMP"/>
<command name="vkCreateThing"/>
<command name="vkGetInstanceProcAddr"/>
</require>
</feature>
<feature api="vulkan" name="VK_VERSION_1_1" number="1.1">
<require>
<type name="VkPhysicalDeviceVulkan13Features"/>
<type name="VkPackedKHR"/>
<enum offset="0" extnumber="12" extends="VkStructureType" name="VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES"/>
<command name="vkListThings"/>
</require>
</feature>
<feature api="vulkansc" name="VKSC_VERSION_1_0" number="1.0">
<require>
<command name="vkSafetyOnly"/>
</require>
</feature>
<extensions>
<extension name="VK_EXT_heard" number="3" supported="vulkan">
<require>
<enum value="2" name="VK_EXT_HEARD_SPEC_VERSION"/>
<enum value="&quot;VK_EXT_heard&quot;" name="VK_EXT_HEARD_EXTENSION_NAME"/>
<enum offset="1" extends="VkResult" dir="-" name="VK_ERROR_NOT_HEARD_EXT"/>
<command name="vkHearEXT"/>
</require>
<require depends="VK_VERSION_1_1">
<type name="VkThingCreateInfoKHR"/>
<command name="vkCreateThingKHR"/>
</require>
</extension>
<extension name="VK_KHR_win32_thing" number="10" supported="vulkan" platform="win32" depends="VK_EXT_heard">
<require>
<enum offset="0" extends="VkStructureType" name="VK_STRUCTURE_TYPE_WIN32_THING_CREATE_INFO_KHR"/>
<type name="VkWin32ThingCreateInfoKHR"/>
<command name="vkCreateWin32ThingKHR"/>
</require>
</extension>
<extension name="VK_EXT_disabled" number="4" supported="disabled"/>
<extension name="VK_MVK_moved" number="5" supported="vulkan" platform="macos"/>
</extensions>
</registry>
""";
# What's wanted of the small registry: its newest version, and the extensions
# named, the platform's exported.
def wanting_of(major: u32, minor: u32, names: span<strview>): wanting {
var made := wanting{ major = major, minor = minor, extensions = vector::<strview>::new(), exported = vector::<strview>::new() };
for &each in names {
made.extensions.append(each);
}
made.exported.append("VK_KHR_win32_thing");
return made;
}
# The text of a file written, or nothing where none of the name was.
def text_of(files: &vector<made_file>, name: strview): strview {
for &each in files {
return each.text.span if each.name.span == name;
}
return "";
}
# Whether a file holds a line.
def holds_line(text: strview, line: strview): bool {
return text.find(line) is some(_);
}
@test def names_types_and_members_as_sakura_does(t: &mut tester): void {
val names: strview[2] = ["VK_EXT_heard", "VK_KHR_win32_thing"];
val wanted := wanting_of(0, 0, names[:]);
var files := vector::<made_file>::new();
var problems := vector::<string>::new();
t.expects(bindings_of(small_registry, &wanted, &mut files, &mut problems) && problems.length == 0);
val types := text_of(&files, "types.sakura");
t.expects(holds_line(types, "pub struct thing_create_info {\n"));
t.expects(holds_line(types, " pub var s_type: u32 = VK_STRUCTURE_TYPE_THING_CREATE_INFO; #! VkStructureType\n"));
t.expects(holds_line(types, " pub var next: *u8;\n"));
t.expects(holds_line(types, " pub var name_count: u32;\n"));
t.expects(holds_line(types, " pub var names: **u8;\n"));
t.expects(holds_line(types, " pub var label: u8[64];\n"));
t.expects(holds_line(types, " pub var module_: u64; #! Which module\n"));
t.expects(holds_line(types, " pub var stages: u64; #! VkStageFlags2\n"));
# C's 3 arrays of 4, as Sakura writes them: innermost first.
t.expects(holds_line(types, " pub var matrix: f32[4][3];\n"));
t.expects(holds_line(types, " pub var heard: PFN_vkHeardCallback;\n"));
t.expects(!holds_line(types, "sc_only"));
# By its `sType`, and in snake case.
t.expects(holds_line(types, "pub struct physical_device_vulkan_1_3_features {\n"));
t.expects(holds_line(types, " pub var next: *mut u8;\n"));
t.expects(holds_line(types, " pub var shader_float64: u32; #! VkBool32\n"));
t.expects(holds_line(types, " pub var device_uuid: u32;\n"));
t.expects(holds_line(types, " pub var max_image_dimension_2d: u32;\n"));
t.expects(holds_line(types, "pub struct extent_2d {\n"));
# Bitfields as one word, an alias by its vendor's letters, and a callback.
t.expects(holds_line(types, "pub struct packed_khr {\n pub var index_and_mask: u32; #! Bits, the lowest first: index, 24, mask, 8.\n"));
t.expects(holds_line(types, "pub type thing_create_info_khr = thing_create_info;\n"));
t.expects(holds_line(types, "pub type PFN_vkHeardCallback = cfn<def(u32, *u8, *mut u8): u32>;\n"));
}
@test def gives_constants_their_values(t: &mut tester): void {
val names: strview[1] = ["VK_EXT_heard"];
val wanted := wanting_of(0, 0, names[:]);
var files := vector::<made_file>::new();
var problems := vector::<string>::new();
t.expects(bindings_of(small_registry, &wanted, &mut files, &mut problems));
val overview := text_of(&files, "vulkan.sakura");
t.expects(holds_line(overview, "pub const VK_HEADER_VERSION: u32 = 7;\n"));
t.expects(holds_line(overview, "pub const VK_API_VERSION_1_1: u32 = (1 << 22) | (1 << 12);\n"));
val constants := text_of(&files, "constants.sakura");
t.expects(holds_line(constants, "pub const VK_REMAINING: u32 = 0xFFFFFFFF;\n"));
t.expects(holds_line(constants, "pub const VK_WHOLE: u64 = 0xFFFFFFFFFFFFFFFF;\n"));
t.expects(holds_line(constants, "pub const VK_CLAMP: f32 = 1000.0;\n"));
t.expects(holds_line(constants, "pub const VK_MAX_LABEL_SIZE: u32 = 64;\n"));
t.expects(holds_line(constants, "pub const VK_ERROR_OUT_OF_HOST_MEMORY: i32 = -1;\n"));
t.expects(holds_line(constants, "pub const VK_ERROR_NOT_HEARD_EXT: i32 = -1000002001;\n"));
t.expects(holds_line(constants, "pub const VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES: u32 = 1000011000;\n"));
t.expects(holds_line(constants, "pub const VK_STAGE_2_FAR_BIT: u64 = 0x10000000000;\n"));
t.expects(holds_line(constants, "# VK_EXT_heard\npub const VK_EXT_HEARD_SPEC_VERSION: u32 = 2;\npub const VK_EXT_HEARD_EXTENSION_NAME: strview = \"VK_EXT_heard\";\n"));
}
@test def declares_what_the_loader_exports_and_types_the_rest(t: &mut tester): void {
val names: strview[1] = ["VK_EXT_heard"];
val wanted := wanting_of(0, 0, names[:]);
var files := vector::<made_file>::new();
var problems := vector::<string>::new();
t.expects(bindings_of(small_registry, &wanted, &mut files, &mut problems));
val commands := text_of(&files, "commands.sakura");
t.expects(holds_line(commands, "extern import \"vulkan-1.dll\" when os == windows;\n"));
t.expects(holds_line(commands, "pub def vkCreateThing(instance: u64, create_info: &thing_create_info, allocator: *u8, thing: &mut u64): i32;\n"));
t.expects(holds_line(commands, "pub def vkListThings(instance: u64, count: &mut u32, things: *mut extent_2d, blend: &f32[4]): void;\n"));
t.expects(holds_line(commands, "pub def vkGetInstanceProcAddr(instance: u64, name: *u8): PFN_vkVoidFunction;\n"));
t.expects(!holds_line(commands, "pub def vkHearEXT"));
t.expects(holds_line(commands, "pub type PFN_vkHearEXT = cfn<def(u64, &mut physical_device_vulkan_1_3_features): void>;\n"));
t.expects(holds_line(commands, "pub type PFN_vkCreateThingKHR = PFN_vkCreateThing;\n"));
t.expects(!holds_line(commands, "vkSafetyOnly"));
}
@test def writes_a_platforms_file_for_its_system(t: &mut tester): void {
val names: strview[2] = ["VK_EXT_heard", "VK_KHR_win32_thing"];
val wanted := wanting_of(0, 0, names[:]);
var files := vector::<made_file>::new();
var problems := vector::<string>::new();
t.expects(bindings_of(small_registry, &wanted, &mut files, &mut problems));
val win32 := text_of(&files, "win32.sakura");
t.expects(holds_line(win32, "extern import \"vulkan-1.dll\" when os == windows;\n\nextern module malunal::vulkan when os == windows;\n"));
t.expects(holds_line(win32, "pub const VK_STRUCTURE_TYPE_WIN32_THING_CREATE_INFO_KHR: u32 = 1000009000;\n"));
t.expects(holds_line(win32, "pub struct win32_thing_create_info_khr {\n"));
t.expects(holds_line(win32, " pub var hwnd: u64; #! HWND\n"));
t.expects(holds_line(win32, "pub def vkCreateWin32ThingKHR(instance: u64, create_info: &win32_thing_create_info_khr): i32;\n"));
t.expects(!holds_line(text_of(&files, "types.sakura"), "win32_thing"));
t.expects(text_of(&files, "xlib.sakura").length == 0);
}
@test def binds_an_older_version_without_whats_newer(t: &mut tester): void {
val names: strview[1] = ["VK_EXT_heard"];
val wanted := wanting_of(1, 0, names[:]);
var files := vector::<made_file>::new();
var problems := vector::<string>::new();
t.expects(bindings_of(small_registry, &wanted, &mut files, &mut problems));
t.expects(!holds_line(text_of(&files, "vulkan.sakura"), "VK_API_VERSION_1_1"));
t.expects(holds_line(text_of(&files, "vulkan.sakura"), "Vulkan 1.1.7, to Vulkan 1.0"));
t.expects(!holds_line(text_of(&files, "commands.sakura"), "vkListThings"));
# What the extension needs only with 1.1.
t.expects(!holds_line(text_of(&files, "commands.sakura"), "PFN_vkCreateThingKHR"));
t.expects(!holds_line(text_of(&files, "types.sakura"), "thing_create_info_khr"));
}
@test def refuses_what_cant_be_bound(t: &mut tester): void {
val cases: strview[4] = ["VK_EXT_nothing", "VK_EXT_disabled", "VK_MVK_moved", "VK_KHR_win32_thing"];
val said: strview[4] = [
"The registry has no extension VK_EXT_nothing.",
"VK_EXT_disabled isn't Vulkan's, or is disabled.",
"VK_MVK_moved is of the platform macos",
"VK_KHR_win32_thing needs VK_EXT_heard",
];
for i in 0..4u {
val wanted := wanting_of(0, 0, cases[i:1]);
var files := vector::<made_file>::new();
var problems := vector::<string>::new();
t.expects(!bindings_of(small_registry, &wanted, &mut files, &mut problems) && problems.length == 1);
t.expects(problems.length == 1 && problems[0].span.starts_with(said[i]));
}
val heard: strview[1] = ["VK_EXT_heard"];
val too_new := wanting_of(2, 0, heard[:]);
var files := vector::<made_file>::new();
var problems := vector::<string>::new();
t.expects(!bindings_of(small_registry, &too_new, &mut files, &mut problems));
t.expects(problems.length == 1 && problems[0].span == "The registry has no Vulkan 2.0.");
}
@test def writes_c_names_in_snake_case(t: &mut tester): void {
t.expects(snake_of("sType").span == "s_type" && snake_of("deviceUUID").span == "device_uuid");
t.expects(snake_of("shaderFloat64").span == "shader_float64" && snake_of("maxImageDimension2D").span == "max_image_dimension_2d");
t.expects(snake_of("Extent2D").span == "extent_2d" && snake_of("textureCompressionASTC_HDR").span == "texture_compression_astc_hdr");
t.expects(snake_of("storageBuffer16BitAccess").span == "storage_buffer16_bit_access" && snake_of("image2DViewOf3D").span == "image_2d_view_of_3d");
t.expects(snake_of("driverID").span == "driver_id" && snake_of("SurfaceFormatKHR").span == "surface_format_khr");
t.expects(without_prefix("ppEnabledLayerNames") == "EnabledLayerNames" && without_prefix("pfnCallback") == "Callback");
t.expects(without_prefix("plane") == "plane" && without_prefix("pNext") == "Next");
}
+74
View File
@@ -0,0 +1,74 @@
#! Contains the tests of how the bindings lay out what they hold, each size and
#! member's place as C's own on 64-bit Windows and Linux, which lay them out
#! alike, and of the constants they give.
import std::testing;
import malunal::vulkan;
# How far into what holds it a member is, in bytes, of their addresses.
def apart(whole: u64, part: u64): u64 {
return part - whole;
}
@test def lays_structs_out_as_c_does(t: &mut tester): void {
t.expects(size_of::<extent_2d>() == 8 && size_of::<offset_3d>() == 12 && size_of::<rect_2d>() == 16);
t.expects(size_of::<application_info>() == 48 && size_of::<instance_create_info>() == 64);
t.expects(size_of::<physical_device_properties>() == 824 && size_of::<physical_device_limits>() == 504);
t.expects(size_of::<physical_device_features>() == 220 && size_of::<physical_device_memory_properties>() == 520);
t.expects(size_of::<physical_device_vulkan_1_2_features>() == 208 && size_of::<physical_device_vulkan_1_3_features>() == 80);
t.expects(size_of::<graphics_pipeline_create_info>() == 144 && size_of::<write_descriptor_set>() == 64);
t.expects(size_of::<image_memory_barrier_2>() == 96 && size_of::<rendering_attachment_info>() == 72);
t.expects(size_of::<swapchain_create_info_khr>() == 104 && size_of::<debug_utils_messenger_callback_data_ext>() == 96);
t.expects(size_of::<allocation_callbacks>() == 48 && size_of::<descriptor_set_layout_binding>() == 24);
t.expects(size_of::<memory_requirements>() == 24 && size_of::<base_in_structure>() == 16);
}
@test def lays_unions_out_as_c_does(t: &mut tester): void {
t.expects(size_of::<clear_color_value>() == 16 && size_of::<clear_value>() == 16);
val floats: f32[4] = [1, 0.5, 0.25, 1];
val color := clear_color_value{ float32 = floats };
t.expects(color.uint32[0] == 0x3F800000 && color.uint32[1] == 0x3F000000);
}
@test def places_members_as_c_does(t: &mut tester): void {
var properties := physical_device_properties{};
val at := address(&properties) as u64;
t.expects(apart(at, address(&properties.limits) as u64) == 296);
t.expects(apart(at, address(&properties.limits.timestamp_period) as u64) == 296 + 424);
t.expects(apart(at, address(&properties.sparse_properties) as u64) == 800);
# Vulkan 1.0's features, each a word, in their order, and 1.2's after a type
# and a chain.
var features := physical_device_features{};
val start := address(&features) as u64;
t.expects(apart(start, address(&features.image_cube_array) as u64) == 2 * 4);
t.expects(apart(start, address(&features.sampler_anisotropy) as u64) == 19 * 4);
t.expects(apart(start, address(&features.shader_float64) as u64) == 39 * 4);
var twelve := physical_device_vulkan_1_2_features{};
val begun := address(&twelve) as u64;
t.expects(apart(begun, address(&twelve.draw_indirect_count) as u64) == 16 + 1 * 4);
t.expects(apart(begun, address(&twelve.runtime_descriptor_array) as u64) == 16 + 29 * 4);
# A union of words after words, aligned as C aligns it, by 4, and the struct
# holding it by 8, as its handles are.
var attachment := rendering_attachment_info{};
t.expects(apart(address(&attachment) as u64, address(&attachment.clear_value) as u64) == 52);
}
@test def gives_each_struct_its_own_type(t: &mut tester): void {
val info := instance_create_info{};
val twelve := physical_device_vulkan_1_2_features{};
val swapchain := swapchain_create_info_khr{};
t.expects(info.s_type == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO && VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO == 1);
t.expects(twelve.s_type == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES && twelve.s_type == 51);
t.expects(swapchain.s_type == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR && swapchain.s_type == 1000001000);
}
@test def writes_constants_as_vulkan_does(t: &mut tester): void {
t.expects(VK_API_VERSION_1_3 == VK_MAKE_API_VERSION(0, 1, 3, 0) && VK_API_VERSION_1_3 == 4206592);
t.expects(VK_API_VERSION_MAJOR(VK_API_VERSION_1_3) == 1 && VK_API_VERSION_MINOR(VK_API_VERSION_1_3) == 3);
t.expects(VK_WHOLE_SIZE == 0xFFFFFFFFFFFFFFFF && VK_QUEUE_FAMILY_IGNORED == 0xFFFFFFFF && VK_LOD_CLAMP_NONE == 1000f);
t.expects(VK_ERROR_OUT_OF_DATE_KHR == -1000001004 && VK_FORMAT_B8G8R8A8_SRGB == 50);
t.expects(VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT == 0x800 && VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT == 0x400000000);
t.expects(VK_KHR_SWAPCHAIN_EXTENSION_NAME == "VK_KHR_swapchain" && VK_EXT_DEBUG_UTILS_EXTENSION_NAME == "VK_EXT_debug_utils");
}
+48
View File
@@ -0,0 +1,48 @@
#! Contains the tests of calls of the loader: the version it gives, an instance
#! made and the devices it finds, what a device has, and a function found by
#! its name and called through its type.
import std::testing;
import malunal::vulkan;
@test def gives_the_version_it_has(t: &mut tester): void {
var version: u32 = 0;
t.expects(vkEnumerateInstanceVersion(&mut version) == VK_SUCCESS);
t.expects(VK_API_VERSION_MAJOR(version) == 1 && VK_API_VERSION_MINOR(version) >= 1);
}
@test def makes_an_instance_and_finds_its_devices(t: &mut tester): void {
val app := application_info{ application_name = "malunal.vulkan.tests".data, api_version = VK_API_VERSION_1_3 };
val info := instance_create_info{ application_info = address(&app) };
var instance: u64 = 0;
t.expects(vkCreateInstance(&info, null, &mut instance) == VK_SUCCESS && instance != VK_NULL_HANDLE);
if instance == VK_NULL_HANDLE {
return;
}
var count: u32 = 0;
t.expects(vkEnumeratePhysicalDevices(instance, &mut count, null) == VK_SUCCESS);
var devices: u64[8];
count = count < 8 ? count : 8;
if count > 0 {
_ = vkEnumeratePhysicalDevices(instance, &mut count, (&mut devices) as *mut u64);
var properties := physical_device_properties{};
vkGetPhysicalDeviceProperties(devices[0], &mut properties);
t.expects(properties.device_name[0] != 0 && VK_API_VERSION_MAJOR(properties.api_version) == 1);
t.expects(properties.limits.max_image_dimension_2d >= 4096 && properties.limits.timestamp_period > 0f);
# Vulkan 1.3's features, chained after 1.0's: a device of 1.3 has these.
var thirteen := physical_device_vulkan_1_3_features{};
var features := physical_device_features_2{ next = address(&mut thirteen) as *mut u8 };
vkGetPhysicalDeviceFeatures2(devices[0], &mut features);
if VK_API_VERSION_MINOR(properties.api_version) >= 3 {
t.expects(thirteen.dynamic_rendering == VK_TRUE && thirteen.synchronization2 == VK_TRUE);
}
}
# A function found by name, and called through its type.
val found := vkGetInstanceProcAddr(instance, "vkDestroyInstance".data) as u64;
t.expects(found != 0);
val destroy := found as PFN_vkDestroyInstance;
destroy(instance, null);
}
+10
View File
@@ -0,0 +1,10 @@
#! Contains the `main` that runs vulkan's tests, each in a copy of the program
#! of its own. `blossom test` runs them, and `-- --only TEXT` those whose name
#! holds the text.
import system;
import std::testing;
def main(args: span<strview>): void {
exit(tester::run(args));
}
+150
View File
@@ -0,0 +1,150 @@
#! Writes the files of `malunal::vulkan`, into `vulkan/`, from the Vulkan
#! registry, `vk.xml`: the Vulkan SDK's, under `VULKAN_SDK`, unless another is
#! named. Run it from the package's root whenever the SDK is updated:
#!
#! ```sh
#! blossom run malunal.vulkan.bindings
#! ```
#!
#! It binds the newest version of Vulkan's core the registry has, unless
#! `--version` names an older one, and the extensions of `extensions`, with any
#! `--extension` names besides. The files it writes are whole: change this, or
#! `tools/writing.sakura`, rather than them. A file of a platform's it no longer
#! writes, as one an extension named once made, is left as it was, to be removed.
import std::args;
import std::containers;
import std::io;
import std::process;
# The extensions the library binds: surfaces and swapchains, then naming objects
# and hearing the validation layers.
const extensions: strview[12] = [
"VK_KHR_surface",
"VK_KHR_swapchain",
"VK_KHR_display",
"VK_KHR_display_swapchain",
"VK_KHR_get_surface_capabilities2",
"VK_KHR_get_display_properties2",
"VK_EXT_headless_surface",
"VK_KHR_win32_surface",
"VK_KHR_xlib_surface",
"VK_KHR_xcb_surface",
"VK_KHR_wayland_surface",
"VK_EXT_debug_utils",
];
# The extensions whose commands the loader exports, as the core's, so they're
# C's functions: the window system's, which `vulkan-1.dll` and `libvulkan.so.1`
# export. Any other's are found by `vkGetInstanceProcAddr`.
const exported: strview[11] = [
"VK_KHR_surface",
"VK_KHR_swapchain",
"VK_KHR_display",
"VK_KHR_display_swapchain",
"VK_KHR_get_surface_capabilities2",
"VK_KHR_get_display_properties2",
"VK_EXT_headless_surface",
"VK_KHR_win32_surface",
"VK_KHR_xlib_surface",
"VK_KHR_xcb_surface",
"VK_KHR_wayland_surface",
];
@args::command{ name = "bindings", help = "Writes the files of malunal::vulkan from the Vulkan registry, vk.xml." }
struct asked {
@args::option{ value = "FILE", help = "The registry read: by default, the Vulkan SDK's, under VULKAN_SDK." }
var from: maybe<strview>;
@args::option{ value = "FOLDER", help = "Where the files are written: by default, vulkan." }
var into: maybe<strview>;
@args::option{ value = "MAJOR.MINOR", help = "The newest version of Vulkan's core bound: by default, the registry's newest." }
var version: maybe<strview>;
@args::option{ value = "NAME", help = "An extension bound besides the library's own, as VK_KHR_present_wait. Write it once for each." }
var extension: vector<strview>;
}
def fail(why: strview): void {
var out := error_output_locked();
_ = out.writer().write($"bindings: {why}\n");
system::exit(1);
}
def main(args: span<strview>): void {
val given := args::parse_or_exit::<asked>(args);
var wanted := wanting{ extensions = vector::<strview>::new(), exported = vector::<strview>::new() };
for &each in extensions {
wanted.extensions.append(each);
}
for &each in given.extension {
if !holds_name(&wanted.extensions, each) {
wanted.extensions.append(each);
}
}
for &each in exported {
wanted.exported.append(each);
}
if given.version is some(version) {
val dot := version.find(".") else {
fail($"--version {version} isn't a version, as 1.3 is.");
return;
};
wanted.major = number_of(version.substr(0, dot)) as u32;
wanted.minor = number_of(version.substr(dot + 1, version.length - dot - 1)) as u32;
}
var file := string::new(nothing{});
if given.from is some(from) {
file.append(from);
} else {
val sdk := process::variable("VULKAN_SDK") else {
fail("VULKAN_SDK isn't set, so there's no registry to read: name one with --from.");
return;
};
file.append(sdk);
file.append("/share/vulkan/registry/vk.xml");
}
val at := path::parse(file.span) else (_) {
fail($"{file} isn't a path.");
return;
};
val text := read_file(&at) else (e) {
fail($"{file} couldn't be read ({e}).");
return;
};
var made := vector::<made_file>::new();
var problems := vector::<string>::new();
if !bindings_of(text.span, &wanted, &mut made, &mut problems) {
var out := error_output_locked();
for &each in problems {
_ = out.writer().write($"bindings: {each}\n");
}
system::exit(1);
}
val folder := given.into else "vulkan";
val into := path::parse(folder) else (_) {
fail($"{folder} isn't a path.");
return;
};
create_directories(&into) else (e) {
fail($"{folder} couldn't be made ({e}).");
};
for &each in made {
val name := $"{folder}/{each.name}";
val written := path::parse(name.span) else (_) {
fail($"{name} isn't a path.");
return;
};
write_file(&written, each.text.span) else (e) {
fail($"{name} couldn't be written ({e}).");
};
var lines: u64 = 0;
for i in 0..each.text.length {
if each.text.span[i] == '\n' {
lines++;
}
}
println($"Wrote {name}, of {lines} lines.");
}
}
+316
View File
@@ -0,0 +1,316 @@
#! Contains `picking`: what a version of Vulkan's core and some extensions need
#! of a registry, each thing placed in the files every system builds, or in a
#! platform's own, as `win32.sakura`, where only a platform's extensions need
#! it.
import std::containers;
#! What's bound: a version of Vulkan's core, and extensions.
struct wanting {
var major: u32; #! The newest version of Vulkan's core bound, or 0 for the registry's newest.
var minor: u32;
var extensions: vector<strview>; #! The extensions bound, by name.
var exported: vector<strview>; #! Those of them whose commands the loader exports, as `vulkan-1.dll` does a surface's.
}
# A platform whose extensions may be bound, in a file of its own, and the system
# that file is built for.
struct platform_file {
var platform: strview;
var os: strview;
}
# The platforms bound: those of the systems Sakura builds for.
const platform_files: platform_file[6] = [
platform_file{ "win32", "windows" },
platform_file{ "xlib", "linux" },
platform_file{ "xlib_xrandr", "linux" },
platform_file{ "xcb", "linux" },
platform_file{ "wayland", "linux" },
platform_file{ "directfb", "linux" },
];
# Where a platform's file is among `platform_files`, and 1 past it, as places
# count: 0 is the files every system builds.
def place_of_platform(platform: strview): u32 {
for i in 0..6u {
return i as u32 + 1 if platform_files[i].platform == platform;
}
return 0;
}
# Whether a list of names holds one.
def holds_name(list: &vector<strview>, name: strview): bool {
for &each in list {
return true if each == name;
}
return false;
}
#! What's bound of a registry, and where.
struct picking {
var major: u32; #! The newest version of the core bound.
var minor: u32;
var places: dict<strview, u32>; #! Each type, command, and constant bound, by name: 0 for the files every system builds, or 1 and its platform's index.
var exported: dict<strview, bool>; #! Each command bound that the loader exports.
var removed: dict<strview, bool>; #! What a bound set removes.
var included: dict<strview, bool>; #! Each feature and extension bound, by name.
var order: vector<u32>; #! Those, in turn, as the sets of `registry`: features, extensions, and then the platforms'.
var extended: vector<u32>; #! The values bound sets give enums, in turn, as `registry`'s.
var defined: vector<u32>; #! The constants bound sets define, in turn.
var definers: vector<u32>; #! The set defining each of those, as `registry`'s.
var given: dict<strview, bool>; #! Each of those, by name, so each is bound once.
}
#! Creates a picking of nothing, to pick.
def picking::new(): picking {
return picking{
places = dict::<strview, u32>::new(),
exported = dict::<strview, bool>::new(),
removed = dict::<strview, bool>::new(),
included = dict::<strview, bool>::new(),
given = dict::<strview, bool>::new()
};
}
#! Picks what's bound of a registry.
#! @param this The picking, empty.
#! @param reg The registry.
#! @param wanted What's bound.
#! @param problems Where why it can't be is said.
#! @returns Whether it could be.
def picking::pick(&mut this, reg: &registry, wanted: &wanting, problems: &mut vector<string>): bool {
this.major = wanted.major;
this.minor = wanted.minor;
if wanted.major == 0 {
for &each in reg.sets {
if each.feature && each.supported && (each.major > this.major || (each.major == this.major && each.minor > this.minor)) {
this.major = each.major;
this.minor = each.minor;
}
}
}
# Each version of the core, to the newest bound.
var versioned := false;
for i, &each in reg.sets {
continue if !each.feature || !each.supported;
continue if each.major > this.major || (each.major == this.major && each.minor > this.minor);
this.included.set(each.name, true);
this.order.append(i as u32);
versioned = versioned || (each.major == this.major && each.minor == this.minor);
}
if !versioned {
problems.append($"The registry has no Vulkan {this.major}.{this.minor}.");
return false;
}
# Each extension, as it can be bound.
for &name in wanted.extensions {
var at: u32 = 0;
if reg.set_at.get(&name) is some(&found) {
at = found;
} else {
problems.append($"The registry has no extension {name}.");
continue;
}
val set := &reg.sets[at as u64];
if set.feature {
problems.append($"{name} is a version of Vulkan, which --version binds.");
} else if !set.supported {
problems.append($"{name} isn't Vulkan's, or is disabled.");
} else if set.platform.length != 0 && place_of_platform(set.platform) == 0 {
problems.append($"{name} is of the platform {set.platform}, which isn't bound: only those of Windows and Linux are.");
} else {
this.included.set(name, true);
}
}
for &name in wanted.extensions {
var at: u32 = 0;
if reg.set_at.get(&name) is some(&found) {
at = found;
}
val set := &reg.sets[at as u64];
if this.included.contains(&name) && set.depends.length != 0 && !this.holds(set.depends) {
problems.append($"{name} needs {set.depends}, which aren't all bound: bind them too, with --extension.");
}
}
if problems.length != 0 {
return false;
}
# The extensions, in the registry's order: those of every system, then the
# platforms', so what both need is placed where every system has it.
for pass in 0..2u {
for i, &each in reg.sets {
continue if each.feature || !this.included.contains(&each.name);
continue if (each.platform.length != 0) != (pass == 1);
this.order.append(i as u32);
}
}
# What each needs, in turn.
for k in 0..this.order.length {
val set := &reg.sets[this.order[k] as u64];
val place := place_of_platform(set.platform);
val exports := !set.feature && holds_name(&wanted.exported, set.name);
for n in set.first..(set.first + set.count) {
val item := &reg.needs[n as u64];
continue if item.depends.length != 0 && !this.holds(item.depends);
if item.removes {
this.removed.set(item.name, true);
} else if item.what == need_kind::of_type {
this.need_type(reg, item.name, place);
} else if item.what == need_kind::of_command {
this.need_command(reg, item.name, place, set.feature, exports);
} else if item.what == need_kind::of_constant {
this.need_constant(reg, item.name, place);
} else if !this.given.contains(&item.name) {
this.given.set(item.name, true);
if !this.places.contains(&item.name) {
this.places.set(item.name, place);
}
if item.what == need_kind::extends {
this.extended.append(item.value);
} else {
this.defined.append(item.value);
this.definers.append(this.order[k]);
val alias := reg.values[item.value as u64].alias;
this.need_constant(reg, alias, place);
}
}
}
}
return true;
}
#! Where a type, a command, or a constant is bound, if it is.
#! @returns 0 for the files every system builds, 1 and a platform's index for
#! its own, or `nothing` where it isn't bound.
def picking::place_of(&this, name: strview): maybe<u32> {
if this.removed.contains(&name) {
return nothing{};
}
if this.places.get(&name) is some(&at) {
return at;
}
return nothing{};
}
#! Whether a type, a command, or a constant is bound in a place.
def picking::is_at(&this, name: strview, place: u32): bool {
if this.place_of(name) is some(at) {
return at == place;
}
return false;
}
# Binds a type, and those it's made of.
def picking::need_type(&mut this, reg: &registry, name: strview, place: u32): void {
if name.length == 0 || this.places.contains(&name) {
return;
}
val t := reg.type_named(name) else { return; };
this.places.set(name, place);
if t.alias.length != 0 {
this.need_type(reg, t.alias, place);
}
if t.category == category::structure || t.category == category::joined || t.category == category::callback {
for &d in reg.declarations_of(t.first, t.count) {
this.need_type(reg, d.base, place);
# An array's length, where a constant names it.
for i in 0..(d.lengths as u64) {
this.need_constant(reg, d.sizes[i], place);
}
}
this.need_type(reg, t.returns.base, place);
} else if t.category == category::bitmask || t.category == category::base {
this.need_type(reg, t.requires, place);
}
}
# Binds a command, and the types it takes and gives.
def picking::need_command(&mut this, reg: &registry, name: strview, place: u32, by_feature: bool, exports: bool): void {
if name.length == 0 || this.places.contains(&name) {
return;
}
var at: u32 = 0;
if reg.command_at.get(&name) is some(&found) {
at = found;
} else {
return;
}
val c := &reg.commands[at as u64];
this.places.set(name, place);
if (by_feature ? c.exported : exports) {
this.exported.set(name, true);
}
if c.alias.length != 0 {
this.need_command(reg, c.alias, place, false, false);
return;
}
this.need_type(reg, c.returns.base, place);
for &d in reg.declarations_of(c.first, c.count) {
this.need_type(reg, d.base, place);
}
}
# Binds a constant of the API's, as `VK_MAX_EXTENSION_NAME_SIZE`.
def picking::need_constant(&mut this, reg: &registry, name: strview, place: u32): void {
if name.length == 0 || this.places.contains(&name) || !reg.value_at.contains(&name) {
return;
}
this.places.set(name, place);
}
#! Whether what a set depends on is bound: names of features and extensions,
#! `+` between those all needed, `,` between those any one of which is, in
#! parentheses where they're mixed.
#! @param this The picking.
#! @param text What it depends on, as `VK_KHR_surface+(VK_VERSION_1_1,VK_KHR_device_group)`.
#! @returns Whether it's bound.
def picking::holds(&this, text: strview): bool {
var at: u64 = 0;
return this.any_of(text, &mut at);
}
def picking::any_of(&this, text: strview, at: &mut u64): bool {
var held := this.all_of(text, at);
while at < text.length && text[at] == ',' {
at++;
val next := this.all_of(text, at);
held = held || next;
}
return held;
}
def picking::all_of(&this, text: strview, at: &mut u64): bool {
var held := this.one_of(text, at);
while at < text.length && text[at] == '+' {
at++;
val next := this.one_of(text, at);
held = held && next;
}
return held;
}
def picking::one_of(&this, text: strview, at: &mut u64): bool {
if at < text.length && text[at] == '(' {
at++;
val held := this.any_of(text, at);
if at < text.length && text[at] == ')' {
at++;
}
return held;
}
val start: u64 = at;
while at < text.length && (text[at].is_ident || text[at] == ':') {
at++;
}
var name := text.substr(start, at - start);
# A feature of an extension, as `VK_KHR_x::shaderY`, is held where the extension is.
if name.find("::") is some(cut) {
name = name.substr(0, cut);
}
return this.included.contains(&name);
}
+561
View File
@@ -0,0 +1,561 @@
#! Contains `registry`, the Vulkan registry, `vk.xml`, read into records of
#! what it declares: its types, the members of its structs and unions, its enums
#! and their values, its commands and their parameters, and the features and
#! extensions that require them. What only another API has, as Vulkan SC's, is
#! left out as it's read.
#!
#! Records name what they hold by views of the document's own text, so a
#! registry keeps the document it was read from, and stays where it was made.
import std::containers;
import std::xml;
# The kinds of types the registry declares.
enum category: u8 {
other, # What isn't bound: a define, or an include.
basic, # C's own, as `uint32_t`, or a platform's, as `HWND`: Sakura's are named by a table.
base, # Another name for a type, as `VkBool32` for `uint32_t`, or one C declares without saying what it is.
handle, # An object's handle.
enumerated, # An enum, whose values are constants.
bitmask, # Flags, of `VkFlags` or `VkFlags64`, whose bits an enum names.
structure, # A struct.
joined, # A union.
callback, # A function C calls back, as `PFN_vkAllocationFunction`.
}
# A declaration as C writes it: of a struct's member, a parameter, or what a
# function returns. It names a type, and may point to it, hold an array of it,
# or hold some bits of it.
struct declaration {
var name: strview; # As declared, as `pCreateInfo`: empty for what a function returns.
var base: strview; # The type named, as `VkInstanceCreateInfo`.
var pointers: u32; # How many `*` follow it.
var consts: u32; # Bit 0 where the type named is const, and bit k where the k-th pointer is.
var sizes: strview[2]; # An array's lengths, outermost first, each a number or a constant's name.
var lengths: u32; # How many of `sizes` it has.
var bits: u32; # A bitfield's width, or 0.
var optional: strview; # Its `optional`: whether it may be zero, and what it points to.
var len: strview; # Its `len`: what counts the elements a pointer points to.
var values: strview; # A member's `values`: the one value it holds, as `sType`'s.
var comment: strview; # What the registry says of it.
}
# A type the registry declares.
struct type_record {
var name: strview;
var category: category;
var alias: strview; # The type it's another name for, where it's an alias.
var requires: strview; # A bitmask's enum of bits; a base type's type.
var wide: bool; # Whether a bitmask is of `VkFlags64`.
var first: u32; # A struct's or union's first member, or a callback's first parameter, in `declarations`.
var count: u32; # How many it has.
var returns: declaration; # What a callback returns.
var comment: strview;
}
# A block of enum values: an enum's, or the API's constants.
struct group_record {
var name: strview;
var kind: strview; # `enum`, `bitmask`, or empty for the API's constants.
var wide: bool; # Whether its bits are of 64.
var negative: bool; # Whether a value is below 0, as `VkResult`'s errors are.
var first: u32; # Its first value, in `values`.
var count: u32;
}
# A value of an enum, or a constant.
struct value_record {
var name: strview;
var group: strview; # The enum or block it's a value of, or empty for a constant a feature or an extension defines.
var written: strview; # Its `value`, as written: `0x7FFFFFFF`, `(~0U)`, `1000.0F`, `"VK_KHR_surface"`.
var bitpos: strview; # Its bit, where it's a bit.
var alias: strview; # The value it's another name for.
var c_type: strview; # A constant's type, as `uint32_t`.
var offset: i64; # Its value, as an extension's number and an offset give it, where `computed`.
var computed: bool;
var comment: strview;
}
# A command the registry declares.
struct command_record {
var name: strview;
var alias: strview; # The command it's another name for.
var returns: declaration;
var first: u32; # Its first parameter, in `declarations`.
var count: u32;
var exported: bool; # Whether the loader exports it, as `export` says of Vulkan's core.
}
# What a feature's or an extension's `require` or `remove` names.
enum need_kind: u8 {
of_type, # A type, by name.
of_command, # A command, by name.
of_constant, # A constant declared elsewhere, by name.
defines, # A constant it defines, as an extension's name.
extends, # A value it gives an enum.
}
struct need {
var what: need_kind;
var name: strview;
var depends: strview; # What the `require` holds only with, as `VK_VERSION_1_1`.
var removes: bool; # Whether it's a `remove`'s.
var value: u32; # The value it defines or gives, in `values`.
}
# A feature, which is a version of Vulkan's core, or an extension.
struct set_record {
var name: strview;
var feature: bool;
var major: u32; # A feature's version.
var minor: u32;
var number: i64; # An extension's number, which its values' offsets are counted from.
var supported: bool; # Whether it's Vulkan's, and not disabled.
var platform: strview; # The platform an extension is of, as `win32`.
var depends: strview; # What it needs bound with it.
var first: u32; # Its first need, in `needs`.
var count: u32;
}
#! The Vulkan registry, read.
struct registry {
var document: xml::document;
var types: vector<type_record>;
var declarations: vector<declaration>;
var blocks: vector<group_record>;
var values: vector<value_record>;
var commands: vector<command_record>;
var sets: vector<set_record>;
var needs: vector<need>;
var type_at: dict<strview, u32>;
var block_at: dict<strview, u32>;
var value_at: dict<strview, u32>;
var command_at: dict<strview, u32>;
var set_at: dict<strview, u32>;
var header: u64; # `VK_HEADER_VERSION`, the registry's own.
}
#! Creates a registry holding nothing, to be read.
def registry::new(): registry {
return registry{
type_at = dict::<strview, u32>::new(),
block_at = dict::<strview, u32>::new(),
value_at = dict::<strview, u32>::new(),
command_at = dict::<strview, u32>::new(),
set_at = dict::<strview, u32>::new()
};
}
# Whether an element is Vulkan's, as its `api` says, where it says.
def for_vulkan(e: &xml::element): bool {
val api := e.attribute("api") else "";
return api.length == 0 || has_word(api, "vulkan");
}
# Whether a list of words, apart by commas, holds a word.
def has_word(list: strview, word: strview): bool {
var start: u64 = 0;
for i in 0..(list.length + 1) {
if i == list.length || list[i] == ',' {
return true if list.substr(start, i - start) == word;
start = i + 1;
}
}
return false;
}
# The text an element holds of its own, as `<name>` and `<type>` hold one name.
def lone_text(e: &xml::element): strview {
for child in e.children() {
return child.text if child.kind == xml::kind::text;
}
return "";
}
# The text of an element's first child of a name.
def text_of_child(e: &xml::element, name: strview): strview {
for child in e.elements() {
return lone_text(&child) if child.name == name;
}
return "";
}
# Splits C into names, numbers, and marks, each a view of the text.
def split_into(text: strview, into: &mut vector<strview>): void {
var i: u64 = 0;
while i < text.length {
val c: u8 = text[i];
if c.is_space {
i++;
continue;
}
if c.is_ident {
val start := i;
while i < text.length && text[i].is_ident {
i++;
}
into.append(text.substr(start, i - start));
continue;
}
into.append(text.substr(i, 1));
i++;
}
}
# The C an element holds, as words, its comments left out.
def tokens_of(e: &xml::element, into: &mut vector<strview>): void {
for child in e.children() {
if child.kind == xml::kind::text {
split_into(child.text, into);
} else if child.as_element() is some(inner) {
continue if inner.name == "comment";
split_into(lone_text(&inner), into);
}
}
}
# A declaration, of C's words: `const char* const* ppEnabledLayerNames`,
# `char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]`, `uint32_t mask:8`.
def declaration_of(tokens: span<strview>): declaration {
var made := declaration{};
var i: u64 = 0;
while i < tokens.length {
val t: strview = tokens[i];
if t == "const" {
made.consts |= 1 << made.pointers;
} else if t == "*" {
made.pointers++;
} else if t == "[" {
if i + 1 < tokens.length && made.lengths < 2 {
made.sizes[made.lengths as u64] = tokens[i + 1];
made.lengths++;
}
i += 2;
} else if t == ":" {
if i + 1 < tokens.length {
made.bits = number_of(tokens[i + 1]) as u32;
}
i++;
} else if t == "struct" || t == "typedef" || t == "]" || t == ";" {
} else if made.base.length == 0 {
made.base = t;
} else {
made.name = t;
}
i++;
}
return made;
}
# A number written in decimal, or in hex after `0x`.
def number_of(text: strview): u64 {
var made: u64 = 0;
if text.starts_with("0x") || text.starts_with("0X") {
for i in 2..text.length {
made = made * 16 + text[i].digit_value;
}
return made;
}
for i in 0..text.length {
break if !text[i].is_digit;
made = made * 10 + text[i].digit_value;
}
return made;
}
#! Reads the registry from its text.
#! @param this The registry, empty, which is made where it stays.
#! @param text The text of `vk.xml`.
#! @param problems Where why it can't be read is said.
#! @returns Whether it was read.
def registry::read(&mut this, text: strview, problems: &mut vector<string>): bool {
var parsed := xml::parse(text) else (e) {
problems.append($"The registry isn't XML: {e.describe()}");
return false;
};
this.document = move(parsed);
val root := this.document.root;
if root.name != "registry" {
problems.append(string::from("The XML isn't a Vulkan registry: its root isn't <registry>.", nothing{}));
return false;
}
for part in root.elements() {
if part.name == "types" {
this.read_types(&part);
} else if part.name == "enums" {
this.read_block(&part);
} else if part.name == "commands" {
this.read_commands(&part);
} else if part.name == "feature" {
this.read_set(&part, true);
} else if part.name == "extensions" {
for each in part.elements() {
if each.name == "extension" {
this.read_set(&each, false);
}
}
}
}
return true;
}
# Reads each type of `<types>`.
def registry::read_types(&mut this, types: &xml::element): void {
var tokens := vector::<strview>::new();
for each in types.elements() {
continue if each.name != "type" || !for_vulkan(&each);
val kind_of := each.attribute("category") else "";
var made := type_record{
name = each.attribute("name") else text_of_child(&each, "name"),
alias = each.attribute("alias") else "",
comment = each.attribute("comment") else ""
};
if kind_of == "struct" || kind_of == "union" {
made.category = kind_of == "struct" ? category::structure : category::joined;
made.first = this.declarations.length as u32;
for member in each.elements() {
continue if member.name != "member" || !for_vulkan(&member);
tokens.clear();
tokens_of(&member, &mut tokens);
var read := declaration_of(tokens.span);
read.optional = member.attribute("optional") else "";
read.len = member.attribute("len") else "";
read.values = member.attribute("values") else "";
read.comment = text_of_child(&member, "comment");
this.declarations.append(read);
}
made.count = this.declarations.length as u32 - made.first;
} else if kind_of == "handle" {
made.category = category::handle;
} else if kind_of == "enum" {
made.category = category::enumerated;
} else if kind_of == "bitmask" {
made.category = category::bitmask;
made.requires = each.attribute("requires") else (each.attribute("bitvalues") else "");
made.wide = text_of_child(&each, "type") == "VkFlags64";
} else if kind_of == "basetype" {
made.category = category::base;
made.requires = text_of_child(&each, "type");
} else if kind_of == "funcpointer" {
made.category = category::callback;
tokens.clear();
tokens_of(&each, &mut tokens);
this.read_callback(tokens.span, &mut made);
} else if kind_of.length == 0 && each.attribute("requires") is some(_) {
made.category = category::basic;
} else if kind_of == "define" && made.name == "VK_HEADER_VERSION" {
tokens.clear();
tokens_of(&each, &mut tokens);
this.header = number_of(tokens[tokens.length - 1]);
}
if made.name.length != 0 && !this.type_at.contains(&made.name) {
this.type_at.set(made.name, this.types.length as u32);
}
this.types.append(made);
}
}
# Reads a callback's C: `typedef VkBool32 (VKAPI_PTR *PFN_vkX)(VkFlags a, void* b);`.
def registry::read_callback(&mut this, tokens: span<strview>, made: &mut type_record): void {
var open: u64 = 0;
while open < tokens.length && tokens[open] != "(" {
open++;
}
made.returns = declaration_of(tokens[1:open - 1]);
made.first = this.declarations.length as u32;
# Past `(VKAPI_PTR *PFN_vkX)`, to the parameters' `(`.
var at := open;
while at < tokens.length && tokens[at] != ")" {
at++;
}
at += 2;
var start := at;
while at < tokens.length {
val t: strview = tokens[at];
if t == "," || t == ")" {
val read := declaration_of(tokens[start:at - start]);
if read.base.length != 0 && !(read.base == "void" && read.pointers == 0) {
this.declarations.append(read);
}
break if t == ")";
start = at + 1;
}
at++;
}
made.count = this.declarations.length as u32 - made.first;
}
# Reads a block of `<enums>`: an enum's values, or the API's constants.
def registry::read_block(&mut this, block: &xml::element): void {
var made := group_record{
name = block.attribute("name") else "",
kind = block.attribute("type") else "",
wide = (block.attribute("bitwidth") else "") == "64",
first = this.values.length as u32
};
if made.kind == "constants" {
made.kind = "";
}
for each in block.elements() {
continue if each.name != "enum" || !for_vulkan(&each);
val read := value_record{
name = each.attribute("name") else "",
group = made.name,
written = each.attribute("value") else "",
bitpos = each.attribute("bitpos") else "",
alias = each.attribute("alias") else "",
c_type = each.attribute("type") else "",
comment = each.attribute("comment") else ""
};
if read.written.starts_with("-") {
made.negative = true;
}
if !this.value_at.contains(&read.name) {
this.value_at.set(read.name, this.values.length as u32);
}
this.values.append(read);
}
made.count = this.values.length as u32 - made.first;
this.block_at.set(made.name, this.blocks.length as u32);
this.blocks.append(made);
}
# Reads each command of `<commands>`.
def registry::read_commands(&mut this, commands: &xml::element): void {
var tokens := vector::<strview>::new();
for each in commands.elements() {
continue if each.name != "command" || !for_vulkan(&each);
var made := command_record{
name = each.attribute("name") else "",
alias = each.attribute("alias") else "",
exported = has_word(each.attribute("export") else "", "vulkan"),
first = this.declarations.length as u32
};
for part in each.elements() {
if part.name == "proto" {
tokens.clear();
tokens_of(&part, &mut tokens);
made.returns = declaration_of(tokens.span);
made.name = made.returns.name;
made.returns.name = "";
} else if part.name == "param" && for_vulkan(&part) {
tokens.clear();
tokens_of(&part, &mut tokens);
var read := declaration_of(tokens.span);
read.optional = part.attribute("optional") else "";
read.len = part.attribute("len") else "";
this.declarations.append(read);
}
}
made.count = this.declarations.length as u32 - made.first;
if !this.command_at.contains(&made.name) {
this.command_at.set(made.name, this.commands.length as u32);
}
this.commands.append(made);
}
}
# Reads a feature or an extension, and what its `require`s and `remove`s name.
def registry::read_set(&mut this, set: &xml::element, feature: bool): void {
var made := set_record{
name = set.attribute("name") else "",
feature = feature,
platform = set.attribute("platform") else "",
depends = set.attribute("depends") else "",
first = this.needs.length as u32
};
if feature {
made.supported = has_word(set.attribute("api") else "", "vulkan");
val number := set.attribute("number") else "";
val dot := number.find(".") else 0;
made.major = number_of(number.substr(0, dot)) as u32;
made.minor = number_of(number.substr(dot + 1, number.length - dot - 1)) as u32;
} else {
made.supported = has_word(set.attribute("supported") else "", "vulkan");
made.number = number_of(set.attribute("number") else "") as i64;
}
for part in set.elements() {
continue if (part.name != "require" && part.name != "remove") || !for_vulkan(&part);
val depends := part.attribute("depends") else "";
val removes := part.name == "remove";
for item in part.elements() {
continue if !for_vulkan(&item);
var named := need{
name = item.attribute("name") else "",
depends = depends,
removes = removes
};
if item.name == "type" {
named.what = need_kind::of_type;
} else if item.name == "command" {
named.what = need_kind::of_command;
} else if item.name == "enum" {
if !this.read_value(&item, &made, &mut named) {
continue;
}
} else {
continue;
}
this.needs.append(named);
}
}
made.count = this.needs.length as u32 - made.first;
this.set_at.set(made.name, this.sets.length as u32);
this.sets.append(made);
}
# Reads an `<enum>` a feature or an extension names: a value it gives an
# enum, a constant it defines, or one it refers to.
def registry::read_value(&mut this, item: &xml::element, set: &set_record, named: &mut need): bool {
val extends := item.attribute("extends") else "";
var read := value_record{
name = named.name,
group = extends,
written = item.attribute("value") else "",
bitpos = item.attribute("bitpos") else "",
alias = item.attribute("alias") else "",
c_type = item.attribute("type") else "",
comment = item.attribute("comment") else ""
};
if item.attribute("offset") is some(offset) {
var number := set.number;
if item.attribute("extnumber") is some(given) {
number = number_of(given) as i64;
}
read.offset = 1000000000 + (number - 1) * 1000 + number_of(offset) as i64;
if (item.attribute("dir") else "") == "-" {
read.offset = -read.offset;
}
read.computed = true;
}
val defines := read.written.length != 0 || read.bitpos.length != 0 || read.alias.length != 0 || read.computed;
if extends.length != 0 {
named.what = need_kind::extends;
} else if defines {
named.what = need_kind::defines;
} else {
named.what = need_kind::of_constant;
return true;
}
named.value = this.values.length as u32;
if !this.value_at.contains(&read.name) {
this.value_at.set(read.name, this.values.length as u32);
}
this.values.append(read);
return true;
}
#! Finds a type by its name.
def registry::type_named(&this, name: strview): maybe<&type_record> {
if this.type_at.get(&name) is some(&at) {
return &this.types[at as u64];
}
return nothing{};
}
#! The parameters or members a record holds, as a view.
def registry::declarations_of(&this, first: u32, count: u32): span<declaration> {
val start: u64 = first;
val length: u64 = count;
return this.declarations.span[start:length];
}
+933
View File
@@ -0,0 +1,933 @@
#! Contains what's written of what's picked of a registry: the names Sakura
#! gives C's, the Sakura type of each C declaration, and the files of
#! `malunal::vulkan`, each a `made_file`.
import std::containers;
#! A file written: its name, within the library's folder, and its text.
struct made_file {
var name: string;
var text: string;
}
# Sakura's own words, which no name may be: a member or a parameter named so is
# followed by `_`.
const keywords: strview[33] = [
"import", "module", "extern", "pub", "const", "var", "val", "def", "mut", "return", "if", "else",
"for", "in", "while", "break", "continue", "type", "enum", "struct", "union", "trait", "as", "is",
"not", "match", "when", "where", "true", "false", "null", "this", "self",
];
# A type C or a platform names, and Sakura's of it.
struct basic_type {
var c: strview;
var sakura: strview;
}
# C's own types, then those of the platforms bound. A type only ever pointed
# to, as Xlib's `Display`, is a byte.
const basic_types: basic_type[32] = [
basic_type{ "void", "u8" },
basic_type{ "char", "u8" },
basic_type{ "float", "f32" },
basic_type{ "double", "f64" },
basic_type{ "int8_t", "i8" },
basic_type{ "uint8_t", "u8" },
basic_type{ "int16_t", "i16" },
basic_type{ "uint16_t", "u16" },
basic_type{ "int32_t", "i32" },
basic_type{ "uint32_t", "u32" },
basic_type{ "int64_t", "i64" },
basic_type{ "uint64_t", "u64" },
basic_type{ "size_t", "u64" },
basic_type{ "int", "i32" },
basic_type{ "HINSTANCE", "u64" },
basic_type{ "HWND", "u64" },
basic_type{ "HMONITOR", "u64" },
basic_type{ "HANDLE", "u64" },
basic_type{ "DWORD", "u32" },
basic_type{ "LPCWSTR", "*u16" },
basic_type{ "SECURITY_ATTRIBUTES", "u8" },
basic_type{ "Display", "u8" },
basic_type{ "VisualID", "u64" },
basic_type{ "Window", "u64" },
basic_type{ "RROutput", "u64" },
basic_type{ "xcb_connection_t", "u8" },
basic_type{ "xcb_visualid_t", "u32" },
basic_type{ "xcb_window_t", "u32" },
basic_type{ "wl_display", "u8" },
basic_type{ "wl_surface", "u8" },
basic_type{ "IDirectFB", "u8" },
basic_type{ "IDirectFBSurface", "u8" },
];
# How many of `basic_types` are C's own, before the platforms'.
const c_types: u64 = 14;
# The prefixes C's names give pointers and functions, longest first.
const pointer_prefixes: strview[3] = ["pfn", "pp", "p"];
# A member of a struct or a union, as written.
struct field_line {
var name: string;
var held: string; # Its type.
var tail: string; # Its default, and what's said of it.
}
#! What's written of a registry: the names given, and the constants written.
struct writing {
var names: dict<strview, u32>; # Each struct's and union's name, by its C name, in `spelled`.
var spelled: vector<string>;
var taken: dict<u64, u32>; # The names in `spelled`, by their hash, to find two types given one.
var written: dict<strview, bool>; # Each constant written, so none is twice.
}
#! Creates a writing of nothing yet.
def writing::new(): writing {
return writing{
names = dict::<strview, u32>::new(),
taken = dict::<u64, u32>::new(),
written = dict::<strview, bool>::new()
};
}
#! Whether a name is one of Sakura's words.
def is_keyword(name: strview): bool {
for &each in keywords {
return true if each == name;
}
return false;
}
#! A C name in snake case, as Sakura names things: a capital begins a word, as
#! does a run of capitals before one, `deviceUUID` is `device_uuid`, a number
#! stays with the word before, `shaderFloat64` is `shader_float64`, and one
#! before a `D` is a word, `maxImageDimension2D` is `max_image_dimension_2d`.
def snake_of(name: strview): string {
var made := string::new(nothing{});
for i in 0..name.length {
val c: u8 = name[i];
if c == '_' {
if made.length != 0 && !made.ends_with("_") {
made.push('_');
}
continue;
}
if i > 0 && made.length != 0 && !made.ends_with("_") {
val before: u8 = name[i - 1];
var after: u8 = 0;
if i + 1 < name.length {
after = name[i + 1];
}
var cut := false;
if c.is_upper {
if before.is_lower {
cut = true;
} else if before.is_digit {
cut = c != 'D' || after.is_lower;
} else if before.is_upper && after.is_lower {
cut = true;
}
} else if c.is_digit && !before.is_digit {
cut = unit_at(name, i);
}
if cut {
made.push('_');
}
}
made.push(c.to_lower);
}
return made;
}
# Whether a run of digits begins at a place, and a `D` follows it as a word, as
# `2D` and `3D` do.
def unit_at(name: strview, at: u64): bool {
var i := at;
while i < name.length && name[i].is_digit {
i++;
}
return i < name.length && name[i] == 'D' && (i + 1 == name.length || !name[i + 1].is_lower);
}
# A C name without the `p`, `pp`, or `pfn` before its first capital.
def without_prefix(name: strview): strview {
for &prefix in pointer_prefixes {
if name.length > prefix.length && name.starts_with(prefix) && name[prefix.length].is_upper {
return name.substr(prefix.length, name.length - prefix.length);
}
}
return name;
}
# A type's C name without its `Vk`.
def without_vk(name: strview): strview {
if name.starts_with("Vk") {
return name.substr(2, name.length - 2);
}
return name;
}
#! A member's or a parameter's name: in snake case, without the prefix of a
#! pointer or a function, and followed by `_` where it's a word of Sakura's.
def member_name_of(reg: &registry, d: &declaration): string {
var name := d.name;
if d.pointers > 0 {
name = without_prefix(name);
} else if reg.type_named(d.base) is some(t) {
if t.category == category::callback {
name = without_prefix(name);
}
}
var made := snake_of(name);
if is_keyword(made.span) {
made.push('_');
}
return made;
}
# A number in hex, as `0x7FFFFFFF`.
def hex_of(n: u64): string {
val digits: strview = "0123456789ABCDEF";
var made := string::from("0x", nothing{});
var started := false;
for j in 0..16u {
val shift: u64 = (15 - j) * 4;
val digit: u64 = (n >> shift) & 0xF;
if digit != 0 || started || j == 15 {
made.push(digits[digit]);
started = true;
}
}
return made;
}
# Sakura's type of a constant of the API, by the C type it says.
def constant_type_of(c_type: strview): strview {
if c_type == "uint64_t" {
return "u64";
} else if c_type == "float" {
return "f32";
} else if c_type == "int32_t" {
return "i32";
}
return "u32";
}
# Sakura's type of an enum's values.
def block_type_of(block: &group_record): strview {
if block.kind == "bitmask" {
return block.wide ? "u64" : "u32";
}
return block.negative ? "i32" : "u32";
}
#! Sakura's type of a constant, by its name: an enum's values', the type an
#! API's constant says, `strview` of a name, or what it's another name for.
def value_type_of(reg: &registry, name: strview): strview {
var at: u32 = 0;
if reg.value_at.get(&name) is some(&found) {
at = found;
} else {
return "u32";
}
val v := &reg.values[at as u64];
if v.group.length == 0 {
if v.alias.length != 0 {
return value_type_of(reg, v.alias);
}
return v.written.starts_with("\"") ? "strview" : "u32";
}
if reg.block_at.get(&v.group) is some(&block) {
val held := &reg.blocks[block as u64];
return held.kind.length == 0 ? constant_type_of(v.c_type) : block_type_of(held);
}
return "u32";
}
#! A value as Sakura writes it, of its type.
def value_text_of(v: &value_record, held: strview): string {
if v.alias.length != 0 {
return string::from(v.alias, nothing{});
}
if v.computed {
return $"{v.offset}";
}
if v.bitpos.length != 0 {
return hex_of((1 as u64) << number_of(v.bitpos));
}
val written := v.written;
# `(~0U)` and `(~0ULL)`: all bits but those of a number.
if written.starts_with("(~") {
val n := number_of(written.substr(2, written.length - 2));
return hex_of(held == "u64" ? ~n : (~n) & 0xFFFFFFFF);
}
if held == "f32" && (written.ends_with("F") || written.ends_with("f")) {
return string::from(written.substr(0, written.length - 1), nothing{});
}
return string::from(written, nothing{});
}
#! Gives each struct and union bound its name. One with an `sType` of its own is
#! named by it, as Vulkan's names are: `VkPhysicalDeviceVulkan13Features` by
#! `VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES`, as
#! `physical_device_vulkan_1_3_features`. Another is its C name in snake case,
#! without its `Vk`, and an alias that only adds its vendor's letters is its
#! type's name and theirs, as `VkPhysicalDeviceFeatures2KHR` is
#! `physical_device_features_2_khr`.
def writing::name_types(&mut this, reg: &registry, picks: &picking, problems: &mut vector<string>): void {
for pass in 0..2u {
for &t in reg.types {
continue if t.category != category::structure && t.category != category::joined;
continue if (t.alias.length != 0) != (pass == 1) || picks.place_of(t.name) is none;
var made := string::new(nothing{});
if t.alias.length == 0 {
made = this.struct_name_of(reg, &t);
} else if this.names.get(&t.alias) is some(&target) {
val rest := t.name.substr(t.alias.length, t.name.length - t.alias.length);
if t.name.starts_with(t.alias) && rest.length != 0 && all_capitals(rest) {
made = string::from(this.spelled[target as u64].span, nothing{});
made.push('_');
made.append(rest.lower().span);
} else {
made = snake_of(without_vk(t.name));
}
} else {
made = snake_of(without_vk(t.name));
}
val hash := made.hash();
if this.taken.get(&hash) is some(&other) {
if this.spelled[other as u64].span == made.span {
problems.append($"{t.name} would be named {made}, as another type is.");
}
}
val at := this.spelled.length as u32;
this.taken.set(hash, at);
this.names.set(t.name, at);
this.spelled.append(move(made));
}
}
}
# Whether a name is all capitals, as a vendor's are.
def all_capitals(name: strview): bool {
for i in 0..name.length {
return false if !name[i].is_upper;
}
return true;
}
# A struct's name: its `sType`'s, or its C name's.
def writing::struct_name_of(&this, reg: &registry, t: &type_record): string {
for &d in reg.declarations_of(t.first, t.count) {
if d.name == "sType" && d.values.starts_with("VK_STRUCTURE_TYPE_") && d.values.find(",") is none {
return d.values.substr(18, d.values.length - 18).lower();
}
}
return snake_of(without_vk(t.name));
}
#! The name a struct or a union is given.
def writing::name_of(&this, c: strview): strview {
if this.names.get(&c) is some(&at) {
return this.spelled[at as u64].span;
}
return c;
}
#! Sakura's type of a type C names.
def writing::base_of(&this, reg: &registry, c: strview, problems: &mut vector<string>): string {
for &each in basic_types {
return string::from(each.sakura, nothing{}) if each.c == c;
}
val t := reg.type_named(c) else {
problems.append($"There's no type {c}.");
return string::from("u8", nothing{});
};
if t.category == category::structure || t.category == category::joined {
if t.alias.length != 0 && !this.names.contains(&c) {
return this.base_of(reg, t.alias, problems);
}
return string::from(this.name_of(c), nothing{});
}
if t.category == category::callback {
return string::from(c, nothing{});
}
if t.category == category::handle {
return string::from("u64", nothing{});
}
if t.alias.length != 0 {
return this.base_of(reg, t.alias, problems);
}
if t.category == category::bitmask {
return string::from(t.wide ? "u64" : "u32", nothing{});
}
if t.category == category::enumerated {
if reg.block_at.get(&c) is some(&block) {
return string::from(block_type_of(&reg.blocks[block as u64]), nothing{});
}
return string::from("u32", nothing{});
}
if t.category == category::base {
return t.requires.length != 0 ? this.base_of(reg, t.requires, problems) : string::from("u8", nothing{});
}
problems.append($"{c} isn't a type that's bound.");
return string::from("u8", nothing{});
}
# Whether a parameter is a reference, as `&T` or `&mut T`: a pointer to one
# thing that's there, not to an array, nor to nothing, nor to bytes.
def writing::takes_reference(&this, reg: &registry, d: &declaration, problems: &mut vector<string>): bool {
if d.pointers == 0 || d.len.length != 0 || d.optional.starts_with("true") {
return false;
}
if d.pointers == 1 {
val base := this.base_of(reg, d.base, problems);
return base.span != "u8";
}
return true;
}
#! Sakura's type of a declaration: of a member, or of a function's parameter,
#! whose pointer may be a reference and whose array is one.
def writing::type_of(&mut this, reg: &registry, d: &declaration, parameter: bool, problems: &mut vector<string>): string {
var made := string::new(nothing{});
if parameter && d.lengths > 0 {
made.append((d.consts & 1) != 0 ? "&" : "&mut ");
}
val reference := parameter && this.takes_reference(reg, d, problems);
var k := d.pointers;
while k > 0 {
val held := ((d.consts >> (k - 1)) & 1) != 0;
if reference && k == d.pointers {
made.append(held ? "&" : "&mut ");
} else {
made.append(held ? "*" : "*mut ");
}
k--;
}
made.append(this.base_of(reg, d.base, problems).span);
# Sakura writes an array of arrays innermost first, C outermost first, so C's
# `float matrix[3][4]`, 3 of 4, is `f32[4][3]`, indexed alike.
var i: u64 = d.lengths;
while i > 0 {
i--;
made.push('[');
made.append(size_of_array(reg, d.sizes[i]).span);
made.push(']');
}
return made;
}
# An array's length, as a number, of a number or a constant's name.
def size_of_array(reg: &registry, size: strview): string {
if size.length != 0 && size[0].is_digit {
return string::from(size, nothing{});
}
if reg.value_at.get(&size) is some(&at) {
return string::from(reg.values[at as u64].written, nothing{});
}
return string::from(size, nothing{});
}
# What's said of a member: the C type it's of where Sakura's says less, as
# `VkFormat` of a `u32`, and what the registry says of it.
def doc_of(reg: &registry, d: &declaration): string {
var made := string::new(nothing{});
var said := false;
if reg.type_named(d.base) is some(t) {
said = t.category == category::handle || t.category == category::enumerated
|| t.category == category::bitmask || (t.category == category::base && t.requires.length != 0);
if t.category == category::basic {
said = true;
for i in 0..c_types {
if basic_types[i].c == d.base {
said = false;
}
}
}
}
if said {
made.append(d.base);
}
val about := said_of(d.comment);
if about.length != 0 {
made.append(said ? ": " : "");
made.append(about);
}
return made;
}
# What the registry says of something, without the marks of a C comment or
# its last full stop.
def said_of(comment: strview): strview {
var made := comment.trim();
if made.starts_with("//") {
made = made.substr(2, made.length - 2).trim();
}
while made.ends_with(".") {
made = made.substr(0, made.length - 1);
}
return made;
}
# Whether a value is written: given by a set bound, or one of an enum bound.
def bound_value(reg: &registry, picks: &picking, name: strview): bool {
if picks.given.contains(&name) {
return true;
}
if reg.value_at.get(&name) is some(&at) {
return picks.place_of(reg.values[at as u64].group) is some(_);
}
return false;
}
# Writes a struct or a union.
def writing::write_struct(&mut this, reg: &registry, picks: &picking, t: &type_record, into: &mut string, problems: &mut vector<string>): void {
var lines := vector::<field_line>::new();
val members := reg.declarations_of(t.first, t.count);
var i: u64 = 0;
while i < members.length {
val d := &members[i];
var line := field_line{
name = member_name_of(reg, d),
held = this.type_of(reg, d, false, problems),
tail = string::new(nothing{})
};
# A run of bitfields is one field of their type, named for them all.
if d.bits != 0 {
var bits: u32 = 0;
var said := string::from("Bits, the lowest first: ", nothing{});
while i < members.length && members[i].bits != 0 && bits < 32 {
if bits != 0 {
line.name.append("_and_");
line.name.append(member_name_of(reg, &members[i]).span);
said.append(", ");
}
said.append($"{members[i].name}, {members[i].bits}");
bits += members[i].bits;
i++;
}
line.tail.append($"; #! {said}.");
lines.append(move(line));
continue;
}
for &other in lines {
if other.name.span == line.name.span {
line.name = snake_of(d.name);
}
}
if d.values.length != 0 && d.values.find(",") is none && bound_value(reg, picks, d.values) {
line.tail.append(" = ");
line.tail.append(d.values);
}
line.tail.push(';');
val said := doc_of(reg, d);
if said.length != 0 {
line.tail.append(" #! ");
line.tail.append(said.span);
}
lines.append(move(line));
i++;
}
into.append($"\n#! `{t.name}`");
val about := said_of(t.comment);
if about.length != 0 {
into.append($": {about}");
}
into.append(".\n");
into.append(t.category == category::structure ? "pub struct " : "pub union ");
into.append(this.name_of(t.name));
into.append(" {\n");
var width: u64 = 0;
for &line in lines {
width = line.name.length > width ? line.name.length : width;
}
for &line in lines {
into.append(" pub var ");
into.append(line.name.span);
into.push(':');
for _ in line.name.length..(width + 1) {
into.push(' ');
}
into.append(line.held.span);
into.append(line.tail.span);
into.push('\n');
}
into.append("}\n");
}
# A function's type, as `cfn<def(&T, *u8): i32>`, of its parameters and what it
# returns.
def writing::function_type_of(&mut this, reg: &registry, params: span<declaration>, returns: &declaration, references: bool, problems: &mut vector<string>): string {
var made := string::from("cfn<def(", nothing{});
for i, &d in params {
if i != 0 {
made.append(", ");
}
made.append(this.type_of(reg, &d, references, problems).span);
}
made.append("): ");
made.append(this.returned_of(reg, returns, problems).span);
made.push('>');
return made;
}
# What a function returns, as Sakura writes it.
def writing::returned_of(&mut this, reg: &registry, returns: &declaration, problems: &mut vector<string>): string {
if returns.base == "void" && returns.pointers == 0 {
return string::from("void", nothing{});
}
return this.type_of(reg, returns, false, problems);
}
#! Writes the types of a place: its structs and unions, its aliases of them,
#! and the functions C calls back.
def writing::types_of(&mut this, reg: &registry, picks: &picking, place: u32, into: &mut string, problems: &mut vector<string>): void {
for &t in reg.types {
continue if !picks.is_at(t.name, place);
if t.category == category::structure || t.category == category::joined {
if t.alias.length == 0 {
this.write_struct(reg, picks, &t, into, problems);
} else if this.name_of(t.name) != this.name_of(t.alias) {
into.append($"\n#! `{t.name}`, another name for `{t.alias}`.\npub type {this.name_of(t.name)} = {this.name_of(t.alias)};\n");
}
} else if t.category == category::callback {
if t.alias.length != 0 {
into.append($"\n#! `{t.name}`, another name for `{t.alias}`.\npub type {t.name} = {t.alias};\n");
continue;
}
val params := reg.declarations_of(t.first, t.count);
into.append($"\n#! `{t.name}`, called with");
if params.length == 0 {
into.append(" nothing");
}
for i, &d in params {
into.append(i == 0 ? " " : ", ");
into.append($"`{d.name}`");
}
into.append($".\npub type {t.name} = {this.function_type_of(reg, params, &t.returns, false, problems)};\n");
}
}
}
#! Writes the commands of a place: each the loader exports as C's function, and
#! each one's type, as `vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` give it.
#! @returns Whether it wrote a function of C's.
def writing::commands_of(&mut this, reg: &registry, picks: &picking, place: u32, into: &mut string, problems: &mut vector<string>): bool {
var linked := false;
for &c in reg.commands {
continue if c.alias.length != 0 || !picks.is_at(c.name, place) || !picks.exported.contains(&c.name);
if !linked {
into.append("\n# The functions the loader exports.\n");
linked = true;
}
into.append($"pub def {c.name}(");
var names := vector::<string>::new();
for i, &d in reg.declarations_of(c.first, c.count) {
if i != 0 {
into.append(", ");
}
var name := member_name_of(reg, &d);
for &other in names {
if other.span == name.span {
name = snake_of(d.name);
}
}
into.append($"{name}: {this.type_of(reg, &d, true, problems)}");
names.append(move(name));
}
into.append($"): {this.returned_of(reg, &c.returns, problems)};\n");
}
var typed := false;
for &c in reg.commands {
continue if !picks.is_at(c.name, place);
if !typed {
into.append("\n# Each command's type, as `vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` give\n# it, to be cast to.\n");
typed = true;
}
if c.alias.length != 0 {
into.append($"pub type PFN_{c.name} = PFN_{c.alias};\n");
} else {
val params := reg.declarations_of(c.first, c.count);
into.append($"pub type PFN_{c.name} = {this.function_type_of(reg, params, &c.returns, true, problems)};\n");
}
}
return linked;
}
# Writes a constant, once.
def writing::write_value(&mut this, v: &value_record, held: strview, into: &mut string): void {
if this.written.contains(&v.name) {
return;
}
this.written.set(v.name, true);
into.append($"pub const {v.name}: {held} = {value_text_of(v, held)};");
if v.comment.length != 0 {
into.append($" #! {v.comment}");
}
into.push('\n');
}
#! Writes the constants of a place: the API's, those features and extensions
#! define, and each enum's values, under the enum's name.
def writing::constants_of(&mut this, reg: &registry, picks: &picking, place: u32, into: &mut string): void {
for &block in reg.blocks {
continue if block.kind.length != 0;
var heading := false;
for i in block.first..(block.first + block.count) {
val v := &reg.values[i as u64];
continue if !picks.is_at(v.name, place);
if !heading {
into.append($"\n# {block.name}\n");
heading = true;
}
this.write_value(v, constant_type_of(v.c_type), into);
}
}
var definer: u32 = 0xFFFFFFFF;
for k in 0..picks.defined.length {
val v := &reg.values[picks.defined[k] as u64];
continue if !picks.is_at(v.name, place);
if picks.definers[k] != definer {
definer = picks.definers[k];
into.append($"\n# {reg.sets[definer as u64].name}\n");
}
this.write_value(v, value_type_of(reg, v.name), into);
}
for &block in reg.blocks {
continue if block.kind.length == 0;
val held := block_type_of(&block);
var heading := false;
if picks.is_at(block.name, place) {
for i in block.first..(block.first + block.count) {
val v := &reg.values[i as u64];
continue if picks.removed.contains(&v.name) || this.written.contains(&v.name);
if !heading {
into.append($"\n# {block.name}\n");
heading = true;
}
this.write_value(v, held, into);
}
}
for &at in picks.extended {
val v := &reg.values[at as u64];
continue if v.group != block.name || !picks.is_at(v.name, place) || this.written.contains(&v.name);
if !heading {
into.append($"\n# {block.name}\n");
heading = true;
}
this.write_value(v, held, into);
}
}
}
# The note every file ends its first comment with.
def made_note(version: strview): string {
return $"#!\n#! Written by `malunal.vulkan.bindings` from the registry of {version}: run\n#! it again, rather than editing this.\n";
}
# The libraries each system's loader is.
const loaders: strview = "extern import \"vulkan-1.dll\" when os == windows;\nextern import \"libvulkan.so.1\" when os == linux;\n";
# The section every system builds.
const every_system: strview = "extern module malunal::vulkan when os == windows || os == linux;\n";
# The newest version of Vulkan's core the registry has, among its sets.
def newest_feature_of(reg: &registry): u32 {
var newest: u32 = 0;
for i, &each in reg.sets {
continue if !each.feature || !each.supported;
val held := &reg.sets[newest as u64];
if !held.feature || each.major > held.major || (each.major == held.major && each.minor > held.minor) {
newest = i as u32;
}
}
return newest;
}
# That version, as `1.4`.
def newest_of(reg: &registry): string {
val set := &reg.sets[newest_feature_of(reg) as u64];
return $"{set.major}.{set.minor}";
}
# The file of the module's own: what it is, the versions of Vulkan, and how a
# version is written.
def writing::overview_of(&mut this, reg: &registry, picks: &picking, version: strview): string {
val newest := &reg.sets[newest_feature_of(reg) as u64];
val newest_major := newest.major;
val newest_minor := newest.minor;
var made := string::from("""
#! Contains `malunal::vulkan`: Vulkan, as its registry declares it, for Sakura.
#! It holds the functions of Vulkan's core and of the extensions bound, the
#! structs and unions they take, laid out as C lays them out, and the numbers
#! they're asked for and give, with the versions of Vulkan, and how a version
#! is written.
#!
#! What C names keeps its name: each function, as `vkCreateInstance`; each
#! constant, as `VK_FORMAT_R8G8B8A8_UNORM`; and each function's type, as
#! `PFN_vkCreateInstance`. A struct or a union with a `VK_STRUCTURE_TYPE_` of
#! its own is named by it, as Vulkan's names are, in lower case:
#! `VkPhysicalDeviceVulkan13Features` is `physical_device_vulkan_1_3_features`.
#! Another is named in snake case without its `Vk`: `VkExtent2D` is
#! `extent_2d`. A member is in snake case, without the `p` or `pp` of a pointer
#! or the `pfn` of a function, `ppEnabledLayerNames` as `enabled_layer_names`,
#! and followed by `_` where it'd be a word of Sakura's, as `module_`. A
#! struct's `s_type` is its own by default.
#!
#! Handles are `u64`s. An enum is its values' type, `u32`, or `i32` for
#! `VkResult`, flags are `u32`, or `u64` where they're of 64 bits, and
#! `VkBool32` is a `u32`: a member of one says which C type it is. A function's
#! parameter that points to one thing that must be there is a reference, `&T`
#! where it's read, and `&mut T` where it's written; one that may be null, or
#! points to an array or to bytes, is a pointer, `*T` or `*mut T`.
#!
#! The functions the loader exports, those of the core and of surfaces and
#! swapchains, are C's, and found in it. Every command has its type, as
#! `PFN_vkCreateDebugUtilsMessengerEXT`, to call what `vkGetInstanceProcAddr`
#! and `vkGetDeviceProcAddr` give: an extension's that the loader doesn't
#! export are called only so.
""", nothing{});
made.append(made_note(version).span);
made.append("\n");
made.append(every_system);
made.append($"\n#! The registry's own version, `VK_HEADER_VERSION`, as Vulkan {newest_major}.{newest_minor}.{reg.header} is.\n");
made.append($"pub const VK_HEADER_VERSION: u32 = {reg.header};\n");
made.append("#! The registry's whole version, as `VK_MAKE_API_VERSION` writes it.\n");
made.append($"pub const VK_HEADER_VERSION_COMPLETE: u32 = ({newest_major} << 22) | ({newest_minor} << 12) | {reg.header};\n");
made.append("\n# Each version of Vulkan's core bound, as `VkApplicationInfo::apiVersion` names it.\n");
for &at in picks.order {
val set := &reg.sets[at as u64];
continue if !set.feature;
made.append($"pub const VK_API_VERSION_{set.major}_{set.minor}: u32 = ({set.major} << 22) | ({set.minor} << 12);\n");
}
made.append("""
#! No handle at all.
pub const VK_NULL_HANDLE: u64 = 0;
#! A version, as Vulkan writes it: its variant, 0 for Vulkan's, in 3 bits, then
#! its major version in 7, its minor version in 10, and its patch in 12.
pub def VK_MAKE_API_VERSION(variant: u32, major: u32, minor: u32, patch: u32): u32 {
return (variant << 29) | (major << 22) | (minor << 12) | patch;
}
#! A version's variant.
pub def VK_API_VERSION_VARIANT(version: u32): u32 {
return version >> 29;
}
#! A version's major version.
pub def VK_API_VERSION_MAJOR(version: u32): u32 {
return (version >> 22) & 0x7F;
}
#! A version's minor version.
pub def VK_API_VERSION_MINOR(version: u32): u32 {
return (version >> 12) & 0x3FF;
}
#! A version's patch.
pub def VK_API_VERSION_PATCH(version: u32): u32 {
return version & 0xFFF;
}
""");
return made;
}
#! Reads a registry, and writes the files of what's wanted of it.
#! @param text The registry's text, of `vk.xml`.
#! @param wanted What's bound.
#! @param into Where the files go, each named within the library's folder.
#! @param problems Where why they couldn't be written is said.
#! @returns Whether they were.
def bindings_of(text: strview, wanted: &wanting, into: &mut vector<made_file>, problems: &mut vector<string>): bool {
var reg := registry::new();
if !reg.read(text, problems) {
return false;
}
var picks := picking::new();
if !picks.pick(&reg, wanted, problems) {
return false;
}
var w := writing::new();
w.name_types(&reg, &picks, problems);
var version := $"Vulkan {newest_of(&reg)}.{reg.header}";
if picks.major != reg.sets[newest_feature_of(&reg) as u64].major || picks.minor != reg.sets[newest_feature_of(&reg) as u64].minor {
version.append($", to Vulkan {picks.major}.{picks.minor}");
}
into.append(made_file{ name = string::from("vulkan.sakura", nothing{}), text = w.overview_of(&reg, &picks, version.span) });
var constants := string::from("""
#! Contains the constants of `malunal::vulkan`: the API's, those its features
#! and extensions define, and each enum's values, under the enum's name.
""", nothing{});
constants.append(made_note(version.span).span);
constants.append("\n");
constants.append(every_system);
w.constants_of(&reg, &picks, 0, &mut constants);
into.append(made_file{ name = string::from("constants.sakura", nothing{}), text = move(constants) });
var types := string::from("""
#! Contains the types of `malunal::vulkan`: its structs and unions, laid out as
#! C lays them out, each with the C name it has in the registry, and the
#! functions C calls back.
""", nothing{});
types.append(made_note(version.span).span);
types.append("\n");
types.append(every_system);
w.types_of(&reg, &picks, 0, &mut types, problems);
into.append(made_file{ name = string::from("types.sakura", nothing{}), text = move(types) });
var commands := string::from("""
#! Contains the commands of `malunal::vulkan`: the functions the loader exports,
#! as C's, and each command's type.
""", nothing{});
commands.append(made_note(version.span).span);
commands.append("\n");
commands.append(loaders);
commands.append("\n");
commands.append(every_system);
w.commands_of(&reg, &picks, 0, &mut commands, problems);
into.append(made_file{ name = string::from("commands.sakura", nothing{}), text = move(commands) });
# Each platform's file, of what only its extensions need.
for i in 0..6u {
val place := i as u32 + 1;
val platform := platform_files[i];
var named := string::new(nothing{});
for &at in picks.order {
val set := &reg.sets[at as u64];
if set.platform == platform.platform {
named.append(named.length == 0 ? "`" : ", `");
named.append(set.name);
named.append("`");
}
}
continue if named.length == 0;
var body := string::new(nothing{});
w.constants_of(&reg, &picks, place, &mut body);
w.types_of(&reg, &picks, place, &mut body, problems);
var calls := string::new(nothing{});
val linked := w.commands_of(&reg, &picks, place, &mut calls, problems);
body.append(calls.span);
val system := platform.os == "windows" ? "Windows" : "Linux";
var made := string::from($"#! Contains the part of `malunal::vulkan` only {system} has, of {platform.platform}'s\n#! extensions: {named}.\n", nothing{});
made.append(made_note(version.span).span);
made.append("\n");
if linked {
made.append(platform.os == "windows" ? "extern import \"vulkan-1.dll\" when os == windows;\n\n" : "extern import \"libvulkan.so.1\" when os == linux;\n\n");
}
made.append($"extern module malunal::vulkan when os == {platform.os};\n");
made.append(body.span);
into.append(made_file{ name = $"{platform.platform}.sakura", text = move(made) });
}
return problems.length == 0;
}
+552
View File
@@ -0,0 +1,552 @@
#! Contains the commands of `malunal::vulkan`: the functions the loader exports,
#! as C's, and each command's type.
#!
#! Written by `malunal.vulkan.bindings` from the registry of Vulkan 1.4.328: run
#! it again, rather than editing this.
extern import "vulkan-1.dll" when os == windows;
extern import "libvulkan.so.1" when os == linux;
extern module malunal::vulkan when os == windows || os == linux;
# The functions the loader exports.
pub def vkCreateInstance(create_info: &instance_create_info, allocator: *allocation_callbacks, instance: &mut u64): i32;
pub def vkDestroyInstance(instance: u64, allocator: *allocation_callbacks): void;
pub def vkEnumeratePhysicalDevices(instance: u64, physical_device_count: &mut u32, physical_devices: *mut u64): i32;
pub def vkGetDeviceProcAddr(device: u64, name: *u8): PFN_vkVoidFunction;
pub def vkGetInstanceProcAddr(instance: u64, name: *u8): PFN_vkVoidFunction;
pub def vkGetPhysicalDeviceProperties(physical_device: u64, properties: &mut physical_device_properties): void;
pub def vkGetPhysicalDeviceQueueFamilyProperties(physical_device: u64, queue_family_property_count: &mut u32, queue_family_properties: *mut queue_family_properties): void;
pub def vkGetPhysicalDeviceMemoryProperties(physical_device: u64, memory_properties: &mut physical_device_memory_properties): void;
pub def vkGetPhysicalDeviceFeatures(physical_device: u64, features: &mut physical_device_features): void;
pub def vkGetPhysicalDeviceFormatProperties(physical_device: u64, format: u32, format_properties: &mut format_properties): void;
pub def vkGetPhysicalDeviceImageFormatProperties(physical_device: u64, format: u32, type_: u32, tiling: u32, usage: u32, flags: u32, image_format_properties: &mut image_format_properties): i32;
pub def vkCreateDevice(physical_device: u64, create_info: &device_create_info, allocator: *allocation_callbacks, device: &mut u64): i32;
pub def vkDestroyDevice(device: u64, allocator: *allocation_callbacks): void;
pub def vkEnumerateInstanceVersion(api_version: &mut u32): i32;
pub def vkEnumerateInstanceLayerProperties(property_count: &mut u32, properties: *mut layer_properties): i32;
pub def vkEnumerateInstanceExtensionProperties(layer_name: *u8, property_count: &mut u32, properties: *mut extension_properties): i32;
pub def vkEnumerateDeviceLayerProperties(physical_device: u64, property_count: &mut u32, properties: *mut layer_properties): i32;
pub def vkEnumerateDeviceExtensionProperties(physical_device: u64, layer_name: *u8, property_count: &mut u32, properties: *mut extension_properties): i32;
pub def vkGetDeviceQueue(device: u64, queue_family_index: u32, queue_index: u32, queue: &mut u64): void;
pub def vkQueueSubmit(queue: u64, submit_count: u32, submits: *submit_info, fence: u64): i32;
pub def vkQueueWaitIdle(queue: u64): i32;
pub def vkDeviceWaitIdle(device: u64): i32;
pub def vkAllocateMemory(device: u64, allocate_info: &memory_allocate_info, allocator: *allocation_callbacks, memory: &mut u64): i32;
pub def vkFreeMemory(device: u64, memory: u64, allocator: *allocation_callbacks): void;
pub def vkMapMemory(device: u64, memory: u64, offset: u64, size: u64, flags: u32, data: &mut *mut u8): i32;
pub def vkUnmapMemory(device: u64, memory: u64): void;
pub def vkFlushMappedMemoryRanges(device: u64, memory_range_count: u32, memory_ranges: *mapped_memory_range): i32;
pub def vkInvalidateMappedMemoryRanges(device: u64, memory_range_count: u32, memory_ranges: *mapped_memory_range): i32;
pub def vkGetDeviceMemoryCommitment(device: u64, memory: u64, committed_memory_in_bytes: &mut u64): void;
pub def vkGetBufferMemoryRequirements(device: u64, buffer: u64, memory_requirements: &mut memory_requirements): void;
pub def vkBindBufferMemory(device: u64, buffer: u64, memory: u64, memory_offset: u64): i32;
pub def vkGetImageMemoryRequirements(device: u64, image: u64, memory_requirements: &mut memory_requirements): void;
pub def vkBindImageMemory(device: u64, image: u64, memory: u64, memory_offset: u64): i32;
pub def vkGetImageSparseMemoryRequirements(device: u64, image: u64, sparse_memory_requirement_count: &mut u32, sparse_memory_requirements: *mut sparse_image_memory_requirements): void;
pub def vkGetPhysicalDeviceSparseImageFormatProperties(physical_device: u64, format: u32, type_: u32, samples: u32, usage: u32, tiling: u32, property_count: &mut u32, properties: *mut sparse_image_format_properties): void;
pub def vkQueueBindSparse(queue: u64, bind_info_count: u32, bind_info: *bind_sparse_info, fence: u64): i32;
pub def vkCreateFence(device: u64, create_info: &fence_create_info, allocator: *allocation_callbacks, fence: &mut u64): i32;
pub def vkDestroyFence(device: u64, fence: u64, allocator: *allocation_callbacks): void;
pub def vkResetFences(device: u64, fence_count: u32, fences: *u64): i32;
pub def vkGetFenceStatus(device: u64, fence: u64): i32;
pub def vkWaitForFences(device: u64, fence_count: u32, fences: *u64, wait_all: u32, timeout: u64): i32;
pub def vkCreateSemaphore(device: u64, create_info: &semaphore_create_info, allocator: *allocation_callbacks, semaphore: &mut u64): i32;
pub def vkDestroySemaphore(device: u64, semaphore: u64, allocator: *allocation_callbacks): void;
pub def vkCreateEvent(device: u64, create_info: &event_create_info, allocator: *allocation_callbacks, event: &mut u64): i32;
pub def vkDestroyEvent(device: u64, event: u64, allocator: *allocation_callbacks): void;
pub def vkGetEventStatus(device: u64, event: u64): i32;
pub def vkSetEvent(device: u64, event: u64): i32;
pub def vkResetEvent(device: u64, event: u64): i32;
pub def vkCreateQueryPool(device: u64, create_info: &query_pool_create_info, allocator: *allocation_callbacks, query_pool: &mut u64): i32;
pub def vkDestroyQueryPool(device: u64, query_pool: u64, allocator: *allocation_callbacks): void;
pub def vkGetQueryPoolResults(device: u64, query_pool: u64, first_query: u32, query_count: u32, data_size: u64, data: *mut u8, stride: u64, flags: u32): i32;
pub def vkResetQueryPool(device: u64, query_pool: u64, first_query: u32, query_count: u32): void;
pub def vkCreateBuffer(device: u64, create_info: &buffer_create_info, allocator: *allocation_callbacks, buffer: &mut u64): i32;
pub def vkDestroyBuffer(device: u64, buffer: u64, allocator: *allocation_callbacks): void;
pub def vkCreateBufferView(device: u64, create_info: &buffer_view_create_info, allocator: *allocation_callbacks, view: &mut u64): i32;
pub def vkDestroyBufferView(device: u64, buffer_view: u64, allocator: *allocation_callbacks): void;
pub def vkCreateImage(device: u64, create_info: &image_create_info, allocator: *allocation_callbacks, image: &mut u64): i32;
pub def vkDestroyImage(device: u64, image: u64, allocator: *allocation_callbacks): void;
pub def vkGetImageSubresourceLayout(device: u64, image: u64, subresource: &image_subresource, layout: &mut subresource_layout): void;
pub def vkCreateImageView(device: u64, create_info: &image_view_create_info, allocator: *allocation_callbacks, view: &mut u64): i32;
pub def vkDestroyImageView(device: u64, image_view: u64, allocator: *allocation_callbacks): void;
pub def vkCreateShaderModule(device: u64, create_info: &shader_module_create_info, allocator: *allocation_callbacks, shader_module: &mut u64): i32;
pub def vkDestroyShaderModule(device: u64, shader_module: u64, allocator: *allocation_callbacks): void;
pub def vkCreatePipelineCache(device: u64, create_info: &pipeline_cache_create_info, allocator: *allocation_callbacks, pipeline_cache: &mut u64): i32;
pub def vkDestroyPipelineCache(device: u64, pipeline_cache: u64, allocator: *allocation_callbacks): void;
pub def vkGetPipelineCacheData(device: u64, pipeline_cache: u64, data_size: &mut u64, data: *mut u8): i32;
pub def vkMergePipelineCaches(device: u64, dst_cache: u64, src_cache_count: u32, src_caches: *u64): i32;
pub def vkCreateGraphicsPipelines(device: u64, pipeline_cache: u64, create_info_count: u32, create_infos: *graphics_pipeline_create_info, allocator: *allocation_callbacks, pipelines: *mut u64): i32;
pub def vkCreateComputePipelines(device: u64, pipeline_cache: u64, create_info_count: u32, create_infos: *compute_pipeline_create_info, allocator: *allocation_callbacks, pipelines: *mut u64): i32;
pub def vkDestroyPipeline(device: u64, pipeline: u64, allocator: *allocation_callbacks): void;
pub def vkCreatePipelineLayout(device: u64, create_info: &pipeline_layout_create_info, allocator: *allocation_callbacks, pipeline_layout: &mut u64): i32;
pub def vkDestroyPipelineLayout(device: u64, pipeline_layout: u64, allocator: *allocation_callbacks): void;
pub def vkCreateSampler(device: u64, create_info: &sampler_create_info, allocator: *allocation_callbacks, sampler: &mut u64): i32;
pub def vkDestroySampler(device: u64, sampler: u64, allocator: *allocation_callbacks): void;
pub def vkCreateDescriptorSetLayout(device: u64, create_info: &descriptor_set_layout_create_info, allocator: *allocation_callbacks, set_layout: &mut u64): i32;
pub def vkDestroyDescriptorSetLayout(device: u64, descriptor_set_layout: u64, allocator: *allocation_callbacks): void;
pub def vkCreateDescriptorPool(device: u64, create_info: &descriptor_pool_create_info, allocator: *allocation_callbacks, descriptor_pool: &mut u64): i32;
pub def vkDestroyDescriptorPool(device: u64, descriptor_pool: u64, allocator: *allocation_callbacks): void;
pub def vkResetDescriptorPool(device: u64, descriptor_pool: u64, flags: u32): i32;
pub def vkAllocateDescriptorSets(device: u64, allocate_info: &descriptor_set_allocate_info, descriptor_sets: *mut u64): i32;
pub def vkFreeDescriptorSets(device: u64, descriptor_pool: u64, descriptor_set_count: u32, descriptor_sets: *u64): i32;
pub def vkUpdateDescriptorSets(device: u64, descriptor_write_count: u32, descriptor_writes: *write_descriptor_set, descriptor_copy_count: u32, descriptor_copies: *copy_descriptor_set): void;
pub def vkCreateFramebuffer(device: u64, create_info: &framebuffer_create_info, allocator: *allocation_callbacks, framebuffer: &mut u64): i32;
pub def vkDestroyFramebuffer(device: u64, framebuffer: u64, allocator: *allocation_callbacks): void;
pub def vkCreateRenderPass(device: u64, create_info: &render_pass_create_info, allocator: *allocation_callbacks, render_pass: &mut u64): i32;
pub def vkDestroyRenderPass(device: u64, render_pass: u64, allocator: *allocation_callbacks): void;
pub def vkGetRenderAreaGranularity(device: u64, render_pass: u64, granularity: &mut extent_2d): void;
pub def vkGetRenderingAreaGranularity(device: u64, rendering_area_info: &rendering_area_info, granularity: &mut extent_2d): void;
pub def vkCreateCommandPool(device: u64, create_info: &command_pool_create_info, allocator: *allocation_callbacks, command_pool: &mut u64): i32;
pub def vkDestroyCommandPool(device: u64, command_pool: u64, allocator: *allocation_callbacks): void;
pub def vkResetCommandPool(device: u64, command_pool: u64, flags: u32): i32;
pub def vkAllocateCommandBuffers(device: u64, allocate_info: &command_buffer_allocate_info, command_buffers: *mut u64): i32;
pub def vkFreeCommandBuffers(device: u64, command_pool: u64, command_buffer_count: u32, command_buffers: *u64): void;
pub def vkBeginCommandBuffer(command_buffer: u64, begin_info: &command_buffer_begin_info): i32;
pub def vkEndCommandBuffer(command_buffer: u64): i32;
pub def vkResetCommandBuffer(command_buffer: u64, flags: u32): i32;
pub def vkCmdBindPipeline(command_buffer: u64, pipeline_bind_point: u32, pipeline: u64): void;
pub def vkCmdSetViewport(command_buffer: u64, first_viewport: u32, viewport_count: u32, viewports: *viewport): void;
pub def vkCmdSetScissor(command_buffer: u64, first_scissor: u32, scissor_count: u32, scissors: *rect_2d): void;
pub def vkCmdSetLineWidth(command_buffer: u64, line_width: f32): void;
pub def vkCmdSetDepthBias(command_buffer: u64, depth_bias_constant_factor: f32, depth_bias_clamp: f32, depth_bias_slope_factor: f32): void;
pub def vkCmdSetBlendConstants(command_buffer: u64, blend_constants: &f32[4]): void;
pub def vkCmdSetDepthBounds(command_buffer: u64, min_depth_bounds: f32, max_depth_bounds: f32): void;
pub def vkCmdSetStencilCompareMask(command_buffer: u64, face_mask: u32, compare_mask: u32): void;
pub def vkCmdSetStencilWriteMask(command_buffer: u64, face_mask: u32, write_mask: u32): void;
pub def vkCmdSetStencilReference(command_buffer: u64, face_mask: u32, reference: u32): void;
pub def vkCmdBindDescriptorSets(command_buffer: u64, pipeline_bind_point: u32, layout: u64, first_set: u32, descriptor_set_count: u32, descriptor_sets: *u64, dynamic_offset_count: u32, dynamic_offsets: *u32): void;
pub def vkCmdBindIndexBuffer(command_buffer: u64, buffer: u64, offset: u64, index_type: u32): void;
pub def vkCmdBindVertexBuffers(command_buffer: u64, first_binding: u32, binding_count: u32, buffers: *u64, offsets: *u64): void;
pub def vkCmdDraw(command_buffer: u64, vertex_count: u32, instance_count: u32, first_vertex: u32, first_instance: u32): void;
pub def vkCmdDrawIndexed(command_buffer: u64, index_count: u32, instance_count: u32, first_index: u32, vertex_offset: i32, first_instance: u32): void;
pub def vkCmdDrawIndirect(command_buffer: u64, buffer: u64, offset: u64, draw_count: u32, stride: u32): void;
pub def vkCmdDrawIndexedIndirect(command_buffer: u64, buffer: u64, offset: u64, draw_count: u32, stride: u32): void;
pub def vkCmdDispatch(command_buffer: u64, group_count_x: u32, group_count_y: u32, group_count_z: u32): void;
pub def vkCmdDispatchIndirect(command_buffer: u64, buffer: u64, offset: u64): void;
pub def vkCmdCopyBuffer(command_buffer: u64, src_buffer: u64, dst_buffer: u64, region_count: u32, regions: *buffer_copy): void;
pub def vkCmdCopyImage(command_buffer: u64, src_image: u64, src_image_layout: u32, dst_image: u64, dst_image_layout: u32, region_count: u32, regions: *image_copy): void;
pub def vkCmdBlitImage(command_buffer: u64, src_image: u64, src_image_layout: u32, dst_image: u64, dst_image_layout: u32, region_count: u32, regions: *image_blit, filter: u32): void;
pub def vkCmdCopyBufferToImage(command_buffer: u64, src_buffer: u64, dst_image: u64, dst_image_layout: u32, region_count: u32, regions: *buffer_image_copy): void;
pub def vkCmdCopyImageToBuffer(command_buffer: u64, src_image: u64, src_image_layout: u32, dst_buffer: u64, region_count: u32, regions: *buffer_image_copy): void;
pub def vkCmdUpdateBuffer(command_buffer: u64, dst_buffer: u64, dst_offset: u64, data_size: u64, data: *u8): void;
pub def vkCmdFillBuffer(command_buffer: u64, dst_buffer: u64, dst_offset: u64, size: u64, data: u32): void;
pub def vkCmdClearColorImage(command_buffer: u64, image: u64, image_layout: u32, color: &clear_color_value, range_count: u32, ranges: *image_subresource_range): void;
pub def vkCmdClearDepthStencilImage(command_buffer: u64, image: u64, image_layout: u32, depth_stencil: &clear_depth_stencil_value, range_count: u32, ranges: *image_subresource_range): void;
pub def vkCmdClearAttachments(command_buffer: u64, attachment_count: u32, attachments: *clear_attachment, rect_count: u32, rects: *clear_rect): void;
pub def vkCmdResolveImage(command_buffer: u64, src_image: u64, src_image_layout: u32, dst_image: u64, dst_image_layout: u32, region_count: u32, regions: *image_resolve): void;
pub def vkCmdSetEvent(command_buffer: u64, event: u64, stage_mask: u32): void;
pub def vkCmdResetEvent(command_buffer: u64, event: u64, stage_mask: u32): void;
pub def vkCmdWaitEvents(command_buffer: u64, event_count: u32, events: *u64, src_stage_mask: u32, dst_stage_mask: u32, memory_barrier_count: u32, memory_barriers: *memory_barrier, buffer_memory_barrier_count: u32, buffer_memory_barriers: *buffer_memory_barrier, image_memory_barrier_count: u32, image_memory_barriers: *image_memory_barrier): void;
pub def vkCmdPipelineBarrier(command_buffer: u64, src_stage_mask: u32, dst_stage_mask: u32, dependency_flags: u32, memory_barrier_count: u32, memory_barriers: *memory_barrier, buffer_memory_barrier_count: u32, buffer_memory_barriers: *buffer_memory_barrier, image_memory_barrier_count: u32, image_memory_barriers: *image_memory_barrier): void;
pub def vkCmdBeginQuery(command_buffer: u64, query_pool: u64, query: u32, flags: u32): void;
pub def vkCmdEndQuery(command_buffer: u64, query_pool: u64, query: u32): void;
pub def vkCmdResetQueryPool(command_buffer: u64, query_pool: u64, first_query: u32, query_count: u32): void;
pub def vkCmdWriteTimestamp(command_buffer: u64, pipeline_stage: u32, query_pool: u64, query: u32): void;
pub def vkCmdCopyQueryPoolResults(command_buffer: u64, query_pool: u64, first_query: u32, query_count: u32, dst_buffer: u64, dst_offset: u64, stride: u64, flags: u32): void;
pub def vkCmdPushConstants(command_buffer: u64, layout: u64, stage_flags: u32, offset: u32, size: u32, values: *u8): void;
pub def vkCmdBeginRenderPass(command_buffer: u64, render_pass_begin: &render_pass_begin_info, contents: u32): void;
pub def vkCmdNextSubpass(command_buffer: u64, contents: u32): void;
pub def vkCmdEndRenderPass(command_buffer: u64): void;
pub def vkCmdExecuteCommands(command_buffer: u64, command_buffer_count: u32, command_buffers: *u64): void;
pub def vkGetPhysicalDeviceDisplayPropertiesKHR(physical_device: u64, property_count: &mut u32, properties: *mut display_properties_khr): i32;
pub def vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physical_device: u64, property_count: &mut u32, properties: *mut display_plane_properties_khr): i32;
pub def vkGetDisplayPlaneSupportedDisplaysKHR(physical_device: u64, plane_index: u32, display_count: &mut u32, displays: *mut u64): i32;
pub def vkGetDisplayModePropertiesKHR(physical_device: u64, display: u64, property_count: &mut u32, properties: *mut display_mode_properties_khr): i32;
pub def vkCreateDisplayModeKHR(physical_device: u64, display: u64, create_info: &display_mode_create_info_khr, allocator: *allocation_callbacks, mode: &mut u64): i32;
pub def vkGetDisplayPlaneCapabilitiesKHR(physical_device: u64, mode: u64, plane_index: u32, capabilities: &mut display_plane_capabilities_khr): i32;
pub def vkCreateDisplayPlaneSurfaceKHR(instance: u64, create_info: &display_surface_create_info_khr, allocator: *allocation_callbacks, surface: &mut u64): i32;
pub def vkCreateSharedSwapchainsKHR(device: u64, swapchain_count: u32, create_infos: *swapchain_create_info_khr, allocator: *allocation_callbacks, swapchains: *mut u64): i32;
pub def vkDestroySurfaceKHR(instance: u64, surface: u64, allocator: *allocation_callbacks): void;
pub def vkGetPhysicalDeviceSurfaceSupportKHR(physical_device: u64, queue_family_index: u32, surface: u64, supported: &mut u32): i32;
pub def vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device: u64, surface: u64, surface_capabilities: &mut surface_capabilities_khr): i32;
pub def vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device: u64, surface: u64, surface_format_count: &mut u32, surface_formats: *mut surface_format_khr): i32;
pub def vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device: u64, surface: u64, present_mode_count: &mut u32, present_modes: *mut u32): i32;
pub def vkCreateSwapchainKHR(device: u64, create_info: &swapchain_create_info_khr, allocator: *allocation_callbacks, swapchain: &mut u64): i32;
pub def vkDestroySwapchainKHR(device: u64, swapchain: u64, allocator: *allocation_callbacks): void;
pub def vkGetSwapchainImagesKHR(device: u64, swapchain: u64, swapchain_image_count: &mut u32, swapchain_images: *mut u64): i32;
pub def vkAcquireNextImageKHR(device: u64, swapchain: u64, timeout: u64, semaphore: u64, fence: u64, image_index: &mut u32): i32;
pub def vkQueuePresentKHR(queue: u64, present_info: &present_info_khr): i32;
pub def vkGetPhysicalDeviceFeatures2(physical_device: u64, features: &mut physical_device_features_2): void;
pub def vkGetPhysicalDeviceProperties2(physical_device: u64, properties: &mut physical_device_properties_2): void;
pub def vkGetPhysicalDeviceFormatProperties2(physical_device: u64, format: u32, format_properties: &mut format_properties_2): void;
pub def vkGetPhysicalDeviceImageFormatProperties2(physical_device: u64, image_format_info: &physical_device_image_format_info_2, image_format_properties: &mut image_format_properties_2): i32;
pub def vkGetPhysicalDeviceQueueFamilyProperties2(physical_device: u64, queue_family_property_count: &mut u32, queue_family_properties: *mut queue_family_properties_2): void;
pub def vkGetPhysicalDeviceMemoryProperties2(physical_device: u64, memory_properties: &mut physical_device_memory_properties_2): void;
pub def vkGetPhysicalDeviceSparseImageFormatProperties2(physical_device: u64, format_info: &physical_device_sparse_image_format_info_2, property_count: &mut u32, properties: *mut sparse_image_format_properties_2): void;
pub def vkCmdPushDescriptorSet(command_buffer: u64, pipeline_bind_point: u32, layout: u64, set: u32, descriptor_write_count: u32, descriptor_writes: *write_descriptor_set): void;
pub def vkTrimCommandPool(device: u64, command_pool: u64, flags: u32): void;
pub def vkGetPhysicalDeviceExternalBufferProperties(physical_device: u64, external_buffer_info: &physical_device_external_buffer_info, external_buffer_properties: &mut external_buffer_properties): void;
pub def vkGetPhysicalDeviceExternalSemaphoreProperties(physical_device: u64, external_semaphore_info: &physical_device_external_semaphore_info, external_semaphore_properties: &mut external_semaphore_properties): void;
pub def vkGetPhysicalDeviceExternalFenceProperties(physical_device: u64, external_fence_info: &physical_device_external_fence_info, external_fence_properties: &mut external_fence_properties): void;
pub def vkEnumeratePhysicalDeviceGroups(instance: u64, physical_device_group_count: &mut u32, physical_device_group_properties: *mut physical_device_group_properties): i32;
pub def vkGetDeviceGroupPeerMemoryFeatures(device: u64, heap_index: u32, local_device_index: u32, remote_device_index: u32, peer_memory_features: &mut u32): void;
pub def vkBindBufferMemory2(device: u64, bind_info_count: u32, bind_infos: *bind_buffer_memory_info): i32;
pub def vkBindImageMemory2(device: u64, bind_info_count: u32, bind_infos: *bind_image_memory_info): i32;
pub def vkCmdSetDeviceMask(command_buffer: u64, device_mask: u32): void;
pub def vkGetDeviceGroupPresentCapabilitiesKHR(device: u64, device_group_present_capabilities: &mut device_group_present_capabilities_khr): i32;
pub def vkGetDeviceGroupSurfacePresentModesKHR(device: u64, surface: u64, modes: &mut u32): i32;
pub def vkAcquireNextImage2KHR(device: u64, acquire_info: &acquire_next_image_info_khr, image_index: &mut u32): i32;
pub def vkCmdDispatchBase(command_buffer: u64, base_group_x: u32, base_group_y: u32, base_group_z: u32, group_count_x: u32, group_count_y: u32, group_count_z: u32): void;
pub def vkGetPhysicalDevicePresentRectanglesKHR(physical_device: u64, surface: u64, rect_count: &mut u32, rects: *mut rect_2d): i32;
pub def vkCreateDescriptorUpdateTemplate(device: u64, create_info: &descriptor_update_template_create_info, allocator: *allocation_callbacks, descriptor_update_template: &mut u64): i32;
pub def vkDestroyDescriptorUpdateTemplate(device: u64, descriptor_update_template: u64, allocator: *allocation_callbacks): void;
pub def vkUpdateDescriptorSetWithTemplate(device: u64, descriptor_set: u64, descriptor_update_template: u64, data: *u8): void;
pub def vkCmdPushDescriptorSetWithTemplate(command_buffer: u64, descriptor_update_template: u64, layout: u64, set: u32, data: *u8): void;
pub def vkGetPhysicalDeviceSurfaceCapabilities2KHR(physical_device: u64, surface_info: &physical_device_surface_info_2_khr, surface_capabilities: &mut surface_capabilities_2_khr): i32;
pub def vkGetPhysicalDeviceSurfaceFormats2KHR(physical_device: u64, surface_info: &physical_device_surface_info_2_khr, surface_format_count: &mut u32, surface_formats: *mut surface_format_2_khr): i32;
pub def vkGetPhysicalDeviceDisplayProperties2KHR(physical_device: u64, property_count: &mut u32, properties: *mut display_properties_2_khr): i32;
pub def vkGetPhysicalDeviceDisplayPlaneProperties2KHR(physical_device: u64, property_count: &mut u32, properties: *mut display_plane_properties_2_khr): i32;
pub def vkGetDisplayModeProperties2KHR(physical_device: u64, display: u64, property_count: &mut u32, properties: *mut display_mode_properties_2_khr): i32;
pub def vkGetDisplayPlaneCapabilities2KHR(physical_device: u64, display_plane_info: &display_plane_info_2_khr, capabilities: &mut display_plane_capabilities_2_khr): i32;
pub def vkGetBufferMemoryRequirements2(device: u64, info: &buffer_memory_requirements_info_2, memory_requirements: &mut memory_requirements_2): void;
pub def vkGetImageMemoryRequirements2(device: u64, info: &image_memory_requirements_info_2, memory_requirements: &mut memory_requirements_2): void;
pub def vkGetImageSparseMemoryRequirements2(device: u64, info: &image_sparse_memory_requirements_info_2, sparse_memory_requirement_count: &mut u32, sparse_memory_requirements: *mut sparse_image_memory_requirements_2): void;
pub def vkGetDeviceBufferMemoryRequirements(device: u64, info: &device_buffer_memory_requirements, memory_requirements: &mut memory_requirements_2): void;
pub def vkGetDeviceImageMemoryRequirements(device: u64, info: &device_image_memory_requirements, memory_requirements: &mut memory_requirements_2): void;
pub def vkGetDeviceImageSparseMemoryRequirements(device: u64, info: &device_image_memory_requirements, sparse_memory_requirement_count: &mut u32, sparse_memory_requirements: *mut sparse_image_memory_requirements_2): void;
pub def vkCreateSamplerYcbcrConversion(device: u64, create_info: &sampler_ycbcr_conversion_create_info, allocator: *allocation_callbacks, ycbcr_conversion: &mut u64): i32;
pub def vkDestroySamplerYcbcrConversion(device: u64, ycbcr_conversion: u64, allocator: *allocation_callbacks): void;
pub def vkGetDeviceQueue2(device: u64, queue_info: &device_queue_info_2, queue: &mut u64): void;
pub def vkGetDescriptorSetLayoutSupport(device: u64, create_info: &descriptor_set_layout_create_info, support: &mut descriptor_set_layout_support): void;
pub def vkCreateRenderPass2(device: u64, create_info: &render_pass_create_info_2, allocator: *allocation_callbacks, render_pass: &mut u64): i32;
pub def vkCmdBeginRenderPass2(command_buffer: u64, render_pass_begin: &render_pass_begin_info, subpass_begin_info: &subpass_begin_info): void;
pub def vkCmdNextSubpass2(command_buffer: u64, subpass_begin_info: &subpass_begin_info, subpass_end_info: &subpass_end_info): void;
pub def vkCmdEndRenderPass2(command_buffer: u64, subpass_end_info: &subpass_end_info): void;
pub def vkGetSemaphoreCounterValue(device: u64, semaphore: u64, value: &mut u64): i32;
pub def vkWaitSemaphores(device: u64, wait_info: &semaphore_wait_info, timeout: u64): i32;
pub def vkSignalSemaphore(device: u64, signal_info: &semaphore_signal_info): i32;
pub def vkCmdDrawIndirectCount(command_buffer: u64, buffer: u64, offset: u64, count_buffer: u64, count_buffer_offset: u64, max_draw_count: u32, stride: u32): void;
pub def vkCmdDrawIndexedIndirectCount(command_buffer: u64, buffer: u64, offset: u64, count_buffer: u64, count_buffer_offset: u64, max_draw_count: u32, stride: u32): void;
pub def vkGetBufferOpaqueCaptureAddress(device: u64, info: &buffer_device_address_info): u64;
pub def vkGetBufferDeviceAddress(device: u64, info: &buffer_device_address_info): u64;
pub def vkCreateHeadlessSurfaceEXT(instance: u64, create_info: &headless_surface_create_info_ext, allocator: *allocation_callbacks, surface: &mut u64): i32;
pub def vkGetDeviceMemoryOpaqueCaptureAddress(device: u64, info: &device_memory_opaque_capture_address_info): u64;
pub def vkCmdSetLineStipple(command_buffer: u64, line_stipple_factor: u32, line_stipple_pattern: u16): void;
pub def vkGetPhysicalDeviceToolProperties(physical_device: u64, tool_count: &mut u32, tool_properties: *mut physical_device_tool_properties): i32;
pub def vkCmdSetCullMode(command_buffer: u64, cull_mode: u32): void;
pub def vkCmdSetFrontFace(command_buffer: u64, front_face: u32): void;
pub def vkCmdSetPrimitiveTopology(command_buffer: u64, primitive_topology: u32): void;
pub def vkCmdSetViewportWithCount(command_buffer: u64, viewport_count: u32, viewports: *viewport): void;
pub def vkCmdSetScissorWithCount(command_buffer: u64, scissor_count: u32, scissors: *rect_2d): void;
pub def vkCmdBindIndexBuffer2(command_buffer: u64, buffer: u64, offset: u64, size: u64, index_type: u32): void;
pub def vkCmdBindVertexBuffers2(command_buffer: u64, first_binding: u32, binding_count: u32, buffers: *u64, offsets: *u64, sizes: *u64, strides: *u64): void;
pub def vkCmdSetDepthTestEnable(command_buffer: u64, depth_test_enable: u32): void;
pub def vkCmdSetDepthWriteEnable(command_buffer: u64, depth_write_enable: u32): void;
pub def vkCmdSetDepthCompareOp(command_buffer: u64, depth_compare_op: u32): void;
pub def vkCmdSetDepthBoundsTestEnable(command_buffer: u64, depth_bounds_test_enable: u32): void;
pub def vkCmdSetStencilTestEnable(command_buffer: u64, stencil_test_enable: u32): void;
pub def vkCmdSetStencilOp(command_buffer: u64, face_mask: u32, fail_op: u32, pass_op: u32, depth_fail_op: u32, compare_op: u32): void;
pub def vkCmdSetRasterizerDiscardEnable(command_buffer: u64, rasterizer_discard_enable: u32): void;
pub def vkCmdSetDepthBiasEnable(command_buffer: u64, depth_bias_enable: u32): void;
pub def vkCmdSetPrimitiveRestartEnable(command_buffer: u64, primitive_restart_enable: u32): void;
pub def vkCreatePrivateDataSlot(device: u64, create_info: &private_data_slot_create_info, allocator: *allocation_callbacks, private_data_slot: &mut u64): i32;
pub def vkDestroyPrivateDataSlot(device: u64, private_data_slot: u64, allocator: *allocation_callbacks): void;
pub def vkSetPrivateData(device: u64, object_type: u32, object_handle: u64, private_data_slot: u64, data: u64): i32;
pub def vkGetPrivateData(device: u64, object_type: u32, object_handle: u64, private_data_slot: u64, data: &mut u64): void;
pub def vkCmdCopyBuffer2(command_buffer: u64, copy_buffer_info: &copy_buffer_info_2): void;
pub def vkCmdCopyImage2(command_buffer: u64, copy_image_info: &copy_image_info_2): void;
pub def vkCmdBlitImage2(command_buffer: u64, blit_image_info: &blit_image_info_2): void;
pub def vkCmdCopyBufferToImage2(command_buffer: u64, copy_buffer_to_image_info: &copy_buffer_to_image_info_2): void;
pub def vkCmdCopyImageToBuffer2(command_buffer: u64, copy_image_to_buffer_info: &copy_image_to_buffer_info_2): void;
pub def vkCmdResolveImage2(command_buffer: u64, resolve_image_info: &resolve_image_info_2): void;
pub def vkCmdSetEvent2(command_buffer: u64, event: u64, dependency_info: &dependency_info): void;
pub def vkCmdResetEvent2(command_buffer: u64, event: u64, stage_mask: u64): void;
pub def vkCmdWaitEvents2(command_buffer: u64, event_count: u32, events: *u64, dependency_infos: *dependency_info): void;
pub def vkCmdPipelineBarrier2(command_buffer: u64, dependency_info: &dependency_info): void;
pub def vkQueueSubmit2(queue: u64, submit_count: u32, submits: *submit_info_2, fence: u64): i32;
pub def vkCmdWriteTimestamp2(command_buffer: u64, stage: u64, query_pool: u64, query: u32): void;
pub def vkCopyMemoryToImage(device: u64, copy_memory_to_image_info: &copy_memory_to_image_info): i32;
pub def vkCopyImageToMemory(device: u64, copy_image_to_memory_info: &copy_image_to_memory_info): i32;
pub def vkCopyImageToImage(device: u64, copy_image_to_image_info: &copy_image_to_image_info): i32;
pub def vkTransitionImageLayout(device: u64, transition_count: u32, transitions: *host_image_layout_transition_info): i32;
pub def vkCmdBeginRendering(command_buffer: u64, rendering_info: &rendering_info): void;
pub def vkCmdEndRendering(command_buffer: u64): void;
pub def vkGetImageSubresourceLayout2(device: u64, image: u64, subresource: &image_subresource_2, layout: &mut subresource_layout_2): void;
pub def vkGetDeviceImageSubresourceLayout(device: u64, info: &device_image_subresource_info, layout: &mut subresource_layout_2): void;
pub def vkMapMemory2(device: u64, memory_map_info: &memory_map_info, data: &mut *mut u8): i32;
pub def vkUnmapMemory2(device: u64, memory_unmap_info: &memory_unmap_info): i32;
pub def vkCmdBindDescriptorSets2(command_buffer: u64, bind_descriptor_sets_info: &bind_descriptor_sets_info): void;
pub def vkCmdPushConstants2(command_buffer: u64, push_constants_info: &push_constants_info): void;
pub def vkCmdPushDescriptorSet2(command_buffer: u64, push_descriptor_set_info: &push_descriptor_set_info): void;
pub def vkCmdPushDescriptorSetWithTemplate2(command_buffer: u64, push_descriptor_set_with_template_info: &push_descriptor_set_with_template_info): void;
pub def vkCmdSetRenderingAttachmentLocations(command_buffer: u64, location_info: &rendering_attachment_location_info): void;
pub def vkCmdSetRenderingInputAttachmentIndices(command_buffer: u64, input_attachment_index_info: &rendering_input_attachment_index_info): void;
# Each command's type, as `vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` give
# it, to be cast to.
pub type PFN_vkCreateInstance = cfn<def(&instance_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyInstance = cfn<def(u64, *allocation_callbacks): void>;
pub type PFN_vkEnumeratePhysicalDevices = cfn<def(u64, &mut u32, *mut u64): i32>;
pub type PFN_vkGetDeviceProcAddr = cfn<def(u64, *u8): PFN_vkVoidFunction>;
pub type PFN_vkGetInstanceProcAddr = cfn<def(u64, *u8): PFN_vkVoidFunction>;
pub type PFN_vkGetPhysicalDeviceProperties = cfn<def(u64, &mut physical_device_properties): void>;
pub type PFN_vkGetPhysicalDeviceQueueFamilyProperties = cfn<def(u64, &mut u32, *mut queue_family_properties): void>;
pub type PFN_vkGetPhysicalDeviceMemoryProperties = cfn<def(u64, &mut physical_device_memory_properties): void>;
pub type PFN_vkGetPhysicalDeviceFeatures = cfn<def(u64, &mut physical_device_features): void>;
pub type PFN_vkGetPhysicalDeviceFormatProperties = cfn<def(u64, u32, &mut format_properties): void>;
pub type PFN_vkGetPhysicalDeviceImageFormatProperties = cfn<def(u64, u32, u32, u32, u32, u32, &mut image_format_properties): i32>;
pub type PFN_vkCreateDevice = cfn<def(u64, &device_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyDevice = cfn<def(u64, *allocation_callbacks): void>;
pub type PFN_vkEnumerateInstanceVersion = cfn<def(&mut u32): i32>;
pub type PFN_vkEnumerateInstanceLayerProperties = cfn<def(&mut u32, *mut layer_properties): i32>;
pub type PFN_vkEnumerateInstanceExtensionProperties = cfn<def(*u8, &mut u32, *mut extension_properties): i32>;
pub type PFN_vkEnumerateDeviceLayerProperties = cfn<def(u64, &mut u32, *mut layer_properties): i32>;
pub type PFN_vkEnumerateDeviceExtensionProperties = cfn<def(u64, *u8, &mut u32, *mut extension_properties): i32>;
pub type PFN_vkGetDeviceQueue = cfn<def(u64, u32, u32, &mut u64): void>;
pub type PFN_vkQueueSubmit = cfn<def(u64, u32, *submit_info, u64): i32>;
pub type PFN_vkQueueWaitIdle = cfn<def(u64): i32>;
pub type PFN_vkDeviceWaitIdle = cfn<def(u64): i32>;
pub type PFN_vkAllocateMemory = cfn<def(u64, &memory_allocate_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkFreeMemory = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkMapMemory = cfn<def(u64, u64, u64, u64, u32, &mut *mut u8): i32>;
pub type PFN_vkUnmapMemory = cfn<def(u64, u64): void>;
pub type PFN_vkFlushMappedMemoryRanges = cfn<def(u64, u32, *mapped_memory_range): i32>;
pub type PFN_vkInvalidateMappedMemoryRanges = cfn<def(u64, u32, *mapped_memory_range): i32>;
pub type PFN_vkGetDeviceMemoryCommitment = cfn<def(u64, u64, &mut u64): void>;
pub type PFN_vkGetBufferMemoryRequirements = cfn<def(u64, u64, &mut memory_requirements): void>;
pub type PFN_vkBindBufferMemory = cfn<def(u64, u64, u64, u64): i32>;
pub type PFN_vkGetImageMemoryRequirements = cfn<def(u64, u64, &mut memory_requirements): void>;
pub type PFN_vkBindImageMemory = cfn<def(u64, u64, u64, u64): i32>;
pub type PFN_vkGetImageSparseMemoryRequirements = cfn<def(u64, u64, &mut u32, *mut sparse_image_memory_requirements): void>;
pub type PFN_vkGetPhysicalDeviceSparseImageFormatProperties = cfn<def(u64, u32, u32, u32, u32, u32, &mut u32, *mut sparse_image_format_properties): void>;
pub type PFN_vkQueueBindSparse = cfn<def(u64, u32, *bind_sparse_info, u64): i32>;
pub type PFN_vkCreateFence = cfn<def(u64, &fence_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyFence = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkResetFences = cfn<def(u64, u32, *u64): i32>;
pub type PFN_vkGetFenceStatus = cfn<def(u64, u64): i32>;
pub type PFN_vkWaitForFences = cfn<def(u64, u32, *u64, u32, u64): i32>;
pub type PFN_vkCreateSemaphore = cfn<def(u64, &semaphore_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroySemaphore = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreateEvent = cfn<def(u64, &event_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyEvent = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkGetEventStatus = cfn<def(u64, u64): i32>;
pub type PFN_vkSetEvent = cfn<def(u64, u64): i32>;
pub type PFN_vkResetEvent = cfn<def(u64, u64): i32>;
pub type PFN_vkCreateQueryPool = cfn<def(u64, &query_pool_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyQueryPool = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkGetQueryPoolResults = cfn<def(u64, u64, u32, u32, u64, *mut u8, u64, u32): i32>;
pub type PFN_vkResetQueryPool = cfn<def(u64, u64, u32, u32): void>;
pub type PFN_vkCreateBuffer = cfn<def(u64, &buffer_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyBuffer = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreateBufferView = cfn<def(u64, &buffer_view_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyBufferView = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreateImage = cfn<def(u64, &image_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyImage = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkGetImageSubresourceLayout = cfn<def(u64, u64, &image_subresource, &mut subresource_layout): void>;
pub type PFN_vkCreateImageView = cfn<def(u64, &image_view_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyImageView = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreateShaderModule = cfn<def(u64, &shader_module_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyShaderModule = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreatePipelineCache = cfn<def(u64, &pipeline_cache_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyPipelineCache = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkGetPipelineCacheData = cfn<def(u64, u64, &mut u64, *mut u8): i32>;
pub type PFN_vkMergePipelineCaches = cfn<def(u64, u64, u32, *u64): i32>;
pub type PFN_vkCreateGraphicsPipelines = cfn<def(u64, u64, u32, *graphics_pipeline_create_info, *allocation_callbacks, *mut u64): i32>;
pub type PFN_vkCreateComputePipelines = cfn<def(u64, u64, u32, *compute_pipeline_create_info, *allocation_callbacks, *mut u64): i32>;
pub type PFN_vkDestroyPipeline = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreatePipelineLayout = cfn<def(u64, &pipeline_layout_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyPipelineLayout = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreateSampler = cfn<def(u64, &sampler_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroySampler = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreateDescriptorSetLayout = cfn<def(u64, &descriptor_set_layout_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyDescriptorSetLayout = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreateDescriptorPool = cfn<def(u64, &descriptor_pool_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyDescriptorPool = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkResetDescriptorPool = cfn<def(u64, u64, u32): i32>;
pub type PFN_vkAllocateDescriptorSets = cfn<def(u64, &descriptor_set_allocate_info, *mut u64): i32>;
pub type PFN_vkFreeDescriptorSets = cfn<def(u64, u64, u32, *u64): i32>;
pub type PFN_vkUpdateDescriptorSets = cfn<def(u64, u32, *write_descriptor_set, u32, *copy_descriptor_set): void>;
pub type PFN_vkCreateFramebuffer = cfn<def(u64, &framebuffer_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyFramebuffer = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkCreateRenderPass = cfn<def(u64, &render_pass_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyRenderPass = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkGetRenderAreaGranularity = cfn<def(u64, u64, &mut extent_2d): void>;
pub type PFN_vkGetRenderingAreaGranularity = cfn<def(u64, &rendering_area_info, &mut extent_2d): void>;
pub type PFN_vkCreateCommandPool = cfn<def(u64, &command_pool_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyCommandPool = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkResetCommandPool = cfn<def(u64, u64, u32): i32>;
pub type PFN_vkAllocateCommandBuffers = cfn<def(u64, &command_buffer_allocate_info, *mut u64): i32>;
pub type PFN_vkFreeCommandBuffers = cfn<def(u64, u64, u32, *u64): void>;
pub type PFN_vkBeginCommandBuffer = cfn<def(u64, &command_buffer_begin_info): i32>;
pub type PFN_vkEndCommandBuffer = cfn<def(u64): i32>;
pub type PFN_vkResetCommandBuffer = cfn<def(u64, u32): i32>;
pub type PFN_vkCmdBindPipeline = cfn<def(u64, u32, u64): void>;
pub type PFN_vkCmdSetViewport = cfn<def(u64, u32, u32, *viewport): void>;
pub type PFN_vkCmdSetScissor = cfn<def(u64, u32, u32, *rect_2d): void>;
pub type PFN_vkCmdSetLineWidth = cfn<def(u64, f32): void>;
pub type PFN_vkCmdSetDepthBias = cfn<def(u64, f32, f32, f32): void>;
pub type PFN_vkCmdSetBlendConstants = cfn<def(u64, &f32[4]): void>;
pub type PFN_vkCmdSetDepthBounds = cfn<def(u64, f32, f32): void>;
pub type PFN_vkCmdSetStencilCompareMask = cfn<def(u64, u32, u32): void>;
pub type PFN_vkCmdSetStencilWriteMask = cfn<def(u64, u32, u32): void>;
pub type PFN_vkCmdSetStencilReference = cfn<def(u64, u32, u32): void>;
pub type PFN_vkCmdBindDescriptorSets = cfn<def(u64, u32, u64, u32, u32, *u64, u32, *u32): void>;
pub type PFN_vkCmdBindIndexBuffer = cfn<def(u64, u64, u64, u32): void>;
pub type PFN_vkCmdBindVertexBuffers = cfn<def(u64, u32, u32, *u64, *u64): void>;
pub type PFN_vkCmdDraw = cfn<def(u64, u32, u32, u32, u32): void>;
pub type PFN_vkCmdDrawIndexed = cfn<def(u64, u32, u32, u32, i32, u32): void>;
pub type PFN_vkCmdDrawIndirect = cfn<def(u64, u64, u64, u32, u32): void>;
pub type PFN_vkCmdDrawIndexedIndirect = cfn<def(u64, u64, u64, u32, u32): void>;
pub type PFN_vkCmdDispatch = cfn<def(u64, u32, u32, u32): void>;
pub type PFN_vkCmdDispatchIndirect = cfn<def(u64, u64, u64): void>;
pub type PFN_vkCmdCopyBuffer = cfn<def(u64, u64, u64, u32, *buffer_copy): void>;
pub type PFN_vkCmdCopyImage = cfn<def(u64, u64, u32, u64, u32, u32, *image_copy): void>;
pub type PFN_vkCmdBlitImage = cfn<def(u64, u64, u32, u64, u32, u32, *image_blit, u32): void>;
pub type PFN_vkCmdCopyBufferToImage = cfn<def(u64, u64, u64, u32, u32, *buffer_image_copy): void>;
pub type PFN_vkCmdCopyImageToBuffer = cfn<def(u64, u64, u32, u64, u32, *buffer_image_copy): void>;
pub type PFN_vkCmdUpdateBuffer = cfn<def(u64, u64, u64, u64, *u8): void>;
pub type PFN_vkCmdFillBuffer = cfn<def(u64, u64, u64, u64, u32): void>;
pub type PFN_vkCmdClearColorImage = cfn<def(u64, u64, u32, &clear_color_value, u32, *image_subresource_range): void>;
pub type PFN_vkCmdClearDepthStencilImage = cfn<def(u64, u64, u32, &clear_depth_stencil_value, u32, *image_subresource_range): void>;
pub type PFN_vkCmdClearAttachments = cfn<def(u64, u32, *clear_attachment, u32, *clear_rect): void>;
pub type PFN_vkCmdResolveImage = cfn<def(u64, u64, u32, u64, u32, u32, *image_resolve): void>;
pub type PFN_vkCmdSetEvent = cfn<def(u64, u64, u32): void>;
pub type PFN_vkCmdResetEvent = cfn<def(u64, u64, u32): void>;
pub type PFN_vkCmdWaitEvents = cfn<def(u64, u32, *u64, u32, u32, u32, *memory_barrier, u32, *buffer_memory_barrier, u32, *image_memory_barrier): void>;
pub type PFN_vkCmdPipelineBarrier = cfn<def(u64, u32, u32, u32, u32, *memory_barrier, u32, *buffer_memory_barrier, u32, *image_memory_barrier): void>;
pub type PFN_vkCmdBeginQuery = cfn<def(u64, u64, u32, u32): void>;
pub type PFN_vkCmdEndQuery = cfn<def(u64, u64, u32): void>;
pub type PFN_vkCmdResetQueryPool = cfn<def(u64, u64, u32, u32): void>;
pub type PFN_vkCmdWriteTimestamp = cfn<def(u64, u32, u64, u32): void>;
pub type PFN_vkCmdCopyQueryPoolResults = cfn<def(u64, u64, u32, u32, u64, u64, u64, u32): void>;
pub type PFN_vkCmdPushConstants = cfn<def(u64, u64, u32, u32, u32, *u8): void>;
pub type PFN_vkCmdBeginRenderPass = cfn<def(u64, &render_pass_begin_info, u32): void>;
pub type PFN_vkCmdNextSubpass = cfn<def(u64, u32): void>;
pub type PFN_vkCmdEndRenderPass = cfn<def(u64): void>;
pub type PFN_vkCmdExecuteCommands = cfn<def(u64, u32, *u64): void>;
pub type PFN_vkGetPhysicalDeviceDisplayPropertiesKHR = cfn<def(u64, &mut u32, *mut display_properties_khr): i32>;
pub type PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR = cfn<def(u64, &mut u32, *mut display_plane_properties_khr): i32>;
pub type PFN_vkGetDisplayPlaneSupportedDisplaysKHR = cfn<def(u64, u32, &mut u32, *mut u64): i32>;
pub type PFN_vkGetDisplayModePropertiesKHR = cfn<def(u64, u64, &mut u32, *mut display_mode_properties_khr): i32>;
pub type PFN_vkCreateDisplayModeKHR = cfn<def(u64, u64, &display_mode_create_info_khr, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkGetDisplayPlaneCapabilitiesKHR = cfn<def(u64, u64, u32, &mut display_plane_capabilities_khr): i32>;
pub type PFN_vkCreateDisplayPlaneSurfaceKHR = cfn<def(u64, &display_surface_create_info_khr, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkCreateSharedSwapchainsKHR = cfn<def(u64, u32, *swapchain_create_info_khr, *allocation_callbacks, *mut u64): i32>;
pub type PFN_vkDestroySurfaceKHR = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkGetPhysicalDeviceSurfaceSupportKHR = cfn<def(u64, u32, u64, &mut u32): i32>;
pub type PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = cfn<def(u64, u64, &mut surface_capabilities_khr): i32>;
pub type PFN_vkGetPhysicalDeviceSurfaceFormatsKHR = cfn<def(u64, u64, &mut u32, *mut surface_format_khr): i32>;
pub type PFN_vkGetPhysicalDeviceSurfacePresentModesKHR = cfn<def(u64, u64, &mut u32, *mut u32): i32>;
pub type PFN_vkCreateSwapchainKHR = cfn<def(u64, &swapchain_create_info_khr, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroySwapchainKHR = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkGetSwapchainImagesKHR = cfn<def(u64, u64, &mut u32, *mut u64): i32>;
pub type PFN_vkAcquireNextImageKHR = cfn<def(u64, u64, u64, u64, u64, &mut u32): i32>;
pub type PFN_vkQueuePresentKHR = cfn<def(u64, &present_info_khr): i32>;
pub type PFN_vkGetPhysicalDeviceFeatures2 = cfn<def(u64, &mut physical_device_features_2): void>;
pub type PFN_vkGetPhysicalDeviceProperties2 = cfn<def(u64, &mut physical_device_properties_2): void>;
pub type PFN_vkGetPhysicalDeviceFormatProperties2 = cfn<def(u64, u32, &mut format_properties_2): void>;
pub type PFN_vkGetPhysicalDeviceImageFormatProperties2 = cfn<def(u64, &physical_device_image_format_info_2, &mut image_format_properties_2): i32>;
pub type PFN_vkGetPhysicalDeviceQueueFamilyProperties2 = cfn<def(u64, &mut u32, *mut queue_family_properties_2): void>;
pub type PFN_vkGetPhysicalDeviceMemoryProperties2 = cfn<def(u64, &mut physical_device_memory_properties_2): void>;
pub type PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 = cfn<def(u64, &physical_device_sparse_image_format_info_2, &mut u32, *mut sparse_image_format_properties_2): void>;
pub type PFN_vkCmdPushDescriptorSet = cfn<def(u64, u32, u64, u32, u32, *write_descriptor_set): void>;
pub type PFN_vkTrimCommandPool = cfn<def(u64, u64, u32): void>;
pub type PFN_vkGetPhysicalDeviceExternalBufferProperties = cfn<def(u64, &physical_device_external_buffer_info, &mut external_buffer_properties): void>;
pub type PFN_vkGetPhysicalDeviceExternalSemaphoreProperties = cfn<def(u64, &physical_device_external_semaphore_info, &mut external_semaphore_properties): void>;
pub type PFN_vkGetPhysicalDeviceExternalFenceProperties = cfn<def(u64, &physical_device_external_fence_info, &mut external_fence_properties): void>;
pub type PFN_vkEnumeratePhysicalDeviceGroups = cfn<def(u64, &mut u32, *mut physical_device_group_properties): i32>;
pub type PFN_vkGetDeviceGroupPeerMemoryFeatures = cfn<def(u64, u32, u32, u32, &mut u32): void>;
pub type PFN_vkBindBufferMemory2 = cfn<def(u64, u32, *bind_buffer_memory_info): i32>;
pub type PFN_vkBindImageMemory2 = cfn<def(u64, u32, *bind_image_memory_info): i32>;
pub type PFN_vkCmdSetDeviceMask = cfn<def(u64, u32): void>;
pub type PFN_vkGetDeviceGroupPresentCapabilitiesKHR = cfn<def(u64, &mut device_group_present_capabilities_khr): i32>;
pub type PFN_vkGetDeviceGroupSurfacePresentModesKHR = cfn<def(u64, u64, &mut u32): i32>;
pub type PFN_vkAcquireNextImage2KHR = cfn<def(u64, &acquire_next_image_info_khr, &mut u32): i32>;
pub type PFN_vkCmdDispatchBase = cfn<def(u64, u32, u32, u32, u32, u32, u32): void>;
pub type PFN_vkGetPhysicalDevicePresentRectanglesKHR = cfn<def(u64, u64, &mut u32, *mut rect_2d): i32>;
pub type PFN_vkCreateDescriptorUpdateTemplate = cfn<def(u64, &descriptor_update_template_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyDescriptorUpdateTemplate = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkUpdateDescriptorSetWithTemplate = cfn<def(u64, u64, u64, *u8): void>;
pub type PFN_vkCmdPushDescriptorSetWithTemplate = cfn<def(u64, u64, u64, u32, *u8): void>;
pub type PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR = cfn<def(u64, &physical_device_surface_info_2_khr, &mut surface_capabilities_2_khr): i32>;
pub type PFN_vkGetPhysicalDeviceSurfaceFormats2KHR = cfn<def(u64, &physical_device_surface_info_2_khr, &mut u32, *mut surface_format_2_khr): i32>;
pub type PFN_vkGetPhysicalDeviceDisplayProperties2KHR = cfn<def(u64, &mut u32, *mut display_properties_2_khr): i32>;
pub type PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR = cfn<def(u64, &mut u32, *mut display_plane_properties_2_khr): i32>;
pub type PFN_vkGetDisplayModeProperties2KHR = cfn<def(u64, u64, &mut u32, *mut display_mode_properties_2_khr): i32>;
pub type PFN_vkGetDisplayPlaneCapabilities2KHR = cfn<def(u64, &display_plane_info_2_khr, &mut display_plane_capabilities_2_khr): i32>;
pub type PFN_vkGetBufferMemoryRequirements2 = cfn<def(u64, &buffer_memory_requirements_info_2, &mut memory_requirements_2): void>;
pub type PFN_vkGetImageMemoryRequirements2 = cfn<def(u64, &image_memory_requirements_info_2, &mut memory_requirements_2): void>;
pub type PFN_vkGetImageSparseMemoryRequirements2 = cfn<def(u64, &image_sparse_memory_requirements_info_2, &mut u32, *mut sparse_image_memory_requirements_2): void>;
pub type PFN_vkGetDeviceBufferMemoryRequirements = cfn<def(u64, &device_buffer_memory_requirements, &mut memory_requirements_2): void>;
pub type PFN_vkGetDeviceImageMemoryRequirements = cfn<def(u64, &device_image_memory_requirements, &mut memory_requirements_2): void>;
pub type PFN_vkGetDeviceImageSparseMemoryRequirements = cfn<def(u64, &device_image_memory_requirements, &mut u32, *mut sparse_image_memory_requirements_2): void>;
pub type PFN_vkCreateSamplerYcbcrConversion = cfn<def(u64, &sampler_ycbcr_conversion_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroySamplerYcbcrConversion = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkGetDeviceQueue2 = cfn<def(u64, &device_queue_info_2, &mut u64): void>;
pub type PFN_vkGetDescriptorSetLayoutSupport = cfn<def(u64, &descriptor_set_layout_create_info, &mut descriptor_set_layout_support): void>;
pub type PFN_vkSetDebugUtilsObjectNameEXT = cfn<def(u64, &debug_utils_object_name_info_ext): i32>;
pub type PFN_vkSetDebugUtilsObjectTagEXT = cfn<def(u64, &debug_utils_object_tag_info_ext): i32>;
pub type PFN_vkQueueBeginDebugUtilsLabelEXT = cfn<def(u64, &debug_utils_label_ext): void>;
pub type PFN_vkQueueEndDebugUtilsLabelEXT = cfn<def(u64): void>;
pub type PFN_vkQueueInsertDebugUtilsLabelEXT = cfn<def(u64, &debug_utils_label_ext): void>;
pub type PFN_vkCmdBeginDebugUtilsLabelEXT = cfn<def(u64, &debug_utils_label_ext): void>;
pub type PFN_vkCmdEndDebugUtilsLabelEXT = cfn<def(u64): void>;
pub type PFN_vkCmdInsertDebugUtilsLabelEXT = cfn<def(u64, &debug_utils_label_ext): void>;
pub type PFN_vkCreateDebugUtilsMessengerEXT = cfn<def(u64, &debug_utils_messenger_create_info_ext, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyDebugUtilsMessengerEXT = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkSubmitDebugUtilsMessageEXT = cfn<def(u64, u32, u32, &debug_utils_messenger_callback_data_ext): void>;
pub type PFN_vkCreateRenderPass2 = cfn<def(u64, &render_pass_create_info_2, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkCmdBeginRenderPass2 = cfn<def(u64, &render_pass_begin_info, &subpass_begin_info): void>;
pub type PFN_vkCmdNextSubpass2 = cfn<def(u64, &subpass_begin_info, &subpass_end_info): void>;
pub type PFN_vkCmdEndRenderPass2 = cfn<def(u64, &subpass_end_info): void>;
pub type PFN_vkGetSemaphoreCounterValue = cfn<def(u64, u64, &mut u64): i32>;
pub type PFN_vkWaitSemaphores = cfn<def(u64, &semaphore_wait_info, u64): i32>;
pub type PFN_vkSignalSemaphore = cfn<def(u64, &semaphore_signal_info): i32>;
pub type PFN_vkCmdDrawIndirectCount = cfn<def(u64, u64, u64, u64, u64, u32, u32): void>;
pub type PFN_vkCmdDrawIndexedIndirectCount = cfn<def(u64, u64, u64, u64, u64, u32, u32): void>;
pub type PFN_vkGetBufferOpaqueCaptureAddress = cfn<def(u64, &buffer_device_address_info): u64>;
pub type PFN_vkGetBufferDeviceAddress = cfn<def(u64, &buffer_device_address_info): u64>;
pub type PFN_vkCreateHeadlessSurfaceEXT = cfn<def(u64, &headless_surface_create_info_ext, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkGetDeviceMemoryOpaqueCaptureAddress = cfn<def(u64, &device_memory_opaque_capture_address_info): u64>;
pub type PFN_vkCmdSetLineStipple = cfn<def(u64, u32, u16): void>;
pub type PFN_vkGetPhysicalDeviceToolProperties = cfn<def(u64, &mut u32, *mut physical_device_tool_properties): i32>;
pub type PFN_vkCmdSetCullMode = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetFrontFace = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetPrimitiveTopology = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetViewportWithCount = cfn<def(u64, u32, *viewport): void>;
pub type PFN_vkCmdSetScissorWithCount = cfn<def(u64, u32, *rect_2d): void>;
pub type PFN_vkCmdBindIndexBuffer2 = cfn<def(u64, u64, u64, u64, u32): void>;
pub type PFN_vkCmdBindVertexBuffers2 = cfn<def(u64, u32, u32, *u64, *u64, *u64, *u64): void>;
pub type PFN_vkCmdSetDepthTestEnable = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetDepthWriteEnable = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetDepthCompareOp = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetDepthBoundsTestEnable = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetStencilTestEnable = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetStencilOp = cfn<def(u64, u32, u32, u32, u32, u32): void>;
pub type PFN_vkCmdSetRasterizerDiscardEnable = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetDepthBiasEnable = cfn<def(u64, u32): void>;
pub type PFN_vkCmdSetPrimitiveRestartEnable = cfn<def(u64, u32): void>;
pub type PFN_vkCreatePrivateDataSlot = cfn<def(u64, &private_data_slot_create_info, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkDestroyPrivateDataSlot = cfn<def(u64, u64, *allocation_callbacks): void>;
pub type PFN_vkSetPrivateData = cfn<def(u64, u32, u64, u64, u64): i32>;
pub type PFN_vkGetPrivateData = cfn<def(u64, u32, u64, u64, &mut u64): void>;
pub type PFN_vkCmdCopyBuffer2 = cfn<def(u64, &copy_buffer_info_2): void>;
pub type PFN_vkCmdCopyImage2 = cfn<def(u64, &copy_image_info_2): void>;
pub type PFN_vkCmdBlitImage2 = cfn<def(u64, &blit_image_info_2): void>;
pub type PFN_vkCmdCopyBufferToImage2 = cfn<def(u64, &copy_buffer_to_image_info_2): void>;
pub type PFN_vkCmdCopyImageToBuffer2 = cfn<def(u64, &copy_image_to_buffer_info_2): void>;
pub type PFN_vkCmdResolveImage2 = cfn<def(u64, &resolve_image_info_2): void>;
pub type PFN_vkCmdSetEvent2 = cfn<def(u64, u64, &dependency_info): void>;
pub type PFN_vkCmdResetEvent2 = cfn<def(u64, u64, u64): void>;
pub type PFN_vkCmdWaitEvents2 = cfn<def(u64, u32, *u64, *dependency_info): void>;
pub type PFN_vkCmdPipelineBarrier2 = cfn<def(u64, &dependency_info): void>;
pub type PFN_vkQueueSubmit2 = cfn<def(u64, u32, *submit_info_2, u64): i32>;
pub type PFN_vkCmdWriteTimestamp2 = cfn<def(u64, u64, u64, u32): void>;
pub type PFN_vkCopyMemoryToImage = cfn<def(u64, &copy_memory_to_image_info): i32>;
pub type PFN_vkCopyImageToMemory = cfn<def(u64, &copy_image_to_memory_info): i32>;
pub type PFN_vkCopyImageToImage = cfn<def(u64, &copy_image_to_image_info): i32>;
pub type PFN_vkTransitionImageLayout = cfn<def(u64, u32, *host_image_layout_transition_info): i32>;
pub type PFN_vkCmdBeginRendering = cfn<def(u64, &rendering_info): void>;
pub type PFN_vkCmdEndRendering = cfn<def(u64): void>;
pub type PFN_vkGetImageSubresourceLayout2 = cfn<def(u64, u64, &image_subresource_2, &mut subresource_layout_2): void>;
pub type PFN_vkGetDeviceImageSubresourceLayout = cfn<def(u64, &device_image_subresource_info, &mut subresource_layout_2): void>;
pub type PFN_vkMapMemory2 = cfn<def(u64, &memory_map_info, &mut *mut u8): i32>;
pub type PFN_vkUnmapMemory2 = cfn<def(u64, &memory_unmap_info): i32>;
pub type PFN_vkCmdBindDescriptorSets2 = cfn<def(u64, &bind_descriptor_sets_info): void>;
pub type PFN_vkCmdPushConstants2 = cfn<def(u64, &push_constants_info): void>;
pub type PFN_vkCmdPushDescriptorSet2 = cfn<def(u64, &push_descriptor_set_info): void>;
pub type PFN_vkCmdPushDescriptorSetWithTemplate2 = cfn<def(u64, &push_descriptor_set_with_template_info): void>;
pub type PFN_vkCmdSetRenderingAttachmentLocations = cfn<def(u64, &rendering_attachment_location_info): void>;
pub type PFN_vkCmdSetRenderingInputAttachmentIndices = cfn<def(u64, &rendering_input_attachment_index_info): void>;
File diff suppressed because it is too large. Load diff
+3767
View File
File diff suppressed because it is too large. Load diff
+75
View File
@@ -0,0 +1,75 @@
#! Contains `malunal::vulkan`: Vulkan, as its registry declares it, for Sakura.
#! It holds the functions of Vulkan's core and of the extensions bound, the
#! structs and unions they take, laid out as C lays them out, and the numbers
#! they're asked for and give, with the versions of Vulkan, and how a version
#! is written.
#!
#! What C names keeps its name: each function, as `vkCreateInstance`; each
#! constant, as `VK_FORMAT_R8G8B8A8_UNORM`; and each function's type, as
#! `PFN_vkCreateInstance`. A struct or a union with a `VK_STRUCTURE_TYPE_` of
#! its own is named by it, as Vulkan's names are, in lower case:
#! `VkPhysicalDeviceVulkan13Features` is `physical_device_vulkan_1_3_features`.
#! Another is named in snake case without its `Vk`: `VkExtent2D` is
#! `extent_2d`. A member is in snake case, without the `p` or `pp` of a pointer
#! or the `pfn` of a function, `ppEnabledLayerNames` as `enabled_layer_names`,
#! and followed by `_` where it'd be a word of Sakura's, as `module_`. A
#! struct's `s_type` is its own by default.
#!
#! Handles are `u64`s. An enum is its values' type, `u32`, or `i32` for
#! `VkResult`, flags are `u32`, or `u64` where they're of 64 bits, and
#! `VkBool32` is a `u32`: a member of one says which C type it is. A function's
#! parameter that points to one thing that must be there is a reference, `&T`
#! where it's read, and `&mut T` where it's written; one that may be null, or
#! points to an array or to bytes, is a pointer, `*T` or `*mut T`.
#!
#! The functions the loader exports, those of the core and of surfaces and
#! swapchains, are C's, and found in it. Every command has its type, as
#! `PFN_vkCreateDebugUtilsMessengerEXT`, to call what `vkGetInstanceProcAddr`
#! and `vkGetDeviceProcAddr` give: an extension's that the loader doesn't
#! export are called only so.
#!
#! Written by `malunal.vulkan.bindings` from the registry of Vulkan 1.4.328: run
#! it again, rather than editing this.
extern module malunal::vulkan when os == windows || os == linux;
#! The registry's own version, `VK_HEADER_VERSION`, as Vulkan 1.4.328 is.
pub const VK_HEADER_VERSION: u32 = 328;
#! The registry's whole version, as `VK_MAKE_API_VERSION` writes it.
pub const VK_HEADER_VERSION_COMPLETE: u32 = (1 << 22) | (4 << 12) | 328;
# Each version of Vulkan's core bound, as `VkApplicationInfo::apiVersion` names it.
pub const VK_API_VERSION_1_0: u32 = (1 << 22) | (0 << 12);
pub const VK_API_VERSION_1_1: u32 = (1 << 22) | (1 << 12);
pub const VK_API_VERSION_1_2: u32 = (1 << 22) | (2 << 12);
pub const VK_API_VERSION_1_3: u32 = (1 << 22) | (3 << 12);
pub const VK_API_VERSION_1_4: u32 = (1 << 22) | (4 << 12);
#! No handle at all.
pub const VK_NULL_HANDLE: u64 = 0;
#! A version, as Vulkan writes it: its variant, 0 for Vulkan's, in 3 bits, then
#! its major version in 7, its minor version in 10, and its patch in 12.
pub def VK_MAKE_API_VERSION(variant: u32, major: u32, minor: u32, patch: u32): u32 {
return (variant << 29) | (major << 22) | (minor << 12) | patch;
}
#! A version's variant.
pub def VK_API_VERSION_VARIANT(version: u32): u32 {
return version >> 29;
}
#! A version's major version.
pub def VK_API_VERSION_MAJOR(version: u32): u32 {
return (version >> 22) & 0x7F;
}
#! A version's minor version.
pub def VK_API_VERSION_MINOR(version: u32): u32 {
return (version >> 12) & 0x3FF;
}
#! A version's patch.
pub def VK_API_VERSION_PATCH(version: u32): u32 {
return version & 0xFFF;
}
+34
View File
@@ -0,0 +1,34 @@
#! Contains the part of `malunal::vulkan` only Linux has, of wayland's
#! extensions: `VK_KHR_wayland_surface`.
#!
#! Written by `malunal.vulkan.bindings` from the registry of Vulkan 1.4.328: run
#! it again, rather than editing this.
extern import "libvulkan.so.1" when os == linux;
extern module malunal::vulkan when os == linux;
# VK_KHR_wayland_surface
pub const VK_KHR_WAYLAND_SURFACE_SPEC_VERSION: u32 = 6;
pub const VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME: strview = "VK_KHR_wayland_surface";
# VkStructureType
pub const VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR: u32 = 1000006000;
#! `VkWaylandSurfaceCreateInfoKHR`.
pub struct wayland_surface_create_info_khr {
pub var s_type: u32 = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; #! VkStructureType
pub var next: *u8;
pub var flags: u32; #! VkWaylandSurfaceCreateFlagsKHR
pub var display: *mut u8; #! wl_display
pub var surface: *mut u8; #! wl_surface
}
# The functions the loader exports.
pub def vkCreateWaylandSurfaceKHR(instance: u64, create_info: &wayland_surface_create_info_khr, allocator: *allocation_callbacks, surface: &mut u64): i32;
pub def vkGetPhysicalDeviceWaylandPresentationSupportKHR(physical_device: u64, queue_family_index: u32, display: *mut u8): u32;
# Each command's type, as `vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` give
# it, to be cast to.
pub type PFN_vkCreateWaylandSurfaceKHR = cfn<def(u64, &wayland_surface_create_info_khr, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR = cfn<def(u64, u32, *mut u8): u32>;
+34
View File
@@ -0,0 +1,34 @@
#! Contains the part of `malunal::vulkan` only Windows has, of win32's
#! extensions: `VK_KHR_win32_surface`.
#!
#! Written by `malunal.vulkan.bindings` from the registry of Vulkan 1.4.328: run
#! it again, rather than editing this.
extern import "vulkan-1.dll" when os == windows;
extern module malunal::vulkan when os == windows;
# VK_KHR_win32_surface
pub const VK_KHR_WIN32_SURFACE_SPEC_VERSION: u32 = 6;
pub const VK_KHR_WIN32_SURFACE_EXTENSION_NAME: strview = "VK_KHR_win32_surface";
# VkStructureType
pub const VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR: u32 = 1000009000;
#! `VkWin32SurfaceCreateInfoKHR`.
pub struct win32_surface_create_info_khr {
pub var s_type: u32 = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; #! VkStructureType
pub var next: *u8;
pub var flags: u32; #! VkWin32SurfaceCreateFlagsKHR
pub var hinstance: u64; #! HINSTANCE
pub var hwnd: u64; #! HWND
}
# The functions the loader exports.
pub def vkCreateWin32SurfaceKHR(instance: u64, create_info: &win32_surface_create_info_khr, allocator: *allocation_callbacks, surface: &mut u64): i32;
pub def vkGetPhysicalDeviceWin32PresentationSupportKHR(physical_device: u64, queue_family_index: u32): u32;
# Each command's type, as `vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` give
# it, to be cast to.
pub type PFN_vkCreateWin32SurfaceKHR = cfn<def(u64, &win32_surface_create_info_khr, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR = cfn<def(u64, u32): u32>;
+34
View File
@@ -0,0 +1,34 @@
#! Contains the part of `malunal::vulkan` only Linux has, of xcb's
#! extensions: `VK_KHR_xcb_surface`.
#!
#! Written by `malunal.vulkan.bindings` from the registry of Vulkan 1.4.328: run
#! it again, rather than editing this.
extern import "libvulkan.so.1" when os == linux;
extern module malunal::vulkan when os == linux;
# VK_KHR_xcb_surface
pub const VK_KHR_XCB_SURFACE_SPEC_VERSION: u32 = 6;
pub const VK_KHR_XCB_SURFACE_EXTENSION_NAME: strview = "VK_KHR_xcb_surface";
# VkStructureType
pub const VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR: u32 = 1000005000;
#! `VkXcbSurfaceCreateInfoKHR`.
pub struct xcb_surface_create_info_khr {
pub var s_type: u32 = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; #! VkStructureType
pub var next: *u8;
pub var flags: u32; #! VkXcbSurfaceCreateFlagsKHR
pub var connection: *mut u8; #! xcb_connection_t
pub var window: u32; #! xcb_window_t
}
# The functions the loader exports.
pub def vkCreateXcbSurfaceKHR(instance: u64, create_info: &xcb_surface_create_info_khr, allocator: *allocation_callbacks, surface: &mut u64): i32;
pub def vkGetPhysicalDeviceXcbPresentationSupportKHR(physical_device: u64, queue_family_index: u32, connection: *mut u8, visual_id: u32): u32;
# Each command's type, as `vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` give
# it, to be cast to.
pub type PFN_vkCreateXcbSurfaceKHR = cfn<def(u64, &xcb_surface_create_info_khr, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR = cfn<def(u64, u32, *mut u8, u32): u32>;
+34
View File
@@ -0,0 +1,34 @@
#! Contains the part of `malunal::vulkan` only Linux has, of xlib's
#! extensions: `VK_KHR_xlib_surface`.
#!
#! Written by `malunal.vulkan.bindings` from the registry of Vulkan 1.4.328: run
#! it again, rather than editing this.
extern import "libvulkan.so.1" when os == linux;
extern module malunal::vulkan when os == linux;
# VK_KHR_xlib_surface
pub const VK_KHR_XLIB_SURFACE_SPEC_VERSION: u32 = 6;
pub const VK_KHR_XLIB_SURFACE_EXTENSION_NAME: strview = "VK_KHR_xlib_surface";
# VkStructureType
pub const VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR: u32 = 1000004000;
#! `VkXlibSurfaceCreateInfoKHR`.
pub struct xlib_surface_create_info_khr {
pub var s_type: u32 = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; #! VkStructureType
pub var next: *u8;
pub var flags: u32; #! VkXlibSurfaceCreateFlagsKHR
pub var dpy: *mut u8; #! Display
pub var window: u64; #! Window
}
# The functions the loader exports.
pub def vkCreateXlibSurfaceKHR(instance: u64, create_info: &xlib_surface_create_info_khr, allocator: *allocation_callbacks, surface: &mut u64): i32;
pub def vkGetPhysicalDeviceXlibPresentationSupportKHR(physical_device: u64, queue_family_index: u32, dpy: *mut u8, visual_id: u64): u32;
# Each command's type, as `vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` give
# it, to be cast to.
pub type PFN_vkCreateXlibSurfaceKHR = cfn<def(u64, &xlib_surface_create_info_khr, *allocation_callbacks, &mut u64): i32>;
pub type PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR = cfn<def(u64, u32, *mut u8, u64): u32>;