HatchitGraphics
ht_vkrenderer.h
1 
15 #pragma once
16 
17 #include <ht_platform.h>
18 #include <ht_vulkan.h>
19 #include <ht_renderer.h>
20 #include <ht_vkrenderpass.h>
21 #include <ht_VKSwapChain.h>
22 #include <ht_vkmaterial.h>
23 #include <ht_vkrootlayout.h>
24 #include <ht_vkdevice.h>
25 #include <ht_string.h>
26 #include <vector>
27 
28 namespace Hatchit {
29 
30  namespace Graphics {
31 
32  namespace Vulkan {
33 
34  class HT_API VKRenderer : public Graphics::Renderer
35  {
36  public:
37  VKRenderer();
38 
39  ~VKRenderer();
40 
44  bool VInitialize(const RendererParams& params) override;
45 
47  void VDeInitialize() override;
48 
53  void VResizeBuffers(uint32_t width, uint32_t height) override;
54 
58  void VSetClearColor(const Color& color) override;
62  void VClearBuffer(ClearArgs args) override;
63 
64  void VRender(float dt) override;
65 
67  void VPresent() override;
68 
69  /* Get the core Vulkan device
70  * \return The VkDevice
71  */
72  const VKDevice& GetVKDevice() const;
73 
74  /* Get the core Vulkan command pool
75  * \return a vulkan command pool
76  */
77  const VkCommandPool& GetVKCommandPool() const;
78 
79  /* Get the core Vulkan descriptor pool
80  * \reutrn a vulkan descriptor pool
81  */
82  const VkDescriptorPool& GetVKDescriptorPool() const;
83 
84 <<<<<<< HEAD:include/vulkan/unused/ht_vkrenderer.h
85  VKRootLayout* const GetVKRootLayoutHandle() const;
86 
87 =======
88 >>>>>>> dev:include/vulkan/ht_vkrenderer.h
89  const VkCommandBuffer& GetSetupCommandBuffer() const;
90 
91  const VkFormat& GetPreferredImageFormat() const;
92  const VkFormat& GetPreferredDepthFormat() const;
93 
94  const RendererParams& GetRendererParams() const;
95 
96  const VkClearValue& GetClearColor() const;
97 
98  void CreateSetupCommandBuffer();
99  void FlushSetupCommandBuffer();
100 
101  //Reused helpers
102  bool SetImageLayout(VkCommandBuffer commandBuffer, VkImage image, VkImageAspectFlags aspectMask,
103  VkImageLayout oldImageLayout, VkImageLayout newImageLayout);
104  bool MemoryTypeFromProperties(uint32_t typeBits, VkFlags requirementsMask, uint32_t* typeIndex);
105  bool CreateBuffer(VkDevice device, VkBufferUsageFlagBits usage, size_t dataSize, void* data, UniformBlock_vk* uniformBlock);
106 
107  private:
108  bool m_enableValidation;
109  std::vector<const char*> m_enabledLayerNames;
110  std::vector<const char*> m_enabledExtensionNames;
111 
112  RendererParams m_rendererParams; //We will need these later to re-create the swapchain if the window resizes
113 
114  //Vuklan data structs
115  std::vector<VkQueueFamilyProperties> m_queueProps;
116  VkQueue m_queue;
117  VkPhysicalDeviceMemoryProperties m_memoryProps;
118 
119  VKSwapChain* m_swapchain;
120 
121  VkCommandBuffer m_setupCommandBuffer;
122 
123  VkCommandPool m_commandPool;
124  VkDescriptorPool m_descriptorPool;
125 
126  VkSemaphore m_presentSemaphore;
127  VkSemaphore m_renderSemaphore;
128  VkSubmitInfo m_submitInfo;
129 
130  VkClearValue m_clearColor;
131 
132  //Resources we want loaded elsewhere
133 <<<<<<< HEAD:include/vulkan/unused/ht_vkrenderer.h
134  VKRootLayoutHandle m_rootLayout;
135  MaterialHandle m_material;
136 =======
137  IMaterialHandle m_material;
138 >>>>>>> dev:include/vulkan/ht_vkrenderer.h
139  TextureHandle m_texture;
140  PipelineHandle m_pipeline;
141  MeshHandle m_meshHandle;
142  VKRenderPassHandle m_renderPass;
143 
144  VKRenderPassHandle m_lightingPass;
145  PipelineHandle m_pointLightingPipeline;
146  MaterialHandle m_pointLightMaterial;
147  MeshHandle m_pointLightMeshHandle;
148 
149  VKRenderPassHandle m_compositionPass;
150  PipelineHandle m_compositionPipeline;
151  MaterialHandle m_compositionMaterial;
152  MeshHandle m_compositionMeshHandle;
153 
154  float m_angle = 0;
155 
156  VKDevice m_device;
157 
158  //Vulkan Callbacks
159  PFN_vkCreateDebugReportCallbackEXT m_createDebugReportCallback;
160  PFN_vkDestroyDebugReportCallbackEXT m_destroyDebugReportCallback;
161  VkDebugReportCallbackEXT msg_callback;
162  PFN_vkDebugReportMessageEXT m_debugReportMessage;
163 
164  static VKAPI_ATTR VkBool32 VKAPI_CALL debugFunction(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType,
165  uint64_t srcObject, size_t location, int32_t msgCode,
166  const char *pLayerPrefix, const char *pMsg, void *pUserData);
167 
168  //Core init methods
169  bool initVulkanSwapchain();
170  bool prepareVulkan();
171 
172  //Helper inits for initVulkan
173  bool setupDebugCallbacks();
174 
175  bool setupCommandPool();
176  bool setupDescriptorPool();
177 
178  bool VKRenderer::setupSwapchainFunctions();
179 
180  };
181 
182  }
183  }
184 }
Definition: ht_vkrootlayout.h:30
Definition: ht_vkrenderer.h:34
Definition: ht_vkswapchain.h:55
Definition: ht_renderer.h:81
Definition: ht_renderer.h:69
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_color.h:19
Color class defining a 4-component color value.
Definition: ht_color.h:26
Vulkan device wrapper.
Definition: ht_vkdevice.h:29