|
- unit uvkuCommandPoolFactory;
-
- {$mode objfpc}{$H+}
-
- interface
-
- uses
- Classes, SysUtils,
- Vulkan, uvkuCommandPool, uvkuDevice, uvkuAllocationHandler;
-
- type
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- TvkuCommandPoolEx = class(TvkuCommandPool)
- private
- fAllocHandler: TvkuAllocationHandler;
- fOwnsHandler: Boolean;
- public
- destructor Destroy; override;
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- TvkuCommandPoolFactory = class(TObject)
- private
- fDeviceCommands: TVkDeviceCommands;
- fFlags: VkCommandPoolCreateFlags;
- fQueueFamilyIndex: VkUint32;
- public
- function CreateCommandPool: TvkuCommandPoolEx;
- function CreateCommandPool(
- const aAllocHandler: TvkuAllocationHandler;
- const aOwnsHandler: Boolean): TvkuCommandPoolEx;
-
- constructor Create(const aDevice: TvkuDevice);
- constructor Create(const aDeviceCommands: TVkDeviceCommands);
- end;
-
- implementation
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //TvkuCommandPoolEx//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- destructor TvkuCommandPoolEx.Destroy;
- begin
- if fOwnsHandler then
- FreeAndNil(fAllocHandler);
- inherited Destroy;
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //TvkuCommandPoolFactory/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- function TvkuCommandPoolFactory.CreateCommandPool: TvkuCommandPoolEx;
- begin
- result := CreateCommandPool(nil, false);
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- function TvkuCommandPoolFactory.CreateCommandPool(const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean): TvkuCommandPoolEx;
- var CreateInfo: TVkCommandPoolCreateInfo;
- begin
- FillByte(CreateInfo, SizeOf(CreateInfo), 0);
- CreateInfo.sType := VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
- CreateInfo.pNext := nil;
- CreateInfo.flags := fFlags;
- CreateInfo.queueFamilyIndex := fQueueFamilyIndex;
- if Assigned(aAllocHandler)
- then result := TvkuCommandPoolEx.Create(CreateInfo, fDeviceCommands, aAllocHandler.GetAllocationCallbacksPtr)
- else result := TvkuCommandPoolEx.Create(CreateInfo, fDeviceCommands);
- try
- TvkuCommandPoolEx(result).fAllocHandler := aAllocHandler;
- TvkuCommandPoolEx(result).fOwnsHandler := aOwnsHandler;
- except
- FreeAndNil(result);
- raise;
- end;
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- constructor TvkuCommandPoolFactory.Create(const aDevice: TvkuDevice);
- begin
- Create(aDevice.DeviceCommands);
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- constructor TvkuCommandPoolFactory.Create(const aDeviceCommands: TVkDeviceCommands);
- begin
- inherited Create;
- fDeviceCommands := aDeviceCommands;
- end;
-
- end.
|