Przeglądaj źródła

* [generator] fixed some bugs

* [utils] started to implement wrapper classes for vulkan api
* [triangle] stared implementation of simple triangle example
master
Bergmann89 8 lat temu
rodzic
commit
ea7ba57a75
14 zmienionych plików z 1287 dodań i 176 usunięć
  1. +136
    -131
      projects/Vulkan.pas
  2. +59
    -4
      projects/generator/HeaderGenerator.pas
  3. +46
    -41
      projects/generator/generator.lps
  4. BIN
     
  5. +106
    -0
      projects/triangle/triangle.lpi
  6. +24
    -0
      projects/triangle/triangle.lpr
  7. +226
    -0
      projects/triangle/triangle.lps
  8. BIN
     
  9. +10
    -0
      projects/triangle/uMainForm.lfm
  10. +61
    -0
      projects/triangle/uMainForm.pas
  11. +125
    -0
      projects/utils/uvkuInstance.pas
  12. +316
    -0
      projects/utils/uvkuInstanceEx.pas
  13. +144
    -0
      projects/utils/uvkuPhysicalDevice.pas
  14. +34
    -0
      projects/utils/uvkuUtils.pas

+ 136
- 131
projects/Vulkan.pas Wyświetl plik

@@ -81,6 +81,11 @@ interface

{********************************* VK_VERSION_1_0 *********************************}
const { constants }
VK_API_VERSION = 4194307;
VK_API_VERSION_MAJOR = 1;
VK_API_VERSION_MINOR = 0;
VK_API_VERSION_BUGFIX = 3;

VK_MAX_PHYSICAL_DEVICE_NAME_SIZE = 256;
VK_UUID_SIZE = 16;
VK_MAX_EXTENSION_NAME_SIZE = 256;
@@ -1011,10 +1016,10 @@ type { enums }
type { funcptrs }
TvkVoidFunction = procedure(); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkFreeFunction = procedure(pUserData: PVkVoid; pMemory: PVkVoid); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkAllocationFunction = procedure(pUserData: PVkVoid; size: VkSize; alignment: VkSize; allocationScope: TVkSystemAllocationScope); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkAllocationFunction = function (pUserData: PVkVoid; size: VkSize; alignment: VkSize; allocationScope: TVkSystemAllocationScope): PVkVoid; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkInternalAllocationNotification = procedure(pUserData: PVkVoid; size: VkSize; allocationType: TVkInternalAllocationType; allocationScope: TVkSystemAllocationScope); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkInternalFreeNotification = procedure(pUserData: PVkVoid; size: VkSize; allocationType: TVkInternalAllocationType; allocationScope: TVkSystemAllocationScope); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkReallocationFunction = procedure(pUserData: PVkVoid; pOriginal: PVkVoid; size: VkSize; alignment: VkSize; allocationScope: TVkSystemAllocationScope); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkReallocationFunction = function (pUserData: PVkVoid; pOriginal: PVkVoid; size: VkSize; alignment: VkSize; allocationScope: TVkSystemAllocationScope): PVkVoid; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};

type { structs }
TVkViewport = record
@@ -1282,14 +1287,6 @@ type { structs }
PVkSubpassDependency = ^TVkSubpassDependency;
PPVkSubpassDependency = ^PVkSubpassDependency;

TVkPushConstantRange = record
stageFlags: VkShaderStageFlags;
offset: VkUint32;
size: VkUint32;
end;
PVkPushConstantRange = ^TVkPushConstantRange;
PPVkPushConstantRange = ^PVkPushConstantRange;

TVkPhysicalDeviceLimits = record
maxImageDimension1D: VkUint32;
maxImageDimension2D: VkUint32;
@@ -1401,6 +1398,21 @@ type { structs }
PVkPhysicalDeviceLimits = ^TVkPhysicalDeviceLimits;
PPVkPhysicalDeviceLimits = ^PVkPhysicalDeviceLimits;

TVkPushConstantRange = record
stageFlags: VkShaderStageFlags;
offset: VkUint32;
size: VkUint32;
end;
PVkPushConstantRange = ^TVkPushConstantRange;
PPVkPushConstantRange = ^PVkPushConstantRange;

TVkRect2D = record
offset: TVkOffset2D;
extent: TVkExtent2D;
end;
PVkRect2D = ^TVkRect2D;
PPVkRect2D = ^PVkRect2D;

TVkDescriptorBufferInfo = record
buffer: VkBuffer;
offset: VkDeviceSize;
@@ -1409,6 +1421,33 @@ type { structs }
PVkDescriptorBufferInfo = ^TVkDescriptorBufferInfo;
PPVkDescriptorBufferInfo = ^PVkDescriptorBufferInfo;

TVkQueueFamilyProperties = record
queueFlags: VkQueueFlags;
queueCount: VkUint32;
timestampValidBits: VkUint32;
minImageTransferGranularity: TVkExtent3D;
end;
PVkQueueFamilyProperties = ^TVkQueueFamilyProperties;
PPVkQueueFamilyProperties = ^PVkQueueFamilyProperties;

TVkImageFormatProperties = record
maxExtent: TVkExtent3D;
maxMipLevels: VkUint32;
maxArrayLayers: VkUint32;
sampleCounts: VkSampleCountFlags;
maxResourceSize: VkDeviceSize;
end;
PVkImageFormatProperties = ^TVkImageFormatProperties;
PPVkImageFormatProperties = ^PVkImageFormatProperties;

TVkSparseImageFormatProperties = record
aspectMask: VkImageAspectFlags;
imageGranularity: TVkExtent3D;
flags: VkSparseImageFormatFlags;
end;
PVkSparseImageFormatProperties = ^TVkSparseImageFormatProperties;
PPVkSparseImageFormatProperties = ^PVkSparseImageFormatProperties;

TVkSparseMemoryBind = record
resourceOffset: VkDeviceSize;
size: VkDeviceSize;
@@ -1533,13 +1572,6 @@ type { structs }
PVkClearValue = ^TVkClearValue;
PPVkClearValue = ^PVkClearValue;

TVkRect2D = record
offset: TVkOffset2D;
extent: TVkExtent2D;
end;
PVkRect2D = ^TVkRect2D;
PPVkRect2D = ^PVkRect2D;

TVkSpecializationInfo = record
mapEntryCount: VkUint32;
pMapEntries: PVkSpecializationMapEntry;
@@ -1634,25 +1666,6 @@ type { structs }
PVkCommandBufferInheritanceInfo = ^TVkCommandBufferInheritanceInfo;
PPVkCommandBufferInheritanceInfo = ^PVkCommandBufferInheritanceInfo;

TVkQueueFamilyProperties = record
queueFlags: VkQueueFlags;
queueCount: VkUint32;
timestampValidBits: VkUint32;
minImageTransferGranularity: TVkExtent3D;
end;
PVkQueueFamilyProperties = ^TVkQueueFamilyProperties;
PPVkQueueFamilyProperties = ^PVkQueueFamilyProperties;

TVkImageFormatProperties = record
maxExtent: TVkExtent3D;
maxMipLevels: VkUint32;
maxArrayLayers: VkUint32;
sampleCounts: VkSampleCountFlags;
maxResourceSize: VkDeviceSize;
end;
PVkImageFormatProperties = ^TVkImageFormatProperties;
PPVkImageFormatProperties = ^PVkImageFormatProperties;

TVkDescriptorSetLayoutBinding = record
binding: VkUint32;
descriptorType: TVkDescriptorType;
@@ -1663,14 +1676,6 @@ type { structs }
PVkDescriptorSetLayoutBinding = ^TVkDescriptorSetLayoutBinding;
PPVkDescriptorSetLayoutBinding = ^PVkDescriptorSetLayoutBinding;

TVkSparseImageFormatProperties = record
aspectMask: VkImageAspectFlags;
imageGranularity: TVkExtent3D;
flags: VkSparseImageFormatFlags;
end;
PVkSparseImageFormatProperties = ^TVkSparseImageFormatProperties;
PPVkSparseImageFormatProperties = ^PVkSparseImageFormatProperties;

TVkSparseImageMemoryBind = record
subresource: TVkImageSubresource;
offset: TVkOffset3D;
@@ -1745,6 +1750,24 @@ type { structs }
PVkPhysicalDeviceProperties = ^TVkPhysicalDeviceProperties;
PPVkPhysicalDeviceProperties = ^PVkPhysicalDeviceProperties;

TVkClearRect = record
rect: TVkRect2D;
baseArrayLayer: VkUint32;
layerCount: VkUint32;
end;
PVkClearRect = ^TVkClearRect;
PPVkClearRect = ^PVkClearRect;

TVkSparseImageMemoryRequirements = record
formatProperties: TVkSparseImageFormatProperties;
imageMipTailFirstLod: VkUint32;
imageMipTailSize: VkDeviceSize;
imageMipTailOffset: VkDeviceSize;
imageMipTailStride: VkDeviceSize;
end;
PVkSparseImageMemoryRequirements = ^TVkSparseImageMemoryRequirements;
PPVkSparseImageMemoryRequirements = ^PVkSparseImageMemoryRequirements;

TVkSparseBufferMemoryBindInfo = record
buffer: VkBuffer;
bindCount: VkUint32;
@@ -1806,14 +1829,6 @@ type { structs }
PVkClearAttachment = ^TVkClearAttachment;
PPVkClearAttachment = ^PVkClearAttachment;

TVkClearRect = record
rect: TVkRect2D;
baseArrayLayer: VkUint32;
layerCount: VkUint32;
end;
PVkClearRect = ^TVkClearRect;
PPVkClearRect = ^PVkClearRect;

TVkDeviceCreateInfo = record
sType: TVkStructureType;
pNext: PVkVoid;
@@ -1848,16 +1863,6 @@ type { structs }
PVkDescriptorSetLayoutCreateInfo = ^TVkDescriptorSetLayoutCreateInfo;
PPVkDescriptorSetLayoutCreateInfo = ^PVkDescriptorSetLayoutCreateInfo;

TVkSparseImageMemoryRequirements = record
formatProperties: TVkSparseImageFormatProperties;
imageMipTailFirstLod: VkUint32;
imageMipTailSize: VkDeviceSize;
imageMipTailOffset: VkDeviceSize;
imageMipTailStride: VkDeviceSize;
end;
PVkSparseImageMemoryRequirements = ^TVkSparseImageMemoryRequirements;
PPVkSparseImageMemoryRequirements = ^PVkSparseImageMemoryRequirements;

