Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

78 linhas
2.7 KiB

  1. unit uvkuCommandBuffer;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan, uvkuBase;
  7. type
  8. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. TvkuCommandBuffer = class(TvkuHandle)
  10. private
  11. fHandle: VkCommandBuffer;
  12. fCommandPool: VkCommandPool;
  13. fDeviceCommands: TVkDeviceCommands;
  14. public
  15. property Handle: VkCommandBuffer read fHandle;
  16. property CommandPool: VkCommandPool read fCommandPool;
  17. property DeviceCommands: TVkDeviceCommands read fDeviceCommands;
  18. procedure BeginCommand;
  19. constructor Create(
  20. const aHandle: VkCommandBuffer;
  21. const aOwnsHandle: Boolean;
  22. const aCommandPool: VkCommandPool;
  23. const aDeviceCommands: TVkDeviceCommands);
  24. destructor Destroy; override;
  25. end;
  26. implementation
  27. uses
  28. uvkuUtils;
  29. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  30. //TvkuCommandBuffer//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  32. procedure TvkuCommandBuffer.BeginCommand;
  33. var
  34. Info: TVkCommandBufferBeginInfo;
  35. err: TVkResult;
  36. begin
  37. FillByte(Info, SizeOf(Info), 0);
  38. Info.sType := VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
  39. Info.pNext := nil;
  40. Info.flags := []; // TODO
  41. Info.pInheritanceInfo := nil; // TODO
  42. err := DeviceCommands.vkBeginCommandBuffer(fHandle, @Info);
  43. if (err < VK_SUCCESS) then
  44. raise TvkuErrorException.Create('unable to begin command buffer', err);
  45. end;
  46. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  47. constructor TvkuCommandBuffer.Create(const aHandle: VkCommandBuffer; const aOwnsHandle: Boolean;
  48. const aCommandPool: VkCommandPool; const aDeviceCommands: TVkDeviceCommands);
  49. begin
  50. inherited Create;
  51. fHandle := aHandle;
  52. fCommandPool := aCommandPool;
  53. fDeviceCommands := aDeviceCommands;
  54. OwnsHandle := aOwnsHandle;
  55. end;
  56. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  57. destructor TvkuCommandBuffer.Destroy;
  58. begin
  59. if OwnsHandle and (fHandle <> VK_INVALID_HANDLE) then
  60. fDeviceCommands.vkFreeCommandBuffers(fDeviceCommands.Device, fCommandPool, 1, @fHandle);
  61. fHandle := VK_INVALID_HANDLE;
  62. inherited Destroy;
  63. end;
  64. end.