unit uvkuQueue; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Vulkan, uvkuBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TvkuQueue = class(TvkuObject) private fHandle: VkQueue; fDeviceCommands: TVkDeviceCommands; public property Handle: VkQueue read fHandle; property DeviceCommands: TVkDeviceCommands read fDeviceCommands; procedure Submit( const aWaitSemaphores: array of VkSemaphore; const aWaitDstStageMask: array of VkSemaphore; const aCommandBuffers: array of VkCommandBuffer; const aSignalSemaphores: array of VkSemaphore; const aFence: VkFence); procedure WaitIdle; constructor Create( const aHandle: VkQueue; const aDeviceCommands: TVkDeviceCommands); end; implementation uses uvkuUtils; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TvkuQueue////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TvkuQueue.Submit( const aWaitSemaphores: array of VkSemaphore; const aWaitDstStageMask: array of VkSemaphore; const aCommandBuffers: array of VkCommandBuffer; const aSignalSemaphores: array of VkSemaphore; const aFence: VkFence); var SubmitInfo: TVkSubmitInfo; err: TVkResult; begin if Length(aWaitSemaphores) <> Length(aWaitDstStageMask) then raise TvkuException.Create('aWaitSemaphores and aWaitDstStageMask must have the same number of elements'); FillByte(SubmitInfo, SizeOf(SubmitInfo), 0); SubmitInfo.sType := VK_STRUCTURE_TYPE_SUBMIT_INFO; SubmitInfo.pNext := nil; SubmitInfo.waitSemaphoreCount := Length(aWaitSemaphores); SubmitInfo.pWaitSemaphores := @aWaitSemaphores[0]; SubmitInfo.pWaitDstStageMask := @aWaitDstStageMask[0]; SubmitInfo.commandBufferCount := Length(aCommandBuffers); SubmitInfo.pCommandBuffers := @aCommandBuffers[0]; SubmitInfo.signalSemaphoreCount := Length(aSignalSemaphores); SubmitInfo.pSignalSemaphores := @aSignalSemaphores[0]; err := fDeviceCommands.vkQueueSubmit(fHandle, 1, @SubmitInfo, aFence); if (err < VK_SUCCESS) then raise TvkuErrorException.Create('unable to submit queue', err); end; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TvkuQueue.WaitIdle; var err: TVkResult; begin err := fDeviceCommands.vkQueueWaitIdle(fHandle); if (err < VK_SUCCESS) then raise TvkuErrorException.Create('error while waiting for queue', err); end; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor TvkuQueue.Create(const aHandle: VkQueue; const aDeviceCommands: TVkDeviceCommands); begin inherited Create; fHandle := aHandle; fDeviceCommands := aDeviceCommands; end; end.