您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

89 行
3.3 KiB

  1. unit uvkuQueue;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan, uvkuBase;
  7. type
  8. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. TvkuQueue = class(TvkuObject)
  10. private
  11. fHandle: VkQueue;
  12. fDeviceCommands: TVkDeviceCommands;
  13. public
  14. property Handle: VkQueue read fHandle;
  15. property DeviceCommands: TVkDeviceCommands read fDeviceCommands;
  16. procedure Submit(
  17. const aWaitSemaphores: array of VkSemaphore;
  18. const aWaitDstStageMask: array of VkSemaphore;
  19. const aCommandBuffers: array of VkCommandBuffer;
  20. const aSignalSemaphores: array of VkSemaphore;
  21. const aFence: VkFence);
  22. procedure WaitIdle;
  23. constructor Create(
  24. const aHandle: VkQueue;
  25. const aDeviceCommands: TVkDeviceCommands);
  26. end;
  27. implementation
  28. uses
  29. uvkuUtils;
  30. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. //TvkuQueue//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  32. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  33. procedure TvkuQueue.Submit(
  34. const aWaitSemaphores: array of VkSemaphore;
  35. const aWaitDstStageMask: array of VkSemaphore;
  36. const aCommandBuffers: array of VkCommandBuffer;
  37. const aSignalSemaphores: array of VkSemaphore;
  38. const aFence: VkFence);
  39. var
  40. SubmitInfo: TVkSubmitInfo;
  41. err: TVkResult;
  42. begin
  43. if Length(aWaitSemaphores) <> Length(aWaitDstStageMask) then
  44. raise TvkuException.Create('aWaitSemaphores and aWaitDstStageMask must have the same number of elements');
  45. FillByte(SubmitInfo, SizeOf(SubmitInfo), 0);
  46. SubmitInfo.sType := VK_STRUCTURE_TYPE_SUBMIT_INFO;
  47. SubmitInfo.pNext := nil;
  48. SubmitInfo.waitSemaphoreCount := Length(aWaitSemaphores);
  49. SubmitInfo.pWaitSemaphores := @aWaitSemaphores[0];
  50. SubmitInfo.pWaitDstStageMask := @aWaitDstStageMask[0];
  51. SubmitInfo.commandBufferCount := Length(aCommandBuffers);
  52. SubmitInfo.pCommandBuffers := @aCommandBuffers[0];
  53. SubmitInfo.signalSemaphoreCount := Length(aSignalSemaphores);
  54. SubmitInfo.pSignalSemaphores := @aSignalSemaphores[0];
  55. err := fDeviceCommands.vkQueueSubmit(fHandle, 1, @SubmitInfo, aFence);
  56. if (err < VK_SUCCESS) then
  57. raise TvkuErrorException.Create('unable to submit queue', err);
  58. end;
  59. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  60. procedure TvkuQueue.WaitIdle;
  61. var err: TVkResult;
  62. begin
  63. err := fDeviceCommands.vkQueueWaitIdle(fHandle);
  64. if (err < VK_SUCCESS) then
  65. raise TvkuErrorException.Create('error while waiting for queue', err);
  66. end;
  67. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  68. constructor TvkuQueue.Create(const aHandle: VkQueue; const aDeviceCommands: TVkDeviceCommands);
  69. begin
  70. inherited Create;
  71. fHandle := aHandle;
  72. fDeviceCommands := aDeviceCommands;
  73. end;
  74. end.