TVkSparseImageMemoryBindInfo = record
image: VkImage;
bindCount: VkUint32;
@@ -2139,6 +2144,18 @@ type { structs }
PVkPipelineLayoutCreateInfo = ^TVkPipelineLayoutCreateInfo;
PPVkPipelineLayoutCreateInfo = ^PVkPipelineLayoutCreateInfo;

TVkPipelineViewportStateCreateInfo = record
sType: TVkStructureType;
pNext: PVkVoid;
flags: VkPipelineViewportStateCreateFlags;
viewportCount: VkUint32;
pViewports: PVkViewport;
scissorCount: VkUint32;
pScissors: PVkRect2D;
end;
PVkPipelineViewportStateCreateInfo = ^TVkPipelineViewportStateCreateInfo;
PPVkPipelineViewportStateCreateInfo = ^PVkPipelineViewportStateCreateInfo;

TVkImageViewCreateInfo = record
sType: TVkStructureType;
pNext: PVkVoid;
@@ -2209,18 +2226,6 @@ type { structs }
PVkWriteDescriptorSet = ^TVkWriteDescriptorSet;
PPVkWriteDescriptorSet = ^PVkWriteDescriptorSet;

TVkPipelineViewportStateCreateInfo = record
sType: TVkStructureType;
pNext: PVkVoid;
flags: VkPipelineViewportStateCreateFlags;
viewportCount: VkUint32;
pViewports: PVkViewport;
scissorCount: VkUint32;
pScissors: PVkRect2D;
end;
PVkPipelineViewportStateCreateInfo = ^TVkPipelineViewportStateCreateInfo;
PPVkPipelineViewportStateCreateInfo = ^PVkPipelineViewportStateCreateInfo;

