| @@ -89,12 +89,12 @@ type | |||||
| {%INTERFACE%} | {%INTERFACE%} | ||||
| type | type | ||||
| TVkInstanceCommands = packed record | |||||
| TVkInstanceCommands = class | |||||
| Instance: VkInstance; | Instance: VkInstance; | ||||
| {%INSTANCE_COMMANDS.INTERFACE%} | {%INSTANCE_COMMANDS.INTERFACE%} | ||||
| end; | end; | ||||
| TVkDeviceCommands = packed record | |||||
| TVkDeviceCommands = class | |||||
| Device: VkDevice; | Device: VkDevice; | ||||
| {%DEVICE_COMMANDS.INTERFACE%} | {%DEVICE_COMMANDS.INTERFACE%} | ||||
| end; | end; | ||||
| @@ -111,12 +111,15 @@ function vkGetVersionMinor(const aVersion: VkVersion): Integer; inline; | |||||
| function vkGetVersionPatch(const aVersion: VkVersion): Integer; inline; | function vkGetVersionPatch(const aVersion: VkVersion): Integer; inline; | ||||
| function InitializeVulkan(const aLibName: String = VULKAN_LIBNAME): Boolean; | function InitializeVulkan(const aLibName: String = VULKAN_LIBNAME): Boolean; | ||||
| function LoadInstanceCommands(const aInstance: VkInstance; out aCommands: TVkInstanceCommands): Boolean; | |||||
| function LoadDeviceCommands(const aInstance: VkInstance; const aDevice: VkDevice; out aCommands: TVkDeviceCommands): Boolean; | |||||
| function LoadInstanceCommands(const aInstance: VkInstance): TVkInstanceCommands; | |||||
| function LoadDeviceCommands(const aInstance: VkInstance; const aDevice: VkDevice): TVkDeviceCommands; | |||||
| procedure FinalizeVulkan; | procedure FinalizeVulkan; | ||||
| implementation | implementation | ||||
| uses | |||||
| SysUtils; | |||||
| type | type | ||||
| {$IF DEFINED(VK_WIN)} | {$IF DEFINED(VK_WIN)} | ||||
| TvkLibHandle = TLibHandle; | TvkLibHandle = TLibHandle; | ||||
| @@ -210,46 +213,47 @@ begin | |||||
| result := success; | result := success; | ||||
| end; | end; | ||||
| function LoadInstanceCommands(const aInstance: VkInstance; out aCommands: TVkInstanceCommands): Boolean; | |||||
| var | |||||
| success: Boolean; | |||||
| function LoadInstanceCommands(const aInstance: VkInstance): TVkInstanceCommands; | |||||
| function GetProcAddress(const aName: String): TvkVoidFunction; | function GetProcAddress(const aName: String): TvkVoidFunction; | ||||
| begin | begin | ||||
| result := vkGetInstanceProcAddr(aInstance, PVkChar(aName)); | result := vkGetInstanceProcAddr(aInstance, PVkChar(aName)); | ||||
| if not Assigned(result) then | |||||
| success := false; | |||||
| end; | end; | ||||
| begin | begin | ||||
| FillByte(aCommands, SizeOf(aCommands), 0); | |||||
| success := true; | |||||
| with aCommands do begin | |||||
| {%INSTANCE_COMMANDS.IMPLEMENTATION%} | |||||
| result := TVkInstanceCommands.Create; | |||||
| try | |||||
| result.Instance := aInstance; | |||||
| with result do begin | |||||
| {%INSTANCE_COMMANDS.IMPLEMENTATION%} | |||||
| end; | |||||
| except | |||||
| FreeAndNil(result); | |||||
| raise; | |||||
| end; | end; | ||||
| result := success; | |||||
| end; | end; | ||||
| function LoadDeviceCommands(const aInstance: VkInstance; const aDevice: VkDevice; out aCommands: TVkDeviceCommands): Boolean; | |||||
| function LoadDeviceCommands(const aInstance: VkInstance; const aDevice: VkDevice): TVkDeviceCommands; | |||||
| var | var | ||||
| vkGetDeviceProcAddr: TvkGetDeviceProcAddr; | vkGetDeviceProcAddr: TvkGetDeviceProcAddr; | ||||
| success: Boolean; | |||||
| function GetProcAddress(const aName: String): TvkVoidFunction; | function GetProcAddress(const aName: String): TvkVoidFunction; | ||||
| begin | begin | ||||
| result := vkGetDeviceProcAddr(aDevice, PVkChar(aName)); | result := vkGetDeviceProcAddr(aDevice, PVkChar(aName)); | ||||
| if not Assigned(result) then | |||||
| success := false; | |||||
| end; | end; | ||||
| begin | begin | ||||
| FillByte(aCommands, SizeOf(aCommands), 0); | |||||
| vkGetDeviceProcAddr := TvkGetDeviceProcAddr(vkGetInstanceProcAddr(aInstance, 'vkGetDeviceProcAddr')); | vkGetDeviceProcAddr := TvkGetDeviceProcAddr(vkGetInstanceProcAddr(aInstance, 'vkGetDeviceProcAddr')); | ||||
| success := true; | |||||
| with aCommands do begin | |||||
| {%DEVICE_COMMANDS.IMPLEMENTATION%} | |||||
| result := TVkDeviceCommands.Create; | |||||
| try | |||||
| result.Device := aDevice; | |||||
| with result do begin | |||||
| {%DEVICE_COMMANDS.IMPLEMENTATION%} | |||||
| end; | |||||
| except | |||||
| FreeAndNil(result); | |||||
| raise; | |||||
| end; | end; | ||||
| result := success; | |||||
| end; | end; | ||||
| procedure FinalizeVulkan; | procedure FinalizeVulkan; | ||||
| @@ -4227,7 +4227,7 @@ var | |||||
| vkEnumerateInstanceLayerProperties: TvkEnumerateInstanceLayerProperties; | vkEnumerateInstanceLayerProperties: TvkEnumerateInstanceLayerProperties; | ||||
| type | type | ||||
| TVkInstanceCommands = packed record | |||||
| TVkInstanceCommands = class | |||||
| Instance: VkInstance; | Instance: VkInstance; | ||||
| { ========================================== VK_VERSION_1_0 ========================================== } | { ========================================== VK_VERSION_1_0 ========================================== } | ||||
| @@ -4303,7 +4303,7 @@ type | |||||
| end; | end; | ||||
| TVkDeviceCommands = packed record | |||||
| TVkDeviceCommands = class | |||||
| Device: VkDevice; | Device: VkDevice; | ||||
| { ========================================== VK_VERSION_1_0 ========================================== } | { ========================================== VK_VERSION_1_0 ========================================== } | ||||
| @@ -4452,12 +4452,15 @@ function vkGetVersionMinor(const aVersion: VkVersion): Integer; inline; | |||||
| function vkGetVersionPatch(const aVersion: VkVersion): Integer; inline; | function vkGetVersionPatch(const aVersion: VkVersion): Integer; inline; | ||||
| function InitializeVulkan(const aLibName: String = VULKAN_LIBNAME): Boolean; | function InitializeVulkan(const aLibName: String = VULKAN_LIBNAME): Boolean; | ||||
| function LoadInstanceCommands(const aInstance: VkInstance; out aCommands: TVkInstanceCommands): Boolean; | |||||
| function LoadDeviceCommands(const aInstance: VkInstance; const aDevice: VkDevice; out aCommands: TVkDeviceCommands): Boolean; | |||||
| function LoadInstanceCommands(const aInstance: VkInstance): TVkInstanceCommands; | |||||
| function LoadDeviceCommands(const aInstance: VkInstance; const aDevice: VkDevice): TVkDeviceCommands; | |||||
| procedure FinalizeVulkan; | procedure FinalizeVulkan; | ||||
| implementation | implementation | ||||
| uses | |||||
| SysUtils; | |||||
| type | type | ||||
| {$IF DEFINED(VK_WIN)} | {$IF DEFINED(VK_WIN)} | ||||
| TvkLibHandle = TLibHandle; | TvkLibHandle = TLibHandle; | ||||
| @@ -4554,249 +4557,250 @@ begin | |||||
| result := success; | result := success; | ||||
| end; | end; | ||||
| function LoadInstanceCommands(const aInstance: VkInstance; out aCommands: TVkInstanceCommands): Boolean; | |||||
| var | |||||
| success: Boolean; | |||||
| function LoadInstanceCommands(const aInstance: VkInstance): TVkInstanceCommands; | |||||
| function GetProcAddress(const aName: String): TvkVoidFunction; | function GetProcAddress(const aName: String): TvkVoidFunction; | ||||
| begin | begin | ||||
| result := vkGetInstanceProcAddr(aInstance, PVkChar(aName)); | result := vkGetInstanceProcAddr(aInstance, PVkChar(aName)); | ||||
| if not Assigned(result) then | |||||
| success := false; | |||||
| end; | end; | ||||
| begin | begin | ||||
| FillByte(aCommands, SizeOf(aCommands), 0); | |||||
| success := true; | |||||
| with aCommands do begin | |||||
| { ========================================== VK_VERSION_1_0 ========================================== } | |||||
| vkDestroyInstance := TvkDestroyInstance (GetProcAddress('vkDestroyInstance')); | |||||
| vkEnumeratePhysicalDevices := TvkEnumeratePhysicalDevices (GetProcAddress('vkEnumeratePhysicalDevices')); | |||||
| vkGetPhysicalDeviceFeatures := TvkGetPhysicalDeviceFeatures (GetProcAddress('vkGetPhysicalDeviceFeatures')); | |||||
| vkGetPhysicalDeviceFormatProperties := TvkGetPhysicalDeviceFormatProperties (GetProcAddress('vkGetPhysicalDeviceFormatProperties')); | |||||
| vkGetPhysicalDeviceImageFormatProperties := TvkGetPhysicalDeviceImageFormatProperties (GetProcAddress('vkGetPhysicalDeviceImageFormatProperties')); | |||||
| vkGetPhysicalDeviceProperties := TvkGetPhysicalDeviceProperties (GetProcAddress('vkGetPhysicalDeviceProperties')); | |||||
| vkGetPhysicalDeviceQueueFamilyProperties := TvkGetPhysicalDeviceQueueFamilyProperties (GetProcAddress('vkGetPhysicalDeviceQueueFamilyProperties')); | |||||
| vkGetPhysicalDeviceMemoryProperties := TvkGetPhysicalDeviceMemoryProperties (GetProcAddress('vkGetPhysicalDeviceMemoryProperties')); | |||||
| vkGetDeviceProcAddr := TvkGetDeviceProcAddr (GetProcAddress('vkGetDeviceProcAddr')); | |||||
| vkCreateDevice := TvkCreateDevice (GetProcAddress('vkCreateDevice')); | |||||
| vkEnumerateDeviceExtensionProperties := TvkEnumerateDeviceExtensionProperties (GetProcAddress('vkEnumerateDeviceExtensionProperties')); | |||||
| vkEnumerateDeviceLayerProperties := TvkEnumerateDeviceLayerProperties (GetProcAddress('vkEnumerateDeviceLayerProperties')); | |||||
| vkGetPhysicalDeviceSparseImageFormatProperties := TvkGetPhysicalDeviceSparseImageFormatProperties (GetProcAddress('vkGetPhysicalDeviceSparseImageFormatProperties')); | |||||
| { ========================================== VK_KHR_surface ========================================== } | |||||
| vkDestroySurfaceKHR := TvkDestroySurfaceKHR (GetProcAddress('vkDestroySurfaceKHR')); | |||||
| vkGetPhysicalDeviceSurfaceSupportKHR := TvkGetPhysicalDeviceSurfaceSupportKHR (GetProcAddress('vkGetPhysicalDeviceSurfaceSupportKHR')); | |||||
| vkGetPhysicalDeviceSurfaceCapabilitiesKHR := TvkGetPhysicalDeviceSurfaceCapabilitiesKHR (GetProcAddress('vkGetPhysicalDeviceSurfaceCapabilitiesKHR')); | |||||
| vkGetPhysicalDeviceSurfaceFormatsKHR := TvkGetPhysicalDeviceSurfaceFormatsKHR (GetProcAddress('vkGetPhysicalDeviceSurfaceFormatsKHR')); | |||||
| vkGetPhysicalDeviceSurfacePresentModesKHR := TvkGetPhysicalDeviceSurfacePresentModesKHR (GetProcAddress('vkGetPhysicalDeviceSurfacePresentModesKHR')); | |||||
| { ========================================== VK_KHR_display ========================================== } | |||||
| vkGetPhysicalDeviceDisplayPropertiesKHR := TvkGetPhysicalDeviceDisplayPropertiesKHR (GetProcAddress('vkGetPhysicalDeviceDisplayPropertiesKHR')); | |||||
| vkGetPhysicalDeviceDisplayPlanePropertiesKHR := TvkGetPhysicalDeviceDisplayPlanePropertiesKHR (GetProcAddress('vkGetPhysicalDeviceDisplayPlanePropertiesKHR')); | |||||
| vkGetDisplayPlaneSupportedDisplaysKHR := TvkGetDisplayPlaneSupportedDisplaysKHR (GetProcAddress('vkGetDisplayPlaneSupportedDisplaysKHR')); | |||||
| vkGetDisplayModePropertiesKHR := TvkGetDisplayModePropertiesKHR (GetProcAddress('vkGetDisplayModePropertiesKHR')); | |||||
| vkCreateDisplayModeKHR := TvkCreateDisplayModeKHR (GetProcAddress('vkCreateDisplayModeKHR')); | |||||
| vkGetDisplayPlaneCapabilitiesKHR := TvkGetDisplayPlaneCapabilitiesKHR (GetProcAddress('vkGetDisplayPlaneCapabilitiesKHR')); | |||||
| vkCreateDisplayPlaneSurfaceKHR := TvkCreateDisplayPlaneSurfaceKHR (GetProcAddress('vkCreateDisplayPlaneSurfaceKHR')); | |||||
| { ======================================= VK_KHR_xlib_surface ======================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_XLIB_KHR} | |||||
| vkCreateXlibSurfaceKHR := TvkCreateXlibSurfaceKHR (GetProcAddress('vkCreateXlibSurfaceKHR')); | |||||
| vkGetPhysicalDeviceXlibPresentationSupportKHR := TvkGetPhysicalDeviceXlibPresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceXlibPresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ======================================== VK_KHR_xcb_surface ======================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_XCB_KHR} | |||||
| vkCreateXcbSurfaceKHR := TvkCreateXcbSurfaceKHR (GetProcAddress('vkCreateXcbSurfaceKHR')); | |||||
| vkGetPhysicalDeviceXcbPresentationSupportKHR := TvkGetPhysicalDeviceXcbPresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceXcbPresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ====================================== VK_KHR_wayland_surface ====================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_WAYLAND_KHR} | |||||
| vkCreateWaylandSurfaceKHR := TvkCreateWaylandSurfaceKHR (GetProcAddress('vkCreateWaylandSurfaceKHR')); | |||||
| vkGetPhysicalDeviceWaylandPresentationSupportKHR := TvkGetPhysicalDeviceWaylandPresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceWaylandPresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ======================================== VK_KHR_mir_surface ======================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_MIR_KHR} | |||||
| vkCreateMirSurfaceKHR := TvkCreateMirSurfaceKHR (GetProcAddress('vkCreateMirSurfaceKHR')); | |||||
| vkGetPhysicalDeviceMirPresentationSupportKHR := TvkGetPhysicalDeviceMirPresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceMirPresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ====================================== VK_KHR_android_surface ====================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_ANDROID_KHR} | |||||
| vkCreateAndroidSurfaceKHR := TvkCreateAndroidSurfaceKHR (GetProcAddress('vkCreateAndroidSurfaceKHR')); | |||||
| {$ENDIF} | |||||
| { ======================================= VK_KHR_win32_surface ======================================= } | |||||
| {$IFDEF VK_USE_PLATFORM_WIN32_KHR} | |||||
| vkCreateWin32SurfaceKHR := TvkCreateWin32SurfaceKHR (GetProcAddress('vkCreateWin32SurfaceKHR')); | |||||
| vkGetPhysicalDeviceWin32PresentationSupportKHR := TvkGetPhysicalDeviceWin32PresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceWin32PresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ======================================= VK_EXT_debug_report ======================================== } | |||||
| vkCreateDebugReportCallbackEXT := TvkCreateDebugReportCallbackEXT (GetProcAddress('vkCreateDebugReportCallbackEXT')); | |||||
| vkDestroyDebugReportCallbackEXT := TvkDestroyDebugReportCallbackEXT (GetProcAddress('vkDestroyDebugReportCallbackEXT')); | |||||
| vkDebugReportMessageEXT := TvkDebugReportMessageEXT (GetProcAddress('vkDebugReportMessageEXT')); | |||||
| result := TVkInstanceCommands.Create; | |||||
| try | |||||
| result.Instance := aInstance; | |||||
| with result do begin | |||||
| { ========================================== VK_VERSION_1_0 ========================================== } | |||||
| vkDestroyInstance := TvkDestroyInstance (GetProcAddress('vkDestroyInstance')); | |||||
| vkEnumeratePhysicalDevices := TvkEnumeratePhysicalDevices (GetProcAddress('vkEnumeratePhysicalDevices')); | |||||
| vkGetPhysicalDeviceFeatures := TvkGetPhysicalDeviceFeatures (GetProcAddress('vkGetPhysicalDeviceFeatures')); | |||||
| vkGetPhysicalDeviceFormatProperties := TvkGetPhysicalDeviceFormatProperties (GetProcAddress('vkGetPhysicalDeviceFormatProperties')); | |||||
| vkGetPhysicalDeviceImageFormatProperties := TvkGetPhysicalDeviceImageFormatProperties (GetProcAddress('vkGetPhysicalDeviceImageFormatProperties')); | |||||
| vkGetPhysicalDeviceProperties := TvkGetPhysicalDeviceProperties (GetProcAddress('vkGetPhysicalDeviceProperties')); | |||||
| vkGetPhysicalDeviceQueueFamilyProperties := TvkGetPhysicalDeviceQueueFamilyProperties (GetProcAddress('vkGetPhysicalDeviceQueueFamilyProperties')); | |||||
| vkGetPhysicalDeviceMemoryProperties := TvkGetPhysicalDeviceMemoryProperties (GetProcAddress('vkGetPhysicalDeviceMemoryProperties')); | |||||
| vkGetDeviceProcAddr := TvkGetDeviceProcAddr (GetProcAddress('vkGetDeviceProcAddr')); | |||||
| vkCreateDevice := TvkCreateDevice (GetProcAddress('vkCreateDevice')); | |||||
| vkEnumerateDeviceExtensionProperties := TvkEnumerateDeviceExtensionProperties (GetProcAddress('vkEnumerateDeviceExtensionProperties')); | |||||
| vkEnumerateDeviceLayerProperties := TvkEnumerateDeviceLayerProperties (GetProcAddress('vkEnumerateDeviceLayerProperties')); | |||||
| vkGetPhysicalDeviceSparseImageFormatProperties := TvkGetPhysicalDeviceSparseImageFormatProperties (GetProcAddress('vkGetPhysicalDeviceSparseImageFormatProperties')); | |||||
| { ========================================== VK_KHR_surface ========================================== } | |||||
| vkDestroySurfaceKHR := TvkDestroySurfaceKHR (GetProcAddress('vkDestroySurfaceKHR')); | |||||
| vkGetPhysicalDeviceSurfaceSupportKHR := TvkGetPhysicalDeviceSurfaceSupportKHR (GetProcAddress('vkGetPhysicalDeviceSurfaceSupportKHR')); | |||||
| vkGetPhysicalDeviceSurfaceCapabilitiesKHR := TvkGetPhysicalDeviceSurfaceCapabilitiesKHR (GetProcAddress('vkGetPhysicalDeviceSurfaceCapabilitiesKHR')); | |||||
| vkGetPhysicalDeviceSurfaceFormatsKHR := TvkGetPhysicalDeviceSurfaceFormatsKHR (GetProcAddress('vkGetPhysicalDeviceSurfaceFormatsKHR')); | |||||
| vkGetPhysicalDeviceSurfacePresentModesKHR := TvkGetPhysicalDeviceSurfacePresentModesKHR (GetProcAddress('vkGetPhysicalDeviceSurfacePresentModesKHR')); | |||||
| { ========================================== VK_KHR_display ========================================== } | |||||
| vkGetPhysicalDeviceDisplayPropertiesKHR := TvkGetPhysicalDeviceDisplayPropertiesKHR (GetProcAddress('vkGetPhysicalDeviceDisplayPropertiesKHR')); | |||||
| vkGetPhysicalDeviceDisplayPlanePropertiesKHR := TvkGetPhysicalDeviceDisplayPlanePropertiesKHR (GetProcAddress('vkGetPhysicalDeviceDisplayPlanePropertiesKHR')); | |||||
| vkGetDisplayPlaneSupportedDisplaysKHR := TvkGetDisplayPlaneSupportedDisplaysKHR (GetProcAddress('vkGetDisplayPlaneSupportedDisplaysKHR')); | |||||
| vkGetDisplayModePropertiesKHR := TvkGetDisplayModePropertiesKHR (GetProcAddress('vkGetDisplayModePropertiesKHR')); | |||||
| vkCreateDisplayModeKHR := TvkCreateDisplayModeKHR (GetProcAddress('vkCreateDisplayModeKHR')); | |||||
| vkGetDisplayPlaneCapabilitiesKHR := TvkGetDisplayPlaneCapabilitiesKHR (GetProcAddress('vkGetDisplayPlaneCapabilitiesKHR')); | |||||
| vkCreateDisplayPlaneSurfaceKHR := TvkCreateDisplayPlaneSurfaceKHR (GetProcAddress('vkCreateDisplayPlaneSurfaceKHR')); | |||||
| { ======================================= VK_KHR_xlib_surface ======================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_XLIB_KHR} | |||||
| vkCreateXlibSurfaceKHR := TvkCreateXlibSurfaceKHR (GetProcAddress('vkCreateXlibSurfaceKHR')); | |||||
| vkGetPhysicalDeviceXlibPresentationSupportKHR := TvkGetPhysicalDeviceXlibPresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceXlibPresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ======================================== VK_KHR_xcb_surface ======================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_XCB_KHR} | |||||
| vkCreateXcbSurfaceKHR := TvkCreateXcbSurfaceKHR (GetProcAddress('vkCreateXcbSurfaceKHR')); | |||||
| vkGetPhysicalDeviceXcbPresentationSupportKHR := TvkGetPhysicalDeviceXcbPresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceXcbPresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ====================================== VK_KHR_wayland_surface ====================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_WAYLAND_KHR} | |||||
| vkCreateWaylandSurfaceKHR := TvkCreateWaylandSurfaceKHR (GetProcAddress('vkCreateWaylandSurfaceKHR')); | |||||
| vkGetPhysicalDeviceWaylandPresentationSupportKHR := TvkGetPhysicalDeviceWaylandPresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceWaylandPresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ======================================== VK_KHR_mir_surface ======================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_MIR_KHR} | |||||
| vkCreateMirSurfaceKHR := TvkCreateMirSurfaceKHR (GetProcAddress('vkCreateMirSurfaceKHR')); | |||||
| vkGetPhysicalDeviceMirPresentationSupportKHR := TvkGetPhysicalDeviceMirPresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceMirPresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ====================================== VK_KHR_android_surface ====================================== } | |||||
| {$IFDEF VK_USE_PLATFORM_ANDROID_KHR} | |||||
| vkCreateAndroidSurfaceKHR := TvkCreateAndroidSurfaceKHR (GetProcAddress('vkCreateAndroidSurfaceKHR')); | |||||
| {$ENDIF} | |||||
| { ======================================= VK_KHR_win32_surface ======================================= } | |||||
| {$IFDEF VK_USE_PLATFORM_WIN32_KHR} | |||||
| vkCreateWin32SurfaceKHR := TvkCreateWin32SurfaceKHR (GetProcAddress('vkCreateWin32SurfaceKHR')); | |||||
| vkGetPhysicalDeviceWin32PresentationSupportKHR := TvkGetPhysicalDeviceWin32PresentationSupportKHR (GetProcAddress('vkGetPhysicalDeviceWin32PresentationSupportKHR')); | |||||
| {$ENDIF} | |||||
| { ======================================= VK_EXT_debug_report ======================================== } | |||||
| vkCreateDebugReportCallbackEXT := TvkCreateDebugReportCallbackEXT (GetProcAddress('vkCreateDebugReportCallbackEXT')); | |||||
| vkDestroyDebugReportCallbackEXT := TvkDestroyDebugReportCallbackEXT (GetProcAddress('vkDestroyDebugReportCallbackEXT')); | |||||
| vkDebugReportMessageEXT := TvkDebugReportMessageEXT (GetProcAddress('vkDebugReportMessageEXT')); | |||||
| end; | |||||
| except | |||||
| FreeAndNil(result); | |||||
| raise; | |||||
| end; | end; | ||||
| result := success; | |||||
| end; | end; | ||||
| function LoadDeviceCommands(const aInstance: VkInstance; const aDevice: VkDevice; out aCommands: TVkDeviceCommands): Boolean; | |||||
| function LoadDeviceCommands(const aInstance: VkInstance; const aDevice: VkDevice): TVkDeviceCommands; | |||||
| var | var | ||||
| vkGetDeviceProcAddr: TvkGetDeviceProcAddr; | vkGetDeviceProcAddr: TvkGetDeviceProcAddr; | ||||
| success: Boolean; | |||||
| function GetProcAddress(const aName: String): TvkVoidFunction; | function GetProcAddress(const aName: String): TvkVoidFunction; | ||||
| begin | begin | ||||
| result := vkGetDeviceProcAddr(aDevice, PVkChar(aName)); | result := vkGetDeviceProcAddr(aDevice, PVkChar(aName)); | ||||
| if not Assigned(result) then | |||||
| success := false; | |||||
| end; | end; | ||||
| begin | begin | ||||
| FillByte(aCommands, SizeOf(aCommands), 0); | |||||
| vkGetDeviceProcAddr := TvkGetDeviceProcAddr(vkGetInstanceProcAddr(aInstance, 'vkGetDeviceProcAddr')); | vkGetDeviceProcAddr := TvkGetDeviceProcAddr(vkGetInstanceProcAddr(aInstance, 'vkGetDeviceProcAddr')); | ||||
| success := true; | |||||
| with aCommands do begin | |||||
| { ========================================== VK_VERSION_1_0 ========================================== } | |||||
| vkDestroyDevice := TvkDestroyDevice (GetProcAddress('vkDestroyDevice')); | |||||
| vkGetDeviceQueue := TvkGetDeviceQueue (GetProcAddress('vkGetDeviceQueue')); | |||||
| vkQueueSubmit := TvkQueueSubmit (GetProcAddress('vkQueueSubmit')); | |||||
| vkQueueWaitIdle := TvkQueueWaitIdle (GetProcAddress('vkQueueWaitIdle')); | |||||
| vkDeviceWaitIdle := TvkDeviceWaitIdle (GetProcAddress('vkDeviceWaitIdle')); | |||||
| vkAllocateMemory := TvkAllocateMemory (GetProcAddress('vkAllocateMemory')); | |||||
| vkFreeMemory := TvkFreeMemory (GetProcAddress('vkFreeMemory')); | |||||
| vkMapMemory := TvkMapMemory (GetProcAddress('vkMapMemory')); | |||||
| vkUnmapMemory := TvkUnmapMemory (GetProcAddress('vkUnmapMemory')); | |||||
| vkFlushMappedMemoryRanges := TvkFlushMappedMemoryRanges (GetProcAddress('vkFlushMappedMemoryRanges')); | |||||
| vkInvalidateMappedMemoryRanges := TvkInvalidateMappedMemoryRanges (GetProcAddress('vkInvalidateMappedMemoryRanges')); | |||||
| vkGetDeviceMemoryCommitment := TvkGetDeviceMemoryCommitment (GetProcAddress('vkGetDeviceMemoryCommitment')); | |||||
| vkBindBufferMemory := TvkBindBufferMemory (GetProcAddress('vkBindBufferMemory')); | |||||
| vkBindImageMemory := TvkBindImageMemory (GetProcAddress('vkBindImageMemory')); | |||||
| vkGetBufferMemoryRequirements := TvkGetBufferMemoryRequirements (GetProcAddress('vkGetBufferMemoryRequirements')); | |||||
| vkGetImageMemoryRequirements := TvkGetImageMemoryRequirements (GetProcAddress('vkGetImageMemoryRequirements')); | |||||
| vkGetImageSparseMemoryRequirements := TvkGetImageSparseMemoryRequirements (GetProcAddress('vkGetImageSparseMemoryRequirements')); | |||||
| vkQueueBindSparse := TvkQueueBindSparse (GetProcAddress('vkQueueBindSparse')); | |||||
| vkCreateFence := TvkCreateFence (GetProcAddress('vkCreateFence')); | |||||
| vkDestroyFence := TvkDestroyFence (GetProcAddress('vkDestroyFence')); | |||||
| vkResetFences := TvkResetFences (GetProcAddress('vkResetFences')); | |||||
| vkGetFenceStatus := TvkGetFenceStatus (GetProcAddress('vkGetFenceStatus')); | |||||
| vkWaitForFences := TvkWaitForFences (GetProcAddress('vkWaitForFences')); | |||||
| vkCreateSemaphore := TvkCreateSemaphore (GetProcAddress('vkCreateSemaphore')); | |||||
| vkDestroySemaphore := TvkDestroySemaphore (GetProcAddress('vkDestroySemaphore')); | |||||
| vkCreateEvent := TvkCreateEvent (GetProcAddress('vkCreateEvent')); | |||||
| vkDestroyEvent := TvkDestroyEvent (GetProcAddress('vkDestroyEvent')); | |||||
| vkGetEventStatus := TvkGetEventStatus (GetProcAddress('vkGetEventStatus')); | |||||
| vkSetEvent := TvkSetEvent (GetProcAddress('vkSetEvent')); | |||||
| vkResetEvent := TvkResetEvent (GetProcAddress('vkResetEvent')); | |||||
| vkCreateQueryPool := TvkCreateQueryPool (GetProcAddress('vkCreateQueryPool')); | |||||
| vkDestroyQueryPool := TvkDestroyQueryPool (GetProcAddress('vkDestroyQueryPool')); | |||||
| vkGetQueryPoolResults := TvkGetQueryPoolResults (GetProcAddress('vkGetQueryPoolResults')); | |||||
| vkCreateBuffer := TvkCreateBuffer (GetProcAddress('vkCreateBuffer')); | |||||
| vkDestroyBuffer := TvkDestroyBuffer (GetProcAddress('vkDestroyBuffer')); | |||||
| vkCreateBufferView := TvkCreateBufferView (GetProcAddress('vkCreateBufferView')); | |||||
| vkDestroyBufferView := TvkDestroyBufferView (GetProcAddress('vkDestroyBufferView')); | |||||
| vkCreateImage := TvkCreateImage (GetProcAddress('vkCreateImage')); | |||||
| vkDestroyImage := TvkDestroyImage (GetProcAddress('vkDestroyImage')); | |||||
| vkGetImageSubresourceLayout := TvkGetImageSubresourceLayout (GetProcAddress('vkGetImageSubresourceLayout')); | |||||
| vkCreateImageView := TvkCreateImageView (GetProcAddress('vkCreateImageView')); | |||||
| vkDestroyImageView := TvkDestroyImageView (GetProcAddress('vkDestroyImageView')); | |||||
| vkCreateShaderModule := TvkCreateShaderModule (GetProcAddress('vkCreateShaderModule')); | |||||
| vkDestroyShaderModule := TvkDestroyShaderModule (GetProcAddress('vkDestroyShaderModule')); | |||||
| vkCreatePipelineCache := TvkCreatePipelineCache (GetProcAddress('vkCreatePipelineCache')); | |||||
| vkDestroyPipelineCache := TvkDestroyPipelineCache (GetProcAddress('vkDestroyPipelineCache')); | |||||
| vkGetPipelineCacheData := TvkGetPipelineCacheData (GetProcAddress('vkGetPipelineCacheData')); | |||||
| vkMergePipelineCaches := TvkMergePipelineCaches (GetProcAddress('vkMergePipelineCaches')); | |||||
| vkCreateGraphicsPipelines := TvkCreateGraphicsPipelines (GetProcAddress('vkCreateGraphicsPipelines')); | |||||
| vkCreateComputePipelines := TvkCreateComputePipelines (GetProcAddress('vkCreateComputePipelines')); | |||||
| vkDestroyPipeline := TvkDestroyPipeline (GetProcAddress('vkDestroyPipeline')); | |||||
| vkCreatePipelineLayout := TvkCreatePipelineLayout (GetProcAddress('vkCreatePipelineLayout')); | |||||
| vkDestroyPipelineLayout := TvkDestroyPipelineLayout (GetProcAddress('vkDestroyPipelineLayout')); | |||||
| vkCreateSampler := TvkCreateSampler (GetProcAddress('vkCreateSampler')); | |||||
| vkDestroySampler := TvkDestroySampler (GetProcAddress('vkDestroySampler')); | |||||
| vkCreateDescriptorSetLayout := TvkCreateDescriptorSetLayout (GetProcAddress('vkCreateDescriptorSetLayout')); | |||||
| vkDestroyDescriptorSetLayout := TvkDestroyDescriptorSetLayout (GetProcAddress('vkDestroyDescriptorSetLayout')); | |||||
| vkCreateDescriptorPool := TvkCreateDescriptorPool (GetProcAddress('vkCreateDescriptorPool')); | |||||
| vkDestroyDescriptorPool := TvkDestroyDescriptorPool (GetProcAddress('vkDestroyDescriptorPool')); | |||||
| vkResetDescriptorPool := TvkResetDescriptorPool (GetProcAddress('vkResetDescriptorPool')); | |||||
| vkAllocateDescriptorSets := TvkAllocateDescriptorSets (GetProcAddress('vkAllocateDescriptorSets')); | |||||
| vkFreeDescriptorSets := TvkFreeDescriptorSets (GetProcAddress('vkFreeDescriptorSets')); | |||||
| vkUpdateDescriptorSets := TvkUpdateDescriptorSets (GetProcAddress('vkUpdateDescriptorSets')); | |||||
| vkCreateFramebuffer := TvkCreateFramebuffer (GetProcAddress('vkCreateFramebuffer')); | |||||
| vkDestroyFramebuffer := TvkDestroyFramebuffer (GetProcAddress('vkDestroyFramebuffer')); | |||||
| vkCreateRenderPass := TvkCreateRenderPass (GetProcAddress('vkCreateRenderPass')); | |||||
| vkDestroyRenderPass := TvkDestroyRenderPass (GetProcAddress('vkDestroyRenderPass')); | |||||
| vkGetRenderAreaGranularity := TvkGetRenderAreaGranularity (GetProcAddress('vkGetRenderAreaGranularity')); | |||||
| vkCreateCommandPool := TvkCreateCommandPool (GetProcAddress('vkCreateCommandPool')); | |||||
| vkDestroyCommandPool := TvkDestroyCommandPool (GetProcAddress('vkDestroyCommandPool')); | |||||
| vkResetCommandPool := TvkResetCommandPool (GetProcAddress('vkResetCommandPool')); | |||||
| vkAllocateCommandBuffers := TvkAllocateCommandBuffers (GetProcAddress('vkAllocateCommandBuffers')); | |||||
| vkFreeCommandBuffers := TvkFreeCommandBuffers (GetProcAddress('vkFreeCommandBuffers')); | |||||
| vkBeginCommandBuffer := TvkBeginCommandBuffer (GetProcAddress('vkBeginCommandBuffer')); | |||||
| vkEndCommandBuffer := TvkEndCommandBuffer (GetProcAddress('vkEndCommandBuffer')); | |||||
| vkResetCommandBuffer := TvkResetCommandBuffer (GetProcAddress('vkResetCommandBuffer')); | |||||
| vkCmdBindPipeline := TvkCmdBindPipeline (GetProcAddress('vkCmdBindPipeline')); | |||||
| vkCmdSetViewport := TvkCmdSetViewport (GetProcAddress('vkCmdSetViewport')); | |||||
| vkCmdSetScissor := TvkCmdSetScissor (GetProcAddress('vkCmdSetScissor')); | |||||
| vkCmdSetLineWidth := TvkCmdSetLineWidth (GetProcAddress('vkCmdSetLineWidth')); | |||||
| vkCmdSetDepthBias := TvkCmdSetDepthBias (GetProcAddress('vkCmdSetDepthBias')); | |||||
| vkCmdSetBlendConstants := TvkCmdSetBlendConstants (GetProcAddress('vkCmdSetBlendConstants')); | |||||
| vkCmdSetDepthBounds := TvkCmdSetDepthBounds (GetProcAddress('vkCmdSetDepthBounds')); | |||||
| vkCmdSetStencilCompareMask := TvkCmdSetStencilCompareMask (GetProcAddress('vkCmdSetStencilCompareMask')); | |||||
| vkCmdSetStencilWriteMask := TvkCmdSetStencilWriteMask (GetProcAddress('vkCmdSetStencilWriteMask')); | |||||
| vkCmdSetStencilReference := TvkCmdSetStencilReference (GetProcAddress('vkCmdSetStencilReference')); | |||||
| vkCmdBindDescriptorSets := TvkCmdBindDescriptorSets (GetProcAddress('vkCmdBindDescriptorSets')); | |||||
| vkCmdBindIndexBuffer := TvkCmdBindIndexBuffer (GetProcAddress('vkCmdBindIndexBuffer')); | |||||
| vkCmdBindVertexBuffers := TvkCmdBindVertexBuffers (GetProcAddress('vkCmdBindVertexBuffers')); | |||||
| vkCmdDraw := TvkCmdDraw (GetProcAddress('vkCmdDraw')); | |||||
| vkCmdDrawIndexed := TvkCmdDrawIndexed (GetProcAddress('vkCmdDrawIndexed')); | |||||
| vkCmdDrawIndirect := TvkCmdDrawIndirect (GetProcAddress('vkCmdDrawIndirect')); | |||||
| vkCmdDrawIndexedIndirect := TvkCmdDrawIndexedIndirect (GetProcAddress('vkCmdDrawIndexedIndirect')); | |||||
| vkCmdDispatch := TvkCmdDispatch (GetProcAddress('vkCmdDispatch')); | |||||
| vkCmdDispatchIndirect := TvkCmdDispatchIndirect (GetProcAddress('vkCmdDispatchIndirect')); | |||||
| vkCmdCopyBuffer := TvkCmdCopyBuffer (GetProcAddress('vkCmdCopyBuffer')); | |||||
| vkCmdCopyImage := TvkCmdCopyImage (GetProcAddress('vkCmdCopyImage')); | |||||
| vkCmdBlitImage := TvkCmdBlitImage (GetProcAddress('vkCmdBlitImage')); | |||||
| vkCmdCopyBufferToImage := TvkCmdCopyBufferToImage (GetProcAddress('vkCmdCopyBufferToImage')); | |||||
| vkCmdCopyImageToBuffer := TvkCmdCopyImageToBuffer (GetProcAddress('vkCmdCopyImageToBuffer')); | |||||
| vkCmdUpdateBuffer := TvkCmdUpdateBuffer (GetProcAddress('vkCmdUpdateBuffer')); | |||||
| vkCmdFillBuffer := TvkCmdFillBuffer (GetProcAddress('vkCmdFillBuffer')); | |||||
| vkCmdClearColorImage := TvkCmdClearColorImage (GetProcAddress('vkCmdClearColorImage')); | |||||
| vkCmdClearDepthStencilImage := TvkCmdClearDepthStencilImage (GetProcAddress('vkCmdClearDepthStencilImage')); | |||||
| vkCmdClearAttachments := TvkCmdClearAttachments (GetProcAddress('vkCmdClearAttachments')); | |||||
| vkCmdResolveImage := TvkCmdResolveImage (GetProcAddress('vkCmdResolveImage')); | |||||
| vkCmdSetEvent := TvkCmdSetEvent (GetProcAddress('vkCmdSetEvent')); | |||||
| vkCmdResetEvent := TvkCmdResetEvent (GetProcAddress('vkCmdResetEvent')); | |||||
| vkCmdWaitEvents := TvkCmdWaitEvents (GetProcAddress('vkCmdWaitEvents')); | |||||
| vkCmdPipelineBarrier := TvkCmdPipelineBarrier (GetProcAddress('vkCmdPipelineBarrier')); | |||||
| vkCmdBeginQuery := TvkCmdBeginQuery (GetProcAddress('vkCmdBeginQuery')); | |||||
| vkCmdEndQuery := TvkCmdEndQuery (GetProcAddress('vkCmdEndQuery')); | |||||
| vkCmdResetQueryPool := TvkCmdResetQueryPool (GetProcAddress('vkCmdResetQueryPool')); | |||||
| vkCmdWriteTimestamp := TvkCmdWriteTimestamp (GetProcAddress('vkCmdWriteTimestamp')); | |||||
| vkCmdCopyQueryPoolResults := TvkCmdCopyQueryPoolResults (GetProcAddress('vkCmdCopyQueryPoolResults')); | |||||
| vkCmdPushConstants := TvkCmdPushConstants (GetProcAddress('vkCmdPushConstants')); | |||||
| vkCmdBeginRenderPass := TvkCmdBeginRenderPass (GetProcAddress('vkCmdBeginRenderPass')); | |||||
| vkCmdNextSubpass := TvkCmdNextSubpass (GetProcAddress('vkCmdNextSubpass')); | |||||
| vkCmdEndRenderPass := TvkCmdEndRenderPass (GetProcAddress('vkCmdEndRenderPass')); | |||||
| vkCmdExecuteCommands := TvkCmdExecuteCommands (GetProcAddress('vkCmdExecuteCommands')); | |||||
| { ========================================= VK_KHR_swapchain ========================================= } | |||||
| vkCreateSwapchainKHR := TvkCreateSwapchainKHR (GetProcAddress('vkCreateSwapchainKHR')); | |||||
| vkDestroySwapchainKHR := TvkDestroySwapchainKHR (GetProcAddress('vkDestroySwapchainKHR')); | |||||
| vkGetSwapchainImagesKHR := TvkGetSwapchainImagesKHR (GetProcAddress('vkGetSwapchainImagesKHR')); | |||||
| vkAcquireNextImageKHR := TvkAcquireNextImageKHR (GetProcAddress('vkAcquireNextImageKHR')); | |||||
| vkQueuePresentKHR := TvkQueuePresentKHR (GetProcAddress('vkQueuePresentKHR')); | |||||
| { ===================================== VK_KHR_display_swapchain ===================================== } | |||||
| vkCreateSharedSwapchainsKHR := TvkCreateSharedSwapchainsKHR (GetProcAddress('vkCreateSharedSwapchainsKHR')); | |||||
| result := TVkDeviceCommands.Create; | |||||
| try | |||||
| result.Device := aDevice; | |||||
| with result do begin | |||||
| { ========================================== VK_VERSION_1_0 ========================================== } | |||||
| vkDestroyDevice := TvkDestroyDevice (GetProcAddress('vkDestroyDevice')); | |||||
| vkGetDeviceQueue := TvkGetDeviceQueue (GetProcAddress('vkGetDeviceQueue')); | |||||
| vkQueueSubmit := TvkQueueSubmit (GetProcAddress('vkQueueSubmit')); | |||||
| vkQueueWaitIdle := TvkQueueWaitIdle (GetProcAddress('vkQueueWaitIdle')); | |||||
| vkDeviceWaitIdle := TvkDeviceWaitIdle (GetProcAddress('vkDeviceWaitIdle')); | |||||
| vkAllocateMemory := TvkAllocateMemory (GetProcAddress('vkAllocateMemory')); | |||||
| vkFreeMemory := TvkFreeMemory (GetProcAddress('vkFreeMemory')); | |||||
| vkMapMemory := TvkMapMemory (GetProcAddress('vkMapMemory')); | |||||
| vkUnmapMemory := TvkUnmapMemory (GetProcAddress('vkUnmapMemory')); | |||||
| vkFlushMappedMemoryRanges := TvkFlushMappedMemoryRanges (GetProcAddress('vkFlushMappedMemoryRanges')); | |||||
| vkInvalidateMappedMemoryRanges := TvkInvalidateMappedMemoryRanges (GetProcAddress('vkInvalidateMappedMemoryRanges')); | |||||
| vkGetDeviceMemoryCommitment := TvkGetDeviceMemoryCommitment (GetProcAddress('vkGetDeviceMemoryCommitment')); | |||||
| vkBindBufferMemory := TvkBindBufferMemory (GetProcAddress('vkBindBufferMemory')); | |||||
| vkBindImageMemory := TvkBindImageMemory (GetProcAddress('vkBindImageMemory')); | |||||
| vkGetBufferMemoryRequirements := TvkGetBufferMemoryRequirements (GetProcAddress('vkGetBufferMemoryRequirements')); | |||||
| vkGetImageMemoryRequirements := TvkGetImageMemoryRequirements (GetProcAddress('vkGetImageMemoryRequirements')); | |||||
| vkGetImageSparseMemoryRequirements := TvkGetImageSparseMemoryRequirements (GetProcAddress('vkGetImageSparseMemoryRequirements')); | |||||
| vkQueueBindSparse := TvkQueueBindSparse (GetProcAddress('vkQueueBindSparse')); | |||||
| vkCreateFence := TvkCreateFence (GetProcAddress('vkCreateFence')); | |||||
| vkDestroyFence := TvkDestroyFence (GetProcAddress('vkDestroyFence')); | |||||
| vkResetFences := TvkResetFences (GetProcAddress('vkResetFences')); | |||||
| vkGetFenceStatus := TvkGetFenceStatus (GetProcAddress('vkGetFenceStatus')); | |||||
| vkWaitForFences := TvkWaitForFences (GetProcAddress('vkWaitForFences')); | |||||
| vkCreateSemaphore := TvkCreateSemaphore (GetProcAddress('vkCreateSemaphore')); | |||||
| vkDestroySemaphore := TvkDestroySemaphore (GetProcAddress('vkDestroySemaphore')); | |||||
| vkCreateEvent := TvkCreateEvent (GetProcAddress('vkCreateEvent')); | |||||
| vkDestroyEvent := TvkDestroyEvent (GetProcAddress('vkDestroyEvent')); | |||||
| vkGetEventStatus := TvkGetEventStatus (GetProcAddress('vkGetEventStatus')); | |||||
| vkSetEvent := TvkSetEvent (GetProcAddress('vkSetEvent')); | |||||
| vkResetEvent := TvkResetEvent (GetProcAddress('vkResetEvent')); | |||||
| vkCreateQueryPool := TvkCreateQueryPool (GetProcAddress('vkCreateQueryPool')); | |||||
| vkDestroyQueryPool := TvkDestroyQueryPool (GetProcAddress('vkDestroyQueryPool')); | |||||
| vkGetQueryPoolResults := TvkGetQueryPoolResults (GetProcAddress('vkGetQueryPoolResults')); | |||||
| vkCreateBuffer := TvkCreateBuffer (GetProcAddress('vkCreateBuffer')); | |||||
| vkDestroyBuffer := TvkDestroyBuffer (GetProcAddress('vkDestroyBuffer')); | |||||
| vkCreateBufferView := TvkCreateBufferView (GetProcAddress('vkCreateBufferView')); | |||||
| vkDestroyBufferView := TvkDestroyBufferView (GetProcAddress('vkDestroyBufferView')); | |||||
| vkCreateImage := TvkCreateImage (GetProcAddress('vkCreateImage')); | |||||
| vkDestroyImage := TvkDestroyImage (GetProcAddress('vkDestroyImage')); | |||||
| vkGetImageSubresourceLayout := TvkGetImageSubresourceLayout (GetProcAddress('vkGetImageSubresourceLayout')); | |||||
| vkCreateImageView := TvkCreateImageView (GetProcAddress('vkCreateImageView')); | |||||
| vkDestroyImageView := TvkDestroyImageView (GetProcAddress('vkDestroyImageView')); | |||||
| vkCreateShaderModule := TvkCreateShaderModule (GetProcAddress('vkCreateShaderModule')); | |||||
| vkDestroyShaderModule := TvkDestroyShaderModule (GetProcAddress('vkDestroyShaderModule')); | |||||
| vkCreatePipelineCache := TvkCreatePipelineCache (GetProcAddress('vkCreatePipelineCache')); | |||||
| vkDestroyPipelineCache := TvkDestroyPipelineCache (GetProcAddress('vkDestroyPipelineCache')); | |||||
| vkGetPipelineCacheData := TvkGetPipelineCacheData (GetProcAddress('vkGetPipelineCacheData')); | |||||
| vkMergePipelineCaches := TvkMergePipelineCaches (GetProcAddress('vkMergePipelineCaches')); | |||||
| vkCreateGraphicsPipelines := TvkCreateGraphicsPipelines (GetProcAddress('vkCreateGraphicsPipelines')); | |||||
| vkCreateComputePipelines := TvkCreateComputePipelines (GetProcAddress('vkCreateComputePipelines')); | |||||
| vkDestroyPipeline := TvkDestroyPipeline (GetProcAddress('vkDestroyPipeline')); | |||||
| vkCreatePipelineLayout := TvkCreatePipelineLayout (GetProcAddress('vkCreatePipelineLayout')); | |||||
| vkDestroyPipelineLayout := TvkDestroyPipelineLayout (GetProcAddress('vkDestroyPipelineLayout')); | |||||
| vkCreateSampler := TvkCreateSampler (GetProcAddress('vkCreateSampler')); | |||||
| vkDestroySampler := TvkDestroySampler (GetProcAddress('vkDestroySampler')); | |||||
| vkCreateDescriptorSetLayout := TvkCreateDescriptorSetLayout (GetProcAddress('vkCreateDescriptorSetLayout')); | |||||
| vkDestroyDescriptorSetLayout := TvkDestroyDescriptorSetLayout (GetProcAddress('vkDestroyDescriptorSetLayout')); | |||||
| vkCreateDescriptorPool := TvkCreateDescriptorPool (GetProcAddress('vkCreateDescriptorPool')); | |||||
| vkDestroyDescriptorPool := TvkDestroyDescriptorPool (GetProcAddress('vkDestroyDescriptorPool')); | |||||
| vkResetDescriptorPool := TvkResetDescriptorPool (GetProcAddress('vkResetDescriptorPool')); | |||||
| vkAllocateDescriptorSets := TvkAllocateDescriptorSets (GetProcAddress('vkAllocateDescriptorSets')); | |||||
| vkFreeDescriptorSets := TvkFreeDescriptorSets (GetProcAddress('vkFreeDescriptorSets')); | |||||
| vkUpdateDescriptorSets := TvkUpdateDescriptorSets (GetProcAddress('vkUpdateDescriptorSets')); | |||||
| vkCreateFramebuffer := TvkCreateFramebuffer (GetProcAddress('vkCreateFramebuffer')); | |||||
| vkDestroyFramebuffer := TvkDestroyFramebuffer (GetProcAddress('vkDestroyFramebuffer')); | |||||
| vkCreateRenderPass := TvkCreateRenderPass (GetProcAddress('vkCreateRenderPass')); | |||||
| vkDestroyRenderPass := TvkDestroyRenderPass (GetProcAddress('vkDestroyRenderPass')); | |||||
| vkGetRenderAreaGranularity := TvkGetRenderAreaGranularity (GetProcAddress('vkGetRenderAreaGranularity')); | |||||
| vkCreateCommandPool := TvkCreateCommandPool (GetProcAddress('vkCreateCommandPool')); | |||||
| vkDestroyCommandPool := TvkDestroyCommandPool (GetProcAddress('vkDestroyCommandPool')); | |||||
| vkResetCommandPool := TvkResetCommandPool (GetProcAddress('vkResetCommandPool')); | |||||
| vkAllocateCommandBuffers := TvkAllocateCommandBuffers (GetProcAddress('vkAllocateCommandBuffers')); | |||||
| vkFreeCommandBuffers := TvkFreeCommandBuffers (GetProcAddress('vkFreeCommandBuffers')); | |||||
| vkBeginCommandBuffer := TvkBeginCommandBuffer (GetProcAddress('vkBeginCommandBuffer')); | |||||
| vkEndCommandBuffer := TvkEndCommandBuffer (GetProcAddress('vkEndCommandBuffer')); | |||||
| vkResetCommandBuffer := TvkResetCommandBuffer (GetProcAddress('vkResetCommandBuffer')); | |||||
| vkCmdBindPipeline := TvkCmdBindPipeline (GetProcAddress('vkCmdBindPipeline')); | |||||
| vkCmdSetViewport := TvkCmdSetViewport (GetProcAddress('vkCmdSetViewport')); | |||||
| vkCmdSetScissor := TvkCmdSetScissor (GetProcAddress('vkCmdSetScissor')); | |||||
| vkCmdSetLineWidth := TvkCmdSetLineWidth (GetProcAddress('vkCmdSetLineWidth')); | |||||
| vkCmdSetDepthBias := TvkCmdSetDepthBias (GetProcAddress('vkCmdSetDepthBias')); | |||||
| vkCmdSetBlendConstants := TvkCmdSetBlendConstants (GetProcAddress('vkCmdSetBlendConstants')); | |||||
| vkCmdSetDepthBounds := TvkCmdSetDepthBounds (GetProcAddress('vkCmdSetDepthBounds')); | |||||
| vkCmdSetStencilCompareMask := TvkCmdSetStencilCompareMask (GetProcAddress('vkCmdSetStencilCompareMask')); | |||||
| vkCmdSetStencilWriteMask := TvkCmdSetStencilWriteMask (GetProcAddress('vkCmdSetStencilWriteMask')); | |||||
| vkCmdSetStencilReference := TvkCmdSetStencilReference (GetProcAddress('vkCmdSetStencilReference')); | |||||
| vkCmdBindDescriptorSets := TvkCmdBindDescriptorSets (GetProcAddress('vkCmdBindDescriptorSets')); | |||||
| vkCmdBindIndexBuffer := TvkCmdBindIndexBuffer (GetProcAddress('vkCmdBindIndexBuffer')); | |||||
| vkCmdBindVertexBuffers := TvkCmdBindVertexBuffers (GetProcAddress('vkCmdBindVertexBuffers')); | |||||
| vkCmdDraw := TvkCmdDraw (GetProcAddress('vkCmdDraw')); | |||||
| vkCmdDrawIndexed := TvkCmdDrawIndexed (GetProcAddress('vkCmdDrawIndexed')); | |||||
| vkCmdDrawIndirect := TvkCmdDrawIndirect (GetProcAddress('vkCmdDrawIndirect')); | |||||
| vkCmdDrawIndexedIndirect := TvkCmdDrawIndexedIndirect (GetProcAddress('vkCmdDrawIndexedIndirect')); | |||||
| vkCmdDispatch := TvkCmdDispatch (GetProcAddress('vkCmdDispatch')); | |||||
| vkCmdDispatchIndirect := TvkCmdDispatchIndirect (GetProcAddress('vkCmdDispatchIndirect')); | |||||
| vkCmdCopyBuffer := TvkCmdCopyBuffer (GetProcAddress('vkCmdCopyBuffer')); | |||||
| vkCmdCopyImage := TvkCmdCopyImage (GetProcAddress('vkCmdCopyImage')); | |||||
| vkCmdBlitImage := TvkCmdBlitImage (GetProcAddress('vkCmdBlitImage')); | |||||
| vkCmdCopyBufferToImage := TvkCmdCopyBufferToImage (GetProcAddress('vkCmdCopyBufferToImage')); | |||||
| vkCmdCopyImageToBuffer := TvkCmdCopyImageToBuffer (GetProcAddress('vkCmdCopyImageToBuffer')); | |||||
| vkCmdUpdateBuffer := TvkCmdUpdateBuffer (GetProcAddress('vkCmdUpdateBuffer')); | |||||
| vkCmdFillBuffer := TvkCmdFillBuffer (GetProcAddress('vkCmdFillBuffer')); | |||||
| vkCmdClearColorImage := TvkCmdClearColorImage (GetProcAddress('vkCmdClearColorImage')); | |||||
| vkCmdClearDepthStencilImage := TvkCmdClearDepthStencilImage (GetProcAddress('vkCmdClearDepthStencilImage')); | |||||
| vkCmdClearAttachments := TvkCmdClearAttachments (GetProcAddress('vkCmdClearAttachments')); | |||||
| vkCmdResolveImage := TvkCmdResolveImage (GetProcAddress('vkCmdResolveImage')); | |||||
| vkCmdSetEvent := TvkCmdSetEvent (GetProcAddress('vkCmdSetEvent')); | |||||
| vkCmdResetEvent := TvkCmdResetEvent (GetProcAddress('vkCmdResetEvent')); | |||||
| vkCmdWaitEvents := TvkCmdWaitEvents (GetProcAddress('vkCmdWaitEvents')); | |||||
| vkCmdPipelineBarrier := TvkCmdPipelineBarrier (GetProcAddress('vkCmdPipelineBarrier')); | |||||
| vkCmdBeginQuery := TvkCmdBeginQuery (GetProcAddress('vkCmdBeginQuery')); | |||||
| vkCmdEndQuery := TvkCmdEndQuery (GetProcAddress('vkCmdEndQuery')); | |||||
| vkCmdResetQueryPool := TvkCmdResetQueryPool (GetProcAddress('vkCmdResetQueryPool')); | |||||
| vkCmdWriteTimestamp := TvkCmdWriteTimestamp (GetProcAddress('vkCmdWriteTimestamp')); | |||||
| vkCmdCopyQueryPoolResults := TvkCmdCopyQueryPoolResults (GetProcAddress('vkCmdCopyQueryPoolResults')); | |||||
| vkCmdPushConstants := TvkCmdPushConstants (GetProcAddress('vkCmdPushConstants')); | |||||
| vkCmdBeginRenderPass := TvkCmdBeginRenderPass (GetProcAddress('vkCmdBeginRenderPass')); | |||||
| vkCmdNextSubpass := TvkCmdNextSubpass (GetProcAddress('vkCmdNextSubpass')); | |||||
| vkCmdEndRenderPass := TvkCmdEndRenderPass (GetProcAddress('vkCmdEndRenderPass')); | |||||
| vkCmdExecuteCommands := TvkCmdExecuteCommands (GetProcAddress('vkCmdExecuteCommands')); | |||||
| { ========================================= VK_KHR_swapchain ========================================= } | |||||
| vkCreateSwapchainKHR := TvkCreateSwapchainKHR (GetProcAddress('vkCreateSwapchainKHR')); | |||||
| vkDestroySwapchainKHR := TvkDestroySwapchainKHR (GetProcAddress('vkDestroySwapchainKHR')); | |||||
| vkGetSwapchainImagesKHR := TvkGetSwapchainImagesKHR (GetProcAddress('vkGetSwapchainImagesKHR')); | |||||
| vkAcquireNextImageKHR := TvkAcquireNextImageKHR (GetProcAddress('vkAcquireNextImageKHR')); | |||||
| vkQueuePresentKHR := TvkQueuePresentKHR (GetProcAddress('vkQueuePresentKHR')); | |||||
| { ===================================== VK_KHR_display_swapchain ===================================== } | |||||
| vkCreateSharedSwapchainsKHR := TvkCreateSharedSwapchainsKHR (GetProcAddress('vkCreateSharedSwapchainsKHR')); | |||||
| end; | |||||
| except | |||||
| FreeAndNil(result); | |||||
| raise; | |||||
| end; | end; | ||||
| result := success; | |||||
| end; | end; | ||||
| procedure FinalizeVulkan; | procedure FinalizeVulkan; | ||||
| @@ -0,0 +1 @@ | |||||
| generator-i386-win32.exe -i ..\..\data\vk.xml -t ..\..\data\vulkan.tpl -o ..\Vulkan.pas | |||||
| @@ -15,6 +15,7 @@ | |||||
| <Unit1> | <Unit1> | ||||
| <Filename Value="HeaderGenerator.pas"/> | <Filename Value="HeaderGenerator.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <IsVisibleTab Value="True"/> | |||||
| <EditorIndex Value="1"/> | <EditorIndex Value="1"/> | ||||
| <UsageCount Value="21"/> | <UsageCount Value="21"/> | ||||
| <Loaded Value="True"/> | <Loaded Value="True"/> | ||||
| @@ -29,9 +30,8 @@ | |||||
| </Unit2> | </Unit2> | ||||
| <Unit3> | <Unit3> | ||||
| <Filename Value="..\Vulkan.pas"/> | <Filename Value="..\Vulkan.pas"/> | ||||
| <IsVisibleTab Value="True"/> | |||||
| <EditorIndex Value="2"/> | <EditorIndex Value="2"/> | ||||
| <TopLine Value="4423"/> | |||||
| <TopLine Value="3935"/> | |||||
| <CursorPos X="33" Y="4655"/> | <CursorPos X="33" Y="4655"/> | ||||
| <UsageCount Value="10"/> | <UsageCount Value="10"/> | ||||
| <Loaded Value="True"/> | <Loaded Value="True"/> | ||||
| @@ -33,7 +33,7 @@ | |||||
| <PackageName Value="LCL"/> | <PackageName Value="LCL"/> | ||||
| </Item1> | </Item1> | ||||
| </RequiredPackages> | </RequiredPackages> | ||||
| <Units Count="11"> | |||||
| <Units Count="12"> | |||||
| <Unit0> | <Unit0> | ||||
| <Filename Value="triangle.lpr"/> | <Filename Value="triangle.lpr"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| @@ -54,15 +54,15 @@ | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| </Unit3> | </Unit3> | ||||
| <Unit4> | <Unit4> | ||||
| <Filename Value="..\utils\uvkuUtils.pas"/> | |||||
| <Filename Value="..\utils\uvkuInstanceFactory.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| </Unit4> | </Unit4> | ||||
| <Unit5> | <Unit5> | ||||
| <Filename Value="..\utils\uvkuInstanceFactory.pas"/> | |||||
| <Filename Value="..\utils\uvkuPhysicalDevice.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| </Unit5> | </Unit5> | ||||
| <Unit6> | <Unit6> | ||||
| <Filename Value="..\utils\uvkuPhysicalDevice.pas"/> | |||||
| <Filename Value="..\utils\uvkuAllocationHandler.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| </Unit6> | </Unit6> | ||||
| <Unit7> | <Unit7> | ||||
| @@ -78,9 +78,13 @@ | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| </Unit9> | </Unit9> | ||||
| <Unit10> | <Unit10> | ||||
| <Filename Value="..\utils\uvkuAllocationHandler.pas"/> | |||||
| <Filename Value="..\utils\uvkuSurface.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| </Unit10> | </Unit10> | ||||
| <Unit11> | |||||
| <Filename Value="..\utils\uvkuSurfaceFactory.pas"/> | |||||
| <IsPartOfProject Value="True"/> | |||||
| </Unit11> | |||||
| </Units> | </Units> | ||||
| </ProjectOptions> | </ProjectOptions> | ||||
| <CompilerOptions> | <CompilerOptions> | ||||
| @@ -105,6 +109,11 @@ | |||||
| </Win32> | </Win32> | ||||
| </Options> | </Options> | ||||
| </Linking> | </Linking> | ||||
| <Other> | |||||
| <CompilerMessages> | |||||
| <IgnoredMessages idx5024="True"/> | |||||
| </CompilerMessages> | |||||
| </Other> | |||||
| </CompilerOptions> | </CompilerOptions> | ||||
| <Debugging> | <Debugging> | ||||
| <Exceptions Count="3"> | <Exceptions Count="3"> | ||||
| @@ -7,8 +7,7 @@ uses | |||||
| {$IFDEF UNIX}{$IFDEF UseCThreads} | {$IFDEF UNIX}{$IFDEF UseCThreads} | ||||
| cthreads, | cthreads, | ||||
| {$ENDIF}{$ENDIF} | {$ENDIF}{$ENDIF} | ||||
| Interfaces, Dialogs, Forms, uMainForm, Vulkan, uvkuDevice, uvkuDeviceFactory, uvkuPhysicalDeviceFactory, | |||||
| uvkuAllocationHandler; | |||||
| Interfaces, Dialogs, Forms, uMainForm, Vulkan, uvkuDevice, uvkuDeviceFactory; | |||||
| {$R *.res} | {$R *.res} | ||||
| @@ -4,13 +4,14 @@ | |||||
| <PathDelim Value="\"/> | <PathDelim Value="\"/> | ||||
| <Version Value="9"/> | <Version Value="9"/> | ||||
| <BuildModes Active="Default"/> | <BuildModes Active="Default"/> | ||||
| <Units Count="17"> | |||||
| <Units Count="30"> | |||||
| <Unit0> | <Unit0> | ||||
| <Filename Value="triangle.lpr"/> | <Filename Value="triangle.lpr"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <EditorIndex Value="-1"/> | |||||
| <CursorPos X="44" Y="22"/> | |||||
| <UsageCount Value="40"/> | |||||
| <EditorIndex Value="7"/> | |||||
| <CursorPos X="79" Y="10"/> | |||||
| <UsageCount Value="51"/> | |||||
| <Loaded Value="True"/> | |||||
| </Unit0> | </Unit0> | ||||
| <Unit1> | <Unit1> | ||||
| <Filename Value="uMainForm.pas"/> | <Filename Value="uMainForm.pas"/> | ||||
| @@ -18,253 +19,353 @@ | |||||
| <ComponentName Value="MainForm"/> | <ComponentName Value="MainForm"/> | ||||
| <HasResources Value="True"/> | <HasResources Value="True"/> | ||||
| <ResourceBaseClass Value="Form"/> | <ResourceBaseClass Value="Form"/> | ||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="64"/> | |||||
| <CursorPos Y="75"/> | |||||
| <UsageCount Value="40"/> | |||||
| <IsVisibleTab Value="True"/> | |||||
| <TopLine Value="65"/> | |||||
| <CursorPos X="28" Y="79"/> | |||||
| <UsageCount Value="51"/> | |||||
| <Loaded Value="True"/> | |||||
| <LoadedDesigner Value="True"/> | |||||
| </Unit1> | </Unit1> | ||||
| <Unit2> | <Unit2> | ||||
| <Filename Value="..\Vulkan.pas"/> | <Filename Value="..\Vulkan.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <IsVisibleTab Value="True"/> | |||||
| <TopLine Value="1480"/> | |||||
| <CursorPos X="13" Y="1486"/> | |||||
| <UsageCount Value="40"/> | |||||
| <EditorIndex Value="5"/> | |||||
| <TopLine Value="163"/> | |||||
| <CursorPos X="63" Y="188"/> | |||||
| <ExtraEditorCount Value="1"/> | |||||
| <ExtraEditor1> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="4282"/> | |||||
| <CursorPos X="79" Y="4295"/> | |||||
| </ExtraEditor1> | |||||
| <UsageCount Value="51"/> | |||||
| <Loaded Value="True"/> | <Loaded Value="True"/> | ||||
| </Unit2> | </Unit2> | ||||
| <Unit3> | <Unit3> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | <Filename Value="..\utils\uvkuInstance.pas"/> | ||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <EditorIndex Value="1"/> | |||||
| <TopLine Value="83"/> | |||||
| <CursorPos Y="96"/> | |||||
| <UsageCount Value="38"/> | |||||
| <EditorIndex Value="8"/> | |||||
| <TopLine Value="12"/> | |||||
| <CursorPos X="10" Y="24"/> | |||||
| <UsageCount Value="49"/> | |||||
| <Loaded Value="True"/> | <Loaded Value="True"/> | ||||
| </Unit3> | </Unit3> | ||||
| <Unit4> | <Unit4> | ||||
| <Filename Value="..\utils\uvkuUtils.pas"/> | |||||
| <Filename Value="..\utils\uvkuInstanceFactory.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="28"/> | |||||
| <CursorPos Y="40"/> | |||||
| <UsageCount Value="35"/> | |||||
| <EditorIndex Value="4"/> | |||||
| <CursorPos X="58" Y="160"/> | |||||
| <UsageCount Value="43"/> | |||||
| <Loaded Value="True"/> | |||||
| </Unit4> | </Unit4> | ||||
| <Unit5> | <Unit5> | ||||
| <Filename Value="..\utils\uvkuInstanceFactory.pas"/> | |||||
| <Filename Value="..\utils\uvkuPhysicalDevice.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="77"/> | |||||
| <CursorPos Y="97"/> | |||||
| <UsageCount Value="32"/> | |||||
| <EditorIndex Value="10"/> | |||||
| <TopLine Value="241"/> | |||||
| <CursorPos Y="250"/> | |||||
| <UsageCount Value="43"/> | |||||
| <Loaded Value="True"/> | |||||
| </Unit5> | </Unit5> | ||||
| <Unit6> | <Unit6> | ||||
| <Filename Value="..\utils\uvkuPhysicalDevice.pas"/> | |||||
| <Filename Value="..\utils\uvkuAllocationHandler.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <EditorIndex Value="2"/> | |||||
| <TopLine Value="40"/> | |||||
| <CursorPos X="14" Y="18"/> | |||||
| <UsageCount Value="32"/> | |||||
| <Loaded Value="True"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="73"/> | |||||
| <CursorPos X="23" Y="93"/> | |||||
| <UsageCount Value="33"/> | |||||
| </Unit6> | </Unit6> | ||||
| <Unit7> | <Unit7> | ||||
| <Filename Value="..\utils\uvkuDevice.pas"/> | |||||
| <IsPartOfProject Value="True"/> | |||||
| <Filename Value="..\utils\uvkuUtils.pas"/> | |||||
| <EditorIndex Value="-1"/> | <EditorIndex Value="-1"/> | ||||
| <CursorPos X="29" Y="60"/> | |||||
| <UsageCount Value="28"/> | |||||
| <UsageCount Value="43"/> | |||||
| </Unit7> | </Unit7> | ||||
| <Unit8> | <Unit8> | ||||
| <Filename Value="..\utils\uvkuDeviceFactory.pas"/> | |||||
| <Filename Value="..\utils\uvkuDevice.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="17"/> | |||||
| <CursorPos X="38" Y="223"/> | |||||
| <UsageCount Value="26"/> | |||||
| <EditorIndex Value="1"/> | |||||
| <TopLine Value="18"/> | |||||
| <CursorPos X="17" Y="32"/> | |||||
| <UsageCount Value="36"/> | |||||
| <Loaded Value="True"/> | |||||
| </Unit8> | </Unit8> | ||||
| <Unit9> | <Unit9> | ||||
| <Filename Value="..\utils\uvkuPhysicalDeviceFactory.pas"/> | |||||
| <Filename Value="..\utils\uvkuDeviceFactory.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <EditorIndex Value="-1"/> | |||||
| <CursorPos Y="16"/> | |||||
| <UsageCount Value="26"/> | |||||
| <EditorIndex Value="2"/> | |||||
| <TopLine Value="44"/> | |||||
| <CursorPos X="73" Y="58"/> | |||||
| <UsageCount Value="34"/> | |||||
| <Loaded Value="True"/> | |||||
| </Unit9> | </Unit9> | ||||
| <Unit10> | <Unit10> | ||||
| <Filename Value="..\utils\uvkuAllocationHandler.pas"/> | |||||
| <Filename Value="..\utils\uvkuPhysicalDeviceFactory.pas"/> | |||||
| <IsPartOfProject Value="True"/> | <IsPartOfProject Value="True"/> | ||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="73"/> | |||||
| <CursorPos Y="100"/> | |||||
| <UsageCount Value="22"/> | |||||
| <EditorIndex Value="9"/> | |||||
| <CursorPos X="74" Y="30"/> | |||||
| <UsageCount Value="35"/> | |||||
| <Loaded Value="True"/> | |||||
| </Unit10> | </Unit10> | ||||
| <Unit11> | <Unit11> | ||||
| <Filename Value="..\utils\uvkuSurface.pas"/> | |||||
| <IsPartOfProject Value="True"/> | |||||
| <EditorIndex Value="3"/> | |||||
| <CursorPos Y="59"/> | |||||
| <UsageCount Value="29"/> | |||||
| <Loaded Value="True"/> | |||||
| </Unit11> | |||||
| <Unit12> | |||||
| <Filename Value="..\utils\uvkuSurfaceFactory.pas"/> | |||||
| <IsPartOfProject Value="True"/> | |||||
| <EditorIndex Value="6"/> | |||||
| <TopLine Value="9"/> | |||||
| <CursorPos X="20" Y="18"/> | |||||
| <UsageCount Value="28"/> | |||||
| <Loaded Value="True"/> | |||||
| </Unit12> | |||||
| <Unit13> | |||||
| <Filename Value="..\..\data\Vulkan.tpl"/> | <Filename Value="..\..\data\Vulkan.tpl"/> | ||||
| <EditorIndex Value="-1"/> | <EditorIndex Value="-1"/> | ||||
| <TopLine Value="44"/> | <TopLine Value="44"/> | ||||
| <CursorPos X="27" Y="22"/> | <CursorPos X="27" Y="22"/> | ||||
| <UsageCount Value="14"/> | <UsageCount Value="14"/> | ||||
| <DefaultSyntaxHighlighter Value="None"/> | <DefaultSyntaxHighlighter Value="None"/> | ||||
| </Unit11> | |||||
| <Unit12> | |||||
| </Unit13> | |||||
| <Unit14> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\packages\fcl-base\src\custapp.pp"/> | <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\packages\fcl-base\src\custapp.pp"/> | ||||
| <UnitName Value="CustApp"/> | <UnitName Value="CustApp"/> | ||||
| <EditorIndex Value="-1"/> | <EditorIndex Value="-1"/> | ||||
| <TopLine Value="72"/> | |||||
| <CursorPos X="14" Y="86"/> | |||||
| <UsageCount Value="9"/> | |||||
| </Unit12> | |||||
| <Unit13> | |||||
| <TopLine Value="13"/> | |||||
| <CursorPos X="3" Y="30"/> | |||||
| <UsageCount Value="10"/> | |||||
| </Unit14> | |||||
| <Unit15> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\objpash.inc"/> | <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\objpash.inc"/> | ||||
| <EditorIndex Value="-1"/> | <EditorIndex Value="-1"/> | ||||
| <TopLine Value="213"/> | <TopLine Value="213"/> | ||||
| <CursorPos X="21" Y="224"/> | <CursorPos X="21" Y="224"/> | ||||
| <UsageCount Value="9"/> | <UsageCount Value="9"/> | ||||
| </Unit13> | |||||
| <Unit14> | |||||
| </Unit15> | |||||
| <Unit16> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\lcl\include\customform.inc"/> | <Filename Value="C:\Zusatzprogramme\Lazarus\lcl\include\customform.inc"/> | ||||
| <EditorIndex Value="-1"/> | <EditorIndex Value="-1"/> | ||||
| <TopLine Value="138"/> | <TopLine Value="138"/> | ||||
| <CursorPos Y="154"/> | <CursorPos Y="154"/> | ||||
| <UsageCount Value="9"/> | <UsageCount Value="9"/> | ||||
| </Unit14> | |||||
| <Unit15> | |||||
| </Unit16> | |||||
| <Unit17> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\sysutils\sysstrh.inc"/> | <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\sysutils\sysstrh.inc"/> | ||||
| <EditorIndex Value="-1"/> | <EditorIndex Value="-1"/> | ||||
| <TopLine Value="96"/> | <TopLine Value="96"/> | ||||
| <CursorPos X="10" Y="112"/> | <CursorPos X="10" Y="112"/> | ||||
| <UsageCount Value="10"/> | <UsageCount Value="10"/> | ||||
| </Unit15> | |||||
| <Unit16> | |||||
| </Unit17> | |||||
| <Unit18> | |||||
| <Filename Value="..\Vulkan_old.pas"/> | <Filename Value="..\Vulkan_old.pas"/> | ||||
| <IsVisibleTab Value="True"/> | |||||
| <WindowIndex Value="1"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <WindowIndex Value="-1"/> | |||||
| <TopLine Value="2195"/> | <TopLine Value="2195"/> | ||||
| <CursorPos X="3" Y="2211"/> | <CursorPos X="3" Y="2211"/> | ||||
| <UsageCount Value="10"/> | <UsageCount Value="10"/> | ||||
| <Loaded Value="True"/> | |||||
| </Unit16> | |||||
| </Unit18> | |||||
| <Unit19> | |||||
| <Filename Value="..\Vulkan.inc"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <CursorPos X="9" Y="5"/> | |||||
| <UsageCount Value="11"/> | |||||
| </Unit19> | |||||
| <Unit20> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\lcl\forms.pp"/> | |||||
| <UnitName Value="Forms"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="1249"/> | |||||
| <CursorPos X="3" Y="1268"/> | |||||
| <UsageCount Value="10"/> | |||||
| </Unit20> | |||||
| <Unit21> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\classes\classesh.inc"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="2100"/> | |||||
| <CursorPos X="38" Y="2125"/> | |||||
| <UsageCount Value="10"/> | |||||
| </Unit21> | |||||
| <Unit22> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\lcl\extctrls.pp"/> | |||||
| <UnitName Value="ExtCtrls"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="1023"/> | |||||
| <CursorPos X="3" Y="1038"/> | |||||
| <UsageCount Value="10"/> | |||||
| </Unit22> | |||||
| <Unit23> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\lcl\controls.pp"/> | |||||
| <UnitName Value="Controls"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="2240"/> | |||||
| <CursorPos X="3" Y="2255"/> | |||||
| <UsageCount Value="10"/> | |||||
| </Unit23> | |||||
| <Unit24> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\sysutils\sysutilh.inc"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="22"/> | |||||
| <CursorPos X="4" Y="37"/> | |||||
| <UsageCount Value="12"/> | |||||
| </Unit24> | |||||
| <Unit25> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\sysosh.inc"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="7"/> | |||||
| <CursorPos X="3" Y="22"/> | |||||
| <UsageCount Value="12"/> | |||||
| </Unit25> | |||||
| <Unit26> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\systemh.inc"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="93"/> | |||||
| <CursorPos X="19" Y="108"/> | |||||
| <UsageCount Value="12"/> | |||||
| </Unit26> | |||||
| <Unit27> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\wininc\ascdef.inc"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="57"/> | |||||
| <CursorPos X="10" Y="72"/> | |||||
| <UsageCount Value="12"/> | |||||
| </Unit27> | |||||
| <Unit28> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win32\windows.pp"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <UsageCount Value="12"/> | |||||
| </Unit28> | |||||
| <Unit29> | |||||
| <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\wininc\base.inc"/> | |||||
| <EditorIndex Value="-1"/> | |||||
| <TopLine Value="84"/> | |||||
| <CursorPos X="6" Y="99"/> | |||||
| <UsageCount Value="12"/> | |||||
| </Unit29> | |||||
| </Units> | </Units> | ||||
| <JumpHistory Count="24" HistoryIndex="23"> | |||||
| <JumpHistory Count="30" HistoryIndex="28"> | |||||
| <Position1> | <Position1> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="118" TopLine="103"/> | |||||
| <Filename Value="..\utils\uvkuPhysicalDevice.pas"/> | |||||
| <Caret Line="272" Column="3" TopLine="246"/> | |||||
| </Position1> | </Position1> | ||||
| <Position2> | <Position2> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="121" TopLine="103"/> | |||||
| <Filename Value="..\utils\uvkuPhysicalDevice.pas"/> | |||||
| <Caret Line="258" Column="10" TopLine="239"/> | |||||
| </Position2> | </Position2> | ||||
| <Position3> | <Position3> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="103" TopLine="88"/> | |||||
| <Filename Value="..\utils\uvkuPhysicalDevice.pas"/> | |||||
| <Caret Line="262" Column="79" TopLine="244"/> | |||||
| </Position3> | </Position3> | ||||
| <Position4> | <Position4> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="107" TopLine="88"/> | |||||
| <Filename Value="..\utils\uvkuPhysicalDevice.pas"/> | |||||
| <Caret Line="62" Column="63" TopLine="48"/> | |||||
| </Position4> | </Position4> | ||||
| <Position5> | <Position5> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="105" TopLine="88"/> | |||||
| <Filename Value="..\utils\uvkuPhysicalDevice.pas"/> | |||||
| <Caret Line="262" Column="101" TopLine="244"/> | |||||
| </Position5> | </Position5> | ||||
| <Position6> | <Position6> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="106" TopLine="88"/> | |||||
| <Filename Value="..\utils\uvkuSurface.pas"/> | |||||
| <Caret Line="14" Column="3"/> | |||||
| </Position6> | </Position6> | ||||
| <Position7> | <Position7> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="104" Column="3" TopLine="101"/> | |||||
| <Filename Value="..\utils\uvkuSurface.pas"/> | |||||
| <Caret Line="57" Column="51" TopLine="42"/> | |||||
| </Position7> | </Position7> | ||||
| <Position8> | <Position8> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="120" TopLine="105"/> | |||||
| <Filename Value="..\utils\uvkuSurface.pas"/> | |||||
| <Caret Line="69" Column="12" TopLine="63"/> | |||||
| </Position8> | </Position8> | ||||
| <Position9> | <Position9> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="91" TopLine="77"/> | |||||
| <Filename Value="..\utils\uvkuSurface.pas"/> | |||||
| <Caret Line="24" Column="67" TopLine="14"/> | |||||
| </Position9> | </Position9> | ||||
| <Position10> | <Position10> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="92" TopLine="77"/> | |||||
| <Filename Value="..\utils\uvkuSurfaceFactory.pas"/> | |||||
| <Caret Line="198" Column="87" TopLine="176"/> | |||||
| </Position10> | </Position10> | ||||
| <Position11> | <Position11> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="93" TopLine="77"/> | |||||
| <Filename Value="triangle.lpr"/> | |||||
| <Caret Line="10" Column="48"/> | |||||
| </Position11> | </Position11> | ||||
| <Position12> | <Position12> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="95" TopLine="77"/> | |||||
| <Filename Value="uMainForm.pas"/> | |||||
| <Caret Line="100" Column="60" TopLine="76"/> | |||||
| </Position12> | </Position12> | ||||
| <Position13> | <Position13> | ||||
| <Filename Value="..\Vulkan.pas"/> | |||||
| <Caret Line="4430" Column="28" TopLine="4415"/> | |||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="31" Column="27" TopLine="14"/> | |||||
| </Position13> | </Position13> | ||||
| <Position14> | <Position14> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="87" Column="56" TopLine="77"/> | |||||
| <Filename Value="..\utils\uvkuSurfaceFactory.pas"/> | |||||
| <Caret Line="161" Column="87" TopLine="115"/> | |||||
| </Position14> | </Position14> | ||||
| <Position15> | <Position15> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="98" Column="5" TopLine="83"/> | |||||
| <Filename Value="..\utils\uvkuSurfaceFactory.pas"/> | |||||
| <Caret Line="150" Column="14" TopLine="136"/> | |||||
| </Position15> | </Position15> | ||||
| <Position16> | <Position16> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="95" TopLine="83"/> | |||||
| <Filename Value="..\utils\uvkuSurfaceFactory.pas"/> | |||||
| <Caret Line="188" Column="24" TopLine="174"/> | |||||
| </Position16> | </Position16> | ||||
| <Position17> | <Position17> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="96" TopLine="83"/> | |||||
| <Filename Value="uMainForm.pas"/> | |||||
| <Caret Line="11" Column="34" TopLine="90"/> | |||||
| </Position17> | </Position17> | ||||
| <Position18> | <Position18> | ||||
| <Filename Value="..\Vulkan.pas"/> | |||||
| <Caret Line="2591" Column="3" TopLine="2576"/> | |||||
| <Filename Value="uMainForm.pas"/> | |||||
| <Caret Line="101" TopLine="91"/> | |||||
| </Position18> | </Position18> | ||||
| <Position19> | <Position19> | ||||
| <Filename Value="..\Vulkan.pas"/> | |||||
| <Caret Line="2453" Column="40" TopLine="2437"/> | |||||
| <Filename Value="..\utils\uvkuDevice.pas"/> | |||||
| <Caret Line="96" Column="15" TopLine="56"/> | |||||
| </Position19> | </Position19> | ||||
| <Position20> | <Position20> | ||||
| <Filename Value="..\utils\uvkuInstance.pas"/> | |||||
| <Caret Line="96" TopLine="83"/> | |||||
| <Filename Value="..\utils\uvkuDevice.pas"/> | |||||
| <Caret Line="55" Column="11" TopLine="40"/> | |||||
| </Position20> | </Position20> | ||||
| <Position21> | <Position21> | ||||
| <Filename Value="..\Vulkan.pas"/> | <Filename Value="..\Vulkan.pas"/> | ||||
| <Caret Line="4178" Column="3" TopLine="4163"/> | |||||
| <Caret Line="4454" Column="11" TopLine="4439"/> | |||||
| </Position21> | </Position21> | ||||
| <Position22> | <Position22> | ||||
| <Filename Value="..\Vulkan_old.pas"/> | |||||
| <Caret Line="11" Column="31" TopLine="61"/> | |||||
| <Filename Value="..\Vulkan.pas"/> | |||||
| </Position22> | </Position22> | ||||
| <Position23> | <Position23> | ||||
| <Filename Value="..\Vulkan_old.pas"/> | |||||
| <Caret Line="2452" Column="20" TopLine="2427"/> | |||||
| <Filename Value="..\Vulkan.pas"/> | |||||
| <Caret Line="86" Column="30" TopLine="61"/> | |||||
| </Position23> | </Position23> | ||||
| <Position24> | <Position24> | ||||
| <Filename Value="..\Vulkan.pas"/> | |||||
| <Caret Line="2999" Column="49" TopLine="2983"/> | |||||
| <Filename Value="..\utils\uvkuDeviceFactory.pas"/> | |||||
| <Caret Line="76" Column="22" TopLine="58"/> | |||||
| </Position24> | </Position24> | ||||
| <Position25> | |||||
| <Filename Value="..\utils\uvkuDeviceFactory.pas"/> | |||||
| <Caret Line="179" TopLine="215"/> | |||||
| </Position25> | |||||
| <Position26> | |||||
| <Filename Value="uMainForm.pas"/> | |||||
| <Caret Line="30" Column="5" TopLine="4"/> | |||||
| </Position26> | |||||
| <Position27> | |||||
| <Filename Value="..\utils\uvkuDeviceFactory.pas"/> | |||||
| <Caret Line="198" Column="96" TopLine="187"/> | |||||
| </Position27> | |||||
| <Position28> | |||||
| <Filename Value="uMainForm.pas"/> | |||||
| <Caret Line="12" Column="32"/> | |||||
| </Position28> | |||||
| <Position29> | |||||
| <Filename Value="uMainForm.pas"/> | |||||
| <Caret Line="111" Column="6" TopLine="89"/> | |||||
| </Position29> | |||||
| <Position30> | |||||
| <Filename Value="..\utils\uvkuDeviceFactory.pas"/> | |||||
| <Caret Line="58" Column="73" TopLine="44"/> | |||||
| </Position30> | |||||
| </JumpHistory> | </JumpHistory> | ||||
| </ProjectSession> | </ProjectSession> | ||||
| <Debugging> | |||||
| <BreakPoints Count="3"> | |||||
| <Item1> | |||||
| <Kind Value="bpkSource"/> | |||||
| <WatchScope Value="wpsLocal"/> | |||||
| <WatchKind Value="wpkWrite"/> | |||||
| <Source Value="uMainForm.pas"/> | |||||
| <Line Value="100"/> | |||||
| </Item1> | |||||
| <Item2> | |||||
| <Kind Value="bpkSource"/> | |||||
| <WatchScope Value="wpsLocal"/> | |||||
| <WatchKind Value="wpkWrite"/> | |||||
| <Source Value="uMainForm.pas"/> | |||||
| <Line Value="75"/> | |||||
| </Item2> | |||||
| <Item3> | |||||
| <Kind Value="bpkSource"/> | |||||
| <WatchScope Value="wpsLocal"/> | |||||
| <WatchKind Value="wpkWrite"/> | |||||
| <Source Value="..\utils\uvkuInstance.pas"/> | |||||
| <Line Value="95"/> | |||||
| </Item3> | |||||
| </BreakPoints> | |||||
| </Debugging> | |||||
| </CONFIG> | </CONFIG> | ||||
| @@ -4,7 +4,18 @@ object MainForm: TMainForm | |||||
| Top = 263 | Top = 263 | ||||
| Width = 320 | Width = 320 | ||||
| Caption = 'Triangle' | Caption = 'Triangle' | ||||
| ClientHeight = 240 | |||||
| ClientWidth = 320 | |||||
| OnCreate = FormCreate | OnCreate = FormCreate | ||||
| OnDestroy = FormDestroy | OnDestroy = FormDestroy | ||||
| LCLVersion = '1.7' | LCLVersion = '1.7' | ||||
| object RenderPanel: TPanel | |||||
| Left = 0 | |||||
| Height = 240 | |||||
| Top = 0 | |||||
| Width = 320 | |||||
| Align = alClient | |||||
| BevelOuter = bvNone | |||||
| TabOrder = 0 | |||||
| end | |||||
| end | end | ||||
| @@ -5,8 +5,11 @@ unit uMainForm; | |||||
| interface | interface | ||||
| uses | uses | ||||
| Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, | |||||
| Vulkan, uvkuInstance, uvkuInstanceFactory, uvkuPhysicalDevice, uvkuUtils, uvkuAllocationHandler, uvkuDevice, uvkuDeviceFactory; | |||||
| Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, | |||||
| Vulkan, uvkuAllocationHandler, | |||||
| uvkuInstance, uvkuInstanceFactory, | |||||
| uvkuSurface, uvkuSurfaceFactory, | |||||
| uvkuDevice, uvkuDeviceFactory; | |||||
| type | type | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -19,12 +22,14 @@ type | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| TMainForm = class(TForm) | TMainForm = class(TForm) | ||||
| RenderPanel: TPanel; | |||||
| procedure FormCreate(Sender: TObject); | procedure FormCreate(Sender: TObject); | ||||
| procedure FormDestroy(Sender: TObject); | procedure FormDestroy(Sender: TObject); | ||||
| private | private | ||||
| fAllocHandler: TCustomAllocHandler; | fAllocHandler: TCustomAllocHandler; | ||||
| fInstance: TvkuInstance; | fInstance: TvkuInstance; | ||||
| fDevice: TvkuDevice; | fDevice: TvkuDevice; | ||||
| fSurface: TvkuSurface; | |||||
| public | public | ||||
| { public declarations } | { public declarations } | ||||
| end; | end; | ||||
| @@ -35,6 +40,7 @@ var | |||||
| implementation | implementation | ||||
| {$R *.lfm} | {$R *.lfm} | ||||
| {$I Vulkan.inc} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| //TCustomAllocHandler//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | //TCustomAllocHandler//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -67,9 +73,9 @@ end; | |||||
| procedure TMainForm.FormCreate(Sender: TObject); | procedure TMainForm.FormCreate(Sender: TObject); | ||||
| var | var | ||||
| PhyDevices: TvkuPhysicalDeviceArr; | PhyDevices: TvkuPhysicalDeviceArr; | ||||
| QueueFamProps: TVkQueueFamilyPropertiesArr; | |||||
| iFactory: TvkuInstanceFactory; | iFactory: TvkuInstanceFactory; | ||||
| dFactory: TvkuDeviceFactory; | dFactory: TvkuDeviceFactory; | ||||
| sFactory: TvkuSurfaceFactory; | |||||
| qci: TvkuQueueCreateInfo; | qci: TvkuQueueCreateInfo; | ||||
| begin | begin | ||||
| fAllocHandler := TCustomAllocHandler.Create; | fAllocHandler := TCustomAllocHandler.Create; | ||||
| @@ -77,6 +83,8 @@ begin | |||||
| WriteLn('create vulkan instance'); | WriteLn('create vulkan instance'); | ||||
| iFactory := TvkuInstanceFactory.Create; | iFactory := TvkuInstanceFactory.Create; | ||||
| try | try | ||||
| iFactory.Extensions.Add(VK_KHR_SURFACE_EXTENSION_NAME); | |||||
| iFactory.Extensions.Add(TvkuInstanceFactory.GetPlatformSurfaceExtensionName); | |||||
| fInstance := iFactory.CreateInstance(fAllocHandler, false); | fInstance := iFactory.CreateInstance(fAllocHandler, false); | ||||
| finally | finally | ||||
| FreeAndNil(iFactory); | FreeAndNil(iFactory); | ||||
| @@ -86,8 +94,17 @@ begin | |||||
| if (Length(PhyDevices) <= 0) then | if (Length(PhyDevices) <= 0) then | ||||
| raise Exception.Create('unable to get physical device'); | raise Exception.Create('unable to get physical device'); | ||||
| WriteLn('create vulkan surface'); | |||||
| sFactory := TvkuSurfaceFactory.Create(fInstance); | |||||
| try | |||||
| sFactory.WinControl := RenderPanel; | |||||
| fSurface := sFactory.CreateSurface(fAllocHandler, false); | |||||
| finally | |||||
| FreeAndNil(sFactory); | |||||
| end; | |||||
| WriteLn('create vulkan device'); | WriteLn('create vulkan device'); | ||||
| dFactory := TvkuDeviceFactory.Create; | |||||
| dFactory := TvkuDeviceFactory.Create(fInstance); | |||||
| try | try | ||||
| SetLength(qci.Priorities, 1); | SetLength(qci.Priorities, 1); | ||||
| qci.Priorities[0] := 1.0; | qci.Priorities[0] := 1.0; | ||||
| @@ -107,6 +124,7 @@ end; | |||||
| procedure TMainForm.FormDestroy(Sender: TObject); | procedure TMainForm.FormDestroy(Sender: TObject); | ||||
| begin | begin | ||||
| FreeAndNil(fDevice); | FreeAndNil(fDevice); | ||||
| FreeAndNil(fSurface); | |||||
| FreeAndNil(fInstance); | FreeAndNil(fInstance); | ||||
| FreeAndNil(fAllocHandler); | FreeAndNil(fAllocHandler); | ||||
| end; | end; | ||||
| @@ -90,7 +90,7 @@ end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| function TvkuAllocationHandler.GetAllocationCallbacks: TVkAllocationCallbacks; | function TvkuAllocationHandler.GetAllocationCallbacks: TVkAllocationCallbacks; | ||||
| begin | begin | ||||
| FillByte(result, SizeOf(result), 0); | |||||
| FillByte(result{%H-}, SizeOf(result), 0); | |||||
| result.pUserData := self; | result.pUserData := self; | ||||
| result.pfnAllocation := @AllocateMemoryCallback; | result.pfnAllocation := @AllocateMemoryCallback; | ||||
| result.pfnReallocation := @ReallocateMemoryCallback; | result.pfnReallocation := @ReallocateMemoryCallback; | ||||
| @@ -15,6 +15,8 @@ type | |||||
| fHandle: VkDevice; | fHandle: VkDevice; | ||||
| fPhysicalDevice: VkPhysicalDevice; | fPhysicalDevice: VkPhysicalDevice; | ||||
| fAllocCallbacks: PVkAllocationCallbacks; | fAllocCallbacks: PVkAllocationCallbacks; | ||||
| fInstanceCommands: TVkInstanceCommands; | |||||
| fDeviceCommands: TVkDeviceCommands; | |||||
| procedure CreateHandle( | procedure CreateHandle( | ||||
| const aCreateInfo: PVkDeviceCreateInfo; | const aCreateInfo: PVkDeviceCreateInfo; | ||||
| @@ -25,10 +27,12 @@ type | |||||
| constructor Create( | constructor Create( | ||||
| const aPhysicalDevice: VkPhysicalDevice; | const aPhysicalDevice: VkPhysicalDevice; | ||||
| const aCreateInfo: TVkDeviceCreateInfo); | |||||
| const aCreateInfo: TVkDeviceCreateInfo; | |||||
| const aInstanceCommands: TVkInstanceCommands); | |||||
| constructor Create( | constructor Create( | ||||
| const aPhysicalDevice: VkPhysicalDevice; | const aPhysicalDevice: VkPhysicalDevice; | ||||
| const aCreateInfo: TVkDeviceCreateInfo; | const aCreateInfo: TVkDeviceCreateInfo; | ||||
| const aInstanceCommands: TVkInstanceCommands; | |||||
| const aAllocCallbacks: TVkAllocationCallbacks); | const aAllocCallbacks: TVkAllocationCallbacks); | ||||
| destructor Destroy; override; | destructor Destroy; override; | ||||
| end; | end; | ||||
| @@ -44,44 +48,54 @@ uses | |||||
| procedure TvkuDevice.CreateHandle(const aCreateInfo: PVkDeviceCreateInfo; const aAllocCallbacks: PVkAllocationCallbacks); | procedure TvkuDevice.CreateHandle(const aCreateInfo: PVkDeviceCreateInfo; const aAllocCallbacks: PVkAllocationCallbacks); | ||||
| var err: TVkResult; | var err: TVkResult; | ||||
| begin | begin | ||||
| if not Assigned(fInstanceCommands.vkCreateDevice) then | |||||
| raise TvkuException.Create('invalid function pointer: vkCreateDevice; did you load the vulkan core commands?'); | |||||
| if Assigned(aAllocCallbacks) then begin | if Assigned(aAllocCallbacks) then begin | ||||
| new(fAllocCallbacks); | new(fAllocCallbacks); | ||||
| fAllocCallbacks^ := aAllocCallbacks^; | fAllocCallbacks^ := aAllocCallbacks^; | ||||
| end; | end; | ||||
| err := vkCreateDevice(fPhysicalDevice, aCreateInfo, fAllocCallbacks, @fHandle); | |||||
| err := fInstanceCommands.vkCreateDevice(fPhysicalDevice, aCreateInfo, fAllocCallbacks, @fHandle); | |||||
| if (err < VK_SUCCESS) then | if (err < VK_SUCCESS) then | ||||
| raise TvkuErrorException.Create('unable to create device', err); | raise TvkuErrorException.Create('unable to create device', err); | ||||
| fDeviceCommands := LoadDeviceCommands(fInstanceCommands.Instance, fHandle); | |||||
| if not Assigned(fDeviceCommands) then | |||||
| raise TvkuException.Create('unable to load device commands'); | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| constructor TvkuDevice.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo); | |||||
| constructor TvkuDevice.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo; | |||||
| const aInstanceCommands: TVkInstanceCommands); | |||||
| begin | begin | ||||
| inherited Create; | inherited Create; | ||||
| fHandle := nil; | |||||
| fPhysicalDevice := aPhysicalDevice; | |||||
| fHandle := nil; | |||||
| fPhysicalDevice := aPhysicalDevice; | |||||
| fInstanceCommands := aInstanceCommands; | |||||
| CreateHandle(@aCreateInfo, nil); | CreateHandle(@aCreateInfo, nil); | ||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| constructor TvkuDevice.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo; const aAllocCallbacks: TVkAllocationCallbacks); | |||||
| constructor TvkuDevice.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo; | |||||
| const aInstanceCommands: TVkInstanceCommands; const aAllocCallbacks: TVkAllocationCallbacks); | |||||
| begin | begin | ||||
| inherited Create; | inherited Create; | ||||
| fHandle := nil; | |||||
| fPhysicalDevice := aPhysicalDevice; | |||||
| fHandle := nil; | |||||
| fPhysicalDevice := aPhysicalDevice; | |||||
| fInstanceCommands := aInstanceCommands; | |||||
| CreateHandle(@aCreateInfo, @aAllocCallbacks); | CreateHandle(@aCreateInfo, @aAllocCallbacks); | ||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| destructor TvkuDevice.Destroy; | destructor TvkuDevice.Destroy; | ||||
| begin | begin | ||||
| if Assigned(fHandle) then begin | |||||
| vkDestroyDevice(fHandle, fAllocCallbacks); | |||||
| if (fHandle <> VK_INVALID_HANDLE) then begin | |||||
| fDeviceCommands.vkDestroyDevice(fHandle, fAllocCallbacks); | |||||
| fHandle := nil; | fHandle := nil; | ||||
| end; | end; | ||||
| if Assigned(fAllocCallbacks) then begin | if Assigned(fAllocCallbacks) then begin | ||||
| Dispose(fAllocCallbacks); | Dispose(fAllocCallbacks); | ||||
| fAllocCallbacks := nil; | fAllocCallbacks := nil; | ||||
| end; | end; | ||||
| FreeAndNil(fDeviceCommands); | |||||
| inherited Destroy; | inherited Destroy; | ||||
| end; | end; | ||||
| @@ -6,7 +6,7 @@ interface | |||||
| uses | uses | ||||
| Classes, SysUtils, | Classes, SysUtils, | ||||
| Vulkan, uvkuDevice, uvkuAllocationHandler; | |||||
| Vulkan, uvkuInstance, uvkuDevice, uvkuAllocationHandler; | |||||
| type | type | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -24,20 +24,13 @@ type | |||||
| fAllocHandler: TvkuAllocationHandler; | fAllocHandler: TvkuAllocationHandler; | ||||
| fOwnsHandler: Boolean; | fOwnsHandler: Boolean; | ||||
| public | public | ||||
| constructor Create( | |||||
| const aPhysicalDevice: VkPhysicalDevice; | |||||
| const aCreateInfo: TVkDeviceCreateInfo); | |||||
| constructor Create( | |||||
| const aPhysicalDevice: VkPhysicalDevice; | |||||
| const aCreateInfo: TVkDeviceCreateInfo; | |||||
| const aAllocHandler: TvkuAllocationHandler; | |||||
| const aOwnsHandler: Boolean); | |||||
| destructor Destroy; override; | destructor Destroy; override; | ||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| TvkuDeviceFactory = class(TObject) | TvkuDeviceFactory = class(TObject) | ||||
| private | private | ||||
| fInstance: TvkuInstance; | |||||
| fFeatures: TVkPhysicalDeviceFeatures; | fFeatures: TVkPhysicalDeviceFeatures; | ||||
| fFlags: VkDeviceCreateFlags; | fFlags: VkDeviceCreateFlags; | ||||
| fLayers: TStringList; | fLayers: TStringList; | ||||
| @@ -71,7 +64,7 @@ type | |||||
| const aAllocHandler: TvkuAllocationHandler; | const aAllocHandler: TvkuAllocationHandler; | ||||
| const aOwnsHandler: Boolean): TvkuDevice; | const aOwnsHandler: Boolean): TvkuDevice; | ||||
| constructor Create; | |||||
| constructor Create(const aInstance: TvkuInstance); | |||||
| destructor Destroy; override; | destructor Destroy; override; | ||||
| end; | end; | ||||
| @@ -82,25 +75,6 @@ uses | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| //TvkuDeviceEx/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | //TvkuDeviceEx/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| constructor TvkuDeviceEx.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo); | |||||
| begin | |||||
| inherited Create(aPhysicalDevice, aCreateInfo); | |||||
| fAllocHandler := nil; | |||||
| fOwnsHandler := false; | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| constructor TvkuDeviceEx.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo; | |||||
| const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean); | |||||
| begin | |||||
| fAllocHandler := aAllocHandler; | |||||
| fOwnsHandler := aOwnsHandler; | |||||
| if Assigned(fAllocHandler) | |||||
| then inherited Create(aPhysicalDevice, aCreateInfo, fAllocHandler.GetAllocationCallbacks) | |||||
| else inherited Create(aPhysicalDevice, aCreateInfo); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| destructor TvkuDeviceEx.Destroy; | destructor TvkuDeviceEx.Destroy; | ||||
| begin | begin | ||||
| @@ -172,7 +146,8 @@ begin | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| function TvkuDeviceFactory.CreateDevice(const aPhysicalDevice: VkPhysicalDevice; const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean): TvkuDevice; | |||||
| function TvkuDeviceFactory.CreateDevice(const aPhysicalDevice: VkPhysicalDevice; | |||||
| const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean): TvkuDevice; | |||||
| var | var | ||||
| CreateInfo: TVkDeviceCreateInfo; | CreateInfo: TVkDeviceCreateInfo; | ||||
| QueueInfos: array of TVkDeviceQueueCreateInfo; | QueueInfos: array of TVkDeviceQueueCreateInfo; | ||||
| @@ -218,14 +193,24 @@ begin | |||||
| CreateInfo.ppEnabledExtensionNames := @ext[0]; | CreateInfo.ppEnabledExtensionNames := @ext[0]; | ||||
| CreateInfo.pEnabledFeatures := @fFeatures; | CreateInfo.pEnabledFeatures := @fFeatures; | ||||
| result := TvkuDeviceEx.Create(aPhysicalDevice, CreateInfo, aAllocHandler, aOwnsHandler); | |||||
| if Assigned(aAllocHandler) | |||||
| then result := TvkuDeviceEx.Create(aPhysicalDevice, CreateInfo, fInstance.InstanceCommands, aAllocHandler.GetAllocationCallbacks) | |||||
| else result := TvkuDeviceEx.Create(aPhysicalDevice, CreateInfo, fInstance.InstanceCommands); | |||||
| try | |||||
| TvkuDeviceEx(result).fAllocHandler := aAllocHandler; | |||||
| TvkuDeviceEx(result).fOwnsHandler := aOwnsHandler; | |||||
| except | |||||
| FreeAndNil(result); | |||||
| raise; | |||||
| end; | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| constructor TvkuDeviceFactory.Create; | |||||
| constructor TvkuDeviceFactory.Create(const aInstance: TvkuInstance); | |||||
| begin | begin | ||||
| inherited Create; | inherited Create; | ||||
| FillByte(fFeatures, SizeOf(fFeatures), 0); | FillByte(fFeatures, SizeOf(fFeatures), 0); | ||||
| fInstance := aInstance; | |||||
| fLayers := TStringList.Create; | fLayers := TStringList.Create; | ||||
| fExtensions := TStringList.Create; | fExtensions := TStringList.Create; | ||||
| end; | end; | ||||
| @@ -6,32 +6,35 @@ interface | |||||
| uses | uses | ||||
| Classes, SysUtils, | Classes, SysUtils, | ||||
| Vulkan, uvkuPhysicalDevice; | |||||
| Vulkan; | |||||
| type | type | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| TvkuPhysicalDeviceArr = array of VkPhysicalDevice; | TvkuPhysicalDeviceArr = array of VkPhysicalDevice; | ||||
| TvkuInstance = class(TObject) | TvkuInstance = class(TObject) | ||||
| private | private | ||||
| fHandle: VkInstance; | |||||
| fAllocCallbacks: PVkAllocationCallbacks; | |||||
| fPhysicalDevices: TvkuPhysicalDeviceArr; | |||||
| fHandle: VkInstance; | |||||
| fAllocCallbacks: PVkAllocationCallbacks; | |||||
| fPhysicalDevices: TvkuPhysicalDeviceArr; | |||||
| fInstanceCommands: TVkInstanceCommands; | |||||
| function GetPhysicalDeviceCount: Integer; | |||||
| function GetPhysicalDevice(const aIndex: Integer): VkPhysicalDevice; | |||||
| procedure UpdatePhysicalDevices; | procedure UpdatePhysicalDevices; | ||||
| protected | protected | ||||
| procedure CreateHandle(const aCreateInfo: PVkInstanceCreateInfo; const aAllocCallbacks: PVkAllocationCallbacks); | procedure CreateHandle(const aCreateInfo: PVkInstanceCreateInfo; const aAllocCallbacks: PVkAllocationCallbacks); | ||||
| constructor Create; | |||||
| {%H-}constructor Create; | |||||
| public | public | ||||
| property Handle: VkInstance read fHandle; | |||||
| property PhysicalDeviceCount: Integer read GetPhysicalDeviceCount; | |||||
| property PhysicalDevices[const aIndex: Integer]: VkPhysicalDevice read GetPhysicalDevice; | |||||
| property Handle: VkInstance read fHandle; | |||||
| property InstanceCommands: TVkInstanceCommands read fInstanceCommands; | |||||
| function GetPhysicalDevices: TvkuPhysicalDeviceArr; | function GetPhysicalDevices: TvkuPhysicalDeviceArr; | ||||
| constructor Create(const aCreateInfo: TVkInstanceCreateInfo); | |||||
| constructor Create(const aCreateInfo: TVkInstanceCreateInfo; const aAllocCallbacks: TVkAllocationCallbacks); | |||||
| constructor Create( | |||||
| const aCreateInfo: TVkInstanceCreateInfo); | |||||
| constructor Create( | |||||
| const aCreateInfo: TVkInstanceCreateInfo; | |||||
| const aAllocCallbacks: TVkAllocationCallbacks); | |||||
| destructor Destroy; override; | destructor Destroy; override; | ||||
| end; | end; | ||||
| @@ -42,22 +45,6 @@ uses | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| //TvkuInstance/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | //TvkuInstance/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuInstance.GetPhysicalDeviceCount: Integer; | |||||
| begin | |||||
| UpdatePhysicalDevices; | |||||
| result := Length(fPhysicalDevices); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuInstance.GetPhysicalDevice(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; | procedure TvkuInstance.UpdatePhysicalDevices; | ||||
| var | var | ||||
| @@ -67,23 +54,16 @@ begin | |||||
| if (Length(fPhysicalDevices) > 0) then | if (Length(fPhysicalDevices) > 0) then | ||||
| exit; | exit; | ||||
| err := vkEnumeratePhysicalDevices(fHandle, @c, nil); | |||||
| err := InstanceCommands.vkEnumeratePhysicalDevices(fHandle, @c, nil); | |||||
| if (err < VK_SUCCESS) then | if (err < VK_SUCCESS) then | ||||
| raise TvkuErrorException.Create('unable to get physical device number', err); | raise TvkuErrorException.Create('unable to get physical device number', err); | ||||
| SetLength(fPhysicalDevices, c); | SetLength(fPhysicalDevices, c); | ||||
| err := vkEnumeratePhysicalDevices(fHandle, @c, @fPhysicalDevices[0]); | |||||
| err := InstanceCommands.vkEnumeratePhysicalDevices(fHandle, @c, @fPhysicalDevices[0]); | |||||
| if (err < VK_SUCCESS) then | if (err < VK_SUCCESS) then | ||||
| raise TvkuErrorException.Create('unable to get physical devices', err); | raise TvkuErrorException.Create('unable to get physical devices', err); | ||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuInstance.GetPhysicalDevices: TvkuPhysicalDeviceArr; | |||||
| begin | |||||
| UpdatePhysicalDevices; | |||||
| result := fPhysicalDevices; | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| procedure TvkuInstance.CreateHandle(const aCreateInfo: PVkInstanceCreateInfo; const aAllocCallbacks: PVkAllocationCallbacks); | procedure TvkuInstance.CreateHandle(const aCreateInfo: PVkInstanceCreateInfo; const aAllocCallbacks: PVkAllocationCallbacks); | ||||
| var e: TVkResult; | var e: TVkResult; | ||||
| @@ -95,7 +75,9 @@ begin | |||||
| e := vkCreateInstance(aCreateInfo, fAllocCallbacks, @fHandle); | e := vkCreateInstance(aCreateInfo, fAllocCallbacks, @fHandle); | ||||
| if (e < VK_SUCCESS) then | if (e < VK_SUCCESS) then | ||||
| raise TvkuErrorException.Create('unable to create vulkan instance', e); | raise TvkuErrorException.Create('unable to create vulkan instance', e); | ||||
| LoadVulkanCommands(fHandle); | |||||
| fInstanceCommands := LoadInstanceCommands(fHandle); | |||||
| if not Assigned(InstanceCommands) then | |||||
| raise TvkuException.Create('unable to load instance commands'); | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -106,6 +88,13 @@ begin | |||||
| fAllocCallbacks := nil; | fAllocCallbacks := nil; | ||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuInstance.GetPhysicalDevices: TvkuPhysicalDeviceArr; | |||||
| begin | |||||
| UpdatePhysicalDevices; | |||||
| result := fPhysicalDevices; | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| constructor TvkuInstance.Create(const aCreateInfo: TVkInstanceCreateInfo); | constructor TvkuInstance.Create(const aCreateInfo: TVkInstanceCreateInfo); | ||||
| begin | begin | ||||
| @@ -123,14 +112,15 @@ end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| destructor TvkuInstance.Destroy; | destructor TvkuInstance.Destroy; | ||||
| begin | begin | ||||
| if Assigned(fHandle) then begin | |||||
| vkDestroyInstance(fHandle, fAllocCallbacks); | |||||
| if (fHandle <> VK_INVALID_HANDLE) then begin | |||||
| InstanceCommands.vkDestroyInstance(fHandle, fAllocCallbacks); | |||||
| fHandle := nil; | fHandle := nil; | ||||
| end; | end; | ||||
| if Assigned(fAllocCallbacks) then begin | if Assigned(fAllocCallbacks) then begin | ||||
| Dispose(fAllocCallbacks); | Dispose(fAllocCallbacks); | ||||
| fAllocCallbacks := nil; | fAllocCallbacks := nil; | ||||
| end; | end; | ||||
| FreeAndNil(fInstanceCommands); | |||||
| inherited Destroy; | inherited Destroy; | ||||
| end; | end; | ||||
| @@ -1,6 +1,7 @@ | |||||
| unit uvkuInstanceFactory; | unit uvkuInstanceFactory; | ||||
| {$mode objfpc}{$H+} | {$mode objfpc}{$H+} | ||||
| {$I Vulkan.inc} | |||||
| interface | interface | ||||
| @@ -24,10 +25,6 @@ type | |||||
| fAllocHandler: TvkuAllocationHandler; | fAllocHandler: TvkuAllocationHandler; | ||||
| fOwnsHandler: Boolean; | fOwnsHandler: Boolean; | ||||
| public | public | ||||
| constructor Create( | |||||
| const aCreateInfo: TVkInstanceCreateInfo; | |||||
| const aAllocHandler: TvkuAllocationHandler; | |||||
| const aOwnsHandler: Boolean); | |||||
| destructor Destroy; override; | destructor Destroy; override; | ||||
| end; | end; | ||||
| @@ -49,10 +46,14 @@ type | |||||
| property Extensions: TStrings read GetExtensions; | property Extensions: TStrings read GetExtensions; | ||||
| function CreateInstance: TvkuInstance; | function CreateInstance: TvkuInstance; | ||||
| function CreateInstance(const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean): TvkuInstance; | |||||
| function CreateInstance( | |||||
| const aAllocHandler: TvkuAllocationHandler; | |||||
| const aOwnsHandler: Boolean): TvkuInstance; | |||||
| constructor Create; | constructor Create; | ||||
| destructor Destroy; override; | destructor Destroy; override; | ||||
| public | |||||
| class function GetPlatformSurfaceExtensionName: String; | |||||
| end; | end; | ||||
| function vkuApplicationInfo: TvkuApplicationInfo; | function vkuApplicationInfo: TvkuApplicationInfo; | ||||
| @@ -78,7 +79,7 @@ end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| function vkuApplicationInfo(aAppName: String; aAppVersion: VkVersion; aEngineName: String; aEngineVersion: VkVersion; aApiVersion: VkVersion): TvkuApplicationInfo; | function vkuApplicationInfo(aAppName: String; aAppVersion: VkVersion; aEngineName: String; aEngineVersion: VkVersion; aApiVersion: VkVersion): TvkuApplicationInfo; | ||||
| begin | begin | ||||
| result := vkuApplicationInfo; | |||||
| result := vkuApplicationInfo(); | |||||
| result.AppName := aAppName; | result.AppName := aAppName; | ||||
| result.AppVersion := aAppVersion; | result.AppVersion := aAppVersion; | ||||
| result.EngineName := aEngineName; | result.EngineName := aEngineName; | ||||
| @@ -88,16 +89,6 @@ end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| //TvkuInstanceEx///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | //TvkuInstanceEx///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| constructor TvkuInstanceEx.Create(const aCreateInfo: TVkInstanceCreateInfo; const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean); | |||||
| begin | |||||
| fOwnsHandler := aOwnsHandler; | |||||
| fAllocHandler := aAllocHandler; | |||||
| if Assigned(fAllocHandler) | |||||
| then inherited Create(aCreateInfo, fAllocHandler.GetAllocationCallbacks) | |||||
| else inherited Create(aCreateInfo); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| destructor TvkuInstanceEx.Destroy; | destructor TvkuInstanceEx.Destroy; | ||||
| begin | begin | ||||
| @@ -135,7 +126,7 @@ var | |||||
| lay: array of PVkChar; | lay: array of PVkChar; | ||||
| ext: array of PVkChar; | ext: array of PVkChar; | ||||
| begin | begin | ||||
| FillByte(AppInfo, SizeOf(AppInfo), 0); | |||||
| FillByte(AppInfo{%H-}, SizeOf(AppInfo), 0); | |||||
| AppInfo.sType := VK_STRUCTURE_TYPE_APPLICATION_INFO; | AppInfo.sType := VK_STRUCTURE_TYPE_APPLICATION_INFO; | ||||
| AppInfo.pNext := nil; | AppInfo.pNext := nil; | ||||
| AppInfo.pApplicationName := PVkChar(fApplicationInfo.AppName); | AppInfo.pApplicationName := PVkChar(fApplicationInfo.AppName); | ||||
| @@ -152,7 +143,7 @@ begin | |||||
| for i := 0 to fExtensions.Count-1 do | for i := 0 to fExtensions.Count-1 do | ||||
| ext[i] := PVkChar(fExtensions[i]); | ext[i] := PVkChar(fExtensions[i]); | ||||
| FillByte(CreateInfo, SizeOf(CreateInfo), 0); | |||||
| FillByte(CreateInfo{%H-}, SizeOf(CreateInfo), 0); | |||||
| CreateInfo.sType := VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; | CreateInfo.sType := VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; | ||||
| CreateInfo.pNext := nil; | CreateInfo.pNext := nil; | ||||
| CreateInfo.flags := fFlags; | CreateInfo.flags := fFlags; | ||||
| @@ -162,7 +153,16 @@ begin | |||||
| CreateInfo.enabledExtensionCount := Length(ext); | CreateInfo.enabledExtensionCount := Length(ext); | ||||
| CreateInfo.ppEnabledExtensionNames := @ext[0]; | CreateInfo.ppEnabledExtensionNames := @ext[0]; | ||||
| result := TvkuInstanceEx.Create(CreateInfo, aAllocHandler, aOwnsHandler); | |||||
| if Assigned(aAllocHandler) | |||||
| then result := TvkuInstanceEx.Create(CreateInfo, aAllocHandler.GetAllocationCallbacks) | |||||
| else result := TvkuInstanceEx.Create(CreateInfo); | |||||
| try | |||||
| TvkuInstanceEx(result).fAllocHandler := aAllocHandler; | |||||
| TvkuInstanceEx(result).fOwnsHandler := aOwnsHandler; | |||||
| except | |||||
| FreeAndNil(result); | |||||
| raise; | |||||
| end; | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -183,5 +183,25 @@ begin | |||||
| inherited Destroy; | inherited Destroy; | ||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| class function TvkuInstanceFactory.GetPlatformSurfaceExtensionName: String; | |||||
| begin | |||||
| {$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)} | |||||
| result := VK_KHR_XLIB_SURFACE_EXTENSION_NAME; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_XCB_KHR)} | |||||
| result := VK_KHR_XCB_SURFACE_EXTENSION_NAME; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WAYLAND_KHR)} | |||||
| result := VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_MIR_KHR)} | |||||
| result := VK_KHR_MIR_SURFACE_EXTENSION_NAME; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_ANDROID_KHR)} | |||||
| result := VK_KHR_ANDROID_SURFACE_EXTENSION_NAME; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| result := VK_KHR_WIN32_SURFACE_EXTENSION_NAME; | |||||
| {$ELSE} | |||||
| {$ERROR 'unknown or unsupportet platform'} | |||||
| {$ENDIF} | |||||
| end; | |||||
| end. | end. | ||||
| @@ -6,18 +6,25 @@ interface | |||||
| uses | uses | ||||
| Classes, SysUtils, | Classes, SysUtils, | ||||
| Vulkan; | |||||
| Vulkan, uvkuInstance; | |||||
| type | type | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| TVkQueueFamilyPropertiesArr = array of TVkQueueFamilyProperties; | TVkQueueFamilyPropertiesArr = array of TVkQueueFamilyProperties; | ||||
| TVkSparseImageFormatPropertiesArr = array of TVkSparseImageFormatProperties; | TVkSparseImageFormatPropertiesArr = array of TVkSparseImageFormatProperties; | ||||
| TVkSurfaceFormatArr = array of TVkSurfaceFormatKHR; | |||||
| TVkPresentModeArr = array of TVkPresentModeKHR; | |||||
| TVkDisplayPropertiesArr = array of TVkDisplayPropertiesKHR; | |||||
| TVkDisplayPlanePropertiesArr = array of TVkDisplayPlanePropertiesKHR; | |||||
| TVkDisplayArr = array of VkDisplayKHR; | |||||
| TVkDisplayModePropertiesArr = array of TVkDisplayModePropertiesKHR; | |||||
| TvkuPhysicalDevice = class(TObject) | TvkuPhysicalDevice = class(TObject) | ||||
| private | private | ||||
| fHandle: VkPhysicalDevice; | fHandle: VkPhysicalDevice; | ||||
| function GetQueueFamilyProperties(const aIndex: Integer): TVkQueueFamilyProperties; | |||||
| function GetQueueFamilyPropertyCount: Integer; | |||||
| public | |||||
| fInstanceCommands: TVkInstanceCommands; | |||||
| public { VK_VERSION_1_0 } | |||||
| function GetFeatures: TVkPhysicalDeviceFeatures; | function GetFeatures: TVkPhysicalDeviceFeatures; | ||||
| function GetProperties: TVkPhysicalDeviceProperties; | function GetProperties: TVkPhysicalDeviceProperties; | ||||
| function GetMemoryProperties: TVkPhysicalDeviceMemoryProperties; | function GetMemoryProperties: TVkPhysicalDeviceMemoryProperties; | ||||
| @@ -35,18 +42,24 @@ type | |||||
| const aSamples: TVkSampleCountFlagBits; | const aSamples: TVkSampleCountFlagBits; | ||||
| const aUsage: VkImageUsageFlags; | const aUsage: VkImageUsageFlags; | ||||
| const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr; | const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr; | ||||
| 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; | |||||
| public { VK_KHR_surface } | |||||
| function GetSurfaceSupport(const aQueueFamilyIndex: VkUint32; const aSurface: VkSurfaceKHR): Boolean; | |||||
| function GetSurfaceCapabilities(const aSurface: VkSurfaceKHR): TVkSurfaceCapabilitiesKHR; | |||||
| function GetSurfaceFormats(const aSurface: VkSurfaceKHR): TVkSurfaceFormatArr; | |||||
| function GetSurfacePresentModes(const aSurface: VkSurfaceKHR): TVkPresentModeArr; | |||||
| property FormatProperties[const aFormat: TVkFormat]: TVkFormatProperties read GetFormatProperties; | |||||
| public { VK_KHR_display } | |||||
| function GetDisplayProperties: TVkDisplayPropertiesArr; | |||||
| function GetDisplayPlaneProperties: TVkDisplayPlanePropertiesArr; | |||||
| function GetDisplayPlaneSupportedDisplays(const aPlaneIndex: VkUint32): TVkDisplayArr; | |||||
| function GetDisplayModeProperties(const aDisplay: VkDisplayKHR): TVkDisplayModePropertiesArr; | |||||
| constructor Create(const aHandle: VkPhysicalDevice); | |||||
| public | |||||
| property Handle: VkPhysicalDevice read fHandle; | |||||
| property InstanceCommands: TVkInstanceCommands read fInstanceCommands; | |||||
| constructor Create(const aHandle: VkPhysicalDevice; const aInstanceCommands: TVkInstanceCommands); | |||||
| end; | end; | ||||
| implementation | implementation | ||||
| @@ -56,53 +69,47 @@ uses | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| //TvkuPhysicalDevice///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | //TvkuPhysicalDevice///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetQueueFamilyProperties(const aIndex: Integer): TVkQueueFamilyProperties; | |||||
| var arr: TVkQueueFamilyPropertiesArr; | |||||
| begin | |||||
| arr := GetQueueFamilyProperties(); | |||||
| if (aIndex < Low(arr)) or (aIndex > High(arr)) then | |||||
| raise TvkuException.CreateFmt('index (%) out of range (%d : %d)', [aIndex, Low(arr), High(arr)]); | |||||
| result := arr[aIndex]; | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetQueueFamilyPropertyCount: Integer; | |||||
| begin | |||||
| result := Length(GetQueueFamilyProperties); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| function TvkuPhysicalDevice.GetFeatures: TVkPhysicalDeviceFeatures; | function TvkuPhysicalDevice.GetFeatures: TVkPhysicalDeviceFeatures; | ||||
| begin | begin | ||||
| vkGetPhysicalDeviceFeatures(fHandle, @result); | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceFeatures) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceFeatures; did you load the vulkan core commands?'); | |||||
| fInstanceCommands.vkGetPhysicalDeviceFeatures(fHandle, @result); | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| function TvkuPhysicalDevice.GetProperties: TVkPhysicalDeviceProperties; | function TvkuPhysicalDevice.GetProperties: TVkPhysicalDeviceProperties; | ||||
| begin | begin | ||||
| vkGetPhysicalDeviceProperties(fHandle, @result); | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceProperties) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceProperties; did you load the vulkan core commands?'); | |||||
| fInstanceCommands.vkGetPhysicalDeviceProperties(fHandle, @result); | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| function TvkuPhysicalDevice.GetMemoryProperties: TVkPhysicalDeviceMemoryProperties; | function TvkuPhysicalDevice.GetMemoryProperties: TVkPhysicalDeviceMemoryProperties; | ||||
| begin | begin | ||||
| vkGetPhysicalDeviceMemoryProperties(fHandle, @result); | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceMemoryProperties) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceMemoryProperties; did you load the vulkan core commands?'); | |||||
| fInstanceCommands.vkGetPhysicalDeviceMemoryProperties(fHandle, @result); | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| function TvkuPhysicalDevice.GetQueueFamilyProperties: TVkQueueFamilyPropertiesArr; | function TvkuPhysicalDevice.GetQueueFamilyProperties: TVkQueueFamilyPropertiesArr; | ||||
| var c: VkUint32; | var c: VkUint32; | ||||
| begin | begin | ||||
| vkGetPhysicalDeviceQueueFamilyProperties(fHandle, @c, nil); | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceQueueFamilyProperties) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceQueueFamilyProperties; did you load the vulkan core commands?'); | |||||
| fInstanceCommands.vkGetPhysicalDeviceQueueFamilyProperties(fHandle, @c, nil); | |||||
| SetLength(result, c); | SetLength(result, c); | ||||
| vkGetPhysicalDeviceQueueFamilyProperties(fHandle, @c, @result[0]); | |||||
| fInstanceCommands.vkGetPhysicalDeviceQueueFamilyProperties(fHandle, @c, @result[0]); | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| function TvkuPhysicalDevice.GetFormatProperties(const aFormat: TVkFormat): TVkFormatProperties; | function TvkuPhysicalDevice.GetFormatProperties(const aFormat: TVkFormat): TVkFormatProperties; | ||||
| begin | begin | ||||
| vkGetPhysicalDeviceFormatProperties(fHandle, aFormat, @result); | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceFormatProperties) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceFormatProperties; did you load the vulkan core commands?'); | |||||
| fInstanceCommands.vkGetPhysicalDeviceFormatProperties(fHandle, aFormat, @result); | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -110,7 +117,9 @@ function TvkuPhysicalDevice.GetImageFormatProperties(const aFormat: TVkFormat; c | |||||
| const aTiling: TVkImageTiling; const aUsage: VkImageUsageFlags; const aFlags: VkImageCreateFlags): TVkImageFormatProperties; | const aTiling: TVkImageTiling; const aUsage: VkImageUsageFlags; const aFlags: VkImageCreateFlags): TVkImageFormatProperties; | ||||
| var err: TVkResult; | var err: TVkResult; | ||||
| begin | begin | ||||
| err := vkGetPhysicalDeviceImageFormatProperties(fHandle, aFormat, aImageType, aTiling, aUsage, aFlags, @result); | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceImageFormatProperties) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceImageFormatProperties; did you load the vulkan core commands?'); | |||||
| err := fInstanceCommands.vkGetPhysicalDeviceImageFormatProperties(fHandle, aFormat, aImageType, aTiling, aUsage, aFlags, @result); | |||||
| if (err < VK_SUCCESS) then | if (err < VK_SUCCESS) then | ||||
| raise TvkuErrorException.Create('unable to get physical device image format properties', err); | raise TvkuErrorException.Create('unable to get physical device image format properties', err); | ||||
| end; | end; | ||||
| @@ -120,18 +129,145 @@ function TvkuPhysicalDevice.GetSparseImageFormatProperties(const aFormat: TVkFor | |||||
| const aSamples: TVkSampleCountFlagBits; const aUsage: VkImageUsageFlags; const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr; | const aSamples: TVkSampleCountFlagBits; const aUsage: VkImageUsageFlags; const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr; | ||||
| var c: VkUint32; | var c: VkUint32; | ||||
| begin | begin | ||||
| vkGetPhysicalDeviceSparseImageFormatProperties(fHandle, aFormat, aImageType, aSamples, aUsage, aTiling, @c, nil); | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSparseImageFormatProperties) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSparseImageFormatProperties; did you load the vulkan core commands?'); | |||||
| fInstanceCommands.vkGetPhysicalDeviceSparseImageFormatProperties(fHandle, aFormat, aImageType, aSamples, aUsage, aTiling, @c, nil); | |||||
| SetLength(result, c); | |||||
| fInstanceCommands.vkGetPhysicalDeviceSparseImageFormatProperties(fHandle, aFormat, aImageType, aSamples, aUsage, aTiling, @c, @result[0]); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetSurfaceSupport(const aQueueFamilyIndex: VkUint32; const aSurface: VkSurfaceKHR): Boolean; | |||||
| var | |||||
| b: VkBool32; | |||||
| err: TVkResult; | |||||
| begin | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSurfaceSupportKHR) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSurfaceSupportKHR; did you enabled the VK_KHR_surface extension?'); | |||||
| err := fInstanceCommands.vkGetPhysicalDeviceSurfaceSupportKHR(fHandle, aQueueFamilyIndex, aSurface, @b); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get physical device surface support', err); | |||||
| result := (b <> 0); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetSurfaceCapabilities(const aSurface: VkSurfaceKHR): TVkSurfaceCapabilitiesKHR; | |||||
| var | |||||
| err: TVkResult; | |||||
| begin | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSurfaceCapabilitiesKHR) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSurfaceCapabilitiesKHR; did you enabled the VK_KHR_surface extension?'); | |||||
| err := fInstanceCommands.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(fHandle, aSurface, @result); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get physical device surface capabilities', err); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetSurfaceFormats(const aSurface: VkSurfaceKHR): TVkSurfaceFormatArr; | |||||
| var c: VkUint32; | |||||
| begin | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSurfaceFormatsKHR) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSurfaceFormatsKHR; did you enabled the VK_KHR_surface extension?'); | |||||
| fInstanceCommands.vkGetPhysicalDeviceSurfaceFormatsKHR(fHandle, aSurface, @c, nil); | |||||
| SetLength(result, c); | |||||
| fInstanceCommands.vkGetPhysicalDeviceSurfaceFormatsKHR(fHandle, aSurface, @c, @result[0]); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetSurfacePresentModes(const aSurface: VkSurfaceKHR): TVkPresentModeArr; | |||||
| var | |||||
| c: VkUint32; | |||||
| err: TVkResult; | |||||
| begin | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSurfacePresentModesKHR) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSurfacePresentModesKHR; did you enabled the VK_KHR_surface extension?'); | |||||
| err := fInstanceCommands.vkGetPhysicalDeviceSurfacePresentModesKHR(fHandle, aSurface, @c, nil); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get physical device surface present mode count', err); | |||||
| SetLength(result, c); | |||||
| err := fInstanceCommands.vkGetPhysicalDeviceSurfacePresentModesKHR(fHandle, aSurface, @c, @result[0]); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get physical device surface present modes', err); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetDisplayProperties: TVkDisplayPropertiesArr; | |||||
| var | |||||
| err: TVkResult; | |||||
| c: VkUint32; | |||||
| begin | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceDisplayPropertiesKHR) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceDisplayPropertiesKHR; did you enabled the VK_KHR_display extension?'); | |||||
| err := fInstanceCommands.vkGetPhysicalDeviceDisplayPropertiesKHR(fHandle, @c, nil); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get physical device display property count', err); | |||||
| SetLength(result, c); | |||||
| err := fInstanceCommands.vkGetPhysicalDeviceDisplayPropertiesKHR(fHandle, @c, @result[0]); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get physical device display properties', err); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetDisplayPlaneProperties: TVkDisplayPlanePropertiesArr; | |||||
| var | |||||
| err: TVkResult; | |||||
| c: VkUint32; | |||||
| begin | |||||
| if not Assigned(fInstanceCommands.vkGetPhysicalDeviceDisplayPlanePropertiesKHR) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceDisplayPlanePropertiesKHR; did you enabled the VK_KHR_display extension?'); | |||||
| err := fInstanceCommands.vkGetPhysicalDeviceDisplayPlanePropertiesKHR(fHandle, @c, nil); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get physical device display plane property count', err); | |||||
| SetLength(result, c); | |||||
| err := fInstanceCommands.vkGetPhysicalDeviceDisplayPlanePropertiesKHR(fHandle, @c, @result[0]); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get physical device display plane properties', err); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetDisplayPlaneSupportedDisplays(const aPlaneIndex: VkUint32): TVkDisplayArr; | |||||
| var | |||||
| err: TVkResult; | |||||
| c: VkUint32; | |||||
| begin | |||||
| if not Assigned(fInstanceCommands.vkGetDisplayPlaneSupportedDisplaysKHR) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetDisplayPlaneSupportedDisplaysKHR; did you enabled the VK_KHR_display extension?'); | |||||
| err := fInstanceCommands.vkGetDisplayPlaneSupportedDisplaysKHR(fHandle, aPlaneIndex, @c, nil); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get supported display plane count', err); | |||||
| SetLength(result, c); | SetLength(result, c); | ||||
| vkGetPhysicalDeviceSparseImageFormatProperties(fHandle, aFormat, aImageType, aSamples, aUsage, aTiling, @c, @result[0]); | |||||
| err := fInstanceCommands.vkGetDisplayPlaneSupportedDisplaysKHR(fHandle, aPlaneIndex, @c, @result[0]); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get supported display planes', err); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuPhysicalDevice.GetDisplayModeProperties(const aDisplay: VkDisplayKHR): TVkDisplayModePropertiesArr; | |||||
| var | |||||
| err: TVkResult; | |||||
| c: VkUint32; | |||||
| begin | |||||
| if not Assigned(fInstanceCommands.vkGetDisplayModePropertiesKHR) then | |||||
| raise TvkuException.Create('invalid function pointer: vkGetDisplayModePropertiesKHR; did you enabled the VK_KHR_display extension?'); | |||||
| err := fInstanceCommands.vkGetDisplayModePropertiesKHR(fHandle, aDisplay, @c, nil); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get display mode property count', err); | |||||
| SetLength(result, c); | |||||
| err := fInstanceCommands.vkGetDisplayPlaneSupportedDisplaysKHR(fHandle, aDisplay, @c, @result[0]); | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to get display mode properties', err); | |||||
| end; | end; | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| constructor TvkuPhysicalDevice.Create(const aHandle: VkPhysicalDevice); | |||||
| constructor TvkuPhysicalDevice.Create(const aHandle: VkPhysicalDevice; const aInstanceCommands: TVkInstanceCommands); | |||||
| begin | begin | ||||
| if not Assigned(aHandle) then | |||||
| if (aHandle = VK_INVALID_HANDLE) then | |||||
| raise TvkuException.Create('invalid physical device handle'); | raise TvkuException.Create('invalid physical device handle'); | ||||
| if not Assigned(aInstanceCommands) then | |||||
| raise TvkuException.Create('invalid instance commands'); | |||||
| inherited Create; | inherited Create; | ||||
| fHandle := aHandle; | |||||
| fHandle := aHandle; | |||||
| fInstanceCommands := aInstanceCommands; | |||||
| end; | end; | ||||
| end. | end. | ||||
| @@ -6,13 +6,18 @@ interface | |||||
| uses | uses | ||||
| Classes, SysUtils, | Classes, SysUtils, | ||||
| Vulkan, uvkuPhysicalDevice; | |||||
| Vulkan, uvkuInstance, uvkuPhysicalDevice; | |||||
| type | type | ||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| TvkuPhysicalDeviceFactory = class(TObject) | TvkuPhysicalDeviceFactory = class(TObject) | ||||
| private | |||||
| fInstance: TvkuInstance; | |||||
| public | public | ||||
| function CreatePhysicalDevice(const aHandle: VkPhysicalDevice): TvkuPhysicalDevice; | |||||
| function CreatePhysicalDevice( | |||||
| const aHandle: VkPhysicalDevice): TvkuPhysicalDevice; | |||||
| constructor Create(const aInstance: TvkuInstance); | |||||
| end; | end; | ||||
| implementation | implementation | ||||
| @@ -22,7 +27,14 @@ implementation | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| function TvkuPhysicalDeviceFactory.CreatePhysicalDevice(const aHandle: VkPhysicalDevice): TvkuPhysicalDevice; | function TvkuPhysicalDeviceFactory.CreatePhysicalDevice(const aHandle: VkPhysicalDevice): TvkuPhysicalDevice; | ||||
| begin | begin | ||||
| result := TvkuPhysicalDevice.Create(aHandle); | |||||
| result := TvkuPhysicalDevice.Create(aHandle, fInstance.InstanceCommands); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| constructor TvkuPhysicalDeviceFactory.Create(const aInstance: TvkuInstance); | |||||
| begin | |||||
| inherited Create; | |||||
| fInstance := aInstance; | |||||
| end; | end; | ||||
| end. | end. | ||||
| @@ -0,0 +1,104 @@ | |||||
| unit uvkuSurface; | |||||
| {$mode objfpc}{$H+} | |||||
| {$I Vulkan.inc} | |||||
| interface | |||||
| uses | |||||
| Classes, SysUtils, | |||||
| Vulkan; | |||||
| type | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| TvkuSurface = class(TObject) | |||||
| private | |||||
| fHandle: VkSurfaceKHR; | |||||
| fInstance: VkInstance; | |||||
| fAllocCallbacks: PVkAllocationCallbacks; | |||||
| fInstanceCommands: TVkInstanceCommands; | |||||
| procedure CreateHandle(const aCreateInfo: Pointer; const aAllocCallbacks: PVkAllocationCallbacks); | |||||
| public | |||||
| property Handle: VkSurfaceKHR read fHandle; | |||||
| property Instance: VkInstance read fInstance; | |||||
| property InstanceCommands: TVkInstanceCommands read fInstanceCommands; | |||||
| {$IF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| constructor Create( | |||||
| const aInstance: VkInstance; | |||||
| const aCreateInfo: TVkWin32SurfaceCreateInfoKHR; | |||||
| const aInstanceCommands: TVkInstanceCommands); | |||||
| constructor Create( | |||||
| const aInstance: VkInstance; | |||||
| const aCreateInfo: TVkWin32SurfaceCreateInfoKHR; | |||||
| const aInstanceCommands: TVkInstanceCommands; | |||||
| const aAllocCallbacks: TVkAllocationCallbacks); | |||||
| {$ELSE} | |||||
| {$ERROR 'unknown or unsupportet platform'} | |||||
| {$ENDIF} | |||||
| destructor Destroy; override; | |||||
| end; | |||||
| implementation | |||||
| uses | |||||
| uvkuUtils; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| //TvkuSurface//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurface.CreateHandle(const aCreateInfo: Pointer; const aAllocCallbacks: PVkAllocationCallbacks); | |||||
| var err: TVkResult; | |||||
| begin | |||||
| if Assigned(aAllocCallbacks) then begin | |||||
| new(fAllocCallbacks); | |||||
| fAllocCallbacks^ := aAllocCallbacks^; | |||||
| end; | |||||
| {$IF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| if not Assigned(fInstanceCommands.vkCreateWin32SurfaceKHR) then | |||||
| raise TvkuException.Create('invalid function pointer: vkCreateWin32SurfaceKHR; did you enabled the VK_KHR_win32_surface extension?'); | |||||
| err := fInstanceCommands.vkCreateWin32SurfaceKHR(fInstance, aCreateInfo, fAllocCallbacks, @fHandle); | |||||
| {$ENDIF} | |||||
| if (err < VK_SUCCESS) then | |||||
| raise TvkuErrorException.Create('unable to create surface', err); | |||||
| end; | |||||
| {$IF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| constructor TvkuSurface.Create(const aInstance: VkInstance; const aCreateInfo: TVkWin32SurfaceCreateInfoKHR; | |||||
| const aInstanceCommands: TVkInstanceCommands); | |||||
| begin | |||||
| inherited Create; | |||||
| fInstance := aInstance; | |||||
| fInstanceCommands := aInstanceCommands; | |||||
| CreateHandle(@aCreateInfo, nil); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| constructor TvkuSurface.Create(const aInstance: VkInstance; const aCreateInfo: TVkWin32SurfaceCreateInfoKHR; | |||||
| const aInstanceCommands: TVkInstanceCommands; const aAllocCallbacks: TVkAllocationCallbacks); | |||||
| begin | |||||
| inherited Create; | |||||
| fInstance := aInstance; | |||||
| fInstanceCommands := aInstanceCommands; | |||||
| CreateHandle(@aCreateInfo, @aAllocCallbacks); | |||||
| end; | |||||
| {$ENDIF} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| destructor TvkuSurface.Destroy; | |||||
| begin | |||||
| if (fHandle <> VK_INVALID_NDP_HANDLE) then begin | |||||
| fInstanceCommands.vkDestroySurfaceKHR(fInstance, fHandle, fAllocCallbacks); | |||||
| fHandle := 0; | |||||
| end; | |||||
| if Assigned(fAllocCallbacks) then begin | |||||
| Dispose(fAllocCallbacks); | |||||
| fAllocCallbacks := nil; | |||||
| end; | |||||
| inherited Destroy; | |||||
| end; | |||||
| end. | |||||
| @@ -0,0 +1,230 @@ | |||||
| unit uvkuSurfaceFactory; | |||||
| {$mode objfpc}{$H+} | |||||
| {$I Vulkan.inc} | |||||
| interface | |||||
| uses | |||||
| Classes, SysUtils, Controls, | |||||
| Vulkan, uvkuInstance, uvkuSurface, uvkuAllocationHandler; | |||||
| type | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| TvkuSurfaceEx = class(TvkuSurface) | |||||
| private | |||||
| fAllocHandler: TvkuAllocationHandler; | |||||
| fOwnsHandler: Boolean; | |||||
| public | |||||
| destructor Destroy; override; | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| TvkuSurfaceFactory = class(TObject) | |||||
| {$IF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| private | |||||
| fHInstance: Vulkan.HINSTANCE; | |||||
| fHwnd: Vulkan.HWND; | |||||
| procedure SetHwnd(const aValue: Vulkan.HWND); | |||||
| public | |||||
| property HInstance: Vulkan.HINSTANCE read fHInstance write fHInstance; | |||||
| property Hwnd: Vulkan.HWND read fHwnd write SetHwnd; | |||||
| {$ENDIF} | |||||
| private | |||||
| fFlags: VkFlags; | |||||
| fWinControl: TWinControl; | |||||
| fInstance: TvkuInstance; | |||||
| procedure SetWinControl(aValue: TWinControl); | |||||
| public | |||||
| property WinControl: TWinControl read fWinControl write SetWinControl; | |||||
| property Flags: VkFlags read fFlags write fFlags; | |||||
| function CreateSurface: TvkuSurface; | |||||
| function CreateSurface( | |||||
| const aAllocHandler: TvkuAllocationHandler; | |||||
| const aOwnsHandler: Boolean): TvkuSurface; | |||||
| constructor Create(const aInstance: TvkuInstance); | |||||
| end; | |||||
| implementation | |||||
| {$IF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| uses Windows; | |||||
| {$ENDIF} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| //TvkuSurfaceEx////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| destructor TvkuSurfaceEx.Destroy; | |||||
| begin | |||||
| inherited Destroy; | |||||
| if fOwnsHandler then | |||||
| FreeAndNil(fAllocHandler); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| //TvkuSurfaceFactory///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| {$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| procedure TvkuSurfaceFactory.SetDisplay(const aValue: TDisplay); | |||||
| begin | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetWindow(const aValue: TWindow); | |||||
| begin | |||||
| end; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_XCB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetConnection(const aValue: xcb_connection_t); | |||||
| begin | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetWindow(const aValue: xcb_window_t); | |||||
| begin | |||||
| end; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WAYLAND_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetDisplay(const aValue: wl_display); | |||||
| begin | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetSurface(const aValue: wl_surface); | |||||
| begin | |||||
| end; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_MIR_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetConnection(const aValue: MirConnection); | |||||
| begin | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetSurface(const aValue: MirSurface); | |||||
| begin | |||||
| end; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_ANDROID_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetWindow(const aValue: ANativeWindow); | |||||
| begin | |||||
| end; | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetHwnd(const aValue: Vulkan.HWND); | |||||
| begin | |||||
| SetWinControl(nil); | |||||
| fHwnd := aValue; | |||||
| end; | |||||
| {$ENDIF} | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| procedure TvkuSurfaceFactory.SetWinControl(aValue: TWinControl); | |||||
| begin | |||||
| if fWinControl = aValue then | |||||
| exit; | |||||
| fWinControl := aValue; | |||||
| {$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_XCB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WAYLAND_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_MIR_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_ANDROID_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| fHwnd := Vulkan.HWND(fWinControl.Handle); | |||||
| {$ENDIF} | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuSurfaceFactory.CreateSurface: TvkuSurface; | |||||
| begin | |||||
| result := CreateSurface(nil, false); | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| function TvkuSurfaceFactory.CreateSurface(const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean): TvkuSurface; | |||||
| {$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_XCB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WAYLAND_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_MIR_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_ANDROID_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| var CreateInfo: TVkWin32SurfaceCreateInfoKHR; | |||||
| {$ENDIF} | |||||
| var srf: TvkuSurfaceEx; | |||||
| begin | |||||
| {$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_XCB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WAYLAND_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_MIR_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_ANDROID_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| FillByte(CreateInfo, SizeOf(CreateInfo), 0); | |||||
| CreateInfo.sType := VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; | |||||
| CreateInfo.pNext := nil; | |||||
| CreateInfo.flags := fFlags; | |||||
| CreateInfo.hinstance := fHInstance; | |||||
| CreateInfo.hwnd := fHwnd; | |||||
| {$ENDIF} | |||||
| if Assigned(aAllocHandler) | |||||
| then srf := TvkuSurfaceEx.Create(fInstance.Handle, CreateInfo, fInstance.InstanceCommands, aAllocHandler.GetAllocationCallbacks) | |||||
| else srf := TvkuSurfaceEx.Create(fInstance.Handle, CreateInfo, fInstance.InstanceCommands); | |||||
| try | |||||
| srf.fAllocHandler := aAllocHandler; | |||||
| srf.fOwnsHandler := aOwnsHandler; | |||||
| except | |||||
| FreeAndNil(srf); | |||||
| end; | |||||
| result := srf; | |||||
| end; | |||||
| ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||||
| constructor TvkuSurfaceFactory.Create(const aInstance: TvkuInstance); | |||||
| begin | |||||
| inherited Create; | |||||
| {$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_XCB_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WAYLAND_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_MIR_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_ANDROID_KHR)} | |||||
| {$ERROR 'TODO: implement'} | |||||
| {$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} | |||||
| fHInstance := Vulkan.HINSTANCE(GetModuleHandle(nil)); | |||||
| {$ENDIF} | |||||
| fInstance := aInstance; | |||||
| fFlags := 0; | |||||
| end; | |||||
| end. | |||||