|
- { ============================================================================
- This file is autogenerated from vk.xml
- You may retrieve the latest version of this file at the Delphi OpenGL
- Community home page, located at http://www.delphigl.com/
-
- The contents of this file are used with permission, subject to
- the Mozilla Public License Version 1.1 (the "License"); you may
- not use this file except in compliance with the License. You may
- obtain a copy of the License at
- http://www.mozilla.org/MPL/MPL-1.1.html
-
- Software distributed under the License is distributed on an
- "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- Original vk.xml comment:
- ==============================================================================
- {%COMMENT%}
- ============================================================================ }
-
- unit Vulkan;
-
- {$I Vulkan.inc}
-
- interface
-
- type
- HINSTANCE = THandle;
- HWND = THandle;
-
- VkHandle = Pointer;
- VkUint8 = Byte;
- VkUint16 = Word;
- VkUint32 = Cardinal;
- VkUint64 = QWord;
- VkInt16 = SmallInt;
- VkInt32 = Integer;
- VkInt64 = Int64;
- VkFloat = Single;
- VkDouble = Double;
- VkChar = AnsiChar;
- VkSize = SizeUInt;
-
- PVkVoid = Pointer;
- PVkHandle = ^VkHandle;
- PVkUint8 = ^VkUint8;
- PVkUint16 = ^VkUint16;
- PVkUint32 = ^VkUint32;
- PVkUint64 = ^VkUint64;
- PVkInt16 = ^VkInt16;
- PVkInt32 = ^VkInt32;
- PVkInt64 = ^VkInt64;
- PVkFloat = ^VkFloat;
- PVkDouble = ^VkDouble;
- PVkChar = ^VkChar;
- PVkSize = ^VkSize;
-
- PPVkVoid = ^PVkVoid;
- PPVkHandle = ^PVkHandle;
- PPVkUint8 = ^PVkUint8;
- PPVkUint16 = ^PVkUint16;
- PPVkUint32 = ^PVkUint32;
- PPVkUint64 = ^PVkUint64;
- PPVkInt16 = ^PVkInt16;
- PPVkInt32 = ^PVkInt32;
- PPVkInt64 = ^PVkInt64;
- PPVkFloat = ^PVkFloat;
- PPVkDouble = ^PVkDouble;
- PPVkChar = ^PVkChar;
- PPVkSize = ^PVkSize;
-
- {%INTERFACE%}
-
- const
- VULKAN_LIBNAME = 'vulkan-1.dll';
-
- type
- VkVersion = VkInt32;
-
- function vkMakeVersion(const aMajor, aMinor, aPatch: Integer): VkVersion; inline;
- function vkGetVersionMajor(const aVersion: VkVersion): Integer; inline;
- function vkGetVersionMinor(const aVersion: VkVersion): Integer; inline;
- function vkGetVersionPatch(const aVersion: VkVersion): Integer; inline;
-
- function InitializeVulkan(const aLibName: String = VULKAN_LIBNAME): Boolean;
- procedure LoadVulkanCommands(const aInstance: VkInstance);
- procedure FinalizeVulkan;
-
- implementation
-
- type
- {$IF DEFINED(VK_WIN)}
- TvkLibHandle = TLibHandle;
- {$ELSE}
- TvkLibHandle = Pointer;
- {$ENDIF}
-
- const
- {$IF DEFINED(VK_WIN)}
- InvalidLibHandle = 0;
- {$ELSE}
- InvalidLibHandle = nil;
- {$ENDIF}
-
- var
- vkLibHandle: TvkLibHandle = InvalidLibHandle;
-
- function vkLoadLibrary(const aLibName: String): TvkLibHandle;
- begin
- {$IF DEFINED(VK_WIN)}
- result := LoadLibrary(aLibName);
- {$ELSE}
- result := InvalidLibHandle;
- {$ENDIF}
- end;
-
- function vkGetProcAddress(const aProcName: String; aInstance: VkInstance = nil; aLibHandle: TvkLibHandle = InvalidLibHandle): TvkVoidFunction;
- begin
- result := nil;
- if (aLibHandle = InvalidLibHandle) then
- aLibHandle := vkLibHandle;
- if Assigned(vkGetInstanceProcAddr) then begin
- result := vkGetInstanceProcAddr(aInstance, PVkChar(aProcName));
- if Assigned(result) then
- exit;
- end;
-
- {$IF DEFINED(VK_WIN)}
- result := GetProcAddress(aLibHandle, AnsiString(aProcName));
- {$ELSE}
- result := nil;
- {$ENDIF}
- end;
-
- procedure vkLoadAddresses(const aInstance: VkInstance = nil);
- begin
- {%IMPLEMENTATION%}
- end;
-
- procedure vkFreeLibrary(var aLibHandle: TvkLibHandle);
- begin
- if (aLibHandle <> InvalidLibHandle) then begin
- {$IF DEFINED(VK_WIN)}
- FreeLibrary(aLibHandle);
- {$ENDIF}
- aLibHandle := InvalidLibHandle;
- end;
- end;
-
- function vkMakeVersion(const aMajor, aMinor, aPatch: Integer): VkVersion;
- begin
- result := (aMajor shl 22) or (aMinor shl 12) or aPatch;
- end;
-
- function vkGetVersionMajor(const aVersion: VkVersion): Integer;
- begin
- result := (aVersion shr 22);
- end;
-
- function vkGetVersionMinor(const aVersion: VkVersion): Integer;
- begin
- result := (aVersion shr 12) and $3FF;
- end;
-
- function vkGetVersionPatch(const aVersion: VkVersion): Integer;
- begin
- result := (aVersion and $FFF);
- end;
-
- function InitializeVulkan(const aLibName: String = VULKAN_LIBNAME): Boolean;
- begin
- FinalizeVulkan;
- vkLibHandle := vkLoadLibrary(aLibName);
- result := (vkLibHandle <> InvalidLibHandle);
- if not result then
- exit;
- vkGetInstanceProcAddr := TvkGetInstanceProcAddr(vkGetProcAddress('vkGetInstanceProcAddr'));
- vkLoadAddresses(nil);
- end;
-
- procedure LoadVulkanCommands(const aInstance: VkInstance);
- begin
- vkLoadAddresses(aInstance);
- end;
-
- procedure FinalizeVulkan;
- begin
- vkFreeLibrary(vkLibHandle);
- end;
-
- initialization
-
- finalization
- FinalizeVulkan;
-
- end.
|