aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-01-26 23:12:49 +0100
committerladevieq <ladevie.quentin@gmail.com>2021-01-26 23:12:49 +0100
commit1314f696a7861f3b1509c7f5c27d6b06bc22d5f1 (patch)
treedc438e1fe4f9c5503f984c00cac190a2cdb6268f /include
parentd3b08c7e8bf808281e32fdef5e5222fb6633a5d0 (diff)
Split vkinstance/vkdevice of renderer into context class
Diffstat (limited to 'include')
-rw-r--r--include/vk-context.hpp40
-rw-r--r--include/vk-renderer.hpp43
2 files changed, 46 insertions, 37 deletions
diff --git a/include/vk-context.hpp b/include/vk-context.hpp
new file mode 100644
index 0000000..405cd83
--- /dev/null
+++ b/include/vk-context.hpp
@@ -0,0 +1,40 @@
+#ifndef __VK_CONTEXT_HPP_
+#define __VK_CONTEXT_HPP_
+
+#include "vulkan-loader.hpp"
+#include "thirdparty/vk_mem_alloc.h"
+
+class vkcontext {
+ public:
+ vkcontext();
+
+ ~vkcontext();
+
+ VkInstance instance;
+
+ VkPhysicalDevice physical_device;
+ VkDevice device;
+
+ VmaAllocator allocator;
+
+ uint32_t queue_index;
+ VkQueue queue;
+
+ private:
+ void create_instance();
+
+ void create_debugger();
+
+ void create_device();
+
+ void create_memory_allocator();
+
+ void select_physical_device();
+
+ void select_queue();
+
+
+ VkDebugUtilsMessengerEXT debugMessenger;
+};
+
+#endif // !__VK_CONTEXT_HPP_
diff --git a/include/vk-renderer.hpp b/include/vk-renderer.hpp
index 5f70718..c13f029 100644
--- a/include/vk-renderer.hpp
+++ b/include/vk-renderer.hpp
@@ -3,12 +3,11 @@
#include <vector>
+#include "vk-context.hpp"
#include "vulkan-loader.hpp"
-#include "thirdparty/vk_mem_alloc.h"
-
-#include "window.hpp"
class input_data;
+class window;
class vkrenderer {
public:
@@ -16,27 +15,19 @@ class vkrenderer {
~vkrenderer();
- void compute();
+ void compute(uint32_t width, uint32_t height);
void recreate_swapchain();
struct input_data* mapped_data;
private:
- void create_instance();
-
- void create_debugger();
-
- void create_surface();
-
- void create_device();
+ void create_surface(window& wnd);
void create_swapchain();
void create_pipeline();
- void create_memory_allocator();
-
void create_command_buffers();
void create_descriptor_sets();
@@ -47,14 +38,8 @@ class vkrenderer {
void create_input_buffer(const input_data& inputs);
- void destroy_instance();
-
- void destroy_debugger();
-
void destroy_surface();
- void destroy_device();
-
void destroy_swapchain();
void destroy_swapchain_images();
@@ -63,8 +48,6 @@ class vkrenderer {
void destroy_command_buffers();
- void destroy_allocator();
-
void destroy_descriptor_sets();
void destroy_fences();
@@ -73,28 +56,16 @@ class vkrenderer {
void destroy_input_buffer();
- void select_physical_device();
-
- void select_compute_queue();
-
void update_descriptors_buffer();
void update_descriptors_image();
void handle_swapchain_result(VkResult function_result);
- uint32_t compute_queue_index;
- uint64_t frame_index = 0;
-
- VkInstance instance;
-
- VkDebugUtilsMessengerEXT debugMessenger;
+ vkcontext context;
- VkPhysicalDevice physical_device;
- VkDevice device;
- VkQueue compute_queue;
+ uint64_t frame_index = 0;
- VmaAllocator allocator;
VmaAllocation allocation;
VkBuffer compute_shader_buffer;
@@ -120,8 +91,6 @@ class vkrenderer {
std::vector<VkImage> swapchain_images;
std::vector<VkImageView> swapchain_images_views;
uint32_t current_image_index;
-
- window& wnd;
};
#endif // !__VK_RENDERER_HPP_