BsVulkanFramebuffer.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsVulkanPrerequisites.h"
  5. #include "BsVulkanResource.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup Vulkan
  9. * @{
  10. */
  11. /** Represents a single attachment in a Vulkan frame-buffer. */
  12. struct VULKAN_ATTACHMENT_DESC
  13. {
  14. /** View of the image to attach or VK_NULL_HANDLE if none. */
  15. VkImageView view;
  16. /** Format of the attached image. */
  17. VkFormat format;
  18. };
  19. /** Contains parameters used for initializing VulkanFrameBuffer object. */
  20. struct VULKAN_FRAMEBUFFER_DESC
  21. {
  22. /** Images describing the color attachments. */
  23. VULKAN_ATTACHMENT_DESC color[BS_MAX_MULTIPLE_RENDER_TARGETS];
  24. /** Image describing the depth attachment. */
  25. VULKAN_ATTACHMENT_DESC depth;
  26. /** Width of the images, in pixels. All images must be the same size. */
  27. UINT32 width;
  28. /** Height of the images, in pixels. All images must be the same size. */
  29. UINT32 height;
  30. /** Number of image layers to render to. */
  31. UINT32 layers;
  32. /** Number of samples in the attached images. All attachments must have the same number of samples. */
  33. UINT32 numSamples;
  34. /** Set to true if framebuffer represents an offscreen surface that will not be presented. */
  35. bool offscreen;
  36. };
  37. /** Vulkan frame buffer containing one or multiple color surfaces, and an optional depth surface. */
  38. class VulkanFramebuffer : public VulkanResource
  39. {
  40. public:
  41. /** Creates a new frame buffer with the specified image views attached.
  42. *
  43. * @param[in] owner Resource manager that allocated this resource.
  44. * @param[in] desc Description of the frame buffer.
  45. */
  46. VulkanFramebuffer(VulkanResourceManager* owner, const VULKAN_FRAMEBUFFER_DESC& desc);
  47. ~VulkanFramebuffer();
  48. /** Returns a unique ID of this framebuffer. */
  49. UINT32 getId() const { return mId; }
  50. /** Gets internal Vulkan render pass object. */
  51. VkRenderPass getRenderPass() const { return mRenderPass; }
  52. /** Gets internal Vulkan framebuffer object. */
  53. VkFramebuffer getFramebuffer() const { return mFramebuffer; }
  54. /** Gets the total number of frame-buffer attachments, including both color and depth. */
  55. UINT32 getNumAttachments() const { return mNumAttachments; }
  56. /** Gets the number of color frame-buffer attachments. */
  57. UINT32 getNumColorAttachments() const { return mNumColorAttachments; }
  58. /** Returns true if the framebuffer has a depth attachment. */
  59. bool hasDepthAttachment() const { return mHasDepth; }
  60. /** Returns sample flags that determine if the framebuffer supports multi-sampling, and for how many samples. */
  61. VkSampleCountFlagBits getSampleFlags() const { return mSampleFlags; }
  62. private:
  63. UINT32 mId;
  64. VkRenderPass mRenderPass;
  65. VkFramebuffer mFramebuffer;
  66. UINT32 mNumAttachments;
  67. UINT32 mNumColorAttachments;
  68. bool mHasDepth;
  69. VkSampleCountFlagBits mSampleFlags;
  70. static UINT32 sNextValidId;
  71. };
  72. /** @} */
  73. }