You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

198 rivejä
4.8 KiB

  1. { ============================================================================
  2. This file is autogenerated from vk.xml
  3. You may retrieve the latest version of this file at the Delphi OpenGL
  4. Community home page, located at http://www.delphigl.com/
  5. The contents of this file are used with permission, subject to
  6. the Mozilla Public License Version 1.1 (the "License"); you may
  7. not use this file except in compliance with the License. You may
  8. obtain a copy of the License at
  9. http://www.mozilla.org/MPL/MPL-1.1.html
  10. Software distributed under the License is distributed on an
  11. "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  12. implied. See the License for the specific language governing
  13. rights and limitations under the License.
  14. Original vk.xml comment:
  15. ==============================================================================
  16. {%COMMENT%}
  17. ============================================================================ }
  18. unit Vulkan;
  19. {$I Vulkan.inc}
  20. interface
  21. type
  22. HINSTANCE = THandle;
  23. HWND = THandle;
  24. VkHandle = Pointer;
  25. VkUint8 = Byte;
  26. VkUint16 = Word;
  27. VkUint32 = Cardinal;
  28. VkUint64 = QWord;
  29. VkInt16 = SmallInt;
  30. VkInt32 = Integer;
  31. VkInt64 = Int64;
  32. VkFloat = Single;
  33. VkDouble = Double;
  34. VkChar = AnsiChar;
  35. VkSize = SizeUInt;
  36. PVkVoid = Pointer;
  37. PVkHandle = ^VkHandle;
  38. PVkUint8 = ^VkUint8;
  39. PVkUint16 = ^VkUint16;
  40. PVkUint32 = ^VkUint32;
  41. PVkUint64 = ^VkUint64;
  42. PVkInt16 = ^VkInt16;
  43. PVkInt32 = ^VkInt32;
  44. PVkInt64 = ^VkInt64;
  45. PVkFloat = ^VkFloat;
  46. PVkDouble = ^VkDouble;
  47. PVkChar = ^VkChar;
  48. PVkSize = ^VkSize;
  49. PPVkVoid = ^PVkVoid;
  50. PPVkHandle = ^PVkHandle;
  51. PPVkUint8 = ^PVkUint8;
  52. PPVkUint16 = ^PVkUint16;
  53. PPVkUint32 = ^PVkUint32;
  54. PPVkUint64 = ^PVkUint64;
  55. PPVkInt16 = ^PVkInt16;
  56. PPVkInt32 = ^PVkInt32;
  57. PPVkInt64 = ^PVkInt64;
  58. PPVkFloat = ^PVkFloat;
  59. PPVkDouble = ^PVkDouble;
  60. PPVkChar = ^PVkChar;
  61. PPVkSize = ^PVkSize;
  62. {%INTERFACE%}
  63. const
  64. VULKAN_LIBNAME = 'vulkan-1.dll';
  65. type
  66. VkVersion = VkInt32;
  67. function vkMakeVersion(const aMajor, aMinor, aPatch: Integer): VkVersion; inline;
  68. function vkGetVersionMajor(const aVersion: VkVersion): Integer; inline;
  69. function vkGetVersionMinor(const aVersion: VkVersion): Integer; inline;
  70. function vkGetVersionPatch(const aVersion: VkVersion): Integer; inline;
  71. function InitializeVulkan(const aLibName: String = VULKAN_LIBNAME): Boolean;
  72. procedure LoadVulkanCommands(const aInstance: VkInstance);
  73. procedure FinalizeVulkan;
  74. implementation
  75. type
  76. {$IF DEFINED(VK_WIN)}
  77. TvkLibHandle = TLibHandle;
  78. {$ELSE}
  79. TvkLibHandle = Pointer;
  80. {$ENDIF}
  81. const
  82. {$IF DEFINED(VK_WIN)}
  83. InvalidLibHandle = 0;
  84. {$ELSE}
  85. InvalidLibHandle = nil;
  86. {$ENDIF}
  87. var
  88. vkLibHandle: TvkLibHandle = InvalidLibHandle;
  89. function vkLoadLibrary(const aLibName: String): TvkLibHandle;
  90. begin
  91. {$IF DEFINED(VK_WIN)}
  92. result := LoadLibrary(aLibName);
  93. {$ELSE}
  94. result := InvalidLibHandle;
  95. {$ENDIF}
  96. end;
  97. function vkGetProcAddress(const aProcName: String; aInstance: VkInstance = nil; aLibHandle: TvkLibHandle = InvalidLibHandle): TvkVoidFunction;
  98. begin
  99. result := nil;
  100. if (aLibHandle = InvalidLibHandle) then
  101. aLibHandle := vkLibHandle;
  102. if Assigned(vkGetInstanceProcAddr) then begin
  103. result := vkGetInstanceProcAddr(aInstance, PVkChar(aProcName));
  104. if Assigned(result) then
  105. exit;
  106. end;
  107. {$IF DEFINED(VK_WIN)}
  108. result := GetProcAddress(aLibHandle, AnsiString(aProcName));
  109. {$ELSE}
  110. result := nil;
  111. {$ENDIF}
  112. end;
  113. procedure vkLoadAddresses(const aInstance: VkInstance = nil);
  114. begin
  115. {%IMPLEMENTATION%}
  116. end;
  117. procedure vkFreeLibrary(var aLibHandle: TvkLibHandle);
  118. begin
  119. if (aLibHandle <> InvalidLibHandle) then begin
  120. {$IF DEFINED(VK_WIN)}
  121. FreeLibrary(aLibHandle);
  122. {$ENDIF}
  123. aLibHandle := InvalidLibHandle;
  124. end;
  125. end;
  126. function vkMakeVersion(const aMajor, aMinor, aPatch: Integer): VkVersion;
  127. begin
  128. result := (aMajor shl 22) or (aMinor shl 12) or aPatch;
  129. end;
  130. function vkGetVersionMajor(const aVersion: VkVersion): Integer;
  131. begin
  132. result := (aVersion shr 22);
  133. end;
  134. function vkGetVersionMinor(const aVersion: VkVersion): Integer;
  135. begin
  136. result := (aVersion shr 12) and $3FF;
  137. end;
  138. function vkGetVersionPatch(const aVersion: VkVersion): Integer;
  139. begin
  140. result := (aVersion and $FFF);
  141. end;
  142. function InitializeVulkan(const aLibName: String = VULKAN_LIBNAME): Boolean;
  143. begin
  144. FinalizeVulkan;
  145. vkLibHandle := vkLoadLibrary(aLibName);
  146. result := (vkLibHandle <> InvalidLibHandle);
  147. if not result then
  148. exit;
  149. vkGetInstanceProcAddr := TvkGetInstanceProcAddr(vkGetProcAddress('vkGetInstanceProcAddr'));
  150. vkLoadAddresses(nil);
  151. end;
  152. procedure LoadVulkanCommands(const aInstance: VkInstance);
  153. begin
  154. vkLoadAddresses(aInstance);
  155. end;
  156. procedure FinalizeVulkan;
  157. begin
  158. vkFreeLibrary(vkLibHandle);
  159. end;
  160. initialization
  161. finalization
  162. FinalizeVulkan;
  163. end.