main
1#ifndef GOG_PIPELINE_H
2#define GOG_PIPELINE_H
3
4#include <vulkan/vulkan_core.h>
5#include "gogerr.h"
6
7
8
9typedef enum{
10 GOG_GRAPHICS_PIPELINE,
11 GOG_COMPUTE_PIPELINE
12} gog_pipeline_type;
13
14typedef struct {
15 VkDescriptorSet vk_set;
16
17 struct {
18 VkDescriptorSetLayout vk_layout;
19 size_t binding_c;
20 } layout;
21} gog_descriptor_set;
22
23typedef struct {
24 VkPushConstantRange vk_range;
25 void* p_data;
26 size_t size;
27} gog_push_constants;
28
29typedef struct {
30 VkBuffer vk_buffer;
31 VkBuffer vk_index_buffer;
32
33 struct {
34 VkVertexInputAttributeDescription* vk_attrs;
35 size_t attr_c;
36 size_t stride;
37 } layout;
38 struct
39 {
40 uint32_t index_c;
41 uint32_t instance_c;
42 uint32_t first_index;
43 int32_t v_offset;
44 }draw_i;
45} gog_vertex_buffer;
46
47typedef struct {
48 VkImage color_img;
49 VkImageView color_view;
50
51 VkImage depth_img;
52 VkImageView depth_view;
53
54 struct {
55 VkFormat color;
56 VkFormat depth;
57 VkSampleCountFlagBits samples;
58 VkExtent2D extent;
59 } format_i;
60} gog_canvas;
61
62
63typedef struct {
64 VkCullModeFlags cull_mode;
65 VkBool32 depth_test;
66} gog_raster_state;
67
68typedef enum {
69 GOG_MSAA_1 = VK_SAMPLE_COUNT_1_BIT,
70 GOG_MSAA_2 = VK_SAMPLE_COUNT_2_BIT,
71 GOG_MSAA_4 = VK_SAMPLE_COUNT_4_BIT,
72 GOG_MSAA_8 = VK_SAMPLE_COUNT_8_BIT
73} gog_msaa_level;
74
75typedef enum {
76 GOG_DYNAMIC_VIEWPORT = VK_DYNAMIC_STATE_VIEWPORT,
77 GOG_DYNAMIC_SCISSOR = VK_DYNAMIC_STATE_SCISSOR,
78 GOG_DYNAMIC_LINE_WIDTH = VK_DYNAMIC_STATE_LINE_WIDTH,
79 GOG_DYNAMIC_DEPTH_BIAS = VK_DYNAMIC_STATE_DEPTH_BIAS
80} gog_dynamic_state_flag;
81
82typedef struct {
83 gog_pipeline_type type;
84 VkDevice device;
85
86 gog_descriptor_set* descriptor_set;
87 gog_push_constants* push_constants;
88
89 uint32_t shader_c;
90 struct {
91 VkShaderModule mod;
92 VkShaderStageFlagBits stage;
93 } * shaders_p;
94
95 union {
96 struct {
97 gog_vertex_buffer* v_buff;
98 gog_canvas* canvas;
99 gog_raster_state* raster;
100 struct {
101 gog_dynamic_state_flag* states;
102 size_t count;
103 } dynamic;
104 } graphics;
105
106 struct {
107 size_t local_x, local_y, local_z;
108 } compute;
109 };
110} gog_pipeline_ci;
111
112typedef struct{
113
114 gog_pipeline_type type;
115 VkDevice vk_pipeline_device;
116 VkPipelineBindPoint vk_bind_point;
117 VkPipeline vk_pipeline;
118 VkPipelineLayout vk_pipeline_layout;
119
120} gog_pipeline_core;
121
122
123typedef struct {
124 gog_canvas * canvas;
125 gog_descriptor_set* resource;
126 gog_push_constants* push_constants;
127
128 VkViewport viewport;
129 VkRect2D scissor;
130
131 union {
132 gog_vertex_buffer* v_buff;
133 struct {
134 struct { uint32_t x, y, z; } group_c;
135 } dispatch;
136 };
137} gog_pipeline_i;
138
139
140typedef struct
141{
142 gog_pipeline_core * core;
143 gog_pipeline_i * info;
144
145} gog_pipeline;
146
147gog_result gog_create_pipeline_core(gog_pipeline_core * core, gog_pipeline_ci ci);
148
149#endif
150
151