TVkRenderPassBeginInfo = record
sType: TVkStructureType;
pNext: PVkVoid;
@@ -2316,13 +2321,13 @@ type { commands }
TvkCmdExecuteCommands = procedure(commandBuffer: VkCommandBuffer; commandBufferCount: VkUint32; const pCommandBuffers: PVkCommandBuffer); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdSetBlendConstants = procedure(commandBuffer: VkCommandBuffer; const blendConstants: VkFloat); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdSetDepthBias = procedure(commandBuffer: VkCommandBuffer; depthBiasConstantFactor: VkFloat; depthBiasClamp: VkFloat; depthBiasSlopeFactor: VkFloat); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdSetDepthBounds = procedure(commandBuffer: VkCommandBuffer; minDepthBounds: VkFloat; maxDepthBounds: VkFloat); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDeviceWaitIdle = function (device: VkDevice): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetDeviceProcAddr = function (device: VkDevice; const pName: PVkChar): TvkVoidFunction; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetInstanceProcAddr = function (instance: VkInstance; const pName: PVkChar): TvkVoidFunction; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkEnumeratePhysicalDevices = function (instance: VkInstance; pPhysicalDeviceCount: PVkUint32; pPhysicalDevices: PVkPhysicalDevice): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetDeviceQueue = procedure(device: VkDevice; queueFamilyIndex: VkUint32; queueIndex: VkUint32; pQueue: PVkQueue); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkQueueWaitIdle = function (queue: VkQueue): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdSetDepthBounds = procedure(commandBuffer: VkCommandBuffer; minDepthBounds: VkFloat; maxDepthBounds: VkFloat); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdSetLineWidth = procedure(commandBuffer: VkCommandBuffer; lineWidth: VkFloat); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkEndCommandBuffer = function (commandBuffer: VkCommandBuffer): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkFreeCommandBuffers = procedure(device: VkDevice; commandPool: VkCommandPool; commandBufferCount: VkUint32; const pCommandBuffers: PVkCommandBuffer); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
@@ -2338,6 +2343,7 @@ type { commands }
TvkCmdEndQuery = procedure(commandBuffer: VkCommandBuffer; queryPool: VkQueryPool; query: VkUint32); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdResetQueryPool = procedure(commandBuffer: VkCommandBuffer; queryPool: VkQueryPool; firstQuery: VkUint32; queryCount: VkUint32); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkWaitForFences = function (device: VkDevice; fenceCount: VkUint32; const pFences: PVkFence; waitAll: VkBool32; timeout: VkUint64): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetRenderAreaGranularity = procedure(device: VkDevice; renderPass: VkRenderPass; pGranularity: PVkExtent2D); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkBindBufferMemory = function (device: VkDevice; buffer: VkBuffer; memory: VkDeviceMemory; memoryOffset: VkDeviceSize): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkBindImageMemory = function (device: VkDevice; image: VkImage; memory: VkDeviceMemory; memoryOffset: VkDeviceSize): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdBindVertexBuffers = procedure(commandBuffer: VkCommandBuffer; firstBinding: VkUint32; bindingCount: VkUint32; const pBuffers: PVkBuffer; const pOffsets: PVkDeviceSize); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
@@ -2365,7 +2371,6 @@ type { commands }
TvkCmdSetViewport = procedure(commandBuffer: VkCommandBuffer; firstViewport: VkUint32; viewportCount: VkUint32; const pViewports: PVkViewport); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkEnumerateDeviceExtensionProperties = function (physicalDevice: VkPhysicalDevice; const pLayerName: PVkChar; pPropertyCount: PVkUint32; pProperties: PVkExtensionProperties): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkEnumerateInstanceExtensionProperties = function (const pLayerName: PVkChar; pPropertyCount: PVkUint32; pProperties: PVkExtensionProperties): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetRenderAreaGranularity = procedure(device: VkDevice; renderPass: VkRenderPass; pGranularity: PVkExtent2D); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkEnumerateDeviceLayerProperties = function (physicalDevice: VkPhysicalDevice; pPropertyCount: PVkUint32; pProperties: PVkLayerProperties): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkEnumerateInstanceLayerProperties = function (pPropertyCount: PVkUint32; pProperties: PVkLayerProperties): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdBindIndexBuffer = procedure(commandBuffer: VkCommandBuffer; buffer: VkBuffer; offset: VkDeviceSize; indexType: TVkIndexType); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
@@ -2377,28 +2382,26 @@ type { commands }
TvkGetImageSubresourceLayout = procedure(device: VkDevice; image: VkImage; const pSubresource: PVkImageSubresource; pLayout: PVkSubresourceLayout); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdClearColorImage = procedure(commandBuffer: VkCommandBuffer; image: VkImage; imageLayout: TVkImageLayout; const pColor: PVkClearColorValue; rangeCount: VkUint32; const pRanges: PVkImageSubresourceRange); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdClearDepthStencilImage = procedure(commandBuffer: VkCommandBuffer; image: VkImage; imageLayout: TVkImageLayout; const pDepthStencil: PVkClearDepthStencilValue; rangeCount: VkUint32; const pRanges: PVkImageSubresourceRange); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkAllocateCommandBuffers = function (device: VkDevice; const pAllocateInfo: PVkCommandBufferAllocateInfo; pCommandBuffers: PVkCommandBuffer): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkAllocateDescriptorSets = function (device: VkDevice; const pAllocateInfo: PVkDescriptorSetAllocateInfo; pDescriptorSets: PVkDescriptorSet): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdSetScissor = procedure(commandBuffer: VkCommandBuffer; firstScissor: VkUint32; scissorCount: VkUint32; const pScissors: PVkRect2D); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetPhysicalDeviceQueueFamilyProperties = procedure(physicalDevice: VkPhysicalDevice; pQueueFamilyPropertyCount: PVkUint32; pQueueFamilyProperties: PVkQueueFamilyProperties); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetPhysicalDeviceImageFormatProperties = function (physicalDevice: VkPhysicalDevice; format: TVkFormat; iType: TVkImageType; tiling: TVkImageTiling; usage: VkImageUsageFlags; flags: VkImageCreateFlags; pImageFormatProperties: PVkImageFormatProperties): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkAllocateCommandBuffers = function (device: VkDevice; const pAllocateInfo: PVkCommandBufferAllocateInfo; pCommandBuffers: PVkCommandBuffer): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkAllocateDescriptorSets = function (device: VkDevice; const pAllocateInfo: PVkDescriptorSetAllocateInfo; pDescriptorSets: PVkDescriptorSet): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdCopyBufferToImage = procedure(commandBuffer: VkCommandBuffer; srcBuffer: VkBuffer; dstImage: VkImage; dstImageLayout: TVkImageLayout; regionCount: VkUint32; const pRegions: PVkBufferImageCopy); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdCopyImageToBuffer = procedure(commandBuffer: VkCommandBuffer; srcImage: VkImage; srcImageLayout: TVkImageLayout; dstBuffer: VkBuffer; regionCount: VkUint32; const pRegions: PVkBufferImageCopy); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdBlitImage = procedure(commandBuffer: VkCommandBuffer; srcImage: VkImage; srcImageLayout: TVkImageLayout; dstImage: VkImage; dstImageLayout: TVkImageLayout; regionCount: VkUint32; const pRegions: PVkImageBlit; filter: TVkFilter); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdCopyImage = procedure(commandBuffer: VkCommandBuffer; srcImage: VkImage; srcImageLayout: TVkImageLayout; dstImage: VkImage; dstImageLayout: TVkImageLayout; regionCount: VkUint32; const pRegions: PVkImageCopy); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdResolveImage = procedure(commandBuffer: VkCommandBuffer; srcImage: VkImage; srcImageLayout: TVkImageLayout; dstImage: VkImage; dstImageLayout: TVkImageLayout; regionCount: VkUint32; const pRegions: PVkImageResolve); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetPhysicalDeviceMemoryProperties = procedure(physicalDevice: VkPhysicalDevice; pMemoryProperties: PVkPhysicalDeviceMemoryProperties); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetPhysicalDeviceProperties = procedure(physicalDevice: VkPhysicalDevice; pProperties: PVkPhysicalDeviceProperties); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetImageSparseMemoryRequirements = procedure(device: VkDevice; image: VkImage; pSparseMemoryRequirementCount: PVkUint32; pSparseMemoryRequirements: PVkSparseImageMemoryRequirements); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateBuffer = function (device: VkDevice; const pCreateInfo: PVkBufferCreateInfo; const pAllocator: PVkAllocationCallbacks; pBuffer: PVkBuffer): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateBufferView = function (device: VkDevice; const pCreateInfo: PVkBufferViewCreateInfo; const pAllocator: PVkAllocationCallbacks; pView: PVkBufferView): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateCommandPool = function (device: VkDevice; const pCreateInfo: PVkCommandPoolCreateInfo; const pAllocator: PVkAllocationCallbacks; pCommandPool: PVkCommandPool): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateDescriptorPool = function (device: VkDevice; const pCreateInfo: PVkDescriptorPoolCreateInfo; const pAllocator: PVkAllocationCallbacks; pDescriptorPool: PVkDescriptorPool): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyBuffer = procedure(device: VkDevice; buffer: VkBuffer; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyBufferView = procedure(device: VkDevice; bufferView: VkBufferView; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyCommandPool = procedure(device: VkDevice; commandPool: VkCommandPool; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdCopyBufferToImage = procedure(commandBuffer: VkCommandBuffer; srcBuffer: VkBuffer; dstImage: VkImage; dstImageLayout: TVkImageLayout; regionCount: VkUint32; const pRegions: PVkBufferImageCopy); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdBlitImage = procedure(commandBuffer: VkCommandBuffer; srcImage: VkImage; srcImageLayout: TVkImageLayout; dstImage: VkImage; dstImageLayout: TVkImageLayout; regionCount: VkUint32; const pRegions: PVkImageBlit; filter: TVkFilter); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkQueueBindSparse = function (queue: VkQueue; bindInfoCount: VkUint32; const pBindInfo: PVkBindSparseInfo; fence: VkFence): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdCopyImageToBuffer = procedure(commandBuffer: VkCommandBuffer; srcImage: VkImage; srcImageLayout: TVkImageLayout; dstBuffer: VkBuffer; regionCount: VkUint32; const pRegions: PVkBufferImageCopy); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdResolveImage = procedure(commandBuffer: VkCommandBuffer; srcImage: VkImage; srcImageLayout: TVkImageLayout; dstImage: VkImage; dstImageLayout: TVkImageLayout; regionCount: VkUint32; const pRegions: PVkImageResolve); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetPhysicalDeviceMemoryProperties = procedure(physicalDevice: VkPhysicalDevice; pMemoryProperties: PVkPhysicalDeviceMemoryProperties); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateDescriptorPool = function (device: VkDevice; const pCreateInfo: PVkDescriptorPoolCreateInfo; const pAllocator: PVkAllocationCallbacks; pDescriptorPool: PVkDescriptorPool): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateDevice = function (physicalDevice: VkPhysicalDevice; const pCreateInfo: PVkDeviceCreateInfo; const pAllocator: PVkAllocationCallbacks; pDevice: PVkDevice): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateDescriptorSetLayout = function (device: VkDevice; const pCreateInfo: PVkDescriptorSetLayoutCreateInfo; const pAllocator: PVkAllocationCallbacks; pSetLayout: PVkDescriptorSetLayout): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetImageSparseMemoryRequirements = procedure(device: VkDevice; image: VkImage; pSparseMemoryRequirementCount: PVkUint32; pSparseMemoryRequirements: PVkSparseImageMemoryRequirements); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyDescriptorPool = procedure(device: VkDevice; descriptorPool: VkDescriptorPool; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyDescriptorSetLayout = procedure(device: VkDevice; descriptorSetLayout: VkDescriptorSetLayout; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyDevice = procedure(device: VkDevice; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
@@ -2411,7 +2414,6 @@ type { commands }
TvkDestroyPipeline = procedure(device: VkDevice; pipeline: VkPipeline; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyPipelineCache = procedure(device: VkDevice; pipelineCache: VkPipelineCache; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyPipelineLayout = procedure(device: VkDevice; pipelineLayout: VkPipelineLayout; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetPhysicalDeviceProperties = procedure(physicalDevice: VkPhysicalDevice; pProperties: PVkPhysicalDeviceProperties); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyQueryPool = procedure(device: VkDevice; queryPool: VkQueryPool; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroyRenderPass = procedure(device: VkDevice; renderPass: VkRenderPass; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkDestroySampler = procedure(device: VkDevice; sampler: VkSampler; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
@@ -2419,7 +2421,10 @@ type { commands }
TvkDestroyShaderModule = procedure(device: VkDevice; shaderModule: VkShaderModule; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkFreeMemory = procedure(device: VkDevice; memory: VkDeviceMemory; const pAllocator: PVkAllocationCallbacks); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdClearAttachments = procedure(commandBuffer: VkCommandBuffer; attachmentCount: VkUint32; const pAttachments: PVkClearAttachment; rectCount: VkUint32; const pRects: PVkClearRect); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateDevice = function (physicalDevice: VkPhysicalDevice; const pCreateInfo: PVkDeviceCreateInfo; const pAllocator: PVkAllocationCallbacks; pDevice: PVkDevice): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkBeginCommandBuffer = function (commandBuffer: VkCommandBuffer; const pBeginInfo: PVkCommandBufferBeginInfo): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateDescriptorSetLayout = function (device: VkDevice; const pCreateInfo: PVkDescriptorSetLayoutCreateInfo; const pAllocator: PVkAllocationCallbacks; pSetLayout: PVkDescriptorSetLayout): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkQueueBindSparse = function (queue: VkQueue; bindInfoCount: VkUint32; const pBindInfo: PVkBindSparseInfo; fence: VkFence): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdNextSubpass = procedure(commandBuffer: VkCommandBuffer; contents: TVkSubpassContents); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdWriteTimestamp = procedure(commandBuffer: VkCommandBuffer; pipelineStage: TVkPipelineStageFlagBits; queryPool: VkQueryPool; query: VkUint32); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkGetPhysicalDeviceSparseImageFormatProperties = procedure(physicalDevice: VkPhysicalDevice; format: TVkFormat; iType: TVkImageType; samples: TVkSampleCountFlagBits; usage: VkImageUsageFlags; tiling: TVkImageTiling; pPropertyCount: PVkUint32; pProperties: PVkSparseImageFormatProperties); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
@@ -2439,13 +2444,13 @@ type { commands }
TvkCmdPipelineBarrier = procedure(commandBuffer: VkCommandBuffer; srcStageMask: VkPipelineStageFlags; dstStageMask: VkPipelineStageFlags; dependencyFlags: VkDependencyFlags; memoryBarrierCount: VkUint32; const pMemoryBarriers: PVkMemoryBarrier; bufferMemoryBarrierCount: VkUint32; const pBufferMemoryBarriers: PVkBufferMemoryBarrier; imageMemoryBarrierCount: VkUint32; const pImageMemoryBarriers: PVkImageMemoryBarrier); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdWaitEvents = procedure(commandBuffer: VkCommandBuffer; eventCount: VkUint32; const pEvents: PVkEvent; srcStageMask: VkPipelineStageFlags; dstStageMask: VkPipelineStageFlags; memoryBarrierCount: VkUint32; const pMemoryBarriers: PVkMemoryBarrier; bufferMemoryBarrierCount: VkUint32; const pBufferMemoryBarriers: PVkBufferMemoryBarrier; imageMemoryBarrierCount: VkUint32; const pImageMemoryBarriers: PVkImageMemoryBarrier); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreatePipelineLayout = function (device: VkDevice; const pCreateInfo: PVkPipelineLayoutCreateInfo; const pAllocator: PVkAllocationCallbacks; pPipelineLayout: PVkPipelineLayout): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateImageView = function (device: VkDevice; const pCreateInfo: PVkImageViewCreateInfo; const pAllocator: PVkAllocationCallbacks; pView: PVkImageView): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateInstance = function (const pCreateInfo: PVkInstanceCreateInfo; const pAllocator: PVkAllocationCallbacks; pInstance: PVkInstance): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkUpdateDescriptorSets = procedure(device: VkDevice; descriptorWriteCount: VkUint32; const pDescriptorWrites: PVkWriteDescriptorSet; descriptorCopyCount: VkUint32; const pDescriptorCopies: PVkCopyDescriptorSet); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCmdBeginRenderPass = procedure(commandBuffer: VkCommandBuffer; const pRenderPassBegin: PVkRenderPassBeginInfo; contents: TVkSubpassContents); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateRenderPass = function (device: VkDevice; const pCreateInfo: PVkRenderPassCreateInfo; const pAllocator: PVkAllocationCallbacks; pRenderPass: PVkRenderPass): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateGraphicsPipelines = function (device: VkDevice; pipelineCache: VkPipelineCache; createInfoCount: VkUint32; const pCreateInfos: PVkGraphicsPipelineCreateInfo; const pAllocator: PVkAllocationCallbacks; pPipelines: PVkPipeline): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateComputePipelines = function (device: VkDevice; pipelineCache: VkPipelineCache; createInfoCount: VkUint32; const pCreateInfos: PVkComputePipelineCreateInfo; const pAllocator: PVkAllocationCallbacks; pPipelines: PVkPipeline): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateGraphicsPipelines = function (device: VkDevice; pipelineCache: VkPipelineCache; createInfoCount: VkUint32; const pCreateInfos: PVkGraphicsPipelineCreateInfo; const pAllocator: PVkAllocationCallbacks; pPipelines: PVkPipeline): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateImageView = function (device: VkDevice; const pCreateInfo: PVkImageViewCreateInfo; const pAllocator: PVkAllocationCallbacks; pView: PVkImageView): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkCreateInstance = function (const pCreateInfo: PVkInstanceCreateInfo; const pAllocator: PVkAllocationCallbacks; pInstance: PVkInstance): TVkResult; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
TvkUpdateDescriptorSets = procedure(device: VkDevice; descriptorWriteCount: VkUint32; const pDescriptorWrites: PVkWriteDescriptorSet; descriptorCopyCount: VkUint32; const pDescriptorCopies: PVkCopyDescriptorSet); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};

var { command variables }
vkCmdDispatch: TvkCmdDispatch = nil;
@@ -2455,13 +2460,13 @@ var { command variables }
vkCmdExecuteCommands: TvkCmdExecuteCommands = nil;
vkCmdSetBlendConstants: TvkCmdSetBlendConstants = nil;
vkCmdSetDepthBias: TvkCmdSetDepthBias = nil;
vkCmdSetDepthBounds: TvkCmdSetDepthBounds = nil;
vkDeviceWaitIdle: TvkDeviceWaitIdle = nil;
vkGetDeviceProcAddr: TvkGetDeviceProcAddr = nil;
vkGetInstanceProcAddr: TvkGetInstanceProcAddr = nil;
vkEnumeratePhysicalDevices: TvkEnumeratePhysicalDevices = nil;
vkGetDeviceQueue: TvkGetDeviceQueue = nil;
vkQueueWaitIdle: TvkQueueWaitIdle = nil;
vkCmdSetDepthBounds: TvkCmdSetDepthBounds = nil;
vkCmdSetLineWidth: TvkCmdSetLineWidth = nil;
vkEndCommandBuffer: TvkEndCommandBuffer = nil;
vkFreeCommandBuffers: TvkFreeCommandBuffers = nil;
@@ -2477,6 +2482,7 @@ var { command variables }
vkCmdEndQuery: TvkCmdEndQuery = nil;
vkCmdResetQueryPool: TvkCmdResetQueryPool = nil;
vkWaitForFences: TvkWaitForFences = nil;
vkGetRenderAreaGranularity: TvkGetRenderAreaGranularity = nil;
vkBindBufferMemory: TvkBindBufferMemory = nil;
vkBindImageMemory: TvkBindImageMemory = nil;
vkCmdBindVertexBuffers: TvkCmdBindVertexBuffers = nil;
@@ -2504,7 +2510,6 @@ var { command variables }
vkCmdSetViewport: TvkCmdSetViewport = nil;
vkEnumerateDeviceExtensionProperties: TvkEnumerateDeviceExtensionProperties = nil;
vkEnumerateInstanceExtensionProperties: TvkEnumerateInstanceExtensionProperties = nil;
vkGetRenderAreaGranularity: TvkGetRenderAreaGranularity = nil;
vkEnumerateDeviceLayerProperties: TvkEnumerateDeviceLayerProperties = nil;
vkEnumerateInstanceLayerProperties: TvkEnumerateInstanceLayerProperties = nil;
vkCmdBindIndexBuffer: TvkCmdBindIndexBuffer = nil;
@@ -2516,28 +2521,26 @@ var { command variables }
vkGetImageSubresourceLayout: TvkGetImageSubresourceLayout = nil;
vkCmdClearColorImage: TvkCmdClearColorImage = nil;
vkCmdClearDepthStencilImage: TvkCmdClearDepthStencilImage = nil;
vkAllocateCommandBuffers: TvkAllocateCommandBuffers = nil;
vkAllocateDescriptorSets: TvkAllocateDescriptorSets = nil;
vkCmdSetScissor: TvkCmdSetScissor = nil;
vkGetPhysicalDeviceQueueFamilyProperties: TvkGetPhysicalDeviceQueueFamilyProperties = nil;
vkGetPhysicalDeviceImageFormatProperties: TvkGetPhysicalDeviceImageFormatProperties = nil;
vkAllocateCommandBuffers: TvkAllocateCommandBuffers = nil;
vkAllocateDescriptorSets: TvkAllocateDescriptorSets = nil;
vkCmdCopyBufferToImage: TvkCmdCopyBufferToImage = nil;
vkCmdCopyImageToBuffer: TvkCmdCopyImageToBuffer = nil;
vkCmdBlitImage: TvkCmdBlitImage = nil;
vkCmdCopyImage: TvkCmdCopyImage = nil;
vkCmdResolveImage: TvkCmdResolveImage = nil;
vkGetPhysicalDeviceMemoryProperties: TvkGetPhysicalDeviceMemoryProperties = nil;
vkGetPhysicalDeviceProperties: TvkGetPhysicalDeviceProperties = nil;
vkGetImageSparseMemoryRequirements: TvkGetImageSparseMemoryRequirements = nil;
vkCreateBuffer: TvkCreateBuffer = nil;
vkCreateBufferView: TvkCreateBufferView = nil;
vkCreateCommandPool: TvkCreateCommandPool = nil;
vkCreateDescriptorPool: TvkCreateDescriptorPool = nil;
vkDestroyBuffer: TvkDestroyBuffer = nil;
vkDestroyBufferView: TvkDestroyBufferView = nil;
vkDestroyCommandPool: TvkDestroyCommandPool = nil;
vkCmdCopyBufferToImage: TvkCmdCopyBufferToImage = nil;
vkCmdBlitImage: TvkCmdBlitImage = nil;
vkQueueBindSparse: TvkQueueBindSparse = nil;
vkCmdCopyImageToBuffer: TvkCmdCopyImageToBuffer = nil;
vkCmdResolveImage: TvkCmdResolveImage = nil;
vkGetPhysicalDeviceMemoryProperties: TvkGetPhysicalDeviceMemoryProperties = nil;
vkCreateDescriptorPool: TvkCreateDescriptorPool = nil;
vkCreateDevice: TvkCreateDevice = nil;
vkCreateDescriptorSetLayout: TvkCreateDescriptorSetLayout = nil;
vkGetImageSparseMemoryRequirements: TvkGetImageSparseMemoryRequirements = nil;
vkDestroyDescriptorPool: TvkDestroyDescriptorPool = nil;
vkDestroyDescriptorSetLayout: TvkDestroyDescriptorSetLayout = nil;
vkDestroyDevice: TvkDestroyDevice = nil;
@@ -2550,7 +2553,6 @@ var { command variables }
vkDestroyPipeline: TvkDestroyPipeline = nil;
vkDestroyPipelineCache: TvkDestroyPipelineCache = nil;
vkDestroyPipelineLayout: TvkDestroyPipelineLayout = nil;
vkGetPhysicalDeviceProperties: TvkGetPhysicalDeviceProperties = nil;
vkDestroyQueryPool: TvkDestroyQueryPool = nil;
vkDestroyRenderPass: TvkDestroyRenderPass = nil;
vkDestroySampler: TvkDestroySampler = nil;
@@ -2558,7 +2560,10 @@ var { command variables }
vkDestroyShaderModule: TvkDestroyShaderModule = nil;
vkFreeMemory: TvkFreeMemory = nil;
vkCmdClearAttachments: TvkCmdClearAttachments = nil;
vkCreateDevice: TvkCreateDevice = nil;
vkBeginCommandBuffer: TvkBeginCommandBuffer = nil;
vkCreateDescriptorSetLayout: TvkCreateDescriptorSetLayout = nil;
vkQueueBindSparse: TvkQueueBindSparse = nil;
vkCmdNextSubpass: TvkCmdNextSubpass = nil;
vkCmdWriteTimestamp: TvkCmdWriteTimestamp = nil;
vkGetPhysicalDeviceSparseImageFormatProperties: TvkGetPhysicalDeviceSparseImageFormatProperties = nil;
@@ -2578,13 +2583,13 @@ var { command variables }
vkCmdPipelineBarrier: TvkCmdPipelineBarrier = nil;
vkCmdWaitEvents: TvkCmdWaitEvents = nil;
vkCreatePipelineLayout: TvkCreatePipelineLayout = nil;
vkCreateImageView: TvkCreateImageView = nil;
vkCreateInstance: TvkCreateInstance = nil;
vkUpdateDescriptorSets: TvkUpdateDescriptorSets = nil;
vkCmdBeginRenderPass: TvkCmdBeginRenderPass = nil;
vkCreateRenderPass: TvkCreateRenderPass = nil;
vkCreateGraphicsPipelines: TvkCreateGraphicsPipelines = nil;
vkCreateComputePipelines: TvkCreateComputePipelines = nil;
vkCreateGraphicsPipelines: TvkCreateGraphicsPipelines = nil;
vkCreateImageView: TvkCreateImageView = nil;
vkCreateInstance: TvkCreateInstance = nil;
vkUpdateDescriptorSets: TvkUpdateDescriptorSets = nil;

const
VULKAN_LIBNAME = 'vulkan-1.dll';
@@ -2686,13 +2691,13 @@ begin
vkCmdExecuteCommands := vkGetProcAddress('vkCmdExecuteCommands');
vkCmdSetBlendConstants := vkGetProcAddress('vkCmdSetBlendConstants');
vkCmdSetDepthBias := vkGetProcAddress('vkCmdSetDepthBias');
vkCmdSetDepthBounds := vkGetProcAddress('vkCmdSetDepthBounds');
vkDeviceWaitIdle := vkGetProcAddress('vkDeviceWaitIdle');
vkGetDeviceProcAddr := vkGetProcAddress('vkGetDeviceProcAddr');
vkGetInstanceProcAddr := vkGetProcAddress('vkGetInstanceProcAddr');
vkEnumeratePhysicalDevices := vkGetProcAddress('vkEnumeratePhysicalDevices');
vkGetDeviceQueue := vkGetProcAddress('vkGetDeviceQueue');
vkQueueWaitIdle := vkGetProcAddress('vkQueueWaitIdle');
vkCmdSetDepthBounds := vkGetProcAddress('vkCmdSetDepthBounds');
vkCmdSetLineWidth := vkGetProcAddress('vkCmdSetLineWidth');
vkEndCommandBuffer := vkGetProcAddress('vkEndCommandBuffer');
vkFreeCommandBuffers := vkGetProcAddress('vkFreeCommandBuffers');
@@ -2708,6 +2713,7 @@ begin
vkCmdEndQuery := vkGetProcAddress('vkCmdEndQuery');
vkCmdResetQueryPool := vkGetProcAddress('vkCmdResetQueryPool');
vkWaitForFences := vkGetProcAddress('vkWaitForFences');
vkGetRenderAreaGranularity := vkGetProcAddress('vkGetRenderAreaGranularity');
vkBindBufferMemory := vkGetProcAddress('vkBindBufferMemory');
vkBindImageMemory := vkGetProcAddress('vkBindImageMemory');
vkCmdBindVertexBuffers := vkGetProcAddress('vkCmdBindVertexBuffers');
@@ -2735,7 +2741,6 @@ begin
vkCmdSetViewport := vkGetProcAddress('vkCmdSetViewport');
vkEnumerateDeviceExtensionProperties := vkGetProcAddress('vkEnumerateDeviceExtensionProperties');
vkEnumerateInstanceExtensionProperties := vkGetProcAddress('vkEnumerateInstanceExtensionProperties');
vkGetRenderAreaGranularity := vkGetProcAddress('vkGetRenderAreaGranularity');
vkEnumerateDeviceLayerProperties := vkGetProcAddress('vkEnumerateDeviceLayerProperties');
vkEnumerateInstanceLayerProperties := vkGetProcAddress('vkEnumerateInstanceLayerProperties');
vkCmdBindIndexBuffer := vkGetProcAddress('vkCmdBindIndexBuffer');
@@ -2747,28 +2752,26 @@ begin
vkGetImageSubresourceLayout := vkGetProcAddress('vkGetImageSubresourceLayout');
vkCmdClearColorImage := vkGetProcAddress('vkCmdClearColorImage');
vkCmdClearDepthStencilImage := vkGetProcAddress('vkCmdClearDepthStencilImage');
vkAllocateCommandBuffers := vkGetProcAddress('vkAllocateCommandBuffers');
vkAllocateDescriptorSets := vkGetProcAddress('vkAllocateDescriptorSets');
vkCmdSetScissor := vkGetProcAddress('vkCmdSetScissor');
vkGetPhysicalDeviceQueueFamilyProperties := vkGetProcAddress('vkGetPhysicalDeviceQueueFamilyProperties');
vkGetPhysicalDeviceImageFormatProperties := vkGetProcAddress('vkGetPhysicalDeviceImageFormatProperties');
vkAllocateCommandBuffers := vkGetProcAddress('vkAllocateCommandBuffers');
vkAllocateDescriptorSets := vkGetProcAddress('vkAllocateDescriptorSets');
vkCmdCopyBufferToImage := vkGetProcAddress('vkCmdCopyBufferToImage');
vkCmdCopyImageToBuffer := vkGetProcAddress('vkCmdCopyImageToBuffer');
vkCmdBlitImage := vkGetProcAddress('vkCmdBlitImage');
vkCmdCopyImage := vkGetProcAddress('vkCmdCopyImage');
vkCmdResolveImage := vkGetProcAddress('vkCmdResolveImage');
vkGetPhysicalDeviceMemoryProperties := vkGetProcAddress('vkGetPhysicalDeviceMemoryProperties');
vkGetPhysicalDeviceProperties := vkGetProcAddress('vkGetPhysicalDeviceProperties');
vkGetImageSparseMemoryRequirements := vkGetProcAddress('vkGetImageSparseMemoryRequirements');
vkCreateBuffer := vkGetProcAddress('vkCreateBuffer');
vkCreateBufferView := vkGetProcAddress('vkCreateBufferView');
vkCreateCommandPool := vkGetProcAddress('vkCreateCommandPool');
vkCreateDescriptorPool := vkGetProcAddress('vkCreateDescriptorPool');
vkDestroyBuffer := vkGetProcAddress('vkDestroyBuffer');
vkDestroyBufferView := vkGetProcAddress('vkDestroyBufferView');
vkDestroyCommandPool := vkGetProcAddress('vkDestroyCommandPool');
vkCmdCopyBufferToImage := vkGetProcAddress('vkCmdCopyBufferToImage');
vkCmdBlitImage := vkGetProcAddress('vkCmdBlitImage');
vkQueueBindSparse := vkGetProcAddress('vkQueueBindSparse');
vkCmdCopyImageToBuffer := vkGetProcAddress('vkCmdCopyImageToBuffer');
vkCmdResolveImage := vkGetProcAddress('vkCmdResolveImage');
vkGetPhysicalDeviceMemoryProperties := vkGetProcAddress('vkGetPhysicalDeviceMemoryProperties');
vkCreateDescriptorPool := vkGetProcAddress('vkCreateDescriptorPool');
vkCreateDevice := vkGetProcAddress('vkCreateDevice');
vkCreateDescriptorSetLayout := vkGetProcAddress('vkCreateDescriptorSetLayout');
vkGetImageSparseMemoryRequirements := vkGetProcAddress('vkGetImageSparseMemoryRequirements');
vkDestroyDescriptorPool := vkGetProcAddress('vkDestroyDescriptorPool');
vkDestroyDescriptorSetLayout := vkGetProcAddress('vkDestroyDescriptorSetLayout');
vkDestroyDevice := vkGetProcAddress('vkDestroyDevice');
@@ -2781,7 +2784,6 @@ begin
vkDestroyPipeline := vkGetProcAddress('vkDestroyPipeline');
vkDestroyPipelineCache := vkGetProcAddress('vkDestroyPipelineCache');
vkDestroyPipelineLayout := vkGetProcAddress('vkDestroyPipelineLayout');
vkGetPhysicalDeviceProperties := vkGetProcAddress('vkGetPhysicalDeviceProperties');
vkDestroyQueryPool := vkGetProcAddress('vkDestroyQueryPool');
vkDestroyRenderPass := vkGetProcAddress('vkDestroyRenderPass');
vkDestroySampler := vkGetProcAddress('vkDestroySampler');
@@ -2789,7 +2791,10 @@ begin
vkDestroyShaderModule := vkGetProcAddress('vkDestroyShaderModule');
vkFreeMemory := vkGetProcAddress('vkFreeMemory');
vkCmdClearAttachments := vkGetProcAddress('vkCmdClearAttachments');
vkCreateDevice := vkGetProcAddress('vkCreateDevice');
vkBeginCommandBuffer := vkGetProcAddress('vkBeginCommandBuffer');
vkCreateDescriptorSetLayout := vkGetProcAddress('vkCreateDescriptorSetLayout');
vkQueueBindSparse := vkGetProcAddress('vkQueueBindSparse');
vkCmdNextSubpass := vkGetProcAddress('vkCmdNextSubpass');
vkCmdWriteTimestamp := vkGetProcAddress('vkCmdWriteTimestamp');
vkGetPhysicalDeviceSparseImageFormatProperties := vkGetProcAddress('vkGetPhysicalDeviceSparseImageFormatProperties');
@@ -2809,13 +2814,13 @@ begin
vkCmdPipelineBarrier := vkGetProcAddress('vkCmdPipelineBarrier');
vkCmdWaitEvents := vkGetProcAddress('vkCmdWaitEvents');
vkCreatePipelineLayout := vkGetProcAddress('vkCreatePipelineLayout');
vkCreateImageView := vkGetProcAddress('vkCreateImageView');
vkCreateInstance := vkGetProcAddress('vkCreateInstance');
vkUpdateDescriptorSets := vkGetProcAddress('vkUpdateDescriptorSets');
vkCmdBeginRenderPass := vkGetProcAddress('vkCmdBeginRenderPass');
vkCreateRenderPass := vkGetProcAddress('vkCreateRenderPass');
vkCreateGraphicsPipelines := vkGetProcAddress('vkCreateGraphicsPipelines');
vkCreateComputePipelines := vkGetProcAddress('vkCreateComputePipelines');
vkCreateGraphicsPipelines := vkGetProcAddress('vkCreateGraphicsPipelines');
vkCreateImageView := vkGetProcAddress('vkCreateImageView');
vkCreateInstance := vkGetProcAddress('vkCreateInstance');
vkUpdateDescriptorSets := vkGetProcAddress('vkUpdateDescriptorSets');

end;



+ 59
- 4
projects/generator/HeaderGenerator.pas Wyświetl plik

@@ -336,6 +336,16 @@ begin
result := x.TextContent;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TryGetNodeValue(xml: TDOMNode; const aName: WideString; out aValue: DOMString): Boolean;
var x: TDOMNode;
begin
x := xml.FindNode(aName);
result := Assigned(x);
if result then
aValue := x.TextContent;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function GetNodeValue(xml: TDOMNode; const aName: WideString; const aDefault: DOMString): DOMString;
var x: TDOMNode;
@@ -547,8 +557,50 @@ end;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class function THeaderGenerator.TvkObject.CreateFromXml(const xml: TDOMNode): THeaderGenerator.TvkObject;
var
s: DOMString;
s, n: DOMString;
x: TDOMNode;

function GenerateVersionEnum: TvkTypeEnum;
var
rx: TRegExpr;
v: TvkTypeEnum.TValue;
begin
result := TvkTypeEnum.Create(otConst);
rx := TRegExpr.Create('\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)');
try try
if not rx.Exec(xml.TextContent) then
raise XmlException.Create('VK_API_VERSION with malformed version', xml);
v := TvkTypeEnum.TValue.Create;
result.Values.Add(v);
v.Name := 'VK_API_VERSION';
v.Value := (StrToInt(rx.Match[1]) shl 22) or
(StrToInt(rx.Match[2]) shl 12) or
(StrToInt(rx.Match[3]) shl 0);

v := TvkTypeEnum.TValue.Create;
result.Values.Add(v);
v.Name := 'VK_API_VERSION_MAJOR';
v.Value := StrToInt(rx.Match[1]);

v := TvkTypeEnum.TValue.Create;
result.Values.Add(v);
v.Name := 'VK_API_VERSION_MINOR';
v.Value := StrToInt(rx.Match[2]);

v := TvkTypeEnum.TValue.Create;
result.Values.Add(v);
v.Name := 'VK_API_VERSION_BUGFIX';
v.Value := StrToInt(rx.Match[3]);
finally
FreeAndNil(rx);
end;
except
FreeAndNil(result);
raise;
end;
end;


begin
result := nil;
if (xml.NodeName = 'type') and xml.HasAttributes then begin
@@ -563,7 +615,10 @@ begin
else if (s = 'funcpointer') then
result := TvkTypeFunctionPtr.CreateFromXml(xml)
else if (s = 'struct') or (s = 'union') then
result := TvkTypeStruct.CreateFromXml(xml);
result := TvkTypeStruct.CreateFromXml(xml)
else if (s = 'define') and TryGetNodeValue(xml, 'name', n) and (n = 'VK_API_VERSION') then begin
result := GenerateVersionEnum;
end;
end else if (xml.NodeName = 'command') then
result := TvkCommand.CreateFromXml(xml);
end;
@@ -700,7 +755,7 @@ var
a: TArgument;
begin
s := WideString(Format(' %-50s', [ GetPascalName(0, '') ]));
if (ReturnValue.Typ = 'void')
if (ReturnValue.Typ = 'void') and (ReturnValue.IsPointer = 0)
then s := s + ' = procedure('
else s := s + ' = function (';
for i := 0 to fArguments.Count-1 do begin
@@ -712,7 +767,7 @@ begin
s := s + '; ';
end;
s := s + ')';
if (ReturnValue.Typ <> 'void') then
if (ReturnValue.Typ <> 'void') or (ReturnValue.IsPointer > 0) then
s := s + ': ' + List.GetPascalName(ReturnValue.Typ, ReturnValue.IsPointer);
s := s + '; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};';
aCode.Add(String(s));


+ 46
- 41
projects/generator/generator.lps Wyświetl plik

@@ -4,22 +4,22 @@
<PathDelim Value="\"/>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="19">
<Units Count="20">
<Unit0>
<Filename Value="generator.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<CursorPos X="47" Y="16"/>
<UsageCount Value="48"/>
<UsageCount Value="51"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="HeaderGenerator.pas"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="695"/>
<CursorPos X="32" Y="705"/>
<UsageCount Value="48"/>
<TopLine Value="746"/>
<CursorPos X="24" Y="756"/>
<UsageCount Value="51"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
@@ -95,29 +95,27 @@
</Unit11>
<Unit12>
<Filename Value="..\..\..\libTextSuite\OpenGlCore\dglOpenGL.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="15048"/>
<CursorPos X="11" Y="14967"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit12>
<Unit13>
<Filename Value="..\..\data\Vulkan.tpl"/>
<EditorIndex Value="2"/>
<EditorIndex Value="-1"/>
<CursorPos X="40" Y="11"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
<DefaultSyntaxHighlighter Value="None"/>
</Unit13>
<Unit14>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\dynlibh.inc"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="1"/>
<TopLine Value="35"/>
<CursorPos X="25" Y="55"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit14>
<Unit15>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\sysdlh.inc"/>
@@ -147,126 +145,133 @@
<CursorPos X="41" Y="8"/>
<UsageCount Value="10"/>
</Unit18>
<Unit19>
<Filename Value="..\..\..\SpaceCrush\src\openglcore\uglcContext.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="94"/>
<UsageCount Value="10"/>
</Unit19>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1025" TopLine="1010"/>
<Caret Line="810" Column="3" TopLine="803"/>
</Position1>
<Position2>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="866" TopLine="852"/>
<Caret Line="568" TopLine="552"/>
</Position2>
<Position3>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="867" TopLine="852"/>
<Caret Line="569" TopLine="552"/>
</Position3>
<Position4>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="268" TopLine="251"/>
<Caret Line="810" TopLine="794"/>
</Position4>
<Position5>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1013" Column="4" TopLine="996"/>
<Caret Line="811" TopLine="794"/>
</Position5>
<Position6>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1025" TopLine="1000"/>
<Caret Line="812" TopLine="794"/>
</Position6>
<Position7>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1026" TopLine="1002"/>
<Caret Line="813" TopLine="794"/>
</Position7>
<Position8>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="269" TopLine="253"/>
<Caret Line="815" TopLine="794"/>
</Position8>
<Position9>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="270" TopLine="253"/>
<Caret Line="814" Column="42" TopLine="794"/>
</Position9>
<Position10>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="271" TopLine="253"/>
<Caret Line="817" TopLine="802"/>
</Position10>
<Position11>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="272" TopLine="253"/>
<Caret Line="818" TopLine="802"/>
</Position11>
<Position12>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="273" TopLine="253"/>
<Caret Line="821" TopLine="802"/>
</Position12>
<Position13>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="275" TopLine="253"/>
<Caret Line="822" TopLine="802"/>
</Position13>
<Position14>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="764" Column="94" TopLine="776"/>
<Caret Line="823" TopLine="802"/>
</Position14>
<Position15>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1025" TopLine="1010"/>
<Caret Line="821" Column="73" TopLine="802"/>
</Position15>
<Position16>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1026" TopLine="1010"/>
<Caret Line="817" TopLine="802"/>
</Position16>
<Position17>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="268" TopLine="252"/>
<Caret Line="818" TopLine="802"/>
</Position17>
<Position18>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="269" TopLine="252"/>
<Caret Line="821" TopLine="802"/>
</Position18>
<Position19>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="270" TopLine="252"/>
<Caret Line="822" TopLine="802"/>
</Position19>
<Position20>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="271" TopLine="252"/>
<Caret Line="823" TopLine="802"/>
</Position20>
<Position21>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="273" TopLine="252"/>
<Caret Line="826" TopLine="802"/>
</Position21>
<Position22>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="275" TopLine="252"/>
<Caret Line="827" TopLine="802"/>
</Position22>
<Position23>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1022" Column="21" TopLine="998"/>
<Caret Line="828" TopLine="802"/>
</Position23>
<Position24>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="268" TopLine="252"/>
</Position24>
<Position25>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="7" Column="29"/>
<Caret Line="269" TopLine="252"/>
</Position25>
<Position26>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="71" Column="27" TopLine="46"/>
<Caret Line="270" TopLine="252"/>
</Position26>
<Position27>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="952" Column="23" TopLine="937"/>
<Caret Line="271" TopLine="252"/>
</Position27>
<Position28>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="106" Column="7" TopLine="85"/>
<Caret Line="272" TopLine="252"/>
</Position28>
<Position29>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="636" TopLine="626"/>
<Caret Line="273" TopLine="252"/>
</Position29>
<Position30>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="97" Column="35" TopLine="92"/>
<Caret Line="275" TopLine="252"/>
</Position30>
</JumpHistory>
</ProjectSession>
@@ -279,7 +284,7 @@
<Expression Value="result.fName"/>
</Item2>
<Item3>
<Expression Value="result.fReturnValue.IsPointer"/>
<Expression Value="result.fReturnValue.Typ"/>
</Item3>
</Watches>
</Debugging>



+ 106
- 0
projects/triangle/triangle.lpi Wyświetl plik

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="triangle"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="7">
<Unit0>
<Filename Value="triangle.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="uMainForm.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
<Unit2>
<Filename Value="..\Vulkan.pas"/>
<IsPartOfProject Value="True"/>
</Unit2>
<Unit3>
<Filename Value="..\utils\uvkuInstance.pas"/>
<IsPartOfProject Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\utils\uvkuUtils.pas"/>
<IsPartOfProject Value="True"/>
</Unit4>
<Unit5>
<Filename Value="..\utils\uvkuInstanceEx.pas"/>
<IsPartOfProject Value="True"/>
</Unit5>
<Unit6>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<IsPartOfProject Value="True"/>
</Unit6>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="triangle-$(TargetCPU)-$(TargetOS)"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);.."/>
<OtherUnitFiles Value="..;..\utils"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<UseHeaptrc Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

+ 24
- 0
projects/triangle/triangle.lpr Wyświetl plik

@@ -0,0 +1,24 @@
program triangle;

{$mode objfpc}{$H+}

uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, Dialogs, Forms, uMainForm, Vulkan, uvkuInstance, uvkuUtils, uvkuInstanceEx, uvkuPhysicalDevice;

{$R *.res}

begin
if not InitializeVulkan then begin
MessageDlg('Error', 'unable to initialize vulkan api', mtError, [mbOK], 0);
halt;
end;

RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.


+ 226
- 0
projects/triangle/triangle.lps Wyświetl plik

@@ -0,0 +1,226 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectSession>
<PathDelim Value="\"/>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="11">
<Unit0>
<Filename Value="triangle.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="47" Y="22"/>
<UsageCount Value="29"/>
</Unit0>
<Unit1>
<Filename Value="uMainForm.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<TopLine Value="30"/>
<CursorPos X="25" Y="9"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\Vulkan.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="2500"/>
<CursorPos X="3" Y="2516"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="..\utils\uvkuInstance.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="3"/>
<TopLine Value="59"/>
<CursorPos X="10" Y="85"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\utils\uvkuUtils.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="6"/>
<CursorPos X="16" Y="13"/>
<UsageCount Value="24"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="..\..\data\Vulkan.tpl"/>
<EditorIndex Value="1"/>
<TopLine Value="44"/>
<CursorPos X="27" Y="22"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
<DefaultSyntaxHighlighter Value="None"/>
</Unit5>
<Unit6>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\packages\fcl-base\src\custapp.pp"/>
<UnitName Value="CustApp"/>
<EditorIndex Value="-1"/>
<TopLine Value="72"/>
<CursorPos X="14" Y="86"/>
<UsageCount Value="10"/>
</Unit6>
<Unit7>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\objpash.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="213"/>
<CursorPos X="21" Y="224"/>
<UsageCount Value="10"/>
</Unit7>
<Unit8>
<Filename Value="C:\Zusatzprogramme\Lazarus\lcl\include\customform.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="138"/>
<CursorPos Y="154"/>
<UsageCount Value="10"/>
</Unit8>
<Unit9>
<Filename Value="..\utils\uvkuInstanceEx.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="5"/>
<TopLine Value="46"/>
<CursorPos X="23" Y="9"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="4"/>
<TopLine Value="61"/>
<CursorPos Y="77"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit10>
</Units>
<JumpHistory Count="30" HistoryIndex="27">
<Position1>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2569" Column="3" TopLine="2553"/>
</Position1>
<Position2>
<Filename Value="..\Vulkan.pas"/>
</Position2>
<Position3>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="1193" Column="36" TopLine="1179"/>
</Position3>
<Position4>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="1200" Column="73" TopLine="1179"/>
</Position4>
<Position5>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="1750" Column="51" TopLine="1724"/>
</Position5>
<Position6>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="1751" Column="52" TopLine="1725"/>
</Position6>
<Position7>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="1981" Column="28" TopLine="1968"/>
</Position7>
<Position8>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2327" Column="103" TopLine="2301"/>
</Position8>
<Position9>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2328" Column="24" TopLine="2313"/>
</Position9>
<Position10>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2372" TopLine="2346"/>
</Position10>
<Position11>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2373" TopLine="2346"/>
</Position11>
<Position12>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2374" TopLine="2348"/>
</Position12>
<Position13>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2377" Column="23" TopLine="2351"/>
</Position13>
<Position14>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2378" Column="4" TopLine="2351"/>
</Position14>
<Position15>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="28" Column="39" TopLine="11"/>
</Position15>
<Position16>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="39" Column="103" TopLine="11"/>
</Position16>
<Position17>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2245" Column="33" TopLine="2231"/>
</Position17>
<Position18>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2328" Column="9" TopLine="2312"/>
</Position18>
<Position19>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2373" Column="19" TopLine="2354"/>
</Position19>
<Position20>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2375" Column="18" TopLine="2354"/>
</Position20>
<Position21>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2386" TopLine="2373"/>
</Position21>
<Position22>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="52" Column="5" TopLine="44"/>
</Position22>
<Position23>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="24" Column="12" TopLine="8"/>
</Position23>
<Position24>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="41" Column="73" TopLine="26"/>
</Position24>
<Position25>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="43" Column="51" TopLine="27"/>
</Position25>
<Position26>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="34" Column="51" TopLine="16"/>
</Position26>
<Position27>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="106" Column="40" TopLine="90"/>
</Position27>
<Position28>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="77" Column="34" TopLine="61"/>
</Position28>
<Position29>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2516" Column="3" TopLine="2500"/>
</Position29>
<Position30>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2377" Column="3" TopLine="2361"/>
</Position30>
</JumpHistory>
</ProjectSession>
</CONFIG>


+ 10
- 0
projects/triangle/uMainForm.lfm Wyświetl plik

@@ -0,0 +1,10 @@
object MainForm: TMainForm
Left = 419
Height = 240
Top = 263
Width = 320
Caption = 'Triangle'
OnCreate = FormCreate
OnDestroy = FormDestroy
LCLVersion = '1.7'
end

+ 61
- 0
projects/triangle/uMainForm.pas Wyświetl plik

@@ -0,0 +1,61 @@
unit uMainForm;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
Vulkan, uvkuInstanceEx;

type
TCustomAllocHandler = class(TvkuAllocationHandler)
protected
procedure InternalAllocationNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
procedure InternalFreeNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
end;

TMainForm = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
fIntance: TvkuInstanceEx;
public
{ public declarations }
end;

var
MainForm: TMainForm;

implementation

{$R *.lfm}

procedure TCustomAllocHandler.InternalAllocationNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
begin
inherited InternalAllocationNotification(aSize, aType, aScope);
end;

procedure TCustomAllocHandler.InternalFreeNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
begin
inherited InternalFreeNotification(aSize, aType, aScope);
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
fIntance := TvkuInstanceEx.Create(
0,
[],
[],
TvkuInstanceEx.DefaultApplicationInfo,
TvkuAllocationHandler.Create,
true);
end;

procedure TMainForm.FormDestroy(Sender: TObject);
begin
FreeAndNil(fIntance);
end;

end.


+ 125
- 0
projects/utils/uvkuInstance.pas Wyświetl plik

@@ -0,0 +1,125 @@
unit uvkuInstance;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils, Vulkan;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuInstance = class(TObject)
private
fHandle: VkInstance;
fAllocCallbacks: PVkAllocationCallbacks;
fPhysicalDevices: array of VkPhysicalDevice;

function GetPhysicalDeviceCount: Integer;
function GetPhysicalDevices(const aIndex: Integer): VkPhysicalDevice;
procedure UpdatePhysicalDevices;
protected
procedure CreateHandle(aCreateInfo: PVkInstanceCreateInfo; aAllocCallbacks: PVkAllocationCallbacks);
constructor Create;
public
property PhysicalDeviceCount: Integer read GetPhysicalDeviceCount;
property PhysicalDevices[const aIndex: Integer]: VkPhysicalDevice read GetPhysicalDevices;

constructor Create(const aCreateInfo: TVkInstanceCreateInfo);
constructor Create(const aCreateInfo: TVkInstanceCreateInfo; const aAllocCallbacks: TVkAllocationCallbacks);
destructor Destroy; override;
end;

implementation

uses
uvkuUtils;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuInstance///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuInstance.GetPhysicalDeviceCount: Integer;
begin
UpdatePhysicalDevices;
result := Length(fPhysicalDevices);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuInstance.GetPhysicalDevices(const aIndex: Integer): VkPhysicalDevice;
begin
UpdatePhysicalDevices;
if (aIndex < Low(fPhysicalDevices)) or (aIndex > High(fPhysicalDevices)) then
raise TvkuException.CreateFmt('index (%d) out of range (%d-%d)', [aIndex, Low(fPhysicalDevices), High(fPhysicalDevices)]);
result := fPhysicalDevices[aIndex];
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuInstance.UpdatePhysicalDevices;
var
c: VkUint32;
err: TVkResult;
begin
if (Length(fPhysicalDevices) > 0) then
exit;

err := vkEnumeratePhysicalDevices(fHandle, @c, nil);
if (err < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to get physical device number', err);
SetLength(fPhysicalDevices, c);

err := vkEnumeratePhysicalDevices(fHandle, @c, @fPhysicalDevices[0]);
if (err < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to get physical devices', err);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuInstance.CreateHandle(aCreateInfo: PVkInstanceCreateInfo; aAllocCallbacks: PVkAllocationCallbacks);
var e: TVkResult;
begin
if Assigned(aAllocCallbacks) then begin
new(fAllocCallbacks);
fAllocCallbacks^ := aAllocCallbacks^;
end;
e := vkCreateInstance(aCreateInfo, fAllocCallbacks, @fHandle);
if (e < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to create vulkan instance', e);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuInstance.Create;
begin
inherited Create;
fHandle := nil;
fAllocCallbacks := nil;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuInstance.Create(const aCreateInfo: TVkInstanceCreateInfo);
begin
Create;
CreateHandle(@aCreateInfo, nil);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuInstance.Create(const aCreateInfo: TVkInstanceCreateInfo; const aAllocCallbacks: TVkAllocationCallbacks);
begin
Create;
CreateHandle(@aCreateInfo, @aAllocCallbacks);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TvkuInstance.Destroy;
begin
if Assigned(fHandle) then begin
vkDestroyInstance(fHandle, fAllocCallbacks);
fHandle := nil;
end;
if Assigned(fAllocCallbacks) then begin
Dispose(fAllocCallbacks);
fAllocCallbacks := nil;
end;
inherited Destroy;
end;

end.


+ 316
- 0
projects/utils/uvkuInstanceEx.pas Wyświetl plik

@@ -0,0 +1,316 @@
unit uvkuInstanceEx;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils,
Vulkan, uvkuInstance;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuApplicationInfo = packed record
AppName: String;
AppVersion: VkVersion;
EngineName: String;
EngineVersion: VkVersion;
ApiVersion: VkVersion;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuAllocationHandler = class(TObject)
protected
function AllocateMemory(const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid; virtual;
function ReallocateMemory(const aOriginal: PVkVoid; const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid; virtual;
procedure FreeMemory(const aMemory: PVkVoid); virtual;

procedure InternalAllocationNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
procedure InternalFreeNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuInstanceEx = class(TvkuInstance)
private
fFlags: VkInstanceCreateFlags;
fOwnsAllocHandler: Boolean;
fAllocationHandler: TvkuAllocationHandler;
fApplicationInfo: TvkuApplicationInfo;

fLayers: TStringList;
fExtensions: TStringList;

function GetLayers: TStrings;
function GetExtensions: TStrings;

procedure Initialize;
procedure MakeStringsFromArray(const aArray: array of String; const aStrings: TStrings);
procedure CreateHandle;
public
property Flags: VkInstanceCreateFlags read fFlags;
property OwnsAllocHandler: Boolean read fOwnsAllocHandler;
property AllocationHandler: TvkuAllocationHandler read fAllocationHandler;
property ApplicationInfo: TvkuApplicationInfo read fApplicationInfo;
property Layers: TStrings read GetLayers;
property Extensions: TStrings read GetExtensions;

constructor Create;

constructor Create(
const aFlags: VkInstanceCreateFlags;
const aLayers: array of String;
const aExtensions: array of String);

constructor Create(
const aFlags: VkInstanceCreateFlags;
const aLayers: array of String;
const aExtensions: array of String;
const aAppInfo: TvkuApplicationInfo);

constructor Create(
const aFlags: VkInstanceCreateFlags;
const aLayers: array of String;
const aExtensions: array of String;
const aAppInfo: TvkuApplicationInfo;
const aAllocHandler: TvkuAllocationHandler;
const aOwnsAllocHandler: Boolean);

destructor Destroy; override;
public
class function DefaultApplicationInfo: TvkuApplicationInfo;
class function MakeApplicationInfo(
aAppName: String;
aAppVersion: VkVersion;
aEngineName: String;
aEngineVersion: VkVersion;
aApiVersion: VkVersion = VK_API_VERSION): TvkuApplicationInfo;
end;

implementation


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuAllocationHandler//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuAllocationHandler.AllocateMemory(const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid;
begin
result := System.GetMemory(aSize);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuAllocationHandler.ReallocateMemory(const aOriginal: PVkVoid; const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid;
begin
result := System.ReAllocMemory(aOriginal, aSize);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuAllocationHandler.FreeMemory(const aMemory: PVkVoid);
begin
System.FreeMemory(aMemory);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuAllocationHandler.InternalAllocationNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
begin
// DUMMY
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuAllocationHandler.InternalFreeNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
begin
// DUMMY
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function AllocateMemoryCallback(aUserData: PVkVoid; aSize: VkSize; aAlignment: VkSize; aScope: TVkSystemAllocationScope): PVkVoid; stdcall;
begin
result := TvkuAllocationHandler(aUserData).AllocateMemory(aSize, aAlignment, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ReallocateMemoryCallback(aUserData: PVkVoid; aOriginal: PVkVoid; aSize: VkSize;
aAlignment: VkSize; aScope: TVkSystemAllocationScope): PVkVoid; stdcall;
begin
result := TvkuAllocationHandler(aUserData).ReallocateMemory(aOriginal, aSize, aAlignment, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure FreeMemoryCallback(aUserData: PVkVoid; aMemory: PVkVoid); stdcall;
begin
TvkuAllocationHandler(aUserData).FreeMemory(aMemory);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure InternalAllocationCallback(aUserData: PVkVoid; aSize: VkSize; aType: TVkInternalAllocationType; aScope: TVkSystemAllocationScope); stdcall;
begin
TvkuAllocationHandler(aUserData).InternalAllocationNotification(aSize, aType, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure InternalFreeCallback(aUserData: PVkVoid; aSize: VkSize; aType: TVkInternalAllocationType; aScope: TVkSystemAllocationScope); stdcall;
begin
TvkuAllocationHandler(aUserData).InternalFreeNotification(aSize, aType, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuInstanceEx///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuInstanceEx.GetLayers: TStrings;
begin
result := fLayers;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuInstanceEx.GetExtensions: TStrings;
begin
result := fExtensions;
end;

procedure TvkuInstanceEx.Initialize;
begin
fLayers := TStringList.Create;
fExtensions := TStringList.Create;
fApplicationInfo := DefaultApplicationInfo;
fFlags := 0;
fAllocationHandler := nil;
fOwnsAllocHandler := false;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuInstanceEx.MakeStringsFromArray(const aArray: array of String; const aStrings: TStrings);
var i: Integer;
begin
for i := Low(aArray) to High(aArray) do
aStrings.Add(aArray[i]);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuInstanceEx.CreateHandle;
var
CreateInfo: TVkInstanceCreateInfo;
AppInfo: TVkApplicationInfo;
AllocCallbacks: TVkAllocationCallbacks;
i: Integer;
lay: array of PVkChar;
ext: array of PVkChar;
begin
FillByte(AppInfo, SizeOf(AppInfo), 0);
AppInfo.sType := VK_STRUCTURE_TYPE_APPLICATION_INFO;
AppInfo.pNext := nil;
AppInfo.pApplicationName := PVkChar(fApplicationInfo.AppName);
AppInfo.applicationVersion := fApplicationInfo.AppVersion;
AppInfo.pEngineName := PVkChar(fApplicationInfo.EngineName);
AppInfo.engineVersion := fApplicationInfo.EngineVersion;
AppInfo.apiVersion := fApplicationInfo.ApiVersion;

SetLength(lay, fLayers.Count);
for i := 0 to fLayers.Count-1 do
lay[i] := PVkChar(fLayers[i]);

SetLength(ext, fExtensions.Count);
for i := 0 to fExtensions.Count-1 do
ext[i] := PVkChar(fExtensions[i]);

FillByte(CreateInfo, SizeOf(CreateInfo), 0);
CreateInfo.sType := VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
CreateInfo.pNext := nil;
CreateInfo.flags := fFlags;
CreateInfo.pApplicationInfo := @AppInfo;
CreateInfo.enabledLayerCount := Length(lay);
CreateInfo.ppEnabledLayerNames := @lay[0];
CreateInfo.enabledExtensionCount := Length(ext);
CreateInfo.ppEnabledExtensionNames := @ext[0];

if Assigned(fAllocationHandler) then begin
FillByte(AllocCallbacks, SizeOf(AllocCallbacks), 0);
AllocCallbacks.pUserData := fAllocationHandler;
AllocCallbacks.pfnAllocation := @AllocateMemoryCallback;
AllocCallbacks.pfnReallocation := @ReallocateMemoryCallback;
AllocCallbacks.pfnFree := @FreeMemoryCallback;
AllocCallbacks.pfnInternalAllocation := @InternalAllocationCallback;
AllocCallbacks.pfnInternalFree := @InternalFreeCallback;
inherited CreateHandle(@CreateInfo, @AllocCallbacks);
end else
inherited CreateHandle(@CreateInfo, nil);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuInstanceEx.Create;
begin
Initialize;
CreateHandle;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuInstanceEx.Create(const aFlags: VkInstanceCreateFlags;
const aLayers: array of String; const aExtensions: array of String);
begin
inherited Create;
Initialize;
fFlags := aFlags;
MakeStringsFromArray(aLayers, fLayers);
MakeStringsFromArray(aExtensions, fExtensions);
CreateHandle;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuInstanceEx.Create(const aFlags: VkInstanceCreateFlags;const aLayers: array of String;
const aExtensions: array of String; const aAppInfo: TvkuApplicationInfo);
begin
inherited Create;
Initialize;
fFlags := aFlags;
fApplicationInfo := aAppInfo;
MakeStringsFromArray(aLayers, fLayers);
MakeStringsFromArray(aExtensions, fExtensions);
CreateHandle;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuInstanceEx.Create(const aFlags: VkInstanceCreateFlags; const aLayers: array of String;const aExtensions: array of String;
const aAppInfo: TvkuApplicationInfo; const aAllocHandler: TvkuAllocationHandler; const aOwnsAllocHandler: Boolean);
begin
inherited Create;
Initialize;
fFlags := aFlags;
fApplicationInfo := aAppInfo;
fAllocationHandler := aAllocHandler;
fOwnsAllocHandler := aOwnsAllocHandler;
MakeStringsFromArray(aLayers, fLayers);
MakeStringsFromArray(aExtensions, fExtensions);
CreateHandle;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TvkuInstanceEx.Destroy;
begin
inherited Destroy;
if fOwnsAllocHandler then
FreeAndNil(fAllocationHandler);
FreeAndNil(fLayers);
FreeAndNil(fExtensions);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class function TvkuInstanceEx.DefaultApplicationInfo: TvkuApplicationInfo;
begin
result.AppName := ExtractFileName(ParamStr(0));
result.AppVersion := 0;
result.EngineName := ExtractFileName(ParamStr(0));
result.EngineVersion := 0;
result.ApiVersion := VK_API_VERSION;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class function TvkuInstanceEx.MakeApplicationInfo(aAppName: String; aAppVersion: VkVersion; aEngineName: String; aEngineVersion: VkVersion; aApiVersion: VkVersion): TvkuApplicationInfo;
begin
result := DefaultApplicationInfo;
result.AppName := aAppName;
result.AppVersion := aAppVersion;
result.EngineName := aEngineName;
result.EngineVersion := aEngineVersion;
result.ApiVersion := aApiVersion;
end;

end.


+ 144
- 0
projects/utils/uvkuPhysicalDevice.pas Wyświetl plik

@@ -0,0 +1,144 @@
unit uvkuPhysicalDevice;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils,
Vulkan;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TVkSparseImageFormatPropertiesArr = array of TVkSparseImageFormatProperties;
TvkuPhysicalDevice = class(TObject)
private type
TPropertyFlag = (
pfFeatures,
pfProperties,
pfMemoryProperties
);
TPropertyFlags = set of TPropertyFlag;
private
fHandle: VkPhysicalDevice;
fCached: TPropertyFlags;

fFeatures: TVkPhysicalDeviceFeatures;
fProperties: TVkPhysicalDeviceProperties;
fMemoryProperties: TVkPhysicalDeviceMemoryProperties;
fFormatProperties: array[TVkFormat] of PVkFormatProperties;

function GetFeatures: TVkPhysicalDeviceFeatures;
function GetProperties: TVkPhysicalDeviceProperties;
function GetMemoryProperties: TVkPhysicalDeviceMemoryProperties;
function GetQueueFamilyPropertyCount: Integer;
function GetQueueFamilyProperties(const aIndex: Integer): TVkQueueFamilyProperties;
function GetFormatProperties(const aFormat: TVkFormat): TVkFormatProperties;
public
property Handle: VkPhysicalDevice read fHandle;
property Features: TVkPhysicalDeviceFeatures read GetFeatures;
property Properties: TVkPhysicalDeviceProperties read GetProperties;
property MemoryProperties: TVkPhysicalDeviceMemoryProperties read GetMemoryProperties;

property QueueFamilyPropertyCount: Integer read GetQueueFamilyPropertyCount;
property QueueFamilyProperties[const aIndex: Integer]: TVkQueueFamilyProperties read GetQueueFamilyProperties;

property FormatProperties[const aFormat: TVkFormat]: TVkFormatProperties read GetFormatProperties;

function GetImageFormatProperties(
const aFormat: TVkFormat;
const aImageType: TVkImageType;
const aTiling: TVkImageTiling;
const aUsage: VkImageUsageFlags;
const aFlags: VkImageCreateFlags): TVkImageFormatProperties;

function GetSparseImageFormatProperties(
const aFormat: TVkFormat;
const aImageType: TVkImageType;
const aSamples: TVkSampleCountFlagBits;
const aUsage: VkImageUsageFlags;
const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr;

constructor Create(const aHandle: VkPhysicalDevice);
end;

implementation

uses
uvkuUtils;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuPhysicalDevice/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetFeatures: TVkPhysicalDeviceFeatures;
begin
if not (pfFeatures in fCached) then begin
vkGetPhysicalDeviceFeatures(fHandle, @fFeatures);
Include(fCached, pfFeatures);
end;
result := fFeatures;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetProperties: TVkPhysicalDeviceProperties;
begin
if not (pfProperties in fCached) then begin
vkGetPhysicalDeviceProperties(fHandle, @fProperties);
Include(fCached, pfProperties);
end;
result := fProperties;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetMemoryProperties: TVkPhysicalDeviceMemoryProperties;
begin
if not (pfMemoryProperties in fCached) then begin
vkGetPhysicalDeviceMemoryProperties(fHandle, @fMemoryProperties);
Include(fCached, pfMemoryProperties);
end;
result := fMemoryProperties;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetQueueFamilyPropertyCount: Integer;
begin

end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetQueueFamilyProperties(const aIndex: Integer): TVkQueueFamilyProperties;
begin

end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetFormatProperties(const aFormat: TVkFormat): TVkFormatProperties;
begin

end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetImageFormatProperties(const aFormat: TVkFormat; const aImageType: TVkImageType;
const aTiling: TVkImageTiling; const aUsage: VkImageUsageFlags; const aFlags: VkImageCreateFlags): TVkImageFormatProperties;
begin

end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetSparseImageFormatProperties(const aFormat: TVkFormat; const aImageType: TVkImageType;
const aSamples: TVkSampleCountFlagBits; const aUsage: VkImageUsageFlags; const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr;
begin

end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuPhysicalDevice.Create(const aHandle: VkPhysicalDevice);
begin
if not Assigned(aHandle) then
raise TvkuException.Create('invalid physical device handle');
inherited Create;
fHandle := aHandle;
end;

end.


+ 34
- 0
projects/utils/uvkuUtils.pas Wyświetl plik

@@ -0,0 +1,34 @@
unit uvkuUtils;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils,
Vulkan;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuException = class(Exception);
TvkuErrorException = class(TvkuException)
private
fError: TVkResult;
public
property Error: TVkResult read fError;
constructor Create(const msg: string; const aError: TVkResult);
end;

implementation

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuErrorException//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuErrorException.Create(const msg: string; const aError: TVkResult);
begin
inherited Create(msg);
fError := aError;
end;

end.


Ładowanie…
Anuluj
Zapisz