|
- unit uvkuBufferView;
-
- {$mode objfpc}{$H+}
-
- interface
-
- uses
- Classes, SysUtils,
- Vulkan, uvkuBase;
-
- type
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- TvkuBufferView = class(TvkuAllocHandle)
- private
- fHandle: VkBufferView;
- fDeviceCommands: TVkDeviceCommands;
-
- procedure CreateHandle(const aCreateInfo: TVkBufferViewCreateInfo);
- public
- property Handle: VkBufferView read fHandle;
- property DeviceCommands: TVkDeviceCommands read fDeviceCommands;
-
- constructor Create(
- const aCreateInfo: TVkBufferViewCreateInfo;
- const aDeviceCommands: TVkDeviceCommands;
- const aAllocCallbacks: PVkAllocationCallbacks = nil);
- constructor Create(
- const aHandle: VkBufferView;
- const aOwnsHandle: Boolean;
- const aDeviceCommands: TVkDeviceCommands;
- const aAllocCallbacks: PVkAllocationCallbacks = nil);
- destructor Destroy; override;
- end;
-
- implementation
-
- uses
- uvkuUtils;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //TvkuBufferView/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- procedure TvkuBufferView.CreateHandle(const aCreateInfo: TVkBufferViewCreateInfo);
- var err: TVkResult;
- begin
- err := fDeviceCommands.vkCreateBufferView(fDeviceCommands.Device, @aCreateInfo, AllocCallbacks, @fHandle);
- if (err < VK_SUCCESS) then
- raise TvkuErrorException.Create('unable to create buffer view', err);
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- constructor TvkuBufferView.Create(const aCreateInfo: TVkBufferViewCreateInfo; const aDeviceCommands: TVkDeviceCommands;
- const aAllocCallbacks: PVkAllocationCallbacks);
- begin
- inherited Create;
- fDeviceCommands := aDeviceCommands;
- SetAllocCallbacks(aAllocCallbacks);
- CreateHandle(aCreateInfo);
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- constructor TvkuBufferView.Create(const aHandle: VkBufferView; const aOwnsHandle: Boolean;
- const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks);
- begin
- inherited Create;
- fHandle := aHandle;
- fDeviceCommands := aDeviceCommands;
- OwnsHandle := aOwnsHandle;
- SetAllocCallbacks(aAllocCallbacks);
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- destructor TvkuBufferView.Destroy;
- begin
- if OwnsHandle and (fHandle <> VK_INVALID_NDP_HANDLE) then
- fDeviceCommands.vkDestroyBufferView(fDeviceCommands.Device, fHandle, AllocCallbacks);
- fHandle := VK_INVALID_NDP_HANDLE;
- inherited Destroy;
- end;
-
- end.
|