2024-10-09 14:31:30 -06:00
|
|
|
#ifndef PIPELINE_H
|
|
|
|
#define PIPELINE_H
|
|
|
|
|
|
|
|
#include "vulkan/vulkan_core.h"
|
|
|
|
#include "cglm/types.h"
|
2024-10-09 20:00:56 -06:00
|
|
|
#include "vk_mem_alloc.h"
|
|
|
|
#include "command.h"
|
2024-10-09 14:31:30 -06:00
|
|
|
|
|
|
|
typedef struct GraphicsPipelineStruct {
|
2024-10-09 20:00:56 -06:00
|
|
|
VkPipelineLayout layout;
|
|
|
|
VkPipeline pipeline;
|
2024-10-09 14:31:30 -06:00
|
|
|
} GraphicsPipeline;
|
|
|
|
|
2024-10-13 15:44:33 -06:00
|
|
|
typedef struct ColoredRectStruct {
|
2024-10-09 20:00:56 -06:00
|
|
|
vec3 pos;
|
|
|
|
vec2 size;
|
|
|
|
vec4 color;
|
2024-10-13 15:44:33 -06:00
|
|
|
} ColoredRect;
|
2024-10-09 20:00:56 -06:00
|
|
|
|
2024-10-13 15:44:33 -06:00
|
|
|
typedef struct UIUniformStruct {
|
2024-10-13 14:11:28 -06:00
|
|
|
mat4 screen;
|
2024-10-13 15:44:33 -06:00
|
|
|
} UIUniform;
|
|
|
|
|
2024-10-14 01:09:05 -06:00
|
|
|
typedef struct CharStruct {
|
2024-10-13 22:18:37 -06:00
|
|
|
vec3 pos;
|
|
|
|
vec2 size;
|
|
|
|
vec4 color;
|
|
|
|
uint32_t code;
|
2024-10-14 01:09:05 -06:00
|
|
|
} Char;
|
2024-10-13 22:18:37 -06:00
|
|
|
|
|
|
|
typedef struct FontUniformStruct {
|
2024-10-14 13:33:14 -06:00
|
|
|
uint32_t num_symbols;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
2024-10-14 14:16:59 -06:00
|
|
|
uint32_t space_width;
|
|
|
|
VkDeviceAddress symbol_list;
|
2024-10-13 22:18:37 -06:00
|
|
|
} FontUniform;
|
|
|
|
|
2024-10-14 13:33:14 -06:00
|
|
|
typedef struct SymbolInfoStruct {
|
|
|
|
uint32_t x;
|
|
|
|
uint32_t top;
|
|
|
|
uint32_t width;
|
|
|
|
} SymbolInfo;
|
|
|
|
|
2024-10-14 01:00:10 -06:00
|
|
|
typedef struct FontDataStruct {
|
|
|
|
FontUniform info;
|
2024-10-14 14:16:59 -06:00
|
|
|
uint16_t* codes;
|
2024-10-14 01:00:10 -06:00
|
|
|
} FontData;
|
|
|
|
|
|
|
|
typedef struct FontDescriptorStruct {
|
|
|
|
VmaAllocation uniform_memory;
|
|
|
|
VmaAllocation image_memory;
|
|
|
|
VkBuffer uniform;
|
|
|
|
VkImage image;
|
|
|
|
VkImageView view;
|
|
|
|
VkSampler sampler;
|
|
|
|
VkDescriptorSet set;
|
|
|
|
} FontDescriptor;
|
|
|
|
|
2024-10-13 15:44:33 -06:00
|
|
|
typedef struct UILayerStruct {
|
|
|
|
VkBuffer colored_rects;
|
|
|
|
uint32_t colored_rect_count;
|
2024-10-13 16:04:12 -06:00
|
|
|
|
|
|
|
VkBuffer textured_rects;
|
|
|
|
uint32_t textured_rect_count;
|
|
|
|
VkDescriptorSet textured_rect_descriptor;
|
|
|
|
|
|
|
|
VkBuffer texts;
|
|
|
|
uint32_t text_count;
|
2024-10-14 01:00:10 -06:00
|
|
|
FontDescriptor font;
|
2024-10-13 15:44:33 -06:00
|
|
|
} UILayer;
|
|
|
|
|
|
|
|
struct RectBuffer {
|
|
|
|
VkBuffer vertex;
|
|
|
|
VkBuffer index;
|
|
|
|
|
|
|
|
VmaAllocation vertex_memory;
|
|
|
|
VmaAllocation index_memory;
|
2024-10-09 14:31:30 -06:00
|
|
|
};
|
|
|
|
|
2024-10-13 20:27:09 -06:00
|
|
|
typedef struct UIContextStruct {
|
|
|
|
VkBuffer ui_descriptor_buffer;
|
|
|
|
VmaAllocation ui_descriptor_memory;
|
|
|
|
VkDescriptorSetLayout ui_descriptor_layout;
|
|
|
|
VkDescriptorPool ui_descriptor_pool;
|
|
|
|
VkDescriptorSet ui_descriptor_set;
|
|
|
|
|
2024-10-13 22:18:37 -06:00
|
|
|
VkDescriptorPool font_pool;
|
|
|
|
VkDescriptorSetLayout font_layout;
|
|
|
|
|
2024-10-13 20:27:09 -06:00
|
|
|
struct RectBuffer ui_rect;
|
|
|
|
GraphicsPipeline ui_pipeline_rect;
|
|
|
|
GraphicsPipeline ui_pipeline_text;
|
|
|
|
} UIContext;
|
|
|
|
|
|
|
|
VkResult init_pipelines(VkDevice device, VmaAllocator allocator, VkExtent2D swapchain_extent, VkRenderPass render_pass, Queue transfer_queue, VkCommandPool transfer_pool, UIContext* context);
|
2024-10-09 20:00:56 -06:00
|
|
|
|
2024-10-14 14:16:59 -06:00
|
|
|
VkResult create_text_descriptor(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayout layout, VkDescriptorPool pool, FontData* font, SymbolInfo* symbols, uint32_t* atlas, VkCommandPool transfer_pool, Queue transfer_queue, FontDescriptor* descriptor);
|
2024-10-14 01:00:10 -06:00
|
|
|
|
2024-10-09 14:31:30 -06:00
|
|
|
#endif
|