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