Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

76 lignes
3.1 KiB

  1. unit uvkuCommandPoolFactory;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan, uvkuCommandPool, uvkuDevice, uvkuAllocationHandler, uvkuFactoryBase;
  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(TvkuDeviceObjFactory)
  18. private
  19. fFlags: VkCommandPoolCreateFlags;
  20. fQueueFamilyIndex: VkUint32;
  21. public
  22. function CreateCommandPool: TvkuCommandPoolEx;
  23. function CreateCommandPool(
  24. const aAllocHandler: TvkuAllocationHandler;
  25. const aOwnsHandler: Boolean): TvkuCommandPoolEx;
  26. end;
  27. implementation
  28. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  29. //TvkuCommandPoolEx//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  30. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. destructor TvkuCommandPoolEx.Destroy;
  32. begin
  33. inherited Destroy;
  34. if fOwnsHandler then
  35. FreeAndNil(fAllocHandler);
  36. end;
  37. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  38. //TvkuCommandPoolFactory/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  39. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  40. function TvkuCommandPoolFactory.CreateCommandPool: TvkuCommandPoolEx;
  41. begin
  42. result := CreateCommandPool(nil, false);
  43. end;
  44. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  45. function TvkuCommandPoolFactory.CreateCommandPool(const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean): TvkuCommandPoolEx;
  46. var CreateInfo: TVkCommandPoolCreateInfo;
  47. begin
  48. FillByte(CreateInfo, SizeOf(CreateInfo), 0);
  49. CreateInfo.sType := VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
  50. CreateInfo.pNext := nil;
  51. CreateInfo.flags := fFlags;
  52. CreateInfo.queueFamilyIndex := fQueueFamilyIndex;
  53. if Assigned(aAllocHandler)
  54. then result := TvkuCommandPoolEx.Create(CreateInfo, DeviceCommands, aAllocHandler.GetAllocationCallbacksPtr)
  55. else result := TvkuCommandPoolEx.Create(CreateInfo, DeviceCommands);
  56. try
  57. TvkuCommandPoolEx(result).fAllocHandler := aAllocHandler;
  58. TvkuCommandPoolEx(result).fOwnsHandler := aOwnsHandler;
  59. except
  60. FreeAndNil(result);
  61. raise;
  62. end;
  63. end;
  64. end.