You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 rivejä
3.2 KiB

  1. unit uvkuPipelineCache;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan, uvkuBase;
  7. type
  8. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. TvkuPipelineCache = class(TvkuAllocHandle)
  10. private
  11. fHandle: VkPipelineCache;
  12. fDeviceCommands: TVkDeviceCommands;
  13. procedure CreateHandle(const aCreateInfo: TVkPipelineCacheCreateInfo);
  14. public
  15. property Handle: VkPipelineCache read fHandle;
  16. property DeviceCommands: TVkDeviceCommands read fDeviceCommands;
  17. constructor Create(
  18. const aCreateInfo: TVkPipelineCacheCreateInfo;
  19. const aDeviceCommands: TVkDeviceCommands;
  20. const aAllocCallbacks: PVkAllocationCallbacks = nil);
  21. constructor Create(
  22. const aHandle: VkPipelineCache;
  23. const aOwnsHandle: Boolean;
  24. const aDeviceCommands: TVkDeviceCommands;
  25. const aAllocCallbacks: PVkAllocationCallbacks = nil);
  26. destructor Destroy; override;
  27. end;
  28. implementation
  29. uses
  30. uvkuUtils;
  31. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  32. //TvkuPipelineCache//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  33. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  34. procedure TvkuPipelineCache.CreateHandle(const aCreateInfo: TVkPipelineCacheCreateInfo);
  35. var err: TVkResult;
  36. begin
  37. err := fDeviceCommands.vkCreatePipelineCache(fDeviceCommands.Device, @aCreateInfo, AllocCallbacks, @fHandle);
  38. if (err <> VK_SUCCESS) then
  39. TvkuErrorException.Create('unable to create pipeline cache', err);
  40. end;
  41. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  42. constructor TvkuPipelineCache.Create(const aCreateInfo: TVkPipelineCacheCreateInfo;
  43. const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks);
  44. begin
  45. inherited Create;
  46. fDeviceCommands := aDeviceCommands;
  47. SetAllocCallbacks(aAllocCallbacks);
  48. CreateHandle(aCreateInfo);
  49. end;
  50. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  51. constructor TvkuPipelineCache.Create(const aHandle: VkPipelineCache; const aOwnsHandle: Boolean;
  52. const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks);
  53. begin
  54. inherited Create;
  55. fHandle := aHandle;
  56. fDeviceCommands := aDeviceCommands;
  57. OwnsHandle := aOwnsHandle;
  58. SetAllocCallbacks(aAllocCallbacks);
  59. end;
  60. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  61. destructor TvkuPipelineCache.Destroy;
  62. begin
  63. if OwnsHandle and (fHandle <> VK_INVALID_NDP_HANDLE) then
  64. fDeviceCommands.vkDestroyPipelineCache(fDeviceCommands.Device, fHandle, AllocCallbacks);
  65. fHandle := VK_INVALID_NDP_HANDLE;
  66. inherited Destroy;
  67. end;
  68. end.