|
- unit uvkuCommandPoolFactory;
-
- {$mode objfpc}{$H+}
-
- interface
-
- uses
- Classes, SysUtils,
- Vulkan, uvkuCommandPool, uvkuAllocationHandler, uvkuFactoryBase;
-
- type
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- TvkuCommandPoolEx = class(TvkuCommandPool)
- private
- fAllocHandler: TvkuAllocationHandler;
- fOwnsHandler: Boolean;
- public
- destructor Destroy; override;
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- TvkuCommandPoolFactory = class(TvkuDeviceObjFactory)
- private
- fFlags: VkCommandPoolCreateFlags;
- fQueueFamilyIndex: VkUint32;
- public
- function CreateCommandPool: TvkuCommandPoolEx;
- function CreateCommandPool(
- const aAllocHandler: TvkuAllocationHandler;
- const aOwnsHandler: Boolean): TvkuCommandPoolEx;
- end;
-
- implementation
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //TvkuCommandPoolEx//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- destructor TvkuCommandPoolEx.Destroy;
- begin
- inherited Destroy;
- if fOwnsHandler then
- FreeAndNil(fAllocHandler);
- 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, DeviceCommands, aAllocHandler.GetAllocationCallbacksPtr)
- else result := TvkuCommandPoolEx.Create(CreateInfo, DeviceCommands);
- try
- TvkuCommandPoolEx(result).fAllocHandler := aAllocHandler;
- TvkuCommandPoolEx(result).fOwnsHandler := aOwnsHandler;
- except
- FreeAndNil(result);
- raise;
- end;
- end;
-
- end.
|