unit uvkuDescriptorSetLayout; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Vulkan, uvkuBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TvkuDescriptorSetLayout = class(TvkuAllocHandle) private fHandle: VkDescriptorSetLayout; fDeviceCommands: TVkDeviceCommands; procedure CreateHandle(const aCreateInfo: TVkDescriptorSetLayoutCreateInfo); public property Handle: VkDescriptorSetLayout read fHandle; property DeviceCommands: TVkDeviceCommands read fDeviceCommands; constructor Create( const aCreateInfo: TVkDescriptorSetLayoutCreateInfo; const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks = nil); constructor Create( const aHandle: VkDescriptorSetLayout; const aOwnsHandle: Boolean; const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks = nil); destructor Destroy; override; end; implementation uses uvkuUtils; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TvkuDescriptorSetLayout//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TvkuDescriptorSetLayout.CreateHandle(const aCreateInfo: TVkDescriptorSetLayoutCreateInfo); var err: TVkResult; begin if not Assigned(fDeviceCommands.vkCreateDescriptorSetLayout) then raise TvkuInvalidFuncPtrException.Create('vkCreateDescriptorSetLayout'); err := fDeviceCommands.vkCreateDescriptorSetLayout(fDeviceCommands.Device, @aCreateInfo, AllocCallbacks, @fHandle); if (err <> VK_SUCCESS) then raise TvkuErrorException.Create('unable to create descriptor set layout', err); end; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor TvkuDescriptorSetLayout.Create(const aCreateInfo: TVkDescriptorSetLayoutCreateInfo; const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks); begin inherited Create; fDeviceCommands := aDeviceCommands; SetAllocCallbacks(aAllocCallbacks); CreateHandle(aCreateInfo); end; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor TvkuDescriptorSetLayout.Create(const aHandle: VkDescriptorSetLayout; const aOwnsHandle: Boolean; const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks); begin inherited Create; fHandle := aHandle; fDeviceCommands := aDeviceCommands; OwnsHandle := aOwnsHandle; SetAllocCallbacks(aAllocCallbacks); end; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// destructor TvkuDescriptorSetLayout.Destroy; begin if OwnsHandle and (fHandle <> VK_INVALID_NDP_HANDLE) then fDeviceCommands.vkDestroyDescriptorSetLayout(fDeviceCommands.Device, fHandle, AllocCallbacks); fHandle := VK_INVALID_NDP_HANDLE; inherited Destroy; end; end.