unit uvkuCommandBuffer; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Vulkan, uvkuBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TvkuCommandBuffer = class(TvkuHandle) private fHandle: VkCommandBuffer; fCommandPool: VkCommandPool; fDeviceCommands: TVkDeviceCommands; public property Handle: VkCommandBuffer read fHandle; property CommandPool: VkCommandPool read fCommandPool; property DeviceCommands: TVkDeviceCommands read fDeviceCommands; procedure BeginCommand; constructor Create( const aHandle: VkCommandBuffer; const aOwnsHandle: Boolean; const aCommandPool: VkCommandPool; const aDeviceCommands: TVkDeviceCommands); destructor Destroy; override; end; implementation uses uvkuUtils; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TvkuCommandBuffer////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TvkuCommandBuffer.BeginCommand; var Info: TVkCommandBufferBeginInfo; err: TVkResult; begin FillByte(Info, SizeOf(Info), 0); Info.sType := VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; Info.pNext := nil; Info.flags := []; // TODO Info.pInheritanceInfo := nil; // TODO err := DeviceCommands.vkBeginCommandBuffer(fHandle, @Info); if (err < VK_SUCCESS) then raise TvkuErrorException.Create('unable to begin command buffer', err); end; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor TvkuCommandBuffer.Create(const aHandle: VkCommandBuffer; const aOwnsHandle: Boolean; const aCommandPool: VkCommandPool; const aDeviceCommands: TVkDeviceCommands); begin inherited Create; fHandle := aHandle; fCommandPool := aCommandPool; fDeviceCommands := aDeviceCommands; OwnsHandle := aOwnsHandle; end; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// destructor TvkuCommandBuffer.Destroy; begin if OwnsHandle and (fHandle <> VK_INVALID_HANDLE) then fDeviceCommands.vkFreeCommandBuffers(fDeviceCommands.Device, fCommandPool, 1, @fHandle); fHandle := VK_INVALID_HANDLE; inherited Destroy; end; end.