25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.7 KiB

  1. unit uvkuFrameBufferFactory;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan, uvkuFrameBuffer, uvkuFactoryBase, uvkuTypes;
  7. type
  8. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. TvkuFrameBufferFactory = class(TvkuDeviceObjFactory)
  10. private
  11. fFlags: VkFramebufferCreateFlags;
  12. fRenderPass: VkRenderPass;
  13. fWidth: VkUint32;
  14. fHeight: VkUint32;
  15. fLayers: VkUint32;
  16. fAttachments: TVkImageViewList;
  17. public
  18. property Flags: VkFramebufferCreateFlags read fFlags write fFlags;
  19. property RenderPass: VkRenderPass read fRenderPass write fRenderPass;
  20. property Width: VkUint32 read fWidth write fWidth;
  21. property Height: VkUint32 read fHeight write fHeight;
  22. property Layers: VkUint32 read fLayers write fLayers;
  23. property Attachments: TVkImageViewList read fAttachments;
  24. function GetStructure: TVkFramebufferCreateInfo;
  25. procedure SetStructure(const aData: TVkFramebufferCreateInfo);
  26. function CreateFrameBuffer: TvkuFrameBuffer;
  27. procedure AfterConstruction; override;
  28. procedure BeforeDestruction; override;
  29. end;
  30. implementation
  31. uses
  32. uvkuUtils;
  33. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  34. //TvkuFrameBufferFactory/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  35. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  36. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  37. function TvkuFrameBufferFactory.GetStructure: TVkFramebufferCreateInfo;
  38. begin
  39. FillByte(result, SizeOf(result), 0);
  40. result.sType := VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
  41. result.pNext := nil;
  42. result.flags := fFlags;
  43. result.renderPass := fRenderPass;
  44. result.attachmentCount := fAttachments.Length;
  45. result.pAttachments := fAttachments.PData;
  46. result.width := fWidth;
  47. result.height := fHeight;
  48. result.layers := fLayers;
  49. end;
  50. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  51. procedure TvkuFrameBufferFactory.SetStructure(const aData: TVkFramebufferCreateInfo);
  52. var i: Integer;
  53. begin
  54. fFlags := aData.flags;
  55. fRenderPass := aData.renderPass;
  56. fWidth := aData.width;
  57. fHeight := aData.height;
  58. fLayers := aData.layers;
  59. fAttachments.SetData(aData.pAttachments, aData.attachmentCount);
  60. end;
  61. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  62. function TvkuFrameBufferFactory.CreateFrameBuffer: TvkuFrameBuffer;
  63. begin
  64. result := TvkuFrameBuffer.Create(GetStructure, DeviceCommands, AllocCallbacks);
  65. end;
  66. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  67. procedure TvkuFrameBufferFactory.AfterConstruction;
  68. begin
  69. inherited AfterConstruction;
  70. fAttachments := TVkImageViewList.Create;
  71. end;
  72. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  73. procedure TvkuFrameBufferFactory.BeforeDestruction;
  74. begin
  75. FreeAndNil(fAttachments);
  76. inherited BeforeDestruction;
  77. end;
  78. end.