Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

83 rader
3.1 KiB

  1. unit uvkuBufferView;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan, uvkuBase;
  7. type
  8. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. TvkuBufferView = class(TvkuAllocHandle)
  10. private
  11. fHandle: VkBufferView;
  12. fDeviceCommands: TVkDeviceCommands;
  13. procedure CreateHandle(const aCreateInfo: TVkBufferViewCreateInfo);
  14. public
  15. property Handle: VkBufferView read fHandle;
  16. property DeviceCommands: TVkDeviceCommands read fDeviceCommands;
  17. constructor Create(
  18. const aCreateInfo: TVkBufferViewCreateInfo;
  19. const aDeviceCommands: TVkDeviceCommands;
  20. const aAllocCallbacks: PVkAllocationCallbacks = nil);
  21. constructor Create(
  22. const aHandle: VkBufferView;
  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. //TvkuBufferView/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  33. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  34. procedure TvkuBufferView.CreateHandle(const aCreateInfo: TVkBufferViewCreateInfo);
  35. var err: TVkResult;
  36. begin
  37. err := fDeviceCommands.vkCreateBufferView(fDeviceCommands.Device, @aCreateInfo, AllocCallbacks, @fHandle);
  38. if (err < VK_SUCCESS) then
  39. raise TvkuErrorException.Create('unable to create buffer view', err);
  40. end;
  41. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  42. constructor TvkuBufferView.Create(const aCreateInfo: TVkBufferViewCreateInfo; const aDeviceCommands: TVkDeviceCommands;
  43. const aAllocCallbacks: PVkAllocationCallbacks);
  44. begin
  45. inherited Create;
  46. fDeviceCommands := aDeviceCommands;
  47. SetAllocCallbacks(aAllocCallbacks);
  48. CreateHandle(aCreateInfo);
  49. end;
  50. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  51. constructor TvkuBufferView.Create(const aHandle: VkBufferView; 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 TvkuBufferView.Destroy;
  62. begin
  63. if OwnsHandle and (fHandle <> VK_INVALID_NDP_HANDLE) then
  64. fDeviceCommands.vkDestroyBufferView(fDeviceCommands.Device, fHandle, AllocCallbacks);
  65. fHandle := VK_INVALID_NDP_HANDLE;
  66. inherited Destroy;
  67. end;
  68. end.