diff --git a/projects/triangle/triangle.lpi b/projects/triangle/triangle.lpi index de857d3..c40805e 100644 --- a/projects/triangle/triangle.lpi +++ b/projects/triangle/triangle.lpi @@ -33,7 +33,7 @@ - + @@ -177,6 +177,14 @@ + + + + + + + + diff --git a/projects/triangle/triangle.lpr b/projects/triangle/triangle.lpr index 98de8fc..32c0b5a 100644 --- a/projects/triangle/triangle.lpr +++ b/projects/triangle/triangle.lpr @@ -7,8 +7,7 @@ uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} - Interfaces, Dialogs, Forms, uMainForm, Vulkan, uvkuRenderPass, uvkuRenderPassFactory, uvkuFactoryBase, -uvkuFrameBuffer, uvkuFrameBufferFactory, uvkuUtils; + Interfaces, Dialogs, Forms, uMainForm, Vulkan; {$R *.res} diff --git a/projects/triangle/triangle.lps b/projects/triangle/triangle.lps index 42b924c..cab35dd 100644 --- a/projects/triangle/triangle.lps +++ b/projects/triangle/triangle.lps @@ -4,13 +4,15 @@ - + - + + - + + @@ -21,21 +23,21 @@ - + - - - + + + - + @@ -43,7 +45,7 @@ - + @@ -51,7 +53,7 @@ - + @@ -59,7 +61,7 @@ - + @@ -67,7 +69,7 @@ - + @@ -75,15 +77,14 @@ - + - - - - + + + @@ -92,23 +93,23 @@ - + - - - - + + + + - - - - + + + + @@ -116,7 +117,7 @@ - + @@ -124,15 +125,15 @@ - + - - - - + + + + @@ -140,7 +141,7 @@ - + @@ -148,7 +149,7 @@ - + @@ -156,7 +157,7 @@ - + @@ -164,32 +165,32 @@ - + - - - - + + + + - - - - + + + + - - - - + + + + @@ -197,38 +198,39 @@ - + - - - - + + + + - - - - + + + + + - - - - + + + + - + @@ -236,16 +238,15 @@ - + - - - - + + + @@ -258,8 +259,9 @@ - - + + + @@ -391,7 +393,7 @@ - + @@ -399,7 +401,7 @@ - + @@ -407,132 +409,165 @@ - + - + - + - - - + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + diff --git a/projects/utils/uvkuBufferFactory.pas b/projects/utils/uvkuBufferFactory.pas index 62dee0b..a12020f 100644 --- a/projects/utils/uvkuBufferFactory.pas +++ b/projects/utils/uvkuBufferFactory.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, - Vulkan, uvkuBuffer, uvkuDevice, uvkuAllocationHandler, uvkuTypes, uvkuFactoryBase; + Vulkan, uvkuBuffer, uvkuAllocationHandler, uvkuTypes, uvkuFactoryBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/projects/utils/uvkuBufferViewFactory.pas b/projects/utils/uvkuBufferViewFactory.pas index 57b2a14..5d8fc6e 100644 --- a/projects/utils/uvkuBufferViewFactory.pas +++ b/projects/utils/uvkuBufferViewFactory.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, - Vulkan, uvkuBufferView, uvkuAllocationHandler, uvkuDevice, uvkuFactoryBase; + Vulkan, uvkuBufferView, uvkuAllocationHandler, uvkuFactoryBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/projects/utils/uvkuCommandPoolFactory.pas b/projects/utils/uvkuCommandPoolFactory.pas index d4c6fd8..42844f0 100644 --- a/projects/utils/uvkuCommandPoolFactory.pas +++ b/projects/utils/uvkuCommandPoolFactory.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, - Vulkan, uvkuCommandPool, uvkuDevice, uvkuAllocationHandler, uvkuFactoryBase; + Vulkan, uvkuCommandPool, uvkuAllocationHandler, uvkuFactoryBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/projects/utils/uvkuDescriptorSetLayout.pas b/projects/utils/uvkuDescriptorSetLayout.pas new file mode 100644 index 0000000..a3b5a52 --- /dev/null +++ b/projects/utils/uvkuDescriptorSetLayout.pas @@ -0,0 +1,84 @@ +unit uvkuDescriptorSetLayout; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, + Vulkan, uvkuBase; + +type +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + TvkuDescriptorSetLayout = class(TvkuAllocHandle) + private + fHandle: VkDescriptorSetLayout; + fDeviceCommands: TVkDeviceCommands; + + procedure CreateHandle(const aCreateInfo: TVkDescriptorSetLayoutCreateInfo); + public + property Handle: VkDescriptorSetLayout read fHandle; + property DeviceCommands: TVkDeviceCommands read fDeviceCommands; + + constructor Create( + const aCreateInfo: TVkDescriptorSetLayoutCreateInfo; + const aDeviceCommands: TVkDeviceCommands; + const aAllocCallbacks: PVkAllocationCallbacks = nil); + constructor Create( + const aHandle: VkDescriptorSetLayout; + const aOwnsHandle: Boolean; + const aDeviceCommands: TVkDeviceCommands; + const aAllocCallbacks: PVkAllocationCallbacks = nil); + destructor Destroy; override; + end; + +implementation + +uses + uvkuUtils; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//TvkuDescriptorSetLayout//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TvkuDescriptorSetLayout.CreateHandle(const aCreateInfo: TVkDescriptorSetLayoutCreateInfo); +var err: TVkResult; +begin + if not Assigned(fDeviceCommands.vkCreateDescriptorSetLayout) then + raise TvkuInvalidFuncPtrException.Create('vkCreateDescriptorSetLayout'); + err := fDeviceCommands.vkCreateDescriptorSetLayout(fDeviceCommands.Device, @aCreateInfo, AllocCallbacks, @fHandle); + if (err < VK_SUCCESS) then + raise TvkuErrorException.Create('unable to create descriptor set layout', err); +end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +constructor TvkuDescriptorSetLayout.Create(const aCreateInfo: TVkDescriptorSetLayoutCreateInfo; + const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks); +begin + inherited Create; + fDeviceCommands := aDeviceCommands; + SetAllocCallbacks(aAllocCallbacks); + CreateHandle(aCreateInfo); +end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +constructor TvkuDescriptorSetLayout.Create(const aHandle: VkDescriptorSetLayout; const aOwnsHandle: Boolean; + const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks); +begin + inherited Create; + fHandle := aHandle; + fDeviceCommands := aDeviceCommands; + OwnsHandle := aOwnsHandle; + SetAllocCallbacks(aAllocCallbacks); +end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +destructor TvkuDescriptorSetLayout.Destroy; +begin + if OwnsHandle and (fHandle <> VK_INVALID_NDP_HANDLE) then + fDeviceCommands.vkDestroyDescriptorSetLayout(fDeviceCommands.Device, fHandle, AllocCallbacks); + fHandle := VK_INVALID_NDP_HANDLE; + inherited Destroy; +end; + +end. + diff --git a/projects/utils/uvkuDescriptorSetLayoutFactory.pas b/projects/utils/uvkuDescriptorSetLayoutFactory.pas new file mode 100644 index 0000000..91b76b8 --- /dev/null +++ b/projects/utils/uvkuDescriptorSetLayoutFactory.pas @@ -0,0 +1,119 @@ +unit uvkuDescriptorSetLayoutFactory; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, + Vulkan, uvkuFactoryBase, uvkuDescriptorSetLayout, uvkuAllocationHandler, uvkuTypes; + +type +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + TvkuDescriptorSetLayoutEx = class(TvkuDescriptorSetLayout) + private + fAllocHandler: TvkuAllocationHandler; + fOwnsHandler: Boolean; + public + destructor Destroy; override; + end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + TvkuDescriptorSetLayoutFactory = class(TvkuDeviceObjFactory) + private + fFlags: VkDescriptorSetLayoutCreateFlags; + fBindings: TvkuDescriptorSetLayoutBindingArr; + function GetBinding(const aIndex: Integer): TVkDescriptorSetLayoutBinding; + function GetBindingCount: Integer; + procedure SetBinding(const aIndex: Integer; aValue: TVkDescriptorSetLayoutBinding); + procedure SetBindingCount(aValue: Integer); + public + property Flags: VkDescriptorSetLayoutCreateFlags read fFlags write fFlags; + + property Bindings: TvkuDescriptorSetLayoutBindingArr read fBindings write fBindings; + property BindingCount: Integer read GetBindingCount write SetBindingCount; + property Binding[const aIndex: Integer]: TVkDescriptorSetLayoutBinding read GetBinding write SetBinding; + + function CreateDescriptorSetLayout: TvkuDescriptorSetLayoutEx; + function CreateDescriptorSetLayout( + const aAllocHandler: TvkuAllocationHandler; + const aOwnsHandler: Boolean): TvkuDescriptorSetLayoutEx; + end; + +implementation + +uses + uvkuUtils; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//TvkuDescriptorSetLayoutEx////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +destructor TvkuDescriptorSetLayoutEx.Destroy; +begin + inherited Destroy; + if fOwnsHandler then + FreeAndNil(fAllocHandler); +end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//TvkuDescriptorSetLayoutFactory///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function TvkuDescriptorSetLayoutFactory.GetBinding(const aIndex: Integer): TVkDescriptorSetLayoutBinding; +begin + if (aIndex < low(fBindings)) or (aIndex > high(fBindings)) then + raise TvkuException.CreateFmt('index (%d) out of range (%d : %d)', [aIndex, Low(fBindings), High(fBindings)]); + result := fBindings[aIndex]; +end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function TvkuDescriptorSetLayoutFactory.GetBindingCount: Integer; +begin + result := Length(fBindings); +end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TvkuDescriptorSetLayoutFactory.SetBinding(const aIndex: Integer; aValue: TVkDescriptorSetLayoutBinding); +begin + if (aIndex < low(fBindings)) or (aIndex > high(fBindings)) then + raise TvkuException.CreateFmt('index (%d) out of range (%d : %d)', [aIndex, Low(fBindings), High(fBindings)]); + fBindings[aIndex] := aValue; +end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +procedure TvkuDescriptorSetLayoutFactory.SetBindingCount(aValue: Integer); +begin + SetLength(fBindings, aValue); +end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function TvkuDescriptorSetLayoutFactory.CreateDescriptorSetLayout: TvkuDescriptorSetLayoutEx; +begin + result := CreateDescriptorSetLayout(nil, false); +end; + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +function TvkuDescriptorSetLayoutFactory.CreateDescriptorSetLayout(const aAllocHandler: TvkuAllocationHandler; + const aOwnsHandler: Boolean): TvkuDescriptorSetLayoutEx; +var + CreateInfo: TVkDescriptorSetLayoutCreateInfo; +begin + FillByte(CreateInfo, SizeOf(CreateInfo), 0); + CreateInfo.sType := VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; + CreateInfo.pNext := nil; + CreateInfo.flags := fFlags; + CreateInfo.bindingCount := Length(fBindings); + CreateInfo.pBindings := @fBindings[0]; + if Assigned(aAllocHandler) + then result := TvkuDescriptorSetLayoutEx.Create(CreateInfo, DeviceCommands, aAllocHandler.GetAllocationCallbacksPtr) + else result := TvkuDescriptorSetLayoutEx.Create(CreateInfo, DeviceCommands); + try + TvkuDescriptorSetLayoutEx(result).fAllocHandler := aAllocHandler; + TvkuDescriptorSetLayoutEx(result).fOwnsHandler := aOwnsHandler; + except + FreeAndNil(result); + raise; + end; +end; + +end. + diff --git a/projects/utils/uvkuDeviceFactory.pas b/projects/utils/uvkuDeviceFactory.pas index 77b19db..25a22d8 100644 --- a/projects/utils/uvkuDeviceFactory.pas +++ b/projects/utils/uvkuDeviceFactory.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, - Vulkan, uvkuInstance, uvkuDevice, uvkuAllocationHandler, uvkuTypes, uvkuFactoryBase; + Vulkan, uvkuDevice, uvkuAllocationHandler, uvkuTypes, uvkuFactoryBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/projects/utils/uvkuImageFactory.pas b/projects/utils/uvkuImageFactory.pas index 7d0f4ac..2ccf31c 100644 --- a/projects/utils/uvkuImageFactory.pas +++ b/projects/utils/uvkuImageFactory.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, - Vulkan, uvkuImage, uvkuDevice, uvkuAllocationHandler, uvkuTypes, uvkuFactoryBase; + Vulkan, uvkuImage, uvkuAllocationHandler, uvkuTypes, uvkuFactoryBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/projects/utils/uvkuImageViewFactory.pas b/projects/utils/uvkuImageViewFactory.pas index 6733a18..717e172 100644 --- a/projects/utils/uvkuImageViewFactory.pas +++ b/projects/utils/uvkuImageViewFactory.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, - Vulkan, uvkuAllocationHandler, uvkuImageView, uvkuDevice, uvkuFactoryBase; + Vulkan, uvkuAllocationHandler, uvkuImageView, uvkuFactoryBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/projects/utils/uvkuSurfaceFactory.pas b/projects/utils/uvkuSurfaceFactory.pas index bc12e41..79f6aca 100644 --- a/projects/utils/uvkuSurfaceFactory.pas +++ b/projects/utils/uvkuSurfaceFactory.pas @@ -7,7 +7,7 @@ interface uses Classes, SysUtils, Controls, - Vulkan, uvkuInstance, uvkuSurface, uvkuAllocationHandler, uvkuFactoryBase; + Vulkan, uvkuSurface, uvkuAllocationHandler, uvkuFactoryBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/projects/utils/uvkuSwapChainFactory.pas b/projects/utils/uvkuSwapChainFactory.pas index f34e94e..eb1aad2 100644 --- a/projects/utils/uvkuSwapChainFactory.pas +++ b/projects/utils/uvkuSwapChainFactory.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, - Vulkan, uvkuSwapChain, uvkuTypes, uvkuAllocationHandler, uvkuDevice, uvkuFactoryBase; + Vulkan, uvkuSwapChain, uvkuTypes, uvkuAllocationHandler, uvkuFactoryBase; type ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/projects/utils/uvkuTypes.pas b/projects/utils/uvkuTypes.pas index da96ea3..ae8a9ec 100644 --- a/projects/utils/uvkuTypes.pas +++ b/projects/utils/uvkuTypes.pas @@ -26,6 +26,7 @@ type TvkuSubpassDescriptionArr = array of TVkSubpassDescription; TvkuSubpassDependencyArr = array of TVkSubpassDependency; TvkuImageViewArr = array of VkImageView; + TvkuDescriptorSetLayoutBindingArr = array of TVkDescriptorSetLayoutBinding; TvkuApplicationInfo = packed record AppName: String; diff --git a/projects/utils/uvkuUtils.pas b/projects/utils/uvkuUtils.pas index f328b7f..e1cc04c 100644 --- a/projects/utils/uvkuUtils.pas +++ b/projects/utils/uvkuUtils.pas @@ -26,7 +26,7 @@ type fFunctionName: String; fExtentionName: String; public - property FunctionName: String read fFunctionName; + property FunctionName: String read fFunctionName; property ExtensionName: String read fExtensionName; constructor Create(const aFunctionName: String; const aExtensionName: String = '');