|
- unit uvkuFrameBufferFactory;
-
- {$mode objfpc}{$H+}
-
- interface
-
- uses
- Classes, SysUtils,
- Vulkan, uvkuFrameBuffer, uvkuFactoryBase, uvkuTypes;
-
- type
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- TvkuFrameBufferFactory = class(TvkuDeviceObjFactory)
- private
- fFlags: VkFramebufferCreateFlags;
- fRenderPass: VkRenderPass;
- fWidth: VkUint32;
- fHeight: VkUint32;
- fLayers: VkUint32;
- fAttachments: TVkImageViewList;
- public
- property Flags: VkFramebufferCreateFlags read fFlags write fFlags;
- property RenderPass: VkRenderPass read fRenderPass write fRenderPass;
- property Width: VkUint32 read fWidth write fWidth;
- property Height: VkUint32 read fHeight write fHeight;
- property Layers: VkUint32 read fLayers write fLayers;
- property Attachments: TVkImageViewList read fAttachments;
-
- function GetStructure: TVkFramebufferCreateInfo;
- procedure SetStructure(const aData: TVkFramebufferCreateInfo);
-
- function CreateFrameBuffer: TvkuFrameBuffer;
-
- procedure AfterConstruction; override;
- procedure BeforeDestruction; override;
- end;
-
- implementation
-
- uses
- uvkuUtils;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //TvkuFrameBufferFactory/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- function TvkuFrameBufferFactory.GetStructure: TVkFramebufferCreateInfo;
- begin
- FillByte(result, SizeOf(result), 0);
- result.sType := VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
- result.pNext := nil;
- result.flags := fFlags;
- result.renderPass := fRenderPass;
- result.attachmentCount := fAttachments.Length;
- result.pAttachments := fAttachments.PData;
- result.width := fWidth;
- result.height := fHeight;
- result.layers := fLayers;
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- procedure TvkuFrameBufferFactory.SetStructure(const aData: TVkFramebufferCreateInfo);
- var i: Integer;
- begin
- fFlags := aData.flags;
- fRenderPass := aData.renderPass;
- fWidth := aData.width;
- fHeight := aData.height;
- fLayers := aData.layers;
- fAttachments.SetData(aData.pAttachments, aData.attachmentCount);
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- function TvkuFrameBufferFactory.CreateFrameBuffer: TvkuFrameBuffer;
- begin
- result := TvkuFrameBuffer.Create(GetStructure, DeviceCommands, AllocCallbacks);
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- procedure TvkuFrameBufferFactory.AfterConstruction;
- begin
- inherited AfterConstruction;
- fAttachments := TVkImageViewList.Create;
- end;
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- procedure TvkuFrameBufferFactory.BeforeDestruction;
- begin
- FreeAndNil(fAttachments);
- inherited BeforeDestruction;
- end;
-
- end.
|