Separate vulkan code into gpu module
This commit is contained in:
1 parent
51c01a2f9e
commit
d4214941b1
4 files changed
+311
-236
No files matched your search
@@ -0,0 +1,50 @@
|
||||
#ifndef GPU_H
|
||||
#define GPU_H
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define SWAPCHAIN_IMG_BUFFER_SIZE 4
|
||||
|
||||
typedef struct {
|
||||
float position[2], colour[3];
|
||||
} vertex_t;
|
||||
|
||||
typedef struct {
|
||||
VkInstance inst;
|
||||
VkSurfaceKHR surface;
|
||||
VkPhysicalDevice physical_dev;
|
||||
VkDevice dev;
|
||||
VkQueue queue;
|
||||
VkSwapchainKHR swapchain;
|
||||
VkExtent2D swapchain_extent;
|
||||
uint32_t swapchain_img_count;
|
||||
VkImageView swapchain_img_views[SWAPCHAIN_IMG_BUFFER_SIZE];
|
||||
VkFramebuffer framebuffers[SWAPCHAIN_IMG_BUFFER_SIZE];
|
||||
VkShaderModule vert_shader;
|
||||
VkShaderModule frag_shader;
|
||||
VkPipelineLayout pipeline_layout;
|
||||
VkRenderPass render_pass;
|
||||
VkPipeline pipeline;
|
||||
VkCommandPool cmd_pool;
|
||||
VkCommandBuffer cmd_buf;
|
||||
VkFence in_flight;
|
||||
VkSemaphore render_fin;
|
||||
VkSemaphore img_avail;
|
||||
VkBuffer vertex_buf;
|
||||
VkDeviceMemory vertex_buf_mem;
|
||||
size_t vertex_data_size;
|
||||
} gpu_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
const char *application_name;
|
||||
GLFWwindow *window;
|
||||
const vertex_t *vertex_data;
|
||||
size_t vertex_data_size;
|
||||
} gpu_config_t;
|
||||
|
||||
void gpu_init(gpu_ctx_t *ctx, const gpu_config_t *config);
|
||||
void gpu_cleanup(const gpu_ctx_t *ctx);
|
||||
void gpu_render(const gpu_ctx_t *ctx);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user