25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

93 satır
3.8 KiB

  1. unit uvkuCommandPoolFactory;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan, uvkuCommandPool, uvkuDevice, uvkuAllocationHandler;
  7. type
  8. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. TvkuCommandPoolEx = class(TvkuCommandPool)
  10. private
  11. fAllocHandler: TvkuAllocationHandler;
  12. fOwnsHandler: Boolean;
  13. public
  14. destructor Destroy; override;
  15. end;
  16. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  17. TvkuCommandPoolFactory = class(TObject)
  18. private
  19. fDeviceCommands: TVkDeviceCommands;
  20. fFlags: VkCommandPoolCreateFlags;
  21. fQueueFamilyIndex: VkUint32;
  22. public
  23. function CreateCommandPool: TvkuCommandPoolEx;
  24. function CreateCommandPool(
  25. const aAllocHandler: TvkuAllocationHandler;
  26. const aOwnsHandler: Boolean): TvkuCommandPoolEx;
  27. constructor Create(const aDevice: TvkuDevice);
  28. constructor Create(const aDeviceCommands: TVkDeviceCommands);
  29. end;
  30. implementation
  31. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  32. //TvkuCommandPoolEx//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  33. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  34. destructor TvkuCommandPoolEx.Destroy;
  35. begin
  36. if fOwnsHandler then
  37. FreeAndNil(fAllocHandler);
  38. inherited Destroy;
  39. end;
  40. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  41. //TvkuCommandPoolFactory/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  42. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  43. function TvkuCommandPoolFactory.CreateCommandPool: TvkuCommandPoolEx;
  44. begin
  45. result := CreateCommandPool(nil, false);
  46. end;
  47. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  48. function TvkuCommandPoolFactory.CreateCommandPool(const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean): TvkuCommandPoolEx;
  49. var CreateInfo: TVkCommandPoolCreateInfo;
  50. begin
  51. FillByte(CreateInfo, SizeOf(CreateInfo), 0);
  52. CreateInfo.sType := VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
  53. CreateInfo.pNext := nil;
  54. CreateInfo.flags := fFlags;
  55. CreateInfo.queueFamilyIndex := fQueueFamilyIndex;
  56. if Assigned(aAllocHandler)
  57. then result := TvkuCommandPoolEx.Create(CreateInfo, fDeviceCommands, aAllocHandler.GetAllocationCallbacksPtr)
  58. else result := TvkuCommandPoolEx.Create(CreateInfo, fDeviceCommands);
  59. try
  60. TvkuCommandPoolEx(result).fAllocHandler := aAllocHandler;
  61. TvkuCommandPoolEx(result).fOwnsHandler := aOwnsHandler;
  62. except
  63. FreeAndNil(result);
  64. raise;
  65. end;
  66. end;
  67. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  68. constructor TvkuCommandPoolFactory.Create(const aDevice: TvkuDevice);
  69. begin
  70. Create(aDevice.DeviceCommands);
  71. end;
  72. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  73. constructor TvkuCommandPoolFactory.Create(const aDeviceCommands: TVkDeviceCommands);
  74. begin
  75. inherited Create;
  76. fDeviceCommands := aDeviceCommands;
  77. end;
  78. end.