dvulkan
Free Pascal Header for Vulkan API, public domain
- Quiet · last change 9-22-2021
- ★ 1 on GitHub
README
dvulkan
Free Pascal Header for Vulkan API, public domain. All in the dvulkan.pas file.
Issues
- Tested only on Windows, no support for other platforms for now
- Declarations for
vk_videoare incomplete. Should be removed completely I guess
Naming
Almost all names are consistent with those of the C headers:
Vk*- typesvk*- functionsPFN_*- pointers to functionsVK_*- constants
There are several exceptions, though:
- When a field or a function argument is a Pascal keyword, an underscore
prefix is added, e.g.
_typeinstead oftype - When a declaration instoduced which is not part of the Vulkan API,
regular pascal conventions are implied (e.g. T prefix for types), e.g.
TVkHandleNonDispatchable - Additionaly, almost each type has corresponding
P*andPP*declarations for a "pointer to X" and a "pointer to pointer to X" types respectively. For example, for VkBuffer there are PVkBuffer and PPVkBuffer types.
The loader
The dvulkan unit is provided with a loader. The loader consists of the following:
- Statically loaded
vkGetInstanceProcAddrprovided by the system. - A function
LoadVulkanGeneralFunctionsand a recordTVulkanGeneralFunctionsfor loading general function (i.e. non-instance and non-device functions) - A function
LoadVulkanInstanceFunctionsand a recordTVulkanInstanceFunctionsfor loading instance functions - A function
LoadVulkanDeviceFunctionsand a recordTVulkanDeviceFunctionsfor loading device functions
Here is an example pseudocode of how to use all of that:
var
vkg: TVulkanGeneralFunctions;
vki: TVulkanInstanceFunctions;
vkd: TVulkanDeviceFunctions;
instance: VkInstance;
device: VkDevice;
function InitVulkan: Boolean;
begin
if not LoadVulkanGeneralFunctions(@vkGetInstanceProcAddr, vkg) then
Exit(False);
...
if vkg.vkCreateInstance(@instanceCreateInfo, nil, @instance) <> VK_SUCCESS then
Exit(False);
if not LoadVulkanInstanceFunctions(instance, vkg.vkGetInstanceProcAddr, vki) then
Exit(False);
...
if vki.vkCreateDevice(physicalDevice, @deviceCreateInfo, nil, @device) <> VK_SUCCESS then
Exit(False);
// Notice the vki.vkGetDeviceProcAddr
if not LoadVulkanInstanceFunctions(instance, vki.vkGetDeviceProcAddr, vkd) then
Exit(False);
// Now all the functions loaded to vkg, vki, vkd and can be used
...
Exit(True);
end;The dvulkan.pas unit does not provide global functions besides
the global vkGetInstanceProcAddr. If you don't want to use prefixes in your
code, you can use with operator:
with vkg, vki, vkd do begin
...
end;You can disable the loader entirely by commenting out the DVULKAN_LOADER define.

